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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d9c0cb44f1419050f4e82cad7cfbe8b756305f2c
4
- data.tar.gz: 9c61d6b760ed5c751ac451cbad15aee35886b87c
3
+ metadata.gz: 157d23ea74f4e8cbeb7ace057bee47f78988836c
4
+ data.tar.gz: 54e5242d199d9ebe544f90ada279cb8dcadc43a2
5
5
  SHA512:
6
- metadata.gz: 3633188bf1bf5d1f4cc3959a9bb22af7c8ee6bba90b94e86467c9c17873cf3505e5433556cfd7994433d09dfac8b9745674b98b8e2b11aac3558c199b4d57b24
7
- data.tar.gz: da0ff6903cd6c93772c6dd767a4eb2db18b6dba5574b7213d339a2afb554a2ebf634245b5d61f49b27faf8f6b9e2b726a1202564ac1d9ab99f7fb98cb8a3c8ea
6
+ metadata.gz: 7a51fbd0c7a1c24fa4df47c94170aadecdb3610fea1e8294a2f116b89e2951f76376b8a83f275d95dcc7eb27f41270330d852e3e81fe4d068ce3aa9863bd5062
7
+ data.tar.gz: 8311112117490c63e2528f5cab044ec4ba66d5258adf3b8c0d51d9b1eb4f7c690b6c7d524ffc8cd5a6456c2f3e28c0a0dc62a9e559a144e619ea4bd8dee7f451
@@ -11,11 +11,15 @@ class ADM::Message
11
11
  tokens = tokens.first
12
12
  end
13
13
 
14
- tokens.each do |token|
15
- ADM::Notification.new(token,self).queue(hydra)
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
- MultiJson.dump(data)
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
@@ -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
@@ -1,3 +1,3 @@
1
1
  module ADM
2
- VERSION = "0.0.3"
2
+ VERSION = "0.0.5"
3
3
  end
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.3
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-25 00:00:00.000000000 Z
11
+ date: 2013-09-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler