push4 0.0.1 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/Gemfile +6 -0
- data/README.md +4 -1
- data/Rakefile +9 -9
- data/lib/push4.rb +16 -4
- data/lib/push4/version.rb +2 -2
- data/test/test_helper.rb +7 -0
- data/test/test_post.rb +24 -0
- metadata +8 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c5e4e20fd2da1c27b810daa0615edfc78a841f6e
|
4
|
+
data.tar.gz: 63d70224d77b57b25288a995475fa3b9cd07625c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 51b350cd73c0f627ae78ccd3b36d320bd9c7aeb985a55910e108d2ff2125cee46d58c285e8c0cbd218cbf5a2269fb5f27e9b2a2408b2521ef976ce1502a05912
|
7
|
+
data.tar.gz: d9d9d5fd700690de823e930705b8f3724e36401f1c32e4df625a9a55f53bb0cc1b0e8ef68f532aba996229efc22720844fc6942f4330c6e952f4a71efdc3fcbc
|
data/CHANGELOG.md
CHANGED
data/Gemfile
ADDED
data/README.md
CHANGED
@@ -1,3 +1,6 @@
|
|
1
|
+
[![Coverage Status](https://coveralls.io/repos/cjlucas/ruby-push4/badge.png)](https://coveralls.io/r/cjlucas/ruby-push4)
|
2
|
+
[![Build Status](https://travis-ci.org/cjlucas/ruby-push4.png?branch=master)](https://travis-ci.org/cjlucas/ruby-push4)
|
3
|
+
|
1
4
|
This is a simple library for the [Push 4.0](http://www.appnotifications.com/) API.
|
2
5
|
|
3
6
|
Currently only the REST API is supported.
|
@@ -9,7 +12,7 @@ Currently only the REST API is supported.
|
|
9
12
|
require 'push4'
|
10
13
|
|
11
14
|
# user credentials can be set at the module level or directly in the Notification instance
|
12
|
-
Push4.
|
15
|
+
Push4.user_credentials = push4_key
|
13
16
|
|
14
17
|
# create a notification instance
|
15
18
|
notification = Push4::Notification.new
|
data/Rakefile
CHANGED
@@ -1,18 +1,18 @@
|
|
1
1
|
$LOAD_PATH.unshift(File.expand_path('../lib', __FILE__))
|
2
2
|
|
3
|
-
|
3
|
+
require 'rake/testtask'
|
4
4
|
|
5
5
|
require 'push4/version'
|
6
6
|
|
7
|
-
|
7
|
+
task :default => [:test]
|
8
8
|
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
9
|
+
task :test do
|
10
|
+
Rake::TestTask.new do |t|
|
11
|
+
t.libs << 'test'
|
12
|
+
t.test_files = FileList['test/test_*.rb']
|
13
|
+
t.verbose = false
|
14
|
+
end
|
15
|
+
end
|
16
16
|
|
17
17
|
task :build do
|
18
18
|
system 'gem build push4.gemspec'
|
data/lib/push4.rb
CHANGED
@@ -21,7 +21,6 @@ module Push4
|
|
21
21
|
attr_accessor :sound
|
22
22
|
|
23
23
|
simple_fields = [
|
24
|
-
:user_credentials,
|
25
24
|
:message,
|
26
25
|
:long_message,
|
27
26
|
:long_message_preview,
|
@@ -33,7 +32,12 @@ module Push4
|
|
33
32
|
|
34
33
|
def initialize
|
35
34
|
@data = {}
|
36
|
-
|
35
|
+
self.user_credentials = Push4.user_credentials
|
36
|
+
end
|
37
|
+
|
38
|
+
def user_credentials=(user_credentials)
|
39
|
+
@user_credentials = user_credentials
|
40
|
+
@data['user_credentials'] = user_credentials
|
37
41
|
end
|
38
42
|
|
39
43
|
def message_level=(message_level)
|
@@ -54,7 +58,15 @@ module Push4
|
|
54
58
|
end
|
55
59
|
|
56
60
|
def send
|
57
|
-
|
61
|
+
uri = URI(URL)
|
62
|
+
|
63
|
+
http = Net::HTTP.new(uri.host, uri.port)
|
64
|
+
http.use_ssl = true
|
65
|
+
|
66
|
+
req = Net::HTTP::Post.new(uri.to_s)
|
67
|
+
req.set_form_data(@data)
|
68
|
+
|
69
|
+
http.request(req)
|
58
70
|
end
|
59
71
|
|
60
72
|
def self.send
|
@@ -79,7 +91,7 @@ module Push4
|
|
79
91
|
|
80
92
|
def self.assert_num_in_range(num, range)
|
81
93
|
unless range.include?(num)
|
82
|
-
raise ArgumentError
|
94
|
+
raise ArgumentError, "Expected number between #{range}"
|
83
95
|
end
|
84
96
|
end
|
85
97
|
end
|
data/lib/push4/version.rb
CHANGED
data/test/test_helper.rb
ADDED
data/test/test_post.rb
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
require 'push4'
|
4
|
+
|
5
|
+
class TestPost < Test::Unit::TestCase
|
6
|
+
def test_post_no_api_key
|
7
|
+
resp = Push4::Notification.send { |notification| }
|
8
|
+
assert_block { resp.is_a?(Net::HTTPUnauthorized) }
|
9
|
+
end
|
10
|
+
|
11
|
+
def test_post_with_api_key
|
12
|
+
user_credentials_file = File.expand_path('../user_creds.txt', __FILE__)
|
13
|
+
|
14
|
+
if File.exists?(user_credentials_file)
|
15
|
+
resp = Push4::Notification.send do |notification|
|
16
|
+
notification.user_credentials = File.read(user_credentials_file).strip
|
17
|
+
notification.title = '[ruby-push4] this is the title'
|
18
|
+
notification.message = '[ruby-push4] this is the message'
|
19
|
+
end
|
20
|
+
|
21
|
+
assert_block { resp.is_a?(Net::HTTPSuccess) }
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: push4
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Chris Lucas
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-06-
|
11
|
+
date: 2013-06-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -32,12 +32,15 @@ extensions: []
|
|
32
32
|
extra_rdoc_files: []
|
33
33
|
files:
|
34
34
|
- CHANGELOG.md
|
35
|
+
- Gemfile
|
35
36
|
- LICENSE
|
36
37
|
- README.md
|
37
38
|
- Rakefile
|
38
39
|
- lib/push4.rb
|
39
40
|
- lib/push4/version.rb
|
40
41
|
- push4.gemspec
|
42
|
+
- test/test_helper.rb
|
43
|
+
- test/test_post.rb
|
41
44
|
homepage: https://github.com/cjlucas/ruby-push4
|
42
45
|
licenses:
|
43
46
|
- MIT
|
@@ -62,4 +65,6 @@ rubygems_version: 2.0.3
|
|
62
65
|
signing_key:
|
63
66
|
specification_version: 4
|
64
67
|
summary: A ruby library for the Push 4.0 API
|
65
|
-
test_files:
|
68
|
+
test_files:
|
69
|
+
- test/test_helper.rb
|
70
|
+
- test/test_post.rb
|