washbullet 0.3.1 → 0.4.0

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.
Files changed (55) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +3 -0
  3. data/.rspec +1 -1
  4. data/.travis.yml +3 -0
  5. data/README.md +61 -24
  6. data/Rakefile +6 -1
  7. data/lib/washbullet.rb +5 -0
  8. data/lib/washbullet/api.rb +3 -1
  9. data/lib/washbullet/api/contacts.rb +13 -3
  10. data/lib/washbullet/api/devices.rb +9 -3
  11. data/lib/washbullet/api/me.rb +1 -1
  12. data/lib/washbullet/api/pushes.rb +14 -55
  13. data/lib/washbullet/api/subscriptions.rb +17 -0
  14. data/lib/washbullet/{basic_authentication.rb → authorization.rb} +1 -1
  15. data/lib/washbullet/channel.rb +29 -0
  16. data/lib/washbullet/client.rb +18 -18
  17. data/lib/washbullet/contact.rb +35 -0
  18. data/lib/washbullet/device.rb +27 -0
  19. data/lib/washbullet/entity.rb +27 -0
  20. data/lib/washbullet/http_exception.rb +19 -14
  21. data/lib/washbullet/push.rb +27 -0
  22. data/lib/washbullet/pushable.rb +59 -0
  23. data/lib/washbullet/pushable/file.rb +55 -0
  24. data/lib/washbullet/pushable/link.rb +13 -0
  25. data/lib/washbullet/pushable/note.rb +13 -0
  26. data/lib/washbullet/request.rb +1 -1
  27. data/lib/washbullet/user.rb +9 -0
  28. data/lib/washbullet/version.rb +1 -1
  29. data/spec/fixtures/green.png +0 -0
  30. data/spec/spec_helper.rb +48 -68
  31. data/spec/vcr/Washbullet_API_Contacts/_contacts/Get_own_active_contacts.yml +48 -0
  32. data/spec/vcr/Washbullet_API_Devices/_devices/Get_own_active_devices.yml +50 -0
  33. data/spec/vcr/Washbullet_API_Me/_me/Get_the_self_information.yml +50 -0
  34. data/spec/vcr/Washbullet_API_Subscriptions/_channel_info/when_channel_is_existing/Get_information_about_a_channel.yml +49 -0
  35. data/spec/vcr/Washbullet_API_Subscriptions/_channel_info/when_channel_is_not_existing/raise_error.yml +49 -0
  36. data/spec/vcr/Washbullet_API_Subscriptions/_subscriptions/Get_list_subscriptions.yml +50 -0
  37. data/spec/vcr/Washbullet_Pushable_File/_push/.yml +170 -0
  38. data/spec/vcr/Washbullet_Pushable_Link/_push/.yml +52 -0
  39. data/spec/vcr/Washbullet_Pushable_Note/_push/.yml +51 -0
  40. data/spec/washbullet/api/contacts_spec.rb +15 -0
  41. data/spec/washbullet/api/devices_spec.rb +14 -0
  42. data/spec/washbullet/api/me_spec.rb +11 -0
  43. data/spec/washbullet/api/subscriptions_spec.rb +31 -0
  44. data/spec/washbullet/pushable/file_spec.rb +23 -0
  45. data/spec/washbullet/pushable/link_spec.rb +24 -0
  46. data/spec/washbullet/pushable/note_spec.rb +20 -0
  47. data/washbullet.gemspec +5 -1
  48. metadata +107 -29
  49. data/spec/fixtures/contacts.json +0 -16
  50. data/spec/fixtures/devices.json +0 -19
  51. data/spec/fixtures/push.json +0 -18
  52. data/spec/fixtures/pushes.json +0 -24
  53. data/spec/fixtures/upload_request.json +0 -14
  54. data/spec/fixtures/users.json +0 -31
  55. data/spec/washbullet/client_spec.rb +0 -9
