prowly 0.2.4 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/CONTRIBUTORS.md +5 -0
- data/LICENSE +1 -1
- data/README.rdoc +37 -12
- data/Rakefile +1 -3
- data/VERSION +1 -1
- data/bin/prowly +7 -1
- data/bin/prowly_retrieve_apikey +57 -0
- data/lib/prowly.rb +8 -23
- data/lib/prowly/interface.rb +3 -24
- data/lib/prowly/notification.rb +2 -1
- data/lib/prowly/response.rb +18 -17
- data/prowly.gemspec +21 -25
- data/test/helper.rb +0 -1
- data/test/test_prowly.rb +75 -2
- metadata +16 -23
- data/.gitignore +0 -21
data/CONTRIBUTORS.md
ADDED
data/LICENSE
CHANGED
data/README.rdoc
CHANGED
@@ -8,12 +8,15 @@ Yet another Ruby interface to Prowl with command line utility
|
|
8
8
|
|
9
9
|
== Usage as a Gem
|
10
10
|
|
11
|
+
Sending a notification via prowly gem
|
12
|
+
|
11
13
|
Prowly.notify do |n| # :notify is an alias of :add
|
12
14
|
n.apikey = "apikey" or n.apikeys = ["apikey_1", "apikey_2", "apikey_n"]
|
13
15
|
n.priority = Prowly::Notification::Priority::MODERATE
|
14
16
|
n.application = "Prowly"
|
15
17
|
n.event = "Notification"
|
16
18
|
n.description = "Your server is under attack!!!"
|
19
|
+
n.url = "http://www.myserver.com"
|
17
20
|
end
|
18
21
|
|
19
22
|
notification = Prowly::Notification.new(:apikey => "apikey", :application => "Prowly", :description => "Testing...")
|
@@ -21,6 +24,30 @@ Yet another Ruby interface to Prowl with command line utility
|
|
21
24
|
|
22
25
|
result = Prowly.notify(notification)
|
23
26
|
|
27
|
+
Obtaining a user's API key with the prowly gem is a three step process:
|
28
|
+
|
29
|
+
- provider gets a token with their provider key via the retrieve_token call
|
30
|
+
- user approves the request at a special web URL (in their browser)
|
31
|
+
- provider gets user's API key with their provider key and the token via retrieve_apikey
|
32
|
+
|
33
|
+
This is somewhat similar to the OAuth scheme.
|
34
|
+
|
35
|
+
# obtain a token first with your provider key first
|
36
|
+
provider_key = "2b33d3f3f8522aaed4b2fc44382f1519791db6a2"
|
37
|
+
token_result = Prowly.retrieve_token(provider_key)
|
38
|
+
if token_result.succeeded?
|
39
|
+
# if the call succeeded, the user will need to approve the request in their browser
|
40
|
+
puts "go to this #{token_result.url} to approve this request"
|
41
|
+
puts "then press <ENTER> to continue "
|
42
|
+
dummy = STDIN.gets
|
43
|
+
|
44
|
+
apikey_result = Prowly.retrieve_apikey(options[:provider], token_result.token)
|
45
|
+
|
46
|
+
if apikey_result.succeeded?
|
47
|
+
puts "The user apikey is #{apikey_result.apikey}"
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
24
51
|
== Usage in the command line
|
25
52
|
|
26
53
|
$prowly -h # help
|
@@ -33,15 +60,17 @@ Yet another Ruby interface to Prowl with command line utility
|
|
33
60
|
-d, --description DESCRIPTION Description
|
34
61
|
-e, --event EVENT Event
|
35
62
|
-p, --priority PRIORITY VERY_LOW, MODERATE, NORMAL (default), HIGH, EMERGENCY
|
63
|
+
-u, --url URL for redirect (v1.2 feature)
|
36
64
|
-v, --version Print the version number and exit
|
37
|
-
|
65
|
+
|
38
66
|
If you only specify the apikey prowly will use the defaults:
|
39
|
-
|
67
|
+
|
40
68
|
:description => "I am testing Prowly, and it works!"
|
41
69
|
:event => "Prowly notification"
|
42
70
|
:application => "Prowly"
|
43
71
|
:priority => NORMAL
|
44
|
-
|
72
|
+
:url => nil
|
73
|
+
|
45
74
|
== Handling the Prowl API response
|
46
75
|
|
47
76
|
ON SUCCESS
|
@@ -50,9 +79,9 @@ Yet another Ruby interface to Prowl with command line utility
|
|
50
79
|
|
51
80
|
if result.succeeded?
|
52
81
|
result.remaining # => "977"
|
53
|
-
|
82
|
+
result.resetdate # => "1266272588"
|
54
83
|
else
|
55
|
-
|
84
|
+
result.message # =>
|
56
85
|
end
|
57
86
|
|
58
87
|
ON ERROR
|
@@ -61,12 +90,10 @@ Yet another Ruby interface to Prowl with command line utility
|
|
61
90
|
|
62
91
|
if result.succeeded?
|
63
92
|
result.remaining # =>
|
64
|
-
|
93
|
+
result.resetdate # =>
|
65
94
|
else
|
66
|
-
|
95
|
+
result.message # => "Invalid API Key(s)" <= This depends on the message sent by the prowl API
|
67
96
|
end
|
68
|
-
|
69
|
-
|
70
97
|
|
71
98
|
== Note on Patches/Pull Requests
|
72
99
|
|
@@ -78,6 +105,4 @@ Yet another Ruby interface to Prowl with command line utility
|
|
78
105
|
(if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)
|
79
106
|
* Send me a pull request. Bonus points for topic branches.
|
80
107
|
|
81
|
-
|
82
|
-
|
83
|
-
Copyright (c) 2010 Rafael Magaña. See LICENSE for details.
|
108
|
+
See LICENSE for details
|
data/Rakefile
CHANGED
@@ -10,9 +10,7 @@ begin
|
|
10
10
|
gem.description = "The Prowly gem is a simple wrapper to the Prowl API, you can use it to send messages to your iPhone in a Rails or pure Ruby application."
|
11
11
|
gem.email = "raf.magana@gmail.com"
|
12
12
|
gem.homepage = "http://github.com/rafmagana/prowly"
|
13
|
-
gem.authors = ["Rafael
|
14
|
-
gem.add_development_dependency "shoulda", ">= 0"
|
15
|
-
# gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
|
13
|
+
gem.authors = ["Rafael Magana"]
|
16
14
|
end
|
17
15
|
Jeweler::GemcutterTasks.new
|
18
16
|
rescue LoadError
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.3.0
|
data/bin/prowly
CHANGED
@@ -15,7 +15,8 @@ options = {
|
|
15
15
|
:description => "I am testing Prowly, and it works!",
|
16
16
|
:event => "Prowly notification",
|
17
17
|
:application => "Prowly",
|
18
|
-
:priority => "NORMAL"
|
18
|
+
:priority => "NORMAL",
|
19
|
+
:url => nil}
|
19
20
|
|
20
21
|
|
21
22
|
opts = OptionParser.new do |opts|
|
@@ -51,6 +52,10 @@ EOF
|
|
51
52
|
options[:priority] = priority
|
52
53
|
end
|
53
54
|
|
55
|
+
opts.on("-uURL", "--url URL", "URL") do |url|
|
56
|
+
options[:url] = url
|
57
|
+
end
|
58
|
+
|
54
59
|
opts.on("-v", "--version", "Print the version number and exit") do
|
55
60
|
options[:version] = true
|
56
61
|
end
|
@@ -88,6 +93,7 @@ result = Prowly.notify do |n|
|
|
88
93
|
n.application = options[:application]
|
89
94
|
n.event = options[:event]
|
90
95
|
n.description = options[:description]
|
96
|
+
n.url = options[:url]
|
91
97
|
end
|
92
98
|
|
93
99
|
if result.succeeded?
|
@@ -0,0 +1,57 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
STDOUT.sync = true
|
4
|
+
|
5
|
+
$LOAD_PATH.unshift File.join(File.dirname(__FILE__), *%w[.. lib])
|
6
|
+
|
7
|
+
require 'rubygems'
|
8
|
+
require 'prowly'
|
9
|
+
require 'optparse'
|
10
|
+
|
11
|
+
options = {}
|
12
|
+
|
13
|
+
ORIGINAL_ARGV = ARGV.dup
|
14
|
+
|
15
|
+
opts = OptionParser.new do |opts|
|
16
|
+
opts.banner = <<-EOF
|
17
|
+
Usage:
|
18
|
+
prowly_retrieve -p providerkey
|
19
|
+
|
20
|
+
Options:
|
21
|
+
EOF
|
22
|
+
|
23
|
+
opts.on("-pPROVIDERKEY", "--provider PRIORITY", "Provider Key") do |priority|
|
24
|
+
options[:provider] = priority
|
25
|
+
end
|
26
|
+
|
27
|
+
opts.on("-v", "--version", "Print the version number and exit") do
|
28
|
+
options[:version] = true
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
opts.parse!
|
33
|
+
|
34
|
+
if options[:version]
|
35
|
+
abort("Version " + Prowly.version)
|
36
|
+
end
|
37
|
+
|
38
|
+
token_result = Prowly.retrieve_token(options[:provider])
|
39
|
+
|
40
|
+
if token_result.succeeded?
|
41
|
+
puts "go to this #{token_result.url} to approve this request"
|
42
|
+
puts "then press <ENTER> to continue "
|
43
|
+
dummy = STDIN.gets
|
44
|
+
|
45
|
+
apikey_result = Prowly.retrieve_apikey(options[:provider], token_result.token)
|
46
|
+
|
47
|
+
if apikey_result.succeeded?
|
48
|
+
puts "The user apikey is #{apikey_result.apikey}"
|
49
|
+
exit(0)
|
50
|
+
else
|
51
|
+
puts "Error: #{apikey_result.message}"
|
52
|
+
exit(1)
|
53
|
+
end
|
54
|
+
else
|
55
|
+
puts "Error: #{token_result.message}"
|
56
|
+
exit(1)
|
57
|
+
end
|
data/lib/prowly.rb
CHANGED
@@ -1,26 +1,3 @@
|
|
1
|
-
#--
|
2
|
-
# Copyright (c) 2010 Rafael Magaña Ávalos
|
3
|
-
#
|
4
|
-
# Permission is hereby granted, free of charge, to any person obtaining
|
5
|
-
# a copy of this software and associated documentation files (the
|
6
|
-
# "Software"), to deal in the Software without restriction, including
|
7
|
-
# without limitation the rights to use, copy, modify, merge, publish,
|
8
|
-
# distribute, sublicense, and/or sell copies of the Software, and to
|
9
|
-
# permit persons to whom the Software is furnished to do so, subject to
|
10
|
-
# the following conditions:
|
11
|
-
#
|
12
|
-
# The above copyright notice and this permission notice shall be
|
13
|
-
# included in all copies or substantial portions of the Software.
|
14
|
-
#
|
15
|
-
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
16
|
-
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
17
|
-
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
18
|
-
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
19
|
-
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
20
|
-
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
21
|
-
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
22
|
-
#++
|
23
|
-
|
24
1
|
require 'prowly/interface'
|
25
2
|
require 'prowly/notification'
|
26
3
|
|
@@ -53,6 +30,14 @@ module Prowly
|
|
53
30
|
def verify(apikey)
|
54
31
|
api.call Interface::Command::VERIFY, "apikey=#{apikey}"
|
55
32
|
end
|
33
|
+
|
34
|
+
def retrieve_token(providerkey)
|
35
|
+
api.call Interface::Command::RETRIEVE_TOKEN, "providerkey=#{providerkey}"
|
36
|
+
end
|
37
|
+
|
38
|
+
def retrieve_apikey(providerkey, token)
|
39
|
+
api.call Interface::Command::RETRIEVE_APIKEY, "providerkey=#{providerkey}&token=#{token}"
|
40
|
+
end
|
56
41
|
|
57
42
|
def valid_key?(key)
|
58
43
|
result = verify(key)
|
data/lib/prowly/interface.rb
CHANGED
@@ -1,26 +1,3 @@
|
|
1
|
-
#--
|
2
|
-
# Copyright (c) 2010 Rafael Magaña Ávalos
|
3
|
-
#
|
4
|
-
# Permission is hereby granted, free of charge, to any person obtaining
|
5
|
-
# a copy of this software and associated documentation files (the
|
6
|
-
# "Software"), to deal in the Software without restriction, including
|
7
|
-
# without limitation the rights to use, copy, modify, merge, publish,
|
8
|
-
# distribute, sublicense, and/or sell copies of the Software, and to
|
9
|
-
# permit persons to whom the Software is furnished to do so, subject to
|
10
|
-
# the following conditions:
|
11
|
-
#
|
12
|
-
# The above copyright notice and this permission notice shall be
|
13
|
-
# included in all copies or substantial portions of the Software.
|
14
|
-
#
|
15
|
-
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
16
|
-
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
17
|
-
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
18
|
-
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
19
|
-
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
20
|
-
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
21
|
-
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
22
|
-
#++
|
23
|
-
|
24
1
|
require 'net/https'
|
25
2
|
require 'prowly/response'
|
26
3
|
require 'prowly/notification'
|
@@ -41,7 +18,7 @@ module Prowly
|
|
41
18
|
include Singleton
|
42
19
|
|
43
20
|
def initialize
|
44
|
-
@url = "https://
|
21
|
+
@url = "https://api.prowlapp.com/publicapi"
|
45
22
|
end
|
46
23
|
|
47
24
|
## Make the actual call to the prowl api
|
@@ -68,6 +45,8 @@ module Prowly
|
|
68
45
|
module Command
|
69
46
|
ADD = "add"
|
70
47
|
VERIFY = "verify"
|
48
|
+
RETRIEVE_TOKEN = "retrieve/token"
|
49
|
+
RETRIEVE_APIKEY = "retrieve/apikey"
|
71
50
|
end
|
72
51
|
|
73
52
|
## EXCEPTIONS
|
data/lib/prowly/notification.rb
CHANGED
@@ -58,7 +58,7 @@ module Prowly
|
|
58
58
|
## EXCEPTIONS
|
59
59
|
class PriorityNotAvailable < RuntimeError; end
|
60
60
|
|
61
|
-
attr_accessor :providerkey, :priority, :event
|
61
|
+
attr_accessor :providerkey, :priority, :event, :url
|
62
62
|
|
63
63
|
def initialize(params = {})
|
64
64
|
@apikey = (params[:apikey] || params[:apikeys]) || "fffffffffffffffffffffffffffffffffffffffff"
|
@@ -66,6 +66,7 @@ module Prowly
|
|
66
66
|
@event = params[:event] || "Prowly is working!!"
|
67
67
|
@description = params[:description] || "This is the default description"
|
68
68
|
@priority = params[:priority] || Priority::NORMAL
|
69
|
+
@url = params[:url] || nil
|
69
70
|
super
|
70
71
|
end
|
71
72
|
|
data/lib/prowly/response.rb
CHANGED
@@ -4,7 +4,7 @@ module Prowly
|
|
4
4
|
|
5
5
|
#This is a Prowl API response wrapper
|
6
6
|
class Response
|
7
|
-
|
7
|
+
|
8
8
|
attr_writer :response
|
9
9
|
attr_accessor :http_response
|
10
10
|
|
@@ -17,28 +17,29 @@ module Prowly
|
|
17
17
|
def self.map_xml(response)
|
18
18
|
response_info = parse_xml(response)
|
19
19
|
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
20
|
+
response_info.elements.each do |r|
|
21
|
+
#define dynamic methods based on the prowl api response
|
22
|
+
#posible methods on success: code, remaining, resetdate
|
23
|
+
#posible methods on error: code
|
24
|
+
r.attributes.each do |key, value|
|
25
|
+
# puts "attribute #{key}: #{value}"
|
26
|
+
if key == "code"
|
27
|
+
add_instance_method(:status, value == "200" ? "success" : "error")
|
28
|
+
#define a method named status and it'll return "success" or "error"
|
29
|
+
boolean_status = value == "200" ? true : false
|
30
|
+
add_instance_method(:succeeded?, boolean_status)
|
31
|
+
add_instance_method(:message, response_info[1].text) unless boolean_status
|
32
|
+
end
|
33
|
+
add_instance_method(key, value)
|
34
|
+
end
|
25
35
|
end
|
26
36
|
|
27
|
-
response_info_name = response_info.name
|
28
|
-
#define a method named status and it'll return "success" or "error"
|
29
|
-
add_instance_method(:status, response_info_name)
|
30
|
-
|
31
|
-
boolean_status = response_info_name == "success" ? true : false
|
32
|
-
|
33
|
-
add_instance_method(:message, response_info.text) unless boolean_status
|
34
|
-
|
35
|
-
add_instance_method(:succeeded?, boolean_status)
|
36
37
|
true
|
37
38
|
end
|
38
39
|
|
39
40
|
def self.parse_xml(response)
|
40
41
|
data = REXML::Document.new response
|
41
|
-
data.root
|
42
|
+
data.root
|
42
43
|
end
|
43
44
|
|
44
45
|
#define dynamic methods
|
@@ -46,7 +47,7 @@ module Prowly
|
|
46
47
|
define_method(name) { content }
|
47
48
|
end
|
48
49
|
|
49
|
-
## ERRORCODES are documented in http://
|
50
|
+
## ERRORCODES are documented in http://www.prowlapp.com/api.php
|
50
51
|
module ErrorCode
|
51
52
|
BAD = 400 #Bad request, the parameters you provided did not validate, see ERRORMESSAGE.
|
52
53
|
NOT_AUTHORIZED = 401 #Not authorized, the API key given is not valid, and does not correspond to a user.
|
data/prowly.gemspec
CHANGED
@@ -1,47 +1,46 @@
|
|
1
1
|
# Generated by jeweler
|
2
2
|
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
-
# Instead, edit Jeweler::Tasks in Rakefile, and run
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
4
|
# -*- encoding: utf-8 -*-
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{prowly}
|
8
|
-
s.version = "0.
|
8
|
+
s.version = "0.3.0"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
-
s.authors = ["Rafael
|
12
|
-
s.date = %q{
|
13
|
-
s.default_executable = %q{prowly}
|
11
|
+
s.authors = ["Rafael Magana"]
|
12
|
+
s.date = %q{2011-03-28}
|
14
13
|
s.description = %q{The Prowly gem is a simple wrapper to the Prowl API, you can use it to send messages to your iPhone in a Rails or pure Ruby application.}
|
15
14
|
s.email = %q{raf.magana@gmail.com}
|
16
|
-
s.executables = ["prowly"]
|
15
|
+
s.executables = ["prowly_retrieve_apikey", "prowly"]
|
17
16
|
s.extra_rdoc_files = [
|
18
17
|
"LICENSE",
|
19
|
-
|
18
|
+
"README.rdoc"
|
20
19
|
]
|
21
20
|
s.files = [
|
22
21
|
".document",
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
22
|
+
"CONTRIBUTORS.md",
|
23
|
+
"LICENSE",
|
24
|
+
"README.rdoc",
|
25
|
+
"Rakefile",
|
26
|
+
"VERSION",
|
27
|
+
"bin/prowly",
|
28
|
+
"bin/prowly_retrieve_apikey",
|
29
|
+
"lib/prowly.rb",
|
30
|
+
"lib/prowly/interface.rb",
|
31
|
+
"lib/prowly/notification.rb",
|
32
|
+
"lib/prowly/response.rb",
|
33
|
+
"prowly.gemspec",
|
34
|
+
"test/helper.rb",
|
35
|
+
"test/test_prowly.rb"
|
36
36
|
]
|
37
37
|
s.homepage = %q{http://github.com/rafmagana/prowly}
|
38
|
-
s.rdoc_options = ["--charset=UTF-8"]
|
39
38
|
s.require_paths = ["lib"]
|
40
39
|
s.rubygems_version = %q{1.3.7}
|
41
40
|
s.summary = %q{A Ruby interface to Prowl (http://prowl.weks.net/)}
|
42
41
|
s.test_files = [
|
43
42
|
"test/helper.rb",
|
44
|
-
|
43
|
+
"test/test_prowly.rb"
|
45
44
|
]
|
46
45
|
|
47
46
|
if s.respond_to? :specification_version then
|
@@ -49,12 +48,9 @@ Gem::Specification.new do |s|
|
|
49
48
|
s.specification_version = 3
|
50
49
|
|
51
50
|
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
52
|
-
s.add_development_dependency(%q<shoulda>, [">= 0"])
|
53
51
|
else
|
54
|
-
s.add_dependency(%q<shoulda>, [">= 0"])
|
55
52
|
end
|
56
53
|
else
|
57
|
-
s.add_dependency(%q<shoulda>, [">= 0"])
|
58
54
|
end
|
59
55
|
end
|
60
56
|
|
data/test/helper.rb
CHANGED
data/test/test_prowly.rb
CHANGED
@@ -1,7 +1,80 @@
|
|
1
1
|
require 'helper'
|
2
2
|
|
3
3
|
class TestProwly < Test::Unit::TestCase
|
4
|
-
|
5
|
-
|
4
|
+
|
5
|
+
# TODO(slashk): add mock/stubs to simulate calls
|
6
|
+
|
7
|
+
def test_parse_good_retrieve_token_response
|
8
|
+
xml_response =
|
9
|
+
<<EOF
|
10
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
11
|
+
<prowl>
|
12
|
+
<success code="200" remaining="999" resetdate="1300659778" />
|
13
|
+
<retrieve token="2e948b117a965a0ead02b106a18fb038b7f05809" url="https://www.prowlapp.com/retrieve.php?token=2e948b117a965a0ead02b106a18fb038b7f05809" />
|
14
|
+
</prowl>
|
15
|
+
EOF
|
16
|
+
full_http_response = "200"
|
17
|
+
rt = Prowly::Response.new(xml_response, full_http_response)
|
18
|
+
assert_equal(rt.code, "200")
|
19
|
+
assert_equal(true, rt.succeeded?)
|
20
|
+
assert_equal("2e948b117a965a0ead02b106a18fb038b7f05809", rt.token)
|
21
|
+
end
|
22
|
+
|
23
|
+
def test_parse_good_notify_response
|
24
|
+
xml_response =
|
25
|
+
<<EOF
|
26
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
27
|
+
<prowl>
|
28
|
+
<success code="200" remaining="999" resetdate="1300659778" />
|
29
|
+
</prowl>
|
30
|
+
EOF
|
31
|
+
full_http_response = "200"
|
32
|
+
rt = Prowly::Response.new(xml_response, full_http_response)
|
33
|
+
assert_equal(rt.code, "200")
|
34
|
+
assert_equal(true, rt.succeeded?)
|
35
|
+
end
|
36
|
+
|
37
|
+
def test_parse_error_notify_response
|
38
|
+
xml_response =
|
39
|
+
<<EOF
|
40
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
41
|
+
<prowl>
|
42
|
+
<error code="401">the API key given is not valid</error>
|
43
|
+
</prowl>
|
44
|
+
EOF
|
45
|
+
full_http_response = "401"
|
46
|
+
rt = Prowly::Response.new(xml_response, full_http_response)
|
47
|
+
assert_equal(rt.message, "the API key given is not valid")
|
6
48
|
end
|
49
|
+
|
50
|
+
def test_verify_good_apikey_response
|
51
|
+
xml_response =
|
52
|
+
<<EOF
|
53
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
54
|
+
<prowl>
|
55
|
+
<success code="200" remaining="998" resetdate="1300665013" />
|
56
|
+
</prowl>
|
57
|
+
EOF
|
58
|
+
full_http_response = "200"
|
59
|
+
rt = Prowly::Response.new(xml_response, full_http_response)
|
60
|
+
assert_equal(rt.code, "200")
|
61
|
+
assert_equal(true, rt.succeeded?)
|
62
|
+
end
|
63
|
+
|
64
|
+
def test_good_retrieve_apikey_response
|
65
|
+
xml_response =
|
66
|
+
<<EOF
|
67
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
68
|
+
<prowl>
|
69
|
+
<success code="200" remaining="999" resetdate="1300659778" />
|
70
|
+
<retrieve apikey="15c501d2e65cfd46316513da47355283db4652fc" />
|
71
|
+
</prowl>
|
72
|
+
EOF
|
73
|
+
full_http_response = "200"
|
74
|
+
rt = Prowly::Response.new(xml_response, full_http_response)
|
75
|
+
assert_equal(rt.code, "200")
|
76
|
+
assert_equal(true, rt.succeeded?)
|
77
|
+
assert_equal("15c501d2e65cfd46316513da47355283db4652fc", rt.apikey)
|
78
|
+
end
|
79
|
+
|
7
80
|
end
|
metadata
CHANGED
@@ -1,38 +1,28 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: prowly
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
+
hash: 19
|
4
5
|
prerelease: false
|
5
6
|
segments:
|
6
7
|
- 0
|
7
|
-
-
|
8
|
-
-
|
9
|
-
version: 0.
|
8
|
+
- 3
|
9
|
+
- 0
|
10
|
+
version: 0.3.0
|
10
11
|
platform: ruby
|
11
12
|
authors:
|
12
|
-
-
|
13
|
+
- Rafael Magana
|
13
14
|
autorequire:
|
14
15
|
bindir: bin
|
15
16
|
cert_chain: []
|
16
17
|
|
17
|
-
date:
|
18
|
-
default_executable:
|
19
|
-
dependencies:
|
20
|
-
|
21
|
-
name: shoulda
|
22
|
-
prerelease: false
|
23
|
-
requirement: &id001 !ruby/object:Gem::Requirement
|
24
|
-
none: false
|
25
|
-
requirements:
|
26
|
-
- - ">="
|
27
|
-
- !ruby/object:Gem::Version
|
28
|
-
segments:
|
29
|
-
- 0
|
30
|
-
version: "0"
|
31
|
-
type: :development
|
32
|
-
version_requirements: *id001
|
18
|
+
date: 2011-03-28 00:00:00 -05:00
|
19
|
+
default_executable:
|
20
|
+
dependencies: []
|
21
|
+
|
33
22
|
description: The Prowly gem is a simple wrapper to the Prowl API, you can use it to send messages to your iPhone in a Rails or pure Ruby application.
|
34
23
|
email: raf.magana@gmail.com
|
35
24
|
executables:
|
25
|
+
- prowly_retrieve_apikey
|
36
26
|
- prowly
|
37
27
|
extensions: []
|
38
28
|
|
@@ -41,12 +31,13 @@ extra_rdoc_files:
|
|
41
31
|
- README.rdoc
|
42
32
|
files:
|
43
33
|
- .document
|
44
|
-
- .
|
34
|
+
- CONTRIBUTORS.md
|
45
35
|
- LICENSE
|
46
36
|
- README.rdoc
|
47
37
|
- Rakefile
|
48
38
|
- VERSION
|
49
39
|
- bin/prowly
|
40
|
+
- bin/prowly_retrieve_apikey
|
50
41
|
- lib/prowly.rb
|
51
42
|
- lib/prowly/interface.rb
|
52
43
|
- lib/prowly/notification.rb
|
@@ -59,8 +50,8 @@ homepage: http://github.com/rafmagana/prowly
|
|
59
50
|
licenses: []
|
60
51
|
|
61
52
|
post_install_message:
|
62
|
-
rdoc_options:
|
63
|
-
|
53
|
+
rdoc_options: []
|
54
|
+
|
64
55
|
require_paths:
|
65
56
|
- lib
|
66
57
|
required_ruby_version: !ruby/object:Gem::Requirement
|
@@ -68,6 +59,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
68
59
|
requirements:
|
69
60
|
- - ">="
|
70
61
|
- !ruby/object:Gem::Version
|
62
|
+
hash: 3
|
71
63
|
segments:
|
72
64
|
- 0
|
73
65
|
version: "0"
|
@@ -76,6 +68,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
76
68
|
requirements:
|
77
69
|
- - ">="
|
78
70
|
- !ruby/object:Gem::Version
|
71
|
+
hash: 3
|
79
72
|
segments:
|
80
73
|
- 0
|
81
74
|
version: "0"
|