Class: AnyGood
- Inherits:
-
Object
- Object
- AnyGood
- Defined in:
- lib/any_good.rb,
lib/any_good/meters.rb
Defined Under Namespace
Constant Summary collapse
- GITHUB_URI_PATTERN =
%r{^https?://(www\.)?github\.com/}- T =
TimeMath
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Class Method Summary collapse
Instance Method Summary collapse
- #fetch ⇒ Object
-
#initialize(name) ⇒ AnyGood
constructor
A new instance of AnyGood.
- #report ⇒ Object
Constructor Details
#initialize(name) ⇒ AnyGood
Returns a new instance of AnyGood.
11 12 13 14 15 16 17 18 19 |
# File 'lib/any_good.rb', line 11 def initialize(name) @name = name @github_client = if (token = ENV['GITHUB_ACCESS_TOKEN']) Octokit::Client.new(access_token: token).tap { |client| client.user.login } else Octokit::Client.new end end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
9 10 11 |
# File 'lib/any_good.rb', line 9 def name @name end |
Class Method Details
.meters ⇒ Object
44 45 46 |
# File 'lib/any_good.rb', line 44 def self.meters @meters ||= [] end |
.metric(name, thresholds: nil, &block) ⇒ Object
48 49 50 |
# File 'lib/any_good.rb', line 48 def self.metric(name, thresholds: nil, &block) meters << Meter.new(name, thresholds, block) end |
Instance Method Details
#fetch ⇒ Object
23 24 25 26 27 28 29 30 31 |
# File 'lib/any_good.rb', line 23 def fetch gem_info = fetch_gem repo_id = detect_repo_id(*gem_info[:gem_info].values_at('source_code_uri', 'homepage_uri')) github_info = fetch_github(repo_id) @data = OpenStruct.new(gem_info.merge(github_info)) self end |
#report ⇒ Object
33 34 35 36 37 38 39 40 |
# File 'lib/any_good.rb', line 33 def report puts description self.class.meters.each do |meter| puts meter.call(@data).format end self end |