pushover 1.0.4 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +78 -0
- data/CODE_OF_CONDUCT.md +46 -0
- data/Gemfile +0 -37
- data/Guardfile +37 -27
- data/LICENSE +17 -32
- data/README.md +26 -153
- data/Rakefile +2 -3
- data/bin/pushover +0 -154
- data/lib/pushover.rb +8 -144
- data/lib/pushover/api.rb +35 -0
- data/lib/pushover/message.rb +38 -0
- data/lib/pushover/receipt.rb +5 -0
- data/lib/pushover/request.rb +12 -0
- data/lib/pushover/response.rb +40 -0
- data/lib/pushover/version.rb +2 -2
- data/pushover.gemspec +38 -25
- data/spec/lib/pushover/api_spec.rb +41 -0
- data/spec/lib/pushover/message_spec.rb +81 -0
- data/spec/lib/pushover/receipt_spec.rb +6 -0
- data/spec/lib/pushover/request_spec.rb +60 -0
- data/spec/lib/pushover/response_spec.rb +98 -0
- data/spec/lib/pushover_spec.rb +1 -116
- data/spec/spec_helper.rb +14 -39
- metadata +234 -36
- data/.travis.yml +0 -15
- data/lib/pushover/app.rb +0 -64
- data/lib/pushover/mixins.rb +0 -7
- data/lib/pushover/priority.rb +0 -63
- data/lib/pushover/user.rb +0 -68
- data/spec/bin/pushover_spec.rb +0 -108
- data/spec/cli_spec_helper.rb +0 -99
- data/spec/lib/pushover/app_spec.rb +0 -54
- data/spec/lib/pushover/user_spec.rb +0 -53
- data/whatsnew.md +0 -69
data/spec/spec_helper.rb
CHANGED
@@ -1,47 +1,22 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
1
|
+
require 'excon'
|
2
|
+
require 'pry'
|
3
|
+
require 'simplecov'
|
4
|
+
require 'simplecov-console'
|
4
5
|
|
5
|
-
|
6
|
-
SimpleCov::Formatter::HTMLFormatter,
|
7
|
-
SimpleCov::Formatter::RcovFormatter
|
8
|
-
]
|
9
|
-
SimpleCov.start do
|
10
|
-
add_filter "/spec/"
|
11
|
-
end
|
12
|
-
end
|
13
|
-
|
14
|
-
require 'webmock/rspec'
|
15
|
-
require 'pushover'
|
6
|
+
Excon.defaults[:mock] = true
|
16
7
|
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
Bini::Config.load
|
8
|
+
SimpleCov.formatters = [
|
9
|
+
SimpleCov::Formatter::HTMLFormatter
|
10
|
+
]
|
21
11
|
|
22
12
|
RSpec.configure do |config|
|
23
|
-
config.treat_symbols_as_metadata_keys_with_true_values = true
|
24
|
-
config.run_all_when_everything_filtered = true
|
25
13
|
config.filter_run :focus
|
26
|
-
config.
|
14
|
+
config.run_all_when_everything_filtered = true
|
15
|
+
config.example_status_persistence_file_path = "tmp/examples.txt"
|
27
16
|
end
|
28
17
|
|
29
|
-
|
30
|
-
|
31
|
-
good_result = '{"status":1}'
|
32
|
-
bad_token = '{"token":"invalid","errors":["application token is invalid"],"status":0}'
|
33
|
-
bad_user = '{"user":"invalid","errors":["user identifier is invalid"],"status":0}'
|
34
|
-
sounds = '{"sounds":{"pushover":"Pushover (default)","bike":"Bike","bugle":"Bugle","cashregister":"Cash Register","classical":"Classical","cosmic":"Cosmic","falling":"Falling","gamelan":"Gamelan","incoming":"Incoming","intermission":"Intermission","magic":"Magic","mechanical":"Mechanical","pianobar":"Piano Bar","siren":"Siren","spacealarm":"Space Alarm","tugboat":"Tug Boat","alien":"Alien Alarm (long)","climb":"Climb (long)","persistent":"Persistent (long)","echo":"Pushover Echo (long)","updown":"Up Down (long)","none":"None (silent)"},"status":1,"request":"14ef413f6a3bf74efee3e140efe63df9"}'
|
35
|
-
|
36
|
-
stub_request(:post, "https://api.pushover.net/1/messages.json").
|
37
|
-
with(body:hash_including(token:'good_token', user:'good_user')).
|
38
|
-
to_return(body:good_result, code:200)
|
39
|
-
stub_request(:post, "https://api.pushover.net/1/messages.json").
|
40
|
-
with(body:hash_including(token:'bad_token')).
|
41
|
-
to_return(body:bad_token, code:400)
|
42
|
-
stub_request(:post, "https://api.pushover.net/1/messages.json").
|
43
|
-
with(body:hash_including(user:'bad_user')).
|
44
|
-
to_return(body:bad_user, code:400)
|
45
|
-
stub_request(:get, /https:\/\/api.pushover.net\/1\/sounds.json.*/).
|
46
|
-
to_return(body:sounds, code:200)
|
18
|
+
SimpleCov.start do
|
19
|
+
add_filter "/spec/"
|
47
20
|
end
|
21
|
+
|
22
|
+
require 'pushover'
|
metadata
CHANGED
@@ -1,57 +1,253 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pushover
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 2.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ernie Brodeur
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2018-09-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
|
-
name:
|
14
|
+
name: creatable
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- -
|
17
|
+
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version:
|
19
|
+
version: '0'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- -
|
24
|
+
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version:
|
26
|
+
version: '0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
|
-
name:
|
28
|
+
name: excon
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- -
|
31
|
+
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: 0
|
33
|
+
version: '0'
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- -
|
38
|
+
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: 0
|
40
|
+
version: '0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
|
-
name:
|
42
|
+
name: oj
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- -
|
45
|
+
- - ">="
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: 0
|
47
|
+
version: '0'
|
48
48
|
type: :runtime
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- -
|
52
|
+
- - ">="
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: 0
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: bundler
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: guard
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: guard-bundler
|
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: guard-rspec
|
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: guard-rubocop
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - ">="
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0'
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - ">="
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '0'
|
125
|
+
- !ruby/object:Gem::Dependency
|
126
|
+
name: guard-yard
|
127
|
+
requirement: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - ">="
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: '0'
|
132
|
+
type: :development
|
133
|
+
prerelease: false
|
134
|
+
version_requirements: !ruby/object:Gem::Requirement
|
135
|
+
requirements:
|
136
|
+
- - ">="
|
137
|
+
- !ruby/object:Gem::Version
|
138
|
+
version: '0'
|
139
|
+
- !ruby/object:Gem::Dependency
|
140
|
+
name: pry
|
141
|
+
requirement: !ruby/object:Gem::Requirement
|
142
|
+
requirements:
|
143
|
+
- - ">="
|
144
|
+
- !ruby/object:Gem::Version
|
145
|
+
version: '0'
|
146
|
+
type: :development
|
147
|
+
prerelease: false
|
148
|
+
version_requirements: !ruby/object:Gem::Requirement
|
149
|
+
requirements:
|
150
|
+
- - ">="
|
151
|
+
- !ruby/object:Gem::Version
|
152
|
+
version: '0'
|
153
|
+
- !ruby/object:Gem::Dependency
|
154
|
+
name: rake
|
155
|
+
requirement: !ruby/object:Gem::Requirement
|
156
|
+
requirements:
|
157
|
+
- - ">="
|
158
|
+
- !ruby/object:Gem::Version
|
159
|
+
version: '0'
|
160
|
+
type: :development
|
161
|
+
prerelease: false
|
162
|
+
version_requirements: !ruby/object:Gem::Requirement
|
163
|
+
requirements:
|
164
|
+
- - ">="
|
165
|
+
- !ruby/object:Gem::Version
|
166
|
+
version: '0'
|
167
|
+
- !ruby/object:Gem::Dependency
|
168
|
+
name: rspec
|
169
|
+
requirement: !ruby/object:Gem::Requirement
|
170
|
+
requirements:
|
171
|
+
- - ">="
|
172
|
+
- !ruby/object:Gem::Version
|
173
|
+
version: '0'
|
174
|
+
type: :development
|
175
|
+
prerelease: false
|
176
|
+
version_requirements: !ruby/object:Gem::Requirement
|
177
|
+
requirements:
|
178
|
+
- - ">="
|
179
|
+
- !ruby/object:Gem::Version
|
180
|
+
version: '0'
|
181
|
+
- !ruby/object:Gem::Dependency
|
182
|
+
name: rubocop
|
183
|
+
requirement: !ruby/object:Gem::Requirement
|
184
|
+
requirements:
|
185
|
+
- - ">="
|
186
|
+
- !ruby/object:Gem::Version
|
187
|
+
version: '0'
|
188
|
+
type: :development
|
189
|
+
prerelease: false
|
190
|
+
version_requirements: !ruby/object:Gem::Requirement
|
191
|
+
requirements:
|
192
|
+
- - ">="
|
193
|
+
- !ruby/object:Gem::Version
|
194
|
+
version: '0'
|
195
|
+
- !ruby/object:Gem::Dependency
|
196
|
+
name: rubocop-rspec
|
197
|
+
requirement: !ruby/object:Gem::Requirement
|
198
|
+
requirements:
|
199
|
+
- - ">="
|
200
|
+
- !ruby/object:Gem::Version
|
201
|
+
version: '0'
|
202
|
+
type: :development
|
203
|
+
prerelease: false
|
204
|
+
version_requirements: !ruby/object:Gem::Requirement
|
205
|
+
requirements:
|
206
|
+
- - ">="
|
207
|
+
- !ruby/object:Gem::Version
|
208
|
+
version: '0'
|
209
|
+
- !ruby/object:Gem::Dependency
|
210
|
+
name: simplecov
|
211
|
+
requirement: !ruby/object:Gem::Requirement
|
212
|
+
requirements:
|
213
|
+
- - ">="
|
214
|
+
- !ruby/object:Gem::Version
|
215
|
+
version: '0'
|
216
|
+
type: :development
|
217
|
+
prerelease: false
|
218
|
+
version_requirements: !ruby/object:Gem::Requirement
|
219
|
+
requirements:
|
220
|
+
- - ">="
|
221
|
+
- !ruby/object:Gem::Version
|
222
|
+
version: '0'
|
223
|
+
- !ruby/object:Gem::Dependency
|
224
|
+
name: simplecov-console
|
225
|
+
requirement: !ruby/object:Gem::Requirement
|
226
|
+
requirements:
|
227
|
+
- - ">="
|
228
|
+
- !ruby/object:Gem::Version
|
229
|
+
version: '0'
|
230
|
+
type: :development
|
231
|
+
prerelease: false
|
232
|
+
version_requirements: !ruby/object:Gem::Requirement
|
233
|
+
requirements:
|
234
|
+
- - ">="
|
235
|
+
- !ruby/object:Gem::Version
|
236
|
+
version: '0'
|
237
|
+
- !ruby/object:Gem::Dependency
|
238
|
+
name: yard
|
239
|
+
requirement: !ruby/object:Gem::Requirement
|
240
|
+
requirements:
|
241
|
+
- - ">="
|
242
|
+
- !ruby/object:Gem::Version
|
243
|
+
version: '0'
|
244
|
+
type: :development
|
245
|
+
prerelease: false
|
246
|
+
version_requirements: !ruby/object:Gem::Requirement
|
247
|
+
requirements:
|
248
|
+
- - ">="
|
249
|
+
- !ruby/object:Gem::Version
|
250
|
+
version: '0'
|
55
251
|
description: Api (and CLI) to interface with pushover.net
|
56
252
|
email:
|
57
253
|
- ebrodeur@ujami.net
|
@@ -59,11 +255,12 @@ executables:
|
|
59
255
|
- pushover
|
60
256
|
extensions: []
|
61
257
|
extra_rdoc_files:
|
258
|
+
- CODE_OF_CONDUCT.md
|
62
259
|
- README.md
|
63
|
-
- whatsnew.md
|
64
260
|
files:
|
65
261
|
- ".gitignore"
|
66
|
-
- ".
|
262
|
+
- ".rubocop.yml"
|
263
|
+
- CODE_OF_CONDUCT.md
|
67
264
|
- Gemfile
|
68
265
|
- Guardfile
|
69
266
|
- LICENSE
|
@@ -71,22 +268,23 @@ files:
|
|
71
268
|
- Rakefile
|
72
269
|
- bin/pushover
|
73
270
|
- lib/pushover.rb
|
74
|
-
- lib/pushover/
|
75
|
-
- lib/pushover/
|
76
|
-
- lib/pushover/
|
77
|
-
- lib/pushover/
|
271
|
+
- lib/pushover/api.rb
|
272
|
+
- lib/pushover/message.rb
|
273
|
+
- lib/pushover/receipt.rb
|
274
|
+
- lib/pushover/request.rb
|
275
|
+
- lib/pushover/response.rb
|
78
276
|
- lib/pushover/version.rb
|
79
277
|
- pushover.gemspec
|
80
|
-
- spec/
|
81
|
-
- spec/
|
82
|
-
- spec/lib/pushover/
|
83
|
-
- spec/lib/pushover/
|
278
|
+
- spec/lib/pushover/api_spec.rb
|
279
|
+
- spec/lib/pushover/message_spec.rb
|
280
|
+
- spec/lib/pushover/receipt_spec.rb
|
281
|
+
- spec/lib/pushover/request_spec.rb
|
282
|
+
- spec/lib/pushover/response_spec.rb
|
84
283
|
- spec/lib/pushover_spec.rb
|
85
284
|
- spec/spec_helper.rb
|
86
|
-
- whatsnew.md
|
87
285
|
homepage: https://github.com/erniebrodeur/pushover
|
88
286
|
licenses:
|
89
|
-
-
|
287
|
+
- MIT
|
90
288
|
metadata: {}
|
91
289
|
post_install_message:
|
92
290
|
rdoc_options:
|
@@ -111,15 +309,15 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
111
309
|
version: '0'
|
112
310
|
requirements: []
|
113
311
|
rubyforge_project:
|
114
|
-
rubygems_version: 2.
|
312
|
+
rubygems_version: 2.6.11
|
115
313
|
signing_key:
|
116
314
|
specification_version: 4
|
117
|
-
summary: This
|
315
|
+
summary: This spec provides both an API and CLI interface to pushover.net.
|
118
316
|
test_files:
|
119
|
-
- spec/
|
120
|
-
- spec/
|
121
|
-
- spec/lib/pushover/
|
122
|
-
- spec/lib/pushover/
|
317
|
+
- spec/lib/pushover/api_spec.rb
|
318
|
+
- spec/lib/pushover/message_spec.rb
|
319
|
+
- spec/lib/pushover/receipt_spec.rb
|
320
|
+
- spec/lib/pushover/request_spec.rb
|
321
|
+
- spec/lib/pushover/response_spec.rb
|
123
322
|
- spec/lib/pushover_spec.rb
|
124
323
|
- spec/spec_helper.rb
|
125
|
-
has_rdoc: yard
|
data/.travis.yml
DELETED
data/lib/pushover/app.rb
DELETED
@@ -1,64 +0,0 @@
|
|
1
|
-
module Pushover
|
2
|
-
# Stores a application definition in the config file.
|
3
|
-
module App
|
4
|
-
# an instance of an application.
|
5
|
-
# @!attribute name
|
6
|
-
# @return [String] the name of the application.
|
7
|
-
# @!attribute api_key
|
8
|
-
# @return [String] the api_key of the application.
|
9
|
-
class App
|
10
|
-
attr_accessor :name
|
11
|
-
attr_accessor :api_key
|
12
|
-
|
13
|
-
def initialize(name, api_key)
|
14
|
-
@name = name
|
15
|
-
@api_key = api_key
|
16
|
-
Bini::Config[:applications] = {} if !Bini::Config[:applications]
|
17
|
-
Bini::Config[:applications][name] = api_key
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
21
|
-
extend self
|
22
|
-
|
23
|
-
# Find the apikey in the applications, or pass on the word to try direct access.
|
24
|
-
# @param [String] word the search token, can be an apikey or appname.
|
25
|
-
# @return [String] return the apikey (if it can find one) or the word itself.
|
26
|
-
def find(word)
|
27
|
-
return Bini::Config[:applications][word] if Bini::Config[:applications] && Bini::Config[:applications][word]
|
28
|
-
word
|
29
|
-
end
|
30
|
-
|
31
|
-
# Add an application to the config file and save it.
|
32
|
-
# @param [String] api_key is the api_key to be used.
|
33
|
-
# @param [String] name is the short name that can be referenced later.
|
34
|
-
# @return [Boolean] return the results of the save attempt.
|
35
|
-
def add(name, api_key)
|
36
|
-
App.new name, api_key
|
37
|
-
Bini::Config.save
|
38
|
-
end
|
39
|
-
|
40
|
-
def remove(name)
|
41
|
-
Bini::Config[:applications].delete name if Bini::Config[:applications]
|
42
|
-
end
|
43
|
-
# Return the current app selected, or the first one saved.
|
44
|
-
def current_app
|
45
|
-
# did something get supplied on the cli? try to find it.
|
46
|
-
if Bini::Options[:token]
|
47
|
-
@current_app = find Bini::Options[:token]
|
48
|
-
else
|
49
|
-
@current_app = find Bini::Config[:applications].values.first if Bini::Config[:applications]
|
50
|
-
end
|
51
|
-
@current_app
|
52
|
-
end
|
53
|
-
|
54
|
-
def current_app=(app)
|
55
|
-
@current_app = app
|
56
|
-
end
|
57
|
-
|
58
|
-
# Will return true if we can find an application either via the cli or save file.
|
59
|
-
def current_app?
|
60
|
-
return true if current_app
|
61
|
-
return nil
|
62
|
-
end
|
63
|
-
end
|
64
|
-
end
|