phant_rb 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +3 -1
- data/lib/phant_rb/version.rb +1 -1
- data/lib/phant_rb.rb +10 -4
- data/spec/phant_rb_spec.rb +5 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ab778e359b2ffcd7606fd5e74adf112b0ee4a2dd
|
4
|
+
data.tar.gz: 5144a0ff72ce5193d4de5b0b0317d401994421ab
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bdaa25bfecd3d2f816b9b6ec52254b49acd1e5f100f58bbd81034e417dc318d9e829a9b93ac6cbedc7c9a7f99d2ae301625ab2d92737ebcc6d03f0d97ef9a4c9
|
7
|
+
data.tar.gz: 1e0359860df56f08459f1de014e5298c09f77786da895da1e26b00ff0baaaee716a80a9e661824992cdd7bfc86e82880fddffcdf56bd294cf0fc4ac639d76f13
|
data/README.md
CHANGED
@@ -30,6 +30,9 @@ client.log(22.7, 17.8)
|
|
30
30
|
data = client.get()
|
31
31
|
puts data
|
32
32
|
|
33
|
+
# paginate data
|
34
|
+
data = client.get(page: 1)
|
35
|
+
|
33
36
|
# retrieve info about the current state of your stream, http://phant.io/docs/output/stats/
|
34
37
|
stats = client.stats()
|
35
38
|
puts stats.pageCount
|
@@ -53,7 +56,6 @@ client = PhantRb::Client.new "PUBLIC_KEY", %w(humidity temp), {private_key: 'PRI
|
|
53
56
|
|
54
57
|
## TODO
|
55
58
|
* delete a stream
|
56
|
-
* paginate data
|
57
59
|
* use local server in specs
|
58
60
|
|
59
61
|
## Contributing
|
data/lib/phant_rb/version.rb
CHANGED
data/lib/phant_rb.rb
CHANGED
@@ -19,8 +19,8 @@ module PhantRb
|
|
19
19
|
Hashie::Mash.new(JSON.parse(@last_response.body))
|
20
20
|
end
|
21
21
|
|
22
|
-
def get
|
23
|
-
conn = rest_conn 'output'
|
22
|
+
def get(params = {})
|
23
|
+
conn = rest_conn 'output', params
|
24
24
|
response = conn.get
|
25
25
|
JSON.parse response.body
|
26
26
|
end
|
@@ -45,11 +45,17 @@ module PhantRb
|
|
45
45
|
end
|
46
46
|
|
47
47
|
private
|
48
|
-
def rest_conn(type)
|
48
|
+
def rest_conn(type, params = nil)
|
49
49
|
url = case type
|
50
50
|
when 'stats' then URI.join @opts[:base_url], "/output/", "#{@public_key}/stats.json"
|
51
|
-
else
|
51
|
+
else
|
52
|
+
if params.nil?
|
53
|
+
URI.join @opts[:base_url], "/#{type}/", "#{@public_key}.json"
|
54
|
+
else
|
55
|
+
URI.join @opts[:base_url], "/#{type}/", "#{@public_key}.json?" + URI.encode_www_form(params)
|
56
|
+
end
|
52
57
|
end
|
58
|
+
|
53
59
|
RestClient::Resource.new url.to_s,
|
54
60
|
{:headers => {'Phant-Private-Key' => @opts[:private_key]}}
|
55
61
|
end
|
data/spec/phant_rb_spec.rb
CHANGED
@@ -22,6 +22,11 @@ describe PhantRb do
|
|
22
22
|
expect(resp).to be_an(Array)
|
23
23
|
end
|
24
24
|
|
25
|
+
it 'reads paginated data' do
|
26
|
+
resp = @client.get(page: 1)
|
27
|
+
expect(resp).to be_an(Array)
|
28
|
+
end
|
29
|
+
|
25
30
|
it 'returns stats for a stream' do
|
26
31
|
resp = @client.stats
|
27
32
|
expect(resp.has_key?(:remaining)).to be true
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: phant_rb
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Girish S
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-07-
|
11
|
+
date: 2014-07-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rest-client
|