Class: HowIs::Fetcher
- Inherits:
-
Object
- Object
- HowIs::Fetcher
- Includes:
- Contracts::Core
- Defined in:
- lib/how_is/fetcher.rb
Overview
Fetches data from GitHub.
Defined Under Namespace
Classes: Results
Class Method Summary collapse
-
.default_github_instance ⇒ Object
TODO: Fix this bullshit.
Instance Method Summary collapse
- #call(repository, github = nil, pulse = nil) ⇒ Object
-
#String ⇒ Object
Fetches repository information from GitHub and returns a Results object.
Class Method Details
.default_github_instance ⇒ Object
TODO: Fix this bullshit. :nodoc:
17 18 19 20 21 |
# File 'lib/how_is/fetcher.rb', line 17 def self.default_github_instance Github.new(auto_pagination: true) do |config| config.basic_auth = ENV["HOWIS_BASIC_AUTH"] if ENV["HOWIS_BASIC_AUTH"] end end |
Instance Method Details
#call(repository, github = nil, pulse = nil) ⇒ Object
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/how_is/fetcher.rb', line 45 def call(repository, github = nil, pulse = nil) github ||= self.class.default_github_instance pulse ||= HowIs::Pulse.new(repository) user, repo = repository.split("/", 2) unless user && repo raise HowIs::CLI::OptionsError, "To generate a report from GitHub, " \ "provide the repository " \ "username/project. Quitting!" end issues = github.issues.list user: user, repo: repo pulls = github.pulls.list user: user, repo: repo summary = pulse.html_summary Results.new( repository, obj_to_array_of_hashes(issues), obj_to_array_of_hashes(pulls), summary ) end |