influxdb 0.2.0 → 0.2.1
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/lib/influxdb/point_value.rb +26 -15
- data/lib/influxdb/version.rb +1 -1
- data/spec/influxdb/cases/udp_client_spec.rb +1 -1
- data/spec/influxdb/point_value_spec.rb +3 -13
- 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: fd312f5542686ccddcc5913b25f6cd55b6c892ac
|
4
|
+
data.tar.gz: 63bbe7b5008a916da5bd411b5c4a0f0a0f8705a8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2d4c579c9af119065cb5d1d30f1d5caf6c3b1b368864d537231ec63ef0a092d543141af4daf8a2860cbb22ad0a6e326aa647aef19b43db79932502c3091c34d3
|
7
|
+
data.tar.gz: 1857f6d61f6475e0330acc86e2baa5502cb9c2b59f7f18c9d414d375da0c3dc5e332d7fc7b4a662f1ea983599770cefde6fb1fed3021ad763df998e40e7a69a3
|
data/lib/influxdb/point_value.rb
CHANGED
@@ -4,9 +4,9 @@ module InfluxDB
|
|
4
4
|
attr_reader :series, :values, :tags, :timestamp
|
5
5
|
|
6
6
|
def initialize(data)
|
7
|
-
@series = data[:series].gsub(/\s/, '\ ').gsub(',','\,')
|
8
|
-
@values =
|
9
|
-
@tags =
|
7
|
+
@series = data[:series].gsub(/\s/, '\ ').gsub(',', '\,')
|
8
|
+
@values = data_to_string(data[:values], true)
|
9
|
+
@tags = data_to_string(data[:tags])
|
10
10
|
@timestamp = data[:timestamp]
|
11
11
|
end
|
12
12
|
|
@@ -20,19 +20,30 @@ module InfluxDB
|
|
20
20
|
|
21
21
|
private
|
22
22
|
|
23
|
-
def
|
24
|
-
return nil unless
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
end
|
23
|
+
def data_to_string(data, quote_escape = false)
|
24
|
+
return nil unless data && !data.empty?
|
25
|
+
mappings = map(data, quote_escape)
|
26
|
+
mappings.join(',')
|
27
|
+
end
|
28
|
+
|
29
|
+
def map(data, quote_escape)
|
30
|
+
data.map do |k, v|
|
31
|
+
key = escape_key(k)
|
32
|
+
val = v.is_a?(String) ? escape_value(v, quote_escape) : v
|
34
33
|
"#{key}=#{val}"
|
35
|
-
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
def escape_value(value, quote_escape)
|
38
|
+
value.gsub!(/\s/, '\ ')
|
39
|
+
value.gsub!(',', '\,')
|
40
|
+
value.gsub!('"', '\"')
|
41
|
+
value = %("#{value}") if quote_escape
|
42
|
+
value
|
43
|
+
end
|
44
|
+
|
45
|
+
def escape_key(key)
|
46
|
+
key.to_s.gsub(/\s/, '\ ').gsub(',', '\,')
|
36
47
|
end
|
37
48
|
end
|
38
49
|
end
|
data/lib/influxdb/version.rb
CHANGED
@@ -6,7 +6,7 @@ describe InfluxDB::Client do
|
|
6
6
|
specify { expect(client.writer).to be_a(InfluxDB::Writer::UDP) }
|
7
7
|
|
8
8
|
describe "#write" do
|
9
|
-
let(:message) { 'responses,region=
|
9
|
+
let(:message) { 'responses,region=eu value=5' }
|
10
10
|
|
11
11
|
it "sends a UPD packet" do
|
12
12
|
s = UDPSocket.new
|
@@ -17,7 +17,7 @@ describe InfluxDB::PointValue do
|
|
17
17
|
point = InfluxDB::PointValue.new(series: "responses",
|
18
18
|
values: { response_time: 0.34343 },
|
19
19
|
tags: { city: "Twin Peaks" })
|
20
|
-
expect(point.tags.split("=").last).to eq(
|
20
|
+
expect(point.tags.split("=").last).to eq("Twin\\ Peaks")
|
21
21
|
end
|
22
22
|
end
|
23
23
|
|
@@ -37,24 +37,14 @@ describe InfluxDB::PointValue do
|
|
37
37
|
point = InfluxDB::PointValue.new(series: "responses",
|
38
38
|
values: { response_time: 0.34343 },
|
39
39
|
tags: { city: "Twin Peaks," })
|
40
|
-
expect(point.tags.split("=").last).to eq(
|
40
|
+
expect(point.tags.split("=").last).to eq("Twin\\ Peaks\\,")
|
41
41
|
end
|
42
42
|
end
|
43
43
|
|
44
|
-
describe "double quote escaping" do
|
45
|
-
it 'should escape passed values' do
|
46
|
-
point = InfluxDB::PointValue.new(series: "responses",
|
47
|
-
values: { response_time: 0.34343 },
|
48
|
-
tags: { city: "Twin Peaks\"" })
|
49
|
-
expect(point.tags.split("=").last).to eq('"Twin\\ Peaks\\""')
|
50
|
-
end
|
51
|
-
end
|
52
|
-
|
53
|
-
|
54
44
|
describe 'dump' do
|
55
45
|
context "with all possible data passed" do
|
56
46
|
let(:expected_value) do
|
57
|
-
'responses,region=
|
47
|
+
'responses,region=eu,status=200 value=5,threshold=0.54 1436349652'
|
58
48
|
end
|
59
49
|
it 'should have proper form' do
|
60
50
|
point = InfluxDB::PointValue.new(series: "responses",
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: influxdb
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Todd Persen
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-07-
|
11
|
+
date: 2015-07-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: json
|