Class: Undine

Inherits:
Object
  • Object
show all
Defined in:
lib/undine.rb,
lib/undine/version.rb,
lib/undine/configuration.rb

Defined Under Namespace

Classes: Configuration

Constant Summary collapse

VERSION =
'0.2.0'

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(configuration) ⇒ Undine

Returns a new instance of Undine.



21
22
23
# File 'lib/undine.rb', line 21

def initialize(configuration)
  @configuration = configuration
end

Class Method Details

.configurationObject



4
5
6
# File 'lib/undine/configuration.rb', line 4

def self.configuration
  @configuration ||= Configuration.new
end

.configure {|configuration| ... } ⇒ Object

Yields:



8
9
10
# File 'lib/undine/configuration.rb', line 8

def self.configure
  yield configuration
end

.loadObject



9
10
11
12
13
14
15
# File 'lib/undine.rb', line 9

def self.load
  at_exit do
    exception = $ERROR_INFO

    Undine.process(exception) unless exception.nil?
  end
end

.process(exception) ⇒ Object



17
18
19
# File 'lib/undine.rb', line 17

def self.process(exception)
  new(Undine.configuration).process(exception)
end

Instance Method Details

#process(exception) ⇒ Object



25
26
27
28
29
30
31
# File 'lib/undine.rb', line 25

def process(exception)
  return if ignore?(exception)

  url = "https://www.google.com/search?q=#{CGI.escape(query_message_from(exception))}"

  system "open '#{url}'"
end

#query_message_from(exception) ⇒ Object



33
34
35
# File 'lib/undine.rb', line 33

def query_message_from(exception)
  @configuration.query_message_from.call(exception)
end