uniqush-rb 0.0.1
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 +7 -0
- data/Gemfile +4 -0
- data/Gemfile.lock +45 -0
- data/LICENSE.txt +22 -0
- data/README.md +74 -0
- data/Rakefile +2 -0
- data/lib/uniqush/client.rb +30 -0
- data/lib/uniqush/version.rb +3 -0
- data/lib/uniqush.rb +6 -0
- data/spec/spec_helper.rb +2 -0
- data/spec/uniqush/client_spec.rb +65 -0
- data/uniqush-rb.gemspec +26 -0
- metadata +129 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 6d1a0b6a6482a754562f8d75a406cc551a902020
|
4
|
+
data.tar.gz: ca5754d6b5b442d15035bed6e445799e4543bd9d
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: faeafcacc8407243b86d016d52b5ee7a2e2a037e216adb168192c3e48af9cde48c94ffd6bee3247e2e4773ac8fbf2541e994f6b8313c3f168b50784f1b376e91
|
7
|
+
data.tar.gz: fd06cf89f0c5286af3d19343ccdd07feed3940c3bb838977e12c30dfe46c34ed4976db25ba6509c68141ffdc63096b633b4655084c5d2dfaa3474ac9086c2df8
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,45 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
uniqush-rb (0.0.1)
|
5
|
+
rest-client (~> 1.7.2)
|
6
|
+
|
7
|
+
GEM
|
8
|
+
remote: https://rubygems.org/
|
9
|
+
specs:
|
10
|
+
addressable (2.3.6)
|
11
|
+
crack (0.4.2)
|
12
|
+
safe_yaml (~> 1.0.0)
|
13
|
+
diff-lcs (1.2.5)
|
14
|
+
mime-types (2.4.3)
|
15
|
+
netrc (0.8.0)
|
16
|
+
rake (10.3.2)
|
17
|
+
rest-client (1.7.2)
|
18
|
+
mime-types (>= 1.16, < 3.0)
|
19
|
+
netrc (~> 0.7)
|
20
|
+
rspec (3.1.0)
|
21
|
+
rspec-core (~> 3.1.0)
|
22
|
+
rspec-expectations (~> 3.1.0)
|
23
|
+
rspec-mocks (~> 3.1.0)
|
24
|
+
rspec-core (3.1.7)
|
25
|
+
rspec-support (~> 3.1.0)
|
26
|
+
rspec-expectations (3.1.2)
|
27
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
28
|
+
rspec-support (~> 3.1.0)
|
29
|
+
rspec-mocks (3.1.3)
|
30
|
+
rspec-support (~> 3.1.0)
|
31
|
+
rspec-support (3.1.2)
|
32
|
+
safe_yaml (1.0.4)
|
33
|
+
webmock (1.18.0)
|
34
|
+
addressable (>= 2.3.6)
|
35
|
+
crack (>= 0.3.2)
|
36
|
+
|
37
|
+
PLATFORMS
|
38
|
+
ruby
|
39
|
+
|
40
|
+
DEPENDENCIES
|
41
|
+
bundler (~> 1.7)
|
42
|
+
rake (~> 10.0)
|
43
|
+
rspec (~> 3.1.0)
|
44
|
+
uniqush-rb!
|
45
|
+
webmock (~> 1.18.0)
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2014 Rafael Bandeira
|
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,74 @@
|
|
1
|
+
# uniqush-rb
|
2
|
+
|
3
|
+
A ruby client for [uniqush-push](http://uniqush.org) the push notification server that handles GCM, APNS and others.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
gem 'uniqush-rb'
|
11
|
+
```
|
12
|
+
|
13
|
+
And then execute:
|
14
|
+
|
15
|
+
$ bundle
|
16
|
+
|
17
|
+
Or install it yourself as:
|
18
|
+
|
19
|
+
$ gem install uniqush-rb
|
20
|
+
|
21
|
+
## Usage
|
22
|
+
|
23
|
+
This is a minimalistic client using [rest-client](https://github.com/rest-client/rest-client), it provides a client to handle HTTP requests to a uniqush-push server. Get full documentation on supported params for each request on [uniqush docs](http://uniqush.org/documentation/usage.html).
|
24
|
+
|
25
|
+
```ruby
|
26
|
+
require "uniqush-rb"
|
27
|
+
|
28
|
+
uniqush = Uniqush::Client.new("http://localhost:9898")
|
29
|
+
```
|
30
|
+
|
31
|
+
### Managing services
|
32
|
+
|
33
|
+
```
|
34
|
+
# GET /addpsp
|
35
|
+
uniqush.add_service(service: "gravity_calculator", pushservicetype: "gcm", projectid: "com.grav.calc", apikey: "foobarbaz")
|
36
|
+
|
37
|
+
# GET /rmpsp
|
38
|
+
uniqush.remove_service(service: "gravity_calculator", pushservicetype: "gcm", projectid: "com.grav.calc", apikey: "foobarbaz")
|
39
|
+
```
|
40
|
+
|
41
|
+
### Managing subscriptions
|
42
|
+
|
43
|
+
```
|
44
|
+
# GET /subscribe
|
45
|
+
uniqush.subscribe_device(service: "gravity_calculator", subscriber: "198", pushservicetype: "gcm", regid: "foobarbaz")
|
46
|
+
|
47
|
+
# GET /unsubscribe
|
48
|
+
uniqush.unsubscribe_device(service: "gravity_calculator", subscriber: "198", pushservicetype: "gcm", regid: "foobarbaz")
|
49
|
+
```
|
50
|
+
|
51
|
+
### Pushing
|
52
|
+
|
53
|
+
```
|
54
|
+
# GET /push
|
55
|
+
uniqush.push(service: "gravity_calculator", subscriber: "198", msg: "Gravity is pretty low, float yo!")
|
56
|
+
```
|
57
|
+
|
58
|
+
### Housekeeping
|
59
|
+
|
60
|
+
```
|
61
|
+
# GET /version
|
62
|
+
uniqush.version
|
63
|
+
|
64
|
+
# GET /stop
|
65
|
+
uniqush.stop
|
66
|
+
```
|
67
|
+
|
68
|
+
## Contributing
|
69
|
+
|
70
|
+
1. Fork it ( https://github.com/rafaelbandeira3/uniqush-rb/fork )
|
71
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
72
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
73
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
74
|
+
5. Create a new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
require "rest-client"
|
2
|
+
|
3
|
+
module Uniqush
|
4
|
+
class Client
|
5
|
+
ENDPOINTS = {
|
6
|
+
version: "version",
|
7
|
+
stop: "stop",
|
8
|
+
add_service: "addpsp",
|
9
|
+
remove_service: "rmpsp",
|
10
|
+
subscribe_device: "subscribe",
|
11
|
+
unsubscribe_device: "unsubscribe",
|
12
|
+
push: "push"
|
13
|
+
}.freeze
|
14
|
+
|
15
|
+
|
16
|
+
def initialize(base_url)
|
17
|
+
@client = rest_client(base_url)
|
18
|
+
end
|
19
|
+
|
20
|
+
ENDPOINTS.each do |method, url|
|
21
|
+
define_method method do |params = {}|
|
22
|
+
@client[url].get(params: params)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
def rest_client(url)
|
27
|
+
RestClient::Resource.new(url)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
data/lib/uniqush.rb
ADDED
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,65 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe Uniqush::Client do
|
4
|
+
let(:base_url) { "http://yourinstall.com" }
|
5
|
+
let(:client) { described_class.new(base_url) }
|
6
|
+
let(:a_hash) { {foo: "bar", baz: "bam"} }
|
7
|
+
|
8
|
+
RSpec::Matchers.define(:request) do |method, url|
|
9
|
+
match do |action|
|
10
|
+
@stub = stub_request(method, url)
|
11
|
+
@stub = @stub.with(@with) unless @with.nil?
|
12
|
+
action.call
|
13
|
+
expect(@stub).to have_been_requested
|
14
|
+
end
|
15
|
+
|
16
|
+
chain(:with) do |options|
|
17
|
+
@with = options
|
18
|
+
end
|
19
|
+
|
20
|
+
def supports_block_expectations?
|
21
|
+
true
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
describe "services" do
|
26
|
+
it "adds service" do
|
27
|
+
expect { client.add_service(a_hash) }.
|
28
|
+
to request(:get, "#{base_url}/addpsp").with(query: a_hash)
|
29
|
+
end
|
30
|
+
|
31
|
+
it "removes service" do
|
32
|
+
expect { client.remove_service(a_hash) }.
|
33
|
+
to request(:get, "#{base_url}/rmpsp").with(query: a_hash)
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
describe "subscriptions" do
|
38
|
+
it "subscribes" do
|
39
|
+
expect { client.subscribe_device(a_hash) }.
|
40
|
+
to request(:get, "#{base_url}/subscribe").with(query: a_hash)
|
41
|
+
end
|
42
|
+
|
43
|
+
it "unsubscribes" do
|
44
|
+
expect { client.unsubscribe_device(a_hash) }.
|
45
|
+
to request(:get, "#{base_url}/unsubscribe").with(query: a_hash)
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
describe "pushing" do
|
50
|
+
it "pushes" do
|
51
|
+
expect { client.push(a_hash) }.
|
52
|
+
to request(:get, "#{base_url}/push").with(query: a_hash)
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
describe "housekeeping" do
|
57
|
+
it "gets version" do
|
58
|
+
expect { client.version }. to request(:get, "#{base_url}/version")
|
59
|
+
end
|
60
|
+
|
61
|
+
it "stops" do
|
62
|
+
expect { client.stop }. to request(:get, "#{base_url}/stop")
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
data/uniqush-rb.gemspec
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'uniqush/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "uniqush-rb"
|
8
|
+
spec.version = Uniqush::VERSION
|
9
|
+
spec.authors = ["Rafael Bandeira"]
|
10
|
+
spec.email = ["rafaelbandeira3@gmail.com"]
|
11
|
+
spec.summary = %q{Client for uniqush-push}
|
12
|
+
spec.description = %q{Client for uniqush-push server for push notifications using GCM, APNS and others http://uniqush.org/}
|
13
|
+
spec.homepage = "https://github.com/rafaelbandeira3/uniqush-rb"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0")
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_dependency "rest-client", "~> 1.7.2"
|
22
|
+
spec.add_development_dependency "bundler", "~> 1.7"
|
23
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
24
|
+
spec.add_development_dependency "rspec", "~> 3.1.0"
|
25
|
+
spec.add_development_dependency "webmock", "~> 1.18.0"
|
26
|
+
end
|
metadata
ADDED
@@ -0,0 +1,129 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: uniqush-rb
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Rafael Bandeira
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-11-24 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rest-client
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 1.7.2
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 1.7.2
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: bundler
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.7'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.7'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rake
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '10.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '10.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rspec
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 3.1.0
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: 3.1.0
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: webmock
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: 1.18.0
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: 1.18.0
|
83
|
+
description: Client for uniqush-push server for push notifications using GCM, APNS
|
84
|
+
and others http://uniqush.org/
|
85
|
+
email:
|
86
|
+
- rafaelbandeira3@gmail.com
|
87
|
+
executables: []
|
88
|
+
extensions: []
|
89
|
+
extra_rdoc_files: []
|
90
|
+
files:
|
91
|
+
- Gemfile
|
92
|
+
- Gemfile.lock
|
93
|
+
- LICENSE.txt
|
94
|
+
- README.md
|
95
|
+
- Rakefile
|
96
|
+
- lib/uniqush.rb
|
97
|
+
- lib/uniqush/client.rb
|
98
|
+
- lib/uniqush/version.rb
|
99
|
+
- spec/spec_helper.rb
|
100
|
+
- spec/uniqush/client_spec.rb
|
101
|
+
- uniqush-rb.gemspec
|
102
|
+
homepage: https://github.com/rafaelbandeira3/uniqush-rb
|
103
|
+
licenses:
|
104
|
+
- MIT
|
105
|
+
metadata: {}
|
106
|
+
post_install_message:
|
107
|
+
rdoc_options: []
|
108
|
+
require_paths:
|
109
|
+
- lib
|
110
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
111
|
+
requirements:
|
112
|
+
- - ">="
|
113
|
+
- !ruby/object:Gem::Version
|
114
|
+
version: '0'
|
115
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
116
|
+
requirements:
|
117
|
+
- - ">="
|
118
|
+
- !ruby/object:Gem::Version
|
119
|
+
version: '0'
|
120
|
+
requirements: []
|
121
|
+
rubyforge_project:
|
122
|
+
rubygems_version: 2.2.2
|
123
|
+
signing_key:
|
124
|
+
specification_version: 4
|
125
|
+
summary: Client for uniqush-push
|
126
|
+
test_files:
|
127
|
+
- spec/spec_helper.rb
|
128
|
+
- spec/uniqush/client_spec.rb
|
129
|
+
has_rdoc:
|