gitlab-mail_room 0.0.9 → 0.0.10
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitlab-ci.yml +0 -4
- data/.travis.yml +3 -2
- data/README.md +3 -3
- data/lib/mail_room/crash_handler.rb +2 -1
- data/lib/mail_room/logger/structured.rb +15 -1
- data/lib/mail_room/version.rb +1 -1
- data/mail_room.gemspec +2 -0
- data/spec/lib/logger/structured_spec.rb +34 -2
- data/spec/spec_helper.rb +1 -0
- metadata +16 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ba503479ca9b110e2cf338a688df900d2ae393118c79a47b9e0e8b4737b5bc3c
|
4
|
+
data.tar.gz: be44255c80b29ccbad7d7c38d1ba18e5d7e9262041b36645deff6feb5266d70a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8e0e0d8e8dbb37643139a655b5fbe613630ea1b6e99de6e2fd51098fb4da75d381762af72f96fd0c1d4922764f8688a75be2bd660ef6a4b21492b0a2df791a15
|
7
|
+
data.tar.gz: 4f02c046002569bfb9d15d730ea2853036cce2e88af27e88a5a586f1526a70869dc1533b5abf601d05ce777a3f3e2620872b27769a49383bb9fc1ef761e47794
|
data/.gitlab-ci.yml
CHANGED
@@ -19,10 +19,6 @@ services:
|
|
19
19
|
- gem install bundler --no-document # Bundler is not installed with the image
|
20
20
|
- bundle install -j $(nproc) --path vendor # Install dependencies into ./vendor/ruby
|
21
21
|
|
22
|
-
rspec-2.4:
|
23
|
-
image: "ruby:2.4"
|
24
|
-
<<: *test
|
25
|
-
|
26
22
|
rspec-2.5:
|
27
23
|
image: "ruby:2.5"
|
28
24
|
<<: *test
|
data/.travis.yml
CHANGED
data/README.md
CHANGED
@@ -56,8 +56,8 @@ You will also need to install `faraday` or `letter_opener` if you use the `postb
|
|
56
56
|
```yaml
|
57
57
|
---
|
58
58
|
:health_check:
|
59
|
-
|
60
|
-
|
59
|
+
:address: "127.0.0.1"
|
60
|
+
:port: 8080
|
61
61
|
:mailboxes:
|
62
62
|
-
|
63
63
|
:email: "user1@gmail.com"
|
@@ -278,7 +278,7 @@ it's probably because the content-type is set to Faraday's default, which is `H
|
|
278
278
|
## idle_timeout ##
|
279
279
|
|
280
280
|
By default, the IDLE command will wait for 29 minutes (in order to keep the server connection happy).
|
281
|
-
If you'd prefer not to wait that long, you can pass `
|
281
|
+
If you'd prefer not to wait that long, you can pass `idle_timeout` in seconds for your mailbox configuration.
|
282
282
|
|
283
283
|
## Search Command ##
|
284
284
|
|
@@ -1,3 +1,4 @@
|
|
1
|
+
require 'date'
|
1
2
|
|
2
3
|
module MailRoom
|
3
4
|
class CrashHandler
|
@@ -19,7 +20,7 @@ module MailRoom
|
|
19
20
|
private
|
20
21
|
|
21
22
|
def json(error)
|
22
|
-
{ time:
|
23
|
+
{ time: DateTime.now.iso8601(3), severity: :fatal, message: error.message, backtrace: error.backtrace }.to_json
|
23
24
|
end
|
24
25
|
end
|
25
26
|
end
|
@@ -1,3 +1,4 @@
|
|
1
|
+
require 'date'
|
1
2
|
require 'logger'
|
2
3
|
require 'json'
|
3
4
|
|
@@ -10,12 +11,25 @@ module MailRoom
|
|
10
11
|
|
11
12
|
data = {}
|
12
13
|
data[:severity] = severity
|
13
|
-
data[:time] = timestamp || Time.now
|
14
|
+
data[:time] = format_timestamp(timestamp || Time.now)
|
14
15
|
# only accept a Hash
|
15
16
|
data.merge!(message)
|
16
17
|
|
17
18
|
data.to_json + "\n"
|
18
19
|
end
|
20
|
+
|
21
|
+
private
|
22
|
+
|
23
|
+
def format_timestamp(timestamp)
|
24
|
+
case timestamp
|
25
|
+
when Time
|
26
|
+
timestamp.to_datetime.iso8601(3).to_s
|
27
|
+
when DateTime
|
28
|
+
timestamp.iso8601(3).to_s
|
29
|
+
else
|
30
|
+
timestamp
|
31
|
+
end
|
32
|
+
end
|
19
33
|
end
|
20
34
|
end
|
21
35
|
end
|
data/lib/mail_room/version.rb
CHANGED
data/mail_room.gemspec
CHANGED
@@ -17,6 +17,8 @@ Gem::Specification.new do |gem|
|
|
17
17
|
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
18
18
|
gem.require_paths = ["lib"]
|
19
19
|
|
20
|
+
gem.add_dependency "net-imap", ">= 0.2.1"
|
21
|
+
|
20
22
|
gem.add_development_dependency "rake"
|
21
23
|
gem.add_development_dependency "rspec", "~> 3.9"
|
22
24
|
gem.add_development_dependency "mocha", "~> 1.11"
|
@@ -5,6 +5,7 @@ describe MailRoom::Logger::Structured do
|
|
5
5
|
subject { described_class.new $stdout }
|
6
6
|
|
7
7
|
let!(:now) { Time.now }
|
8
|
+
let(:timestamp) { now.to_datetime.iso8601(3) }
|
8
9
|
let(:message) { { action: 'exciting development', message: 'testing 123' } }
|
9
10
|
|
10
11
|
before do
|
@@ -32,7 +33,7 @@ describe MailRoom::Logger::Structured do
|
|
32
33
|
}
|
33
34
|
expected = {
|
34
35
|
severity: 'DEBUG',
|
35
|
-
time:
|
36
|
+
time: timestamp,
|
36
37
|
additional_field: "some value"
|
37
38
|
}
|
38
39
|
|
@@ -40,10 +41,41 @@ describe MailRoom::Logger::Structured do
|
|
40
41
|
end
|
41
42
|
end
|
42
43
|
|
44
|
+
describe '#format_message' do
|
45
|
+
shared_examples 'timestamp formatting' do
|
46
|
+
it 'outputs ISO8601 timestamps' do
|
47
|
+
data = JSON.parse(subject.format_message('debug', input_timestamp, 'test', { message: 'hello' } ))
|
48
|
+
|
49
|
+
expect(data['time']).to eq(expected_timestamp)
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
context 'with no timestamp' do
|
54
|
+
let(:input_timestamp) { nil }
|
55
|
+
let(:expected_timestamp) { timestamp }
|
56
|
+
|
57
|
+
it_behaves_like 'timestamp formatting'
|
58
|
+
end
|
59
|
+
|
60
|
+
context 'with DateTime' do
|
61
|
+
let(:input_timestamp) { now.to_datetime }
|
62
|
+
let(:expected_timestamp) { timestamp }
|
63
|
+
|
64
|
+
it_behaves_like 'timestamp formatting'
|
65
|
+
end
|
66
|
+
|
67
|
+
context 'with string' do
|
68
|
+
let(:input_timestamp) { now.to_s }
|
69
|
+
let(:expected_timestamp) { input_timestamp }
|
70
|
+
|
71
|
+
it_behaves_like 'timestamp formatting'
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
43
75
|
def json_matching(level, message)
|
44
76
|
contents = {
|
45
77
|
severity: level,
|
46
|
-
time:
|
78
|
+
time: timestamp
|
47
79
|
}.merge(message)
|
48
80
|
|
49
81
|
as_regex(contents)
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,15 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gitlab-mail_room
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.10
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tony Pitale
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-03-
|
11
|
+
date: 2021-03-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: net-imap
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 0.2.1
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 0.2.1
|
13
27
|
- !ruby/object:Gem::Dependency
|
14
28
|
name: rake
|
15
29
|
requirement: !ruby/object:Gem::Requirement
|