tengine_event 1.2.1 → 1.2.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- ZGIxMzc0N2I5ZGNjNGMwMmU3ZGM3NjdmNzNkOGFmYTVmZGE1N2E5Ng==
4
+ MTI1YmNlYjNlZWQ4YTJjNTY4M2JlZTRiNzE3MzFkZjNkZmRmYjI5ZQ==
5
5
  data.tar.gz: !binary |-
6
- ODZjNTY2NDQ1OWUwZmI2ZDVhNGQ3MjBkZGQ5OGE5MWI0NjExZjc5ZQ==
6
+ NmJkNmI0MWE4MTVlYjM1YjVjNmI3YzZhMGI1NGI0YzJkMmZjYzViNw==
7
7
  !binary "U0hBNTEy":
8
8
  metadata.gz: !binary |-
9
- NzZkN2QyNzY0NWQ1YjZmZmZjZDFhYmQ2NzBjN2NkNGQzMWUyYWE5NjEyOGVj
10
- NDU4YmE4YTgwNGI1Zjc5OGViYTk0MTJkNTU0MzI4NzEyMDhjZGUyZDAyNDU5
11
- NmJmMGM5Y2NkOTEzMTMxOGYyOTk4MzUyODI0ZTBhNWFkZmY0YjI=
9
+ ZWM1MjczMTgzNmJlZmI4ZDRiNzdiZjc1NWQwYjVhMDNhMGJhNzdhMzAxZWU5
10
+ NTBhMTA4NGZkZTBjMjI5MmNiN2Q5YWFjN2NkZDY5MGYwNTEyY2QzY2I3NTBl
11
+ NmQzZmQ1OWExY2M3MzI0N2Y3YjMzODU4YjI3YzUzYjczNmRlMmQ=
12
12
  data.tar.gz: !binary |-
13
- ZDZiMWZkN2NhMmZjMjRhZTJjNTFiMDBjYjkwNjhkZmFmNDcwOGEzZmUxMWIz
14
- NDZlMDZjNTlhOWRhNjU2YjJiNjVmMTIzNWUwZTAyNmFjNjY0NTRiZmJhYmNi
15
- YjA4NGY3NGUzMDE5Njc5ZDQwZDA3N2VhOTlkMWJlMWY4NmU4ZmQ=
13
+ MDdiMzVhM2JhMzg3Y2Q1ZWFiODU3YmU4ODA3YWNkZjg1MzZkNjFkMGU2NDc1
14
+ MDA0NWU4ODk3ZGFhYmUxNGRiOWJiZjc4ODhhMTI5MjUwYWU3ZmNjOThlNTA5
15
+ Y2QxNGMxNGRjYWEwZTExMzVhOGZmNmYzZWY0NTdlNDQwZDJhMzY=
@@ -1,10 +1,10 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- tengine_event (1.2.1)
4
+ tengine_event (1.2.2)
5
5
  activesupport (>= 3.0.0)
6
6
  amqp (~> 0.9.10)
7
- tengine_support (~> 1.2.1)
7
+ tengine_support (~> 1.2.2)
8
8
  uuid (~> 2.3.4)
9
9
 
10
10
  GEM
@@ -64,7 +64,7 @@ GEM
64
64
  simplecov-html (0.7.1)
65
65
  slop (3.4.4)
66
66
  systemu (2.5.2)
67
- tengine_support (1.2.1)
67
+ tengine_support (1.2.2)
68
68
  activesupport (>= 3.0.0, < 4.0.0)
69
69
  uuid (2.3.7)
70
70
  macaddr (~> 1.0)
@@ -119,14 +119,16 @@ class Tengine::Event
119
119
  # イベントの発生日時。
120
120
  attr_accessor :occurred_at
121
121
  def occurred_at=(v)
