pushbullet_ruby 1.0.1 → 1.0.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: 2dae0e7808cbb8b26e29d8dce88ce2422717990c
4
- data.tar.gz: 524e45b761a5aabd47e3507c2506de08eb898477
3
+ metadata.gz: 872ee001c5e1440a6b53af23b8eb4ff79feae331
4
+ data.tar.gz: 3ab5d04e0c2f0982d17d93a736b64ecdaf19be64
5
5
  SHA512:
6
- metadata.gz: b8d4a658e59faf4c23b339d1560a0b64926b3b8661732334f7ca88060e047353a54c51dcec8e31dd9d520ae0d96436cb63b8df42e778f77e8473e4def7c37fa0
7
- data.tar.gz: 819e336ab483032124a92d56566360333560b754d5d253834f029bd12e44f056ae57d043510b7162b7b82ab97e9eb0c072b6a83b16f59220aab952dab69a84a6
6
+ metadata.gz: 14e84e7b703df31c4d736d162c7aac65bcead77dccd613c68ba16abb9cc41adaa51659c580b19d9d69668037cba386bba54ecfe4c9afd7feaceb18df77b65aca
7
+ data.tar.gz: 08dbeecedf08494a0d3c29306fdbc15cc3690a25cbff131041ad8dddbe0c0393b12b3c6b6dfaa5d6335b66901e3f4aef21ba8b5a40da15f2986d8b804ded5650
data/.gitignore CHANGED
@@ -7,3 +7,7 @@
7
7
  /pkg/
8
8
  /spec/reports/
9
9
  /tmp/
10
+ /.idea/
11
+ /bin/
12
+ /*.gem
13
+ /test.rb
data/README.md CHANGED
@@ -1,9 +1,5 @@
1
1
  # PushbulletRuby
2
2
 
3
- Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/pushbullet_ruby`. To experiment with that code, run `bin/console` for an interactive prompt.
4
-
5
- TODO: Delete this and the text above, and describe your gem
6
-
7
3
  ## Installation
8
4
 
9
5
  Add this line to your application's Gemfile:
@@ -11,31 +7,69 @@ Add this line to your application's Gemfile:
11
7
  ```ruby
12
8
  gem 'pushbullet_ruby'
13
9
  ```
14
-
15
- And then execute:
16
-
17
- $ bundle
18
-
19
- Or install it yourself as:
20
-
21
- $ gem install pushbullet_ruby
22
-
23
10
  ## Usage
24
11
 
25
- TODO: Write usage instructions here
26
-
27
- ## Development
28
-
29
- After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
12
+ ### Setup
13
+ Puts your api-key into a token.json file formatted like this:
14
+ ```ruby
15
+ {token: 'your api-key here'}
16
+ ```
17
+ And setup your client:
18
+ ```ruby
19
+ client = PushbulletRuby::Client.new(PushbulletRuby::Token.load)
20
+ ```
30
21
 
31
- To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
22
+ ### List devices
23
+ ```ruby
24
+ client.devices
25
+ ```
26
+ ### Update device informations
27
+ ```ruby
28
+ client.update_device(
29
+ id: 'device id',
30
+ params: {
31
+ nickname: 'device name'
32
+ }
33
+ )
34
+ ```
35
+ ### List contacts
36
+ ```ruby
37
+ client.contacts
38
+ ```
39
+ ### List subscriptions(channels)
40
+ ```ruby
41
+ client.subscriptions
42
+ ```
43
+ ### Get recent channel pushes
44
+ ```ruby
45
+ client.recent_pushes('channel tag')
46
+ ```
47
+ ### List pushes
48
+ ```ruby
49
+ client.pushes
50
+ ```
51
+ ### Push
52
+ You can send following list:
32
53
 
54
+ - note
55
+ - link
56
+ - file
57
+ ```ruby
58
+ client.push_note(
59
+ receiver: :device,
60
+ identifier: 'devide id',
61
+ params: {
62
+ title: 'Title',
63
+ body: 'Content'
64
+ }
65
+ )
66
+ ```
33
67
  ## Contributing
34
68
 
35
69
  Bug reports and pull requests are welcome on GitHub at https://github.com/creends/pushbullet_ruby.
36
70
 
37
71
 
38
- ## License
72
+ ##### This gem is inspired by [washbullet](https://github.com/hrysd/washbullet)
73
+
39
74
 
40
- The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
41
75
 
@@ -17,6 +17,10 @@ module PushbulletRuby
17
17
  def push_file(receiver: nil, identifier: nil, params: {})
18
18
  PushbulletRuby::Pushable::File.push(self, receiver, identifier, params)
19
19
  end
20
+
21
+ def pushes
22
+ PushbulletRuby::Push.from_response(get('/v2/pushes'))
23
+ end
20
24
  end
21
25
  end
22
26
  end
@@ -12,11 +12,9 @@ module PushbulletRuby
12
12
  end
13
13
 
14
14
  def recent_pushes(tag)
15
- pushes = []
16
- channel_info(tag).body['recent_pushes'].each do |push|
17
- pushes << PushbulletRuby::Push.new(push)
15
+ channel_info(tag).body['recent_pushes'].each_with_object([]) do |push, memo|
16
+ memo << PushbulletRuby::Push.new(push)
18
17
  end
19
- pushes
20
18
  end
21
19
  end
22
20
  end
@@ -18,5 +18,13 @@ module PushbulletRuby
18
18
  def tag
19
19
  body['tag']
20
20
  end
21
+
22
+ def name
23
+ body['name']
24
+ end
25
+
26
+ def id
27
+ body['iden']
28
+ end
21
29
  end
22
30
  end
@@ -8,5 +8,13 @@ module PushbulletRuby
8
8
  memo << new(attributes)
9
9
  end
10
10
  end
11
+
12
+ def name
13
+ body['name']
14
+ end
15
+
16
+ def email
17
+ body['email']
18
+ end
11
19
  end
12
20
  end
@@ -2,6 +2,13 @@ require 'pushbullet_ruby/entity'
2
2
 
3
3
  module PushbulletRuby
4
4
  class Push < Entity
5
+ def self.from_response(response)
6
+ response.body['pushes'].each_with_object([]) do |push, memo|
7
+ next unless push['active']
8
+ memo << new(push)
9
+ end
10
+ end
11
+
5
12
  def id
6
13
  body['iden']
7
14
  end
@@ -1,3 +1,3 @@
1
1
  module PushbulletRuby
2
- VERSION = "1.0.1"
2
+ VERSION = "1.0.2"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pushbullet_ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - creends
@@ -102,7 +102,6 @@ files:
102
102
  - lib/pushbullet_ruby/user.rb
103
103
  - lib/pushbullet_ruby/version.rb
104
104
  - pushbullet_ruby.gemspec
105
- - token.json
106
105
  homepage: https://github.com/creends/pushbullet_ruby
107
106
  licenses:
108
107
  - MIT
data/token.json DELETED
@@ -1 +0,0 @@
1
- {"token": "your api key here"}