ruby-pushbullet 0.1.1 → 0.1.2

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: 24ea52ae23543f776f27e23032a60b5009f74eb4
4
- data.tar.gz: ff625189e17d3e6c2c60dfa1ceee179bedc505b6
3
+ metadata.gz: b49aed8fdb5c64e3c4253a1c9fe1d84b411867ee
4
+ data.tar.gz: 8ba43ab44197cdfb6ff915d833d9b08f963f5322
5
5
  SHA512:
6
- metadata.gz: 17e97ccc4e0fa09785bd82215ab70b98c8308b2595cba1fff7a7c773369f0f6ae1df2489327b295adebe04a610b16cca0bdfe33febf59d876efa17d06b1faa90
7
- data.tar.gz: 8faa04548d1bc4f5aab466fa3871d8f4787a967e3468a211c0ec1f5fa4b93d3260531ef7e93278a63b0339e5f035d523ad4e8f6bb296f14577abfc7a380dc92e
6
+ metadata.gz: 756bad7f9044dab161ee878f19777575dbb98f4ea8167764e55c8d2bd054d9e4fce1bf2e3f379718f39d8378b91026569927bbc3fdee9152734e3178f254dbd8
7
+ data.tar.gz: c03faae1c2fecd83e06d388e540b3d61131797e3720afe757fafe74eb550772d560ba1db9edc4abd83af82d12d17a6525163dc4f4ef9046db0e0e4347190f45a
data/README.md CHANGED
@@ -55,7 +55,27 @@ device.save #update
55
55
 
56
56
  ### Push
57
57
 
58
- DOC TODO...
58
+ ```ruby
59
+ # Id can be an device id or a email
60
+
61
+ Pushbullet::Push.create_note(id, title, body)
62
+ Pushbullet::Push.create_link(id, title, url, body)
63
+ Pushbullet::Push.create_address(id, name, address)
64
+ Pushbullet::Push.create_list(id, title, items)
65
+ ```
66
+
67
+ **Or directly from a device or a contact**
68
+
69
+ ```ruby
70
+ me = Pushbullet::Contact.me
71
+ me.push_note(title, body)
72
+
73
+ # or...
74
+
75
+ device = Pushbullet::Device.all.first
76
+ device.push_link(title, link, body)
77
+
78
+ ```
59
79
 
60
80
  ### Channel
61
81
 
@@ -1,6 +1,22 @@
1
1
  module Pushbullet
2
2
  class Push < Resource
3
3
 
4
+ def self.create_note(id, title, body)
5
+ create :note, id, title: title, body: body
6
+ end
7
+
8
+ def self.create_link(id, title, url, body)
9
+ create :link, id, title: title, url: url, body: body
10
+ end
11
+
12
+ def self.create_address(id, name, address)
13
+ create :address, id, name: name, address: address
14
+ end
15
+
16
+ def self.create_list(id, title, items)
17
+ create :list, id, title: title, items: items
18
+ end
19
+
4
20
  def self.create(type, iden, payload)
5
21
  id = iden[/.@.?/].nil? ? :device_iden : :email
6
22
  super(payload.merge(type: type, id => iden))
@@ -2,19 +2,19 @@ module Pushbullet
2
2
  module Pushable
3
3
 
4
4
  def push_note(title, body)
5
- Push.create :note, target_id, title: title, body: body
5
+ Push.create_note target_id, title, body
6
6
  end
7
7
 
8
8
  def push_link(title, url, body)
9
- Push.create :link, target_id, title: title, url: url, body: body
9
+ Push.create_link target_id, title, url, body
10
10
  end
11
11
 
12
12
  def push_address(name, address)
13
- Push.create :address, target_id, name: name, address: address
13
+ Push.create_address target_id, name, address
14
14
  end
15
15
 
16
16
  def push_list(title, items)
17
- Push.create :list, target_id, title: title, items: items
17
+ Push.create_list target_id, title, items
18
18
  end
19
19
  end
20
20
  end
