circonus_api 0.3.4 → 0.3.6

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,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a3ede201a007dc23e83a498822aaecdd1d088c10
4
- data.tar.gz: 2acd47ca32aa05a890eaa51b73166cd30bc39044
3
+ metadata.gz: f3dd86026f850d751ace448591afc5015309e132
4
+ data.tar.gz: 8133e4309976a4f692c3f490e0c4e97529a29e82
5
5
  SHA512:
6
- metadata.gz: 117a9a496d9d6c056cddfcc42a6a0185a300d2ab7fb729498f30bc493cf024e773b40109ec16d64531456fe22b29261823461f66872e9396b8b3642e047e2ca8
7
- data.tar.gz: 041229edd86a31bacb0f557107bef5ac6940c2246eb645460347d71d4e14191cbe22b4c5123f0efaadf223f79940544be133fcc109b6e981821b1eb8d3d20fad
6
+ metadata.gz: 89acbe5f0168866ef3f8dd72ee827ffb13742e2027644e0a18f28ac8934cb65f0a8c1b502ce6856f50384520fa8fc156f34cfcf453f8cb7208362c2eb0b877e1
7
+ data.tar.gz: ae60b2c88291bec21595335136f8f7099446d7aaeb3b6b93d47d9943c55cfdd44be77e2caa86e7f5ea3bf27af2eebcb9a759c9f26a3e53e43e3b77aafd93e642
@@ -10,13 +10,15 @@ module Circonus
10
10
 
11
11
  module Find
12
12
  def find(id, conditions = {})
13
- data = client.get(URI.escape("#{path}/#{id}"), conditions)
13
+ attributes = Circonus::Actions.time_to_i(conditions)
14
+ data = client.get(URI.escape("#{path}/#{id}"), attributes)
14
15
  new(JSON.parse(data))
15
16
  end
16
17
  end
17
18
 
18
19
  module Create
19
20
  def create(attributes)
21
+ attributes = Circonus::Actions.time_to_i(attributes)
20
22
  data = client.post(URI.escape(path), attributes)
21
23
  new(JSON.parse(data))
22
24
  end
@@ -35,8 +37,12 @@ module Circonus
35
37
  def build_query(conditions)
36
38
  conditions.map do |key, value|
37
39
  if value.is_a?(Array)
38
- value.map { |v| "f_#{key}=#{v}" }.join('&')
40
+ value.map do |v|
41
+ v = v.to_i if v.kind_of?(Time)
42
+ "f_#{key}=#{v}"
43
+ end.join('&')
39
44
  else
45
+ value = value.to_i if value.kind_of?(Time)
40
46
  "f_#{key}=#{value}"
41
47
  end
42
48
  end.join('&')
@@ -58,7 +64,8 @@ module Circonus
58
64
  module Create
59
65
  include Circonus::Actions::InstanceMethods::Save
60
66
  def create
61
- data = client.post(URI.escape(path), filtered_attributes)
67
+ attributes = Circonus::Actions.time_to_i(filtered_attributes)
68
+ data = client.post(URI.escape(path), attributes)
62
69
  self.class.new(JSON.parse(data))
63
70
  end
64
71
  end
@@ -66,7 +73,8 @@ module Circonus
66
73
  module Update
67
74
  include Circonus::Actions::InstanceMethods::Save
68
75
  def update
69
- data = client.put(URI.escape("#{path}/#{id}"), filtered_attributes)
76
+ attributes = Circonus::Actions.time_to_i(filtered_attributes)
77
+ data = client.put(URI.escape("#{path}/#{id}"), attributes)
70
78
  self.class.new(JSON.parse(data))
71
79
  end
72
80
  end
@@ -78,5 +86,9 @@ module Circonus
78
86
  alias_method :delete, :destroy
79
87
  end
80
88
  end
89
+
90
+ def self.time_to_i(attrs)
91
+ attrs.each { |k, v| attrs[k] = v.to_i if v.kind_of?(Time) }
92
+ end
81
93
  end
82
94
  end
@@ -10,7 +10,6 @@ module Circonus
10
10
  class << self
11
11
  def find(check_id, metric_name, conditions)
12
12
  check_conditions!(conditions)
13
- convert_time!(conditions)
14
13
  super("#{check_id}_#{metric_name}", conditions)
15
14
  end
16
15
 
@@ -25,11 +24,6 @@ module Circonus
25
24
  fail "wrong 'type'" unless TYPES.include?(conditions[:type])
26
25
  fail "wrong 'period'" unless PERIODS.include?(conditions[:period])
27
26
  end
28
-
29
- def convert_time!(conditions)
30
- conditions[:start] = conditions[:start].to_i
31
- conditions[:end] = conditions[:end].to_i
32
- end
33
27
  end
34
28
  end
35
29
  end
@@ -1,3 +1,3 @@
1
1
  module Circonus
2
- VERSION = '0.3.4'
2
+ VERSION = '0.3.6'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: circonus_api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.4
4
+ version: 0.3.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Anton Mishchuk
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-12-04 00:00:00.000000000 Z
11
+ date: 2015-12-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rest-client