rjmetrics-client 0.2.0 → 0.3.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 +9 -9
- data/lib/rjmetrics-client/client.rb +11 -3
- metadata +4 -5
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
ZjIzNTg3OThkMThkNzQwOWVhMGI2Mjc3NThiZGQ0NDU3NjM1YTJhYw==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
7
|
-
|
6
|
+
MzY2YTg4ZGRhM2FkZDQ1NTg4OWY2Y2I1MTdkYjE0NzIxN2RmYmIzZQ==
|
7
|
+
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
YTI0Nzk1MjcxODdiOGE5ODY1ZGFhYzlkYjQ1M2Q2MDQwMzdmY2ZkMzQzZjdi
|
10
|
+
OGNiNzIxMDJhZTdjMzU3NDEyZGIxZWI2ZGJmMDMzY2RjNjZhZmI4Y2ZkNTIz
|
11
|
+
MmFjNjQ4MjdhNTE3YzgxOTA0YWQ1ZTVjYzQzNTk4NTg0ZjQ5NDA=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
NzZjZTcyY2YzYTRkYTgzMzI1ZmIzOWYwZDA2NTNlMGM0ODE5N2E4NzE4OGFk
|
14
|
+
YzAwNWU4YmZmOWJmNDhmODJlNDNiODAxYmEyOWViZTk3NDcwNDYxNzAxNzky
|
15
|
+
ZDIxZjJlMThhYjcxZWE5YjczYzVmMjdmYTc0YWYwMjI0ZTI5NTk=
|
@@ -1,5 +1,6 @@
|
|
1
1
|
require 'rest_client'
|
2
2
|
require 'json'
|
3
|
+
require 'enumerator'
|
3
4
|
|
4
5
|
class Client
|
5
6
|
|
@@ -7,6 +8,8 @@ class Client
|
|
7
8
|
API_BASE = "https://connect.rjmetrics.com/v2"
|
8
9
|
# RJMetrics Sandbox API url
|
9
10
|
SANDBOX_BASE = "https://sandbox-connect.rjmetrics.com/v2"
|
11
|
+
# Datapoints to push at a time
|
12
|
+
BATCH_SIZE = 100
|
10
13
|
|
11
14
|
# Constructs a Client instance if it receives valid arguments or will raise an ArgumentError.
|
12
15
|
#
|
@@ -20,7 +23,7 @@ class Client
|
|
20
23
|
@timeout_in_seconds = timeout_in_seconds
|
21
24
|
end
|
22
25
|
|
23
|
-
# Checks if the provided Client ID and API Key are valid credentials by
|
26
|
+
# Checks if the provided Client ID and API Key are valid credentials by requesting from the RJMetrics API Sandbox.
|
24
27
|
def authenticated?
|
25
28
|
test_data = {:keys => [:id], :id => 1}
|
26
29
|
begin
|
@@ -31,20 +34,25 @@ class Client
|
|
31
34
|
return true
|
32
35
|
end
|
33
36
|
|
34
|
-
# Sends data to RJMetrics Data Import API.
|
37
|
+
# Sends data to RJMetrics Data Import API in batches of 100.
|
35
38
|
#
|
36
39
|
# @param table_name [String] the table name you wish to store the data
|
37
40
|
# @param data [Hashamp] or Array of Hashmaps of data points that will get sent
|
38
41
|
# @param url [String] Import API url or nil
|
39
42
|
# @return [Array] results of each request to RJMetrics Data Import API
|
40
43
|
def pushData(table_name, data, url = API_BASE)
|
44
|
+
responses = Array.new
|
41
45
|
validatePushDataArgs(table_name, data, url)
|
42
46
|
|
43
47
|
if not data.is_a? Array
|
44
48
|
data = Array.[](data)
|
45
49
|
end
|
46
50
|
|
47
|
-
|
51
|
+
data.each_slice(BATCH_SIZE) {|batch_data|
|
52
|
+
puts "pushing batch of #{batch_data.count} data points"
|
53
|
+
responses << makePushDataAPICall(table_name, batch_data, url)
|
54
|
+
}
|
55
|
+
return responses
|
48
56
|
end
|
49
57
|
|
50
58
|
private
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rjmetrics-client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Owen Jones
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-02
|
11
|
+
date: 2014-04-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rest-client
|
@@ -72,8 +72,8 @@ executables: []
|
|
72
72
|
extensions: []
|
73
73
|
extra_rdoc_files: []
|
74
74
|
files:
|
75
|
-
- lib/rjmetrics_client.rb
|
76
75
|
- lib/rjmetrics-client/client.rb
|
76
|
+
- lib/rjmetrics_client.rb
|
77
77
|
homepage: http://rjmetrics.com
|
78
78
|
licenses:
|
79
79
|
- Apache-2.0
|
@@ -94,9 +94,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
94
94
|
version: '0'
|
95
95
|
requirements: []
|
96
96
|
rubyforge_project:
|
97
|
-
rubygems_version: 2.
|
97
|
+
rubygems_version: 2.2.1
|
98
98
|
signing_key:
|
99
99
|
specification_version: 4
|
100
100
|
summary: RJMetrics Data Import API Client Library
|
101
101
|
test_files: []
|
102
|
-
has_rdoc:
|