lib/how_is/fetcher.rb in how_is-18.0.5 vs lib/how_is/fetcher.rb in how_is-18.1.0

- old
+ new

@@ -2,16 +2,26 @@ require "contracts" require "github_api" require "how_is/pulse" +C ||= Contracts + class HowIs ## # Fetches data from GitHub. class Fetcher include Contracts::Core + # TODO: Fix this bullshit. + # :nodoc: + 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 + ## # Standardized representation for fetcher results. # # Implemented as a class instead of passing around a Hash so that it can # be more easily referenced by Contracts. @@ -33,10 +43,10 @@ C::Or[C::RespondTo[:issues, :pulls], nil], C::Or[C::RespondTo[:html_summary], nil] => Results def call(repository, github = nil, pulse = nil) - github ||= Github.new(auto_pagination: true) + 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, " \