@@ -0,0 +1,52 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: post
5
+ uri: https://api.pushbullet.com/v2/pushes
6
+ body:
7
+ encoding: UTF-8
8
+ string: body=Pushbullet+is+awesome&title=Check+it+out&type=link&url=https%3A%2F%2Fwww.pushbullet.com
9
+ headers:
10
+ Accept:
11
+ - application/json
12
+ User-Agent:
13
+ - Washbullet Ruby Gem 0.3.1
14
+ Content-Type:
15
+ - application/x-www-form-urlencoded
16
+ Authorization:
17
+ - Bearer <API_KEY>
18
+ Accept-Encoding:
19
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
20
+ response:
21
+ status:
22
+ code: 200
23
+ message: OK
24
+ headers:
25
+ X-Ratelimit-Limit:
26
+ - '16384'
27
+ X-Ratelimit-Remaining:
28
+ - '16369'
29
+ X-Ratelimit-Reset:
30
+ - '1431475410'
31
+ Content-Type:
32
+ - application/json; charset=utf-8
33
+ Date:
34
+ - Tue, 12 May 2015 23:42:39 GMT
35
+ Server:
36
+ - Google Frontend
37
+ Cache-Control:
38
+ - private
39
+ Accept-Ranges:
40
+ - none
41
+ Vary:
42
+ - Accept-Encoding
43
+ Transfer-Encoding:
44
+ - chunked
45
+ body:
46
+ encoding: UTF-8
47
+ string: '{"active":true,"iden":"<IDENTIFIER>","created":1431474159.0350842,"modified":1431474159.0388443,"type":"link","dismissed":false,"direction":"self","sender_iden":"ujDZntJ9gzY","sender_email":"hrysd22@gmail.com","sender_email_normalized":"hrysd22@gmail.com","sender_name":"Hiroshi
48
+ Yoshida","receiver_iden":"ujDZntJ9gzY","receiver_email":"hrysd22@gmail.com","receiver_email_normalized":"hrysd22@gmail.com","title":"Check
49
+ it out","body":"Pushbullet is awesome","url":"https://www.pushbullet.com"}'
50
+ http_version:
51
+ recorded_at: Tue, 12 May 2015 23:42:39 GMT
52
+ recorded_with: VCR 2.9.3
@@ -0,0 +1,51 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: post
5
+ uri: https://api.pushbullet.com/v2/pushes
6
+ body:
7
+ encoding: UTF-8
8
+ string: body=body&title=title&type=note
9
+ headers:
10
+ Accept:
11
+ - application/json
12
+ User-Agent:
13
+ - Washbullet Ruby Gem 0.3.1
14
+ Content-Type:
15
+ - application/x-www-form-urlencoded
16
+ Authorization:
17
+ - Bearer <API_KEY>
18
+ Accept-Encoding:
19
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
20
+ response:
21
+ status:
22
+ code: 200
23
+ message: OK
24
+ headers:
25
+ X-Ratelimit-Limit:
26
+ - '16384'
27
+ X-Ratelimit-Remaining:
28
+ - '16368'
29
+ X-Ratelimit-Reset:
30
+ - '1431475410'
31
+ Content-Type:
32
+ - application/json; charset=utf-8
33
+ Date:
34
+ - Tue, 12 May 2015 23:42:40 GMT
35
+ Server:
36
+ - Google Frontend
37
+ Cache-Control:
38
+ - private
39
+ Accept-Ranges:
40
+ - none
41
+ Vary:
42
+ - Accept-Encoding
43
+ Transfer-Encoding:
44
+ - chunked
45
+ body:
46
+ encoding: UTF-8
47
+ string: '{"active":true,"iden":"<IDENTIFIER>","created":1431474160.213009,"modified":1431474160.2159953,"type":"note","dismissed":false,"direction":"self","sender_iden":"ujDZntJ9gzY","sender_email":"hrysd22@gmail.com","sender_email_normalized":"hrysd22@gmail.com","sender_name":"Hiroshi
48
+ Yoshida","receiver_iden":"ujDZntJ9gzY","receiver_email":"hrysd22@gmail.com","receiver_email_normalized":"hrysd22@gmail.com","title":"title","body":"body"}'
49
+ http_version:
50
+ recorded_at: Tue, 12 May 2015 23:42:40 GMT
51
+ recorded_with: VCR 2.9.3
@@ -0,0 +1,15 @@
1
+ RSpec.describe Washbullet::API::Contacts do
2
+ describe '#contacts', :vcr do
3
+ let(:client) { Washbullet::Client.new(test_api_key) }
4
+
5
+ subject(:contacts) { client.contacts }
6
+
7
+ specify 'Get own active contacts' do
8
+ expect(contacts.first).to be_kind_of(Washbullet::Contact)
9
+ expect(
10
+ contacts.all? {|device| device.body['active'] }
11
+ ).to be_truthy
12
+ end
13
+ end
14
+ end
15
+
@@ -0,0 +1,14 @@
1
+ RSpec.describe Washbullet::API::Devices do
2
+ describe '#devices', :vcr do
3
+ let(:client) { Washbullet::Client.new(test_api_key) }
4
+
5
+ subject(:devices) { client.devices }
6
+
7
+ specify 'Get own active devices' do
8
+ expect(devices.first).to be_kind_of(Washbullet::Device)
9
+ expect(
10
+ devices.all? {|device| device.body['active'] }
11
+ ).to be_truthy
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,11 @@
1
+ RSpec.describe Washbullet::API::Me do
2
+ describe '#me', :vcr do
3
+ let(:client) { Washbullet::Client.new(test_api_key) }
4
+
5
+ subject(:me) { client.me }
6
+
7
+ specify 'Get the self information' do
8
+ expect(me).to be_kind_of(Washbullet::User)
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,31 @@
1
+ RSpec.describe Washbullet::API::Subscriptions do
2
+ let(:client) { Washbullet::Client.new(test_api_key) }
3
+
4
+ describe '#subscriptions', :vcr do
5
+ subject(:subscriptions) { client.subscriptions }
6
+
7
+ specify 'Get list subscriptions' do
8
+ expect(subscriptions.first).to be_kind_of(Washbullet::Channel)
9
+ end
10
+ end
11
+
12
+ describe '#channel_info', :vcr do
13
+ subject(:channel_info) { client.channel_info(tag) }
14
+
15
+ context 'when channel is existing' do
16
+ let(:tag) { 'docs-hrysd-org' }
17
+
18
+ specify 'Get information about a channel' do
19
+ expect(channel_info).to be_kind_of(Washbullet::Channel)
20
+ end
21
+ end
22
+
23
+ context 'when channel is not existing' do
24
+ let(:tag) { 'invalid' }
25
+
26
+ specify 'raise error' do
27
+ expect { channel_info }.to raise_error
28
+ end
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,23 @@
1
+ RSpec.describe Washbullet::Pushable::File do
2
+ describe '.push', :vcr do
3
+ let(:client) { Washbullet::Client.new(test_api_key) }
4
+
5
+ subject(:push) {
6
+ described_class.push(
7
+ client,
8
+ :device,
9
+ nil,
10
+ {
11
+ file_name: 'Green',
12
+ file_path: 'spec/fixtures/green.png',
13
+ body: 'Color is green'
14
+ }
15
+ )
16
+ }
17
+
18
+ specify do
19
+ expect(push).to be_kind_of(Washbullet::Push)
20
+ expect(push.type).to eq('file')
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,24 @@
1
+ RSpec.describe Washbullet::Pushable::Link do
2
+ describe '.push', :vcr do
3
+ let(:client) { Washbullet::Client.new(test_api_key) }
4
+
5
+ subject(:push) {
6
+ described_class.push(
7
+ client,
8
+ :device,
9
+ nil,
10
+ {
11
+ title: 'Check it out',
12
+ url: 'https://www.pushbullet.com',
13
+ body: 'Pushbullet is awesome'
14
+ }
15
+ )
16
+ }
17
+
18
+ specify do
19
+ expect(push).to be_kind_of(Washbullet::Push)
20
+ expect(push.type).to eq('link')
21
+ end
22
+ end
23
+ end
24
+
@@ -0,0 +1,20 @@
1
+ RSpec.describe Washbullet::Pushable::Note do
2
+ describe '.push', :vcr do
3
+ let(:client) { Washbullet::Client.new(test_api_key) }
4
+
5
+ subject(:push) {
6
+ described_class.push(
7
+ client,
8
+ :device,
9
+ nil,
10
+ {title: 'title', body: 'body'}
11
+ )
12
+ }
13
+
14
+ specify do
15
+ expect(push).to be_kind_of(Washbullet::Push)
16
+ expect(push.type).to eq('note')
17
+ expect(push.body['title']).to eq('title')
18
+ end
19
+ end
20
+ end
@@ -18,9 +18,13 @@ Gem::Specification.new do |gem|
18
18
  gem.require_paths = ['lib']
