logplex 0.0.6 → 0.0.7

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
  SHA256:
3
- metadata.gz: 3f973380d37a67928c3e0e9798c88df6caf1ea88ed190351bb34d1594ab25cb7
4
- data.tar.gz: 2d21727ab0fe7ebe472cc4eb8a9213b237807d63f968e0b1d2ec1dce8544cd80
3
+ metadata.gz: 74968b946301f4fcecd000127c5bfd98b80d39ce024084ece76af5479e7a109e
4
+ data.tar.gz: 9edd68f2df748bfb7ffc2f8ffe3d4fd64251897c1c236fc5bd8229f324cb9214
5
5
  SHA512:
6
- metadata.gz: d689eb0ee848ae374046adadce1280a6612e97cb884d075c762b8c514e379a837bcdadcf0afcb27add81d6e50e3c75bd808ac6df9e9bb3eefc43c6ed2b8fbe92
7
- data.tar.gz: 5b39c6f7598bf01a87dec86769f28a8c6497728524b3378f7a9c8c8841af23ba8c90855d5224c7fcb65b4574fe3585fdb066bb6b627537b0a7988a9a34687505
6
+ metadata.gz: f3eb73debbaaad3261d89834acee07d3c46642275926c705df4547c5dfb2da4ec09c5b17b412de8edb1baaad55da03b85a4f0985a316ac54ef0c6180278e53fc
7
+ data.tar.gz: dc60bb59e898e11e36a6728bd5f0cb7d6ecc202dd1b2df013e0e825692702020c50b264d1c6229987224c1d7c247e1f090a00022e98be86c7ad7395b89939358
data/.gitignore CHANGED
@@ -17,3 +17,4 @@ test/tmp
17
17
  test/version_tmp
18
18
  tmp
19
19
  .tags
20
+ .idea
@@ -9,9 +9,10 @@ module Logplex
9
9
  Excon::Errors::Unauthorized,
10
10
  Timeout::Error].freeze
11
11
 
12
- def initialize(logplex_url = nil)
12
+ def initialize(logplex_url = nil, bearer_token: nil)
13
13
  @logplex_url = logplex_url || Logplex.configuration.logplex_url
14
14
  @token = URI(@logplex_url).password || Logplex.configuration.app_name
15
+ @auth_headers = bearer_token ? { 'Authorization' => "Bearer #{bearer_token}" } : {}
15
16
  end
16
17
 
17
18
  def publish(messages, opts={})
@@ -36,11 +37,11 @@ module Logplex
36
37
  private
37
38
 
38
39
  def api_post(message, number_messages)
39
- Excon.post(@logplex_url, body: message, headers: {
40
+ Excon.post(@logplex_url, body: message, headers: @auth_headers.merge({
40
41
  "Content-Type" => 'application/logplex-1',
41
42
  "Content-Length" => message.length,
42
43
  "Logplex-Msg-Count" => number_messages
43
- }, expects: [200, 202, 204])
44
+ }), expects: [200, 202, 204])
44
45
  end
45
46
  end
46
47
  end
@@ -1,3 +1,3 @@
1
1
  module Logplex
2
- VERSION = "0.0.6".freeze
2
+ VERSION = "0.0.7".freeze
3
3
  end
@@ -102,5 +102,17 @@ describe Logplex::Publisher do
102
102
  expect(Excon).to receive(:post).with(any_args, hash_including(:headers => headers))
103
103
  Logplex::Publisher.new('https://token:t.some-token@logplex.example.com').publish(message)
104
104
  end
105
+
106
+ it "supports bearer authentication" do
107
+ message = 'hello-bearer'
108
+ headers = {
109
+ "Authorization" => 'Bearer test-bearer-token',
110
+ "Content-Type" => 'application/logplex-1',
111
+ "Content-Length" => 70,
112
+ "Logplex-Msg-Count" => 1
113
+ }
114
+ expect(Excon).to receive(:post).with(any_args, hash_including(:headers => headers))
115
+ Logplex::Publisher.new('https://logplex-next.example.com', bearer_token: 'test-bearer-token').publish(message)
116
+ end
105
117
  end
106
118
  end
metadata CHANGED
@@ -1,15 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: logplex
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.6
4
+ version: 0.0.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Harold Giménez
8
8
  - Heroku
9
- autorequire:
9
+ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2022-03-03 00:00:00.000000000 Z
12
+ date: 2025-04-09 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: valcro
@@ -82,7 +82,7 @@ files:
82
82
  homepage: https://github.com/heroku/logplex-gem
83
83
  licenses: []
84
84
  metadata: {}
85
- post_install_message:
85
+ post_install_message:
86
86
  rdoc_options: []
87
87
  require_paths:
88
88
  - lib
@@ -97,8 +97,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
97
97
  - !ruby/object:Gem::Version
98
98
  version: '0'
99
99
  requirements: []
100
- rubygems_version: 3.3.4
101
- signing_key:
100
+ rubygems_version: 3.4.6
101
+ signing_key:
102
102
  specification_version: 4
103
103
  summary: Publish and Consume Logplex messages
104
104
  test_files: