prowlr 0.2.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,5 @@
1
+ README.rdoc
2
+ lib/**/*.rb
3
+ bin/*
4
+ features/**/*.feature
5
+ LICENSE
@@ -0,0 +1,6 @@
1
+ *.sw?
2
+ .DS_Store
3
+ coverage
4
+ rdoc
5
+ pkg
6
+ *.tmproj
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2009 Rob Bevan
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,53 @@
1
+ # prowlr
2
+
3
+ Yet another [Prowl](https://prowl.weks.net/) [API](https://prowl.weks.net/api.php) gem. Includes a command line interface. Depends on (the very awesome) [httparty](http://railstips.org/2008/7/29/it-s-an-httparty-and-everyone-is-invited).
4
+
5
+ Install: gem install robbevan-prowlr --source=http://gems.github.com/
6
+
7
+ ### Add event:
8
+ Prowlr.add(:apikey => 'apikey', :event => 'Notification from prowlr gem', :description => "Sent: #{Time.now}")
9
+ => {"code"=>"200", "remaining"=>"981", "resetdate"=>"1247481311"}
10
+
11
+ Required: apikey and event or description. Optional: application, providerkey, priority. See [API](https://prowl.weks.net/api.php) for details.
12
+
13
+ ### Create instance and add event:
14
+ prowlr = Prowlr.new('apikey')
15
+ prowlr.add(:event => 'Notification from prowlr gem', :description => "Sent: #{Time.now}")
16
+ => {"code"=>"200", "remaining"=>"980", "resetdate"=>"1247481311"}
17
+
18
+ ### Verify:
19
+ Prowlr.verify('apikey')
20
+ => {"code"=>"200", "remaining"=>"979", "resetdate"=>"1247481311"}
21
+
22
+ ### Valid API key?
23
+ Prowlr.valid_apikey?('apikey')
24
+ => true (or false)
25
+
26
+ ### Remaining calls:
27
+ Prowlr.remaining_calls('apikey')
28
+ => 997 (or nil if API key not valid)
29
+
30
+ ### Reset date:
31
+ Prowlr.reset_date('apikey')
32
+ => Mon Jul 13 11:35:11 +0100 2009 (or nil if API key not valid)
33
+
34
+ See [examples](http://github.com/robbevan/prowlr/tree/master/examples).
35
+
36
+ ### From the command line:
37
+ prowlr -h
38
+ USAGE: /opt/local/bin/prowlr [options] [apikey] [event]
39
+ -a, --application [APPLICATION] Name of your application. Defaults to prowlr.gem if omitted.
40
+ -d, --description [DESCRIPTION] Description of the event
41
+ -k, --providerkey [PROVIDER KEY] Your provider API key. Only necessary if you have been whitelisted.
42
+ -p, --priority [PRIORITY] Priority: an integer value ranging [-2, 2]: Very Low, Moderate, Normal, High, Emergency. Defaults to 0 if omitted.
43
+ -h, --help Show help documentation
44
+
45
+ ### Post a url to your iPhone:
46
+ prowlr apikey -d 'http://www.google.com' 'URL'
47
+
48
+ ### Post a phone number:
49
+ prowlr apikey -d '0800 800 8000' 'Phone number'
50
+
51
+ ## Copyright
52
+
53
+ Copyright (c) 2009 Rob Bevan. See LICENSE for details.
@@ -0,0 +1,56 @@
1
+ require 'rubygems'
2
+ require 'rake'
3
+
4
+ begin
5
+ require 'jeweler'
6
+ Jeweler::Tasks.new do |gem|
7
+ gem.name = "prowlr"
8
+ gem.summary = %Q{Yet another Prowl API gem and command line interface}
9
+ gem.email = "robbevan@xpt.com"
10
+ gem.homepage = "http://github.com/robbevan/prowlr"
11
+ gem.authors = ["Rob Bevan"]
12
+ # gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
13
+ end
14
+
15
+ rescue LoadError
16
+ puts "Jeweler (or a dependency) not available. Install it with: sudo gem install jeweler"
17
+ end
18
+
19
+ require 'rake/testtask'
20
+ Rake::TestTask.new(:test) do |test|
21
+ test.libs << 'lib' << 'test'
22
+ test.pattern = 'test/**/*_test.rb'
23
+ test.verbose = true
24
+ end
25
+
26
+ begin
27
+ require 'rcov/rcovtask'
28
+ Rcov::RcovTask.new do |test|
29
+ test.libs << 'test'
30
+ test.pattern = 'test/**/*_test.rb'
31
+ test.verbose = true
32
+ end
33
+ rescue LoadError
34
+ task :rcov do
35
+ abort "RCov is not available. In order to run rcov, you must: sudo gem install spicycode-rcov"
36
+ end
37
+ end
38
+
39
+
40
+ task :default => :test
41
+
42
+ require 'rake/rdoctask'
43
+ Rake::RDocTask.new do |rdoc|
44
+ if File.exist?('VERSION.yml')
45
+ config = YAML.load(File.read('VERSION.yml'))
46
+ version = "#{config[:major]}.#{config[:minor]}.#{config[:patch]}"
47
+ else
48
+ version = ""
49
+ end
50
+
51
+ rdoc.rdoc_dir = 'rdoc'
52
+ rdoc.title = "prowlr #{version}"
53
+ rdoc.rdoc_files.include('README*')
54
+ rdoc.rdoc_files.include('lib/**/*.rb')
55
+ end
56
+
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.2.2
@@ -0,0 +1,62 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "optparse"
4
+ require "pp"
5
+
6
+ $:.unshift(File.join(File.dirname(__FILE__), "/../lib"))
7
+ require 'prowlr'
8
+
9
+ options = {
10
+ :application => 'prowlr.gem'
11
+ }
12
+
13
+ def die(msg)
14
+ STDERR.puts(msg)
15
+ exit 1
16
+ end
17
+
18
+ OptionParser.new do |o|
19
+ o.banner = "\rUSAGE: #{$0} [options] [apikey] [event]"
20
+
21
+ o.on("-a",
22
+ "--application [APPLICATION]",
23
+ "Name of your application. Defaults to prowlr.gem if omitted.") do |a|
24
+ options[:application] = a
25
+ end
26
+
27
+ o.on("-d",
28
+ "--description [DESCRIPTION]",
29
+ "Description of the event") do |d|
30
+ options[:description] = d
31
+ end
32
+
33
+ o.on("-k",
34
+ "--providerkey [PROVIDER KEY]",
35
+ "Your provider API key. Only necessary if you have been whitelisted.") do |k|
36
+ options[:providerkey] = k
37
+ end
38
+
39
+ o.on("-p",
40
+ "--priority [PRIORITY]",
41
+ "Priority: an integer value ranging [-2, 2]: Very Low, Moderate, Normal, High, Emergency. Defaults to 0 if omitted.") do |p|
42
+ options[:priority] = p
43
+ end
44
+
45
+ o.on("-h", "--help", "Show help documentation") do |h|
46
+ puts o
47
+ exit
48
+ end
49
+ end.parse!
50
+
51
+ if ARGV.length < 2
52
+ STDERR.puts "You need to provide your apikey and an event"
53
+ STDERR.puts "USAGE: #{$0} [options] [apikey] [event]"
54
+ end
55
+
56
+ apikey = ARGV[0]
57
+ event = ARGV[1]
58
+
59
+ prowlr = Prowlr.new(apikey)
60
+ options.merge!(:apikey => apikey, :event => event)
61
+ response = prowlr.add(options)
62
+ puts "Error: #{response['error'].inspect}" if response['error']
@@ -0,0 +1,7 @@
1
+ require File.join(File.dirname(__FILE__), '..', 'lib', 'prowlr')
2
+ require File.join(File.dirname(__FILE__), 'helpers', 'config_store')
3
+ require 'pp'
4
+
5
+ config = ConfigStore.new("#{ENV['HOME']}/.prowlr")
6
+
7
+ pp Prowlr.add(:apikey => config['apikey'], :event => 'Notification from prowlr gem', :description => "Sent: #{Time.now}")
@@ -0,0 +1,8 @@
1
+ require File.join(File.dirname(__FILE__), '..', 'lib', 'prowlr')
2
+ require File.join(File.dirname(__FILE__), 'helpers', 'config_store')
3
+ require 'pp'
4
+
5
+ config = ConfigStore.new("#{ENV['HOME']}/.prowlr")
6
+
7
+ prowlr = Prowlr.new(config['apikey'])
8
+ pp prowlr.add(:event => 'Notification from prowlr gem', :description => "Sent: #{Time.now}")
@@ -0,0 +1,59 @@
1
+ # Copyright (c) 2009 John Nunemaker
2
+ #
3
+ # Permission is hereby granted, free of charge, to any person obtaining
4
+ # a copy of this software and associated documentation files (the
5
+ # "Software"), to deal in the Software without restriction, including
6
+ # without limitation the rights to use, copy, modify, merge, publish,
7
+ # distribute, sublicense, and/or sell copies of the Software, and to
8
+ # permit persons to whom the Software is furnished to do so, subject to
9
+ # the following conditions:
10
+ #
11
+ # The above copyright notice and this permission notice shall be
12
+ # included in all copies or substantial portions of the Software.
13
+ #
14
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21
+
22
+ class ConfigStore
23
+ attr_reader :file
24
+
25
+ def initialize(file)
26
+ @file = file
27
+ end
28
+
29
+ def load
30
+ @config ||= YAML::load(open(file))
31
+ self
32
+ end
33
+
34
+ def [](key)
35
+ load
36
+ @config[key]
37
+ end
38
+
39
+ def []=(key, value)
40
+ @config[key] = value
41
+ end
42
+
43
+ def delete(*keys)
44
+ keys.each { |key| @config.delete(key) }
45
+ save
46
+ self
47
+ end
48
+
49
+ def update(c={})
50
+ @config.merge!(c)
51
+ save
52
+ self
53
+ end
54
+
55
+ def save
56
+ File.open(file, 'w') { |f| f.write(YAML.dump(@config)) }
57
+ self
58
+ end
59
+ end
@@ -0,0 +1,7 @@
1
+ require File.join(File.dirname(__FILE__), '..', 'lib', 'prowlr')
2
+ require File.join(File.dirname(__FILE__), 'helpers', 'config_store')
3
+ require 'pp'
4
+
5
+ config = ConfigStore.new("#{ENV['HOME']}/.prowlr")
6
+
7
+ pp Prowlr.remaining_calls(config['apikey'])
@@ -0,0 +1,7 @@
1
+ require File.join(File.dirname(__FILE__), '..', 'lib', 'prowlr')
2
+ require File.join(File.dirname(__FILE__), 'helpers', 'config_store')
3
+ require 'pp'
4
+
5
+ config = ConfigStore.new("#{ENV['HOME']}/.prowlr")
6
+
7
+ puts Prowlr.reset_date(config['apikey'])
@@ -0,0 +1,7 @@
1
+ require File.join(File.dirname(__FILE__), '..', 'lib', 'prowlr')
2
+ require File.join(File.dirname(__FILE__), 'helpers', 'config_store')
3
+ require 'pp'
4
+
5
+ config = ConfigStore.new("#{ENV['HOME']}/.prowlr")
6
+
7
+ puts Prowlr.valid_apikey?(config['apikey'])
@@ -0,0 +1,7 @@
1
+ require File.join(File.dirname(__FILE__), '..', 'lib', 'prowlr')
2
+ require File.join(File.dirname(__FILE__), 'helpers', 'config_store')
3
+ require 'pp'
4
+
5
+ config = ConfigStore.new("#{ENV['HOME']}/.prowlr")
6
+
7
+ pp Prowlr.verify(config['apikey'])
@@ -0,0 +1,52 @@
1
+ require 'rubygems'
2
+ gem 'httparty'
3
+ require 'httparty'
4
+
5
+ class Prowlr
6
+ include HTTParty
7
+ format :xml
8
+
9
+ base_uri 'https://prowl.weks.net/publicapi'
10
+
11
+ class ProwlrError < StandardError; end
12
+
13
+ def initialize(apikey)
14
+ @apikey = apikey
15
+ end
16
+
17
+ def add(options={})
18
+ options.merge!({:apikey => @apikey})
19
+ self.class.add(options)
20
+ end
21
+
22
+ class << self
23
+ def verify(apikey)
24
+ raise_errors(get('/verify', :query => {:apikey => apikey})['prowl'])
25
+ end
26
+
27
+ def valid_apikey?(apikey)
28
+ verify(apikey)['code'].to_i == 200 rescue false
29
+ end
30
+
31
+ def remaining_calls(apikey)
32
+ verify(apikey)['remaining'].to_i rescue nil
33
+ end
34
+
35
+ def reset_date(apikey)
36
+ Time.at(verify(apikey)['resetdate'].to_i) rescue nil
37
+ end
38
+
39
+ def add(options={})
40
+ options.merge!({:application => 'prowlr gem'}) unless options[:application]
41
+ raise_errors(post('/add', :query => options)['prowl'])
42
+ end
43
+
44
+ def raise_errors(response)
45
+ unless error = response['error']
46
+ response['success']
47
+ else
48
+ raise ProwlrError, error
49
+ end
50
+ end
51
+ end
52
+ end
@@ -0,0 +1,66 @@
1
+ # -*- encoding: utf-8 -*-
2
+
3
+ Gem::Specification.new do |s|
4
+ s.name = %q{prowlr}
5
+ s.version = "0.2.2"
6
+
7
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
8
+ s.authors = ["Rob Bevan"]
9
+ s.date = %q{2009-07-13}
10
+ s.default_executable = %q{prowlr}
11
+ s.email = %q{robbevan@xpt.com}
12
+ s.executables = ["prowlr"]
13
+ s.extra_rdoc_files = [
14
+ "LICENSE",
15
+ "README.md"
16
+ ]
17
+ s.files = [
18
+ ".document",
19
+ ".gitignore",
20
+ "LICENSE",
21
+ "README.md",
22
+ "Rakefile",
23
+ "VERSION",
24
+ "bin/prowlr",
25
+ "examples/add.rb",
26
+ "examples/add_instance.rb",
27
+ "examples/helpers/config_store.rb",
28
+ "examples/remaining_calls.rb",
29
+ "examples/reset_date.rb",
30
+ "examples/valid_apikey.rb",
31
+ "examples/verify.rb",
32
+ "lib/prowlr.rb",
33
+ "prowlr.gemspec",
34
+ "test/fixtures/bad_request.xml",
35
+ "test/fixtures/invalid_apikey.xml",
36
+ "test/fixtures/success.xml",
37
+ "test/prowlr_test.rb",
38
+ "test/test_helper.rb"
39
+ ]
40
+ s.homepage = %q{http://github.com/robbevan/prowlr}
41
+ s.rdoc_options = ["--charset=UTF-8"]
42
+ s.require_paths = ["lib"]
43
+ s.rubygems_version = %q{1.3.3}
44
+ s.summary = %q{Yet another Prowl API gem and command line interface}
45
+ s.test_files = [
46
+ "test/prowlr_test.rb",
47
+ "test/test_helper.rb",
48
+ "examples/add.rb",
49
+ "examples/add_instance.rb",
50
+ "examples/helpers/config_store.rb",
51
+ "examples/remaining_calls.rb",
52
+ "examples/reset_date.rb",
53
+ "examples/valid_apikey.rb",
54
+ "examples/verify.rb"
55
+ ]
56
+
57
+ if s.respond_to? :specification_version then
58
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
59
+ s.specification_version = 3
60
+
61
+ if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
62
+ else
63
+ end
64
+ else
65
+ end
66
+ end
@@ -0,0 +1,4 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <prowl>
3
+ <error code="400">Missing field: Event or description is required</error>
4
+ </prowl>
@@ -0,0 +1,4 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <prowl>
3
+ <error code="401">Invalid API key</error>
4
+ </prowl>
@@ -0,0 +1,4 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <prowl>
3
+ <success code="200" remaining="999" resetdate="1247418349" />
4
+ </prowl>
@@ -0,0 +1,127 @@
1
+ require 'test_helper'
2
+
3
+ class ProwlrTest < Test::Unit::TestCase
4
+ context "Verifying an API key" do
5
+ should "raise an exception if an invalid API key is passed" do
6
+ apikey = 'invalid-apikey'
7
+ stub_api_call(:get, 'verify', {:apikey => apikey}, 'invalid_apikey.xml')
8
+ assert_raises Prowlr::ProwlrError do
9
+ Prowlr.verify(apikey)
10
+ end
11
+ end
12
+
13
+ should "return 200 if a valid API key is passed" do
14
+ apikey = 'valid-apikey'
15
+ stub_api_call(:get, 'verify', {:apikey => apikey}, 'success.xml')
16
+ assert_equal 200, Prowlr.verify(apikey)['code'].to_i
17
+ end
18
+ end
19
+
20
+ context "Validating an API key" do
21
+ should "return 'false' if an invalid API key is passed" do
22
+ apikey = 'invalid-apikey'
23
+ stub_api_call(:get, 'verify', {:apikey => apikey}, 'invalid_apikey.xml')
24
+ assert !Prowlr.valid_apikey?(apikey)
25
+ end
26
+
27
+ should "return 'true' if a valid API key is passed" do
28
+ apikey = 'valid-apikey'
29
+ stub_api_call(:get, 'verify', {:apikey => apikey}, 'success.xml')
30
+ assert Prowlr.valid_apikey?(apikey)
31
+ end
32
+ end
33
+
34
+ context "Fetching the number of remaining API calls" do
35
+ should "return nil if an invalid API key is passed" do
36
+ apikey = 'invalid-apikey'
37
+ stub_api_call(:get, 'verify', {:apikey => apikey}, 'invalid_apikey.xml')
38
+ assert_nil Prowlr.remaining_calls(apikey)
39
+ end
40
+
41
+ should "return 999 if a valid API key is passed" do
42
+ apikey = 'valid-apikey'
43
+ stub_api_call(:get, 'verify', {:apikey => apikey}, 'success.xml')
44
+ assert_equal 999, Prowlr.remaining_calls(apikey)
45
+ end
46
+ end
47
+
48
+ context "Fetching the date when the number of remaining API calls is reset" do
49
+ should "return nil if an invalid API key is passed" do
50
+ apikey = 'invalid-apikey'
51
+ stub_api_call(:get, 'verify', {:apikey => apikey}, 'invalid_apikey.xml')
52
+ assert_nil Prowlr.reset_date(apikey)
53
+ end
54
+
55
+ should "return the date if a valid API key is passed" do
56
+ apikey = 'valid-apikey'
57
+ stub_api_call(:get, 'verify', {:apikey => apikey}, 'success.xml')
58
+ assert_equal Time.at(1247418349), Prowlr.reset_date(apikey)
59
+ end
60
+ end
61
+
62
+ context "Adding an event" do
63
+ setup do
64
+ @params = {:apikey => 'valid-apikey',
65
+ :application => 'an application',
66
+ :event => 'an event',
67
+ :description => 'a description'}
68
+ end
69
+
70
+ should "raise an exception if an invalid API key is passed" do
71
+ @params.merge!({:apikey => 'invalid-apikey'})
72
+ stub_api_call(:post, 'add', @params, 'invalid_apikey.xml')
73
+ assert_raises Prowlr::ProwlrError do
74
+ Prowlr.add(@params)
75
+ end
76
+ end
77
+
78
+ should "raise an exception if neither an event or a description is passed" do
79
+ @params.delete(:event)
80
+ @params.delete(:description)
81
+ stub_api_call(:post, 'add', @params, 'bad_request.xml')
82
+ assert_raises Prowlr::ProwlrError do
83
+ Prowlr.add(@params)
84
+ end
85
+ end
86
+
87
+ should "return 200 if a valid API key and required params are passed" do
88
+ stub_api_call(:post, 'add', @params, 'success.xml')
89
+ assert_equal 200, Prowlr.add(@params)['code'].to_i
90
+ end
91
+ end
92
+
93
+ context "Creating an instance and adding an event" do
94
+ setup do
95
+ @params = {:application => 'an application',
96
+ :event => 'an event',
97
+ :description => 'a description'}
98
+ end
99
+
100
+ should "raise an exception if the instance was initialized with an invalid API key" do
101
+ apikey = 'invalid_apikey'
102
+ prowlr = Prowlr.new(apikey)
103
+ stub_api_call(:post, 'add', @params.merge(:apikey => apikey), 'invalid_apikey.xml')
104
+ assert_raises Prowlr::ProwlrError do
105
+ prowlr.add(@params)
106
+ end
107
+ end
108
+
109
+ should "raise an exception if neither an event or a description is passed" do
110
+ apikey = 'invalid_apikey'
111
+ prowlr = Prowlr.new(apikey)
112
+ @params.delete(:event)
113
+ @params.delete(:description)
114
+ stub_api_call(:post, 'add', @params.merge(:apikey => apikey), 'bad_request.xml')
115
+ assert_raises Prowlr::ProwlrError do
116
+ prowlr.add(@params)
117
+ end
118
+ end
119
+
120
+ should "return 200 if the instance was initialized with a valid API key and required params are passed" do
121
+ apikey = 'valid_apikey'
122
+ prowlr = Prowlr.new(apikey)
123
+ stub_api_call(:post, 'add', @params.merge(:apikey => apikey), 'success.xml')
124
+ assert_equal 200, prowlr.add(@params)['code'].to_i
125
+ end
126
+ end
127
+ end
@@ -0,0 +1,34 @@
1
+ require 'rubygems'
2
+ require 'test/unit'
3
+ require 'shoulda'
4
+ require 'mocha'
5
+ require 'fakeweb'
6
+ require 'uri'
7
+
8
+ FakeWeb.allow_net_connect = false
9
+
10
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
11
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
12
+ require 'prowlr'
13
+
14
+ class Test::Unit::TestCase
15
+ end
16
+
17
+ def fixture_file(filename)
18
+ return '' if filename == ''
19
+ file_path = File.expand_path(File.dirname(__FILE__) + '/fixtures/' + filename)
20
+ File.read(file_path)
21
+ end
22
+
23
+ def prowlr_uri(uri)
24
+ uri =~ /^https/ ? uri : "https://prowl.weks.net/publicapi/#{uri}"
25
+ end
26
+
27
+ def encode_params(params)
28
+ params.map {|k,v| "#{URI.escape(k.to_s)}=#{URI.escape(v.to_s)}"}.join('&')
29
+ end
30
+
31
+ def stub_api_call(method, uri, params, filename)
32
+ uri = "#{prowlr_uri(uri)}?#{encode_params(params)}"
33
+ FakeWeb.register_uri(method, uri, :body => fixture_file(filename))
34
+ end
metadata ADDED
@@ -0,0 +1,84 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: prowlr
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.2.2
5
+ platform: ruby
6
+ authors:
7
+ - Rob Bevan
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2009-07-13 00:00:00 +01:00
13
+ default_executable: prowlr
14
+ dependencies: []
15
+
16
+ description:
17
+ email: robbevan@xpt.com
18
+ executables:
19
+ - prowlr
20
+ extensions: []
21
+
22
+ extra_rdoc_files:
23
+ - LICENSE
24
+ - README.md
25
+ files:
26
+ - .document
27
+ - .gitignore
28
+ - LICENSE
29
+ - README.md
30
+ - Rakefile
31
+ - VERSION
32
+ - bin/prowlr
33
+ - examples/add.rb
34
+ - examples/add_instance.rb
35
+ - examples/helpers/config_store.rb
36
+ - examples/remaining_calls.rb
37
+ - examples/reset_date.rb
38
+ - examples/valid_apikey.rb
39
+ - examples/verify.rb
40
+ - lib/prowlr.rb
41
+ - prowlr.gemspec
42
+ - test/fixtures/bad_request.xml
43
+ - test/fixtures/invalid_apikey.xml
44
+ - test/fixtures/success.xml
45
+ - test/prowlr_test.rb
46
+ - test/test_helper.rb
47
+ has_rdoc: true
48
+ homepage: http://github.com/robbevan/prowlr
49
+ licenses: []
50
+
51
+ post_install_message:
52
+ rdoc_options:
53
+ - --charset=UTF-8
54
+ require_paths:
55
+ - lib
56
+ required_ruby_version: !ruby/object:Gem::Requirement
57
+ requirements:
58
+ - - ">="
59
+ - !ruby/object:Gem::Version
60
+ version: "0"
61
+ version:
62
+ required_rubygems_version: !ruby/object:Gem::Requirement
63
+ requirements:
64
+ - - ">="
65
+ - !ruby/object:Gem::Version
66
+ version: "0"
67
+ version:
68
+ requirements: []
69
+
70
+ rubyforge_project:
71
+ rubygems_version: 1.3.3
72
+ signing_key:
73
+ specification_version: 3
74
+ summary: Yet another Prowl API gem and command line interface
75
+ test_files:
76
+ - test/prowlr_test.rb
77
+ - test/test_helper.rb
78
+ - examples/add.rb
79
+ - examples/add_instance.rb
80
+ - examples/helpers/config_store.rb
81
+ - examples/remaining_calls.rb
82
+ - examples/reset_date.rb
83
+ - examples/valid_apikey.rb
84
+ - examples/verify.rb