influxer 0.5.3 → 0.5.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: fbd1c48babf418c779aa5544ba81a1afbff04c44
4
- data.tar.gz: 6f5cd76d8bab0ddea496b7baa9ea4d47f4d6cd98
3
+ metadata.gz: 7cec9cd466a9efd8fae51deb50a907b6414f0a91
4
+ data.tar.gz: e5f8a42ee86a15d2a771bdce69c816cbedd5d765
5
5
  SHA512:
6
- metadata.gz: d80b9c5d201d5deec8c1a5fcca21f3d581958d6631c395e861a9a7385984c0cb7e974117917c34a3cb0e3484ccbf6da6f6afd3cc521c9dee835f0d76dd745ffb
7
- data.tar.gz: 14c99afa8346fa1c22b7639e1983e7f2245fd90c74ccd5a9433a05c3856b129e4119084367cc3a2d5a687e6218714ffe7add3949d57965f80982aff893d0e105
6
+ metadata.gz: bae2a0c3b78427f808a13cf53cefb320c2ef6e8ff62ece027962c65b06fc0c4db27716193781cc6b0a6be619884e73eb795d4fd96505ea45d7250fb949b3c3fa
7
+ data.tar.gz: 45d12dc4e1f446a0d33c217adbb0fd37cb9dc0bd917a2698741698397e5d2c34e539c0c20311284670fe9c5239efe77d1c69a2653d9589fa4f980d35e7341eec
data/Changelog.md CHANGED
@@ -1,3 +1,6 @@
1
+ ## 0.5.4
2
+ - Add `set_retention_policy` method
3
+
1
4
  ## 0.5.3
2
5
  - Fix `where.not` with ranges typo
3
6
 
@@ -33,6 +33,7 @@ module Influxer
33
33
 
34
34
  attr_reader :series
35
35
  attr_accessor :tag_names
36
+ attr_accessor :retention_policy
36
37
 
37
38
  def attributes(*attrs)
38
39
  attrs.each do |name|
@@ -61,6 +62,10 @@ module Influxer
61
62
  subclass.tag_names = tag_names.nil? ? [] : tag_names.dup
62
63
  end
63
64
 
65
+ def set_retention_policy(policy_name)
66
+ @retention_policy = policy_name
67
+ end
68
+
64
69
  # rubocop:disable Metrics/MethodLength
65
70
  # rubocop:disable Metrics/AbcSize
66
71
  def set_series(*args)
@@ -102,9 +107,18 @@ module Influxer
102
107
  quoted_series(val.first)
103
108
  end
104
109
  else
105
- '"' + val.to_s.gsub(/\"/) { '\"' } + '"'
110
+ if retention_policy.present?
111
+ [quote(@retention_policy), quote(val)].join('.')
112
+ else
113
+ quote(val)
114
+ end
106
115
  end
107
116
  end
117
+
118
+ def quote(name)
119
+ '"' + name.to_s.gsub(/\"/) { '\"' } + '"'
120
+ end
121
+
108
122
  # rubocop:enable Metrics/MethodLength
109
123
  end
110
124
 
@@ -1,3 +1,3 @@
1
1
  module Influxer # :nodoc:
2
- VERSION = "0.5.3".freeze
2
+ VERSION = "0.5.4".freeze
3
3
  end
@@ -11,6 +11,7 @@ describe Influxer::Metrics, :query do
11
11
 
12
12
  specify { is_expected.to respond_to :attributes }
13
13
  specify { is_expected.to respond_to :set_series }
14
+ specify { is_expected.to respond_to :set_retention_policy }
14
15
  specify { is_expected.to respond_to :series }
15
16
  specify { is_expected.to respond_to :write }
16
17
  specify { is_expected.to respond_to :write! }
@@ -138,6 +139,26 @@ describe Influxer::Metrics, :query do
138
139
  end
139
140
  end
140
141
 
142
+ describe "#quoted_series" do
143
+ context "with retention policy" do
144
+ let(:dummy_with_retention_policy) do
145
+ Class.new(described_class) do
146
+ attributes :user_id, :test_id
147
+ set_series :dummies
148
+ set_retention_policy :week
149
+ end
150
+ end
151
+
152
+ it "sets retention policy" do
153
+ expect(dummy_with_retention_policy.retention_policy).to eq :week
154
+ end
155
+
156
+ it "sets quoted series with retention policy" do
157
+ expect(dummy_with_retention_policy.quoted_series).to eq "\"week\".\"dummies\""
158
+ end
159
+ end
160
+ end
161
+
141
162
  describe ".tags" do
142
163
  let(:dummy1) { Class.new(DummyMetrics) }
143
164
  let!(:dummy2) do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: influxer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.3
4
+ version: 0.5.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Vlad Dem
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-09-27 00:00:00.000000000 Z
11
+ date: 2016-11-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activemodel