github / version_sorter Goto Github PK
View Code? Open in Web Editor NEWFast sorting of version numbers
License: MIT License
Fast sorting of version numbers
License: MIT License
For example if I have a Tag class with an attribute name
, and an array tags
of objects of that class, currently I have to do something like this:
VersionSorter.sort(tags.map(&:name)).map do |tag_name|
tags.find { |tag| tag.name == tag_name }
end
... which is rather inefficient.
Implementing some kind of "sort by" could be really helpful.
Hi,
I am packaging version_sorter for Debian and have some doubts
Hope you help me. Thanks.
rb_version_sort_1
manually allocates/frees versions
which doesn't play nice with exceptions.
This is reasonably hard to hit but can be triggered by:
VersionSorter.sort(["1"]) { |x| raise 'oh noes' }
which causes an exception to be throw by rb_yield
:
version_sorter/ext/version_sorter/version_sorter.c
Lines 193 to 194 in fca9ae5
and
VersionSorter.sort ["\0"]
which causes an exception to be thrown by StringValueCStr
because it contains embedded NULs:
Given following example:
require 'version_sorter'
versions = %w( 1.0 1.1-täst)
versions.each do |v|
puts v.encoding
end
sorted = VersionSorter.rsort(versions)
sorted.each do |v|
puts v.encoding
end
Input, as well as out has same encoding.
Input and output have different encoding. The encoding is changed from UTF8
to ASCII-8BIT
UTF-8
UTF-8
ASCII-8BIT
ASCII-8BIT
I'm porting version_sorter to FreeBSD, and noticed that this repository does not contain any license information.
I suggest adding one (most ruby gems I've seen use MIT) for clarity.
Best
xmj
Hi @vmg I will need your help here please.
On "enable-travis" branch I've tried enabling Travis CI but it fails with errors:
All tests pass for me on these Ruby versions on Darwin except 1.8 which fails with:
Edyld: lazy symbol binding failed: Symbol not found: _RARRAY_AREF
Referenced from: /Users/mislav/github/version_sorter/lib/version_sorter.bundle
Expected in: flat namespace
dyld: Symbol not found: _RARRAY_AREF
Referenced from: /Users/mislav/github/version_sorter/lib/version_sorter.bundle
Expected in: flat namespace
I'm not adamant about 1.8 support but since it worked in the 1.1.1 version of this library I'm trying to see whether we can keep compatibility or official drop it.
And as for other Ruby versions, do you have an idea what's going on here?
Update and fine support
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.