zeppelin 0.2.0 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/zeppelin/version.rb +1 -1
- data/lib/zeppelin.rb +52 -1
- data/test/zeppelin_test.rb +82 -1
- metadata +68 -77
data/lib/zeppelin/version.rb
CHANGED
data/lib/zeppelin.rb
CHANGED
@@ -139,6 +139,49 @@ class Zeppelin
|
|
139
139
|
response = @connection.get(feedback_uri(since))
|
140
140
|
successful?(response) ? Yajl::Parser.parse(response.body) : nil
|
141
141
|
end
|
142
|
+
|
143
|
+
# Creates a tag that is not associated with any device
|
144
|
+
#
|
145
|
+
# @param [#to_s] name The name of the tag to add
|
146
|
+
#
|
147
|
+
# @return [Boolean] whether or not the request was successful
|
148
|
+
def add_tag(name)
|
149
|
+
response = @connection.put(tag_uri(name))
|
150
|
+
successful?(response)
|
151
|
+
end
|
152
|
+
|
153
|
+
# Removes a tag from the service
|
154
|
+
#
|
155
|
+
# @param [#to_s] name The name of the tag to remove
|
156
|
+
#
|
157
|
+
# @return [Boolean] true when the request was successful. Note that this
|
158
|
+
# method will return false if the tag has already been removed.
|
159
|
+
def remove_tag(name)
|
160
|
+
response = @connection.delete(tag_uri(name))
|
161
|
+
successful?(response)
|
162
|
+
end
|
163
|
+
|
164
|
+
# @param [String] device_token
|
165
|
+
#
|
166
|
+
# @param [#to_s] tag_name
|
167
|
+
#
|
168
|
+
# @return [Boolean] whether or not a tag was successfully associated with
|
169
|
+
# a device
|
170
|
+
def add_tag_to_device(device_token, tag_name)
|
171
|
+
response = @connection.put(device_tag_uri(device_token, tag_name))
|
172
|
+
successful?(response)
|
173
|
+
end
|
174
|
+
|
175
|
+
# @param [String] device_token
|
176
|
+
#
|
177
|
+
# @param [#to_s] tag_name
|
178
|
+
#
|
179
|
+
# @return [Boolean] whether or not a tag was successfully dissociated from
|
180
|
+
# a device
|
181
|
+
def remove_tag_from_device(device_token, tag_name)
|
182
|
+
response = @connection.delete(device_tag_uri(device_token, tag_name))
|
183
|
+
successful?(response)
|
184
|
+
end
|
142
185
|
|
143
186
|
private
|
144
187
|
|
@@ -153,10 +196,18 @@ class Zeppelin
|
|
153
196
|
def feedback_uri(since)
|
154
197
|
"/api/device_tokens/feedback/?since=#{since.utc.iso8601}"
|
155
198
|
end
|
199
|
+
|
200
|
+
def tag_uri(name)
|
201
|
+
"/api/tags/#{name}"
|
202
|
+
end
|
203
|
+
|
204
|
+
def device_tag_uri(device_token, tag_name)
|
205
|
+
device_token_uri(device_token) + "/tags/#{tag_name}"
|
206
|
+
end
|
156
207
|
|
157
208
|
def successful?(response)
|
158
209
|
SUCCESSFUL_STATUS_CODES.include?(response.status)
|
159
210
|
end
|
160
211
|
end
|
161
212
|
|
162
|
-
require 'zeppelin/version'
|
213
|
+
require 'zeppelin/version'
|
data/test/zeppelin_test.rb
CHANGED
@@ -303,9 +303,90 @@ class ZeppelinTest < Zeppelin::TestCase
|
|
303
303
|
response = @client.feedback(since)
|
304
304
|
assert_nil response
|
305
305
|
end
|
306
|
+
|
307
|
+
test '#add_tag' do
|
308
|
+
tag_name = 'chunky.bacon'
|
309
|
+
|
310
|
+
stub_requests @client.connection do |stub|
|
311
|
+
stub.put("/api/tags/#{tag_name}") do
|
312
|
+
[201, {}, '']
|
313
|
+
end
|
314
|
+
end
|
315
|
+
|
316
|
+
response = @client.add_tag(tag_name)
|
317
|
+
assert response
|
318
|
+
end
|
319
|
+
|
320
|
+
test '#remove_tag with an existing tag' do
|
321
|
+
tag_name = 'cats.pajamas'
|
322
|
+
|
323
|
+
stub_requests @client.connection do |stub|
|
324
|
+
stub.delete("/api/tags/#{tag_name}") do
|
325
|
+
[204, {}, '']
|
326
|
+
end
|
327
|
+
end
|
328
|
+
|
329
|
+
response = @client.remove_tag(tag_name)
|
330
|
+
assert response
|
331
|
+
end
|
332
|
+
|
333
|
+
test '#remove_tag with non-existant tag' do
|
334
|
+
tag_name = 'cats.pajamas'
|
335
|
+
|
336
|
+
stub_requests @client.connection do |stub|
|
337
|
+
stub.delete("/api/tags/#{tag_name}") do
|
338
|
+
[404, {}, 'Not Found']
|
339
|
+
end
|
340
|
+
end
|
341
|
+
|
342
|
+
response = @client.remove_tag(tag_name)
|
343
|
+
refute response
|
344
|
+
end
|
345
|
+
|
346
|
+
test '#add_tag_to_device' do
|
347
|
+
tag_name = 'radio.head'
|
348
|
+
device_token = 'CAFEBABE'
|
349
|
+
|
350
|
+
stub_requests @client.connection do |stub|
|
351
|
+
stub.put("/api/device_tokens/#{device_token}/tags/#{tag_name}") do
|
352
|
+
[201, {}, 'Created']
|
353
|
+
end
|
354
|
+
end
|
355
|
+
|
356
|
+
response = @client.add_tag_to_device(device_token, tag_name)
|
357
|
+
assert response
|
358
|
+
end
|
359
|
+
|
360
|
+
test '#remove_tag_from_device successfully' do
|
361
|
+
tag_name = 'martin.fowler'
|
362
|
+
device_token = 'DEADBEEF'
|
363
|
+
|
364
|
+
stub_requests @client.connection do |stub|
|
365
|
+
stub.delete("/api/device_tokens/#{device_token}/tags/#{tag_name}") do
|
366
|
+
[204, {}, 'No Content']
|
367
|
+
end
|
368
|
+
end
|
369
|
+
|
370
|
+
response = @client.remove_tag_from_device(device_token, tag_name)
|
371
|
+
assert response
|
372
|
+
end
|
373
|
+
|
374
|
+
test '#remove_tag_from_device unsuccessfully' do
|
375
|
+
tag_name = 'martin.fowler'
|
376
|
+
device_token = 'DEADBEEF'
|
377
|
+
|
378
|
+
stub_requests @client.connection do |stub|
|
379
|
+
stub.delete("/api/device_tokens/#{device_token}/tags/#{tag_name}") do
|
380
|
+
[404, {}, 'Not Found']
|
381
|
+
end
|
382
|
+
end
|
383
|
+
|
384
|
+
response = @client.remove_tag_from_device(device_token, tag_name)
|
385
|
+
refute response
|
386
|
+
end
|
306
387
|
|
307
388
|
def stub_requests(connection, &block)
|
308
389
|
connection.builder.handlers.delete(Faraday::Adapter::NetHttp)
|
309
390
|
connection.adapter(:test, &block)
|
310
391
|
end
|
311
|
-
end
|
392
|
+
end
|
metadata
CHANGED
@@ -1,94 +1,89 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: zeppelin
|
3
|
-
version: !ruby/object:Gem::Version
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.3.0
|
4
5
|
prerelease:
|
5
|
-
version: 0.2.0
|
6
6
|
platform: ruby
|
7
|
-
authors:
|
7
|
+
authors:
|
8
8
|
- Alexander Kern
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
dependencies:
|
16
|
-
- !ruby/object:Gem::Dependency
|
12
|
+
date: 2011-08-17 00:00:00.000000000Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
17
15
|
name: faraday
|
18
|
-
|
19
|
-
requirement: &id001 !ruby/object:Gem::Requirement
|
16
|
+
requirement: &2156462880 !ruby/object:Gem::Requirement
|
20
17
|
none: false
|
21
|
-
requirements:
|
22
|
-
- -
|
23
|
-
- !ruby/object:Gem::Version
|
24
|
-
version:
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
25
22
|
type: :runtime
|
26
|
-
version_requirements: *id001
|
27
|
-
- !ruby/object:Gem::Dependency
|
28
|
-
name: yajl-ruby
|
29
23
|
prerelease: false
|
30
|
-
|
24
|
+
version_requirements: *2156462880
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: yajl-ruby
|
27
|
+
requirement: &2156462460 !ruby/object:Gem::Requirement
|
31
28
|
none: false
|
32
|
-
requirements:
|
33
|
-
- -
|
34
|
-
- !ruby/object:Gem::Version
|
35
|
-
version:
|
29
|
+
requirements:
|
30
|
+
- - ! '>='
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '0'
|
36
33
|
type: :runtime
|
37
|
-
version_requirements: *id002
|
38
|
-
- !ruby/object:Gem::Dependency
|
39
|
-
name: minitest
|
40
34
|
prerelease: false
|
41
|
-
|
35
|
+
version_requirements: *2156462460
|
36
|
+
- !ruby/object:Gem::Dependency
|
37
|
+
name: minitest
|
38
|
+
requirement: &2156493440 !ruby/object:Gem::Requirement
|
42
39
|
none: false
|
43
|
-
requirements:
|
40
|
+
requirements:
|
44
41
|
- - ~>
|
45
|
-
- !ruby/object:Gem::Version
|
46
|
-
version:
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: '2.0'
|
47
44
|
type: :development
|
48
|
-
version_requirements: *id003
|
49
|
-
- !ruby/object:Gem::Dependency
|
50
|
-
name: journo
|
51
45
|
prerelease: false
|
52
|
-
|
46
|
+
version_requirements: *2156493440
|
47
|
+
- !ruby/object:Gem::Dependency
|
48
|
+
name: journo
|
49
|
+
requirement: &2156493020 !ruby/object:Gem::Requirement
|
53
50
|
none: false
|
54
|
-
requirements:
|
55
|
-
- -
|
56
|
-
- !ruby/object:Gem::Version
|
57
|
-
version:
|
51
|
+
requirements:
|
52
|
+
- - ! '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
58
55
|
type: :development
|
59
|
-
version_requirements: *id004
|
60
|
-
- !ruby/object:Gem::Dependency
|
61
|
-
name: mocha
|
62
56
|
prerelease: false
|
63
|
-
|
57
|
+
version_requirements: *2156493020
|
58
|
+
- !ruby/object:Gem::Dependency
|
59
|
+
name: mocha
|
60
|
+
requirement: &2156492560 !ruby/object:Gem::Requirement
|
64
61
|
none: false
|
65
|
-
requirements:
|
66
|
-
- -
|
67
|
-
- !ruby/object:Gem::Version
|
68
|
-
version:
|
62
|
+
requirements:
|
63
|
+
- - ! '>='
|
64
|
+
- !ruby/object:Gem::Version
|
65
|
+
version: '0'
|
69
66
|
type: :development
|
70
|
-
version_requirements: *id005
|
71
|
-
- !ruby/object:Gem::Dependency
|
72
|
-
name: test_declarative
|
73
67
|
prerelease: false
|
74
|
-
|
68
|
+
version_requirements: *2156492560
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: test_declarative
|
71
|
+
requirement: &2156492140 !ruby/object:Gem::Requirement
|
75
72
|
none: false
|
76
|
-
requirements:
|
77
|
-
- -
|
78
|
-
- !ruby/object:Gem::Version
|
79
|
-
version:
|
73
|
+
requirements:
|
74
|
+
- - ! '>='
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
version: '0'
|
80
77
|
type: :development
|
81
|
-
|
78
|
+
prerelease: false
|
79
|
+
version_requirements: *2156492140
|
82
80
|
description: Ruby client for the Urban Airship Push Notification API
|
83
|
-
email:
|
81
|
+
email:
|
84
82
|
- alex@kernul.com
|
85
83
|
executables: []
|
86
|
-
|
87
84
|
extensions: []
|
88
|
-
|
89
85
|
extra_rdoc_files: []
|
90
|
-
|
91
|
-
files:
|
86
|
+
files:
|
92
87
|
- .autotest
|
93
88
|
- .gitignore
|
94
89
|
- .travis.yml
|
@@ -102,34 +97,30 @@ files:
|
|
102
97
|
- test/test_helper.rb
|
103
98
|
- test/zeppelin_test.rb
|
104
99
|
- zeppelin.gemspec
|
105
|
-
has_rdoc: true
|
106
100
|
homepage: https://github.com/CapnKernul/zeppelin
|
107
101
|
licenses: []
|
108
|
-
|
109
102
|
post_install_message:
|
110
103
|
rdoc_options: []
|
111
|
-
|
112
|
-
require_paths:
|
104
|
+
require_paths:
|
113
105
|
- lib
|
114
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
106
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
115
107
|
none: false
|
116
|
-
requirements:
|
117
|
-
- -
|
118
|
-
- !ruby/object:Gem::Version
|
119
|
-
version:
|
120
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
108
|
+
requirements:
|
109
|
+
- - ! '>='
|
110
|
+
- !ruby/object:Gem::Version
|
111
|
+
version: '0'
|
112
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
121
113
|
none: false
|
122
|
-
requirements:
|
123
|
-
- -
|
124
|
-
- !ruby/object:Gem::Version
|
125
|
-
version:
|
114
|
+
requirements:
|
115
|
+
- - ! '>='
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0'
|
126
118
|
requirements: []
|
127
|
-
|
128
119
|
rubyforge_project: zeppelin
|
129
|
-
rubygems_version: 1.6
|
120
|
+
rubygems_version: 1.8.6
|
130
121
|
signing_key:
|
131
122
|
specification_version: 3
|
132
123
|
summary: Urban Airship library for Ruby
|
133
|
-
test_files:
|
124
|
+
test_files:
|
134
125
|
- test/test_helper.rb
|
135
126
|
- test/zeppelin_test.rb
|