logplex 0.0.5 → 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 +4 -4
- data/.circleci/config.yml +15 -0
- data/.gitignore +1 -0
- data/CODEOWNERS +2 -0
- data/lib/logplex/publisher.rb +4 -3
- data/lib/logplex/version.rb +1 -1
- data/spec/logplex/publisher_spec.rb +19 -0
- metadata +8 -7
- data/.travis.yml +0 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 74968b946301f4fcecd000127c5bfd98b80d39ce024084ece76af5479e7a109e
|
4
|
+
data.tar.gz: 9edd68f2df748bfb7ffc2f8ffe3d4fd64251897c1c236fc5bd8229f324cb9214
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f3eb73debbaaad3261d89834acee07d3c46642275926c705df4547c5dfb2da4ec09c5b17b412de8edb1baaad55da03b85a4f0985a316ac54ef0c6180278e53fc
|
7
|
+
data.tar.gz: dc60bb59e898e11e36a6728bd5f0cb7d6ecc202dd1b2df013e0e825692702020c50b264d1c6229987224c1d7c247e1f090a00022e98be86c7ad7395b89939358
|
data/.gitignore
CHANGED
data/CODEOWNERS
ADDED
data/lib/logplex/publisher.rb
CHANGED
@@ -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, 204])
|
44
|
+
}), expects: [200, 202, 204])
|
44
45
|
end
|
45
46
|
end
|
46
47
|
end
|
data/lib/logplex/version.rb
CHANGED
@@ -56,6 +56,13 @@ describe Logplex::Publisher do
|
|
56
56
|
expect(publisher.publish(message)).to be_truthy
|
57
57
|
end
|
58
58
|
|
59
|
+
it 'does the thing with a 202' do
|
60
|
+
Excon.stub({ method: :post, password: "t.some-token", body: /hi\="there\"/ }, status: 202)
|
61
|
+
message = { hi: 'there' }
|
62
|
+
publisher = Logplex::Publisher.new('https://token:t.some-token@logplex.example.com')
|
63
|
+
expect(publisher.publish(message)).to be_truthy
|
64
|
+
end
|
65
|
+
|
59
66
|
it 'returns true' do
|
60
67
|
Excon.stub({ method: :post, password: "t.some-token" }, status: 204)
|
61
68
|
message = 'I have a message for you'
|
@@ -95,5 +102,17 @@ describe Logplex::Publisher do
|
|
95
102
|
expect(Excon).to receive(:post).with(any_args, hash_including(:headers => headers))
|
96
103
|
Logplex::Publisher.new('https://token:t.some-token@logplex.example.com').publish(message)
|
97
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
|
98
117
|
end
|
99
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.
|
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:
|
12
|
+
date: 2025-04-09 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: valcro
|
@@ -60,9 +60,10 @@ executables: []
|
|
60
60
|
extensions: []
|
61
61
|
extra_rdoc_files: []
|
62
62
|
files:
|
63
|
+
- ".circleci/config.yml"
|
63
64
|
- ".gitignore"
|
64
65
|
- ".rspec"
|
65
|
-
-
|
66
|
+
- CODEOWNERS
|
66
67
|
- Gemfile
|
67
68
|
- LICENSE
|
68
69
|
- LICENSE.txt
|
@@ -81,7 +82,7 @@ files:
|
|
81
82
|
homepage: https://github.com/heroku/logplex-gem
|
82
83
|
licenses: []
|
83
84
|
metadata: {}
|
84
|
-
post_install_message:
|
85
|
+
post_install_message:
|
85
86
|
rdoc_options: []
|
86
87
|
require_paths:
|
87
88
|
- lib
|
@@ -96,8 +97,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
96
97
|
- !ruby/object:Gem::Version
|
97
98
|
version: '0'
|
98
99
|
requirements: []
|
99
|
-
rubygems_version: 3.
|
100
|
-
signing_key:
|
100
|
+
rubygems_version: 3.4.6
|
101
|
+
signing_key:
|
101
102
|
specification_version: 4
|
102
103
|
summary: Publish and Consume Logplex messages
|
103
104
|
test_files:
|