databox 0.0.1 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/.ruby-gemset +1 -0
- data/.ruby-version +1 -0
- data/Guardfile +9 -0
- data/README.md +80 -7
- data/databox.gemspec +10 -3
- data/lib/databox.rb +32 -2
- data/lib/databox/client.rb +90 -0
- data/lib/databox/configuration.rb +13 -0
- data/lib/databox/integration.rb +60 -0
- data/lib/databox/version.rb +1 -1
- data/spec/databox/client_spec.rb +96 -0
- data/spec/databox/funnel_spec.rb +30 -0
- data/spec/databox/integration_spec.rb +11 -0
- data/spec/databox/messages_spec.rb +52 -0
- data/spec/databox/pie_spec.rb +32 -0
- data/spec/databox/pipeline_spec.rb +31 -0
- data/spec/requests/funnel_simple.txt +14 -0
- data/spec/requests/invalid_push.txt +19 -0
- data/spec/requests/logs.txt +14 -0
- data/spec/requests/multiple_message.txt +14 -0
- data/spec/requests/pie_simple.txt +14 -0
- data/spec/requests/pipeline_simple.txt +14 -0
- data/spec/requests/simple_message.txt +14 -0
- data/spec/requests/simple_push.txt +14 -0
- data/spec/spec_helper.rb +24 -1
- metadata +83 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b35f81369b4cdc7ba2b9abff91729aecdec96818
|
4
|
+
data.tar.gz: 6da7f16169fc7f16deaefc6796b192bbfacbe789
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 546f51c0c865a0caaf9af5e016d5ab952fdd6a1a52c945f1ddea16d431b68c15497e6d6cd662c9df127f5f6a42a068960411ab2475bc2e38cc4577301af60ed6
|
7
|
+
data.tar.gz: a2c4927156b9da8155de87d9d4e03fbca9042e9640174a02f06ad4283173e2d0ebc238c7a77a9479d90aa52d1fe3c095068538942ee2373adbd8a06ddcd7718e
|
data/.gitignore
CHANGED
data/.ruby-gemset
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
databox
|
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
ruby-2.0.0
|
data/Guardfile
ADDED
@@ -0,0 +1,9 @@
|
|
1
|
+
guard :rspec, all_on_start: false, all_after_pass: false, parallel: false do
|
2
|
+
watch(%r{^spec/.+_spec\.rb$})
|
3
|
+
watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" }
|
4
|
+
watch(%r{^lib/databox/(.+)\.rb$}) { |m| "spec/databox/#{m[1]}_spec.rb" }
|
5
|
+
|
6
|
+
watch('spec/spec_helper.rb') { "spec" }
|
7
|
+
watch('lib/databox.rb') { "spec" }
|
8
|
+
|
9
|
+
end
|
data/README.md
CHANGED
@@ -1,8 +1,8 @@
|
|
1
|
-
# Databox
|
1
|
+
# Databox
|
2
2
|
|
3
|
-
|
3
|
+
[![Gem Version][fury-badge]][fury] [![Build Status][travis-badge]][travis] [![Coverage Status](https://coveralls.io/repos/otobrglez/databox/badge.png)](https://coveralls.io/r/otobrglez/databox)
|
4
4
|
|
5
|
-
|
5
|
+
Ruby Gem for [Databox](http://databox.com/) - Mobile Executive Dashboard.
|
6
6
|
|
7
7
|
- By [Oto Brglez](https://github.com/otobrglez)
|
8
8
|
|
@@ -12,10 +12,6 @@ Add this line to your application's Gemfile:
|
|
12
12
|
|
13
13
|
gem 'databox'
|
14
14
|
|
15
|
-
For most recent version please use:
|
16
|
-
|
17
|
-
gem 'databox', github: 'otobrglez/databox'
|
18
|
-
|
19
15
|
And then execute:
|
20
16
|
|
21
17
|
$ bundle
|
@@ -24,5 +20,82 @@ Or install it yourself as:
|
|
24
20
|
|
25
21
|
$ gem install databox
|
26
22
|
|
23
|
+
## Usage
|
24
|
+
|
25
|
+
You can use Databox::Client directly to insert raw KPIs. This is done by invoking Databox::Client and pushing Hash or Array of Hashes to it.
|
26
|
+
|
27
|
+
```ruby
|
28
|
+
client = Databox.client
|
29
|
+
|
30
|
+
client.push([{
|
31
|
+
key: "name",
|
32
|
+
date: "2014-01-22T12:00:00",
|
33
|
+
value: 1
|
34
|
+
}])
|
35
|
+
|
36
|
+
puts client.logs
|
37
|
+
```
|
38
|
+
|
39
|
+
Databox gem support following widgets
|
40
|
+
|
41
|
+
- [Pipeline](https://developers.databox.com/push/v1/widgets/pipeline)
|
42
|
+
- [Funnel](https://developers.databox.com/push/v1/widgets/funnel)
|
43
|
+
- [Pie](https://developers.databox.com/push/v1/widgets/pie)
|
44
|
+
- [Messages](https://developers.databox.com/push/v1/widgets/messages)
|
45
|
+
|
46
|
+
### Pipeline
|
47
|
+
```ruby
|
48
|
+
pipeline = Databox::Pipeline.new "pipe_visits"
|
49
|
+
pipeline.add "Negotiation", 1_121_603
|
50
|
+
pipeline.add "Proposal", 3_245_927
|
51
|
+
pipeline.add "Solution", 10_726_397
|
52
|
+
pipeline.save
|
53
|
+
```
|
54
|
+
|
55
|
+
### Funnel
|
56
|
+
```ruby
|
57
|
+
funnel = Databox::Funnel.new "funnel_simple"
|
58
|
+
funnel.add "Requests sent", 33_342
|
59
|
+
funnel.add "New Accounts", 25_350
|
60
|
+
funnel.add "Viewed results", 8_930
|
61
|
+
funnel.add "Return Visits", 3_580
|
62
|
+
funnel.save
|
63
|
+
```
|
64
|
+
|
65
|
+
### Pie
|
66
|
+
```ruby
|
67
|
+
pie = Databox::Pie.new "my_pie"
|
68
|
+
pie.add "A", 3_014
|
69
|
+
pie.add "B", 29_496
|
70
|
+
pie.add "C", 9_121
|
71
|
+
pie.add "D", 20_390
|
72
|
+
pie.add "E", 7_423
|
73
|
+
pie.save
|
74
|
+
```
|
75
|
+
|
76
|
+
### Messages
|
77
|
+
|
78
|
+
```ruby
|
79
|
+
messages = Databox::Messages.new "just_messages"
|
80
|
+
messages.add "I was here"
|
81
|
+
messages.add "Second message"
|
82
|
+
messages.save
|
83
|
+
```
|
84
|
+
|
85
|
+
## Versions
|
86
|
+
|
87
|
+
[Databox](https://github.com/otobrglez/databox) is tested on following Ruby versions
|
88
|
+
|
89
|
+
- MRI 1.9.3
|
90
|
+
- MRI 2.0.0
|
91
|
+
|
92
|
+
## Resources
|
93
|
+
|
94
|
+
- [Databox Web App](https://app.databox.com/)
|
95
|
+
- [Databox Developers Portal](https://developers.databox.com/)
|
96
|
+
|
97
|
+
|
98
|
+
[fury-badge]: https://badge.fury.io/rb/databox.png
|
99
|
+
[fury]: http://badge.fury.io/rb/databox
|
27
100
|
[travis-badge]: https://secure.travis-ci.org/otobrglez/databox.png?branch=master
|
28
101
|
[travis]: http://travis-ci.org/otobrglez/databox
|
data/databox.gemspec
CHANGED
@@ -18,14 +18,21 @@ Gem::Specification.new do |spec|
|
|
18
18
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
19
|
spec.require_paths = ["lib"]
|
20
20
|
|
21
|
+
|
22
|
+
spec.add_dependency "httparty"
|
23
|
+
|
24
|
+
#TODO: Use multi_json spec.add_dependency "multi_json"
|
25
|
+
|
21
26
|
spec.add_development_dependency "bundler", "~> 1.3"
|
22
27
|
spec.add_development_dependency "rake"
|
23
28
|
spec.add_development_dependency "rspec"
|
24
29
|
spec.add_development_dependency "shoulda-matchers"
|
25
30
|
spec.add_development_dependency "webmock"
|
26
|
-
spec.add_development_dependency "httparty"
|
27
|
-
spec.add_development_dependency "oj"
|
28
|
-
spec.add_development_dependency "multi_json"
|
29
31
|
spec.add_development_dependency "dotenv"
|
32
|
+
spec.add_development_dependency "guard"
|
33
|
+
spec.add_development_dependency "guard-rspec"
|
34
|
+
spec.add_development_dependency "pry"
|
35
|
+
spec.add_development_dependency "simplecov"
|
36
|
+
spec.add_development_dependency "coveralls"
|
30
37
|
|
31
38
|
end
|
data/lib/databox.rb
CHANGED
@@ -1,3 +1,33 @@
|
|
1
|
-
require "
|
1
|
+
require "httparty"
|
2
2
|
|
3
|
-
module Databox
|
3
|
+
module Databox
|
4
|
+
autoload :VERSION, "databox/version"
|
5
|
+
autoload :Client, "databox/client"
|
6
|
+
autoload :Configuration, "databox/configuration"
|
7
|
+
autoload :Integration, "databox/integration"
|
8
|
+
|
9
|
+
autoload :Pipeline, "databox/integration"
|
10
|
+
autoload :Funnel, "databox/integration"
|
11
|
+
autoload :Pie, "databox/integration"
|
12
|
+
autoload :Messages, "databox/integration"
|
13
|
+
|
14
|
+
|
15
|
+
class << self
|
16
|
+
attr_accessor :configuration
|
17
|
+
|
18
|
+
def configured?
|
19
|
+
return false if configuration.nil?
|
20
|
+
[configuration.token, configuration.key, configuration.url].compact.size == 3
|
21
|
+
end
|
22
|
+
|
23
|
+
def client
|
24
|
+
@client ||= Databox::Client.new
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
def self.configure
|
29
|
+
self.configuration ||= Configuration.new
|
30
|
+
yield configuration if block_given?
|
31
|
+
end
|
32
|
+
|
33
|
+
end
|
@@ -0,0 +1,90 @@
|
|
1
|
+
class Databox::Client
|
2
|
+
include HTTParty
|
3
|
+
format :json
|
4
|
+
|
5
|
+
headers "User-Agent" => "Databox/#{Databox::VERSION} (Ruby)"
|
6
|
+
|
7
|
+
debug_output if ENV["HTTPARTY_DEBUG"] == "1"
|
8
|
+
|
9
|
+
default_timeout 1 if ENV["DATABOX_MODE"] == "test"
|
10
|
+
|
11
|
+
attr_accessor :token
|
12
|
+
def token
|
13
|
+
@token || Databox.configuration.token
|
14
|
+
end
|
15
|
+
|
16
|
+
def key; Databox.configuration.key end
|
17
|
+
def url; Databox.configuration.url end
|
18
|
+
|
19
|
+
def initialize
|
20
|
+
Databox.configure unless Databox.configured?
|
21
|
+
|
22
|
+
self.class.base_uri url
|
23
|
+
self.class.basic_auth key, "password"
|
24
|
+
end
|
25
|
+
|
26
|
+
def push data={}
|
27
|
+
if validate data
|
28
|
+
data = [data] unless data.is_a?(Array)
|
29
|
+
handle self.class.post("/push/custom/#{self.token}", body: { data: data }.to_json)
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
def logs
|
34
|
+
handle self.class.get("/push/custom/#{self.token}/logs")
|
35
|
+
end
|
36
|
+
|
37
|
+
def handle response
|
38
|
+
if response.code > 201
|
39
|
+
raise Databox::ClientError.new(
|
40
|
+
response.code.to_s+" - "+
|
41
|
+
response.parsed_response["error"]["type"]+" - "+
|
42
|
+
response.parsed_response["error"]["message"]
|
43
|
+
)
|
44
|
+
end
|
45
|
+
|
46
|
+
output = response.parsed_response
|
47
|
+
|
48
|
+
if output.is_a?(Hash) and output.keys.include?("response")
|
49
|
+
Databox::Response.new(output["response"])
|
50
|
+
elsif output.is_a?(Array)
|
51
|
+
output.map { |item| Databox::Response.new(item) }
|
52
|
+
else
|
53
|
+
output
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
def validate data
|
58
|
+
return data.map do |dp|
|
59
|
+
validate(dp)
|
60
|
+
end if data.is_a?(Array)
|
61
|
+
|
62
|
+
errors = []
|
63
|
+
errors.push("Data is missing") if data.nil? or data == {}
|
64
|
+
errors.push("Key is required") if data[:key].nil?
|
65
|
+
# errors.push("Value is required") if data[:value].nil?
|
66
|
+
|
67
|
+
errors.push("Date format is invalid") if not(data[:date].nil?) and (Date.iso8601(data[:date]) rescue false) == false
|
68
|
+
errors.push("Key format is invalid") unless data[:key] =~/^[a-zA-Z0-9_\.\@]*$/
|
69
|
+
|
70
|
+
unless errors.empty?
|
71
|
+
invalid_record = Databox::InvalidRecord.new "Payload is invalid"
|
72
|
+
invalid_record.errors = errors
|
73
|
+
raise invalid_record
|
74
|
+
end
|
75
|
+
|
76
|
+
true
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
class Databox::InvalidRecord < StandardError
|
81
|
+
attr_accessor :errors
|
82
|
+
end
|
83
|
+
|
84
|
+
class Databox::ClientError < StandardError; end
|
85
|
+
|
86
|
+
class Databox::Response < OpenStruct
|
87
|
+
def success?
|
88
|
+
self.type == "success"
|
89
|
+
end
|
90
|
+
end
|
@@ -0,0 +1,60 @@
|
|
1
|
+
class Databox::Integration < Databox::Client
|
2
|
+
|
3
|
+
attr_accessor :name, :list, :date
|
4
|
+
|
5
|
+
def initialize name, options={date: nil, id: nil}
|
6
|
+
super()
|
7
|
+
@name = name
|
8
|
+
|
9
|
+
@date = options[:date] unless options[:date].nil?
|
10
|
+
@token = options[:id] unless options[:id].nil?
|
11
|
+
|
12
|
+
@list = []
|
13
|
+
end
|
14
|
+
|
15
|
+
def save
|
16
|
+
if push(to_data).success?
|
17
|
+
@list = []
|
18
|
+
true
|
19
|
+
else
|
20
|
+
false
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
25
|
+
|
26
|
+
#TODO: Add support for icons
|
27
|
+
class Databox::Messages < Databox::Integration
|
28
|
+
|
29
|
+
def add message
|
30
|
+
@list.push message
|
31
|
+
end
|
32
|
+
|
33
|
+
def to_data
|
34
|
+
{ key: "#{name}", value: list }
|
35
|
+
end
|
36
|
+
|
37
|
+
end
|
38
|
+
|
39
|
+
#TODO: Add support for icons
|
40
|
+
#TODO: Add support for changes
|
41
|
+
class Databox::Pipeline < Databox::Integration
|
42
|
+
|
43
|
+
def add message, value
|
44
|
+
@list.push [message, value]
|
45
|
+
end
|
46
|
+
|
47
|
+
def to_data
|
48
|
+
[
|
49
|
+
{ key: "#{name}@labels", value: list.map(&:first) },
|
50
|
+
{ key: "#{name}@values", value: list.map{|e| e[1] } },
|
51
|
+
]
|
52
|
+
end
|
53
|
+
|
54
|
+
end
|
55
|
+
|
56
|
+
#TODO: Add support for icons
|
57
|
+
#TODO: Add support for changes
|
58
|
+
class Databox::Funnel < Databox::Pipeline; end;
|
59
|
+
class Databox::Pie < Databox:: Pipeline; end;
|
60
|
+
|
data/lib/databox/version.rb
CHANGED
@@ -0,0 +1,96 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe Databox::Client do
|
4
|
+
let(:client){ Databox.client }
|
5
|
+
|
6
|
+
context "#push" do
|
7
|
+
|
8
|
+
context "validation" do
|
9
|
+
|
10
|
+
it do
|
11
|
+
expect {
|
12
|
+
client.push()
|
13
|
+
}.to raise_error(Databox::InvalidRecord){ |e|
|
14
|
+
expect(e.errors).to include "Data is missing"
|
15
|
+
}
|
16
|
+
end
|
17
|
+
|
18
|
+
it do
|
19
|
+
expect {
|
20
|
+
client.push({})
|
21
|
+
}.to raise_error(Databox::InvalidRecord)
|
22
|
+
end
|
23
|
+
|
24
|
+
it do
|
25
|
+
expect {
|
26
|
+
client.push({})
|
27
|
+
}.to raise_error(Databox::InvalidRecord){ |e|
|
28
|
+
expect(e.errors).to include "Key is required"
|
29
|
+
# expect(e.errors).to include "Value is required"
|
30
|
+
}
|
31
|
+
end
|
32
|
+
|
33
|
+
it do
|
34
|
+
expect {
|
35
|
+
client.push({key:" w d d", date:"", value:"Oto was here"})
|
36
|
+
}.to raise_error(Databox::InvalidRecord){ |e|
|
37
|
+
expect(e.errors).to include "Date format is invalid"
|
38
|
+
expect(e.errors).to include "Key format is invalid"
|
39
|
+
}
|
40
|
+
end
|
41
|
+
|
42
|
+
it "validates list" do
|
43
|
+
expect {
|
44
|
+
client.push([
|
45
|
+
{date:"2014-01-29"},
|
46
|
+
{key:"what", date:"2014-01-29"}
|
47
|
+
])
|
48
|
+
}.to raise_error(Databox::InvalidRecord){ |e|
|
49
|
+
expect(e.errors).to include "Key is required"
|
50
|
+
}
|
51
|
+
end
|
52
|
+
|
53
|
+
end
|
54
|
+
|
55
|
+
context "valid KPI" do
|
56
|
+
before {
|
57
|
+
stub_request(:post, /push/).to_return { request_from "simple_push" }
|
58
|
+
}
|
59
|
+
|
60
|
+
let(:data){ {
|
61
|
+
key: "databox_visits",
|
62
|
+
date: "2014-01-29",
|
63
|
+
value: 1
|
64
|
+
} }
|
65
|
+
|
66
|
+
let!(:response){ client.push(data) }
|
67
|
+
|
68
|
+
it { expect(response).to be_kind_of(Databox::Response) }
|
69
|
+
it { expect(response).to be_success }
|
70
|
+
|
71
|
+
end
|
72
|
+
|
73
|
+
# #TODO: Validation on server is down.
|
74
|
+
# context "too many requests" do
|
75
|
+
# before {
|
76
|
+
# stub_request(:post, /push/).to_return { request_from "invalid_push" }
|
77
|
+
# Databox::Client.any_instance.stub(:validate).and_return(true)
|
78
|
+
# }
|
79
|
+
# let(:data){{
|
80
|
+
# key:"o t o",
|
81
|
+
# date: "d d d",
|
82
|
+
# value: "-2"
|
83
|
+
# }}
|
84
|
+
# let!(:response){ client.push(data) }
|
85
|
+
# it { expect(response).to be_kind_of(Databox::ClientError) }
|
86
|
+
# end
|
87
|
+
|
88
|
+
end
|
89
|
+
|
90
|
+
context "#logs" do
|
91
|
+
before { stub_request(:get, /logs/).to_return { request_from "logs" } }
|
92
|
+
subject { client.logs }
|
93
|
+
it { expect(subject).to be_kind_of Array }
|
94
|
+
end
|
95
|
+
|
96
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe Databox::Funnel do
|
4
|
+
|
5
|
+
before do
|
6
|
+
Databox.configure do |c|
|
7
|
+
c.token = "218oxlmk3ikkogo0"
|
8
|
+
c.key = "3s70rekrhcmcgkccssckc448kgw04ssk"
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
let(:funnel){ Databox::Funnel.new "little_funnel" }
|
13
|
+
|
14
|
+
context "simple" do
|
15
|
+
before {
|
16
|
+
stub_request(:post, /push/)
|
17
|
+
.to_return { request_from "funnel_simple" }
|
18
|
+
}
|
19
|
+
|
20
|
+
before do
|
21
|
+
funnel.add "Requests sent", 2000
|
22
|
+
funnel.add "New Accounts", 1600
|
23
|
+
funnel.add "Viewed results", 999
|
24
|
+
end
|
25
|
+
|
26
|
+
it { expect(funnel.save).to be_true }
|
27
|
+
|
28
|
+
end
|
29
|
+
|
30
|
+
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe Databox::Integration do
|
4
|
+
|
5
|
+
context "token" do
|
6
|
+
subject { Databox::Integration.new(nil, id: "some fake token") }
|
7
|
+
it { expect(subject.token).to eq "some fake token" }
|
8
|
+
it { expect(Databox::Integration.new(nil).token).not_to be_nil }
|
9
|
+
end
|
10
|
+
|
11
|
+
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe Databox::Messages do
|
4
|
+
|
5
|
+
let(:messages){ Databox::Messages.new("just_messages") }
|
6
|
+
|
7
|
+
context "add messages" do
|
8
|
+
it { expect(messages.name).to eq "just_messages" }
|
9
|
+
|
10
|
+
it {
|
11
|
+
expect { messages.add("Just message") }
|
12
|
+
.to change { messages.list.size }.from(0).to(1)
|
13
|
+
}
|
14
|
+
|
15
|
+
|
16
|
+
context "save" do
|
17
|
+
context "simple" do
|
18
|
+
before {
|
19
|
+
stub_request(:post, /push/)
|
20
|
+
.to_return { request_from "simple_message" }
|
21
|
+
}
|
22
|
+
|
23
|
+
before { messages.add("I was here") }
|
24
|
+
|
25
|
+
it {
|
26
|
+
expect { messages.save }
|
27
|
+
.to change { messages.list.size }.to(0)
|
28
|
+
}
|
29
|
+
end
|
30
|
+
|
31
|
+
context "multiple" do
|
32
|
+
before {
|
33
|
+
stub_request(:post, /push/)
|
34
|
+
.to_return { request_from "multiple_message" }
|
35
|
+
}
|
36
|
+
|
37
|
+
before do
|
38
|
+
messages.add "I was here"
|
39
|
+
messages.add "This is test"
|
40
|
+
end
|
41
|
+
|
42
|
+
it {
|
43
|
+
expect { messages.save }
|
44
|
+
.to change { messages.list.size }.to(0)
|
45
|
+
}
|
46
|
+
end
|
47
|
+
|
48
|
+
end
|
49
|
+
|
50
|
+
end
|
51
|
+
|
52
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe Databox::Pie do
|
4
|
+
|
5
|
+
before do
|
6
|
+
Databox.configure do |c|
|
7
|
+
c.token = "218oxlmk3ikkogo0"
|
8
|
+
c.key = "3s70rekrhcmcgkccssckc448kgw04ssk"
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
let(:pie){ Databox::Pie.new "my_pie" }
|
13
|
+
|
14
|
+
context "simple" do
|
15
|
+
before {
|
16
|
+
stub_request(:post, /push/)
|
17
|
+
.to_return { request_from "pie_simple" }
|
18
|
+
}
|
19
|
+
|
20
|
+
before do
|
21
|
+
pie.add "A", 3_014
|
22
|
+
pie.add "B", 29_496
|
23
|
+
pie.add "C", 9_121
|
24
|
+
pie.add "D", 20_390
|
25
|
+
pie.add "E", 7_423
|
26
|
+
end
|
27
|
+
|
28
|
+
it { expect(pie.save).to be_true }
|
29
|
+
|
30
|
+
end
|
31
|
+
|
32
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe Databox::Pipeline do
|
4
|
+
|
5
|
+
before do
|
6
|
+
Databox.configure do |c|
|
7
|
+
c.token = "218oxlmk3ikkogo0"
|
8
|
+
c.key = "3s70rekrhcmcgkccssckc448kgw04ssk"
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
let(:pipeline){ Databox::Pipeline.new "pipe_visits" }
|
13
|
+
|
14
|
+
context "simple" do
|
15
|
+
before {
|
16
|
+
stub_request(:post, /push/)
|
17
|
+
.to_return { request_from "multiple_message" }
|
18
|
+
}
|
19
|
+
|
20
|
+
before do
|
21
|
+
pipeline.add "Step I.", 2000
|
22
|
+
pipeline.add "Step II.", 1600
|
23
|
+
pipeline.add "Step III.", 999
|
24
|
+
pipeline.add "Step IV.", 100
|
25
|
+
end
|
26
|
+
|
27
|
+
it { expect(pipeline.save).to be_true }
|
28
|
+
|
29
|
+
end
|
30
|
+
|
31
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
HTTP/1.1 200 OK
|
2
|
+
Server: nginx/1.4.4
|
3
|
+
Date: Mon, 03 Feb 2014 11:09:46 GMT
|
4
|
+
Content-Type: application/json
|
5
|
+
Transfer-Encoding: chunked
|
6
|
+
Connection: keep-alive
|
7
|
+
Vary: Accept-Encoding
|
8
|
+
X-Powered-By: PHP/5.4.23
|
9
|
+
Set-Cookie: zep_uid=61qo9ej8cv3d6bm4r1mija7v45; path=/
|
10
|
+
Expires: Thu, 19 Nov 1981 08:52:00 GMT
|
11
|
+
Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0
|
12
|
+
Pragma: no-cache
|
13
|
+
|
14
|
+
{"response":{"type":"success","message":"Items stored: 2"}}
|
@@ -0,0 +1,19 @@
|
|
1
|
+
HTTP/1.1 429 Too Many Requests
|
2
|
+
Server: nginx/1.4.4
|
3
|
+
Date: Wed, 29 Jan 2014 13:56:36 GMT
|
4
|
+
Content-Type: application/json
|
5
|
+
Transfer-Encoding: chunked
|
6
|
+
Connection: keep-alive
|
7
|
+
Vary: Accept-Encoding
|
8
|
+
X-Powered-By: PHP/5.4.23
|
9
|
+
Set-Cookie: zep_uid=2va9ho5bgfshtbqlnhcpig21l3; path=/
|
10
|
+
Expires: Thu, 19 Nov 1981 08:52:00 GMT
|
11
|
+
Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0
|
12
|
+
Pragma: no-cache
|
13
|
+
|
14
|
+
{
|
15
|
+
"response":{
|
16
|
+
"type":"Too Many Requests",
|
17
|
+
"message":"One request every 15 minute is allowed."
|
18
|
+
}
|
19
|
+
}
|
@@ -0,0 +1,14 @@
|
|
1
|
+
HTTP/1.1 200 OK
|
2
|
+
Server: nginx/1.4.4
|
3
|
+
Date: Wed, 29 Jan 2014 14:05:01 GMT
|
4
|
+
Content-Type: application/json
|
5
|
+
Transfer-Encoding: chunked
|
6
|
+
Connection: keep-alive
|
7
|
+
Vary: Accept-Encoding
|
8
|
+
X-Powered-By: PHP/5.4.23
|
9
|
+
Set-Cookie: zep_uid=e4hhgj7i67hgibtdodrtii1167; path=/
|
10
|
+
Expires: Thu, 19 Nov 1981 08:52:00 GMT
|
11
|
+
Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0
|
12
|
+
Pragma: no-cache
|
13
|
+
|
14
|
+
[{"time":"2014-01-29 13:56:36","method":"POST","url":"\/push\/custom\/zqa9z737mxw4ck84","status":200,"ip":"193.77.153.49","request":{"headers":{"content-type":["application\/x-www-form-urlencoded"],"content-length":["54"],"authorization":["Basic OHMwaWdnNDE3MThnb3MwMHd3YzQwZ2tva3djb3drODQ6cGFzc3dvcmQ="],"user-agent":["Databox\/0.0.x"],"host":["app.databox.com"],"accept":["*\/*"],"php-auth-user":["8s0igg41718gos00wwc40gkokwcowk84"],"php-auth-pw":["password"]},"body":"{\"data\":[{\"key\":\"visits_to_databox _hq\", \"value\":22}]}"},"response":{"body":{"response":{"type":"success","message":"Items stored: 1"}}}},{"time":"2014-01-29 13:52:41","method":"POST","url":"\/push\/custom\/zqa9z737mxw4ck84","status":200,"ip":"193.77.153.49","request":{"headers":{"content-type":["application\/x-www-form-urlencoded"],"content-length":["54"],"authorization":["Basic OHMwaWdnNDE3MThnb3MwMHd3YzQwZ2tva3djb3drODQ6cGFzc3dvcmQ="],"user-agent":["Databox\/0.0.x"],"host":["app.databox.com"],"accept":["*\/*"],"php-auth-user":["8s0igg41718gos00wwc40gkokwcowk84"],"php-auth-pw":["password"]},"body":"{\"data\":[{\"key\":\"visits_to_databox _hq\", \"value\":22}]}"},"response":{"body":{"response":{"type":"success","message":"Items stored: 1"}}}},{"time":"2014-01-29 13:50:14","method":"POST","url":"\/push\/custom\/zqa9z737mxw4ck84","status":200,"ip":"193.77.153.49","request":{"headers":{"content-type":["application\/x-www-form-urlencoded"],"content-length":["53"],"authorization":["Basic OHMwaWdnNDE3MThnb3MwMHd3YzQwZ2tva3djb3drODQ6cGFzc3dvcmQ="],"user-agent":["Databox\/0.0.x"],"host":["app.databox.com"],"accept":["*\/*"],"php-auth-user":["8s0igg41718gos00wwc40gkokwcowk84"],"php-auth-pw":["password"]},"body":"{\"data\":[{\"key\":\"visits_to_databox _hq\",\"value\":99}]}"},"response":{"body":{"response":{"type":"success","message":"Items stored: 1"}}}},{"time":"2014-01-29 13:49:40","method":"POST","url":"\/push\/custom\/zqa9z737mxw4ck84","status":200,"ip":"193.77.153.49","request":{"headers":{"content-type":["application\/x-www-form-urlencoded"],"content-length":["52"],"authorization":["Basic OHMwaWdnNDE3MThnb3MwMHd3YzQwZ2tva3djb3drODQ6cGFzc3dvcmQ="],"user-agent":["Databox\/0.0.x"],"host":["app.databox.com"],"accept":["*\/*"],"php-auth-user":["8s0igg41718gos00wwc40gkokwcowk84"],"php-auth-pw":["password"]},"body":"{\"data\":[{\"key\":\"visits_to_databox_hq\",\"value\":99}]}"},"response":{"body":{"response":{"type":"success","message":"Items stored: 1"}}}},{"time":"2014-01-29 13:49:38","method":"POST","url":"\/push\/custom\/zqa9z737mxw4ck84","status":200,"ip":"193.77.153.49","request":{"headers":{"content-type":["application\/x-www-form-urlencoded"],"content-length":["52"],"authorization":["Basic OHMwaWdnNDE3MThnb3MwMHd3YzQwZ2tva3djb3drODQ6cGFzc3dvcmQ="],"user-agent":["Databox\/0.0.x"],"host":["app.databox.com"],"accept":["*\/*"],"php-auth-user":["8s0igg41718gos00wwc40gkokwcowk84"],"php-auth-pw":["password"]},"body":"{\"data\":[{\"key\":\"visits_to_databox_hq\",\"value\":99}]}"},"response":{"body":{"response":{"type":"success","message":"Items stored: 1"}}}},{"time":"2014-01-29 13:48:38","method":"POST","url":"\/push\/custom\/zqa9z737mxw4ck84","status":200,"ip":"193.77.153.49","request":{"headers":{"content-type":["application\/x-www-form-urlencoded"],"content-length":["50"],"authorization":["Basic OHMwaWdnNDE3MThnb3MwMHd3YzQwZ2tva3djb3drODQ6cGFzc3dvcmQ="],"user-agent":["Databox\/0.0.x"],"host":["app.databox.com"],"accept":["*\/*"],"php-auth-user":["8s0igg41718gos00wwc40gkokwcowk84"],"php-auth-pw":["password"]},"body":"{\"data\":[{\"key\":\"+++\",\"date\":\"d d d\",\"value\":99}]}"},"response":{"body":{"response":{"type":"success","message":"Items stored: 1"}}}},{"time":"2014-01-29 13:48:12","method":"POST","url":"\/push\/custom\/zqa9z737mxw4ck84","status":200,"ip":"193.77.153.49","request":{"headers":{"content-type":["application\/x-www-form-urlencoded"],"content-length":["52"],"authorization":["Basic OHMwaWdnNDE3MThnb3MwMHd3YzQwZ2tva3djb3drODQ6cGFzc3dvcmQ="],"user-agent":["Databox\/0.0.x"],"host":["app.databox.com"],"accept":["*\/*"],"php-auth-user":["8s0igg41718gos00wwc40gkokwcowk84"],"php-auth-pw":["password"]},"body":"{\"data\":[{\"key\":\"+++\",\"date\":\"d d d\",\"value\":\"-2\"}]}"},"response":{"body":{"response":{"type":"success","message":"Items stored: 1"}}}},{"time":"2014-01-29 13:44:47","method":"POST","url":"\/push\/custom\/zqa9z737mxw4ck84","status":200,"ip":"193.77.153.49","request":{"headers":{"content-type":["application\/x-www-form-urlencoded"],"content-length":["54"],"authorization":["Basic OHMwaWdnNDE3MThnb3MwMHd3YzQwZ2tva3djb3drODQ6cGFzc3dvcmQ="],"user-agent":["Databox\/0.0.x"],"host":["app.databox.com"],"accept":["*\/*"],"php-auth-user":["8s0igg41718gos00wwc40gkokwcowk84"],"php-auth-pw":["password"]},"body":"{\"data\":[{\"key\":\"o t o\",\"date\":\"d d d\",\"value\":\"-2\"}]}"},"response":{"body":{"response":{"type":"success","message":"Items stored: 1"}}}},{"time":"2014-01-29 13:42:52","method":"POST","url":"\/push\/custom\/zqa9z737mxw4ck84","status":200,"ip":"193.77.153.49","request":{"headers":{"content-type":["application\/x-www-form-urlencoded"],"content-length":["54"],"authorization":["Basic OHMwaWdnNDE3MThnb3MwMHd3YzQwZ2tva3djb3drODQ6cGFzc3dvcmQ="],"user-agent":["Databox\/0.0.x"],"host":["app.databox.com"],"accept":["*\/*"],"php-auth-user":["8s0igg41718gos00wwc40gkokwcowk84"],"php-auth-pw":["password"]},"body":"{\"data\":[{\"key\":\"o t o\",\"date\":\"d d d\",\"value\":\"-2\"}]}"},"response":{"body":{"response":{"type":"success","message":"Items stored: 1"}}}},{"time":"2014-01-29 11:05:39","method":"POST","url":"\/push\/custom\/zqa9z737mxw4ck84","status":200,"ip":"193.77.153.49","request":{"headers":{"content-type":["application\/x-www-form-urlencoded"],"content-length":["65"],"user-agent":["Databox\/0.0.3 (Ruby)"],"authorization":["Basic OHMwaWdnNDE3MThnb3MwMHd3YzQwZ2tva3djb3drODQ6cGFzc3dvcmQ="],"connection":["close"],"host":["app.databox.com"],"php-auth-user":["8s0igg41718gos00wwc40gkokwcowk84"],"php-auth-pw":["password"]},"body":"{\"data\":[{\"key\":\"databox_visits\",\"date\":\"2014-01-29\",\"value\":1}]}"},"response":{"body":{"response":{"type":"success","message":"Items stored: 1"}}}},{"time":"2014-01-29 11:03:53","method":"POST","url":"\/push\/custom\/zqa9z737mxw4ck84","status":200,"ip":"193.77.153.49","request":{"headers":{"content-type":["application\/x-www-form-urlencoded"],"content-length":["65"],"user-agent":["Databox\/0.0.3 (Ruby)"],"authorization":["Basic OHMwaWdnNDE3MThnb3MwMHd3YzQwZ2tva3djb3drODQ6cGFzc3dvcmQ="],"connection":["close"],"host":["app.databox.com"],"php-auth-user":["8s0igg41718gos00wwc40gkokwcowk84"],"php-auth-pw":["password"]},"body":"{\"data\":[{\"key\":\"databox_visits\",\"date\":\"2014-01-29\",\"value\":1}]}"},"response":{"body":{"response":{"type":"success","message":"Items stored: 1"}}}},{"time":"2014-01-29 11:00:24","method":"POST","url":"\/push\/custom\/zqa9z737mxw4ck84","status":200,"ip":"193.77.153.49","request":{"headers":{"content-type":["application\/x-www-form-urlencoded"],"content-length":["65"],"authorization":["Basic OHMwaWdnNDE3MThnb3MwMHd3YzQwZ2tva3djb3drODQ6cGFzc3dvcmQ="],"user-agent":["Databox\/0.0.x"],"host":["app.databox.com"],"accept":["*\/*"],"php-auth-user":["8s0igg41718gos00wwc40gkokwcowk84"],"php-auth-pw":["password"]},"body":"{\"data\":[{\"key\":\"databox_visits\",\"date\":\"2014-01-29\",\"value\":1}]}"},"response":{"body":{"response":{"type":"success","message":"Items stored: 1"}}}},{"time":"2014-01-29 10:53:00","method":"POST","url":"\/push\/custom\/zqa9z737mxw4ck84","status":200,"ip":"193.77.153.49","request":{"headers":{"content-type":["application\/x-www-form-urlencoded"],"content-length":["65"],"authorization":["Basic OHMwaWdnNDE3MThnb3MwMHd3YzQwZ2tva3djb3drODQ6cGFzc3dvcmQ="],"user-agent":["Databox\/0.0.x"],"host":["app.databox.com"],"accept":["*\/*"],"php-auth-user":["8s0igg41718gos00wwc40gkokwcowk84"],"php-auth-pw":["password"]},"body":"{\"data\":[{\"key\":\"databox_visits\",\"date\":\"2014-01-29\",\"value\":1}]}"},"response":{"body":{"response":{"type":"success","message":"Items stored: 1"}}}},{"time":"2014-01-29 10:52:31","method":"POST","url":"\/push\/custom\/zqa9z737mxw4ck84","status":400,"ip":"193.77.153.49","request":{"headers":{"content-type":["application\/x-www-form-urlencoded"],"content-length":["77"],"authorization":["Basic OHMwaWdnNDE3MThnb3MwMHd3YzQwZ2tva3djb3drODQ6cGFzc3dvcmQ="],"user-agent":["Databox\/0.0.x"],"host":["app.databox.com"],"accept":["*\/*"],"php-auth-user":["8s0igg41718gos00wwc40gkokwcowk84"],"php-auth-pw":["password"]},"body":"{\\\"data\\\":[{\\\"key\\\":\\\"databox_visits\\\",\\\"date\\\":\\\"2014-01-29\\\",\\\"value\\\":1}]}"},"response":{"body":{"error":{"type":"Bad Request","message":"Content is not valid JSON string."}}}},{"time":"2014-01-29 10:49:43","method":"POST","url":"\/push\/custom\/zqa9z737mxw4ck84","status":401,"ip":"193.77.153.49","request":{"headers":{"content-type":["application\/x-www-form-urlencoded"],"content-length":["77"],"user-agent":["Databox\/0.0.x"],"host":["app.databox.com"],"accept":["*\/*"]},"body":"{\\\"data\\\":[{\\\"key\\\":\\\"databox_visits\\\",\\\"date\\\":\\\"2014-01-29\\\",\\\"value\\\":1}]}"},"response":{"body":{"error":{"type":"Unauthorized","message":"No valid API token provided."}}}},{"time":"2014-01-29 10:48:47","method":"POST","url":"\/push\/custom\/zqa9z737mxw4ck84","status":401,"ip":"193.77.153.49","request":{"headers":{"content-type":[""],"content-length":[""],"user-agent":["curl\/7.24.0 (x86_64-apple-darwin12.0) libcurl\/7.24.0 OpenSSL\/0.9.8y zlib\/1.2.5"],"host":["app.databox.com"],"accept":["*\/*"]},"body":""},"response":{"body":{"error":{"type":"Unauthorized","message":"No valid API token provided."}}}},{"time":"2014-01-29 10:46:26","method":"POST","url":"\/push\/custom\/zqa9z737mxw4ck84","status":401,"ip":"193.77.153.49","request":{"headers":{"content-type":[""],"content-length":[""],"user-agent":["curl\/7.24.0 (x86_64-apple-darwin12.0) libcurl\/7.24.0 OpenSSL\/0.9.8y zlib\/1.2.5"],"host":["app.databox.com"],"accept":["*\/*"]},"body":""},"response":{"body":{"error":{"type":"Unauthorized","message":"No valid API token provided."}}}},{"time":"2014-01-29 10:40:46","method":"POST","url":"\/push\/custom\/zqa9z737mxw4ck84","status":200,"ip":"193.77.153.49","request":{"headers":{"content-type":["application\/x-www-form-urlencoded"],"content-length":["65"],"user-agent":["Databox\/0.0.3 (Ruby)"],"authorization":["Basic OHMwaWdnNDE3MThnb3MwMHd3YzQwZ2tva3djb3drODQ6cGFzc3dvcmQ="],"connection":["close"],"host":["app.databox.com"],"php-auth-user":["8s0igg41718gos00wwc40gkokwcowk84"],"php-auth-pw":["password"]},"body":"{\"data\":[{\"key\":\"databox_visits\",\"date\":\"2014-01-29\",\"value\":1}]}"},"response":{"body":{"response":{"type":"success","message":"Items stored: 1"}}}},{"time":"2014-01-29 10:39:42","method":"POST","url":"\/push\/custom\/zqa9z737mxw4ck84","status":400,"ip":"193.77.153.49","request":{"headers":{"content-type":["application\/x-www-form-urlencoded"],"content-length":["63"],"user-agent":["Databox\/0.0.3 (Ruby)"],"authorization":["Basic OHMwaWdnNDE3MThnb3MwMHd3YzQwZ2tva3djb3drODQ6cGFzc3dvcmQ="],"connection":["close"],"host":["app.databox.com"],"php-auth-user":["8s0igg41718gos00wwc40gkokwcowk84"],"php-auth-pw":["password"]},"body":"{\"data\":{\"key\":\"databox_visits\",\"date\":\"2014-01-29\",\"value\":1}}"},"response":{"body":{"error":{"type":"Bad Request","message":"Missing required key parameter."}}}},{"time":"2014-01-29 10:39:24","method":"POST","url":"\/push\/custom\/zqa9z737mxw4ck84","status":400,"ip":"193.77.153.49","request":{"headers":{"content-type":["application\/x-www-form-urlencoded"],"content-length":["63"],"user-agent":["Databox\/0.0.3 (Ruby)"],"authorization":["Basic OHMwaWdnNDE3MThnb3MwMHd3YzQwZ2tva3djb3drODQ6cGFzc3dvcmQ="],"connection":["close"],"host":["app.databox.com"],"php-auth-user":["8s0igg41718gos00wwc40gkokwcowk84"],"php-auth-pw":["password"]},"body":"{\"data\":{\"key\":\"databox_visits\",\"date\":\"2014-01-29\",\"value\":1}}"},"response":{"body":{"error":{"type":"Bad Request","message":"Missing required key parameter."}}}},{"time":"2014-01-29 10:22:21","method":"POST","url":"\/push\/custom\/zqa9z737mxw4ck84","status":400,"ip":"193.77.153.49","request":{"headers":{"content-type":["application\/x-www-form-urlencoded"],"content-length":["63"],"user-agent":["Databox\/0.0.3 (Ruby)"],"authorization":["Basic OHMwaWdnNDE3MThnb3MwMHd3YzQwZ2tva3djb3drODQ6cGFzc3dvcmQ="],"connection":["close"],"host":["app.databox.com"],"php-auth-user":["8s0igg41718gos00wwc40gkokwcowk84"],"php-auth-pw":["password"]},"body":"{\"data\":{\"key\":\"databox_visits\",\"date\":\"2014-01-29\",\"value\":1}}"},"response":{"body":{"error":{"type":"Bad Request","message":"Missing required key parameter."}}}},{"time":"2014-01-29 09:56:28","method":"POST","url":"\/push\/custom\/zqa9z737mxw4ck84","status":400,"ip":"193.77.153.49","request":{"headers":{"content-type":["application\/x-www-form-urlencoded"],"content-length":["25"],"user-agent":["Databox\/0.0.3 (Ruby)"],"authorization":["Basic OHMwaWdnNDE3MThnb3MwMHd3YzQwZ2tva3djb3drODQ6cGFzc3dvcmQ="],"connection":["close"],"host":["app.databox.com"],"php-auth-user":["8s0igg41718gos00wwc40gkokwcowk84"],"php-auth-pw":["password"]},"body":"{\"data\":{\"date\":\"d d d\"}}"},"response":{"body":{"error":{"type":"Bad Request","message":"Missing required key parameter."}}}},{"time":"2014-01-29 09:56:22","method":"POST","url":"\/push\/custom\/zqa9z737mxw4ck84","status":400,"ip":"193.77.153.49","request":{"headers":{"content-type":["application\/x-www-form-urlencoded"],"content-length":["11"],"user-agent":["Databox\/0.0.3 (Ruby)"],"authorization":["Basic OHMwaWdnNDE3MThnb3MwMHd3YzQwZ2tva3djb3drODQ6cGFzc3dvcmQ="],"connection":["close"],"host":["app.databox.com"],"php-auth-user":["8s0igg41718gos00wwc40gkokwcowk84"],"php-auth-pw":["password"]},"body":"{\"data\":{}}"},"response":{"body":{"error":{"type":"Bad Request","message":"Data parameter is empty."}}}},{"time":"2014-01-29 09:49:41","method":"POST","url":"\/push\/custom\/zqa9z737mxw4ck84","status":400,"ip":"193.77.153.49","request":{"headers":{"content-type":["application\/x-www-form-urlencoded"],"content-length":["11"],"user-agent":["Databox\/0.0.3 (Ruby)"],"authorization":["Basic OHMwaWdnNDE3MThnb3MwMHd3YzQwZ2tva3djb3drODQ6cGFzc3dvcmQ="],"connection":["close"],"host":["app.databox.com"],"php-auth-user":["8s0igg41718gos00wwc40gkokwcowk84"],"php-auth-pw":["password"]},"body":"{\"data\":{}}"},"response":{"body":{"error":{"type":"Bad Request","message":"Data parameter is empty."}}}},{"time":"2014-01-29 09:38:41","method":"POST","url":"\/push\/custom\/zqa9z737mxw4ck84","status":200,"ip":"193.77.153.49","request":{"headers":{"content-type":["application\/x-www-form-urlencoded"],"content-length":["75"],"user-agent":["Databox\/0.0.3 (Ruby)"],"authorization":["Basic OHMwaWdnNDE3MThnb3MwMHd3YzQwZ2tva3djb3drODQ6cGFzc3dvcmQ="],"connection":["close"],"host":["app.databox.com"],"php-auth-user":["8s0igg41718gos00wwc40gkokwcowk84"],"php-auth-pw":["password"]},"body":"{\"data\":[{\"date\":\"2014-01-26T12:00:00\",\"key\":\"databox_visits\",\"value\":10}]}"},"response":{"body":{"response":{"type":"success","message":"Items stored: 1"}}}},{"time":"2014-01-29 09:37:41","method":"POST","url":"\/push\/custom\/zqa9z737mxw4ck84","status":200,"ip":"193.77.153.49","request":{"headers":{"content-type":["application\/x-www-form-urlencoded"],"content-length":["75"],"user-agent":["Databox\/0.0.3 (Ruby)"],"authorization":["Basic OHMwaWdnNDE3MThnb3MwMHd3YzQwZ2tva3djb3drODQ6cGFzc3dvcmQ="],"connection":["close"],"host":["app.databox.com"],"php-auth-user":["8s0igg41718gos00wwc40gkokwcowk84"],"php-auth-pw":["password"]},"body":"{\"data\":[{\"date\":\"2014-01-26T12:00:00\",\"key\":\"databox_visits\",\"value\":10}]}"},"response":{"body":{"response":{"type":"success","message":"Items stored: 1"}}}},{"time":"2014-01-29 09:37:40","method":"POST","url":"\/push\/custom\/zqa9z737mxw4ck84","status":200,"ip":"193.77.153.49","request":{"headers":{"content-type":["application\/x-www-form-urlencoded"],"content-length":["75"],"user-agent":["Databox\/0.0.3 (Ruby)"],"authorization":["Basic OHMwaWdnNDE3MThnb3MwMHd3YzQwZ2tva3djb3drODQ6cGFzc3dvcmQ="],"connection":["close"],"host":["app.databox.com"],"php-auth-user":["8s0igg41718gos00wwc40gkokwcowk84"],"php-auth-pw":["password"]},"body":"{\"data\":[{\"date\":\"2014-01-26T12:00:00\",\"key\":\"databox_visits\",\"value\":10}]}"},"response":{"body":{"response":{"type":"success","message":"Items stored: 1"}}}},{"time":"2014-01-29 09:35:27","method":"POST","url":"\/push\/custom\/zqa9z737mxw4ck84","status":200,"ip":"193.77.153.49","request":{"headers":{"content-type":["application\/x-www-form-urlencoded"],"content-length":["75"],"user-agent":["Databox\/0.0.3 (Ruby)"],"authorization":["Basic OHMwaWdnNDE3MThnb3MwMHd3YzQwZ2tva3djb3drODQ6cGFzc3dvcmQ="],"connection":["close"],"host":["app.databox.com"],"php-auth-user":["8s0igg41718gos00wwc40gkokwcowk84"],"php-auth-pw":["password"]},"body":"{\"data\":[{\"date\":\"2014-01-26T12:00:00\",\"key\":\"databox_visits\",\"value\":10}]}"},"response":{"body":{"response":{"type":"success","message":"Items stored: 1"}}}},{"time":"2014-01-29 09:05:07","method":"POST","url":"\/push\/custom\/zqa9z737mxw4ck84","status":200,"ip":"193.77.153.49","request":{"headers":{"content-type":["application\/x-www-form-urlencoded"],"content-length":["75"],"user-agent":["Databox\/0.0.3 (Ruby)"],"authorization":["Basic OHMwaWdnNDE3MThnb3MwMHd3YzQwZ2tva3djb3drODQ6cGFzc3dvcmQ="],"connection":["close"],"host":["app.databox.com"],"php-auth-user":["8s0igg41718gos00wwc40gkokwcowk84"],"php-auth-pw":["password"]},"body":"{\"data\":[{\"date\":\"2014-01-26T12:00:00\",\"key\":\"databox_visits\",\"value\":10}]}"},"response":{"body":{"response":{"type":"success","message":"Items stored: 1"}}}},{"time":"2014-01-29 09:04:13","method":"POST","url":"\/push\/custom\/zqa9z737mxw4ck84","status":200,"ip":"193.77.153.49","request":{"headers":{"content-type":["application\/x-www-form-urlencoded"],"content-length":["74"],"user-agent":["Databox\/0.0.3 (Ruby)"],"authorization":["Basic OHMwaWdnNDE3MThnb3MwMHd3YzQwZ2tva3djb3drODQ6cGFzc3dvcmQ="],"connection":["close"],"host":["app.databox.com"],"php-auth-user":["8s0igg41718gos00wwc40gkokwcowk84"],"php-auth-pw":["password"]},"body":"{\"data\":[{\"date\":\"2014-01-25T12:00:00\",\"key\":\"databox_visits\",\"value\":5}]}"},"response":{"body":{"response":{"type":"success","message":"Items stored: 1"}}}},{"time":"2014-01-29 09:03:16","method":"POST","url":"\/push\/custom\/zqa9z737mxw4ck84","status":200,"ip":"193.77.153.49","request":{"headers":{"content-type":["application\/x-www-form-urlencoded"],"content-length":["74"],"user-agent":["Databox\/0.0.3 (Ruby)"],"authorization":["Basic OHMwaWdnNDE3MThnb3MwMHd3YzQwZ2tva3djb3drODQ6cGFzc3dvcmQ="],"connection":["close"],"host":["app.databox.com"],"php-auth-user":["8s0igg41718gos00wwc40gkokwcowk84"],"php-auth-pw":["password"]},"body":"{\"data\":[{\"date\":\"2014-01-22T12:00:00\",\"key\":\"databox_visits\",\"value\":1}]}"},"response":{"body":{"response":{"type":"success","message":"Items stored: 1"}}}},{"time":"2014-01-29 09:02:39","method":"POST","url":"\/push\/custom\/zqa9z737mxw4ck84","status":200,"ip":"193.77.153.49","request":{"headers":{"content-type":["application\/x-www-form-urlencoded"],"content-length":["64"],"user-agent":["Databox\/0.0.3 (Ruby)"],"authorization":["Basic OHMwaWdnNDE3MThnb3MwMHd3YzQwZ2tva3djb3drODQ6cGFzc3dvcmQ="],"connection":["close"],"host":["app.databox.com"],"php-auth-user":["8s0igg41718gos00wwc40gkokwcowk84"],"php-auth-pw":["password"]},"body":"{\"data\":[{\"date\":\"2014-01-22T12:00:00\",\"key\":\"name\",\"value\":1}]}"},"response":{"body":{"response":{"type":"success","message":"Items stored: 1"}}}}]
|
@@ -0,0 +1,14 @@
|
|
1
|
+
HTTP/1.1 200 OK
|
2
|
+
Server: nginx/1.4.4
|
3
|
+
Date: Wed, 29 Jan 2014 16:04:27 GMT
|
4
|
+
Content-Type: application/json
|
5
|
+
Transfer-Encoding: chunked
|
6
|
+
Connection: keep-alive
|
7
|
+
Vary: Accept-Encoding
|
8
|
+
X-Powered-By: PHP/5.4.23
|
9
|
+
Set-Cookie: zep_uid=rjrsvc12d2k7m2n7815jc13q86; path=/
|
10
|
+
Expires: Thu, 19 Nov 1981 08:52:00 GMT
|
11
|
+
Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0
|
12
|
+
Pragma: no-cache
|
13
|
+
|
14
|
+
{"response":{"type":"success","message":"Items stored: 1"}}
|
@@ -0,0 +1,14 @@
|
|
1
|
+
HTTP/1.1 200 OK
|
2
|
+
Server: nginx/1.4.4
|
3
|
+
Date: Mon, 03 Feb 2014 11:29:54 GMT
|
4
|
+
Content-Type: application/json
|
5
|
+
Transfer-Encoding: chunked
|
6
|
+
Connection: keep-alive
|
7
|
+
Vary: Accept-Encoding
|
8
|
+
X-Powered-By: PHP/5.4.23
|
9
|
+
Set-Cookie: zep_uid=iqh4otfgjthiaph9181c7prgk5; path=/
|
10
|
+
Expires: Thu, 19 Nov 1981 08:52:00 GMT
|
11
|
+
Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0
|
12
|
+
Pragma: no-cache
|
13
|
+
|
14
|
+
{"response":{"type":"success","message":"Items stored: 2"}}
|
@@ -0,0 +1,14 @@
|
|
1
|
+
HTTP/1.1 200 OK
|
2
|
+
Server: nginx/1.4.4
|
3
|
+
Date: Mon, 03 Feb 2014 10:50:53 GMT
|
4
|
+
Content-Type: application/json
|
5
|
+
Transfer-Encoding: chunked
|
6
|
+
Connection: keep-alive
|
7
|
+
Vary: Accept-Encoding
|
8
|
+
X-Powered-By: PHP/5.4.23
|
9
|
+
Set-Cookie: zep_uid=pc9fcv4gdo2rhik99rvsho7n53; path=/
|
10
|
+
Expires: Thu, 19 Nov 1981 08:52:00 GMT
|
11
|
+
Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0
|
12
|
+
Pragma: no-cache
|
13
|
+
|
14
|
+
{"response":{"type":"success","message":"Items stored: 2"}}
|
@@ -0,0 +1,14 @@
|
|
1
|
+
HTTP/1.1 200 OK
|
2
|
+
Server: nginx/1.4.4
|
3
|
+
Date: Wed, 29 Jan 2014 15:57:05 GMT
|
4
|
+
Content-Type: application/json
|
5
|
+
Transfer-Encoding: chunked
|
6
|
+
Connection: keep-alive
|
7
|
+
Vary: Accept-Encoding
|
8
|
+
X-Powered-By: PHP/5.4.23
|
9
|
+
Set-Cookie: zep_uid=128b1cjukp7n899ajdjncp5om6; path=/
|
10
|
+
Expires: Thu, 19 Nov 1981 08:52:00 GMT
|
11
|
+
Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0
|
12
|
+
Pragma: no-cache
|
13
|
+
|
14
|
+
{"response":{"type":"success","message":"Items stored: 1"}}
|
@@ -0,0 +1,14 @@
|
|
1
|
+
HTTP/1.1 200 OK
|
2
|
+
Server: nginx/1.4.4
|
3
|
+
Date: Wed, 29 Jan 2014 11:00:24 GMT
|
4
|
+
Content-Type: application/json
|
5
|
+
Transfer-Encoding: chunked
|
6
|
+
Connection: keep-alive
|
7
|
+
Vary: Accept-Encoding
|
8
|
+
X-Powered-By: PHP/5.4.23
|
9
|
+
Set-Cookie: zep_uid=odcb9bv42fsj6nap26bimnjqf0; path=/
|
10
|
+
Expires: Thu, 19 Nov 1981 08:52:00 GMT
|
11
|
+
Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0
|
12
|
+
Pragma: no-cache
|
13
|
+
|
14
|
+
{"response":{"type":"success","message":"Items stored: 1"}}
|
data/spec/spec_helper.rb
CHANGED
@@ -1,12 +1,34 @@
|
|
1
1
|
require "bundler/setup"
|
2
2
|
|
3
|
+
require 'coveralls'
|
4
|
+
Coveralls.wear!
|
5
|
+
|
6
|
+
if ENV['COVERAGE']
|
7
|
+
require 'simplecov'
|
8
|
+
SimpleCov.start
|
9
|
+
end
|
10
|
+
|
11
|
+
require 'pry'
|
3
12
|
require 'dotenv'
|
13
|
+
|
14
|
+
if ENV["NO_WEBMOCK"] != "1"
|
15
|
+
require 'webmock/rspec'
|
16
|
+
WebMock.disable_net_connect!(allow_localhost: false)
|
17
|
+
end
|
18
|
+
|
4
19
|
Dotenv.load
|
5
20
|
|
6
|
-
ENV["DATABOX_MODE"]
|
21
|
+
ENV["DATABOX_MODE"] = "test"
|
22
|
+
ENV["DATABOX_KEY"] ||= "8s0igg41718gos00wwc40gkokwcowk84"
|
23
|
+
ENV["DATABOX_TOKEN"] ||= "zqa9z737mxw4ck84"
|
7
24
|
|
8
25
|
require "databox"
|
9
26
|
|
27
|
+
def request_from file
|
28
|
+
file = "#{file}.txt" unless file =~ /\.txt$/
|
29
|
+
File.new("./spec/requests/#{file}")
|
30
|
+
end
|
31
|
+
|
10
32
|
RSpec.configure do |config|
|
11
33
|
config.fail_fast = ENV['RSPEC_FAIL_FAST'] == "1"
|
12
34
|
config.mock_framework = :rspec # :mocha
|
@@ -17,3 +39,4 @@ RSpec.configure do |config|
|
|
17
39
|
c.syntax = :expect
|
18
40
|
end
|
19
41
|
end
|
42
|
+
|
metadata
CHANGED
@@ -1,15 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: databox
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Oto Brglez
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-02-03 00:00:00.000000000 Z
|
12
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'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - '>='
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
13
27
|
- !ruby/object:Gem::Dependency
|
14
28
|
name: bundler
|
15
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -81,7 +95,7 @@ dependencies:
|
|
81
95
|
- !ruby/object:Gem::Version
|
82
96
|
version: '0'
|
83
97
|
- !ruby/object:Gem::Dependency
|
84
|
-
name:
|
98
|
+
name: dotenv
|
85
99
|
requirement: !ruby/object:Gem::Requirement
|
86
100
|
requirements:
|
87
101
|
- - '>='
|
@@ -95,7 +109,7 @@ dependencies:
|
|
95
109
|
- !ruby/object:Gem::Version
|
96
110
|
version: '0'
|
97
111
|
- !ruby/object:Gem::Dependency
|
98
|
-
name:
|
112
|
+
name: guard
|
99
113
|
requirement: !ruby/object:Gem::Requirement
|
100
114
|
requirements:
|
101
115
|
- - '>='
|
@@ -109,7 +123,7 @@ dependencies:
|
|
109
123
|
- !ruby/object:Gem::Version
|
110
124
|
version: '0'
|
111
125
|
- !ruby/object:Gem::Dependency
|
112
|
-
name:
|
126
|
+
name: guard-rspec
|
113
127
|
requirement: !ruby/object:Gem::Requirement
|
114
128
|
requirements:
|
115
129
|
- - '>='
|
@@ -123,7 +137,35 @@ dependencies:
|
|
123
137
|
- !ruby/object:Gem::Version
|
124
138
|
version: '0'
|
125
139
|
- !ruby/object:Gem::Dependency
|
126
|
-
name:
|
140
|
+
name: pry
|
141
|
+
requirement: !ruby/object:Gem::Requirement
|
142
|
+
requirements:
|
143
|
+
- - '>='
|
144
|
+
- !ruby/object:Gem::Version
|
145
|
+
version: '0'
|
146
|
+
type: :development
|
147
|
+
prerelease: false
|
148
|
+
version_requirements: !ruby/object:Gem::Requirement
|
149
|
+
requirements:
|
150
|
+
- - '>='
|
151
|
+
- !ruby/object:Gem::Version
|
152
|
+
version: '0'
|
153
|
+
- !ruby/object:Gem::Dependency
|
154
|
+
name: simplecov
|
155
|
+
requirement: !ruby/object:Gem::Requirement
|
156
|
+
requirements:
|
157
|
+
- - '>='
|
158
|
+
- !ruby/object:Gem::Version
|
159
|
+
version: '0'
|
160
|
+
type: :development
|
161
|
+
prerelease: false
|
162
|
+
version_requirements: !ruby/object:Gem::Requirement
|
163
|
+
requirements:
|
164
|
+
- - '>='
|
165
|
+
- !ruby/object:Gem::Version
|
166
|
+
version: '0'
|
167
|
+
- !ruby/object:Gem::Dependency
|
168
|
+
name: coveralls
|
127
169
|
requirement: !ruby/object:Gem::Requirement
|
128
170
|
requirements:
|
129
171
|
- - '>='
|
@@ -146,15 +188,35 @@ files:
|
|
146
188
|
- .env
|
147
189
|
- .gitignore
|
148
190
|
- .rspec
|
191
|
+
- .ruby-gemset
|
192
|
+
- .ruby-version
|
149
193
|
- .travis.yml
|
150
194
|
- Gemfile
|
195
|
+
- Guardfile
|
151
196
|
- LICENSE.txt
|
152
197
|
- README.md
|
153
198
|
- Rakefile
|
154
199
|
- databox.gemspec
|
155
200
|
- lib/databox.rb
|
201
|
+
- lib/databox/client.rb
|
202
|
+
- lib/databox/configuration.rb
|
203
|
+
- lib/databox/integration.rb
|
156
204
|
- lib/databox/version.rb
|
205
|
+
- spec/databox/client_spec.rb
|
206
|
+
- spec/databox/funnel_spec.rb
|
207
|
+
- spec/databox/integration_spec.rb
|
208
|
+
- spec/databox/messages_spec.rb
|
209
|
+
- spec/databox/pie_spec.rb
|
210
|
+
- spec/databox/pipeline_spec.rb
|
157
211
|
- spec/databox_spec.rb
|
212
|
+
- spec/requests/funnel_simple.txt
|
213
|
+
- spec/requests/invalid_push.txt
|
214
|
+
- spec/requests/logs.txt
|
215
|
+
- spec/requests/multiple_message.txt
|
216
|
+
- spec/requests/pie_simple.txt
|
217
|
+
- spec/requests/pipeline_simple.txt
|
218
|
+
- spec/requests/simple_message.txt
|
219
|
+
- spec/requests/simple_push.txt
|
158
220
|
- spec/spec_helper.rb
|
159
221
|
homepage: https://github.com/otobrglez/databox
|
160
222
|
licenses:
|
@@ -176,10 +238,24 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
176
238
|
version: '0'
|
177
239
|
requirements: []
|
178
240
|
rubyforge_project:
|
179
|
-
rubygems_version: 2.
|
241
|
+
rubygems_version: 2.1.11
|
180
242
|
signing_key:
|
181
243
|
specification_version: 4
|
182
244
|
summary: API wrapper for Databox
|
183
245
|
test_files:
|
246
|
+
- spec/databox/client_spec.rb
|
247
|
+
- spec/databox/funnel_spec.rb
|
248
|
+
- spec/databox/integration_spec.rb
|
249
|
+
- spec/databox/messages_spec.rb
|
250
|
+
- spec/databox/pie_spec.rb
|
251
|
+
- spec/databox/pipeline_spec.rb
|
184
252
|
- spec/databox_spec.rb
|
253
|
+
- spec/requests/funnel_simple.txt
|
254
|
+
- spec/requests/invalid_push.txt
|
255
|
+
- spec/requests/logs.txt
|
256
|
+
- spec/requests/multiple_message.txt
|
257
|
+
- spec/requests/pie_simple.txt
|
258
|
+
- spec/requests/pipeline_simple.txt
|
259
|
+
- spec/requests/simple_message.txt
|
260
|
+
- spec/requests/simple_push.txt
|
185
261
|
- spec/spec_helper.rb
|