logplex 0.0.1 → 0.0.5

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
- SHA1:
3
- metadata.gz: dc2d2954418c3b93be55493748e2561c4b7b4b27
4
- data.tar.gz: c5fb17e4a46500eb26779b3089b7aeb357e60498
2
+ SHA256:
3
+ metadata.gz: ffe48a52e4f1d01b38a9fec2cfd6cba64b4e735c926616d36b3a87b2ec6a75b1
4
+ data.tar.gz: c01b8e0627ae7410b4148ffcdc3ead41983df81fc161fdd1692456cd55573310
5
5
  SHA512:
6
- metadata.gz: 35fd6b2c2f5e56e6ed6d2036ae5add5e487f25418a552fdce091c02d2a6ecc5e6693a43a44cfc3dc2a24f4eb75728d3cea58865750a2a141f24e711c338a1f18
7
- data.tar.gz: dd7b526faa13b42dd98261bdc7d3bd64c9389e734a7fcdfc106740b03ecaba58f896665e901d003276cdbfc116dddae24537c6cb26616b1493d985414f050422
6
+ metadata.gz: 79e429707324d1c2e057dbc3a1d9880e9449e7f8088058953568cffa2e14b4cc4204c292e07a015d6c84099b391075a6236bf521b9a931c2b0d283b8a106f79a
7
+ data.tar.gz: 247a921c9096a10eda1df39b950eab655bb795438da89b650548f113d46ae206cd0bfe9786a4e07f4b31d4c65c1c5f012e12edd023b04306f3814fb613adb040
@@ -19,12 +19,12 @@ module Logplex
19
19
  unless messages.is_a? Array
20
20
  message_list = [message_list]
21
21
  end
22
- message_list.map! { |m| Message.new(m, opts.merge(app_name: @token)) }
22
+ message_list.map! { |m| Message.new(m, { app_name: @token }.merge(opts)) }
23
23
  message_list.each(&:validate)
24
24
  if message_list.inject(true) { |accum, m| m.valid? }
25
25
  begin
26
26
  Timeout.timeout(Logplex.configuration.publish_timeout) do
27
- api_post(message_list.map(&:syslog_frame).join(''))
27
+ api_post(message_list.map(&:syslog_frame).join(''), message_list.length)
28
28
  true
29
29
  end
30
30
  rescue *PUBLISH_ERRORS
@@ -35,10 +35,11 @@ module Logplex
35
35
 
36
36
  private
37
37
 
38
- def api_post(message)
38
+ def api_post(message, number_messages)
39
39
  Excon.post(@logplex_url, body: message, headers: {
40
40
  "Content-Type" => 'application/logplex-1',
41
41
  "Content-Length" => message.length,
42
+ "Logplex-Msg-Count" => number_messages
42
43
  }, expects: [200, 204])
43
44
  end
44
45
  end
@@ -1,3 +1,3 @@
1
1
  module Logplex
2
- VERSION = "0.0.1".freeze
2
+ VERSION = "0.0.5".freeze
3
3
  end
data/logplex.gemspec CHANGED
@@ -6,11 +6,11 @@ require 'logplex/version'
6
6
  Gem::Specification.new do |gem|
7
7
  gem.name = "logplex"
8
8
  gem.version = Logplex::VERSION
9
- gem.authors = ["Harold Giménez"]
9
+ gem.authors = ["Harold Giménez", "Heroku"]
10
10
  gem.email = ["harold.gimenez@gmail.com"]
11
11
  gem.description = "Publish and Consume Logplex messages"
12
12
  gem.summary = "Publish and Consume Logplex messages"
13
- gem.homepage = "https://practiceovertheory.com"
13
+ gem.homepage = "https://github.com/heroku/logplex-gem"
14
14
 
15
15
  gem.files = `git ls-files`.split($/)
16
16
  gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
@@ -1,5 +1,6 @@
1
1
  require 'spec_helper'
