Reputation: 5618
https://rubygems.org/api/v1/search.json
provides only 30 gems, but in my local machine I can get all gems using gem list --remote
.
I read http://guides.rubygems.org/rubygems-org-api/
, and an API which can get all gems in the list does not exist. How can I get the list via the web? Or, does anyone provide this?
I want the gem's name at a minimum but, if possible, I want to get the name and version.
I think gem list --remote
is via web, so I can get all gem lists.
Upvotes: 3
Views: 256
Reputation: 12826
You could use https://rubygems.org/latest_specs.4.8.gz
which returns gzipped marshal dumped array like this:
[["abscss", Gem::Version.new("0.0.1"), "ruby"],
["absee", Gem::Version.new("1.0"), "ruby"],
["absentee_camper", Gem::Version.new("0.0.7"), "ruby"],
["absgit", Gem::Version.new("0.3.0"), "ruby"],
["absinthe", Gem::Version.new("0.0.3"), "ruby"],
["absolute", Gem::Version.new("0.0.5"), "ruby"],
["AbsoluteRenamer", Gem::Version.new("1.1.2"), "ruby"],
["AbsoluteRenamer-date", Gem::Version.new("0.1.0"), "ruby"]]
But if you're in Ruby, I strongly recommend using the gem fetcher:
require 'rubygems/spec_fetcher'
fetcher = Gem::SpecFetcher.fetcher
tuples = fetcher.detect(:released) { true }
tuples
is now an array of tuples of [Gem::NameTuple, Gem::Remote]
. Some examples of what you can do with this:
tuples[1337][0].name # => GraphvizR
tuples[1337][0].version.to_s # => "0.1.0"
Upvotes: 12
Reputation: 11951
You can provide the page
query parameter to paginate through the list, e.g.:
https://rubygems.org/api/v1/search.json?query=main&page=2
Upvotes: 1