122
- case v
123
- when nil then @occurred_at = nil
124
- when Time then @occurred_at = v.utc
125
- when String then
126
- @occurred_at = v.respond_to?(:to_time) ? v.to_time : Time.respond_to?(:parse) ? Time.parse(v) : v
127
- else
128
- raise ArgumentError, "occurred_at must be a Time but was #{v.inspect}" unless v.is_a?(Time)
129
- end
122
+ @occurred_at =
123
+ case v
124
+ when nil then nil
125
+ when Time then v.utc
126
+ when Numeric then Time.at(v).utc
127
+ when String then
128
+ v.respond_to?(:to_time) ? v.to_time : Time.respond_to?(:parse) ? Time.parse(v) : v
129
+ else
130
+ raise ArgumentError, "occurred_at must be a Time but was #{v.inspect}" unless v.is_a?(Time)
131
+ end
130
132
  end
131
133
 
132
134
  # from level to level_key
@@ -322,17 +322,21 @@ describe "Tengine::Event" do
322
322
 
323
323
 
324
324
  describe :parse do
325
+ let(:valid_attrs) do
326
+ {
327
+ :event_type_name => :foo,
328
+ :key => "hoge",
329
+ 'source_name' => "server1",
330
+ :occurred_at => Time.utc(2011,8,11,12,0),
331
+ :level_key => 'error',
332
+ 'sender_name' => "server2",
333
+ :properties => {:bar => "ABC", :baz => 999}
334
+ }
335
+ end
336
+
325
337
  context "can parse valid json object" do
326
338
  subject do
327
- source = Tengine::Event.new(
328
- :event_type_name => :foo,
329
- :key => "hoge",
330
- 'source_name' => "server1",
331
- :occurred_at => Time.utc(2011,8,11,12,0),
332
- :level_key => 'error',
333
- 'sender_name' => "server2",
334
- :properties => {:bar => "ABC", :baz => 999}
335
- )
339
+ source = Tengine::Event.new(valid_attrs)
336
340
  Tengine::Event.parse(source.to_json)
337
341
  end
338
342
  its(:key){ should == "hoge" }
@@ -345,6 +349,22 @@ describe "Tengine::Event" do
345
349
  its(:properties){ should == {'bar' => "ABC", 'baz' => 999}}
346
350
  end
347
351
 
352
+ context "can accept Integer UNIX time" do
353
+ subject do
354
+ source = Tengine::Event.new(valid_attrs.dup.update(:occurred_at => Time.utc(2011,8,11,12,0).to_i))
355
+ Tengine::Event.parse(source.to_json)
356
+ end
357
+ its(:occurred_at){ should == Time.utc(2011,8,11,12,0) }
358
+ end
359
+
360
+ context "can accept Float UNIX time" do
361
+ subject do
362
+ source = Tengine::Event.new(valid_attrs.dup.update(:occurred_at => Time.utc(2011,8,11,12,0).to_f))
363
+ Tengine::Event.parse(source.to_json)
364
+ end
365
+ its(:occurred_at){ should == Time.utc(2011,8,11,12,0) }
366
+ end
367
+
348
368
  context "can parse valid json array" do
349
369
  before do
350
370
  source1 = Tengine::Event.new(
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tengine_event
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.1
4
+ version: 1.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - taigou
@@ -12,7 +12,7 @@ authors:
12
12
  autorequire:
13
13
  bindir: bin
14
14
  cert_chain: []
15
- date: 2013-08-23 00:00:00.000000000 Z
15
+ date: 2013-09-03 00:00:00.000000000 Z
16
16
  dependencies:
17
17
  - !ruby/object:Gem::Dependency
18
18
  name: activesupport
@@ -34,14 +34,14 @@ dependencies:
34
34
  requirements:
35
35
  - - ~>
36
36
  - !ruby/object:Gem::Version
37
- version: 1.2.1
37
+ version: 1.2.2
38
38
  type: :runtime
39
39
  prerelease: false
40
40
  version_requirements: !ruby/object:Gem::Requirement
41
41
  requirements:
42
42
  - - ~>
43
43
  - !ruby/object:Gem::Version
44
- version: 1.2.1
44
+ version: 1.2.2
45
45
  - !ruby/object:Gem::Dependency
46
46
  name: uuid
47
47
  requirement: !ruby/object:Gem::Requirement