push4 0.0.1 → 0.1.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0433449ec2d3a7a12231af942d69152105e5d2fb
4
- data.tar.gz: f5130b784271486c3b4a3d88a89b5513e5ba3af4
3
+ metadata.gz: c5e4e20fd2da1c27b810daa0615edfc78a841f6e
4
+ data.tar.gz: 63d70224d77b57b25288a995475fa3b9cd07625c
5
5
  SHA512:
6
- metadata.gz: 9425386e2587a9afe6935c404d6a193c65889ddf126d15419b00a67daff076381d37d2ea1767c50f31988be2c4ddc428ad8be35db30e5f0f5751e8d209dc6269
7
- data.tar.gz: e09a65b0b3582dd6631aa25acc6ccd743912ba6f1e4bdd47f3967af1d841013baf704d0f98c59fdc660f6576c2010869bab7c1187f295841527fec525ee4c1b4
6
+ metadata.gz: 51b350cd73c0f627ae78ccd3b36d320bd9c7aeb985a55910e108d2ff2125cee46d58c285e8c0cbd218cbf5a2269fb5f27e9b2a2408b2521ef976ce1502a05912
7
+ data.tar.gz: d9d9d5fd700690de823e930705b8f3724e36401f1c32e4df625a9a55f53bb0cc1b0e8ef68f532aba996229efc22720844fc6942f4330c6e952f4a71efdc3fcbc
@@ -1,2 +1,6 @@
1
+ ##### v0.1.0 (2013-06-25) #####
2
+ * fixed: setting user credentials at the `Notification` level
3
+ * fixed: issues with Ruby 1.8 and 1.9 related to HTTPS support
4
+
1
5
  ##### v0.0.1 (2013-06-09) #####
2
6
  * initial release
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ source 'https://rubygems.org'
2
+
3
+ group :test do
4
+ gem 'rake'
5
+ gem 'coveralls'
6
+ end
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.user_credential = push4_key
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
- #require 'rake/testtask'
3
+ require 'rake/testtask'
4
4
 
5
5
  require 'push4/version'
6
6
 
7
- #task :default => [:build]
7
+ task :default => [:test]
8
8
 
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
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'
@@ -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
- @data['user_credentials'] = Push4.user_credentials
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
- Net::HTTP.post_form(URI(Push4::URL), @data)
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.new("Expected number between #{range}")
94
+ raise ArgumentError, "Expected number between #{range}"
83
95
  end
84
96
  end
85
97
  end
@@ -1,8 +1,8 @@
1
1
  module Push4
2
2
  class Version
3
3
  MAJOR = 0
4
- MINOR = 0
5
- TINY = 1
4
+ MINOR = 1
5
+ TINY = 0
6
6
  end
7
7
 
8
8
  VERSION = [Version::MAJOR, Version::MINOR, Version::TINY].join('.')
@@ -0,0 +1,7 @@
1
+ require 'bundler'
2
+ Bundler.require(:test)
3
+
4
+ require 'test/unit'
5
+ require 'coveralls'
6
+
7
+ Coveralls.wear!
@@ -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.1
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-09 00:00:00.000000000 Z
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