influxdb 0.0.15 → 0.0.16

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,15 +1,7 @@
1
1
  ---
2
- !binary "U0hBMQ==":
3
- metadata.gz: !binary |-
4
- MTM1OTVmZjljMTBkM2NjMjM3YTg2MTA5Yjk0MDRlZTdhNzNiODU4OQ==
5
- data.tar.gz: !binary |-
6
- ZDJlMGNhZDFhODg2NzEyZmFhODk5MTk4YjIxMzZjMjU3MTIwMzY0OA==
7
- !binary "U0hBNTEy":
8
- metadata.gz: !binary |-
9
- YjlhYmZmMTk0MTEwYzc4MjVmNjJiN2E4MjE0OWI5YjU2ZGFlMDc0YTY3ZDBm
10
- YjJkNWM3OGRiODU5NzMxMTdmYmJiMmZjZTdlOTIyNzA3OWZiZWJmMjNjZDU2
11
- ZDVjYzNmOWUxOWMyNDcyZjZhMjIzMDVmZjY4MTFjNDkwZjIxM2M=
12
- data.tar.gz: !binary |-
13
- Njc1OTllNjhmYmQwYjM3ZGU0NjliZmRhZjJiMGZiZGExZmYzMzc0NWY0Zjcx
14
- Yjc3Y2MyZjRjZDQxOGE5YmE0YmRjZWY3NzBlMmQ0NzJkMWFlZTY4M2I5NGZk
15
- MDkzY2Y1OGRkYjBjNjkxYjljNmUyODUxNWMyNDhkODcxZTdhNjM=
2
+ SHA1:
3
+ metadata.gz: 922d7fb8e14dbf9ed19a5be9309589f17ca56772
4
+ data.tar.gz: e13dbb25d5cc539b31751a8e6fc28f1561c6f5db
5
+ SHA512:
6
+ metadata.gz: 8770fa30c86622dc5da0cc973bb7642ec1840be9fddd68280c810c2be3313fab4803db4067f5c88c271a71def0b27a6208aa16af539e2d62f245d8cc3d15c446
7
+ data.tar.gz: c32e3f4298a9b67af57695db14459eface58346a56ba7da079ad4764d5a7891b572d13bff04dd75afb4efa125d273cb4f2e53dea3671c952e53fdb2e5ec19aee
@@ -18,32 +18,19 @@ module InfluxDB
18
18
  end
19
19
 
20
20
  def load
21
- if json?
21
+ if maybe_json?
22
22
  begin
23
23
  JSON.parse(value)
24
24
  rescue JSON::ParserError => e
25
- raise InfluxDB::JSONParserError, e.message
25
+ value
26
26
  end
27
27
  else
28
28
  value
29
29
  end
30
30
  end
31
31
 
32
- def json?
33
- value =~ /(
34
- # define subtypes and build up the json syntax, BNF-grammar-style
35
- # The {0} is a hack to simply define them as named groups here but not match on them yet
36
- # I added some atomic grouping to prevent catastrophic backtracking on invalid inputs
37
- (?<number> -?(?=[1-9]|0(?!\d))\d+(\.\d+)?([eE][+-]?\d+)?){0}
38
- (?<boolean> true | false | null ){0}
39
- (?<string> " (?>[^"\\\\]* | \\\\ ["\\\\bfnrt\/] | \\\\ u [0-9a-f]{4} )* " ){0}
40
- (?<array> \[ (?> \g<json> (?: , \g<json> )* )? \s* \] ){0}
41
- (?<pair> \s* \g<string> \s* : \g<json> ){0}
42
- (?<object> \{ (?> \g<pair> (?: , \g<pair> )* )? \s* \} ){0}
43
- (?<json> \s* (?> \g<number> | \g<boolean> | \g<string> | \g<array> | \g<object> ) \s* ){0}
44
- )
45
- \A \g<json> \Z
46
- /uix
32
+ def maybe_json?
33
+ value.is_a?(String) && value =~ /\A(\{|\[).*(\}|\])$/
47
34
  end
48
35
  end
49
36
  end
@@ -1,3 +1,3 @@
1
1
  module InfluxDB
2
- VERSION = "0.0.15"
2
+ VERSION = "0.0.16"
3
3
  end
@@ -4,10 +4,24 @@ describe InfluxDB::PointValue do
4
4
 
5
5
  describe 'load' do
6
6
 
7
- it 'should raise error if json parsing fails' do
8
- val = InfluxDB::PointValue.new('{invalid_json')
9
- val.should_receive(:json?).and_return(true)
10
- expect { val.load }.to raise_error(InfluxDB::JSONParserError)
7
+ it 'should parse json as array' do
8
+ val = InfluxDB::PointValue.new('["foo", "bar"]')
9
+ val.load.should == %w(foo bar)
10
+ end
11
+
12
+ it 'should parse json as hash' do
13
+ val = InfluxDB::PointValue.new('{"foo":"bar"}')
14
+ val.load.should == {"foo" => "bar"}
15
+ end
16
+
17
+ it 'should return string value if invalid json array' do
18
+ val = InfluxDB::PointValue.new('[foo,bar]')
19
+ val.load.should == '[foo,bar]'
20
+ end
21
+
22
+ it 'should return string value if invalid json hash' do
23
+ val = InfluxDB::PointValue.new('{foo:"bar"}')
24
+ val.load.should == '{foo:"bar"}'
11
25
  end
12
26
  end
13
27
  end
metadata CHANGED
@@ -1,27 +1,27 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: influxdb
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.15
4
+ version: 0.0.16
5
5
  platform: ruby
6
6
  authors:
7
7
  - Todd Persen
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-02-04 00:00:00.000000000 Z
11
+ date: 2014-02-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: json
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ! '>='
17
+ - - '>='
18
18
  - !ruby/object:Gem::Version
19
19
  version: '0'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - ! '>='
24
+ - - '>='
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0'
27
27
  - !ruby/object:Gem::Dependency
@@ -42,42 +42,42 @@ dependencies:
42
42
  name: rake
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - ! '>='
45
+ - - '>='
46
46
  - !ruby/object:Gem::Version
47
47
  version: '0'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - ! '>='
52
+ - - '>='
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: rspec
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - ! '>='
59
+ - - '>='
60
60
  - !ruby/object:Gem::Version
61
61
  version: '0'
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - ! '>='
66
+ - - '>='
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0'
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: webmock
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
- - - ! '>='
73
+ - - '>='
74
74
  - !ruby/object:Gem::Version
75
75
  version: '0'
76
76
  type: :development
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
- - - ! '>='
80
+ - - '>='
81
81
  - !ruby/object:Gem::Version
82
82
  version: '0'
83
83
  description: This is the official Ruby library for InfluxDB.
@@ -118,17 +118,17 @@ require_paths:
118
118
  - lib
119
119
  required_ruby_version: !ruby/object:Gem::Requirement
120
120
  requirements:
121
- - - ! '>='
121
+ - - '>='
122
122
  - !ruby/object:Gem::Version
123
123
  version: '0'
124
124
  required_rubygems_version: !ruby/object:Gem::Requirement
125
125
  requirements:
126
- - - ! '>='
126
+ - - '>='
127
127
  - !ruby/object:Gem::Version
128
128
  version: '0'
129
129
  requirements: []
130
130
  rubyforge_project:
131
- rubygems_version: 2.0.7
131
+ rubygems_version: 2.1.11
132
132
  signing_key:
133
133
  specification_version: 4
134
134
  summary: Ruby library for InfluxDB.