Class: Inspector::Evidence

Inherits:
Object
  • Object
show all
Defined in:
lib/evidence.rb

Overview

The default user interface for the inspector, its public API should be considered the protocol for other classes wanting to provide a user interface.

Your custom objects will be verified at runtime that they conform to the protocol.

You can see the default implmentation at [lib/evidence.rb](/orta/gh-issues-inspector/tree/master/lib/evidence.rb).

Both ‘search_query` and `search_exception` take your custom delegate as a 2nd optional parameter.

“‘ ruby require ’inspector’ inspector = Inspector::Inspector.new “orta”, “eigen” inspector.search_query “Someone set us up the bomb”, ArtsyUI.new “‘

Instance Method Summary collapse

Instance Method Details

#inspector_could_not_create_report(error, query, inspector) ⇒ Object

Called when there have been networking issues in creating the report.


45
46
47
48
49
# File 'lib/evidence.rb', line 45

def inspector_could_not_create_report(error, query, inspector)
  puts "Could not access the GitHub API, you may have better luck via the website."
  puts "https://github.com/#{inspector.repo_owner}/#{inspector.repo_name}/search?q=#{query}&type=Issues&utf8=✓"
  puts "Error: #{error.name}"
end

#inspector_recieved_empty_report(report, inspector) ⇒ Object

Called once the report has been recieved, but when there are no issues found.


39
40
41
42
# File 'lib/evidence.rb', line 39

def inspector_recieved_empty_report(report, inspector)
  puts "Found no similar issues. To create a new issue, please visit:"
  puts "https://github.com/#{inspector.repo_owner}/#{inspector.repo_name}/issues/new"
end

#inspector_started_query(query, inspector) ⇒ Object

Called just as the investigation has begun.


24
25
26
# File 'lib/evidence.rb', line 24

def inspector_started_query(query, inspector)
  puts "Looking for related issues on #{inspector.repo_owner}/#{inspector.repo_name}..."
end

#inspector_successfully_recieved_report(report, inspector) ⇒ Object

Called once the inspector has recieved a report with more than one issue.


29
30
31
32
33
34
35
36
# File 'lib/evidence.rb', line 29

def inspector_successfully_recieved_report(report, inspector)
  report.issues[0..2].each { |issue| print_issue_full(issue) }

  if report.issues.count > 3
    puts "and #{report.total_results - 3} more at:"
    puts report.url
  end
end