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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 43c93f797ec347cc95898adf7ff3db9878d5a6c5
4
- data.tar.gz: 7b6f2fb2794724e639549f6f625fa3c930d93734
3
+ metadata.gz: 027523f726fd684d6909a412d61902470dbb92d7
4
+ data.tar.gz: 4a232e9ac8a3309edbd697df6c3eac4cfa71db7b
5
5
  SHA512:
6
- metadata.gz: 7a8914973c57b03e2e6248bae9a5d45639cc9b4b81fc6133a33aa1923ae887da828c2ce4f687b7d44503f8cbaa008c14b4d218d37ff41e5ad0ee4356511531b2
7
- data.tar.gz: 9992d5d1ae2a1cde5c32e8849cc86a4297d720a54ce185d88dc4cdced1c24f4558875bbb1e4b9918022f4c9466d5640fad2fe5bbc62e101581698949be2222f5
6
+ metadata.gz: d589ec0319595fa27d317422f7e55da02635cc22d0a28ce8d5b72348cc08b573f8a478b5740e242c8a13b801662c3a487b5bc9a2c90237609e460d2a2a2fa490
7
+ data.tar.gz: b99fdac4d6fe27a5f5e3dc8250f2a8cc768ad86f7fb1444b324c07d0fe579b10dbeec79b2c28c7cdb970d3ee6b729259d5e35f097f2b83f9489c31ffa37cfb1b
data/.gitignore CHANGED
@@ -10,3 +10,4 @@
10
10
 
11
11
  # Ignore application configuration
12
12
  /config/application.yml
13
+ .idea*
data/Gemfile CHANGED
@@ -3,8 +3,9 @@ source 'https://rubygems.org'
3
3
  # Specify your gem's dependencies in slacked.gemspec
4
4
  gemspec
5
5
 
6
- gem "rails"
6
+ gem 'rails'
7
7
 
8
8
  group :test do
9
- gem "aruba", "~> 0.6.2"
9
+ gem 'aruba', '~> 0.6.2'
10
+ gem 'pry'
10
11
  end
data/README.md CHANGED
@@ -1,6 +1,8 @@
1
1
  # Slacked
2
2
 
3
- A simple and easy way to send notifications to Slack from your Rails application. 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.
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
- SLACK_MESSAGE= "TEST"
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 the message to slack use the method:
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
- SLACK_MESSAGE= "TEST"
2
+ SLACK_DEFAULT_MESSAGE= "TEST"
@@ -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
- def post message = ENV["SLACK_MESSAGE"]
5
- send = Slack::Notifier.new ENV["SLACK_WEBHOOK"]
6
- send.ping message, icon_emoji: ":ghost:"
7
- end
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
@@ -1,3 +1,3 @@
1
1
  module Slacked
2
- VERSION = "0.7.0"
2
+ VERSION = "0.8.0"
3
3
  end
@@ -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{Notify slack when an action has been completed.}
13
- spec.description = %q{Notify slack when an action has been completed.}
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 = "exe"
31
+ spec.bindir = 'exe'
27
32
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
28
- spec.require_paths = ["lib"]
33
+ spec.require_paths = ['lib']
29
34
 
30
- spec.add_development_dependency "bundler", "~> 1.10"
31
- spec.add_development_dependency "rake", "~> 10.0"
32
- spec.add_development_dependency "rspec"
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 "slack-notifier"
35
- spec.add_dependency "dotenv"
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.7.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-04 00:00:00.000000000 Z
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: Notify slack when an action has been completed.
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: Notify slack when an action has been completed.
177
+ summary: A super simple and easy way to send notifications to Slack from your Rails
178
+ application.
159
179
  test_files: []