@@ -0,0 +1,57 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: post
5
+ uri: https://DhOX5Q8Fps9mq4g90yfrfioRPyo1qQRd:@api.pushbullet.com/v2/pushes
6
+ body:
7
+ encoding: US-ASCII
8
+ string: title=Le%20title&body=Le%20body&type=note&email=letzdevelopment%40gmail.com
9
+ headers:
10
+ Accept:
11
+ - "*/*; q=0.5, application/xml"
12
+ Accept-Encoding:
13
+ - gzip, deflate
14
+ Content-Length:
15
+ - '75'
16
+ Content-Type:
17
+ - application/x-www-form-urlencoded
18
+ User-Agent:
19
+ - Ruby
20
+ response:
21
+ status:
22
+ code: 200
23
+ message: OK
24
+ headers:
25
+ Content-Type:
26
+ - application/json; charset=utf-8
27
+ X-Ratelimit-Limit:
28
+ - '16384'
29
+ X-Ratelimit-Remaining:
30
+ - '16381'
31
+ X-Ratelimit-Reset:
32
+ - '1422834116'
33
+ Date:
34
+ - Sun, 01 Feb 2015 23:12:20 GMT
35
+ Server:
36
+ - Google Frontend
37
+ Cache-Control:
38
+ - private
39
+ Transfer-Encoding:
40
+ - chunked
41
+ body:
42
+ encoding: ASCII-8BIT
43
+ string: !binary |-
44
+ eyJhY3RpdmUiOnRydWUsImlkZW4iOiJ1akMyZjd6NnN2Y3NqQXlmRmN1Tm9H
45
+ IiwiY3JlYXRlZCI6MS40MjI4MzIzMzk5NzExNTZlKzA5LCJtb2RpZmllZCI6
46
+ MS40MjI4MzIzNDAwNDQwNTQ3ZSswOSwidHlwZSI6Im5vdGUiLCJkaXNtaXNz
47
+ ZWQiOmZhbHNlLCJzZW5kZXJfaWRlbiI6InVqQzJmN3o2c3ZjIiwic2VuZGVy
48
+ X2VtYWlsIjoicmljYXJkbzdybEBnbWFpbC5jb20iLCJzZW5kZXJfZW1haWxf
49
+ bm9ybWFsaXplZCI6InJpY2FyZG83cmxAZ21haWwuY29tIiwic2VuZGVyX25h
50
+ bWUiOiJSaWNhcmRvIExlaXTDo28iLCJyZWNlaXZlcl9pZGVuIjoidWpEeUlV
51
+ TFlyelUiLCJyZWNlaXZlcl9lbWFpbCI6ImxldHpkZXZlbG9wbWVudEBnbWFp
52
+ bC5jb20iLCJyZWNlaXZlcl9lbWFpbF9ub3JtYWxpemVkIjoibGV0emRldmVs
53
+ b3BtZW50QGdtYWlsLmNvbSIsInRpdGxlIjoiTGUgdGl0bGUiLCJib2R5Ijoi
54
+ TGUgYm9keSJ9
55
+ http_version:
56
+ recorded_at: Sun, 01 Feb 2015 23:12:20 GMT
57
+ recorded_with: VCR 2.9.3
@@ -0,0 +1,27 @@
1
+ require 'spec_helper'
2
+
3
+ describe Pushbullet::Push do
4
+ describe '::create_note' do
5
+ context 'given an id, a title and a body' do
6
+ let(:id) { 'letzdevelopment@gmail.com' }
7
+ let(:title) { 'Le title' }
8
+ let(:body) { 'Le body' }
9
+
10
+ it 'returns a Push' do
11
+ VCR.use_cassette('push_create_note') do
12
+ expect(described_class.create_note id, title, body).to be_a described_class
13
+ end
14
+ end
15
+ end
16
+ end
17
+
18
+ describe '::create_link' do
19
+
20
+ end
21
+
22
+ describe '::create_address' do
23
+
24
+ end
25
+
26
+ describe '::create_list'
27
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby-pushbullet
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ricardo Leitao
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-02-01 00:00:00.000000000 Z
11
+ date: 2015-02-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -217,8 +217,10 @@ files:
217
217
  - spec/fixtures/vcr_cassettes/devices_create.yml
218
218
  - spec/fixtures/vcr_cassettes/devices_remove.yml
219
219
  - spec/fixtures/vcr_cassettes/devices_update.yml
220
+ - spec/fixtures/vcr_cassettes/push_create_note.yml
220
221
  - spec/pushbullet/contact_spec.rb
221
222
  - spec/pushbullet/devices_spec.rb
223
+ - spec/pushbullet/push_spec.rb
222
224
  - spec/pushbullet_spec.rb
223
225
  - spec/spec_helper.rb
224
226
  - spec/support/factories.rb
@@ -255,8 +257,10 @@ test_files:
255
257
  - spec/fixtures/vcr_cassettes/devices_create.yml
256
258
  - spec/fixtures/vcr_cassettes/devices_remove.yml
257
259
  - spec/fixtures/vcr_cassettes/devices_update.yml
260
+ - spec/fixtures/vcr_cassettes/push_create_note.yml
258
261
  - spec/pushbullet/contact_spec.rb
259
262
  - spec/pushbullet/devices_spec.rb
263
+ - spec/pushbullet/push_spec.rb
260
264
  - spec/pushbullet_spec.rb
261
265
  - spec/spec_helper.rb
262
266
  - spec/support/factories.rb