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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 058ca2a3c6debdaa7cf28e55bfde03636d01ccf8
4
- data.tar.gz: cffb5cd41ab81245e59b65d28f0b81a991266827
3
+ metadata.gz: dd4871f2017a8a856cf1d1028bd57d7da66a7a5e
4
+ data.tar.gz: 5392cb04f638eba6d7b105ee2ac8193126411b6d
5
5
  SHA512:
6
- metadata.gz: 83b406a6ed51dc721fd91931622e9ca177265c8e80f0a9606ee58de908723f6a465931bc434298dd393472635024db73f6dd45fb1da3ac01e10f8d817baa6d3e
7
- data.tar.gz: f31f7ce70ac4a33a9ead4285dbb211e6bcaa8e9ea2c418486a6d4c85ccb5e2909971eb2a3159f1a9593496de5d862fb81c4b0e0dbaccd46bd1f79ef815f6aae5
6
+ metadata.gz: a4b4fe37a811ee47d99e876a6f50837de7a225ec28922497df681956e21f44d4248d7482cb232d1f753004a34d3bf8fd22b32f5ab392e4f7b135ac39db4b6106
7
+ data.tar.gz: c568214f243bc7b80102163e7ce6c16e97fcc4ff9358ef8ead85ea934bead6de59d386ed058667815356b82daa0ae74a8785e880ed9b06cf169f4f656232928c
@@ -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 = ENV["DATABOX_PUSH_TOKEN"]
7
+ c.push_token = "vi0jlkpxsy5pdhdtw94el"
8
8
  end
9
9
 
10
10
  client = Databox::Client.new()
11
11
 
12
- 3.times do |t|
13
- client.push(key: "example.ruby", value: t*100, date:(DateTime.now - t).strftime('%Y-%m-%d'))
14
- end
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)
@@ -4,7 +4,8 @@ require 'json'
4
4
  class Databox::Client
5
5
  include HTTParty
6
6
  format :json
7
- headers 'User-Agent' => "Databox/#{Databox::VERSION} (Ruby)"
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['status'] == 'ok'
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['status'] == 'ok'
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/#{n}")
70
+ handle self.class.get("/lastpushes?limit=#{n}")
70
71
  end
71
72
  end
@@ -2,7 +2,7 @@ class Databox::Configuration
2
2
  attr_accessor :push_token, :push_host
3
3
 
4
4
  def initialize
5
- @push_host ||= 'https://push2new.databox.com'
5
+ @push_host ||= 'https://push.databox.com'
6
6
  @push_token ||= ENV['DATABOX_PUSH_TOKEN']
7
7
  end
8
8
  end
@@ -1,3 +1,3 @@
1
1
  module Databox
2
- VERSION = '0.2.2'
2
+ VERSION = '2.0.0'
3
3
  end
@@ -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({'status' => 'ok'})
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
- 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
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.2.2
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: 2016-01-24 00:00:00.000000000 Z
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.5.1
146
+ rubygems_version: 2.6.12
146
147
  signing_key:
147
148
  specification_version: 4
148
149
  summary: API wrapper for Databox