slacked 0.7.0 → 0.8.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/Gemfile +3 -2
- data/README.md +30 -4
- data/lib/generators/slacked/install/templates/.env +1 -1
- data/lib/slacked/slack_post.rb +24 -4
- data/lib/slacked/version.rb +1 -1
- data/slacked.gemspec +15 -9
- metadata +24 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 027523f726fd684d6909a412d61902470dbb92d7
|
4
|
+
data.tar.gz: 4a232e9ac8a3309edbd697df6c3eac4cfa71db7b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d589ec0319595fa27d317422f7e55da02635cc22d0a28ce8d5b72348cc08b573f8a478b5740e242c8a13b801662c3a487b5bc9a2c90237609e460d2a2a2fa490
|
7
|
+
data.tar.gz: b99fdac4d6fe27a5f5e3dc8250f2a8cc768ad86f7fb1444b324c07d0fe579b10dbeec79b2c28c7cdb970d3ee6b729259d5e35f097f2b83f9489c31ffa37cfb1b
|
data/.gitignore
CHANGED
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -1,6 +1,8 @@
|
|
1
1
|
# Slacked
|
2
2
|
|
3
|
-
|
3
|
+
This is a super simple Slack integration for Rails. A use case for this would be to post a notification in Slack when a new User is created or a certain action has been taken in your application.
|
4
|
+
|
5
|
+
Are there other gems that provide similar functionality? Yes. Do some of them provide more flexibility? Yes. The point of this was to make installing and integrating a 30 second process.
|
4
6
|
|
5
7
|
## Getting Started
|
6
8
|
|
@@ -22,17 +24,40 @@ This will create a .env file in the root of the rails appication. Specify the We
|
|
22
24
|
|
23
25
|
```ruby
|
24
26
|
SLACK_WEBHOOK= "WEBHOOK_URL"
|
25
|
-
|
27
|
+
SLACK_DEFAULT_MESSAGE= "TEST"
|
26
28
|
```
|
27
29
|
|
28
30
|
|
29
31
|
## Usage
|
32
|
+
Set the SLACK_WEBOOK env variable with the value of the webhook which you want to send the messages.
|
33
|
+
If you want to send a unique message in your application like 'Application is running' you can set the SLACK_DEFAULT_MESSAGE and call the message methods without sending an argument.
|
34
|
+
|
30
35
|
|
31
|
-
To send
|
36
|
+
### To send a sync message to slack use the method:
|
37
|
+
|
38
|
+
```ruby
|
39
|
+
Slacked.post "This is a test post"
|
40
|
+
```
|
41
|
+
|
42
|
+
or
|
32
43
|
|
33
44
|
```ruby
|
34
45
|
Slacked.post
|
35
46
|
```
|
47
|
+
The last example will use the SLACK_DEFAULT_MESSAGE value
|
48
|
+
|
49
|
+
### To send an async message to slack use the method:
|
50
|
+
|
51
|
+
```ruby
|
52
|
+
Slacked.post_async "This is a test post"
|
53
|
+
```
|
54
|
+
|
55
|
+
or
|
56
|
+
|
57
|
+
```ruby
|
58
|
+
Slacked.post_async
|
59
|
+
```
|
60
|
+
The last example will use the SLACK_DEFAULT_MESSAGE value
|
36
61
|
|
37
62
|
## Example
|
38
63
|
|
@@ -43,7 +68,7 @@ class Post < ActiveRecord::Base
|
|
43
68
|
private
|
44
69
|
|
45
70
|
def slacked
|
46
|
-
Slacked.post
|
71
|
+
Slacked.post 'post created!'
|
47
72
|
end
|
48
73
|
end
|
49
74
|
```
|
@@ -51,6 +76,7 @@ end
|
|
51
76
|
## Contributors
|
52
77
|
|
53
78
|
- [Sean H.](https://github.com/seathony)
|
79
|
+
- [Kaio Magalhães](https://github.com/kaiomagalhaes)
|
54
80
|
|
55
81
|
## License
|
56
82
|
|
@@ -1,2 +1,2 @@
|
|
1
1
|
SLACK_WEBHOOK= "WEBHOOK_URL"
|
2
|
-
|
2
|
+
SLACK_DEFAULT_MESSAGE= "TEST"
|
data/lib/slacked/slack_post.rb
CHANGED
@@ -1,9 +1,29 @@
|
|
1
1
|
module Slacked
|
2
|
+
SLACK_PROFILE_IMAGE=':robot_face:'
|
3
|
+
SLACK_WEBHOOK_URL_KEY='SLACK_WEBHOOK'
|
4
|
+
SLACK_DEFAULT_MESSAGE_KEY='SLACK_DEFAULT_MESSAGE'
|
5
|
+
SLACK_CONFIG= {
|
6
|
+
icon_emoji: SLACK_PROFILE_IMAGE
|
7
|
+
}
|
8
|
+
|
2
9
|
class << self
|
10
|
+
def post message = ENV[SLACK_DEFAULT_MESSAGE_KEY]
|
11
|
+
return false if message.nil? || message.empty?
|
12
|
+
notifier = slack_notifier
|
13
|
+
notifier.ping message, SLACK_CONFIG
|
14
|
+
end
|
15
|
+
|
16
|
+
def post_async message
|
17
|
+
Thread.start do
|
18
|
+
result = post(message)
|
19
|
+
defined?(ActiveRecord) ? ActiveRecord::Base.connection.close : nil
|
20
|
+
result
|
21
|
+
end
|
22
|
+
end
|
3
23
|
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
24
|
+
private
|
25
|
+
def slack_notifier webhook_url = ENV[SLACK_WEBHOOK_URL_KEY]
|
26
|
+
Slack::Notifier.new webhook_url
|
27
|
+
end
|
8
28
|
end
|
9
29
|
end
|
data/lib/slacked/version.rb
CHANGED
data/slacked.gemspec
CHANGED
@@ -9,8 +9,13 @@ Gem::Specification.new do |spec|
|
|
9
9
|
spec.authors = ["sean"]
|
10
10
|
spec.email = ["seathony@gmail.com"]
|
11
11
|
|
12
|
-
spec.summary = %q{
|
13
|
-
spec.description = %q{
|
12
|
+
spec.summary = %q{A super simple and easy way to send notifications to Slack from your Rails application.}
|
13
|
+
spec.description = %q{This is a super simple Slack integration for Rails. A use case for this would be to post
|
14
|
+
a notification in Slack when a new User is created or a certain action has been taken in
|
15
|
+
your application.
|
16
|
+
Are there other gems that provide similar functionality? Yes. Do some of them provide more
|
17
|
+
flexibility? Yes. The point of this was to make installing and integrating a 30 second process.}
|
18
|
+
|
14
19
|
spec.homepage = "https://github.com/codelittinc/slacked"
|
15
20
|
spec.license = "MIT"
|
16
21
|
|
@@ -23,16 +28,17 @@ Gem::Specification.new do |spec|
|
|
23
28
|
end
|
24
29
|
|
25
30
|
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
26
|
-
spec.bindir =
|
31
|
+
spec.bindir = 'exe'
|
27
32
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
28
|
-
spec.require_paths = [
|
33
|
+
spec.require_paths = ['lib']
|
29
34
|
|
30
|
-
spec.add_development_dependency
|
31
|
-
spec.add_development_dependency
|
32
|
-
spec.add_development_dependency
|
35
|
+
spec.add_development_dependency 'bundler', '~> 1.10'
|
36
|
+
spec.add_development_dependency 'rake', '~> 10.0'
|
37
|
+
spec.add_development_dependency 'rspec'
|
38
|
+
spec.add_development_dependency 'rspec-mocks'
|
33
39
|
|
34
|
-
spec.add_dependency
|
35
|
-
spec.add_dependency
|
40
|
+
spec.add_dependency 'slack-notifier'
|
41
|
+
spec.add_dependency 'dotenv'
|
36
42
|
spec.add_dependency 'thor'
|
37
43
|
spec.add_dependency 'httparty'
|
38
44
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: slacked
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.8.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- sean
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-12-
|
11
|
+
date: 2015-12-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -52,6 +52,20 @@ dependencies:
|
|
52
52
|
- - ">="
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rspec-mocks
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
55
69
|
- !ruby/object:Gem::Dependency
|
56
70
|
name: slack-notifier
|
57
71
|
requirement: !ruby/object:Gem::Requirement
|
@@ -108,7 +122,12 @@ dependencies:
|
|
108
122
|
- - ">="
|
109
123
|
- !ruby/object:Gem::Version
|
110
124
|
version: '0'
|
111
|
-
description:
|
125
|
+
description: |-
|
126
|
+
This is a super simple Slack integration for Rails. A use case for this would be to post
|
127
|
+
a notification in Slack when a new User is created or a certain action has been taken in
|
128
|
+
your application.
|
129
|
+
Are there other gems that provide similar functionality? Yes. Do some of them provide more
|
130
|
+
flexibility? Yes. The point of this was to make installing and integrating a 30 second process.
|
112
131
|
email:
|
113
132
|
- seathony@gmail.com
|
114
133
|
executables: []
|
@@ -155,5 +174,6 @@ rubyforge_project:
|
|
155
174
|
rubygems_version: 2.4.8
|
156
175
|
signing_key:
|
157
176
|
specification_version: 4
|
158
|
-
summary:
|
177
|
+
summary: A super simple and easy way to send notifications to Slack from your Rails
|
178
|
+
application.
|
159
179
|
test_files: []
|