Class: Gemometer::Notifiers::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/gemometer/notifiers/base.rb

Direct Known Subclasses

Hipchat, Mailgun, Slack

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(opts) ⇒ Base

Returns a new instance of Base.



11
12
13
14
15
16
# File 'lib/gemometer/notifiers/base.rb', line 11

def initialize(opts)
  @gems     = opts[:gems]
  @url      = opts[:url]
  @key      = opts[:key]
  @username = opts[:username]
end

Instance Attribute Details

#gemsObject (readonly)

Returns the value of attribute gems.



9
10
11
# File 'lib/gemometer/notifiers/base.rb', line 9

def gems
  @gems
end

#keyObject (readonly)

Returns the value of attribute key.



9
10
11
# File 'lib/gemometer/notifiers/base.rb', line 9

def key
  @key
end

#urlObject (readonly)

Returns the value of attribute url.



9
10
11
# File 'lib/gemometer/notifiers/base.rb', line 9

def url
  @url
end

#usernameObject (readonly)

Returns the value of attribute username.



9
10
11
# File 'lib/gemometer/notifiers/base.rb', line 9

def username
  @username
end

Class Method Details

.mandatory_optionsObject

Raises:

  • (NotImplementedError)


24
25
26
# File 'lib/gemometer/notifiers/base.rb', line 24

def self.mandatory_options
  raise NotImplementedError
end

Instance Method Details

#notifyObject



18
19
20
21
22
# File 'lib/gemometer/notifiers/base.rb', line 18

def notify
  return false if gems.empty?
  response = make_request
  %w(204 200).include?(response.code) || raise(Gemometer::NotifyError.new("#{response.code}: #{response.message}"))
end