ermaker_ting 0.0.2 → 0.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/lib/ting.rb +2 -0
- data/lib/ting/all.rb +7 -0
- data/lib/ting/detail.rb +23 -0
- data/lib/ting/pushover.rb +4 -14
- data/lib/ting/version.rb +1 -1
- data/spec/lib/ting/all_spec.rb +17 -0
- data/spec/lib/ting/detail_spec.rb +26 -0
- data/spec/lib/ting/pushover_spec.rb +13 -34
- metadata +8 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e2fa214b9024b4eaaca75c4bdf4005be25b12316
|
4
|
+
data.tar.gz: 69ed22c6962f1b51d40577cd80d19b1517248f20
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 41536e8fc2156696fae6fdd41d40d1c8d468fc4cfb4ed4a42bd1aeb443a1756e4af5a68c2d4b6b58262dff335ddad7320cf531fde997538236472d9b158bdca9
|
7
|
+
data.tar.gz: d753fb8911a35070417ed172eb81e15e5108d68886db19bdd642005df51115c4803a59b41f4090c251e1f3d9806d2e3765d4194e920b32caf4331c3d99587cb6
|
data/Gemfile.lock
CHANGED
data/lib/ting.rb
CHANGED
data/lib/ting/all.rb
ADDED
data/lib/ting/detail.rb
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
require 'httparty'
|
2
|
+
|
3
|
+
module Ting
|
4
|
+
class Detail
|
5
|
+
@@options = {}
|
6
|
+
|
7
|
+
def self.config **options
|
8
|
+
@@options = options
|
9
|
+
end
|
10
|
+
|
11
|
+
def self.make **options
|
12
|
+
options = @@options.merge options
|
13
|
+
if options.has_key?(:detail) && options.has_key?(:detail_server)
|
14
|
+
options[:url] = HTTParty.post(
|
15
|
+
options[:detail_server],
|
16
|
+
body: {detail: options[:detail]}).body
|
17
|
+
end
|
18
|
+
options.delete :detail_server
|
19
|
+
options.delete:detail
|
20
|
+
options
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
data/lib/ting/pushover.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'httparty'
|
2
|
+
require 'ting/detail'
|
2
3
|
|
3
4
|
module Ting
|
4
5
|
class Pushover
|
@@ -8,25 +9,14 @@ module Ting
|
|
8
9
|
@@options = options
|
9
10
|
end
|
10
11
|
|
11
|
-
def notify **options
|
12
|
+
def self.notify **options
|
12
13
|
options = @@options.merge options
|
13
14
|
options = manipulate options
|
14
15
|
HTTParty.post('https://api.pushover.net/1/messages.json', body: options)
|
15
16
|
end
|
16
17
|
|
17
|
-
def
|
18
|
-
|
19
|
-
options[:url] = HTTParty.post(
|
20
|
-
options[:detail_server],
|
21
|
-
body: {detail: options[:detail]}).body
|
22
|
-
end
|
23
|
-
options.delete :detail_server
|
24
|
-
options.delete:detail
|
25
|
-
options
|
26
|
-
end
|
27
|
-
|
28
|
-
def manipulate **options
|
29
|
-
options = manipulate_detail options
|
18
|
+
def self.manipulate **options
|
19
|
+
options = Detail.make options
|
30
20
|
options
|
31
21
|
end
|
32
22
|
end
|
data/lib/ting/version.rb
CHANGED
@@ -0,0 +1,17 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'ting'
|
3
|
+
|
4
|
+
describe Ting::All do
|
5
|
+
describe '.notify' do
|
6
|
+
it 'works' do
|
7
|
+
[
|
8
|
+
{a:1},
|
9
|
+
{a:2},
|
10
|
+
{a:1, b:2},
|
11
|
+
].each do |arg|
|
12
|
+
Ting::Pushover.should_receive(:notify).with(arg).once.ordered
|
13
|
+
described_class.notify arg
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'ting'
|
3
|
+
require 'fake_web'
|
4
|
+
|
5
|
+
describe Ting::Detail do
|
6
|
+
describe '.make' do
|
7
|
+
before do
|
8
|
+
FakeWeb.allow_net_connect = false
|
9
|
+
FakeWeb.register_uri(
|
10
|
+
:post,
|
11
|
+
'http://detail.server.com/path',
|
12
|
+
body:'http://detail.server.com/path/1')
|
13
|
+
end
|
14
|
+
after do
|
15
|
+
FakeWeb.clean_registry
|
16
|
+
FakeWeb.allow_net_connect = true
|
17
|
+
end
|
18
|
+
|
19
|
+
it 'works with detail related options' do
|
20
|
+
described_class.make(
|
21
|
+
detail_server: 'http://detail.server.com/path',
|
22
|
+
detail:'test',
|
23
|
+
).should == {url: 'http://detail.server.com/path/1'}
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -3,7 +3,7 @@ require 'ting'
|
|
3
3
|
require 'fake_web'
|
4
4
|
|
5
5
|
describe Ting::Pushover do
|
6
|
-
describe '
|
6
|
+
describe '.notify' do
|
7
7
|
before do
|
8
8
|
FakeWeb.allow_net_connect = false
|
9
9
|
FakeWeb.register_uri(:post, 'https://api.pushover.net/1/messages.json', body:'')
|
@@ -14,50 +14,29 @@ describe Ting::Pushover do
|
|
14
14
|
end
|
15
15
|
|
16
16
|
it 'gets valid options' do
|
17
|
-
|
17
|
+
described_class.notify
|
18
18
|
FakeWeb.last_request.body.should == ''
|
19
|
-
|
19
|
+
described_class.notify(a:1)
|
20
20
|
FakeWeb.last_request.body.should == 'a=1'
|
21
21
|
Ting::Pushover.config(a:1)
|
22
|
-
|
22
|
+
described_class.notify(a:1)
|
23
23
|
FakeWeb.last_request.body.should == 'a=1'
|
24
|
-
|
24
|
+
described_class.notify(a:2)
|
25
25
|
FakeWeb.last_request.body.should == 'a=2'
|
26
|
-
|
26
|
+
described_class.notify(b:2)
|
27
27
|
FakeWeb.last_request.body.should == 'a=1&b=2'
|
28
28
|
end
|
29
29
|
|
30
|
-
it 'calls
|
31
|
-
|
32
|
-
|
30
|
+
it 'calls .manipulate' do
|
31
|
+
described_class.should_receive(:manipulate).once
|
32
|
+
described_class.notify
|
33
33
|
end
|
34
34
|
end
|
35
35
|
|
36
|
-
describe '
|
37
|
-
it 'calls
|
38
|
-
|
39
|
-
|
40
|
-
end
|
41
|
-
end
|
42
|
-
|
43
|
-
describe '#manipulate_detail' do
|
44
|
-
before do
|
45
|
-
FakeWeb.allow_net_connect = false
|
46
|
-
FakeWeb.register_uri(
|
47
|
-
:post,
|
48
|
-
'http://detail.server.com/path',
|
49
|
-
body:'http://detail.server.com/path/1')
|
50
|
-
end
|
51
|
-
after do
|
52
|
-
FakeWeb.clean_registry
|
53
|
-
FakeWeb.allow_net_connect = true
|
54
|
-
end
|
55
|
-
|
56
|
-
it 'works with detail related options' do
|
57
|
-
subject.manipulate(
|
58
|
-
detail_server: 'http://detail.server.com/path',
|
59
|
-
detail:'test',
|
60
|
-
).should == {url: 'http://detail.server.com/path/1'}
|
36
|
+
describe '.manipulate' do
|
37
|
+
it 'calls Ting::Detail.make' do
|
38
|
+
Ting::Detail.should_receive(:make).once
|
39
|
+
described_class.manipulate
|
61
40
|
end
|
62
41
|
end
|
63
42
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ermaker_ting
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Minwoo Lee
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-03-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: httparty
|
@@ -168,8 +168,12 @@ files:
|
|
168
168
|
- README.md
|
169
169
|
- Rakefile
|
170
170
|
- lib/ting.rb
|
171
|
+
- lib/ting/all.rb
|
172
|
+
- lib/ting/detail.rb
|
171
173
|
- lib/ting/pushover.rb
|
172
174
|
- lib/ting/version.rb
|
175
|
+
- spec/lib/ting/all_spec.rb
|
176
|
+
- spec/lib/ting/detail_spec.rb
|
173
177
|
- spec/lib/ting/pushover_spec.rb
|
174
178
|
- spec/spec_helper.rb
|
175
179
|
- ting.gemspec
|
@@ -198,5 +202,7 @@ signing_key:
|
|
198
202
|
specification_version: 4
|
199
203
|
summary: ''
|
200
204
|
test_files:
|
205
|
+
- spec/lib/ting/all_spec.rb
|
206
|
+
- spec/lib/ting/detail_spec.rb
|
201
207
|
- spec/lib/ting/pushover_spec.rb
|
202
208
|
- spec/spec_helper.rb
|