devise_slack_notifiable 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.editorconfig +9 -9
- data/.github/workflows/gem-push.yml +28 -0
- data/.github/workflows/ruby.yml +27 -0
- data/.gitignore +2 -0
- data/.travis.yml +0 -6
- data/Gemfile +1 -0
- data/Gemfile.lock +28 -2
- data/README.md +4 -0
- data/Rakefile +8 -8
- data/devise_slack_notifiable.gemspec +1 -0
- data/lib/devise/models/slack_notifiable.rb +11 -1
- data/lib/devise_slack_notifiable.rb +3 -0
- data/lib/devise_slack_notifiable/configuration.rb +4 -0
- data/lib/devise_slack_notifiable/errors/configuration.rb +2 -0
- data/lib/devise_slack_notifiable/notifier.rb +21 -3
- data/lib/devise_slack_notifiable/version.rb +5 -5
- metadata +17 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b99296dbdd359b33c21ff11fd912a5079072e16d448b0ab0204a551663c3cd3d
|
4
|
+
data.tar.gz: 3759859e2a7b792e05094887c0057afe6f2ddf1e30fd05b3618c615b52e0bced
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5043d05915f13b686b7d71921dd9c0411ed4a39d5da8ae323f2b13cfd2a69834b78ccc6153975a2af5bb47529ddf65056d49fd09f6cfd64e82469018f677934e
|
7
|
+
data.tar.gz: 8566eeef5f0658b6de2483b97cb3f629c47c2db5ac65efea4cb0d63d89ecb2f13912c1b1a8b05e7c5b39b96f6d9b556c8d6dec6a55a97584655a1e7b4a44502d
|
data/.editorconfig
CHANGED
@@ -1,9 +1,9 @@
|
|
1
|
-
root = true
|
2
|
-
|
3
|
-
[*]
|
4
|
-
indent_style = space
|
5
|
-
indent_size = 2
|
6
|
-
end_of_line = lf
|
7
|
-
charset = utf-8
|
8
|
-
trim_trailing_whitespace = true
|
9
|
-
insert_final_newline = true
|
1
|
+
root = true
|
2
|
+
|
3
|
+
[*]
|
4
|
+
indent_style = space
|
5
|
+
indent_size = 2
|
6
|
+
end_of_line = lf
|
7
|
+
charset = utf-8
|
8
|
+
trim_trailing_whitespace = true
|
9
|
+
insert_final_newline = true
|
@@ -0,0 +1,28 @@
|
|
1
|
+
name: Ruby Gem
|
2
|
+
|
3
|
+
on:
|
4
|
+
release:
|
5
|
+
types: [published]
|
6
|
+
|
7
|
+
jobs:
|
8
|
+
build:
|
9
|
+
name: Build + Publish
|
10
|
+
runs-on: ubuntu-latest
|
11
|
+
|
12
|
+
steps:
|
13
|
+
- uses: actions/checkout@v2
|
14
|
+
- name: Set up Ruby 2.6
|
15
|
+
uses: actions/setup-ruby@v1
|
16
|
+
with:
|
17
|
+
version: 2.6.x
|
18
|
+
|
19
|
+
- name: Publish to RubyGems
|
20
|
+
run: |
|
21
|
+
mkdir -p $HOME/.gem
|
22
|
+
touch $HOME/.gem/credentials
|
23
|
+
chmod 0600 $HOME/.gem/credentials
|
24
|
+
printf -- "---\n:rubygems_api_key: ${GEM_HOST_API_KEY}\n" > $HOME/.gem/credentials
|
25
|
+
gem build *.gemspec
|
26
|
+
gem push *.gem
|
27
|
+
env:
|
28
|
+
GEM_HOST_API_KEY: ${{secrets.RUBYGEMS_AUTH_TOKEN}}
|
@@ -0,0 +1,27 @@
|
|
1
|
+
name: Ruby
|
2
|
+
|
3
|
+
on:
|
4
|
+
push:
|
5
|
+
branches: [ master ]
|
6
|
+
pull_request:
|
7
|
+
branches: [ master ]
|
8
|
+
|
9
|
+
jobs:
|
10
|
+
test:
|
11
|
+
|
12
|
+
runs-on: ubuntu-latest
|
13
|
+
|
14
|
+
steps:
|
15
|
+
- uses: actions/checkout@v2
|
16
|
+
- name: Set up Ruby
|
17
|
+
uses: ruby/setup-ruby@v1
|
18
|
+
with:
|
19
|
+
ruby-version: 2.6
|
20
|
+
|
21
|
+
- name: Install dependencies
|
22
|
+
run: bundle install
|
23
|
+
|
24
|
+
- name: Run tests and send coverage
|
25
|
+
run: bundle exec rspec
|
26
|
+
env:
|
27
|
+
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
|
data/.gitignore
CHANGED
data/.travis.yml
CHANGED
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,7 +1,8 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
devise_slack_notifiable (0.
|
4
|
+
devise_slack_notifiable (0.2.0)
|
5
|
+
devise
|
5
6
|
rails
|
6
7
|
slack-notifier
|
7
8
|
|
@@ -63,15 +64,28 @@ GEM
|
|
63
64
|
minitest (~> 5.1)
|
64
65
|
tzinfo (~> 1.1)
|
65
66
|
zeitwerk (~> 2.2, >= 2.2.2)
|
67
|
+
bcrypt (3.1.13)
|
66
68
|
builder (3.2.4)
|
69
|
+
codecov (0.1.17)
|
70
|
+
json
|
71
|
+
simplecov
|
72
|
+
url
|
67
73
|
concurrent-ruby (1.1.6)
|
68
74
|
crass (1.0.6)
|
75
|
+
devise (4.7.2)
|
76
|
+
bcrypt (~> 3.0)
|
77
|
+
orm_adapter (~> 0.1)
|
78
|
+
railties (>= 4.1.0)
|
79
|
+
responders
|
80
|
+
warden (~> 1.2.3)
|
69
81
|
diff-lcs (1.3)
|
82
|
+
docile (1.3.2)
|
70
83
|
erubi (1.9.0)
|
71
84
|
globalid (0.4.2)
|
72
85
|
activesupport (>= 4.2.0)
|
73
86
|
i18n (1.8.3)
|
74
87
|
concurrent-ruby (~> 1.0)
|
88
|
+
json (2.3.0)
|
75
89
|
loofah (2.6.0)
|
76
90
|
crass (~> 1.0.2)
|
77
91
|
nokogiri (>= 1.5.9)
|
@@ -87,6 +101,7 @@ GEM
|
|
87
101
|
nio4r (2.5.2)
|
88
102
|
nokogiri (1.10.9-x64-mingw32)
|
89
103
|
mini_portile2 (~> 2.4.0)
|
104
|
+
orm_adapter (0.5.0)
|
90
105
|
rack (2.2.3)
|
91
106
|
rack-test (1.1.0)
|
92
107
|
rack (>= 1.0, < 3)
|
@@ -117,6 +132,9 @@ GEM
|
|
117
132
|
rake (>= 0.8.7)
|
118
133
|
thor (>= 0.20.3, < 2.0)
|
119
134
|
rake (12.3.3)
|
135
|
+
responders (3.0.1)
|
136
|
+
actionpack (>= 5.0)
|
137
|
+
railties (>= 5.0)
|
120
138
|
rspec (3.9.0)
|
121
139
|
rspec-core (~> 3.9.0)
|
122
140
|
rspec-expectations (~> 3.9.0)
|
@@ -130,8 +148,12 @@ GEM
|
|
130
148
|
diff-lcs (>= 1.2.0, < 2.0)
|
131
149
|
rspec-support (~> 3.9.0)
|
132
150
|
rspec-support (3.9.3)
|
151
|
+
simplecov (0.18.5)
|
152
|
+
docile (~> 1.1)
|
153
|
+
simplecov-html (~> 0.11)
|
154
|
+
simplecov-html (0.12.2)
|
133
155
|
slack-notifier (2.3.2)
|
134
|
-
sprockets (
|
156
|
+
sprockets (4.0.2)
|
135
157
|
concurrent-ruby (~> 1.0)
|
136
158
|
rack (> 1, < 3)
|
137
159
|
sprockets-rails (3.2.1)
|
@@ -142,6 +164,9 @@ GEM
|
|
142
164
|
thread_safe (0.3.6)
|
143
165
|
tzinfo (1.2.7)
|
144
166
|
thread_safe (~> 0.1)
|
167
|
+
url (0.3.2)
|
168
|
+
warden (1.2.8)
|
169
|
+
rack (>= 2.0.6)
|
145
170
|
websocket-driver (0.7.2)
|
146
171
|
websocket-extensions (>= 0.1.0)
|
147
172
|
websocket-extensions (0.1.5)
|
@@ -151,6 +176,7 @@ PLATFORMS
|
|
151
176
|
x64-mingw32
|
152
177
|
|
153
178
|
DEPENDENCIES
|
179
|
+
codecov
|
154
180
|
devise_slack_notifiable!
|
155
181
|
rake (~> 12.0)
|
156
182
|
rspec (~> 3.0)
|
data/README.md
CHANGED
@@ -2,6 +2,10 @@
|
|
2
2
|
|
3
3
|
Devise slack notifications gem. It posts message after registration and confirmation (if Devise confirmations strategy is enabled).
|
4
4
|
|
5
|
+
[![Gem Version](https://badge.fury.io/rb/devise_slack_notifiable.svg)](https://badge.fury.io/rb/devise_slack_notifiable)
|
6
|
+
[![codecov](https://codecov.io/gh/invoicity/devise_slack_notifiable/branch/master/graph/badge.svg)](https://codecov.io/gh/invoicity/devise_slack_notifiable)
|
7
|
+
[![ruby](https://github.com/invoicity/devise_slack_notifiable/workflows/Ruby/badge.svg)](https://github.com/invoicity/devise_slack_notifiable/actions)
|
8
|
+
|
5
9
|
## Installation
|
6
10
|
|
7
11
|
Add this line to your application's Gemfile:
|
data/Rakefile
CHANGED
@@ -1,8 +1,8 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'bundler/gem_tasks'
|
4
|
-
require 'rspec/core/rake_task'
|
5
|
-
|
6
|
-
RSpec::Core::RakeTask.new(:spec)
|
7
|
-
|
8
|
-
task default: :spec
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'bundler/gem_tasks'
|
4
|
+
require 'rspec/core/rake_task'
|
5
|
+
|
6
|
+
RSpec::Core::RakeTask.new(:spec)
|
7
|
+
|
8
|
+
task default: :spec
|
@@ -21,6 +21,7 @@ Gem::Specification.new do |spec|
|
|
21
21
|
spec.metadata['changelog_uri'] = 'https://github.com/invoicity/devise_slack_notifiable/releases'
|
22
22
|
|
23
23
|
spec.add_dependency 'rails'
|
24
|
+
spec.add_dependency 'devise'
|
24
25
|
spec.add_dependency 'slack-notifier'
|
25
26
|
|
26
27
|
# Specify which files should be added to the gem when it is released.
|
@@ -2,20 +2,26 @@
|
|
2
2
|
|
3
3
|
module Devise
|
4
4
|
module Models
|
5
|
+
# Slack notifications for devise models!
|
5
6
|
module SlackNotifiable
|
6
7
|
extend ActiveSupport::Concern
|
7
8
|
|
8
9
|
included do
|
10
|
+
# Rails hook
|
11
|
+
# Triggers slack registration message
|
9
12
|
after_create :registration_notification
|
10
13
|
|
11
14
|
protected
|
12
15
|
|
16
|
+
# Devise hook
|
17
|
+
# Triggers slack confirmation message
|
13
18
|
def after_confirmation
|
14
19
|
confirmation_notification
|
15
20
|
|
16
|
-
super
|
21
|
+
super if defined?(super)
|
17
22
|
end
|
18
23
|
|
24
|
+
# Sends slack notification if confirmation_message_enabled
|
19
25
|
def confirmation_notification
|
20
26
|
return unless DeviseSlackNotifiable.configuration.confirmation_message_enabled
|
21
27
|
|
@@ -24,6 +30,7 @@ module Devise
|
|
24
30
|
)
|
25
31
|
end
|
26
32
|
|
33
|
+
# Sends slack notification
|
27
34
|
def registration_notification
|
28
35
|
send_slack_notification(
|
29
36
|
DeviseSlackNotifiable.configuration.registration_message_formatter
|
@@ -32,6 +39,9 @@ module Devise
|
|
32
39
|
|
33
40
|
private
|
34
41
|
|
42
|
+
# Creates notifier and sends message
|
43
|
+
#
|
44
|
+
# @param [Proc] formatter
|
35
45
|
def send_slack_notification(formatter)
|
36
46
|
notifier = DeviseSlackNotifiable::Notifier.new
|
37
47
|
notifier.send_message(self, formatter)
|
@@ -1,6 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module DeviseSlackNotifiable
|
4
|
+
# Configuration container
|
4
5
|
class Configuration
|
5
6
|
attr_accessor :enabled,
|
6
7
|
:slack_webhook,
|
@@ -9,6 +10,9 @@ module DeviseSlackNotifiable
|
|
9
10
|
:confirmation_message_enabled,
|
10
11
|
:context_fields
|
11
12
|
|
13
|
+
# DeviseSlackNotifiable::Configuration constructor.
|
14
|
+
#
|
15
|
+
# Sets default values
|
12
16
|
def initialize
|
13
17
|
@enabled = false
|
14
18
|
@slack_webhook = nil
|
@@ -3,7 +3,13 @@
|
|
3
3
|
require 'slack-notifier'
|
4
4
|
|
5
5
|
module DeviseSlackNotifiable
|
6
|
+
# Module <-> Slack communication layer
|
7
|
+
# and payload builder
|
6
8
|
class Notifier
|
9
|
+
|
10
|
+
# DeviseSlackNotifiable::Notifier constructor.
|
11
|
+
#
|
12
|
+
# Creates Slack::Notifier instance
|
7
13
|
def initialize
|
8
14
|
return unless enabled?
|
9
15
|
|
@@ -31,18 +37,33 @@ module DeviseSlackNotifiable
|
|
31
37
|
|
32
38
|
attr_reader :client
|
33
39
|
|
40
|
+
# Integration enabled?
|
41
|
+
#
|
42
|
+
# @return [Boolean]
|
34
43
|
def enabled?
|
35
44
|
DeviseSlackNotifiable.configuration.enabled
|
36
45
|
end
|
37
46
|
|
47
|
+
# Webhook URL
|
48
|
+
#
|
49
|
+
# @return [String, NilClass]
|
38
50
|
def webhook
|
39
51
|
DeviseSlackNotifiable.configuration.slack_webhook
|
40
52
|
end
|
41
53
|
|
54
|
+
# Context fields
|
55
|
+
#
|
56
|
+
# @return [Array]
|
42
57
|
def context_fields
|
43
58
|
DeviseSlackNotifiable.configuration.context_fields
|
44
59
|
end
|
45
60
|
|
61
|
+
# Message builder
|
62
|
+
#
|
63
|
+
# @param [String] message
|
64
|
+
# @param [ActiveRecord::Base] entity
|
65
|
+
#
|
66
|
+
# @return [Hash]
|
46
67
|
def formatter(message, entity)
|
47
68
|
{
|
48
69
|
blocks: [
|
@@ -54,9 +75,6 @@ module DeviseSlackNotifiable
|
|
54
75
|
emoji: true
|
55
76
|
}
|
56
77
|
},
|
57
|
-
{
|
58
|
-
type: 'divider'
|
59
|
-
},
|
60
78
|
{
|
61
79
|
type: 'section',
|
62
80
|
text: {
|
@@ -1,5 +1,5 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module DeviseSlackNotifiable
|
4
|
-
VERSION = '0.
|
5
|
-
end
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module DeviseSlackNotifiable
|
4
|
+
VERSION = '0.2.0'
|
5
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: devise_slack_notifiable
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- whitemerry
|
@@ -24,6 +24,20 @@ dependencies:
|
|
24
24
|
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: devise
|
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: slack-notifier
|
29
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -46,6 +60,8 @@ extensions: []
|
|
46
60
|
extra_rdoc_files: []
|
47
61
|
files:
|
48
62
|
- ".editorconfig"
|
63
|
+
- ".github/workflows/gem-push.yml"
|
64
|
+
- ".github/workflows/ruby.yml"
|
49
65
|
- ".gitignore"
|
50
66
|
- ".rspec"
|
51
67
|
- ".travis.yml"
|