ruby - How can I list all gems in rubygems.org? -
ruby - How can I list all gems in rubygems.org? -
recently diving tool gems.
a feature requires repos' address given gems list. want fetch gems info in rubygems.org, , store them local, instead of searching them each time. searching list of gem name cost much time.
however, not find response api in api page of rubygems.org. there apis search specific gem, or list gems owned guys. not 1 lists gems info in rubygems.org.
so, how can list gems in rubygems.org? there 3-party api that?
gem search
without argument homecoming total list of gems on rubygems.org. since urls on rubygems follows simple patterns can start playing around gem names simple class this:
class gemrepo attr_reader :names def initialize @names = [] load_names end def size @names.size end def urls @names.map { |name| "https://rubygems.org/gems/#{name}" } end private def load_names `gem search`.each_line |line| next if line.empty? || line.match(/\*/) @names << line.split().first end end end gem_repo = gemrepo.new gem_repo.size # => 88679 gem_repo.names # => ['-', '0mq', ..., 'zzzzz', 'zzzzzz'] gem_repo.urls # => ['https://rubygems.org/gems/-', 'https://rubygems.org/gems/0mq', ..., 'https://rubygems.org/gems/zzzzz', 'https://rubygems.org/gems/zzzzzz']
ruby gem
Comments
Post a Comment