logplex 0.0.1.pre.3 → 0.0.1.pre.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -16,13 +16,16 @@ module Logplex
16
16
  end
17
17
 
18
18
  def publish(messages, opts={})
19
- messages = Array(messages).dup
20
- messages.map! { |m| Message.new(m, opts.merge(token: @token)) }
21
- messages.each(&:validate)
22
- if messages.inject(true) { |accum, m| m.valid? }
19
+ message_list = messages.dup
20
+ unless messages.is_a? Array
21
+ message_list = [message_list]
22
+ end
23
+ message_list.map! { |m| Message.new(m, opts.merge(token: @token)) }
24
+ message_list.each(&:validate)
25
+ if message_list.inject(true) { |accum, m| m.valid? }
23
26
  begin
24
27
  Timeout::timeout(Logplex.configuration.publish_timeout) do
25
- api_post(messages.map(&:syslog_frame).join(''))
28
+ api_post(message_list.map(&:syslog_frame).join(''))
26
29
  true
27
30
  end
28
31
  rescue *PUBLISH_ERRORS
@@ -1,3 +1,3 @@
1
1
  module Logplex
2
- VERSION = "0.0.1.pre.3"
2
+ VERSION = "0.0.1.pre.4"
3
3
  end
@@ -48,6 +48,16 @@ describe Logplex::Publisher, '#publish' do
48
48
  expect(FakeLogplex.requests_received).to eq(1)
49
49
  end
50
50
 
51
+ it 'does the thing' do
52
+ FakeLogplex.register_token('t.some-token')
53
+
54
+ message = { hi: 'there' }
55
+ publisher = Logplex::Publisher.new('t.some-token', 'https://logplex.example.com')
56
+ publisher.publish(message)
57
+
58
+ expect(FakeLogplex).to have_received_message('hi="there"')
59
+ end
60
+
51
61
  it 'returns true' do
52
62
  FakeLogplex.register_token('t.some-token')
53
63
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: logplex
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1.pre.3
4
+ version: 0.0.1.pre.4
5
5
  prerelease: 6
6
6
  platform: ruby
7
7
  authors:
@@ -13,7 +13,7 @@ date: 2013-05-02 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: valcro
16
- requirement: &70108795420800 !ruby/object:Gem::Requirement
16
+ requirement: &70169923645940 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '0'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *70108795420800
24
+ version_requirements: *70169923645940
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: rest-client
27
- requirement: &70108795449080 !ruby/object:Gem::Requirement
27
+ requirement: &70169923645520 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: '0'
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *70108795449080
35
+ version_requirements: *70169923645520
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: rspec
38
- requirement: &70108795448440 !ruby/object:Gem::Requirement
38
+ requirement: &70169923645040 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ! '>='
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: '0'
44
44
  type: :development
45
45
  prerelease: false
46
- version_requirements: *70108795448440
46
+ version_requirements: *70169923645040
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: sham_rack
49
- requirement: &70108795447760 !ruby/object:Gem::Requirement
49
+ requirement: &70169923644580 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ! '>='
@@ -54,7 +54,7 @@ dependencies:
54
54
  version: '0'
55
55
  type: :development
56
56
  prerelease: false
57
- version_requirements: *70108795447760
57
+ version_requirements: *70169923644580
58
58
  description: Publish and Consume Logplex messages
59
59
  email:
60
60
  - harold.gimenez@gmail.com