Class: GhInspector::Sidekick
- Inherits:
-
Object
- Object
- GhInspector::Sidekick
- Defined in:
- lib/gh_inspector/sidekick.rb
Overview
The Sidekick is the one who does all the real work. They take the query, get the GitHub API results, etc then pass them back to the inspector who gets the public API credit.
Instance Attribute Summary collapse
-
#inspector ⇒ Object
Returns the value of attribute inspector.
-
#repo_name ⇒ Object
Returns the value of attribute repo_name.
-
#repo_owner ⇒ Object
Returns the value of attribute repo_owner.
-
#using_deprecated_method ⇒ Object
Returns the value of attribute using_deprecated_method.
Instance Method Summary collapse
-
#initialize(inspector, repo_owner, repo_name) ⇒ Sidekick
constructor
A new instance of Sidekick.
-
#search(query, delegate) ⇒ Object
Searches for a query, with a UI delegate.
- #verbose ⇒ Object
Constructor Details
#initialize(inspector, repo_owner, repo_name) ⇒ Sidekick
Returns a new instance of Sidekick.
12 13 14 15 16 17 |
# File 'lib/gh_inspector/sidekick.rb', line 12 def initialize(inspector, repo_owner, repo_name) self.inspector = inspector self.repo_owner = repo_owner self.repo_name = repo_name self.using_deprecated_method = false end |
Instance Attribute Details
#inspector ⇒ Object
Returns the value of attribute inspector.
10 11 12 |
# File 'lib/gh_inspector/sidekick.rb', line 10 def inspector @inspector end |
#repo_name ⇒ Object
Returns the value of attribute repo_name.
10 11 12 |
# File 'lib/gh_inspector/sidekick.rb', line 10 def repo_name @repo_name end |
#repo_owner ⇒ Object
Returns the value of attribute repo_owner.
10 11 12 |
# File 'lib/gh_inspector/sidekick.rb', line 10 def repo_owner @repo_owner end |
#using_deprecated_method ⇒ Object
Returns the value of attribute using_deprecated_method.
10 11 12 |
# File 'lib/gh_inspector/sidekick.rb', line 10 def using_deprecated_method @using_deprecated_method end |
Instance Method Details
#search(query, delegate) ⇒ Object
Searches for a query, with a UI delegate
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/gh_inspector/sidekick.rb', line 20 def search(query, delegate) validate_delegate(delegate) delegate.inspector_started_query(query, inspector) url = url_for_request query begin results = get_api_results(url) rescue Timeout::Error, Errno::EINVAL, Errno::ECONNRESET, EOFError, Net::HTTPBadResponse, Net::HTTPHeaderSyntaxError, Net::ProtocolError => e delegate.inspector_could_not_create_report(e, query, inspector) return end report = parse_results query, results # TODO: progress callback if report.issues.any? if self.using_deprecated_method delegate.inspector_successfully_recieved_report(report, inspector) else delegate.inspector_successfully_received_report(report, inspector) end else # rubocop:disable Style/IfInsideElse if self.using_deprecated_method delegate.inspector_recieved_empty_report(report, inspector) else delegate.inspector_received_empty_report(report, inspector) end # rubocop:enable Style/IfInsideElse end report end |
#verbose ⇒ Object
56 57 58 |
# File 'lib/gh_inspector/sidekick.rb', line 56 def verbose self.inspector.verbose end |