
Research
/Security News
60 Malicious Ruby Gems Used in Targeted Credential Theft Campaign
A RubyGems malware campaign used 60 malicious packages posing as automation tools to steal credentials from social media and marketing tool users.
Supply Chain Security
Vulnerability
Quality
Maintenance
License
Natual sorting implementation in Ruby.
Add this line to your application's Gemfile:
gem "natural_sort"
And then execute:
$ bundle
Or install it yourself as:
$ gem install natural_sort
list = ["a10", "a", "a20", "a1b", "a1a", "a2", "a0", "a1"]
list.sort(&NaturalSort) # => ["a", "a0", "a1", "a1a", "a1b", "a2", "a10", "a20"]
list = ["a10", "a", "a20", "a1b", "a1a", "a2", "a0", "a1"]
NaturalSort.sort(list) # => ["a", "a0", "a1", "a1a", "a1b", "a2", "a10", "a20"]
list = ["a10", "a", "a20", "a1b", "a1a", "a2", "a0", "a1"]
NaturalSort.sort! list # => ["a", "a0", "a1", "a1a", "a1b", "a2", "a10", "a20"]
list # => ["a", "a0", "a1", "a1a", "a1b", "a2", "a10", "a20"]
UbuntuRelease = Struct.new(:number, :name)
ubuntu_releases = [
UbuntuRelease.new("9.04", "Jaunty Jackalope"),
UbuntuRelease.new("10.10", "Maverick Meerkat"),
UbuntuRelease.new("8.10", "Intrepid Ibex"),
UbuntuRelease.new("10.04.4", "Lucid Lynx"),
UbuntuRelease.new("9.10", "Karmic Koala"),
]
ubuntu_releases.sort_by { |v| NaturalSort(v.number) }
# => [
# UbuntuRelease.new("8.10", "Intrepid Ibex"),
# UbuntuRelease.new("9.04", "Jaunty Jackalope"),
# UbuntuRelease.new("9.10", "Karmic Koala"),
# UbuntuRelease.new("10.04.4", "Lucid Lynx"),
# UbuntuRelease.new("10.10", "Maverick Meerkat")
# ]
If you're running ruby 2.1 or newer, you can use refinements.
require "natural_sort/refinments"
class MyClass
using NaturalSort
list.natural_sort # => ["a", "a0", "a1", "a1a"...
ubuntu_releases.natural_sort_by(&:number) # => [ UbuntuRelease.new("8.10"...
end
Bug reports and pull requests are welcome on GitHub at https://github.com/rwz/natural_sort.
The gem is available as open source under the terms of the MIT License.
FAQs
Unknown package
We found that natural_sort demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
/Security News
A RubyGems malware campaign used 60 malicious packages posing as automation tools to steal credentials from social media and marketing tool users.
Security News
The CNA Scorecard ranks CVE issuers by data completeness, revealing major gaps in patch info and software identifiers across thousands of vulnerabilities.
Research
/Security News
Two npm packages masquerading as WhatsApp developer libraries include a kill switch that deletes all files if the phone number isn’t whitelisted.