ruby-notify-my-android 0.3.1

Sign up to get free protection for your applications and to get access to all the features.
data/.document ADDED
@@ -0,0 +1,5 @@
1
+ lib/**/*.rb
2
+ bin/*
3
+ -
4
+ features/**/*.feature
5
+ LICENSE.txt
data/Gemfile ADDED
@@ -0,0 +1,16 @@
1
+ source "http://rubygems.org"
2
+ # Add dependencies required to use your gem here.
3
+ # Example:
4
+ # gem "activesupport", ">= 2.3.5"
5
+
6
+ gem "xml-simple", ">= 1.0.15"
7
+
8
+ # Add dependencies to develop your gem here.
9
+ # Include everything needed to run rake, tests, features, etc.
10
+ group :development do
11
+ gem "test-unit", ">= 0"
12
+ gem "bundler", "~> 1.0.0"
13
+ gem "jeweler", "~> 1.5.2"
14
+ gem "rcov", ">= 0"
15
+ gem "webmock"
16
+ end
data/LICENSE.txt ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2011 Ken Pepple
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.
data/README.rdoc ADDED
@@ -0,0 +1,69 @@
1
+ = ruby-notify-my-android
2
+
3
+ Send notifications to Android devices via the Notify My Android API. Details about the API are available at https://nma.usk.bz/api.php .
4
+
5
+ == Installation
6
+
7
+ gem install ruby-notify-my-android
8
+
9
+ == Usage as a Gem
10
+
11
+ Sending a notification via ruby-notify-my-android gem
12
+
13
+ require 'ruby-notify-my-android'
14
+
15
+ NMA.notify do |n|
16
+ n.apikey = "9d1538ab7b52360e906e0e766f34501b69edde92fe3409e9" # can also be list such as ["key1", "key2"]
17
+ n.priority = NMA::Priority::MODERATE
18
+ n.application = "NMA"
19
+ n.event = "Notification"
20
+ n.description = "Your server is under attack!!!"
21
+ n.url = "http://www.nma.bz"
22
+ end
23
+
24
+ == Using the API
25
+
26
+ There are only a few commands that are available:
27
+ * notify(notification block): send a notification via the block given (see above) and returns standard API response.
28
+ * verify(apikey): send API call to verify key. returns standard API response.
29
+ * valid_key?(apikey): send API call to verify key. returns true or false.
30
+ * remaining_calls(apikey): send API call to verify key. returns number of remaining calls as integer.
31
+ * version: returns version of this gem
32
+
33
+ The standard API response for a successful call is as follows:
34
+ #<NMA::Response:0x1059682b8
35
+ @body={"success"=>[{"resettimer"=>"59", "code"=>"200", "remaining"=>"798"}]},
36
+ @code="200",
37
+ @raw=
38
+ "<?xml version=\"1.0\" encoding=\"UTF-8\"?><nma><success code=\"200\" remaining=\"798\" resettimer=\"59\" /></nma>\r\n",
39
+ @response={"resettimer"=>"59", "code"=>"200", "remaining"=>"798"}>
40
+
41
+ The standard API response for a unsuccessful call is as follows:
42
+ @body=
43
+ {"error"=>
44
+ [{"code"=>"400", "content"=>"Parameter 'apikey' length is invalid."}]},
45
+ @code="200",
46
+ @raw=
47
+ "<?xml version=\"1.0\" encoding=\"UTF-8\"?><nma><error code=\"400\" >Parameter 'apikey' length is invalid.</error></nma>\r\n",
48
+ @response={"code"=>"400", "content"=>"Parameter 'apikey' length is invalid."}>
49
+
50
+ Note that the @code signifies the success or failure of the HTTP call, not the NMA call. Use the @response["code"] for that determination.
51
+
52
+ == Contributing to ruby-notify-my-android
53
+
54
+ * Familiarize yourself with the documentation at https://nma.usk.bz/api.php
55
+ * Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet
56
+ * Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it
57
+ * Fork the project
58
+ * Start a feature/bugfix branch
59
+ * Make tests for your new feature(s). We can't accept non-tested features.
60
+ * Commit and push until you are happy with your contribution
61
+ * Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
62
+
63
+ == Copyright
64
+
65
+ Written by Ken Pepple
66
+
67
+ Based on Prowly gem (https://github.com/rafmagana/prowly) by Rafael Magana
68
+
69
+ See LICENSE.txt for further details.
data/Rakefile ADDED
@@ -0,0 +1,52 @@
1
+ require 'rubygems'
2
+ require 'bundler'
3
+ begin
4
+ Bundler.setup(:default, :development)
5
+ rescue Bundler::BundlerError => e
6
+ $stderr.puts e.message
7
+ $stderr.puts "Run `bundle install` to install missing gems"
8
+ exit e.status_code
9
+ end
10
+ require 'rake'
11
+
12
+ require 'jeweler'
13
+ Jeweler::Tasks.new do |gem|
14
+ # gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
15
+ gem.name = "ruby-notify-my-android"
16
+ gem.homepage = "http://github.com/slashk/ruby-notify-my-android"
17
+ gem.license = "MIT"
18
+ gem.summary = %Q{Send notifications to Android devices via the Notify My Android API}
19
+ gem.description = %Q{Send notifications to Android devices via the Notify My Android API. Details about the API are available at https://nma.usk.bz/api.php .}
20
+ gem.email = "ken.pepple@rabbityard.com"
21
+ gem.authors = ["Ken Pepple"]
22
+ # gem.executables = [ 'notify-my-android' ]
23
+ gem.add_runtime_dependency "xml-simple", ">= 1.0.15"
24
+ gem.add_development_dependency 'webmock'
25
+ end
26
+ Jeweler::RubygemsDotOrgTasks.new
27
+
28
+ require 'rake/testtask'
29
+ Rake::TestTask.new(:test) do |test|
30
+ test.libs << 'lib' << 'test'
31
+ test.pattern = 'test/**/test_*.rb'
32
+ test.verbose = true
33
+ end
34
+
35
+ require 'rcov/rcovtask'
36
+ Rcov::RcovTask.new do |test|
37
+ test.libs << 'test'
38
+ test.pattern = 'test/**/test_*.rb'
39
+ test.verbose = true
40
+ end
41
+
42
+ task :default => :test
43
+
44
+ require 'rake/rdoctask'
45
+ Rake::RDocTask.new do |rdoc|
46
+ version = File.exist?('VERSION') ? File.read('VERSION') : ""
47
+
48
+ rdoc.rdoc_dir = 'rdoc'
49
+ rdoc.title = "ruby-notify-my-android #{version}"
50
+ rdoc.rdoc_files.include('README*')
51
+ rdoc.rdoc_files.include('lib/**/*.rb')
52
+ end
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.3.1
@@ -0,0 +1,29 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ $LOAD_PATH.unshift File.expand_path(File.dirname(__FILE__) + '/../lib')
4
+
5
+ require 'ruby-notify-my-android'
6
+ require 'yaml'
7
+
8
+ # set defaults
9
+ options = { :apikey => nil,
10
+ :description => "test description",
11
+ :event => "test event",
12
+ :application => "NMA",
13
+ :priority => Priority::NORMAL }
14
+
15
+ # use first argument on command line as API key
16
+ options[:apikey] = ARGV[0]
17
+
18
+ # send notification
19
+ result = NMA.notify do |n|
20
+ n.apikey = options[:apikey]
21
+ n.priority = options[:priority]
22
+ n.application = options[:application]
23
+ n.event = options[:event]
24
+ n.description = options[:description]
25
+ n.url = options[:url]
26
+ end
27
+
28
+ # putput raw XML response
29
+ puts result.raw
@@ -0,0 +1,35 @@
1
+ require 'ruby-notify-my-android/request'
2
+ require 'ruby-notify-my-android/response'
3
+ require 'ruby-notify-my-android/notification'
4
+
5
+ # This is the main Notify My Andoid module
6
+
7
+ module NMA
8
+
9
+ extend self
10
+
11
+ def notify(notification = Notification.new)
12
+ yield notification if block_given?
13
+ Request.instance.call Request::Command::NOTIFY, notification.to_params
14
+ end
15
+
16
+ def verify(apikey)
17
+ Request.instance.call Request::Command::VERIFY, "apikey=#{apikey}"
18
+ end
19
+
20
+ def valid_key?(key)
21
+ result = verify(key)
22
+ result.succeeded?
23
+ end
24
+
25
+ def remaining_calls(key)
26
+ result = verify(key)
27
+ return result.response["remaining"].to_i if result.succeeded?
28
+ result.response["content"]
29
+ end
30
+
31
+ def version
32
+ File.read(File.join(File.dirname(__FILE__), *%w[.. VERSION]))
33
+ end
34
+
35
+ end
@@ -0,0 +1,62 @@
1
+ require 'cgi'
2
+
3
+ module NMA
4
+
5
+ class Notification
6
+
7
+ ## EXCEPTIONS
8
+ class NoAPIKeyGiven < RuntimeError; end
9
+ class NoDescriptionGiven < RuntimeError; end
10
+ class NoApplicationNameGiven < RuntimeError; end
11
+
12
+ attr_accessor :application, :description
13
+ attr_accessor :providerkey, :priority, :event, :url
14
+ attr_writer :apikey
15
+
16
+ def apikey
17
+ if @apikey.is_a? Array
18
+ @apikey.join(',')
19
+ else
20
+ @apikey
21
+ end
22
+ end
23
+
24
+ def initialize(params = {})
25
+ @apikey = params[:apikey]
26
+ @application = params[:application] || "NMA"
27
+ @event = params[:event] || "NMA is working!!"
28
+ @description = params[:description] || "This is the default description"
29
+ @priority = params[:priority] || Priority::NORMAL
30
+ @url = params[:url] || nil
31
+ end
32
+
33
+ def to_params
34
+ raise NoAPIKeyGiven if apikey.nil?
35
+ raise NoApplicationNameGiven if @application.nil?
36
+ raise NoDescriptionGiven if @description.nil?
37
+ params.join('&')
38
+ end
39
+
40
+ private
41
+ def params
42
+ attributes = []
43
+ instance_variables.each do |var|
44
+ raw_attr = "#{var.to_s.sub('@','')}"
45
+ value = send("#{raw_attr}")
46
+ next if value.nil?
47
+ attributes << "#{raw_attr}=" + CGI.escape(value.to_s)
48
+ end
49
+ attributes.sort
50
+ end
51
+
52
+ end
53
+
54
+ class Priority
55
+ VERY_LOW = -2
56
+ MODERATE = -1
57
+ NORMAL = 0
58
+ HIGH = 1
59
+ EMERGENCY = 2
60
+ end
61
+
62
+ end
@@ -0,0 +1,41 @@
1
+ require 'net/https'
2
+ require 'singleton'
3
+
4
+ module NMA
5
+
6
+ class Request
7
+
8
+ include Singleton
9
+
10
+ def initialize
11
+ @url = "https://nma.usk.bz/publicapi"
12
+ end
13
+
14
+ ## Make the actual call to the api
15
+ def call(command, params)
16
+ @command = command
17
+ request = Net::HTTP::Get.new(uri.request_uri + "?" + params)
18
+ response = http.request(request)
19
+ Response.new(response)
20
+ end
21
+
22
+ private
23
+ def http
24
+ http = Net::HTTP.new(uri.host, uri.port)
25
+ http.use_ssl = true
26
+ http.verify_mode = OpenSSL::SSL::VERIFY_NONE
27
+ http
28
+ end
29
+
30
+ def uri
31
+ URI.parse("#{@url}/#{@command}")
32
+ end
33
+
34
+ module Command
35
+ NOTIFY = "notify"
36
+ VERIFY = "verify"
37
+ end
38
+
39
+ end
40
+
41
+ end
@@ -0,0 +1,34 @@
1
+ require 'rubygems'
2
+ require 'xmlsimple'
3
+
4
+ module NMA
5
+
6
+ # A wrapper around the API response.
7
+ class Response
8
+
9
+ # The response body.
10
+ attr_accessor :raw
11
+
12
+ # The HTTP status code of the response.
13
+ attr_accessor :code
14
+
15
+ # A hash of the returned XML response
16
+ attr_accessor :body
17
+
18
+ # A hash of the cooked XML
19
+ attr_accessor :response
20
+
21
+ def initialize(response)
22
+ self.raw = response.body
23
+ self.code = response.code
24
+ self.body = XmlSimple.xml_in(response.body)
25
+ self.response = self.body[self.body.keys.first].first
26
+ end
27
+
28
+ def succeeded?
29
+ self.response["code"] == "200"
30
+ end
31
+
32
+ end
33
+
34
+ end
@@ -0,0 +1,80 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
+ # -*- encoding: utf-8 -*-
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = %q{ruby-notify-my-android}
8
+ s.version = "0.3.1"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["Ken Pepple"]
12
+ s.date = %q{2011-04-18}
13
+ s.default_executable = %q{notify-my-andoid}
14
+ s.description = %q{Send notifications to Android devices via the Notify My Android API. Details about the API are available at https://nma.usk.bz/api.php .}
15
+ s.email = %q{ken.pepple@rabbityard.com}
16
+ s.executables = ["notify-my-andoid"]
17
+ s.extra_rdoc_files = [
18
+ "LICENSE.txt",
19
+ "README.rdoc"
20
+ ]
21
+ s.files = [
22
+ ".document",
23
+ "Gemfile",
24
+ "LICENSE.txt",
25
+ "README.rdoc",
26
+ "Rakefile",
27
+ "VERSION",
28
+ "bin/notify-my-andoid",
29
+ "lib/ruby-notify-my-android.rb",
30
+ "lib/ruby-notify-my-android/notification.rb",
31
+ "lib/ruby-notify-my-android/request.rb",
32
+ "lib/ruby-notify-my-android/response.rb",
33
+ "ruby-notify-my-android.gemspec",
34
+ "test/helper.rb",
35
+ "test/test_ruby-notify-my-android.rb"
36
+ ]
37
+ s.homepage = %q{http://github.com/slashk/ruby-notify-my-android}
38
+ s.licenses = ["MIT"]
39
+ s.require_paths = ["lib"]
40
+ s.rubygems_version = %q{1.5.2}
41
+ s.summary = %q{Send notifications to Android devices via the Notify My Android API}
42
+ s.test_files = [
43
+ "test/helper.rb",
44
+ "test/test_ruby-notify-my-android.rb"
45
+ ]
46
+
47
+ if s.respond_to? :specification_version then
48
+ s.specification_version = 3
49
+
50
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
51
+ s.add_runtime_dependency(%q<xml-simple>, [">= 1.0.15"])
52
+ s.add_development_dependency(%q<test-unit>, [">= 0"])
53
+ s.add_development_dependency(%q<bundler>, ["~> 1.0.0"])
54
+ s.add_development_dependency(%q<jeweler>, ["~> 1.5.2"])
55
+ s.add_development_dependency(%q<rcov>, [">= 0"])
56
+ s.add_development_dependency(%q<webmock>, [">= 0"])
57
+ s.add_runtime_dependency(%q<xml-simple>, [">= 1.0.15"])
58
+ s.add_development_dependency(%q<webmock>, [">= 0"])
59
+ else
60
+ s.add_dependency(%q<xml-simple>, [">= 1.0.15"])
61
+ s.add_dependency(%q<test-unit>, [">= 0"])
62
+ s.add_dependency(%q<bundler>, ["~> 1.0.0"])
63
+ s.add_dependency(%q<jeweler>, ["~> 1.5.2"])
64
+ s.add_dependency(%q<rcov>, [">= 0"])
65
+ s.add_dependency(%q<webmock>, [">= 0"])
66
+ s.add_dependency(%q<xml-simple>, [">= 1.0.15"])
67
+ s.add_dependency(%q<webmock>, [">= 0"])
68
+ end
69
+ else
70
+ s.add_dependency(%q<xml-simple>, [">= 1.0.15"])
71
+ s.add_dependency(%q<test-unit>, [">= 0"])
72
+ s.add_dependency(%q<bundler>, ["~> 1.0.0"])
73
+ s.add_dependency(%q<jeweler>, ["~> 1.5.2"])
74
+ s.add_dependency(%q<rcov>, [">= 0"])
75
+ s.add_dependency(%q<webmock>, [">= 0"])
76
+ s.add_dependency(%q<xml-simple>, [">= 1.0.15"])
77
+ s.add_dependency(%q<webmock>, [">= 0"])
78
+ end
79
+ end
80
+
data/test/helper.rb ADDED
@@ -0,0 +1,18 @@
1
+ require 'rubygems'
2
+ require 'bundler'
3
+ begin
4
+ Bundler.setup(:default, :development)
5
+ rescue Bundler::BundlerError => e
6
+ $stderr.puts e.message
7
+ $stderr.puts "Run `bundle install` to install missing gems"
8
+ exit e.status_code
9
+ end
10
+ require 'test/unit'
11
+
12
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
13
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
14
+ require 'ruby-notify-my-android'
15
+ require 'webmock/test_unit'
16
+
17
+ class Test::Unit::TestCase
18
+ end
@@ -0,0 +1,120 @@
1
+ require 'helper'
2
+
3
+ class TestRubyNotifyMyAndroid < Test::Unit::TestCase
4
+
5
+ def setup
6
+ @api_endpoint = "https://nma.usk.bz/publicapi/"
7
+ @good_apikey = "9d0538ab7b52360e906e0e766f34501b69edde92fe3409e9"
8
+ @bad_apikey = "9d0538ab7b52360e906e0e766f34501b69edde92fe3409e0"
9
+ # verify endpoints and stubs
10
+ good_verify_endpoint = @api_endpoint + "verify?apikey=" + @good_apikey
11
+ bad_verify_endpoint = @api_endpoint + "verify?apikey=" + @bad_apikey
12
+ good_verify_return = '<?xml version="1.0" encoding="UTF-8"?><nma><success code="200" remaining="799" resettimer="60" /></nma>'
13
+ bad_verify_return = '<?xml version="1.0" encoding="UTF-8"?><nma><error code="401" >The API key is not valid.</error></nma>'
14
+ stub_request(:get, good_verify_endpoint).
15
+ with(:headers => {'Accept'=>'*/*'}).
16
+ to_return(:body => good_verify_return, :status => 200)
17
+ stub_request(:get, bad_verify_endpoint).
18
+ with(:headers => {'Accept'=>'*/*'}).
19
+ to_return(:body => bad_verify_return, :status => 200)
20
+ # notify endpoints and stubs
21
+ default_notify_params = "&application=NMA&description=This%20is%20the%20default%20description&event=NMA%20is%20working!!&priority=0"
22
+ important_notify_params = "&application=NMA&description=This%20is%20the%20default%20description&event=NMA%20is%20working!!&priority=" + NMA::Priority::EMERGENCY.to_s
23
+ good_notify_endpoint = @api_endpoint + "notify?apikey=" + @good_apikey + default_notify_params
24
+ dbl_good_notify_endpoint = @api_endpoint + "notify?apikey=" + @good_apikey + "," + @good_apikey + default_notify_params
25
+ bad_notify_endpoint = @api_endpoint + "notify?apikey=" + @bad_apikey + default_notify_params
26
+ important_notify_endpoint = @api_endpoint + "notify?apikey=" + @good_apikey + important_notify_params
27
+ good_notify_return = '<?xml version="1.0" encoding="UTF-8"?><nma><success code="200" remaining="790" resettimer="43" /></nma>'
28
+ bad_notify_return = '<?xml version="1.0" encoding="UTF-8"?><nma><error code="401" >None of the API keys provided were valid.</error></nma>'
29
+ stub_request(:get, good_notify_endpoint).
30
+ with(:headers => {'Accept'=>'*/*'}).
31
+ to_return(:status => 200, :body => good_notify_return, :headers => {})
32
+ stub_request(:get, dbl_good_notify_endpoint).
33
+ with(:headers => {'Accept'=>'*/*'}).
34
+ to_return(:status => 200, :body => good_notify_return, :headers => {})
35
+ stub_request(:get, bad_notify_endpoint).
36
+ with(:headers => {'Accept'=>'*/*'}).
37
+ to_return(:status => 200, :body => bad_notify_return, :headers => {})
38
+ stub_request(:get, important_notify_endpoint).
39
+ with(:headers => {'Accept'=>'*/*'}).
40
+ to_return(:status => 200, :body => good_notify_return, :headers => {})
41
+ end
42
+
43
+ def test_should_verify_good_key
44
+ result = NMA.verify(@good_apikey)
45
+ assert_equal(true, result.succeeded?)
46
+ assert_equal("200", result.code)
47
+ assert_equal("799", result.response["remaining"])
48
+ assert_equal("200", result.response["code"])
49
+ assert_equal("60", result.response["resettimer"])
50
+ end
51
+
52
+ def test_should_verify_bad_but_valid_size_apikey
53
+ result = NMA.verify(@bad_apikey)
54
+ assert_equal("200", result.code)
55
+ assert_equal("401", result.response["code"])
56
+ assert_equal("The API key is not valid.", result.response["content"])
57
+ end
58
+
59
+ def test_should_notify
60
+ result = NMA.notify do |n|
61
+ n.apikey = @good_apikey
62
+ end
63
+ assert_equal("200", result.code)
64
+ assert_equal("790", result.response["remaining"])
65
+ assert_equal("200", result.response["code"])
66
+ assert_equal("43", result.response["resettimer"])
67
+ end
68
+
69
+ def test_should_notify_with_multiple_keys
70
+ result = NMA.notify do |n|
71
+ n.apikey = [@good_apikey, @good_apikey]
72
+ end
73
+ assert_equal("200", result.code)
74
+ assert_equal("790", result.response["remaining"])
75
+ assert_equal("200", result.response["code"])
76
+ assert_equal("43", result.response["resettimer"])
77
+ end
78
+
79
+ def test_should_not_notify_with_bad_apikey
80
+ result = NMA.notify do |n|
81
+ n.apikey = @bad_apikey
82
+ end
83
+ assert_equal("200", result.code)
84
+ assert_equal("401", result.response["code"])
85
+ assert_equal("None of the API keys provided were valid.", result.response["content"])
86
+ end
87
+
88
+ def test_should_not_notify_with_good_apikey
89
+ result = NMA.notify do |n|
90
+ n.apikey = @good_apikey
91
+ n.priority = NMA::Priority::EMERGENCY
92
+ end
93
+ assert_equal("200", result.code)
94
+ end
95
+
96
+ def test_should_show_remaining_calls
97
+ result = NMA.remaining_calls(@good_apikey)
98
+ assert_equal(799, result)
99
+ end
100
+
101
+ def test_should_not_show_remaining_calls_with_bad_apikey
102
+ result = NMA.remaining_calls(@bad_apikey)
103
+ assert_equal("The API key is not valid.", result)
104
+ end
105
+
106
+
107
+ def test_for_valid_key
108
+ assert_equal(true, NMA.valid_key?(@good_apikey))
109
+ end
110
+
111
+ def test_for_invalid_key
112
+ assert_equal(false, NMA.valid_key?(@bad_apikey))
113
+ end
114
+
115
+ def test_version
116
+ v = File.read(File.join(File.dirname(__FILE__), '..', 'VERSION'))
117
+ assert_equal(v, NMA.version)
118
+ end
119
+
120
+ end
metadata ADDED
@@ -0,0 +1,201 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: ruby-notify-my-android
3
+ version: !ruby/object:Gem::Version
4
+ hash: 17
5
+ prerelease:
6
+ segments:
7
+ - 0
8
+ - 3
9
+ - 1
10
+ version: 0.3.1
11
+ platform: ruby
12
+ authors:
13
+ - Ken Pepple
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2011-04-18 00:00:00 -07:00
19
+ default_executable: notify-my-andoid
20
+ dependencies:
21
+ - !ruby/object:Gem::Dependency
22
+ prerelease: false
23
+ type: :runtime
24
+ requirement: &id001 !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ">="
28
+ - !ruby/object:Gem::Version
29
+ hash: 9
30
+ segments:
31
+ - 1
32
+ - 0
33
+ - 15
34
+ version: 1.0.15
35
+ name: xml-simple
36
+ version_requirements: *id001
37
+ - !ruby/object:Gem::Dependency
38
+ prerelease: false
39
+ type: :development
40
+ requirement: &id002 !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ">="
44
+ - !ruby/object:Gem::Version
45
+ hash: 3
46
+ segments:
47
+ - 0
48
+ version: "0"
49
+ name: test-unit
50
+ version_requirements: *id002
51
+ - !ruby/object:Gem::Dependency
52
+ prerelease: false
53
+ type: :development
54
+ requirement: &id003 !ruby/object:Gem::Requirement
55
+ none: false
56
+ requirements:
57
+ - - ~>
58
+ - !ruby/object:Gem::Version
59
+ hash: 23
60
+ segments:
61
+ - 1
62
+ - 0
63
+ - 0
64
+ version: 1.0.0
65
+ name: bundler
66
+ version_requirements: *id003
67
+ - !ruby/object:Gem::Dependency
68
+ prerelease: false
69
+ type: :development
70
+ requirement: &id004 !ruby/object:Gem::Requirement
71
+ none: false
72
+ requirements:
73
+ - - ~>
74
+ - !ruby/object:Gem::Version
75
+ hash: 7
76
+ segments:
77
+ - 1
78
+ - 5
79
+ - 2
80
+ version: 1.5.2
81
+ name: jeweler
82
+ version_requirements: *id004
83
+ - !ruby/object:Gem::Dependency
84
+ prerelease: false
85
+ type: :development
86
+ requirement: &id005 !ruby/object:Gem::Requirement
87
+ none: false
88
+ requirements:
89
+ - - ">="
90
+ - !ruby/object:Gem::Version
91
+ hash: 3
92
+ segments:
93
+ - 0
94
+ version: "0"
95
+ name: rcov
96
+ version_requirements: *id005
97
+ - !ruby/object:Gem::Dependency
98
+ prerelease: false
99
+ type: :development
100
+ requirement: &id006 !ruby/object:Gem::Requirement
101
+ none: false
102
+ requirements:
103
+ - - ">="
104
+ - !ruby/object:Gem::Version
105
+ hash: 3
106
+ segments:
107
+ - 0
108
+ version: "0"
109
+ name: webmock
110
+ version_requirements: *id006
111
+ - !ruby/object:Gem::Dependency
112
+ prerelease: false
113
+ type: :runtime
114
+ requirement: &id007 !ruby/object:Gem::Requirement
115
+ none: false
116
+ requirements:
117
+ - - ">="
118
+ - !ruby/object:Gem::Version
119
+ hash: 9
120
+ segments:
121
+ - 1
122
+ - 0
123
+ - 15
124
+ version: 1.0.15
125
+ name: xml-simple
126
+ version_requirements: *id007
127
+ - !ruby/object:Gem::Dependency
128
+ prerelease: false
129
+ type: :development
130
+ requirement: &id008 !ruby/object:Gem::Requirement
131
+ none: false
132
+ requirements:
133
+ - - ">="
134
+ - !ruby/object:Gem::Version
135
+ hash: 3
136
+ segments:
137
+ - 0
138
+ version: "0"
139
+ name: webmock
140
+ version_requirements: *id008
141
+ description: Send notifications to Android devices via the Notify My Android API. Details about the API are available at https://nma.usk.bz/api.php .
142
+ email: ken.pepple@rabbityard.com
143
+ executables:
144
+ - notify-my-andoid
145
+ extensions: []
146
+
147
+ extra_rdoc_files:
148
+ - LICENSE.txt
149
+ - README.rdoc
150
+ files:
151
+ - .document
152
+ - Gemfile
153
+ - LICENSE.txt
154
+ - README.rdoc
155
+ - Rakefile
156
+ - VERSION
157
+ - bin/notify-my-andoid
158
+ - lib/ruby-notify-my-android.rb
159
+ - lib/ruby-notify-my-android/notification.rb
160
+ - lib/ruby-notify-my-android/request.rb
161
+ - lib/ruby-notify-my-android/response.rb
162
+ - ruby-notify-my-android.gemspec
163
+ - test/helper.rb
164
+ - test/test_ruby-notify-my-android.rb
165
+ has_rdoc: true
166
+ homepage: http://github.com/slashk/ruby-notify-my-android
167
+ licenses:
168
+ - MIT
169
+ post_install_message:
170
+ rdoc_options: []
171
+
172
+ require_paths:
173
+ - lib
174
+ required_ruby_version: !ruby/object:Gem::Requirement
175
+ none: false
176
+ requirements:
177
+ - - ">="
178
+ - !ruby/object:Gem::Version
179
+ hash: 3
180
+ segments:
181
+ - 0
182
+ version: "0"
183
+ required_rubygems_version: !ruby/object:Gem::Requirement
184
+ none: false
185
+ requirements:
186
+ - - ">="
187
+ - !ruby/object:Gem::Version
188
+ hash: 3
189
+ segments:
190
+ - 0
191
+ version: "0"
192
+ requirements: []
193
+
194
+ rubyforge_project:
195
+ rubygems_version: 1.5.2
196
+ signing_key:
197
+ specification_version: 3
198
+ summary: Send notifications to Android devices via the Notify My Android API
199
+ test_files:
200
+ - test/helper.rb
201
+ - test/test_ruby-notify-my-android.rb