adm 0.0.3 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/adm/message.rb +15 -3
- data/lib/adm/notification.rb +18 -0
- data/lib/adm/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 157d23ea74f4e8cbeb7ace057bee47f78988836c
|
4
|
+
data.tar.gz: 54e5242d199d9ebe544f90ada279cb8dcadc43a2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7a51fbd0c7a1c24fa4df47c94170aadecdb3610fea1e8294a2f116b89e2951f76376b8a83f275d95dcc7eb27f41270330d852e3e81fe4d068ce3aa9863bd5062
|
7
|
+
data.tar.gz: 8311112117490c63e2528f5cab044ec4ba66d5258adf3b8c0d51d9b1eb4f7c690b6c7d524ffc8cd5a6456c2f3e28c0a0dc62a9e559a144e619ea4bd8dee7f451
|
data/lib/adm/message.rb
CHANGED
@@ -11,11 +11,15 @@ class ADM::Message
|
|
11
11
|
tokens = tokens.first
|
12
12
|
end
|
13
13
|
|
14
|
-
tokens.
|
15
|
-
ADM::Notification.new(token,self)
|
14
|
+
notifications = tokens.collect do |token|
|
15
|
+
note = ADM::Notification.new(token,self)
|
16
|
+
note.queue(hydra)
|
17
|
+
note
|
16
18
|
end
|
17
19
|
|
18
20
|
hydra.run
|
21
|
+
|
22
|
+
notifications
|
19
23
|
end
|
20
24
|
|
21
25
|
def hydra
|
@@ -25,7 +29,15 @@ class ADM::Message
|
|
25
29
|
def compile
|
26
30
|
@json ||= begin
|
27
31
|
@compiled = true
|
28
|
-
|
32
|
+
data_to_compile = data.dup
|
33
|
+
|
34
|
+
if data[:data]
|
35
|
+
data_to_compile[:data] = MultiJson.dump(data[:data])
|
36
|
+
elsif data['data']
|
37
|
+
data_to_compile['data'] = MultiJson.dump(data['data'])
|
38
|
+
end
|
39
|
+
|
40
|
+
MultiJson.dump(data_to_compile)
|
29
41
|
end
|
30
42
|
end
|
31
43
|
end
|
data/lib/adm/notification.rb
CHANGED
@@ -34,6 +34,24 @@ class ADM::Notification
|
|
34
34
|
request.run
|
35
35
|
end
|
36
36
|
|
37
|
+
def success?
|
38
|
+
response.success?
|
39
|
+
end
|
40
|
+
|
41
|
+
def response
|
42
|
+
request.response
|
43
|
+
end
|
44
|
+
|
45
|
+
def reesponse_json
|
46
|
+
MultiJson.load(response.body) if response.headers['Content-type'] == 'application/json'
|
47
|
+
end
|
48
|
+
|
49
|
+
def error
|
50
|
+
if !success?
|
51
|
+
reesponse_json['reason']
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
37
55
|
def queue hydra
|
38
56
|
hydra.queue(self.request)
|
39
57
|
end
|
data/lib/adm/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: adm
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tal Atlas
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-09-
|
11
|
+
date: 2013-09-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|