Class: Gemometer::Notifiers::Base
- Inherits:
-
Object
- Object
- Gemometer::Notifiers::Base
- Defined in:
- lib/gemometer/notifiers/base.rb
Instance Attribute Summary collapse
-
#gems ⇒ Object
readonly
Returns the value of attribute gems.
-
#url ⇒ Object
readonly
Returns the value of attribute url.
Instance Method Summary collapse
-
#initialize(opts) ⇒ Base
constructor
A new instance of Base.
- #notify ⇒ Object
Constructor Details
#initialize(opts) ⇒ Base
Returns a new instance of Base.
11 12 13 14 |
# File 'lib/gemometer/notifiers/base.rb', line 11 def initialize(opts) @gems = opts[:gems] @url = opts[:url] end |
Instance Attribute Details
#gems ⇒ Object (readonly)
Returns the value of attribute gems.
9 10 11 |
# File 'lib/gemometer/notifiers/base.rb', line 9 def gems @gems end |
#url ⇒ Object (readonly)
Returns the value of attribute url.
9 10 11 |
# File 'lib/gemometer/notifiers/base.rb', line 9 def url @url end |
Instance Method Details
#notify ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/gemometer/notifiers/base.rb', line 16 def notify return false if gems.empty? uri = URI(url) http = Net::HTTP.new(uri.host, uri.port) http.use_ssl = (uri.scheme == "https") req = Net::HTTP::Post.new(uri) req.content_type = 'application/json' res = http.request(req, JSON.generate(data)) %w(204 200).include?(res.code) || raise(Gemometer::NotifyError.new("#{res.code}: #{res.}")) end |