Class: GemStats::Fetcher
- Inherits:
-
Object
- Object
- GemStats::Fetcher
- Defined in:
- lib/gem_stats/fetcher.rb
Constant Summary collapse
- @@bulk_number =
50
Class Method Summary collapse
- .fetch_and_safe ⇒ Object
- .list(all_versions = false, prerelease = false) ⇒ Object
- .list_names ⇒ Object
Class Method Details
.fetch_and_safe ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/gem_stats/fetcher.rb', line 17 def self.fetch_and_safe = ProgressBar.new("Fetching gems", list.count) . = '#' threads = [] list_names.each_with_index do |name, index| threads << Thread.new(name) { |name| GemInfo.new(name).save } if threads.count == @@bulk_number threads.each(&:join) threads = [] .inc(bulk_number) end end threads.each(&:join) .inc(bulk_number) .finish end |
.list(all_versions = false, prerelease = false) ⇒ Object
9 10 11 |
# File 'lib/gem_stats/fetcher.rb', line 9 def self.list(all_versions = false, prerelease = false) @gem_list ||= ::Gem::SpecFetcher.new.list(all_versions, prerelease).values.flatten(1) end |
.list_names ⇒ Object
13 14 15 |
# File 'lib/gem_stats/fetcher.rb', line 13 def self.list_names @list_name ||= list.map(&:first).uniq.compact end |