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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 046d032389d041dfea1d880c47ff567ad6ccd97439ba05db04f49fe8f6fd8596
4
- data.tar.gz: c1eda45ae5d2cbab863eabb843adfb89694ea563f73101bbf268fba18c25d175
3
+ metadata.gz: ba503479ca9b110e2cf338a688df900d2ae393118c79a47b9e0e8b4737b5bc3c
4
+ data.tar.gz: be44255c80b29ccbad7d7c38d1ba18e5d7e9262041b36645deff6feb5266d70a
5
5
  SHA512:
6
- metadata.gz: 58986de036f80e17d25440c25d4d6bbdb54a0340f865b455847f7a7bf4d2206ae4fefccb91edbb3b56990cf468505501ad1fa30f5223f589483a1e291a59c49a
7
- data.tar.gz: a085cd90036662bf26516bd5574a64d921cfff6b0728ec3350cac8eba80f75faef08dc0a69bf4909adb6e31a1f62ff9e4f2d62560eff5226e493af777eaa5810
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
@@ -1,9 +1,10 @@
1
1
  language: ruby
2
2
  rvm:
3
- - 2.3.0
4
- - 2.4
5
3
  - 2.5
6
4
  - 2.6
5
+ - 2.7
6
+ - 3.0
7
+ - truffleruby
7
8
  services:
8
9
  - redis-server
9
10
  script: bundle exec rspec spec
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
- - :address: "127.0.0.1"
60
- :port: 8080
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 `imap_timeout` in seconds for your mailbox configuration.
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: Time.now, severity: :fatal, message: error.message, backtrace: error.backtrace }.to_json
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.to_s
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
@@ -1,4 +1,4 @@
1
1
  module MailRoom
2
2
  # Current version of gitlab-mail_room gem
3
- VERSION = "0.0.9"
3
+ VERSION = "0.0.10"
4
4
  end
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: now,
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: now
78
+ time: timestamp
47
79
  }.merge(message)
48
80
 
49
81
  as_regex(contents)
data/spec/spec_helper.rb CHANGED
@@ -2,6 +2,7 @@ require 'simplecov'
2
2
  SimpleCov.start
3
3
 
4
4
  require 'bundler/setup'
5
+ require 'date'
5
6
 
6
7
  require 'rspec'
7
8
  require 'mocha/api'
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.9
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-12 00:00:00.000000000 Z
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