pushybullet 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +11 -0
- data/.rspec +3 -0
- data/.rubocop.yml +14 -0
- data/.rubocop_todo.yml +7 -0
- data/.travis.yml +6 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/Gemfile +11 -0
- data/Gemfile.lock +70 -0
- data/LICENSE.txt +21 -0
- data/README.md +46 -0
- data/Rakefile +8 -0
- data/bin/console +15 -0
- data/bin/setup +8 -0
- data/lib/pushybullet.rb +9 -0
- data/lib/pushybullet/client.rb +69 -0
- data/lib/pushybullet/concerns.rb +26 -0
- data/lib/pushybullet/errors.rb +27 -0
- data/lib/pushybullet/middleware/error.rb +18 -0
- data/lib/pushybullet/types.rb +8 -0
- data/lib/pushybullet/types/device.rb +25 -0
- data/lib/pushybullet/types/push.rb +35 -0
- data/lib/pushybullet/types/push_target.rb +25 -0
- data/lib/pushybullet/version.rb +5 -0
- data/pushybullet.gemspec +33 -0
- metadata +99 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 3dbd4aca0912df61b2a9d59d072c32e86ede352a9508ab948fb790ad4d6fd380
|
4
|
+
data.tar.gz: fa897f29ff17e1e8e70fbf01608a122e5fbb3ffbe91e195a4511cacd5b3355cb
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 387b62d51ab6554d27af2ee055660a06aa15ebc84753d50c39d8c09681d3f000c1e5d35519d0f09c684ff28e171bcec71e99a190ba3eb98452c5a46abcc86a6b
|
7
|
+
data.tar.gz: ac35d5f7aff6745312aba73f264129202dccb1d920c9f729c16e2c6fda0efdfb121c8847343dbd74949bffaab0c764a8dd6826a43b09688da07c9795af44c5e1
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.rubocop.yml
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
inherit_from: .rubocop_todo.yml
|
2
|
+
|
3
|
+
# The behavior of RuboCop can be controlled via the .rubocop.yml
|
4
|
+
# configuration file. It makes it possible to enable/disable
|
5
|
+
# certain cops (checks) and to alter their behavior if they accept
|
6
|
+
# any parameters. The file can be placed either in your home
|
7
|
+
# directory or in some project directory.
|
8
|
+
#
|
9
|
+
# RuboCop will start looking for the configuration file in the directory
|
10
|
+
# where the inspected file is and continue its way up to the root directory.
|
11
|
+
#
|
12
|
+
# See https://docs.rubocop.org/rubocop/configuration
|
13
|
+
AllCops:
|
14
|
+
NewCops: enable
|
data/.rubocop_todo.yml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
# This configuration was generated by
|
2
|
+
# `rubocop --auto-gen-config`
|
3
|
+
# on 2020-11-17 17:08:45 UTC using RuboCop version 1.3.1.
|
4
|
+
# The point is for the user to remove these configuration records
|
5
|
+
# one by one as the offenses are removed from the code base.
|
6
|
+
# Note that changes in the inspected code, or installation of new
|
7
|
+
# versions of RuboCop, may require this file to be generated again.
|
data/.travis.yml
ADDED
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,74 @@
|
|
1
|
+
# Contributor Covenant Code of Conduct
|
2
|
+
|
3
|
+
## Our Pledge
|
4
|
+
|
5
|
+
In the interest of fostering an open and welcoming environment, we as
|
6
|
+
contributors and maintainers pledge to making participation in our project and
|
7
|
+
our community a harassment-free experience for everyone, regardless of age, body
|
8
|
+
size, disability, ethnicity, gender identity and expression, level of experience,
|
9
|
+
nationality, personal appearance, race, religion, or sexual identity and
|
10
|
+
orientation.
|
11
|
+
|
12
|
+
## Our Standards
|
13
|
+
|
14
|
+
Examples of behavior that contributes to creating a positive environment
|
15
|
+
include:
|
16
|
+
|
17
|
+
* Using welcoming and inclusive language
|
18
|
+
* Being respectful of differing viewpoints and experiences
|
19
|
+
* Gracefully accepting constructive criticism
|
20
|
+
* Focusing on what is best for the community
|
21
|
+
* Showing empathy towards other community members
|
22
|
+
|
23
|
+
Examples of unacceptable behavior by participants include:
|
24
|
+
|
25
|
+
* The use of sexualized language or imagery and unwelcome sexual attention or
|
26
|
+
advances
|
27
|
+
* Trolling, insulting/derogatory comments, and personal or political attacks
|
28
|
+
* Public or private harassment
|
29
|
+
* Publishing others' private information, such as a physical or electronic
|
30
|
+
address, without explicit permission
|
31
|
+
* Other conduct which could reasonably be considered inappropriate in a
|
32
|
+
professional setting
|
33
|
+
|
34
|
+
## Our Responsibilities
|
35
|
+
|
36
|
+
Project maintainers are responsible for clarifying the standards of acceptable
|
37
|
+
behavior and are expected to take appropriate and fair corrective action in
|
38
|
+
response to any instances of unacceptable behavior.
|
39
|
+
|
40
|
+
Project maintainers have the right and responsibility to remove, edit, or
|
41
|
+
reject comments, commits, code, wiki edits, issues, and other contributions
|
42
|
+
that are not aligned to this Code of Conduct, or to ban temporarily or
|
43
|
+
permanently any contributor for other behaviors that they deem inappropriate,
|
44
|
+
threatening, offensive, or harmful.
|
45
|
+
|
46
|
+
## Scope
|
47
|
+
|
48
|
+
This Code of Conduct applies both within project spaces and in public spaces
|
49
|
+
when an individual is representing the project or its community. Examples of
|
50
|
+
representing a project or community include using an official project e-mail
|
51
|
+
address, posting via an official social media account, or acting as an appointed
|
52
|
+
representative at an online or offline event. Representation of a project may be
|
53
|
+
further defined and clarified by project maintainers.
|
54
|
+
|
55
|
+
## Enforcement
|
56
|
+
|
57
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
58
|
+
reported by contacting the project team at TBD. All
|
59
|
+
complaints will be reviewed and investigated and will result in a response that
|
60
|
+
is deemed necessary and appropriate to the circumstances. The project team is
|
61
|
+
obligated to maintain confidentiality with regard to the reporter of an incident.
|
62
|
+
Further details of specific enforcement policies may be posted separately.
|
63
|
+
|
64
|
+
Project maintainers who do not follow or enforce the Code of Conduct in good
|
65
|
+
faith may face temporary or permanent repercussions as determined by other
|
66
|
+
members of the project's leadership.
|
67
|
+
|
68
|
+
## Attribution
|
69
|
+
|
70
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
|
71
|
+
available at [https://contributor-covenant.org/version/1/4][version]
|
72
|
+
|
73
|
+
[homepage]: https://contributor-covenant.org
|
74
|
+
[version]: https://contributor-covenant.org/version/1/4/
|
data/Gemfile
ADDED
@@ -0,0 +1,11 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
source 'https://rubygems.org'
|
4
|
+
|
5
|
+
# Specify your gem's dependencies in pushybullet.gemspec
|
6
|
+
gemspec
|
7
|
+
|
8
|
+
gem 'rake', '~> 12.0'
|
9
|
+
gem 'rspec', '~> 3.0'
|
10
|
+
gem 'rubocop', '~> 1.3'
|
11
|
+
gem 'simplecov', '~> 0.19', require: false, group: :test
|
data/Gemfile.lock
ADDED
@@ -0,0 +1,70 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
pushybullet (0.1.0)
|
5
|
+
faraday (~> 1.1.0)
|
6
|
+
faraday_middleware (~> 1.0.0)
|
7
|
+
|
8
|
+
GEM
|
9
|
+
remote: https://rubygems.org/
|
10
|
+
specs:
|
11
|
+
ast (2.4.1)
|
12
|
+
diff-lcs (1.4.4)
|
13
|
+
docile (1.3.2)
|
14
|
+
faraday (1.1.0)
|
15
|
+
multipart-post (>= 1.2, < 3)
|
16
|
+
ruby2_keywords
|
17
|
+
faraday_middleware (1.0.0)
|
18
|
+
faraday (~> 1.0)
|
19
|
+
multipart-post (2.1.1)
|
20
|
+
parallel (1.20.0)
|
21
|
+
parser (2.7.2.0)
|
22
|
+
ast (~> 2.4.1)
|
23
|
+
rainbow (3.0.0)
|
24
|
+
rake (12.3.3)
|
25
|
+
regexp_parser (1.8.2)
|
26
|
+
rexml (3.2.4)
|
27
|
+
rspec (3.10.0)
|
28
|
+
rspec-core (~> 3.10.0)
|
29
|
+
rspec-expectations (~> 3.10.0)
|
30
|
+
rspec-mocks (~> 3.10.0)
|
31
|
+
rspec-core (3.10.0)
|
32
|
+
rspec-support (~> 3.10.0)
|
33
|
+
rspec-expectations (3.10.0)
|
34
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
35
|
+
rspec-support (~> 3.10.0)
|
36
|
+
rspec-mocks (3.10.0)
|
37
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
38
|
+
rspec-support (~> 3.10.0)
|
39
|
+
rspec-support (3.10.0)
|
40
|
+
rubocop (1.3.1)
|
41
|
+
parallel (~> 1.10)
|
42
|
+
parser (>= 2.7.1.5)
|
43
|
+
rainbow (>= 2.2.2, < 4.0)
|
44
|
+
regexp_parser (>= 1.8)
|
45
|
+
rexml
|
46
|
+
rubocop-ast (>= 1.1.1)
|
47
|
+
ruby-progressbar (~> 1.7)
|
48
|
+
unicode-display_width (>= 1.4.0, < 2.0)
|
49
|
+
rubocop-ast (1.1.1)
|
50
|
+
parser (>= 2.7.1.5)
|
51
|
+
ruby-progressbar (1.10.1)
|
52
|
+
ruby2_keywords (0.0.2)
|
53
|
+
simplecov (0.19.1)
|
54
|
+
docile (~> 1.1)
|
55
|
+
simplecov-html (~> 0.11)
|
56
|
+
simplecov-html (0.12.3)
|
57
|
+
unicode-display_width (1.7.0)
|
58
|
+
|
59
|
+
PLATFORMS
|
60
|
+
x64-mingw32
|
61
|
+
|
62
|
+
DEPENDENCIES
|
63
|
+
pushybullet!
|
64
|
+
rake (~> 12.0)
|
65
|
+
rspec (~> 3.0)
|
66
|
+
rubocop (~> 1.3)
|
67
|
+
simplecov (~> 0.19)
|
68
|
+
|
69
|
+
BUNDLED WITH
|
70
|
+
2.1.4
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2020 Nick King
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,46 @@
|
|
1
|
+
# Pushybullet
|
2
|
+
|
3
|
+
A ruby gem for pushbullet.
|
4
|
+
|
5
|
+
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/pushybullet`. To experiment with that code, run `bin/console` for an interactive prompt.
|
6
|
+
|
7
|
+
TODO: Delete this and the text above, and describe your gem
|
8
|
+
|
9
|
+
## Installation
|
10
|
+
|
11
|
+
Add this line to your application's Gemfile:
|
12
|
+
|
13
|
+
```ruby
|
14
|
+
gem 'pushybullet'
|
15
|
+
```
|
16
|
+
|
17
|
+
And then execute:
|
18
|
+
|
19
|
+
$ bundle install
|
20
|
+
|
21
|
+
Or install it yourself as:
|
22
|
+
|
23
|
+
$ gem install pushybullet
|
24
|
+
|
25
|
+
## Usage
|
26
|
+
|
27
|
+
TODO: Write usage instructions here
|
28
|
+
|
29
|
+
## Development
|
30
|
+
|
31
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
32
|
+
|
33
|
+
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).
|
34
|
+
|
35
|
+
## Contributing
|
36
|
+
|
37
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/pushybullet. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/arcticfoxnv/pushybullet/blob/master/CODE_OF_CONDUCT.md).
|
38
|
+
|
39
|
+
|
40
|
+
## License
|
41
|
+
|
42
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
43
|
+
|
44
|
+
## Code of Conduct
|
45
|
+
|
46
|
+
Everyone interacting in the Pushybullet project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/arcticfoxnv/pushybullet/blob/master/CODE_OF_CONDUCT.md).
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
require 'bundler/setup'
|
5
|
+
require 'pushybullet'
|
6
|
+
|
7
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
8
|
+
# with your gem easier. You can also use a different console, if you like.
|
9
|
+
|
10
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
11
|
+
# require "pry"
|
12
|
+
# Pry.start
|
13
|
+
|
14
|
+
require 'irb'
|
15
|
+
IRB.start(__FILE__)
|
data/bin/setup
ADDED
data/lib/pushybullet.rb
ADDED
@@ -0,0 +1,69 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'faraday_middleware'
|
4
|
+
require 'json'
|
5
|
+
require 'pushybullet/middleware/error'
|
6
|
+
require 'pushybullet/types'
|
7
|
+
|
8
|
+
module Pushybullet
|
9
|
+
class Client
|
10
|
+
def initialize(access_token, request_timeout = 3)
|
11
|
+
@access_token = access_token
|
12
|
+
@request_timeout = request_timeout
|
13
|
+
end
|
14
|
+
|
15
|
+
def devices
|
16
|
+
resp = conn.get('v2/devices')
|
17
|
+
devs = []
|
18
|
+
puts resp.body
|
19
|
+
resp.body['devices'].each do |data|
|
20
|
+
devs << Pushybullet::Types::Device.from_hash(data)
|
21
|
+
end
|
22
|
+
|
23
|
+
devs
|
24
|
+
end
|
25
|
+
|
26
|
+
def create_push(push)
|
27
|
+
payload = JSON.dump(push.to_hash)
|
28
|
+
resp = conn.post('v2/pushes', payload, 'Content-Type' => 'application/json')
|
29
|
+
Pushybullet::Types::Push.from_hash(resp.body)
|
30
|
+
end
|
31
|
+
|
32
|
+
def push_link(title, body, url, target)
|
33
|
+
push = Pushybullet::Types::Push.from_hash({
|
34
|
+
type: :link,
|
35
|
+
title: title,
|
36
|
+
body: body,
|
37
|
+
url: url
|
38
|
+
})
|
39
|
+
push.target = target
|
40
|
+
create_push(push)
|
41
|
+
end
|
42
|
+
|
43
|
+
def push_note(title, body, target)
|
44
|
+
push = Pushybullet::Types::Push.from_hash({
|
45
|
+
type: :note,
|
46
|
+
title: title,
|
47
|
+
body: body
|
48
|
+
})
|
49
|
+
push.target = target
|
50
|
+
create_push(push)
|
51
|
+
end
|
52
|
+
|
53
|
+
private
|
54
|
+
|
55
|
+
def conn
|
56
|
+
@conn ||= Faraday.new 'https://api.pushbullet.com' do |conn|
|
57
|
+
conn.options.timeout = @request_timeout
|
58
|
+
conn.headers['Access-Token'] = @access_token
|
59
|
+
|
60
|
+
conn.request :json
|
61
|
+
conn.response :json, content_type: /\bjson$/
|
62
|
+
|
63
|
+
conn.use :instrumentation if defined?(ActiveSupport)
|
64
|
+
conn.use Pushybullet::Middleware::Error
|
65
|
+
conn.use Faraday::Response::RaiseError
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
module Pushybullet
|
2
|
+
module Concerns
|
3
|
+
module FromHash
|
4
|
+
def from_hash(data)
|
5
|
+
o = new
|
6
|
+
data.each do |key, value|
|
7
|
+
o.send("#{key}=", value)
|
8
|
+
end
|
9
|
+
|
10
|
+
o
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
module ToHash
|
15
|
+
def to_hash
|
16
|
+
d = {}
|
17
|
+
instance_variables.each do |name|
|
18
|
+
val = instance_variable_get(name)
|
19
|
+
d[name[1..-1]] = val unless val.nil?
|
20
|
+
end
|
21
|
+
|
22
|
+
d
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Pushybullet
|
4
|
+
module Errors
|
5
|
+
class ClientError < Faraday::ClientError
|
6
|
+
attr_reader :cat, :message, :type
|
7
|
+
|
8
|
+
protected
|
9
|
+
|
10
|
+
def exc_msg_and_response(exc, response = nil)
|
11
|
+
headers = response[:headers]
|
12
|
+
|
13
|
+
if headers['Content-Type'] =~ /\bjson$/
|
14
|
+
err = JSON.parse(response[:body])
|
15
|
+
@type = err[:error][:type]
|
16
|
+
@message = err[:error][:message]
|
17
|
+
@cat = err[:error][:cat]
|
18
|
+
end
|
19
|
+
|
20
|
+
super
|
21
|
+
end
|
22
|
+
end
|
23
|
+
class Unauthorized < ClientError; end
|
24
|
+
class Forbidden < ClientError; end
|
25
|
+
class TooManyRequests < ClientError; end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Pushybullet
|
4
|
+
module Middleware
|
5
|
+
class Error < Faraday::Response::RaiseError
|
6
|
+
def on_complete(env)
|
7
|
+
case env[:status]
|
8
|
+
when 401
|
9
|
+
raise Errors::Unauthorized, response_values(env)
|
10
|
+
when 403
|
11
|
+
raise Errors::Forbidden, response_values(env)
|
12
|
+
when 429
|
13
|
+
raise Errors::TooManyRequests, response_values(env)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'pushybullet/concerns'
|
4
|
+
|
5
|
+
module Pushybullet
|
6
|
+
module Types
|
7
|
+
class Device
|
8
|
+
extend Pushybullet::Concerns::FromHash
|
9
|
+
|
10
|
+
# strings
|
11
|
+
attr_accessor :iden, :icon, :nickname, :manufacturer, :model,
|
12
|
+
:fingerprint, :key_fingerprint, :push_token, :has_sms,
|
13
|
+
:type, :kind, :remote_files
|
14
|
+
|
15
|
+
# bools
|
16
|
+
attr_accessor :active, :generated_nickname, :pushable
|
17
|
+
|
18
|
+
# floats
|
19
|
+
attr_accessor :created, :modified
|
20
|
+
|
21
|
+
# ints
|
22
|
+
attr_accessor :app_version
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'pushybullet/concerns'
|
4
|
+
|
5
|
+
module Pushybullet
|
6
|
+
module Types
|
7
|
+
class Push
|
8
|
+
extend Pushybullet::Concerns::FromHash
|
9
|
+
include Pushybullet::Concerns::ToHash
|
10
|
+
|
11
|
+
# strings
|
12
|
+
attr_accessor :iden, :type, :guid, :direction,
|
13
|
+
:sender_iden, :sender_email, :sender_email_normalized, :sender_name,
|
14
|
+
:receiver_iden, :receiver_email, :receiver_email_normalized,
|
15
|
+
:target_device_iden, :source_device_iden, :client_iden, :channel_iden,
|
16
|
+
:title, :body, :url, :file_name, :file_type, :file_url, :image_url
|
17
|
+
|
18
|
+
# lists
|
19
|
+
attr_accessor :awake_app_guids
|
20
|
+
|
21
|
+
# bools
|
22
|
+
attr_accessor :active, :dismissed
|
23
|
+
|
24
|
+
# floats
|
25
|
+
attr_accessor :created, :modified
|
26
|
+
|
27
|
+
# ints
|
28
|
+
attr_accessor :image_width, :image_height
|
29
|
+
|
30
|
+
def target=(target)
|
31
|
+
instance_variable_set("@#{target.key}", target.value) unless target.nil?
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
module Pushybullet
|
2
|
+
module Types
|
3
|
+
class PushTarget
|
4
|
+
ID_TYPES = {
|
5
|
+
device: 'device_iden',
|
6
|
+
email: 'email',
|
7
|
+
channel: 'channel_tag',
|
8
|
+
client: 'client_iden'
|
9
|
+
}.freeze
|
10
|
+
|
11
|
+
def initialize(type, id)
|
12
|
+
@type = type
|
13
|
+
@id = id
|
14
|
+
end
|
15
|
+
|
16
|
+
def key
|
17
|
+
ID_TYPES[@type]
|
18
|
+
end
|
19
|
+
|
20
|
+
def value
|
21
|
+
@id
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
data/pushybullet.gemspec
ADDED
@@ -0,0 +1,33 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative 'lib/pushybullet/version'
|
4
|
+
|
5
|
+
Gem::Specification.new do |spec|
|
6
|
+
spec.name = 'pushybullet'
|
7
|
+
spec.version = Pushybullet::VERSION
|
8
|
+
spec.authors = ['Nick King']
|
9
|
+
spec.email = ['TBD']
|
10
|
+
|
11
|
+
spec.summary = 'A ruby gem for the pushybullet api'
|
12
|
+
spec.homepage = 'https://github.com/arcticfoxnv/pushybullet-gem'
|
13
|
+
spec.license = 'MIT'
|
14
|
+
spec.required_ruby_version = Gem::Requirement.new('>= 2.4.0')
|
15
|
+
|
16
|
+
spec.metadata['allowed_push_host'] = 'https://rubygems.org'
|
17
|
+
|
18
|
+
spec.metadata['homepage_uri'] = spec.homepage
|
19
|
+
spec.metadata['source_code_uri'] = 'https://github.com/arcticfoxnv/pushybullet-gem'
|
20
|
+
spec.metadata['changelog_uri'] = 'https://github.com/arcticfoxnv/pushybullet-gem'
|
21
|
+
|
22
|
+
# Specify which files should be added to the gem when it is released.
|
23
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
24
|
+
spec.files = Dir.chdir(File.expand_path(__dir__)) do
|
25
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features|.idea)/}) }
|
26
|
+
end
|
27
|
+
spec.bindir = 'exe'
|
28
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
29
|
+
spec.require_paths = ['lib']
|
30
|
+
|
31
|
+
spec.add_dependency 'faraday', '~> 1.1.0'
|
32
|
+
spec.add_dependency 'faraday_middleware', '~> 1.0.0'
|
33
|
+
end
|
metadata
ADDED
@@ -0,0 +1,99 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: pushybullet
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Nick King
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2020-11-18 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: faraday
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 1.1.0
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 1.1.0
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: faraday_middleware
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 1.0.0
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 1.0.0
|
41
|
+
description:
|
42
|
+
email:
|
43
|
+
- TBD
|
44
|
+
executables: []
|
45
|
+
extensions: []
|
46
|
+
extra_rdoc_files: []
|
47
|
+
files:
|
48
|
+
- ".gitignore"
|
49
|
+
- ".rspec"
|
50
|
+
- ".rubocop.yml"
|
51
|
+
- ".rubocop_todo.yml"
|
52
|
+
- ".travis.yml"
|
53
|
+
- CODE_OF_CONDUCT.md
|
54
|
+
- Gemfile
|
55
|
+
- Gemfile.lock
|
56
|
+
- LICENSE.txt
|
57
|
+
- README.md
|
58
|
+
- Rakefile
|
59
|
+
- bin/console
|
60
|
+
- bin/setup
|
61
|
+
- lib/pushybullet.rb
|
62
|
+
- lib/pushybullet/client.rb
|
63
|
+
- lib/pushybullet/concerns.rb
|
64
|
+
- lib/pushybullet/errors.rb
|
65
|
+
- lib/pushybullet/middleware/error.rb
|
66
|
+
- lib/pushybullet/types.rb
|
67
|
+
- lib/pushybullet/types/device.rb
|
68
|
+
- lib/pushybullet/types/push.rb
|
69
|
+
- lib/pushybullet/types/push_target.rb
|
70
|
+
- lib/pushybullet/version.rb
|
71
|
+
- pushybullet.gemspec
|
72
|
+
homepage: https://github.com/arcticfoxnv/pushybullet-gem
|
73
|
+
licenses:
|
74
|
+
- MIT
|
75
|
+
metadata:
|
76
|
+
allowed_push_host: https://rubygems.org
|
77
|
+
homepage_uri: https://github.com/arcticfoxnv/pushybullet-gem
|
78
|
+
source_code_uri: https://github.com/arcticfoxnv/pushybullet-gem
|
79
|
+
changelog_uri: https://github.com/arcticfoxnv/pushybullet-gem
|
80
|
+
post_install_message:
|
81
|
+
rdoc_options: []
|
82
|
+
require_paths:
|
83
|
+
- lib
|
84
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
85
|
+
requirements:
|
86
|
+
- - ">="
|
87
|
+
- !ruby/object:Gem::Version
|
88
|
+
version: 2.4.0
|
89
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
90
|
+
requirements:
|
91
|
+
- - ">="
|
92
|
+
- !ruby/object:Gem::Version
|
93
|
+
version: '0'
|
94
|
+
requirements: []
|
95
|
+
rubygems_version: 3.1.2
|
96
|
+
signing_key:
|
97
|
+
specification_version: 4
|
98
|
+
summary: A ruby gem for the pushybullet api
|
99
|
+
test_files: []
|