slackistrano 1.1.0 → 2.0.0
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/CHANGELOG.md +7 -0
- data/README.md +7 -2
- data/lib/slackistrano.rb +0 -44
- data/lib/slackistrano/capistrano.rb +50 -0
- data/lib/slackistrano/version.rb +1 -1
- data/slackistrano.gemspec +16 -0
- data/spec/spec_helper.rb +2 -0
- metadata +8 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7aee7cb384807fb00bce41d808dcf1c147673237
|
4
|
+
data.tar.gz: 6849e3a8506f73c0efc7002afc34c42ee2ae88fc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c7b9457420f08b96541d278ce5ef92a57d178b49c321a4bf3036b478a4a2c8d63f177b155d5b75bc0fc646b73a20aea3cf4fdd1debbf23f57812ca5245ffc34b
|
7
|
+
data.tar.gz: 7a61dec6f4c406987ea4d797d1a1ed5447af0b070349b77fc2cd92d241baa1c00a9d875059ee7be8eee136c2be1ee639a69fcd8654ab04c3f8d13d311f1ea7c3
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,12 @@
|
|
1
1
|
# Slackistrano Change Log
|
2
2
|
|
3
|
+
2.0.0
|
4
|
+
-----
|
5
|
+
|
6
|
+
- **BREAKING:** You must now `require 'slackistrano/capistrano'` in your Capfile.
|
7
|
+
Previously it was just `require 'slackistrano'`. It is also no longer necessary
|
8
|
+
to add `require: false` in your Gemfile, but it won't hurt to leave it.
|
9
|
+
|
3
10
|
1.1.0
|
4
11
|
-----
|
5
12
|
|
data/README.md
CHANGED
@@ -8,6 +8,11 @@ Send notifications to [Slack](https://slack.com) about [Capistrano](http://www.c
|
|
8
8
|
|
9
9
|
If you need Capistrano v2 support, check out [capistrano-slack](https://github.com/j-mcnally/capistrano-slack).
|
10
10
|
|
11
|
+
## NOTE: Upgrading from 1.x? Not Getting Notifications?
|
12
|
+
|
13
|
+
Version 2.0 has changed how Slackistrano must be loaded in your Gemfile and Capfile. See the *Installation* section
|
14
|
+
below current install.
|
15
|
+
|
11
16
|
## Requirements
|
12
17
|
|
13
18
|
- Capistrano >= 3.1.0
|
@@ -19,7 +24,7 @@ If you need Capistrano v2 support, check out [capistrano-slack](https://github.c
|
|
19
24
|
Add this line to your application's Gemfile:
|
20
25
|
|
21
26
|
```ruby
|
22
|
-
gem 'slackistrano'
|
27
|
+
gem 'slackistrano'
|
23
28
|
```
|
24
29
|
|
25
30
|
And then execute:
|
@@ -40,7 +45,7 @@ In both case, you need to enable the integration inside Slack and get the token
|
|
40
45
|
Require the library in your application's Capfile:
|
41
46
|
|
42
47
|
```ruby
|
43
|
-
require 'slackistrano'
|
48
|
+
require 'slackistrano/capistrano'
|
44
49
|
```
|
45
50
|
|
46
51
|
If you post using *Incoming Webhooks* you need to set your webhook url in your application's config/deploy.rb:
|
data/lib/slackistrano.rb
CHANGED
@@ -2,50 +2,6 @@ require 'slackistrano/version'
|
|
2
2
|
require 'net/http'
|
3
3
|
require 'json'
|
4
4
|
|
5
|
-
load File.expand_path("../slackistrano/tasks/slack.rake", __FILE__)
|
6
|
-
|
7
5
|
module Slackistrano
|
8
6
|
|
9
|
-
#
|
10
|
-
#
|
11
|
-
#
|
12
|
-
def self.post(team: nil, token: nil, webhook: nil, via_slackbot: false, payload: {})
|
13
|
-
if via_slackbot
|
14
|
-
post_as_slackbot(team: team, token: token, webhook: webhook, payload: payload)
|
15
|
-
else
|
16
|
-
post_as_webhook(team: team, token: token, webhook: webhook, payload: payload)
|
17
|
-
end
|
18
|
-
rescue => e
|
19
|
-
error("[slackistrano] Error notifying Slack!")
|
20
|
-
error("[slackistrano] Error: #{e.inspect}")
|
21
|
-
end
|
22
|
-
|
23
|
-
#
|
24
|
-
#
|
25
|
-
#
|
26
|
-
def self.post_as_slackbot(team: nil, token: nil, webhook: nil, payload: {})
|
27
|
-
uri = URI(URI.encode("https://#{team}.slack.com/services/hooks/slackbot?token=#{token}&channel=#{payload[:channel]}"))
|
28
|
-
|
29
|
-
text = payload[:attachments].collect { |a| a[:text] }.join("\n")
|
30
|
-
|
31
|
-
Net::HTTP.start(uri.host, uri.port, use_ssl: true) do |http|
|
32
|
-
http.request_post uri, text
|
33
|
-
end
|
34
|
-
end
|
35
|
-
|
36
|
-
#
|
37
|
-
#
|
38
|
-
#
|
39
|
-
def self.post_as_webhook(team: nil, token: nil, webhook: nil, payload: {})
|
40
|
-
params = {'payload' => payload.to_json}
|
41
|
-
|
42
|
-
if webhook.nil?
|
43
|
-
webhook = "https://#{team}.slack.com/services/hooks/incoming-webhook"
|
44
|
-
params.merge!('token' => token)
|
45
|
-
end
|
46
|
-
|
47
|
-
uri = URI(webhook)
|
48
|
-
Net::HTTP.post_form(uri, params)
|
49
|
-
end
|
50
|
-
|
51
7
|
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
require 'net/http'
|
2
|
+
require 'json'
|
3
|
+
|
4
|
+
load File.expand_path("../tasks/slack.rake", __FILE__)
|
5
|
+
|
6
|
+
module Slackistrano
|
7
|
+
|
8
|
+
#
|
9
|
+
#
|
10
|
+
#
|
11
|
+
def self.post(team: nil, token: nil, webhook: nil, via_slackbot: false, payload: {})
|
12
|
+
if via_slackbot
|
13
|
+
post_as_slackbot(team: team, token: token, webhook: webhook, payload: payload)
|
14
|
+
else
|
15
|
+
post_as_webhook(team: team, token: token, webhook: webhook, payload: payload)
|
16
|
+
end
|
17
|
+
rescue => e
|
18
|
+
error("[slackistrano] Error notifying Slack!")
|
19
|
+
error("[slackistrano] Error: #{e.inspect}")
|
20
|
+
end
|
21
|
+
|
22
|
+
#
|
23
|
+
#
|
24
|
+
#
|
25
|
+
def self.post_as_slackbot(team: nil, token: nil, webhook: nil, payload: {})
|
26
|
+
uri = URI(URI.encode("https://#{team}.slack.com/services/hooks/slackbot?token=#{token}&channel=#{payload[:channel]}"))
|
27
|
+
|
28
|
+
text = payload[:attachments].collect { |a| a[:text] }.join("\n")
|
29
|
+
|
30
|
+
Net::HTTP.start(uri.host, uri.port, use_ssl: true) do |http|
|
31
|
+
http.request_post uri, text
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
#
|
36
|
+
#
|
37
|
+
#
|
38
|
+
def self.post_as_webhook(team: nil, token: nil, webhook: nil, payload: {})
|
39
|
+
params = {'payload' => payload.to_json}
|
40
|
+
|
41
|
+
if webhook.nil?
|
42
|
+
webhook = "https://#{team}.slack.com/services/hooks/incoming-webhook"
|
43
|
+
params.merge!('token' => token)
|
44
|
+
end
|
45
|
+
|
46
|
+
uri = URI(webhook)
|
47
|
+
Net::HTTP.post_form(uri, params)
|
48
|
+
end
|
49
|
+
|
50
|
+
end
|
data/lib/slackistrano/version.rb
CHANGED
data/slackistrano.gemspec
CHANGED
@@ -25,4 +25,20 @@ Gem::Specification.new do |gem|
|
|
25
25
|
gem.add_development_dependency 'rake'
|
26
26
|
gem.add_development_dependency 'rspec'
|
27
27
|
gem.add_development_dependency 'pry'
|
28
|
+
|
29
|
+
gem.post_install_message = %Q{
|
30
|
+
BREAKING: You must now `require 'slackistrano/capistrano'` in your Capfile.
|
31
|
+
Previously it was just `require 'slackistrano'`. It is also no longer necessary
|
32
|
+
to add `require: false` in your Gemfile, but it won't hurt to leave it.
|
33
|
+
|
34
|
+
Your files should now look like this:
|
35
|
+
|
36
|
+
Gemfile:
|
37
|
+
|
38
|
+
gem 'slackistrano'
|
39
|
+
|
40
|
+
Capfile:
|
41
|
+
|
42
|
+
require 'slackistrano/capistrano'
|
43
|
+
}
|
28
44
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -4,6 +4,7 @@ require 'capistrano/all'
|
|
4
4
|
require 'capistrano/setup'
|
5
5
|
load 'capistrano_deploy_stubs.rake'
|
6
6
|
require 'slackistrano'
|
7
|
+
require 'slackistrano/capistrano'
|
7
8
|
require 'rspec'
|
8
9
|
|
9
10
|
# Requires supporting files with custom matchers and macros, etc,
|
@@ -14,4 +15,5 @@ RSpec.configure do |config|
|
|
14
15
|
config.order = 'random'
|
15
16
|
config.filter_run :focus
|
16
17
|
config.run_all_when_everything_filtered = true
|
18
|
+
config.fail_fast = 1
|
17
19
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: slackistrano
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 2.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Philip Hallstrom
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-01-
|
11
|
+
date: 2016-01-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: capistrano
|
@@ -96,6 +96,7 @@ files:
|
|
96
96
|
- Rakefile
|
97
97
|
- examples/fomatting_with_fields.png
|
98
98
|
- lib/slackistrano.rb
|
99
|
+
- lib/slackistrano/capistrano.rb
|
99
100
|
- lib/slackistrano/tasks/slack.rake
|
100
101
|
- lib/slackistrano/version.rb
|
101
102
|
- slackistrano.gemspec
|
@@ -106,7 +107,11 @@ homepage: https://github.com/phallstrom/slackistrano
|
|
106
107
|
licenses:
|
107
108
|
- MIT
|
108
109
|
metadata: {}
|
109
|
-
post_install_message:
|
110
|
+
post_install_message: "\n BREAKING: You must now `require 'slackistrano/capistrano'`
|
111
|
+
in your Capfile.\n Previously it was just `require 'slackistrano'`. It is also
|
112
|
+
no longer necessary\n to add `require: false` in your Gemfile, but it won't hurt
|
113
|
+
to leave it.\n\n Your files should now look like this:\n\n Gemfile:\n\n gem
|
114
|
+
'slackistrano'\n\n Capfile:\n\n require 'slackistrano/capistrano'\n "
|
110
115
|
rdoc_options: []
|
111
116
|
require_paths:
|
112
117
|
- lib
|