-
Notifications
You must be signed in to change notification settings - Fork 8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Regression and/or documentation lackage: cannot parse version from rubygems index #3
Comments
The only other code I can find which uses this for Gem Version is https://github.com/d9pouces/Moneta/blob/master/moneta/repositories/ruby.py and https://github.com/ATIX-AG/pulp_gem/blob/master/pulp_gem/specs.py written by @mdellweg , which may be also affected or might hold the answer for how to workaround this. |
You're right.
|
Still, what's the correct way to get |
Anyone only wanting a solution for Ruby versions, and only need py35+ support, https://github.com/dephell/dephell_specifier includes a fairly good Ruby version parser. |
@d9pouces do you need some help to fix this? (and as an aside, thank you ++ for this library 🙇 ) |
@jayvdb re:
Actually I have a tool that's about to be released at last that uses this for Gem Version too. |
@AMDmi3 I se you have something working now at https://github.com/repology/repology-updater/blob/dbc9445f8e156caf38cca0a67108684c9960355c/repology/parsers/parsers/rubygem.py ... using https://github.com/repology/repology-updater/blob/dbc9445f8e156caf38cca0a67108684c9960355c/requirements.txt#L11 |
I've mentioned it right in the issue. |
I got it to work with this class (It needs to inherit UsrMarshal, because it uses marshal_dump/load on the ruby side.): class GemVersion(UsrMarshal):
ruby_class_name = "Gem::Version"
@property
def version(self):
return self._private_data[0]
def __repr__(self):
return f"{self.ruby_class_name}('{self.version}')"
def __str__(self):
return f"{self.ruby_class_name}('{self.version}')"
def __eq__(self, other):
return isinstance(other, self.__class__) and self._private_data == self._private_data
rubymarshal.classes.registry.register(GemVersion) |
Here's a simple program to parse rubygems index I've successfully used with rubymarshal 1.0.3:
It's output with 1.0.3:
With 1.2.6 it looks like this
Nice thing is that unicode problem has gone, but bad thing is that custom object is no longer parsed.
At the very least, this requires major version bump.
Next, the documentation is not clean or wrong on how this can be parsed now. Changing it the way an example suggests:
doesn't change a thing.
In fact, this cannot work (at least with this data file), because
ClassRegistry
uses class names in form ofstr
s, but class name is read byReader.read
asSymbol("Gem::Version")
, which is hashed differently, soself.registry.get(class_name, UsrMarshal)
always returnsUsrMarshal
.I've solved this by using
ver.marshal_dump()
instead, but I don't think it's correct solution.The text was updated successfully, but these errors were encountered: