pushover 0.5.1 → 0.99.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +79 -41
- data/bin/pushover +9 -4
- data/lib/pushover.rb +42 -7
- data/lib/pushover/app.rb +7 -7
- data/lib/pushover/user.rb +7 -7
- data/lib/pushover/version.rb +1 -1
- data/pushover.gemspec +2 -2
- data/spec/lib/pushover/app_spec.rb +6 -5
- data/spec/lib/pushover/pushover_spec.rb +45 -3
- data/spec/lib/pushover/user_spec.rb +7 -6
- data/spec/spec_helper.rb +1 -4
- data/whatsnew.md +21 -10
- metadata +4 -4
data/README.md
CHANGED
@@ -1,32 +1,22 @@
|
|
1
1
|
# Pushover
|
2
|
+
**Master** [![Code Climate](https://codeclimate.com/badge.png)](https://codeclimate.com/github/erniebrodeur/pushover) [![Build Status](https://travis-ci.org/erniebrodeur/pushover.png?branch=master)](https://travis-ci.org/erniebrodeur/pushover) [![Dependency Status](https://gemnasium.com/erniebrodeur/pushover.png)](https://gemnasium.com/erniebrodeur/pushover)
|
3
|
+
**Development** [![Build Status](https://travis-ci.org/erniebrodeur/pushover.png?branch=development)](https://travis-ci.org/erniebrodeur/pushover)
|
2
4
|
|
3
5
|
This gem provides a CLI and an API interface to http://pushover.net.
|
4
6
|
|
5
|
-
#### Build Status
|
6
|
-
<table border="0">
|
7
|
-
<tr>
|
8
|
-
<td>master</td>
|
9
|
-
<td><a href=http://travis-ci.org/erniebrodeur/pushover?branch=master><img src="https://secure.travis-ci.org/erniebrodeur/pushover.png?branch=master"/></h> </td>
|
10
|
-
</tr>
|
11
|
-
<tr>
|
12
|
-
<td>development</td>
|
13
|
-
<td><a href=http://travis-ci.org/erniebrodeur/pushover?branch=development><img src="https://secure.travis-ci.org/erniebrodeur/pushover.png?branch=development"/></h> </td>
|
14
|
-
</tr>
|
15
|
-
</table>
|
16
|
-
|
17
7
|
## Installation
|
18
8
|
|
19
9
|
To install:
|
20
10
|
|
21
|
-
|
11
|
+
$ gem install pushover
|
22
12
|
|
23
13
|
To use inside of an application, add this to the your gemfile:
|
24
14
|
|
25
|
-
|
15
|
+
$ gem 'pushover'
|
26
16
|
|
27
17
|
and run bundle to make it available:
|
28
18
|
|
29
|
-
|
19
|
+
$ bundle
|
30
20
|
|
31
21
|
## Usage
|
32
22
|
|
@@ -50,59 +40,107 @@ end
|
|
50
40
|
|
51
41
|
Pushover.notification('message', 'title')
|
52
42
|
```
|
43
|
+
|
53
44
|
### CLI:
|
54
45
|
|
55
46
|
To get help do, try ```--(h)elp```
|
56
47
|
|
57
|
-
|
58
|
-
% pushover --h
|
48
|
+
$ pushover -h
|
59
49
|
|
60
50
|
To send a message.
|
61
51
|
|
62
|
-
|
52
|
+
$ pushover -u user_token -a app_key message is the rest of the cli.
|
63
53
|
|
64
54
|
#### Optional parameters
|
65
55
|
|
66
|
-
|
67
|
-
* Config_file: the file to use for stored credentials.
|
68
|
-
* Priority: Priority of the message, as an integer (for now).
|
69
|
-
* -1: low
|
70
|
-
* 0: normal
|
71
|
-
* 1: high
|
72
|
-
* Device: specific device to send the notification to.
|
56
|
+
Most optional parameters have a shorter form you can use. If that's the case, they will be displayed like ```--(h)elp```.
|
73
57
|
|
58
|
+
#### Config_file
|
74
59
|
|
75
|
-
|
60
|
+
The file to use for stored settings (including credentials).
|
76
61
|
|
77
|
-
|
62
|
+
$ pushover --(c)onfig_file /tmp/config_file
|
78
63
|
|
79
|
-
User:
|
80
64
|
|
81
|
-
|
65
|
+
#### Title
|
82
66
|
|
83
|
-
|
67
|
+
The title of the message, if not supplied it will end up being the app name.
|
84
68
|
|
85
|
-
|
69
|
+
$ pushover --(t)itle "A title"
|
86
70
|
|
87
|
-
|
71
|
+
$ pushover --(t)itle "A title"
|
88
72
|
|
89
|
-
|
73
|
+
#### Priority
|
90
74
|
|
91
|
-
|
75
|
+
Priority of the message, either (low,normal,high) or (-1,0,1). For the string you only need the first letter.
|
92
76
|
|
93
|
-
|
77
|
+
$ pushover --(p)riority high
|
94
78
|
|
95
|
-
|
79
|
+
$ pushover --(p)riority h
|
96
80
|
|
97
|
-
|
81
|
+
$ pushover --(p)riority -1
|
82
|
+
|
83
|
+
#### Device
|
84
|
+
|
85
|
+
Specific device to send the message too, must be registered at pushover.net
|
86
|
+
|
87
|
+
$ pushover --(d)evice "Device name"
|
88
|
+
|
89
|
+
#### URL
|
90
|
+
|
91
|
+
Supplementary URL that can be passed with the message.
|
92
|
+
|
93
|
+
$ pushover --url "http://www.github.com/erniebrodeur/pushover"
|
94
|
+
|
95
|
+
##### URL Title
|
96
|
+
|
97
|
+
The display string of the supplementary URL.
|
98
|
+
|
99
|
+
$ pushover --url "http://www.git.com/erniebrodeur/pushover" --url_title "This repo."
|
100
|
+
|
101
|
+
#### Time
|
102
|
+
|
103
|
+
Time is tricky, I just pass the string off to the stdlib ```Time.parse```. Therefore, if it fails I can't do much about it. Though, it shouldn't fail, it seems to take just a ton of stuff. You can always handle this yourself and just pass in an epoch (string or fixnum).
|
98
104
|
|
99
|
-
|
105
|
+
$ pushover --time 1331249662
|
100
106
|
|
101
|
-
|
107
|
+
$ pushover --time "6:30"
|
102
108
|
|
103
|
-
|
109
|
+
##### String examples
|
104
110
|
|
105
|
-
|
111
|
+
As far as I can tell, you can toss a ton of different things and get an output.
|
112
|
+
|
113
|
+
* rfc822: Tue, 14 Nov 2000 14:55:07 -0500
|
114
|
+
* xml: 1979-08-13T06:30:00.313UTC
|
115
|
+
* Aug 13, 1979 6:30
|
116
|
+
* 1979/08/13, 6:30:50 UTC
|
117
|
+
* 6:30
|
118
|
+
* 14:30
|
119
|
+
* Aug 21
|
120
|
+
|
121
|
+
#### Saving
|
122
|
+
|
123
|
+
You can also save and use stored information. The username/application are titles. They can be anything you want to reference them.
|
124
|
+
|
125
|
+
##### User
|
126
|
+
|
127
|
+
$ pushover -u user_token --save-user email@somewhere.net
|
128
|
+
|
129
|
+
##### Application
|
130
|
+
|
131
|
+
$ pushover -a app_key --save-app myApp
|
132
|
+
|
133
|
+
Delete done in the api, not lifted to the cli.
|
134
|
+
|
135
|
+
Now, you can use these to send messages instead of having to remeber the key:
|
136
|
+
|
137
|
+
$ pushover -a myApp -u email@somewhere.net Hello from somewhere!
|
138
|
+
|
139
|
+
If you don't supply the application or user name, it will use the first one in the save file.
|
140
|
+
|
141
|
+
$ pushover so now I can just send an app.
|
142
|
+
|
143
|
+
Anytime you supply token's directly to the cli, it will ignore any saved information and try them. This allows you to use it as a once-off tool while keeping credentials stored.
|
106
144
|
|
107
145
|
## Contributing
|
108
146
|
|
data/bin/pushover
CHANGED
@@ -7,9 +7,12 @@ include Pushover
|
|
7
7
|
Options.on("-u", "--user USER", "Which user, can be a saved name or token.") { |o| Options[:user] = o}
|
8
8
|
Options.on("-a", "--app APPKEY", "Which app to notify, can be a saved name or apikey.") { |o| Options[:appkey] = o}
|
9
9
|
Options.on("-t", "--title [TITLE]", "Set the title of the notification (optional).") { |o| Options[:title] = o}
|
10
|
-
Options.on("-p", "--priority [PRIORITY]",
|
10
|
+
Options.on("-p", "--priority [PRIORITY]", "Set the priority of the notification from (low,normal,high) (optional).") { |o| Options[:priority] = o}
|
11
11
|
Options.on("-d", "--device [DEVICE]", "Specify the device to send the notifcation to. (optional).") { |o| Options[:device] = o}
|
12
12
|
Options.on("-c", "--config_file [FILE]", "Set the target config file.") {|o| Options[:config_file] = o}
|
13
|
+
Options.on("--url [URL]", "Supplementary URL") { |o| Options[:url] = o }
|
14
|
+
Options.on("--url_title [TITLE]", "Supplementary URL title.") { |o| Options[:url_title] = o }
|
15
|
+
Options.on("--time [TIME]", "Set the messages time.") {|o| Options[:timestamp] = o}
|
13
16
|
Options.on("--save-app NAME", "Saves the application to the config file under NAME.") { |o| Options[:save_app] = [Options[:appkey], o]}
|
14
17
|
Options.on("--save-user NAME", "Saves the user to the config file under NAME.") { |o| Options[:save_user] = [Options[:user], o]}
|
15
18
|
|
@@ -53,6 +56,7 @@ if !App.current_app?
|
|
53
56
|
end
|
54
57
|
|
55
58
|
if !User.current_user?
|
59
|
+
puts User.current_user?
|
56
60
|
puts "Couldn't find a user via the cli or save file."
|
57
61
|
bail = true
|
58
62
|
end
|
@@ -66,8 +70,10 @@ Pushover.configure do |c|
|
|
66
70
|
end
|
67
71
|
|
68
72
|
# Or in real time, which will also overwrite the .configure block.
|
69
|
-
|
70
|
-
|
73
|
+
options = Options[].select { |k,v| v}
|
74
|
+
|
75
|
+
options.merge! message:message
|
76
|
+
response = Pushover.notification options
|
71
77
|
|
72
78
|
if response.code == "200"
|
73
79
|
puts "Message sent successfully!"
|
@@ -75,4 +81,3 @@ else
|
|
75
81
|
j = Yajl.load response.body
|
76
82
|
puts "ErrorCode (#{response.code}): #{j['errors'].first}."
|
77
83
|
end
|
78
|
-
|
data/lib/pushover.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
require "net/https"
|
2
2
|
require "yajl"
|
3
|
+
require 'time'
|
3
4
|
require 'bini'
|
4
5
|
require 'bini/config'
|
5
6
|
require 'bini/optparser'
|
@@ -10,8 +11,8 @@ require "pushover/user"
|
|
10
11
|
# The primary pushover namespace.
|
11
12
|
module Pushover
|
12
13
|
# lets save our config to it's own dir, just because.
|
13
|
-
Bini.
|
14
|
-
Bini.
|
14
|
+
Bini::Config.file = "#{Dir.home}/.config/pushover/credentials.yaml"
|
15
|
+
Bini::Config.load
|
15
16
|
|
16
17
|
extend self
|
17
18
|
|
@@ -23,10 +24,44 @@ module Pushover
|
|
23
24
|
attr_accessor :message
|
24
25
|
# [optional,String] Title of the message.
|
25
26
|
attr_accessor :title
|
26
|
-
# [optional,Fixnum] priority The priority of the message, from -1 to 1.
|
27
|
-
attr_accessor :priority
|
28
27
|
# [optional,String] device to recieve the message.
|
29
28
|
attr_accessor :device
|
29
|
+
attr_accessor :url
|
30
|
+
attr_accessor :url_title
|
31
|
+
# [optional,String, Fixnum] time a time stamp im one of three forms (epoch, strfmt, rails)
|
32
|
+
attr_reader :timestamp
|
33
|
+
attr_reader :priority
|
34
|
+
def priority=(level)
|
35
|
+
if level.class == String
|
36
|
+
if level =~ /^[lL]/
|
37
|
+
@priority = -1
|
38
|
+
elsif level =~ /^[hH]/
|
39
|
+
@priority = 1
|
40
|
+
else
|
41
|
+
@priority = 0
|
42
|
+
end
|
43
|
+
elsif level.class == Fixnum
|
44
|
+
@priority = level
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
# Stdlib time, seems to take a shitload of options.
|
49
|
+
# rfc822: Tue, 14 Nov 2000 14:55:07 -0500
|
50
|
+
# xml: 1979-08-13T06:30:00.313UTC
|
51
|
+
# Time.parse 'Aug 13, 1979 6:30'
|
52
|
+
# Time.parse '1979/08/13, 6:30:50 UTC'
|
53
|
+
def timestamp=(time_string)
|
54
|
+
if time_string.class == String
|
55
|
+
begin
|
56
|
+
@timestamp = Time.parse(time_string).to_i
|
57
|
+
rescue ArgumentError
|
58
|
+
@timestamp = time_string.to_i
|
59
|
+
end
|
60
|
+
elsif
|
61
|
+
time_string.class == Fixnum
|
62
|
+
@timestamp = time_string
|
63
|
+
end
|
64
|
+
end
|
30
65
|
|
31
66
|
# push a message to pushover, must supply all variables.
|
32
67
|
# @param [String] message The message to be sent
|
@@ -37,9 +72,10 @@ module Pushover
|
|
37
72
|
# @param [optional, String] user the user token.
|
38
73
|
# @return [String] the response from pushover.net, in json.
|
39
74
|
def notification(tokens={})
|
75
|
+
tokens.each {|k,v| send("#{k}=", tokens[k])}
|
40
76
|
url = URI.parse("https://api.pushover.net/1/messages.json")
|
41
77
|
req = Net::HTTP::Post.new(url.path)
|
42
|
-
req.set_form_data(params
|
78
|
+
req.set_form_data(params)
|
43
79
|
res = Net::HTTP.new(url.host, url.port)
|
44
80
|
res.use_ssl = true
|
45
81
|
res.verify_mode = OpenSSL::SSL::VERIFY_PEER
|
@@ -74,7 +110,6 @@ module Pushover
|
|
74
110
|
|
75
111
|
# A [Array] of keys available in Pushover.
|
76
112
|
def keys
|
77
|
-
keys ||= [:token, :user, :message, :title, :priority, :device]
|
113
|
+
keys ||= [:token, :user, :message, :title, :priority, :device, :timestamp, :url, :url_title]
|
78
114
|
end
|
79
115
|
end
|
80
|
-
|
data/lib/pushover/app.rb
CHANGED
@@ -13,8 +13,8 @@ module Pushover
|
|
13
13
|
def initialize(name, api_key)
|
14
14
|
@name = name
|
15
15
|
@api_key = api_key
|
16
|
-
Bini
|
17
|
-
Bini
|
16
|
+
Bini::Config[:applications] = {} if !Bini::Config[:applications]
|
17
|
+
Bini::Config[:applications][name] = api_key
|
18
18
|
end
|
19
19
|
end
|
20
20
|
|
@@ -24,7 +24,7 @@ module Pushover
|
|
24
24
|
# @param [String] word the search token, can be an apikey or appname.
|
25
25
|
# @return [String] return the apikey (if it can find one) or the word itself.
|
26
26
|
def find(word)
|
27
|
-
return Bini
|
27
|
+
return Bini::Config[:applications][word] if Bini::Config[:applications] && Bini::Config[:applications][word]
|
28
28
|
word
|
29
29
|
end
|
30
30
|
|
@@ -34,11 +34,11 @@ module Pushover
|
|
34
34
|
# @return [Boolean] return the results of the save attempt.
|
35
35
|
def add(name, api_key)
|
36
36
|
App.new name, api_key
|
37
|
-
Bini.
|
37
|
+
Bini::Config.save!
|
38
38
|
end
|
39
39
|
|
40
40
|
def remove(name)
|
41
|
-
Bini
|
41
|
+
Bini::Config[:applications].delete name if Bini::Config[:applications]
|
42
42
|
end
|
43
43
|
# Return the current app selected, or the first one saved.
|
44
44
|
def current_app
|
@@ -49,7 +49,7 @@ module Pushover
|
|
49
49
|
|
50
50
|
# no? do we have anything we can return?
|
51
51
|
if !@current_app
|
52
|
-
@current_app = find Bini
|
52
|
+
@current_app = find Bini::Config[:applications].first[0] if Bini::Config[:applications]
|
53
53
|
end
|
54
54
|
@current_app
|
55
55
|
end
|
@@ -60,7 +60,7 @@ module Pushover
|
|
60
60
|
|
61
61
|
# Will return true if we can find an application either via the cli or save file.
|
62
62
|
def current_app?
|
63
|
-
return true if
|
63
|
+
return true if current_app
|
64
64
|
return nil
|
65
65
|
end
|
66
66
|
end
|
data/lib/pushover/user.rb
CHANGED
@@ -13,8 +13,8 @@ module Pushover
|
|
13
13
|
def initialize(name, token)
|
14
14
|
@name = name
|
15
15
|
@token = token
|
16
|
-
Bini
|
17
|
-
Bini
|
16
|
+
Bini::Config[:users] = {} if !Bini::Config[:users]
|
17
|
+
Bini::Config[:users][name] = token
|
18
18
|
end
|
19
19
|
|
20
20
|
end
|
@@ -25,7 +25,7 @@ module Pushover
|
|
25
25
|
# @param [String] word the search token, can be an apikey or appname.
|
26
26
|
# @return [String] return the apikey (if it can find one) or the word itself.
|
27
27
|
def find(word)
|
28
|
-
return Bini
|
28
|
+
return Bini::Config[:users][word] if Bini::Config[:users] && Bini::Config[:users][word]
|
29
29
|
word
|
30
30
|
end
|
31
31
|
|
@@ -35,11 +35,11 @@ module Pushover
|
|
35
35
|
# @return [Boolean] return the results of the save attempt.
|
36
36
|
def add(name, token)
|
37
37
|
User.new name, token
|
38
|
-
Bini.
|
38
|
+
Bini::Config.save!
|
39
39
|
end
|
40
40
|
|
41
41
|
def remove(name)
|
42
|
-
Bini
|
42
|
+
Bini::Config[:users].delete name if Bini::Config[:users]
|
43
43
|
end
|
44
44
|
|
45
45
|
# Return the current user selected, or the first one saved.
|
@@ -51,7 +51,7 @@ module Pushover
|
|
51
51
|
|
52
52
|
# no? do we have anything we can return?
|
53
53
|
if !@current_user
|
54
|
-
@current_user = find Bini
|
54
|
+
@current_user = find Bini::Config[:users].first[0] if Bini::Config[:users]
|
55
55
|
end
|
56
56
|
@current_user
|
57
57
|
end
|
@@ -63,7 +63,7 @@ module Pushover
|
|
63
63
|
|
64
64
|
# Will return true if it can find a user either via the cli or save file.
|
65
65
|
def current_user?
|
66
|
-
return true if
|
66
|
+
return true if current_user
|
67
67
|
return nil
|
68
68
|
end
|
69
69
|
end
|
data/lib/pushover/version.rb
CHANGED
data/pushover.gemspec
CHANGED
@@ -10,8 +10,8 @@ Gem::Specification.new do |gem|
|
|
10
10
|
gem.platform = Gem::Platform::RUBY
|
11
11
|
|
12
12
|
# descriptions
|
13
|
-
gem.description = "
|
14
|
-
gem.summary = "This gem
|
13
|
+
gem.description = "Api (and CLI) to interface with pushover.net"
|
14
|
+
gem.summary = "This gem provides both an API and CLI interface to pushover.net."
|
15
15
|
gem.homepage = "https://github.com/erniebrodeur/pushover"
|
16
16
|
|
17
17
|
#files
|
@@ -2,20 +2,21 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
describe "application" do
|
4
4
|
before(:each) do
|
5
|
-
Bini.
|
6
|
-
Bini.
|
5
|
+
Bini::Config.file = "tmp/test.save"
|
6
|
+
Bini::Config.clear
|
7
|
+
Bini::Options.clear
|
7
8
|
App.current_app = nil
|
8
9
|
end
|
9
10
|
|
10
11
|
it "can add a application to the Config[:application] hash." do
|
11
12
|
App.add "foo", "bar"
|
12
|
-
Bini
|
13
|
+
Bini::Config[:applications]["foo"].should eq("bar")
|
13
14
|
end
|
14
15
|
|
15
16
|
it "can remove a application from the hash." do
|
16
17
|
App.add "foo", "bar"
|
17
18
|
App.remove "foo"
|
18
|
-
Bini
|
19
|
+
Bini::Config[:applications]["foo"].should be_nil
|
19
20
|
end
|
20
21
|
|
21
22
|
describe "#find" do
|
@@ -35,7 +36,7 @@ describe "application" do
|
|
35
36
|
end
|
36
37
|
it "will grab the first app in the config as a last resort" do
|
37
38
|
App.add "foo", "bar2"
|
38
|
-
Bini.
|
39
|
+
Bini::Config.save
|
39
40
|
Bini::Options[:apikey] = nil
|
40
41
|
App.current_app.should eq "bar2"
|
41
42
|
end
|
@@ -17,7 +17,13 @@ describe "Pushover" do
|
|
17
17
|
|
18
18
|
describe "#parameters?" do
|
19
19
|
it 'will return true only if every key is set to something.' do
|
20
|
-
keys.each
|
20
|
+
keys.each do |k|
|
21
|
+
if k == :timestamp
|
22
|
+
Pushover.send("timestamp=", '1970-01-01 00:00:01 UTC')
|
23
|
+
else
|
24
|
+
Pushover.send("#{k}=", 'ladeda')
|
25
|
+
end
|
26
|
+
end
|
21
27
|
parameters?.should eq true
|
22
28
|
end
|
23
29
|
it 'will return false otherwise.' do
|
@@ -41,8 +47,44 @@ describe "Pushover" do
|
|
41
47
|
describe "#notification" do
|
42
48
|
it "can send a notification" do
|
43
49
|
setup_webmocks
|
44
|
-
|
45
|
-
|
50
|
+
Pushover.notification message:'a message', token:'good_token', user:'good_user'
|
51
|
+
WebMock.should have_requested(:post, /.*api.pushover.net.*/).with do |req|
|
52
|
+
puts req.body hash_including(priority:'ajkasdfj')
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
describe "extra behavior" do
|
58
|
+
describe "Priority" do
|
59
|
+
it "can be set by text" do
|
60
|
+
setup_webmocks
|
61
|
+
Pushover.notification message:'a message', token:'good_token', user:'good_user', priority:'low'
|
62
|
+
WebMock.should have_requested(:post, /.*api.pushover.net.*/).with { |req| req.body.include? 'priority=-1'}
|
63
|
+
setup_webmocks
|
64
|
+
Pushover.notification message:'a message', token:'good_token', user:'good_user', priority:'high'
|
65
|
+
WebMock.should have_requested(:post, /.*api.pushover.net.*/).with { |req| req.body.include? 'priority=1'}
|
66
|
+
end
|
67
|
+
it "falls back to normal" do
|
68
|
+
setup_webmocks
|
69
|
+
Pushover.notification message:'a message', token:'good_token', user:'good_user', priority:'kwkru'
|
70
|
+
WebMock.should have_requested(:post, /api.pushover.net/).with { |req| req.body.include? 'priority=0' }
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
describe "Time" do
|
75
|
+
it "can be set by epoch" do
|
76
|
+
setup_webmocks
|
77
|
+
Pushover.notification message:'a message', token:'good_token', user:'good_user', timestamp:1000
|
78
|
+
Pushover.notification message:'a message', token:'good_token', user:'good_user', timestamp:'1000'
|
79
|
+
WebMock.should have_requested(:post, /api.pushover.net/).with { |req| req.body.include? 'timestamp=1000' }.twice
|
80
|
+
end
|
81
|
+
|
82
|
+
it "can be set by a text string" do
|
83
|
+
setup_webmocks
|
84
|
+
Pushover.notification message:'a message', token:'good_token', user:'good_user', timestamp:'1970-01-01 00:00:01 UTC'
|
85
|
+
WebMock.should have_requested(:post, /api.pushover.net/).with { |req| req.body.include? 'timestamp=1' }
|
86
|
+
end
|
46
87
|
end
|
47
88
|
end
|
48
89
|
end
|
90
|
+
|
@@ -2,20 +2,21 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
describe "user" do
|
4
4
|
before(:each) do
|
5
|
-
Bini.
|
6
|
-
Bini.
|
5
|
+
Bini::Config.file = "tmp/test.save"
|
6
|
+
Bini::Config.clear
|
7
|
+
Bini::Options.clear
|
7
8
|
User.current_user = nil
|
8
9
|
end
|
9
10
|
|
10
11
|
it "can add a user to the Config[:users] hash." do
|
11
12
|
User.add "foo", "bar"
|
12
|
-
Bini
|
13
|
+
Bini::Config[:users]["foo"].should eq("bar")
|
13
14
|
end
|
14
15
|
|
15
16
|
it "can remove a user from the hash." do
|
16
17
|
User.add "foo", "bar"
|
17
18
|
User.remove "foo"
|
18
|
-
Bini
|
19
|
+
Bini::Config[:users]["foo"].should be_nil
|
19
20
|
end
|
20
21
|
|
21
22
|
describe "#find" do
|
@@ -35,7 +36,7 @@ describe "user" do
|
|
35
36
|
end
|
36
37
|
it "will grab the first user in the config as a last resort" do
|
37
38
|
User.add "foo", "bar2"
|
38
|
-
Bini.
|
39
|
+
Bini::Config.save
|
39
40
|
Bini::Options[:token] = nil
|
40
41
|
User.current_user.should eq "bar2"
|
41
42
|
end
|
@@ -44,7 +45,7 @@ describe "user" do
|
|
44
45
|
describe "#current_user?" do
|
45
46
|
it "Will return true if we have a current_user" do
|
46
47
|
Bini::Options[:token] = 'somethingsilly'
|
47
|
-
User.current_user
|
48
|
+
User.current_user?.should be_true
|
48
49
|
end
|
49
50
|
it "Will return nil otherwise" do
|
50
51
|
User.current_user?.should be_nil
|
data/spec/spec_helper.rb
CHANGED
@@ -10,8 +10,8 @@ if ENV["COVERAGE"] == 'true'
|
|
10
10
|
add_filter "/spec/"
|
11
11
|
end
|
12
12
|
end
|
13
|
-
require 'webmock/rspec'
|
14
13
|
|
14
|
+
require 'webmock/rspec'
|
15
15
|
require 'pushover'
|
16
16
|
|
17
17
|
include Pushover
|
@@ -36,6 +36,3 @@ def setup_webmocks
|
|
36
36
|
stub_http_request(:post, "https://api.pushover.net/1/messages.json").to_return(:status => 200,
|
37
37
|
:headers => {}, :body => bad_user).with(:body => hash_including({token:'good_token', user:'bad_user'}))
|
38
38
|
end
|
39
|
-
|
40
|
-
|
41
|
-
|
data/whatsnew.md
CHANGED
@@ -1,22 +1,33 @@
|
|
1
|
-
0.
|
1
|
+
## 0.99.0 (unreleased):
|
2
|
+
* Added url and a url_title.
|
3
|
+
* Added time, we can take an epoch or string. The string is run through stdlib Time#parse, so effectively takes rfc822, html, xml, and a bunch of random bits.
|
4
|
+
* Added gemnasium to the readme.
|
5
|
+
* Added code climate to the readme.
|
6
|
+
* Updated for Bini 0.6.0
|
7
|
+
* Priority takes a text or integer argument now.
|
8
|
+
|
9
|
+
## 0.5.1:
|
2
10
|
* SimpleCov and 100% test coverage
|
3
|
-
* Webmock based testing for Pushover
|
11
|
+
* Webmock based testing for Pushover##notification.
|
4
12
|
* Added intergration to http://travis-ci.org
|
5
13
|
|
6
|
-
0.5.0:
|
14
|
+
## 0.5.0:
|
7
15
|
* Switched the order of App and it's derivatives so that it's name, api_key to make it more human readable.
|
8
16
|
* Ditto for User.
|
9
17
|
* Merged in me bones.
|
10
18
|
* Using bini's logic whenever possible now instead of reinventing the wheel.
|
11
|
-
|
12
|
-
|
13
|
-
|
19
|
+
|
20
|
+
## 0.4.0:
|
21
|
+
* Added priority and device specification.
|
22
|
+
* Moved all the variables, including message, into the configure block.
|
14
23
|
* Updated the gemspec with some more information.
|
15
24
|
* Better output for error messages.
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
25
|
+
|
26
|
+
## 0.3.1
|
27
|
+
* Added benwoody's changes back to the system, this allows for some nifty generators.
|
28
|
+
* Fixed the nasty bug where it wasn't working once installed.
|
29
|
+
|
30
|
+
## 0.3.0
|
20
31
|
* No longer need to supply credentials at all if you have some saved.
|
21
32
|
* Fixed up a ton of documentation and spelling mistakes.
|
22
33
|
* Various bug fixes.
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pushover
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.99.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-12-
|
12
|
+
date: 2012-12-23 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: yajl-ruby
|
@@ -43,7 +43,7 @@ dependencies:
|
|
43
43
|
- - ! '>='
|
44
44
|
- !ruby/object:Gem::Version
|
45
45
|
version: '0'
|
46
|
-
description:
|
46
|
+
description: Api (and CLI) to interface with pushover.net
|
47
47
|
email:
|
48
48
|
- ebrodeur@ujami.net
|
49
49
|
executables:
|
@@ -102,7 +102,7 @@ rubyforge_project:
|
|
102
102
|
rubygems_version: 1.8.21
|
103
103
|
signing_key:
|
104
104
|
specification_version: 3
|
105
|
-
summary: This gem
|
105
|
+
summary: This gem provides both an API and CLI interface to pushover.net.
|
106
106
|
test_files:
|
107
107
|
- spec/bin/pushover_spec.rb
|
108
108
|
- spec/lib/pushover/app_spec.rb
|