19
19
 
20
20
  gem.add_development_dependency 'bundler'
21
+ gem.add_development_dependency 'multi_json'
21
22
  gem.add_development_dependency 'pry'
22
23
  gem.add_development_dependency 'rake'
23
- gem.add_development_dependency 'rspec', '~> 3.0.0.beta2'
24
+ gem.add_development_dependency 'rspec', '~> 3.2.0'
25
+ gem.add_development_dependency 'rubocop'
26
+ gem.add_development_dependency 'vcr'
27
+ gem.add_development_dependency 'webmock'
24
28
 
25
29
  gem.add_dependency 'faraday', '~> 0.9.0'
26
30
  gem.add_dependency 'mime-types'
metadata CHANGED
@@ -1,97 +1,153 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: washbullet
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.1
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Hiroshi Yoshida
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-05-25 00:00:00.000000000 Z
11
+ date: 2015-05-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - '>='
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
19
  version: '0'
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - '>='
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: multi_json
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
25
39
  - !ruby/object:Gem::Version
26
40
  version: '0'
27
41
  - !ruby/object:Gem::Dependency
28
42
  name: pry
29
43
  requirement: !ruby/object:Gem::Requirement
30
44
  requirements:
31
- - - '>='
45
+ - - ">="
32
46
  - !ruby/object:Gem::Version
