Class: Inspector::Sidekick
- Inherits:
-
Object
- Object
- Inspector::Sidekick
- Defined in:
- lib/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.
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.
Constructor Details
#initialize(inspector, repo_owner, repo_name) ⇒ Sidekick
Returns a new instance of Sidekick.
12 13 14 15 16 |
# File 'lib/sidekick.rb', line 12 def initialize(inspector, repo_owner, repo_name) self.inspector = inspector self.repo_owner = repo_owner self.repo_name = repo_name end |
Instance Attribute Details
#inspector ⇒ Object
Returns the value of attribute inspector.
10 11 12 |
# File 'lib/sidekick.rb', line 10 def inspector @inspector end |
#repo_name ⇒ Object
Returns the value of attribute repo_name.
10 11 12 |
# File 'lib/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/sidekick.rb', line 10 def repo_owner @repo_owner end |
Instance Method Details
#search(query, delegate) ⇒ Object
Searches for a query, with a UI delegate
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/sidekick.rb', line 19 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? delegate.inspector_successfully_recieved_report(report, inspector) else delegate.inspector_recieved_empty_report(report, inspector) end report end |