integrity-notifyio 0.1.3 → 0.1.4

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.3
1
+ 0.1.4
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{integrity-notifyio}
8
- s.version = "0.1.3"
8
+ s.version = "0.1.4"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Andrew Kalek"]
@@ -27,7 +27,6 @@ Gem::Specification.new do |s|
27
27
  "integrity-notifyio.gemspec",
28
28
  "lib/integrity/notifier/config.haml",
29
29
  "lib/integrity/notifier/notifyio.rb",
30
- "lib/integrity/notifier/notifyio_client.rb",
31
30
  "test/integrity-notifyio_test.rb",
32
31
  "test/test_helper.rb"
33
32
  ]
@@ -1,4 +1,6 @@
1
1
  require File.dirname(__FILE__) + '/notifyio_client.rb'
2
+ require 'httparty'
3
+ require 'md5'
2
4
 
3
5
  module Integrity
4
6
  class Notifier
@@ -10,12 +12,28 @@ module Integrity
10
12
  end
11
13
 
12
14
  def deliver!
13
- NotifyioClient.post(config['email'], config['api_key'], short_message, full_message)
15
+ post(config['email'], config['api_key'], short_message, full_message)
14
16
  end
15
17
 
16
18
  def to_s
17
19
  'Notifyio'
18
20
  end
21
+
22
+ private
23
+
24
+ def post(emails, api_key, title, body)
25
+ emails.split(',').each do |email|
26
+ email_hash = MD5.hexdigest(email.strip!)
27
+ HTTParty.post "http://api.notify.io/v1/notify/#{email_hash}?api_key=#{api_key}", :body => {
28
+ :type => 'regular',
29
+ :title => title,
30
+ :body => body,
31
+ :generator => 'integrity-notifyio notifier'
32
+ }
33
+
34
+ end
35
+ end
36
+
19
37
  end
20
38
 
21
39
  register Notifyio
@@ -28,12 +28,12 @@ class IntegrityNotifyioTest < Test::Unit::TestCase
28
28
  end
29
29
 
30
30
  [:successful, :failed, :pending].each do |status|
31
- should "post a notification to the tumblelog after completing a #{status} build" do
31
+ should "post a notification to notify.io after completing a #{status} build" do
32
32
  commit = Integrity::Commit.gen(status)
33
33
  config = { :email => "foo@example.org", :api_key => "key123" }
34
34
  notifier = Integrity::Notifier::Notifyio.new(commit, config)
35
35
 
36
- mock(Integrity::Notifier::NotifyioClient).post(config['email'], config['api_key'], notifier.short_message, notifier.full_message)
36
+ mock(Integrity::Notifier::Notifyio).post(config['email'], config['api_key'], notifier.short_message, notifier.full_message)
37
37
 
38
38
  notifier.deliver!
39
39
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: integrity-notifyio
3
3
  version: !ruby/object:Gem::Version
4
- hash: 29
4
+ hash: 19
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 1
9
- - 3
10
- version: 0.1.3
9
+ - 4
10
+ version: 0.1.4
11
11
  platform: ruby
12
12
  authors:
13
13
  - Andrew Kalek
@@ -80,7 +80,6 @@ files:
80
80
  - integrity-notifyio.gemspec
81
81
  - lib/integrity/notifier/config.haml
82
82
  - lib/integrity/notifier/notifyio.rb
83
- - lib/integrity/notifier/notifyio_client.rb
84
83
  - test/integrity-notifyio_test.rb
85
84
  - test/test_helper.rb
86
85
  has_rdoc: true
@@ -1,20 +0,0 @@
1
- require 'httparty'
2
- require 'md5'
3
- module Integrity
4
- class Notifier
5
- class NotifyioClient
6
- def self.post(emails, api_key, title, body)
7
- emails.split(',').each do |email|
8
- email_hash = MD5.hexdigest(email.strip!)
9
- HTTParty.post "http://api.notify.io/v1/notify/#{email_hash}?api_key=#{api_key}", :body => {
10
- :type => 'regular',
11
- :title => title,
12
- :body => body,
13
- :generator => 'integrity-notifyio notifier'
14
- }
15
-
16
- end
17
- end
18
- end
19
- end
20
- end