33
47
  version: '0'
34
48
  type: :development
35
49
  prerelease: false
36
50
  version_requirements: !ruby/object:Gem::Requirement
37
51
  requirements:
38
- - - '>='
52
+ - - ">="
39
53
  - !ruby/object:Gem::Version
40
54
  version: '0'
41
55
  - !ruby/object:Gem::Dependency
42
56
  name: rake
43
57
  requirement: !ruby/object:Gem::Requirement
44
58
  requirements:
45
- - - '>='
59
+ - - ">="
46
60
  - !ruby/object:Gem::Version
47
61
  version: '0'
48
62
  type: :development
49
63
  prerelease: false
50
64
  version_requirements: !ruby/object:Gem::Requirement
51
65
  requirements:
52
- - - '>='
66
+ - - ">="
53
67
  - !ruby/object:Gem::Version
54
68
  version: '0'
55
69
  - !ruby/object:Gem::Dependency
56
70
  name: rspec
57
71
  requirement: !ruby/object:Gem::Requirement
58
72
  requirements:
59
- - - ~>
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: 3.2.0
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: 3.2.0
83
+ - !ruby/object:Gem::Dependency
84
+ name: rubocop
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: vcr
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ - !ruby/object:Gem::Dependency
112
+ name: webmock
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ">="
60
116
  - !ruby/object:Gem::Version
61
- version: 3.0.0.beta2
117
+ version: '0'
62
118
  type: :development
63
119
  prerelease: false
64
120
  version_requirements: !ruby/object:Gem::Requirement
65
121
  requirements:
66
- - - ~>
122
+ - - ">="
67
123
  - !ruby/object:Gem::Version
68
- version: 3.0.0.beta2
124
+ version: '0'
69
125
  - !ruby/object:Gem::Dependency
70
126
  name: faraday
71
127
  requirement: !ruby/object:Gem::Requirement
72
128
  requirements:
73
- - - ~>
129
+ - - "~>"
74
130
  - !ruby/object:Gem::Version
75
131
  version: 0.9.0
76
132
  type: :runtime
77
133
  prerelease: false
78
134
  version_requirements: !ruby/object:Gem::Requirement
79
135
  requirements:
80
- - - ~>
136
+ - - "~>"
81
137
  - !ruby/object:Gem::Version
82
138
  version: 0.9.0
83
139
  - !ruby/object:Gem::Dependency
84
140
  name: mime-types
85
141
  requirement: !ruby/object:Gem::Requirement
86
142
  requirements:
87
- - - '>='
143
+ - - ">="
88
144
  - !ruby/object:Gem::Version
89
145
  version: '0'
90
146
  type: :runtime
91
147
  prerelease: false
92
148
  version_requirements: !ruby/object:Gem::Requirement
93
149
  requirements:
94
- - - '>='
150
+ - - ">="
95
151
  - !ruby/object:Gem::Version
96
152
  version: '0'
