Class: OmgPullRequest::Prowl

Inherits:
Object
  • Object
show all
Extended by:
Configuration::Helpers
Defined in:
lib/omg_pull_request/prowl.rb

Constant Summary collapse

PROWL_URL =
'https://api.prowlapp.com'
PROWL_PATH =
'/publicapi/add'

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Configuration::Helpers

delegate_config_to

Constructor Details

#initialize(attributes = Hash.new) ⇒ Prowl

Returns a new instance of Prowl.



8
9
10
11
12
# File 'lib/omg_pull_request/prowl.rb', line 8

def initialize(attributes=Hash.new)
  attributes.each do |attr, value|
    self.send("#{attr}=", value)
  end
end

Instance Attribute Details

#configurationObject

Returns the value of attribute configuration.



6
7
8
# File 'lib/omg_pull_request/prowl.rb', line 6

def configuration
  @configuration
end

#github_wrapperObject

Returns the value of attribute github_wrapper.



6
7
8
# File 'lib/omg_pull_request/prowl.rb', line 6

def github_wrapper
  @github_wrapper
end

#loggerObject

Returns the value of attribute logger.



6
7
8
# File 'lib/omg_pull_request/prowl.rb', line 6

def logger
  @logger
end

#runnerObject

Returns the value of attribute runner.



6
7
8
# File 'lib/omg_pull_request/prowl.rb', line 6

def runner
  @runner
end

Instance Method Details

#alert_all_relevant_people!(message, event) ⇒ Object



28
29
30
31
32
33
# File 'lib/omg_pull_request/prowl.rb', line 28

def alert_all_relevant_people!(message, event)
  notify_users(message, all_keys, { 
    :url   => runner.pull_request.html_url, 
    :event => event
  } )
end

#alert_author!(message, event) ⇒ Object



35
36
37
38
39
40
# File 'lib/omg_pull_request/prowl.rb', line 35

def alert_author!(message, event)
  notify_users(message, author_keys, {
    :url   => runner.pull_request.html_url,
    :event => event
  })
end

#notify_users(msg, keys = [], options = {}) ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/omg_pull_request/prowl.rb', line 14

def notify_users(msg, keys=[], options={})
  return if keys.blank?

  opts = {
    :application => prowl_application,
    :event => "notification",
    :description => msg
  }.merge( options )

  keys.each do |key|
    open_connection.post PROWL_PATH, opts.merge(:apikey => key)
  end
end