databox 0.2.2 → 2.0.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 +4 -4
- data/CHANGELOG.md +17 -0
- data/example.rb +12 -5
- data/lib/databox/client.rb +5 -4
- data/lib/databox/configuration.rb +1 -1
- data/lib/databox/version.rb +1 -1
- data/spec/databox/client_spec.rb +20 -20
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: dd4871f2017a8a856cf1d1028bd57d7da66a7a5e
|
4
|
+
data.tar.gz: 5392cb04f638eba6d7b105ee2ac8193126411b6d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a4b4fe37a811ee47d99e876a6f50837de7a225ec28922497df681956e21f44d4248d7482cb232d1f753004a34d3bf8fd22b32f5ab392e4f7b135ac39db4b6106
|
7
|
+
data.tar.gz: c568214f243bc7b80102163e7ce6c16e97fcc4ff9358ef8ead85ea934bead6de59d386ed058667815356b82daa0ae74a8785e880ed9b06cf169f4f656232928c
|
data/CHANGELOG.md
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
# Change Log
|
2
|
+
Following guidelines of http://keepachangelog.com/
|
3
|
+
|
4
|
+
## [Unreleased]
|
5
|
+
- update to support Databox API version 3
|
6
|
+
|
7
|
+
## [0.2.2] - Jan 24, 2016
|
8
|
+
Databox API has changed a bit in part dedicated for retrieving last pushes. This SDK was updated accordingly.
|
9
|
+
|
10
|
+
## [0.2.1] - Jul 22, 2015
|
11
|
+
Support for additional attributes
|
12
|
+
Test for additional attributes support
|
13
|
+
Updated README.md example
|
14
|
+
|
15
|
+
[Unreleased]: https://github.com/databox/databox-ruby/compare/0.2.2...master
|
16
|
+
[0.2.2]: https://github.com/databox/databox-ruby/compare/0.2.1...0.2.2
|
17
|
+
[0.2.1]: https://github.com/databox/databox-ruby/tree/0.2.1
|
data/example.rb
CHANGED
@@ -4,14 +4,21 @@ require 'bundler/setup'
|
|
4
4
|
require 'databox'
|
5
5
|
|
6
6
|
Databox.configure do |c|
|
7
|
-
c.push_token =
|
7
|
+
c.push_token = "vi0jlkpxsy5pdhdtw94el"
|
8
8
|
end
|
9
9
|
|
10
10
|
client = Databox::Client.new()
|
11
11
|
|
12
|
-
|
13
|
-
|
14
|
-
|
12
|
+
client.insert_all([
|
13
|
+
{key: 'temp.ljx', value: 4.3, attributes: {test: 'rees je'}},
|
14
|
+
{key: 'temp.ljx', value: 1.3, date: '2015-01-01 09:00:00'},
|
15
|
+
])
|
15
16
|
|
16
|
-
pp client.last_push(3)
|
17
17
|
|
18
|
+
#3.times do |t|
|
19
|
+
# client.push(key: "example.ruby", value: t*100, date:(DateTime.now - t).strftime('%Y-%m-%d'))
|
20
|
+
#end
|
21
|
+
|
22
|
+
#client.push(key: "example.ruby.unit", value: 100, unit: "USD")
|
23
|
+
|
24
|
+
pp client.last_push(3)
|
data/lib/databox/client.rb
CHANGED
@@ -4,7 +4,8 @@ require 'json'
|
|
4
4
|
class Databox::Client
|
5
5
|
include HTTParty
|
6
6
|
format :json
|
7
|
-
headers 'User-Agent' => "
|
7
|
+
headers 'User-Agent' => "databox-ruby/#{Databox::VERSION}"
|
8
|
+
headers 'Accept' => "application/vnd.databox.v#{Databox::VERSION.split('.')[0]}+json"
|
8
9
|
debug_output if [1, "1"].include?(ENV["HTTPARTY_DEBUG"])
|
9
10
|
default_timeout 1 if ENV["DATABOX_MODE"] == "test"
|
10
11
|
|
@@ -57,15 +58,15 @@ class Databox::Client
|
|
57
58
|
|
58
59
|
def push(kpi={})
|
59
60
|
self.last_push_content = raw_push('/', [process_kpi(kpi)])
|
60
|
-
self.last_push_content
|
61
|
+
self.last_push_content.key?('id')
|
61
62
|
end
|
62
63
|
|
63
64
|
def insert_all(rows=[])
|
64
65
|
self.last_push_content = raw_push('/', rows.map {|r| process_kpi(r) })
|
65
|
-
self.last_push_content
|
66
|
+
self.last_push_content.key?('id')
|
66
67
|
end
|
67
68
|
|
68
69
|
def last_push(n=1)
|
69
|
-
handle self.class.get("/lastpushes
|
70
|
+
handle self.class.get("/lastpushes?limit=#{n}")
|
70
71
|
end
|
71
72
|
end
|
data/lib/databox/version.rb
CHANGED
data/spec/databox/client_spec.rb
CHANGED
@@ -8,7 +8,7 @@ describe Databox::Client do
|
|
8
8
|
end
|
9
9
|
|
10
10
|
allow_any_instance_of(Databox::Client).to receive(:raw_push)\
|
11
|
-
.and_return({'
|
11
|
+
.and_return({'id' => '147251'})
|
12
12
|
end
|
13
13
|
|
14
14
|
let!(:client) { Databox::Client.new }
|
@@ -20,24 +20,24 @@ describe Databox::Client do
|
|
20
20
|
it { expect(client.push(key: 'sales.total', value: 2000)).to eq true }
|
21
21
|
end
|
22
22
|
|
23
|
-
context 'push w/ attributes' do
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
end
|
23
|
+
# context 'push w/ attributes' do
|
24
|
+
# it {
|
25
|
+
# payload = {
|
26
|
+
# key: 'test',
|
27
|
+
# value: 200,
|
28
|
+
# attributes: {
|
29
|
+
# 'me': 'Oto'
|
30
|
+
# }
|
31
|
+
# }
|
32
|
+
#
|
33
|
+
# expect(client).to receive(:raw_push)
|
34
|
+
# .with('/', [
|
35
|
+
# {"$test" => 200, :me => "Oto"}
|
36
|
+
# ])
|
37
|
+
# .once.and_call_original
|
38
|
+
# expect(client.push(payload)).to eq true
|
39
|
+
# }
|
40
|
+
# end
|
41
41
|
|
42
42
|
context 'insert_all' do
|
43
43
|
it { expect { client.insert_all([
|
@@ -50,4 +50,4 @@ describe Databox::Client do
|
|
50
50
|
{key: 'temp.ljx', value: 1.3, date: '2015-01-01 09:00:00'},
|
51
51
|
])).to eq true }
|
52
52
|
end
|
53
|
-
end
|
53
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: databox
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 2.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Oto Brglez
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2017-06-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: httparty
|
@@ -108,6 +108,7 @@ files:
|
|
108
108
|
- ".ruby-gemset"
|
109
109
|
- ".ruby-version"
|
110
110
|
- ".travis.yml"
|
111
|
+
- CHANGELOG.md
|
111
112
|
- Gemfile
|
112
113
|
- Guardfile
|
113
114
|
- LICENSE.txt
|
@@ -142,7 +143,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
142
143
|
version: '0'
|
143
144
|
requirements: []
|
144
145
|
rubyforge_project:
|
145
|
-
rubygems_version: 2.
|
146
|
+
rubygems_version: 2.6.12
|
146
147
|
signing_key:
|
147
148
|
specification_version: 4
|
148
149
|
summary: API wrapper for Databox
|