2
2
  require 'logplex/publisher'
3
+ require 'logplex/message'
3
4
 
4
5
  describe Logplex::Publisher do
5
6
  describe '#publish' do
@@ -28,13 +29,24 @@ describe Logplex::Publisher do
28
29
  end
29
30
 
30
31
  it 'sends many messages in one request when passed an array' do
31
- Excon.stub({ method: :post, password: "t.some-token", body: /here is another/ }, status: 204)
32
- expect(Excon).to receive(:post).once
32
+ Excon.stub({ method: :post, password: "t.some-token", body: /message for you.+here is another.+some final thoughts/ }, status: 204)
33
33
  messages = ['I have a message for you', 'here is another', 'some final thoughts']
34
+ publisher = Logplex::Publisher.new('https://token:t.some-token@logplex.example.com')
35
+ publisher.publish(messages)
36
+ end
34
37
 
38
+ it 'uses the token if app_name is not given' do
39
+ Excon.stub({ method: :post, password: "t.some-token", body: /t.some-token/ }, status: 204)
40
+ message = 'I have a message for you'
35
41
  publisher = Logplex::Publisher.new('https://token:t.some-token@logplex.example.com')
42
+ publisher.publish(message)
43
+ end
36
44
 
37
- publisher.publish(messages)
45
+ it 'uses the given app_name' do
46
+ Excon.stub({ method: :post, password: "t.some-token", body: /foo/ }, status: 204)
47
+ message = 'I have a message for you'
48
+ publisher = Logplex::Publisher.new('https://token:t.some-token@logplex.example.com')
49
+ publisher.publish(message, app_name: 'foo')
38
50
  end
39
51
 
40
52
  it 'does the thing' do
@@ -72,5 +84,16 @@ describe Logplex::Publisher do
72
84
  publisher = Logplex::Publisher.new('https://token:t.some-token@logplex.example.com')
73
85
  expect(publisher.publish('hi')).to be_falsey
74
86
  end
87
+
88
+ it "includes the correct headers" do
89
+ message = 'hello-harold'
90
+ headers = {
91
+ "Content-Type" => 'application/logplex-1',
92
+ "Content-Length" => 79,
93
+ "Logplex-Msg-Count" => 1
94
+ }
95
+ expect(Excon).to receive(:post).with(any_args, hash_including(:headers => headers))
96
+ Logplex::Publisher.new('https://token:t.some-token@logplex.example.com').publish(message)
97
+ end
75
98
  end
76
99
  end
metadata CHANGED
@@ -1,14 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: logplex
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Harold Giménez
8
+ - Heroku
8
9
  autorequire:
9
10
  bindir: bin
10
11
  cert_chain: []
11
- date: 2016-07-26 00:00:00.000000000 Z
12
+ date: 2021-09-13 00:00:00.000000000 Z
12
13
  dependencies:
13
14
  - !ruby/object:Gem::Dependency
14
15
  name: valcro
@@ -77,7 +78,7 @@ files:
77
78
  - spec/logplex/message_spec.rb
78
79
  - spec/logplex/publisher_spec.rb
79
80
  - spec/spec_helper.rb
80
- homepage: https://practiceovertheory.com
81
+ homepage: https://github.com/heroku/logplex-gem
81
82
  licenses: []
82
83
  metadata: {}
83
84
  post_install_message:
@@ -95,8 +96,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
95
96
  - !ruby/object:Gem::Version
96
97
  version: '0'
97
98
  requirements: []
98
- rubyforge_project:
99
- rubygems_version: 2.4.5.1
99
+ rubygems_version: 3.0.3
100
100
  signing_key:
101
101
  specification_version: 4
102
102
  summary: Publish and Consume Logplex messages
@@ -105,4 +105,3 @@ test_files:
105
105
  - spec/logplex/message_spec.rb
106
106
  - spec/logplex/publisher_spec.rb
107
107
  - spec/spec_helper.rb
108
- has_rdoc: