slacked 0.9.0 → 0.9.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +28 -6
- data/lib/generators/slacked/install/install_generator.rb +15 -2
- data/lib/slacked/slack_post.rb +5 -6
- data/lib/slacked/version.rb +1 -1
- data/slacked.gemspec +1 -1
- metadata +6 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 11d1d52d36df88fa4f403b9ba8097380bae094f7
|
4
|
+
data.tar.gz: 05eb2fcda4d3744a4b326ce1cf50d622f568c80b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 05a09bc4ef9b7f6bdf126ab16f57bc5f0e29107b2fdbbc5023ef9f7020628f0983704687378ab3a448f05793f46b7505346d68c6da921613e38036077cc0ad7d
|
7
|
+
data.tar.gz: 5f0b3474f752ec00b288619629eddf1721a79e8a7110a2eb0a799f01528d2225ff85456935a3e827fbf6f78f162fff5a237e7a097a83ed986f1faf8096d3b123
|
data/README.md
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
# Slacked
|
4
4
|
|
5
|
-
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.
|
5
|
+
This is a super simple Slack integration for Ruby and for Ruby and Rails applications. 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.
|
6
6
|
|
7
7
|
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.
|
8
8
|
|
@@ -10,7 +10,15 @@ This gem can be used with a rails application and enabled/disabled based on the
|
|
10
10
|
|
11
11
|
## Getting Started
|
12
12
|
|
13
|
-
|
13
|
+
#### without rails
|
14
|
+
|
15
|
+
```ruby
|
16
|
+
gem install slacked
|
17
|
+
```
|
18
|
+
|
19
|
+
|
20
|
+
#### With rails
|
21
|
+
Add this line to your application's Gemfile:
|
14
22
|
|
15
23
|
```ruby
|
16
24
|
gem 'slacked'
|
@@ -24,7 +32,7 @@ Then run the installer:
|
|
24
32
|
|
25
33
|
$ bundle exec rails g slacked:install
|
26
34
|
|
27
|
-
This will create a .env file in the root of the rails
|
35
|
+
This will create a .env file in the root of the rails application. Specify the Webhook Url and the message to be sent.
|
28
36
|
|
29
37
|
```ruby
|
30
38
|
SLACK_WEBHOOK= "WEBHOOK_URL"
|
@@ -63,6 +71,19 @@ Slacked.post_async
|
|
63
71
|
```
|
64
72
|
The last example will use the SLACK_DEFAULT_MESSAGE value
|
65
73
|
|
74
|
+
### To pass the config:
|
75
|
+
|
76
|
+
```ruby
|
77
|
+
Slacked.post "I have a message from the underworld!", {icon_emoji: ':ghost:'}
|
78
|
+
```
|
79
|
+
|
80
|
+
or
|
81
|
+
```ruby
|
82
|
+
Slacked.post_async "Let's play fetch!", {icon_emoji: ':dog:'}
|
83
|
+
```
|
84
|
+
|
85
|
+
Right now we only have the config for the icon, if you need another one let us know or submit a pull request.
|
86
|
+
|
66
87
|
## Example
|
67
88
|
|
68
89
|
```ruby
|
@@ -70,7 +91,7 @@ class Post < ActiveRecord::Base
|
|
70
91
|
after_create :slacked
|
71
92
|
|
72
93
|
private
|
73
|
-
|
94
|
+
|
74
95
|
def slacked
|
75
96
|
Slacked.post 'post created!'
|
76
97
|
end
|
@@ -88,10 +109,11 @@ The default value is false
|
|
88
109
|
|
89
110
|
## Contributors
|
90
111
|
|
91
|
-
- [Sean H.](https://github.com/seathony)
|
92
112
|
- [Kaio Magalhães](https://github.com/kaiomagalhaes)
|
113
|
+
- [Lockyy](https://github.com/Lockyy)
|
114
|
+
- [Sean H.](https://github.com/seathony)
|
115
|
+
|
93
116
|
|
94
117
|
## License
|
95
118
|
|
96
119
|
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
97
|
-
|
@@ -1,10 +1,23 @@
|
|
1
1
|
module Slacked
|
2
2
|
module Generators
|
3
3
|
class InstallGenerator < ::Rails::Generators::Base
|
4
|
-
source_root File.expand_path(
|
4
|
+
source_root File.expand_path('../templates', __FILE__)
|
5
|
+
|
6
|
+
desc 'Copy a Slacked file to your appplication'
|
5
7
|
|
6
8
|
def create_configuration
|
7
|
-
|
9
|
+
file_name = '.env'
|
10
|
+
|
11
|
+
if !File.exist?(file_name)
|
12
|
+
copy_file(file_name, file_name)
|
13
|
+
elsif !File.readlines(file_name).grep(/SLACK_/).any?
|
14
|
+
template_dir = self.class.source_root
|
15
|
+
lines = "\n"
|
16
|
+
File.readlines("#{template_dir}/#{file_name}").each do |line|
|
17
|
+
lines << line
|
18
|
+
end
|
19
|
+
append_file(file_name, lines)
|
20
|
+
end
|
8
21
|
end
|
9
22
|
end
|
10
23
|
end
|
data/lib/slacked/slack_post.rb
CHANGED
@@ -2,20 +2,19 @@ module Slacked
|
|
2
2
|
SLACK_PROFILE_IMAGE=':robot_face:'
|
3
3
|
SLACK_WEBHOOK_URL_KEY='SLACK_WEBHOOK'
|
4
4
|
SLACK_DEFAULT_MESSAGE_KEY='SLACK_DEFAULT_MESSAGE'
|
5
|
-
|
5
|
+
SLACK_DEFAULT_CONFIG= {
|
6
6
|
icon_emoji: SLACK_PROFILE_IMAGE
|
7
7
|
}
|
8
8
|
|
9
9
|
class << self
|
10
|
-
def post message = ENV[SLACK_DEFAULT_MESSAGE_KEY]
|
10
|
+
def post message = ENV[SLACK_DEFAULT_MESSAGE_KEY], config = SLACK_DEFAULT_CONFIG
|
11
11
|
return false if message.nil? || message.empty? || disabled?
|
12
|
-
|
13
|
-
notifier.ping message, SLACK_CONFIG
|
12
|
+
slack_notifier.ping message, SLACK_DEFAULT_CONFIG.merge(config)
|
14
13
|
end
|
15
14
|
|
16
|
-
def post_async message
|
15
|
+
def post_async message= ENV[SLACK_DEFAULT_MESSAGE_KEY], config = SLACK_DEFAULT_CONFIG
|
17
16
|
Thread.start do
|
18
|
-
result = post(message)
|
17
|
+
result = post(message, config)
|
19
18
|
defined?(ActiveRecord) ? ActiveRecord::Base.connection.close : nil
|
20
19
|
result
|
21
20
|
end
|
data/lib/slacked/version.rb
CHANGED
data/slacked.gemspec
CHANGED
@@ -32,7 +32,7 @@ Gem::Specification.new do |spec|
|
|
32
32
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
33
33
|
spec.require_paths = ['lib']
|
34
34
|
|
35
|
-
spec.add_development_dependency 'bundler'
|
35
|
+
spec.add_development_dependency 'bundler'
|
36
36
|
spec.add_development_dependency 'rake', '~> 10.0'
|
37
37
|
spec.add_development_dependency 'rspec'
|
38
38
|
spec.add_development_dependency 'rspec-mocks'
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: slacked
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.9.
|
4
|
+
version: 0.9.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sean
|
@@ -10,22 +10,22 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: exe
|
12
12
|
cert_chain: []
|
13
|
-
date: 2015-12-
|
13
|
+
date: 2015-12-19 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: bundler
|
17
17
|
requirement: !ruby/object:Gem::Requirement
|
18
18
|
requirements:
|
19
|
-
- - "
|
19
|
+
- - ">="
|
20
20
|
- !ruby/object:Gem::Version
|
21
|
-
version: '
|
21
|
+
version: '0'
|
22
22
|
type: :development
|
23
23
|
prerelease: false
|
24
24
|
version_requirements: !ruby/object:Gem::Requirement
|
25
25
|
requirements:
|
26
|
-
- - "
|
26
|
+
- - ">="
|
27
27
|
- !ruby/object:Gem::Version
|
28
|
-
version: '
|
28
|
+
version: '0'
|
29
29
|
- !ruby/object:Gem::Dependency
|
30
30
|
name: rake
|
31
31
|
requirement: !ruby/object:Gem::Requirement
|