doctor_doug 0.1.3 → 0.1.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +30 -1
- data/README.md +6 -3
- data/doctor_doug.gemspec +1 -0
- data/lib/doctor_doug.rb +2 -0
- data/lib/doctor_doug/configuration.rb +5 -1
- data/lib/doctor_doug/notify/base.rb +5 -2
- data/lib/doctor_doug/notify/slack_adapter.rb +25 -0
- data/lib/doctor_doug/version.rb +1 -1
- metadata +17 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c053696881afbb49ce411598b1fb2f5093bee707
|
4
|
+
data.tar.gz: d988625f0105392cd476dd1ace15eda9079e8e94
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9349f210c1642e96af4e6077a43f53419f9d91994865f9efa837416900bbd61dd1194660be48ff1f6a45edfc331930f35895fd2e8f74435da6f40402ae0e0b02
|
7
|
+
data.tar.gz: 684a71a624c8395bc48219b43d01e07ef47ee125565b4940a469aeab82453399eefb8e60d4aa71697a206ec5d65a9b0085216bb0ef8570c6b8e23d9daa13f26a
|
data/Gemfile.lock
CHANGED
@@ -1,24 +1,53 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
doctor_doug (0.1.
|
4
|
+
doctor_doug (0.1.4)
|
5
5
|
mail
|
6
|
+
slack-ruby-client
|
6
7
|
|
7
8
|
GEM
|
8
9
|
remote: https://rubygems.org/
|
9
10
|
specs:
|
11
|
+
activesupport (5.2.0)
|
12
|
+
concurrent-ruby (~> 1.0, >= 1.0.2)
|
13
|
+
i18n (>= 0.7, < 2)
|
14
|
+
minitest (~> 5.1)
|
15
|
+
tzinfo (~> 1.1)
|
16
|
+
concurrent-ruby (1.0.5)
|
10
17
|
docile (1.3.0)
|
18
|
+
faraday (0.15.2)
|
19
|
+
multipart-post (>= 1.2, < 3)
|
20
|
+
faraday_middleware (0.12.2)
|
21
|
+
faraday (>= 0.7.4, < 1.0)
|
22
|
+
gli (2.17.1)
|
23
|
+
hashie (3.5.7)
|
24
|
+
i18n (1.0.1)
|
25
|
+
concurrent-ruby (~> 1.0)
|
11
26
|
json (2.1.0)
|
12
27
|
mail (2.7.0)
|
13
28
|
mini_mime (>= 0.1.1)
|
14
29
|
mini_mime (1.0.0)
|
15
30
|
minitest (5.11.3)
|
31
|
+
multipart-post (2.0.0)
|
16
32
|
rake (10.5.0)
|
17
33
|
simplecov (0.16.1)
|
18
34
|
docile (~> 1.1)
|
19
35
|
json (>= 1.8, < 3)
|
20
36
|
simplecov-html (~> 0.10.0)
|
21
37
|
simplecov-html (0.10.2)
|
38
|
+
slack-ruby-client (0.11.1)
|
39
|
+
activesupport
|
40
|
+
faraday (>= 0.9)
|
41
|
+
faraday_middleware
|
42
|
+
gli
|
43
|
+
hashie
|
44
|
+
websocket-driver
|
45
|
+
thread_safe (0.3.6)
|
46
|
+
tzinfo (1.2.5)
|
47
|
+
thread_safe (~> 0.1)
|
48
|
+
websocket-driver (0.7.0)
|
49
|
+
websocket-extensions (>= 0.1.0)
|
50
|
+
websocket-extensions (0.1.3)
|
22
51
|
|
23
52
|
PLATFORMS
|
24
53
|
ruby
|
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# DoctorDoug
|
2
2
|
|
3
|
-
Run checkup and notify you
|
3
|
+
Run checkup and notify you on mail/slack when there are violations
|
4
4
|
|
5
5
|
## Installation
|
6
6
|
|
@@ -24,7 +24,7 @@ Or install it yourself as:
|
|
24
24
|
# config/initializers/doctor_doug.rb
|
25
25
|
|
26
26
|
DoctorDoug.configure do |config|
|
27
|
-
config.strategies = [:mail]
|
27
|
+
config.strategies = [:mail, :slack]
|
28
28
|
config.mail_options = {
|
29
29
|
address: 'smtp.gmail.com',
|
30
30
|
port: 587,
|
@@ -35,6 +35,10 @@ DoctorDoug.configure do |config|
|
|
35
35
|
from: 'from@gmail.com',
|
36
36
|
to: 'to@gmail.com'
|
37
37
|
}
|
38
|
+
config.slack_options = {
|
39
|
+
token: 'your_slack_token',
|
40
|
+
channel: '#general'
|
41
|
+
}
|
38
42
|
end
|
39
43
|
```
|
40
44
|
|
@@ -45,7 +49,6 @@ DoctorDoug.checkup "user name should not be blank" do
|
|
45
49
|
violate? user.name.blank?
|
46
50
|
end
|
47
51
|
end
|
48
|
-
|
49
52
|
```
|
50
53
|
|
51
54
|
## Development
|
data/doctor_doug.gemspec
CHANGED
data/lib/doctor_doug.rb
CHANGED
@@ -6,8 +6,10 @@ require 'doctor_doug/errors'
|
|
6
6
|
require 'doctor_doug/configuration'
|
7
7
|
require 'doctor_doug/notify/base'
|
8
8
|
require 'doctor_doug/notify/mail'
|
9
|
+
require 'doctor_doug/notify/slack_adapter'
|
9
10
|
|
10
11
|
require 'mail'
|
12
|
+
require 'slack-ruby-client'
|
11
13
|
|
12
14
|
module DoctorDoug # :nodoc:
|
13
15
|
end
|
@@ -18,6 +18,10 @@ module DoctorDoug
|
|
18
18
|
# from: 'from@gmail.com',
|
19
19
|
# to: 'to@gmail.com'
|
20
20
|
# }
|
21
|
+
# config.slack_options = {
|
22
|
+
# token: 'aabbcc',
|
23
|
+
# channel: '#general'
|
24
|
+
# }
|
21
25
|
# end
|
22
26
|
class << self
|
23
27
|
attr_accessor :configuration
|
@@ -29,7 +33,7 @@ module DoctorDoug
|
|
29
33
|
end
|
30
34
|
|
31
35
|
class Configuration # :nodoc:
|
32
|
-
attr_accessor :strategies, :mail_options
|
36
|
+
attr_accessor :strategies, :mail_options, :slack_options
|
33
37
|
|
34
38
|
def initialize
|
35
39
|
@strategies = [:mail]
|
@@ -7,8 +7,11 @@ module DoctorDoug
|
|
7
7
|
strategies = DoctorDoug.configuration.strategies
|
8
8
|
strategies = valid_strategies(strategies)
|
9
9
|
strategies.each do |strategy|
|
10
|
-
|
10
|
+
case strategy
|
11
|
+
when :mail
|
11
12
|
DoctorDoug::Notify::Mail.new(DoctorDoug.configuration, violations: violations).deliver(checkup_name: checkup_name)
|
13
|
+
when :slack
|
14
|
+
DoctorDoug::Notify::SlackAdapter.new(DoctorDoug.configuration.slack_options, violations: violations).deliver(checkup_name: checkup_name)
|
12
15
|
end
|
13
16
|
end
|
14
17
|
end
|
@@ -16,7 +19,7 @@ module DoctorDoug
|
|
16
19
|
|
17
20
|
class << self
|
18
21
|
def valid_strategies(strategies)
|
19
|
-
[:mail] & strategies
|
22
|
+
[:mail, :slack] & strategies
|
20
23
|
end
|
21
24
|
end
|
22
25
|
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module DoctorDoug
|
4
|
+
module Notify
|
5
|
+
class SlackAdapter < Base # :nodoc:
|
6
|
+
def initialize(slack_options, violations:)
|
7
|
+
super(violations)
|
8
|
+
@slack_options = slack_options
|
9
|
+
end
|
10
|
+
|
11
|
+
def client
|
12
|
+
@client ||= ::Slack::Web::Client.new(token: slack_options[:token])
|
13
|
+
end
|
14
|
+
|
15
|
+
def deliver(checkup_name:)
|
16
|
+
message = self.message
|
17
|
+
client.chat_postMessage(channel: slack_options[:channel], text: "#{checkup_name}: #{message}", as_user: true)
|
18
|
+
end
|
19
|
+
|
20
|
+
private
|
21
|
+
|
22
|
+
attr_reader :slack_options
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
data/lib/doctor_doug/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: doctor_doug
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tongfei Gao
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-06-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: mail
|
@@ -24,6 +24,20 @@ dependencies:
|
|
24
24
|
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: slack-ruby-client
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
27
41
|
- !ruby/object:Gem::Dependency
|
28
42
|
name: bundler
|
29
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -104,6 +118,7 @@ files:
|
|
104
118
|
- lib/doctor_doug/errors.rb
|
105
119
|
- lib/doctor_doug/notify/base.rb
|
106
120
|
- lib/doctor_doug/notify/mail.rb
|
121
|
+
- lib/doctor_doug/notify/slack_adapter.rb
|
107
122
|
- lib/doctor_doug/version.rb
|
108
123
|
homepage: https://github.com/gaotongfei/doctor_doug
|
109
124
|
licenses: []
|