pushmeup 0.1.0 → 0.1.1

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.
data/README.md CHANGED
@@ -166,24 +166,24 @@ You can use multiple keys to send notifications, to do it just do this changes i
166
166
  #### Usage
167
167
 
168
168
  # For single notification
169
- GCM.send_notification( destination, :identity => :key1 )
170
- # Empty notification
171
-
172
- GCM.send_notification( destination, data, :identity => :key1 )
173
- # Notification with custom information
174
-
175
- GCM.send_notification( destination, data, :collapse_key => "placar_score_global", :time_to_live => 3600, :delay_while_idle => false, :identity => :key1 )
176
- # Notification with custom information and parameters
177
-
169
+ GCM.send_notification( destination, :identity => :key1 )
170
+ # Empty notification
171
+
172
+ GCM.send_notification( destination, data, :identity => :key1 )
173
+ # Notification with custom information
174
+
175
+ GCM.send_notification( destination, data, :collapse_key => "placar_score_global", :time_to_live => 3600, :delay_while_idle => false, :identity => :key1 )
176
+ # Notification with custom information and parameters
177
+
178
178
  # For multiple notifications
179
179
  options1 = {}
180
180
  options2 = {..., :identity => :key2}
181
181
  n1 = GCM::Notification.new(destination1, data1, options1.merge({:identity => :key2}))
182
182
  n2 = GCM::Notification.new(destination2, data2, :identity => :key1)
183
- n3 = GCM::Notification.new(destination3, data3, options2)
184
-
185
- GCM.send_notifications( [n1, n2, n3] )
186
- # In this case, every notification has his own parameters, options and key
183
+ n3 = GCM::Notification.new(destination3, data3, options2)
184
+
185
+ GCM.send_notifications( [n1, n2, n3] )
186
+ # In this case, every notification has his own parameters, options and key
187
187
 
188
188
  ## Build Status [![Build Status](https://secure.travis-ci.org/NicosKaralis/pushmeup.png?branch=master)](http://travis-ci.org/NicosKaralis/pushmeup) [![Code Climate](https://codeclimate.com/badge.png)](https://codeclimate.com/github/NicosKaralis/pushmeup)
189
189
 
@@ -11,6 +11,15 @@ module GCM
11
11
 
12
12
  class << self
13
13
  attr_accessor :host, :format, :key
14
+
15
+ def key(identity = nil)
16
+ if @key.is_a?(Hash)
17
+ raise %{If your key is a hash of keys you'l need to pass a identifier to the notification!} if identity.nil?
18
+ return @key[identity]
19
+ else
20
+ return @key
21
+ end
22
+ end
14
23
  end
15
24
 
16
25
  def self.send_notification(device_tokens, data = {}, options = {})
@@ -50,7 +59,7 @@ module GCM
50
59
 
51
60
  def self.send_push_as_json(n)
52
61
  headers = {
53
- 'Authorization' => "key=#{ self.key.is_a?(Hash) ? self.key[n.identity] : self.key }",
62
+ 'Authorization' => "key=#{ self.key(n.identity) }",
54
63
  'Content-Type' => 'application/json',
55
64
  }
56
65
  body = {
@@ -67,7 +76,7 @@ module GCM
67
76
  raise "Still has to be done: http://developer.android.com/guide/google/gcm/gcm.html"
68
77
  headers = {
69
78
  # TODO: Aceitar key ser um hash
70
- 'Authorization' => "key=#{ self.key.is_a?(Hash) ? self.key[n.identity] : self.key }",
79
+ 'Authorization' => "key=#{ self.key(n.identity) }",
71
80
  'Content-Type' => 'application/x-www-form-urlencoded;charset=UTF-8',
72
81
  }
73
82
  return self.send_to_server(headers, body)
@@ -1,3 +1,3 @@
1
1
  module Pushmeup
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pushmeup
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -120,7 +120,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
120
120
  version: '0'
121
121
  segments:
122
122
  - 0
123
- hash: -2576380722783718588
123
+ hash: 3085707259142359060
124
124
  required_rubygems_version: !ruby/object:Gem::Requirement
125
125
  none: false
126
126
  requirements:
@@ -129,7 +129,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
129
129
  version: '0'
130
130
  segments:
131
131
  - 0
132
- hash: -2576380722783718588
132
+ hash: 3085707259142359060
133
133
  requirements: []
134
134
  rubyforge_project: pushmeup
135
135
  rubygems_version: 1.8.24