zenoss_client 0.7.0 → 0.8.0

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
  SHA256:
3
- metadata.gz: 0604c70eea29dc67d7083fb3521bf52ff3a1adff59160791b8756b06cca753c4
4
- data.tar.gz: 385c6c6b898364bb88a16832db0846dbaf594ade55859131e6cd08b3c30b6cf6
3
+ metadata.gz: 49a04e901616b01c8d358d4241b504ba162a39f9f12156c44d1f33377b64d037
4
+ data.tar.gz: b83e1398a83a7db53dec85b29f6b5662c7c9264fe02dc8b81fedfb37b7c3fb16
5
5
  SHA512:
6
- metadata.gz: 1102a72533a0ca09895d70a9468af7a5766c90f418e63c8bd9fa6616a7f9a4487fb0342d01b3768e2177b8f934755068de39c044d9dbbe50f6e3128c4683fa74
7
- data.tar.gz: 5f34aa8d4ce4f292640d6460abfea740aa16857d560e8976468e5f416c72eb5f0910788b49ceffd4e8853135bcad3de3d39c6afc29601b63ed0635ef9016c3bf
6
+ metadata.gz: 1204abb1c334da5add5fe006153715580be6f8194ac41a0b715113f34493ccf259a44c00a362719f62ee761057e8e6eb5b694651fbb43ef7dce4d2ef0a83eeb0
7
+ data.tar.gz: b1f1e0d54beda78f3cd28319829f0a2773e7e3dacff8034a99ee2ad8a4f7de24e738b3ad3daf851096dceb0da1f5dd6ca8533fa372ad5cd2f7d36f5a06ed3e44
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.7.0
1
+ 0.8.0
@@ -28,8 +28,20 @@ module Zenoss
28
28
  def initialize(zenoss,zhash)
29
29
  @zenoss = zenoss
30
30
  super zhash
31
- self.firstTime = DateTime.parse(self.firstTime) if self.firstTime
32
- self.lastTime = DateTime.parse(self.lastTime) if self.lastTime
31
+ self.firstTime &&= convert_time(self.firstTime)
32
+ self.lastTime &&= convert_time(self.lastTime)
33
+ end
34
+
35
+ # Converts a string or float to a Time object
36
+ # Zenoss version 4 emits the time format as a string
37
+ # Zenoss version 6 emits the time as a float
38
+ # @return[Time]
39
+ def convert_time(time)
40
+ if time.is_a?(String)
41
+ Time.parse(time)
42
+ else
43
+ Time.at(time)
44
+ end
33
45
  end
34
46
 
35
47
  def detail(history = false)
@@ -137,3 +137,58 @@ describe Zenoss do
137
137
  end
138
138
  end
139
139
  end
140
+
141
+ describe Zenoss::Events::Event do
142
+ it 'initializes an object with times as strings' do
143
+ @zenoss = Zenoss
144
+ firstTime = Time.new(2018, 10, 3, 1, 0, 0)
145
+ lastTime = Time.new(2018, 10, 3, 3, 0, 0)
146
+ zhash = {
147
+ firstTime: firstTime.to_s,
148
+ lastTime: lastTime.to_s
149
+ }
150
+ event = Zenoss::Events::Event.new(@zenoss, zhash)
151
+ event.must_be_kind_of Zenoss::Events::Event
152
+ event.firstTime.must_be_kind_of Time
153
+ event.lastTime.must_be_kind_of Time
154
+ end
155
+
156
+ it 'intializes an object with times as unix time' do
157
+ @zenoss = Zenoss
158
+ firstTime = Time.new(2018, 10, 3, 2, 0, 0)
159
+ lastTime = Time.new(2018, 10, 3, 5, 0, 0)
160
+ zhash = {
161
+ firstTime: firstTime.to_f,
162
+ lastTime: lastTime.to_f
163
+ }
164
+ event = Zenoss::Events::Event.new(@zenoss, zhash)
165
+ event.must_be_kind_of Zenoss::Events::Event
166
+ event.firstTime.class.must_equal Time
167
+ event.firstTime.must_be_kind_of Time
168
+ event.lastTime.must_be_kind_of Time
169
+ end
170
+
171
+ it 'intializes an object with times set to nil' do
172
+ @zenoss = Zenoss
173
+ zhash = {
174
+ firstTime: nil,
175
+ lastTime: nil
176
+ }
177
+ event = Zenoss::Events::Event.new(@zenoss, zhash)
178
+ event.must_be_kind_of Zenoss::Events::Event
179
+ assert_nil event.firstTime
180
+ assert_nil event.lastTime
181
+ end
182
+
183
+ it 'intializes an object with times set to false' do
184
+ @zenoss = Zenoss
185
+ zhash = {
186
+ firstTime: false,
187
+ lastTime: false
188
+ }
189
+ event = Zenoss::Events::Event.new(@zenoss, zhash)
190
+ event.must_be_kind_of Zenoss::Events::Event
191
+ event.firstTime.must_equal false
192
+ event.lastTime.must_equal false
193
+ end
194
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: zenoss_client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.0
4
+ version: 0.8.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dan Wanek
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2018-03-18 00:00:00.000000000 Z
13
+ date: 2018-10-09 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: httpclient