comboclient 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/lib/comboclient.rb +42 -0
- metadata +64 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 2fc5d2ec953a2b98ee82ddc2ee41ab3ef755f93d
|
4
|
+
data.tar.gz: f20c916621a0876debfc3a9142e9551ef046f4cc
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: e30c6d49a92274df186a7fa3f468200573dac2e7da864536f2fca50256c13cfb48dd439926295887ba300cd429519fe97297939ad3dbf49548fdce6f509a4ca1
|
7
|
+
data.tar.gz: 1ec1ea95b1426b74e02d4fd76206e00b3b26745c9574984950cb7d215636645160cf6b31a3dec7bfcb8b5bf520717c7539b05a190710f25e4ece48e5748c5f8a
|
data/lib/comboclient.rb
ADDED
@@ -0,0 +1,42 @@
|
|
1
|
+
require 'httparty'
|
2
|
+
|
3
|
+
class ComboClient
|
4
|
+
include HTTParty
|
5
|
+
|
6
|
+
def initialize(host, topic)
|
7
|
+
self.class.base_uri "#{host}/topics/#{topic}"
|
8
|
+
end
|
9
|
+
|
10
|
+
def facts
|
11
|
+
self.class.get("/facts")
|
12
|
+
end
|
13
|
+
|
14
|
+
def add(fact)
|
15
|
+
self.class.post("/facts", body: fact.to_json, headers: {'Content-Type' => 'application/json'})
|
16
|
+
end
|
17
|
+
|
18
|
+
def subscribe
|
19
|
+
response = self.class.post("/subscriptions")
|
20
|
+
poll_url = response.parsed_response["retrieval_url"]
|
21
|
+
manager = ComboClientSubscriptionManager.new
|
22
|
+
while manager.is_active? do
|
23
|
+
newdata = self.class.get(poll_url)
|
24
|
+
if newdata.code == 200
|
25
|
+
yield newdata.parsed_response, manager
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
class ComboClientSubscriptionManager
|
32
|
+
def initialize
|
33
|
+
@active = true
|
34
|
+
end
|
35
|
+
def cancel
|
36
|
+
@active = false
|
37
|
+
end
|
38
|
+
|
39
|
+
def is_active?
|
40
|
+
@active
|
41
|
+
end
|
42
|
+
end
|
metadata
ADDED
@@ -0,0 +1,64 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: comboclient
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Jak Spalding
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-10-25 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: httparty
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0.13'
|
20
|
+
- - ">="
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: 0.13.1
|
23
|
+
type: :runtime
|
24
|
+
prerelease: false
|
25
|
+
version_requirements: !ruby/object:Gem::Requirement
|
26
|
+
requirements:
|
27
|
+
- - "~>"
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '0.13'
|
30
|
+
- - ">="
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: 0.13.1
|
33
|
+
description: A simple client for combo microservices
|
34
|
+
email: jak@jak.io
|
35
|
+
executables: []
|
36
|
+
extensions: []
|
37
|
+
extra_rdoc_files: []
|
38
|
+
files:
|
39
|
+
- lib/comboclient.rb
|
40
|
+
homepage: http://rubygems.org/gems/comboclient
|
41
|
+
licenses:
|
42
|
+
- MIT
|
43
|
+
metadata: {}
|
44
|
+
post_install_message:
|
45
|
+
rdoc_options: []
|
46
|
+
require_paths:
|
47
|
+
- lib
|
48
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
49
|
+
requirements:
|
50
|
+
- - ">="
|
51
|
+
- !ruby/object:Gem::Version
|
52
|
+
version: '0'
|
53
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
54
|
+
requirements:
|
55
|
+
- - ">="
|
56
|
+
- !ruby/object:Gem::Version
|
57
|
+
version: '0'
|
58
|
+
requirements: []
|
59
|
+
rubyforge_project:
|
60
|
+
rubygems_version: 2.2.2
|
61
|
+
signing_key:
|
62
|
+
specification_version: 4
|
63
|
+
summary: A simple client for combo microservices
|
64
|
+
test_files: []
|