Class: GhInspector::Inspector

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

Overview

To get started using The Issues Inspector, you will need to create an inspector instance. This class is main public API for querying issues.

Getting Started

Create an instance of GhInspector::Inspector, you can then ask it to search based on your raised exception, or as a direct query yourself.

require 'gh_inspector'
inspector = GhInspector::Inspector.new "orta", "eigen"
# Either use an error:
inspector.search_exception an_error, ArtsyUI.new
# Or use a specific query:
inspector.search_query "Someone set us up the bomb"

By default this would output:

Looking for related issues on CocoaPods/CocoaPods...

  - undefined method `to_ary' for #<Pod::Specification name="iVersion">Did you mean? to_query
    https://github.com/CocoaPods/CocoaPods/issues/4748 [closed] [1 comment]

  - NoMethodError - undefined method `to_ary' for Pod EAIntroView
    https://github.com/CocoaPods/CocoaPods/issues/4391 [closed] [15 comments]

  - Do a search on GitHub for issues relating to a crash?
    https://github.com/CocoaPods/CocoaPods/issues/4391 [open] [3 comments]

and 10 more at:
https://github.com/CocoaPods/CocoaPods/search?q=undefined+method+%60to_ary%27&type=Issues

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(repo_owner, repo_name, verbose: false) ⇒ Inspector

Init function with "orta", "project"



51
52
53
54
55
56
# File 'lib/gh_inspector/inspector.rb', line 51

def initialize(repo_owner, repo_name, verbose: false)
  self.repo_owner = repo_owner
  self.repo_name = repo_name
  self.verbose = verbose
  self.sidekick = Sidekick.new(self, repo_owner, repo_name)
end

Instance Attribute Details

#query ⇒ Object

Returns the value of attribute query.



42
43
44
# File 'lib/gh_inspector/inspector.rb', line 42

def query
  @query
end

#repo_name ⇒ Object

Returns the value of attribute repo_name.



42
43
44
# File 'lib/gh_inspector/inspector.rb', line 42

def repo_name
  @repo_name
end

#repo_owner ⇒ Object

Returns the value of attribute repo_owner.



42
43
44
# File 'lib/gh_inspector/inspector.rb', line 42

def repo_owner
  @repo_owner
end

#sidekick ⇒ Object

Returns the value of attribute sidekick.



42
43
44
# File 'lib/gh_inspector/inspector.rb', line 42

def sidekick
  @sidekick
end

#verbose ⇒ Object

Returns the value of attribute verbose.



42
43
44
# File 'lib/gh_inspector/inspector.rb', line 42

def verbose
  @verbose
end

Class Method Details

.from_slug(slug) ⇒ Object

Class init function with a "orta/project" style string



45
46
47
48
# File 'lib/gh_inspector/inspector.rb', line 45

def self.from_slug(slug)
  details = slug.split '/'
  Inspector.new details.first, details.last
end

Instance Method Details

#search_exception(exception, delegate = nil) ⇒ Object

Will do some magic to try and pull out a reasonable search query for an exception, then searches with that



60
61
62
63
# File 'lib/gh_inspector/inspector.rb', line 60

def search_exception(exception, delegate = nil)
  query = ExceptionHound.new(exception).query
  search_query(query, delegate)
end

#search_query(query, delegate = nil) ⇒ Object

Queries for an specific search string



66
67
68
69
# File 'lib/gh_inspector/inspector.rb', line 66

def search_query(query, delegate = nil)
  delegate ||= Evidence.new
  sidekick.search(query, delegate)
end