zero_push 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/.autotest ADDED
@@ -0,0 +1,25 @@
1
+ # -*- ruby -*-
2
+
3
+ require "autotest/restart"
4
+
5
+ # Autotest.add_hook :initialize do |at|
6
+ # at.testlib = "minitest/unit"
7
+ #
8
+ # at.extra_files << "../some/external/dependency.rb"
9
+ #
10
+ # at.libs << ":../some/external"
11
+ #
12
+ # at.add_exception "vendor"
13
+ #
14
+ # at.add_mapping(/dependency.rb/) do |f, _|
15
+ # at.files_matching(/test_.*rb$/)
16
+ # end
17
+ #
18
+ # %w(TestA TestB).each do |klass|
19
+ # at.extra_class_map[klass] = "test/test_misc.rb"
20
+ # end
21
+ # end
22
+
23
+ # Autotest.add_hook :run_command do |at|
24
+ # system "rake build"
25
+ # end
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in zero_push.gemspec
4
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,22 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ zero_push (0.0.1)
5
+ faraday (= 0.8.5)
6
+
7
+ GEM
8
+ remote: https://rubygems.org/
9
+ specs:
10
+ faraday (0.8.5)
11
+ multipart-post (~> 1.1)
12
+ minitest (4.6.1)
13
+ multipart-post (1.1.5)
14
+ vcr (2.4.0)
15
+
16
+ PLATFORMS
17
+ ruby
18
+
19
+ DEPENDENCIES
20
+ minitest (= 4.6.1)
21
+ vcr (= 2.4.0)
22
+ zero_push!
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2013 ZeroPush
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,33 @@
1
+ # ZeroPush
2
+
3
+ ---
4
+
5
+ ## Disclaimer:
6
+
7
+ This gem is not for use at this time
8
+
9
+ ## Installation
10
+
11
+ Add this line to your application's Gemfile:
12
+
13
+ gem 'zero_push'
14
+
15
+ And then execute:
16
+
17
+ $ bundle
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install zero_push
22
+
23
+ ## Usage
24
+
25
+ TODO: Write usage instructions here
26
+
27
+ ## Contributing
28
+
29
+ 1. Fork it
30
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
31
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
32
+ 4. Push to the branch (`git push origin my-new-feature`)
33
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,11 @@
1
+ require "rake/testtask"
2
+ require "bundler/gem_tasks"
3
+
4
+ task default: :test
5
+
6
+ Rake::TestTask.new do |t|
7
+ t.libs << 'lib' << 'spec'
8
+ t.test_files = Dir["spec/**/*_spec.rb"]
9
+ t.verbose = true
10
+ end
11
+
@@ -0,0 +1,3 @@
1
+ module ZeroPush
2
+ VERSION = "0.0.1"
3
+ end
data/lib/zero_push.rb ADDED
@@ -0,0 +1,22 @@
1
+ require 'zero_push/version'
2
+ require 'faraday'
3
+
4
+ module ZeroPush
5
+ URL = "http://www.zeropush.com"
6
+
7
+ class << self
8
+ attr_accessor :auth_token
9
+
10
+ def notify(params)
11
+ client.post('/api/notify', params)
12
+ end
13
+
14
+ def client
15
+ Faraday.new(url: URL) do |c|
16
+ c.token_auth self.auth_token
17
+ c.request :url_encoded # form-encode POST params
18
+ c.adapter Faraday.default_adapter # Net::HTTP
19
+ end
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,45 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: post
5
+ uri: https://staging.zeropush.com/api/notify
6
+ body:
7
+ encoding: US-ASCII
8
+ string: device_tokens%5B%5D=abc&alert=hi
9
+ headers:
10
+ Authorization:
11
+ - Token token="acEJeDVC8if6XCxwe2js"
12
+ Content-Type:
13
+ - application/x-www-form-urlencoded
14
+ response:
15
+ status:
16
+ code: 200
17
+ message:
18
+ headers:
19
+ cache-control:
20
+ - max-age=0, private, must-revalidate
21
+ content-type:
22
+ - application/json; charset=utf-8
23
+ etag:
24
+ - ! '"4548a4f1a11a241120f97a1c3737817a"'
25
+ server:
26
+ - thin 1.5.0 codename Knife
27
+ set-cookie:
28
+ - _zero-push-session=BAh7BkkiD3Nlc3Npb25faWQGOgZFRkkiJWNhNjk0MThlNTkyN2U2MDU0OGI1NmNhMjRlYTM0NDAyBjsAVA%3D%3D--c2725a3ea06e0f18296784b9755884f9a2b00a72;
29
+ path=/; HttpOnly
30
+ x-request-id:
31
+ - dfa3796a4db1cd63769e5618057d2d67
32
+ x-runtime:
33
+ - '0.045433'
34
+ x-ua-compatible:
35
+ - IE=Edge
36
+ transfer-encoding:
37
+ - chunked
38
+ connection:
39
+ - Close
40
+ body:
41
+ encoding: US-ASCII
42
+ string: ! '{"message":"ok"}'
43
+ http_version:
44
+ recorded_at: Wed, 20 Feb 2013 23:03:03 GMT
45
+ recorded_with: VCR 2.4.0
@@ -0,0 +1,14 @@
1
+ require 'minitest/spec'
2
+ require 'minitest/autorun'
3
+ require 'zero_push'
4
+ require 'vcr'
5
+
6
+ VCR.configure do |c|
7
+ c.cassette_library_dir = 'spec/fixtures'
8
+ c.hook_into :faraday
9
+ end
10
+
11
+ #TODO: remove this once Faraday 0.9.0 comes out
12
+ require 'net/https'
13
+ OpenSSL::SSL::VERIFY_PEER = OpenSSL::SSL::VERIFY_NONE
14
+ #Faraday.default_connection_options = {ssl: {verify: false}}
@@ -0,0 +1,25 @@
1
+ require 'spec_helper'
2
+
3
+ #Faraday.default_adapter = :test
4
+
5
+ describe ZeroPush do
6
+ before do
7
+ ZeroPush::URL = "https://staging.zeropush.com"
8
+ ZeroPush.auth_token = "acEJeDVC8if6XCxwe2js"
9
+ end
10
+
11
+ describe "/notify" do
12
+ before do
13
+ VCR.insert_cassette "notify"
14
+ end
15
+
16
+ after do
17
+ VCR.eject_cassette
18
+ end
19
+
20
+ it "should construct the request" do
21
+ response = ZeroPush.notify(device_tokens: ['abc'], alert: 'hi')
22
+ response.status.must_equal 200
23
+ end
24
+ end
25
+ end
data/zero_push.gemspec ADDED
@@ -0,0 +1,24 @@
1
+ # -*- encoding: utf-8 -*-
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'zero_push/version'
5
+
6
+ Gem::Specification.new do |gem|
7
+ gem.name = "zero_push"
8
+ gem.version = ZeroPush::VERSION
9
+ gem.authors = ["Stefan Natchev", "Adam Duke"]
10
+ gem.email = ["stefan.natchev@gmail.com", "adam.v.duke@gmail.com"]
11
+ gem.description = %q{A gem to wrap the ZeroPush API}
12
+ gem.summary = %q{A gem for interacting with the ZeroPush API. (http://zeropush.com)}
13
+ gem.homepage = "https://github.com/ZeroPush/zero_push"
14
+
15
+ gem.files = `git ls-files`.split($/)
16
+ gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
17
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
18
+ gem.require_paths = ["lib"]
19
+
20
+ gem.add_dependency "faraday", "0.8.5"
21
+
22
+ gem.add_development_dependency "minitest", "4.6.1"
23
+ gem.add_development_dependency "vcr", "2.4.0"
24
+ end
metadata ADDED
@@ -0,0 +1,110 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: zero_push
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Stefan Natchev
9
+ - Adam Duke
10
+ autorequire:
11
+ bindir: bin
12
+ cert_chain: []
13
+ date: 2013-02-27 00:00:00.000000000 Z
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: faraday
17
+ requirement: !ruby/object:Gem::Requirement
18
+ none: false
19
+ requirements:
20
+ - - '='
21
+ - !ruby/object:Gem::Version
22
+ version: 0.8.5
23
+ type: :runtime
24
+ prerelease: false
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ none: false
27
+ requirements:
28
+ - - '='
29
+ - !ruby/object:Gem::Version
30
+ version: 0.8.5
31
+ - !ruby/object:Gem::Dependency
32
+ name: minitest
33
+ requirement: !ruby/object:Gem::Requirement
34
+ none: false
35
+ requirements:
36
+ - - '='
37
+ - !ruby/object:Gem::Version
38
+ version: 4.6.1
39
+ type: :development
40
+ prerelease: false
41
+ version_requirements: !ruby/object:Gem::Requirement
42
+ none: false
43
+ requirements:
44
+ - - '='
45
+ - !ruby/object:Gem::Version
46
+ version: 4.6.1
47
+ - !ruby/object:Gem::Dependency
48
+ name: vcr
49
+ requirement: !ruby/object:Gem::Requirement
50
+ none: false
51
+ requirements:
52
+ - - '='
53
+ - !ruby/object:Gem::Version
54
+ version: 2.4.0
55
+ type: :development
56
+ prerelease: false
57
+ version_requirements: !ruby/object:Gem::Requirement
58
+ none: false
59
+ requirements:
60
+ - - '='
61
+ - !ruby/object:Gem::Version
62
+ version: 2.4.0
63
+ description: A gem to wrap the ZeroPush API
64
+ email:
65
+ - stefan.natchev@gmail.com
66
+ - adam.v.duke@gmail.com
67
+ executables: []
68
+ extensions: []
69
+ extra_rdoc_files: []
70
+ files:
71
+ - .autotest
72
+ - Gemfile
73
+ - Gemfile.lock
74
+ - LICENSE.txt
75
+ - README.md
76
+ - Rakefile
77
+ - lib/zero_push.rb
78
+ - lib/zero_push/version.rb
79
+ - spec/fixtures/notify.yml
80
+ - spec/spec_helper.rb
81
+ - spec/zero_push_spec.rb
82
+ - zero_push.gemspec
83
+ homepage: https://github.com/ZeroPush/zero_push
84
+ licenses: []
85
+ post_install_message:
86
+ rdoc_options: []
87
+ require_paths:
88
+ - lib
89
+ required_ruby_version: !ruby/object:Gem::Requirement
90
+ none: false
91
+ requirements:
92
+ - - ! '>='
93
+ - !ruby/object:Gem::Version
94
+ version: '0'
95
+ required_rubygems_version: !ruby/object:Gem::Requirement
96
+ none: false
97
+ requirements:
98
+ - - ! '>='
99
+ - !ruby/object:Gem::Version
100
+ version: '0'
101
+ requirements: []
102
+ rubyforge_project:
103
+ rubygems_version: 1.8.24
104
+ signing_key:
105
+ specification_version: 3
106
+ summary: A gem for interacting with the ZeroPush API. (http://zeropush.com)
107
+ test_files:
108
+ - spec/fixtures/notify.yml
109
+ - spec/spec_helper.rb
110
+ - spec/zero_push_spec.rb