97
153
  description: Ruby client of Pushbullet API.
@@ -101,8 +157,9 @@ executables: []
101
157
  extensions: []
102
158
  extra_rdoc_files: []
103
159
  files:
104
- - .gitignore
105
- - .rspec
160
+ - ".gitignore"
161
+ - ".rspec"
162
+ - ".travis.yml"
106
163
  - Gemfile
107
164
  - LICENSE.txt
108
165
  - README.md
@@ -113,20 +170,41 @@ files:
113
170
  - lib/washbullet/api/devices.rb
114
171
  - lib/washbullet/api/me.rb
115
172
  - lib/washbullet/api/pushes.rb
116
- - lib/washbullet/basic_authentication.rb
173
+ - lib/washbullet/api/subscriptions.rb
174
+ - lib/washbullet/authorization.rb
175
+ - lib/washbullet/channel.rb
117
176
  - lib/washbullet/client.rb
177
+ - lib/washbullet/contact.rb
178
+ - lib/washbullet/device.rb
179
+ - lib/washbullet/entity.rb
118
180
  - lib/washbullet/http_exception.rb
119
181
  - lib/washbullet/parse_json.rb
182
+ - lib/washbullet/push.rb
183
+ - lib/washbullet/pushable.rb
184
+ - lib/washbullet/pushable/file.rb
185
+ - lib/washbullet/pushable/link.rb
186
+ - lib/washbullet/pushable/note.rb
120
187
  - lib/washbullet/request.rb
188
+ - lib/washbullet/user.rb
121
189
  - lib/washbullet/version.rb
122
- - spec/fixtures/contacts.json
123
- - spec/fixtures/devices.json
124
- - spec/fixtures/push.json
125
- - spec/fixtures/pushes.json
126
- - spec/fixtures/upload_request.json
127
- - spec/fixtures/users.json
190
+ - spec/fixtures/green.png
128
191
  - spec/spec_helper.rb
129
- - spec/washbullet/client_spec.rb
192
+ - spec/vcr/Washbullet_API_Contacts/_contacts/Get_own_active_contacts.yml
193
+ - spec/vcr/Washbullet_API_Devices/_devices/Get_own_active_devices.yml
194
+ - spec/vcr/Washbullet_API_Me/_me/Get_the_self_information.yml
195
+ - spec/vcr/Washbullet_API_Subscriptions/_channel_info/when_channel_is_existing/Get_information_about_a_channel.yml
196
+ - spec/vcr/Washbullet_API_Subscriptions/_channel_info/when_channel_is_not_existing/raise_error.yml
197
+ - spec/vcr/Washbullet_API_Subscriptions/_subscriptions/Get_list_subscriptions.yml
198
+ - spec/vcr/Washbullet_Pushable_File/_push/.yml
199
+ - spec/vcr/Washbullet_Pushable_Link/_push/.yml
200
+ - spec/vcr/Washbullet_Pushable_Note/_push/.yml
201
+ - spec/washbullet/api/contacts_spec.rb
202
+ - spec/washbullet/api/devices_spec.rb
203
+ - spec/washbullet/api/me_spec.rb
204
+ - spec/washbullet/api/subscriptions_spec.rb
205
+ - spec/washbullet/pushable/file_spec.rb
206
+ - spec/washbullet/pushable/link_spec.rb
207
+ - spec/washbullet/pushable/note_spec.rb
130
208
  - washbullet.gemspec
131
209
  homepage: https://github.com/hrysd/washbullet
132
210
  licenses:
@@ -138,17 +216,17 @@ require_paths:
138
216
  - lib
139
217
  required_ruby_version: !ruby/object:Gem::Requirement
140
218
  requirements:
141
- - - '>='
219
+ - - ">="
142
220
  - !ruby/object:Gem::Version
143
221
  version: '0'
144
222
  required_rubygems_version: !ruby/object:Gem::Requirement
145
223
  requirements:
146
- - - '>='
224
+ - - ">="
147
225
  - !ruby/object:Gem::Version
148
226
  version: '0'
149
227
  requirements: []
150
228
  rubyforge_project:
151
- rubygems_version: 2.0.3
229
+ rubygems_version: 2.2.2
152
230
  signing_key:
153
231
  specification_version: 4
154
232
  summary: Ruby client of Pushbullet API.