Module: Ossert::Fetch
- Defined in:
- lib/ossert/fetch.rb,
lib/ossert/fetch/github.rb,
lib/ossert/fetch/bestgems.rb,
lib/ossert/fetch/rubygems.rb
Overview
Public: Various classes and methods for fetching data from different sources. Such as GitHub, Rubygems, Bestgems. Also provides simple functionality for fetching HTTP API.
Defined Under Namespace
Classes: Bestgems, BestgemsBase, BestgemsDailyStat, BestgemsTotalStat, GitHub, Rubygems, SimpleClient
Constant Summary collapse
- ALL_FETCHERS =
[Rubygems, Bestgems, GitHub].freeze
Class Method Summary collapse
-
.all(project) ⇒ Object
Public: Fetch data for project using all fetchers by default process method.
-
.only(fetchers, project, process = :process) ⇒ Object
Public: Fetch data for project using given fetchers by process method.
Class Method Details
.all(project) ⇒ Object
Public: Fetch data for project using all fetchers by default process method
project - The Ossert::Project instance to fill using fetchers
Examples
project = Ossert::Project.new('ramaze')
Ossert::Fetch.all(project)
project.dump
Returns nothing.
30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/ossert/fetch.rb', line 30 def all(project) ALL_FETCHERS.each do |fetcher| puts "======> with #{fetcher}..." time = Benchmark.realtime do fetcher.new(project).process end puts "<====== Finished in #{time.round(3)} sec." sleep(1) end nil rescue => e puts "Fetching Failed for '#{name}' with error: #{e.inspect}" puts e.backtrace end |
.only(fetchers, project, process = :process) ⇒ Object
Public: Fetch data for project using given fetchers by process method
fetchers - The Array or one of Ossert::Fetch::GitHub, Ossert::Fetch::Bestgems, Ossert::Fetch::Rubygems to
use for processing
project - The Ossert::Project instance to fill using fetchers process - The Symbol method name used for processing by fetchers (default: :process)
Examples
project = Ossert::Project.new('ramaze')
Ossert::Fetch.only(Ossert::Fetch::Rubygems, project, :process_meta)
project.dump_attribute :meta_data
Returns nothing.
60 61 62 63 64 65 66 67 68 69 70 71 |
# File 'lib/ossert/fetch.rb', line 60 def only(fetchers, project, process = :process) fetchers = Array.wrap(fetchers) puts "Fetching project '#{project.name}'..." (ALL_FETCHERS & fetchers).each do |fetcher| puts "======> with #{fetcher}..." time = Benchmark.realtime do fetcher.new(project).send(process) end puts "<====== Finished in #{time.round(3)} sec." sleep(1) end end |