pushover 2.0.0 → 3.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.github/ISSUE_TEMPLATE/bug_report.md +35 -0
- data/.github/ISSUE_TEMPLATE/feature_request.md +17 -0
- data/.rubocop.yml +3 -1
- data/.travis.yml +8 -0
- data/Gemfile +28 -1
- data/Guardfile +5 -0
- data/README.md +43 -28
- data/Rakefile +60 -3
- data/bin/add +25 -0
- data/exe/pushover +37 -0
- data/lib/pushover.rb +6 -4
- data/lib/pushover/message.rb +32 -32
- data/lib/pushover/receipt.rb +13 -2
- data/lib/pushover/response.rb +35 -29
- data/lib/pushover/version.rb +1 -2
- data/pushover.gemspec +1 -21
- data/spec/lib/pushover_spec.rb +3 -0
- data/spec/pushover/message_spec.rb +36 -0
- data/spec/pushover/receipt_spec.rb +24 -0
- data/spec/pushover/response_spec.rb +26 -0
- data/spec/spec_helper.rb +5 -10
- data/spec/vscode_formatter.rb +31 -0
- metadata +21 -227
- data/bin/pushover +0 -0
- data/lib/pushover/api.rb +0 -35
- data/lib/pushover/request.rb +0 -12
- data/spec/lib/pushover/api_spec.rb +0 -41
- data/spec/lib/pushover/message_spec.rb +0 -81
- data/spec/lib/pushover/receipt_spec.rb +0 -6
- data/spec/lib/pushover/request_spec.rb +0 -60
- data/spec/lib/pushover/response_spec.rb +0 -98
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 1535788cd7fdbd24c0e3d8ebb12af8f2b4111e08294f1e3e15ace5113fcae01a
|
4
|
+
data.tar.gz: 8eb169ee1c697ea82af093e8d6c5a75db31664fc3c41c0086f688e300c3e6cc8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3356428132d9652dd216de3b45832777a7188c3e144cf1781dccf55b767cf2e25cd4b63d2ce7084b9a5944ab428949bb3299396ff8cf14e251c33bbbf22fe01b
|
7
|
+
data.tar.gz: f345fb5bb6328267be1a48d87a7a5ee218f28d7ce72ca8bb6b64a0ecb4426d057fcf45b17e291eb44a0c449373a7c142efada3a46d09dc436b57b04a46e117e3
|
@@ -0,0 +1,35 @@
|
|
1
|
+
---
|
2
|
+
name: Bug report
|
3
|
+
about: Create a report to help us improve
|
4
|
+
|
5
|
+
---
|
6
|
+
|
7
|
+
**Describe the bug**
|
8
|
+
A clear and concise description of what the bug is.
|
9
|
+
|
10
|
+
**To Reproduce**
|
11
|
+
Steps to reproduce the behavior:
|
12
|
+
1. Go to '...'
|
13
|
+
2. Click on '....'
|
14
|
+
3. Scroll down to '....'
|
15
|
+
4. See error
|
16
|
+
|
17
|
+
**Expected behavior**
|
18
|
+
A clear and concise description of what you expected to happen.
|
19
|
+
|
20
|
+
**Screenshots**
|
21
|
+
If applicable, add screenshots to help explain your problem.
|
22
|
+
|
23
|
+
**Desktop (please complete the following information):**
|
24
|
+
- OS: [e.g. iOS]
|
25
|
+
- Browser [e.g. chrome, safari]
|
26
|
+
- Version [e.g. 22]
|
27
|
+
|
28
|
+
**Smartphone (please complete the following information):**
|
29
|
+
- Device: [e.g. iPhone6]
|
30
|
+
- OS: [e.g. iOS8.1]
|
31
|
+
- Browser [e.g. stock browser, safari]
|
32
|
+
- Version [e.g. 22]
|
33
|
+
|
34
|
+
**Additional context**
|
35
|
+
Add any other context about the problem here.
|
@@ -0,0 +1,17 @@
|
|
1
|
+
---
|
2
|
+
name: Feature request
|
3
|
+
about: Suggest an idea for this project
|
4
|
+
|
5
|
+
---
|
6
|
+
|
7
|
+
**Is your feature request related to a problem? Please describe.**
|
8
|
+
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
|
9
|
+
|
10
|
+
**Describe the solution you'd like**
|
11
|
+
A clear and concise description of what you want to happen.
|
12
|
+
|
13
|
+
**Describe alternatives you've considered**
|
14
|
+
A clear and concise description of any alternative solutions or features you've considered.
|
15
|
+
|
16
|
+
**Additional context**
|
17
|
+
Add any other context or screenshots about the feature request here.
|
data/.rubocop.yml
CHANGED
@@ -33,8 +33,9 @@ Metrics/LineLength:
|
|
33
33
|
|
34
34
|
Metrics/BlockLength:
|
35
35
|
Exclude:
|
36
|
-
- 'Guardfile'
|
37
36
|
- '*.gemspec'
|
37
|
+
- 'Guardfile'
|
38
|
+
- 'Rakefile'
|
38
39
|
- 'spec/**/*'
|
39
40
|
|
40
41
|
# we exclude these two files since they are generated, the rest of our projects
|
@@ -59,6 +60,7 @@ Style/FrozenStringLiteralComment:
|
|
59
60
|
Style/MixinUsage:
|
60
61
|
Exclude:
|
61
62
|
- 'bin/*'
|
63
|
+
- 'exe/*'
|
62
64
|
|
63
65
|
# Specs don't need inline documentation.
|
64
66
|
Style/Documentation:
|
data/.travis.yml
ADDED
data/Gemfile
CHANGED
@@ -1,3 +1,30 @@
|
|
1
1
|
source 'https://rubygems.org'
|
2
|
-
|
3
2
|
gemspec
|
3
|
+
|
4
|
+
gem 'excon'
|
5
|
+
gem 'gli'
|
6
|
+
gem 'oj'
|
7
|
+
gem 'codecov', :require => false, :group => :test
|
8
|
+
|
9
|
+
group :test do
|
10
|
+
gem 'bump'
|
11
|
+
gem 'bundler'
|
12
|
+
gem 'rake'
|
13
|
+
gem 'rspec'
|
14
|
+
gem 'rubocop'
|
15
|
+
gem 'rubocop-rspec'
|
16
|
+
gem 'simplecov'
|
17
|
+
gem 'yard'
|
18
|
+
end
|
19
|
+
|
20
|
+
group :development, optional: true do
|
21
|
+
gem 'guard'
|
22
|
+
gem 'guard-bundler'
|
23
|
+
gem 'guard-rspec'
|
24
|
+
gem 'guard-rubocop'
|
25
|
+
gem 'guard-shell'
|
26
|
+
gem 'guard-yard'
|
27
|
+
gem 'pry'
|
28
|
+
gem "pry-inline"
|
29
|
+
gem "solargraph"
|
30
|
+
end
|
data/Guardfile
CHANGED
data/README.md
CHANGED
@@ -1,60 +1,75 @@
|
|
1
1
|
# Pushover
|
2
|
+
[![Build Status](https://travis-ci.org/erniebrodeur/pushover.svg?branch=master)](https://travis-ci.org/erniebrodeur/pushover) [![codecov](https://codecov.io/gh/erniebrodeur/pushover/branch/master/graph/badge.svg)](https://codecov.io/gh/erniebrodeur/pushover)
|
2
3
|
|
3
|
-
This gem provides a CLI and an API interface to
|
4
|
+
This gem provides a CLI and an API interface to https://pushover.net.
|
4
5
|
|
5
6
|
## Installation
|
6
7
|
|
7
8
|
To install:
|
8
9
|
|
9
|
-
|
10
|
+
gem install pushover
|
10
11
|
|
11
12
|
To use inside of an application, add this to the your gemfile:
|
12
13
|
|
13
|
-
|
14
|
+
gem 'pushover'
|
14
15
|
|
15
16
|
and run bundle to make it available:
|
16
17
|
|
17
|
-
|
18
|
+
bundle
|
19
|
+
|
18
20
|
|
19
21
|
## Usage
|
20
22
|
|
21
|
-
|
23
|
+
For now, not much is supported on the CLI.
|
22
24
|
|
23
|
-
|
24
|
-
require 'pushover'
|
25
|
-
```
|
25
|
+
Sending a message:
|
26
26
|
|
27
|
-
|
27
|
+
pushover --token=your_app_token --user=user_key message here we go again, on my own.
|
28
|
+
pushover -tyour_app_token -uuser_key message here we go again, on my own.
|
28
29
|
|
29
|
-
|
30
|
-
message = Pushover.create {
|
31
|
-
user: '...',
|
32
|
-
token: '...',
|
33
|
-
message: '...'
|
34
|
-
}
|
35
|
-
```
|
30
|
+
Getting receipt details:
|
36
31
|
|
37
|
-
### Send the message
|
38
32
|
|
39
|
-
|
40
|
-
response = message.send
|
41
|
-
```
|
33
|
+
pushover -tyour_app_token receipt receipt-hash
|
42
34
|
|
43
|
-
|
35
|
+
Currently unsupported message features:
|
36
|
+
- attachments
|
37
|
+
- callbacks
|
38
|
+
- setting timestamp
|
44
39
|
|
45
|
-
- The response will always include `status` and `request`.
|
46
|
-
- When set, it will also include `errors` and `receipt`.
|
47
40
|
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
41
|
+
### Api
|
42
|
+
|
43
|
+
``` ruby
|
44
|
+
require 'pushover'
|
52
45
|
|
46
|
+
### message
|
47
|
+
message = Pushover::Message.new(token: 'token', user: 'user_key', message: '...')
|
48
|
+
message.push
|
49
|
+
|
50
|
+
|
51
|
+
### Receipt
|
52
|
+
Pushover::Message.new(token: 'token', user: 'user_key', message: '...', 'priority': 2, expire: 1, retry: 60).push
|
53
|
+
|
54
|
+
receipt = Pushover::Receipt.new(receipt: "receipt", token: 'token')
|
55
|
+
receipt.get
|
56
|
+
|
57
|
+
### Responses
|
58
|
+
response = Pushover::Message.new(token: 'token', user: 'user_key', message: '...').push
|
59
|
+
|
60
|
+
# the below data is populated from the response
|
61
|
+
puts response.status # return the status of the request, 0 or 1
|
62
|
+
puts response.request # uuid of the request
|
63
|
+
puts response.errors # array of errors (if any)
|
64
|
+
puts response.receipt # receipt (if requested)
|
65
|
+
puts response.headers # response headers (includes limits)
|
66
|
+
puts response.attributes # any other k/v pair returned from pushover
|
67
|
+
```
|
53
68
|
|
54
69
|
## Contributing
|
55
70
|
|
56
71
|
1. Fork it
|
57
|
-
2. Switch to development (`git checkout
|
72
|
+
2. Switch to development (`git checkout development`)
|
58
73
|
3. Create your feature branch (`git checkout -b my-new-feature`)
|
59
74
|
4. Commit your changes (`git commit -am 'Added some feature'`)
|
60
75
|
5. Push to the branch (`git push origin my-new-feature`)
|
data/Rakefile
CHANGED
@@ -1,6 +1,63 @@
|
|
1
|
-
require
|
2
|
-
require
|
1
|
+
require "bundler/gem_tasks"
|
2
|
+
require "rspec/core/rake_task"
|
3
|
+
require "open-uri"
|
4
|
+
### Configurables
|
3
5
|
|
4
|
-
|
6
|
+
files = {
|
7
|
+
Gemfile: 'https://gist.githubusercontent.com/erniebrodeur/5a5518f5051210f1828a0712bf623dc8/raw',
|
8
|
+
Rakefile: 'https://gist.githubusercontent.com/erniebrodeur/afc92b72158413aa1f85d8d1facd267a/raw',
|
9
|
+
Rubocop: 'https://gist.githubusercontent.com/erniebrodeur/f7f63996ef1e017aee9bf9d8e680a1df/raw',
|
10
|
+
Tasks: 'https://gist.githubusercontent.com/erniebrodeur/03573fecf4f274101c14f6802abdbe83/raw',
|
11
|
+
BinAdd: 'https://gist.githubusercontent.com/erniebrodeur/a815ee4d8bd9ccc54d91025a5543ebb8/raw',
|
12
|
+
VsCodeFormatter: 'https://gist.githubusercontent.com/erniebrodeur/b24d757c0c625d108019eaceff2234cc/raw'
|
13
|
+
}
|
5
14
|
|
15
|
+
# spec
|
16
|
+
RSpec::Core::RakeTask.new(:spec)
|
6
17
|
task default: :spec
|
18
|
+
|
19
|
+
# automagical updating
|
20
|
+
desc "updates for various bits of the development environment."
|
21
|
+
|
22
|
+
namespace :update do
|
23
|
+
desc "update everything (multitasked)"
|
24
|
+
multitask(all: %i[gemfile rakefile rubocop tasks vscode_formatter])
|
25
|
+
|
26
|
+
desc 'Update Gemfile from gist'
|
27
|
+
task :gemfile do
|
28
|
+
grab_file 'Gemfile', files[:Gemfile]
|
29
|
+
end
|
30
|
+
|
31
|
+
desc 'Update Rakefile from gist'
|
32
|
+
task :rakefile do
|
33
|
+
grab_file 'Rakefile', files[:Rakefile]
|
34
|
+
end
|
35
|
+
|
36
|
+
desc 'Update .rubocop.yml from gist'
|
37
|
+
task :rubocop do
|
38
|
+
grab_file '.rubocop.yml', files[:Rubocop]
|
39
|
+
end
|
40
|
+
|
41
|
+
desc 'Update .vscode/tasks.json from gist'
|
42
|
+
task :tasks do
|
43
|
+
mkdir_p '.vscode'
|
44
|
+
grab_file '.vscode/tasks.json', files[:Tasks]
|
45
|
+
end
|
46
|
+
|
47
|
+
desc 'Update vscode_formatter.rb in spec_helper'
|
48
|
+
task :vscode_formatter do
|
49
|
+
mkdir_p 'spec'
|
50
|
+
grab_file 'spec/vscode_formatter.rb', files[:VsCodeFormatter]
|
51
|
+
end
|
52
|
+
|
53
|
+
desc 'Add a new lib and spec file (binary)'
|
54
|
+
task :binadd do
|
55
|
+
mkdir_p 'bin'
|
56
|
+
grab_file 'bin/add', files[:BinAdd]
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
def grab_file(filename, uri)
|
61
|
+
File.write filename, OpenURI.open_uri(uri).read
|
62
|
+
puts "Updated #{filename} from: #{uri}"
|
63
|
+
end
|
data/bin/add
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
require 'bundler'
|
3
|
+
require 'fileutils'
|
4
|
+
|
5
|
+
# add files to lib and spec
|
6
|
+
# takes one arg, the path from lib/spec + base filename
|
7
|
+
# example: add models/something
|
8
|
+
|
9
|
+
unless ARGV[0]
|
10
|
+
puts "example: add models/something"
|
11
|
+
exit
|
12
|
+
end
|
13
|
+
|
14
|
+
file = ARGV[0].dup
|
15
|
+
root = Bundler.root.split.last.to_s
|
16
|
+
|
17
|
+
file.chomp!(".rb")
|
18
|
+
|
19
|
+
lib = "lib/#{root}/#{file}.rb"
|
20
|
+
spec = "spec/#{root}/#{file}_spec.rb"
|
21
|
+
|
22
|
+
[lib, spec].each do |s|
|
23
|
+
FileUtils.mkdir_p(File.dirname(s))
|
24
|
+
puts "created: #{FileUtils.touch(s).first}"
|
25
|
+
end
|
data/exe/pushover
ADDED
@@ -0,0 +1,37 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
require 'gli'
|
3
|
+
require 'pushover'
|
4
|
+
|
5
|
+
include GLI::App
|
6
|
+
|
7
|
+
program_desc 'A simple todo list'
|
8
|
+
subcommand_option_handling :normal
|
9
|
+
|
10
|
+
flag %i[t token], type: String, desc: 'Application token'
|
11
|
+
flag %i[u user], type: String, desc: 'User token'
|
12
|
+
|
13
|
+
desc 'send a message'
|
14
|
+
command :message do |c|
|
15
|
+
c.flag :device, type: String, desc: 'device to send too'
|
16
|
+
c.flag :title, type: String, desc: 'title of message'
|
17
|
+
c.flag :url, type: String, desc: 'url to include'
|
18
|
+
c.flag :url_title, type: String, desc: 'title of included url'
|
19
|
+
c.flag :priority, type: String, desc: 'numeric priority (-2,-1,0,1,2) from low to high'
|
20
|
+
c.flag :sound, type: String, desc: 'sound, see pushover api for list.'
|
21
|
+
c.flag :expire, type: String, desc: 'how long should a priority message live'
|
22
|
+
c.flag :retry, type: String, desc: 'how often should a resend be attempted (until acknowledged)'
|
23
|
+
c.action do |global_options, options, args|
|
24
|
+
puts Pushover::Message.new({
|
25
|
+
message: args.join(" "), user: global_options[:user], token: global_options[:token]
|
26
|
+
}.merge(GLI::Options.new(options).to_h.reject { |_k, v| v.nil? })).push
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
desc 'get a receipt'
|
31
|
+
command :receipt do |c|
|
32
|
+
c.action do |global_options, _options, args|
|
33
|
+
puts Pushover::Receipt.new(token: global_options[:token], receipt: args[0]).get
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
run(ARGV)
|
data/lib/pushover.rb
CHANGED
@@ -1,12 +1,14 @@
|
|
1
1
|
require 'oj'
|
2
|
-
require '
|
2
|
+
require 'excon'
|
3
3
|
|
4
|
-
require 'pushover/api'
|
5
4
|
require 'pushover/message'
|
6
|
-
require 'pushover/receipt'
|
7
5
|
require 'pushover/response'
|
8
|
-
require 'pushover/
|
6
|
+
require 'pushover/receipt'
|
9
7
|
|
10
8
|
# pushover interface for ruby
|
11
9
|
module Pushover
|
10
|
+
# headers to include in every request.
|
11
|
+
HEADERS = { 'Content-Type' => 'application/json', 'User-Agent' => "pushover (ruby gem) v#{VERSION}" }.freeze
|
12
|
+
# excon connection to use for every request.
|
13
|
+
Excon = Excon.new('https://api.pushover.net', headers: HEADERS).freeze
|
12
14
|
end
|
data/lib/pushover/message.rb
CHANGED
@@ -1,38 +1,38 @@
|
|
1
|
-
# Pushover interface
|
2
1
|
module Pushover
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
2
|
+
# Message is a struct to send a message to pushover.
|
3
|
+
# @!attribute [rw] token
|
4
|
+
# @return [String] application token
|
5
|
+
# @!attribute [rw] user
|
6
|
+
# @return [String] user key
|
7
|
+
# @!attribute [rw] message
|
8
|
+
# @return [String] message to transmit
|
9
|
+
# @!attribute [rw] device
|
10
|
+
# @return [String] device to transmit too
|
11
|
+
# @!attribute [rw] title
|
12
|
+
# @return [String] title of the message
|
13
|
+
# @!attribute [rw] url
|
14
|
+
# @return [String] supplementary url
|
15
|
+
# @!attribute [rw] url_title
|
16
|
+
# @return [String] title of the supplementary url
|
17
|
+
# @!attribute [rw] priority
|
18
|
+
# @return [Numeric] numeric value for priority.
|
19
|
+
# @!attribute [rw] sound
|
20
|
+
# @return [String] sound to play
|
21
|
+
# @!attribute [rw] timestamp
|
22
|
+
# @return [Numeric] timestamp to expire, in epoch
|
23
|
+
# @!attribute [rw] expire
|
24
|
+
# @return [Numeric] expire time until message expires
|
25
|
+
# @!attribute [rw] retry
|
26
|
+
# @return [Numeric] how long to retry for, in seconds
|
27
|
+
# @!attribute [rw] callback
|
28
|
+
# @return [String] callback url
|
29
|
+
Message = Struct.new(:token, :user, :message, :attachment, :device, :title, :url, :url_title, :priority, :sound, :timestamp, :expire, :retry, :callback, keyword_init: true) do
|
30
|
+
# push the configured message to pushover.
|
31
|
+
# @return [Response] response for the receipt request
|
24
32
|
def push
|
25
|
-
|
26
|
-
raise ArgumentError, 'token is a required parameter' unless token
|
27
|
-
raise ArgumentError, 'message is a required parameter' unless message
|
28
|
-
|
29
|
-
query = {}
|
30
|
-
|
31
|
-
attributes.each { |e| query.store e[:name], instance_variable_get("@#{e[:name]}") if instance_variable_get("@#{e[:name]}") }
|
33
|
+
%i[token user message].each { |param| raise "#{param} must be supplied" unless send param }
|
32
34
|
|
33
|
-
|
34
|
-
response.process
|
35
|
-
@response = response
|
35
|
+
Response.create_from_excon_response Excon.post(path: '1/messages.json', query: to_h)
|
36
36
|
end
|
37
37
|
end
|
38
38
|
end
|