mina_slack_promulgator 1.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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: b4194861d3772ccc75df47a4ef9187f4f12bbad9
4
+ data.tar.gz: 386cacff0ad97f94af85a1fa9355a8d4e852d311
5
+ SHA512:
6
+ metadata.gz: 2296325c5b6cde5327908181817f267c9af942e926d8eff4580cb0579ea0e20e7faacf4a79b484dd29cda15c6a99326700182e2f10fcb36c135e1ef454ec6387
7
+ data.tar.gz: 5fc08f501526234ee4632b4bfcab25bd5875ae9d6b0d33a7e2b9c0998d9dc47bff251f6da7cf453ee8897a358a7d0b41c667d5504c3ac6638dd10bc805d40602
data/.gitignore ADDED
@@ -0,0 +1,18 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ .DS_Store
7
+ Gemfile.lock
8
+ InstalledFiles
9
+ _yardoc
10
+ coverage
11
+ doc/
12
+ lib/bundler/man
13
+ pkg
14
+ rdoc
15
+ spec/reports
16
+ test/tmp
17
+ test/version_tmp
18
+ tmp
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in mina_slack_promulgator.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2015 Evan Closson
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,45 @@
1
+ # MinaSlackPromulgator
2
+
3
+ Simple mina deploy success/failure notifications to slack channels.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'mina_slack_promulgator'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install mina_slack_promulgator
18
+
19
+ ## Usage
20
+
21
+ Require within your mina deploy.rb:
22
+
23
+ require 'mina/slack/promulgator'
24
+
25
+ Call success on launch in deploy.rb:
26
+
27
+ to :launch do
28
+ { ... other launch tasks ... }
29
+ invoke :'slack:promulgator:success'
30
+ end
31
+
32
+ Call failure on clean in deploy.rb:
33
+
34
+ to :clean do
35
+ { ... other cleanup tasks ... }
36
+ invoke :'slack:promulgator:failure'
37
+ end
38
+
39
+ ## Contributing
40
+
41
+ 1. Fork it ( http://github.com/eclosson/mina_slack_promulgator/fork )
42
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
43
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
44
+ 4. Push to the branch (`git push origin my-new-feature`)
45
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,37 @@
1
+ module Mina
2
+ module Slack
3
+ module Promulgator
4
+ class Helper
5
+
6
+ def self.requirements_check(slack_promulgator_webhook_url)
7
+ raise "Must set 'slack_promulgator_webhook_url' in your deploy file for promulgator to work" unless slack_promulgator_webhook_url
8
+ end
9
+
10
+ def self.default_github_url
11
+ remote_origin_url = `git config --get remote.origin.url`
12
+ path = remote_origin_url.gsub("git@", "").gsub(".git", "").gsub("github.com:", "github.com/")
13
+ "https://#{path}".strip
14
+ end
15
+
16
+ def self.success_message(emoji, project_name, github_url)
17
+ "#{emoji} [#{project_name}] deployed: #{github_url}/commit/'\"$GIT_HASH\"'"
18
+ end
19
+
20
+ def self.failure_message(emoji, project_name, github_url)
21
+ "#{emoji} [#{project_name}] deploy failed: #{github_url}/commit/'\"$GIT_HASH\"'"
22
+ end
23
+
24
+ def self.success_payload(text, channel, name, application_emoji)
25
+ %{{"text": "#{text}", "channel": "#{channel}", "username": "#{name}", "icon_emoji": "#{application_emoji}"}}
26
+ end
27
+
28
+ def self.failure_payload(text, channel, name, application_emoji)
29
+ %{{"attachments": [ { "fallback": "#{text}", "color": "danger", "text": "#{text}" } ], "channel": "#{channel}", "username": "#{name}", "icon_emoji": "#{application_emoji}"}}
30
+ end
31
+
32
+ end
33
+ end
34
+ end
35
+ end
36
+
37
+
@@ -0,0 +1,7 @@
1
+ module Mina
2
+ module Slack
3
+ module Promulgator
4
+ VERSION = "1.0.0"
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,44 @@
1
+ require "mina/slack/promulgator/version"
2
+ require "mina/slack/promulgator/helper"
3
+
4
+ set_default :slack_promulgator_webhook_url, nil
5
+ set_default :slack_promulgator_channel, '#general'
6
+ set_default :slack_promulgator_name, 'Promulgator'
7
+ set_default :slack_promulgator_application_emoji, ':earth_americas:'
8
+ set_default :slack_promulgator_success_message_emoji, ':rocket:'
9
+ set_default :slack_promulgator_failure_message_emoji, ':boom:'
10
+ set_default :slack_promulgator_github_url, Mina::Slack::Promulgator::Helper.default_github_url
11
+
12
+ namespace :slack do
13
+
14
+ namespace :promulgator do
15
+
16
+ task :success do
17
+ Mina::Slack::Promulgator::Helper.requirements_check(slack_promulgator_webhook_url)
18
+
19
+ message = Mina::Slack::Promulgator::Helper.success_message(slack_promulgator_success_message_emoji, project_name, slack_promulgator_github_url)
20
+ payload = Mina::Slack::Promulgator::Helper.success_payload(message, slack_promulgator_channel, slack_promulgator_name, slack_promulgator_application_emoji)
21
+
22
+ queue %{
23
+ export GIT_HASH=$(cd #{deploy_to}/scm && git rev-parse #{commit || branch})
24
+ echo "-----> Posting Deploy Success to Slack #{slack_promulgator_channel}"
25
+ curl -X POST --data-urlencode 'payload=#{payload}' #{slack_promulgator_webhook_url}
26
+ }
27
+ end
28
+
29
+ task :failure do
30
+ Mina::Slack::Promulgator::Helper.requirements_check(slack_promulgator_webhook_url)
31
+
32
+ message = Mina::Slack::Promulgator::Helper.failure_message(slack_promulgator_failure_message_emoji, project_name, slack_promulgator_github_url)
33
+ payload = Mina::Slack::Promulgator::Helper.failure_payload(message, slack_promulgator_channel, slack_promulgator_name, slack_promulgator_application_emoji)
34
+
35
+ queue %{
36
+ export GIT_HASH=$(cd #{deploy_to}/scm && git rev-parse #{commit || branch})
37
+ echo "-----> Posting Deploy Failure to Slack #{slack_promulgator_channel}"
38
+ curl -X POST --data-urlencode 'payload=#{payload}' #{slack_promulgator_webhook_url}
39
+ }
40
+ end
41
+
42
+ end
43
+
44
+ end
@@ -0,0 +1,23 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'mina/slack/promulgator/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "mina_slack_promulgator"
8
+ spec.version = Mina::Slack::Promulgator::VERSION
9
+ spec.authors = ["Evan Closson", "Matthew Powers"]
10
+ spec.email = ["eclosson@medivo.com", "mpowers@medivo.com"]
11
+ spec.summary = %q{Mina Deploy Notifications in Slack}
12
+ spec.description = %q{Mina Deploy Notifications in Slack.}
13
+ spec.homepage = ""
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0")
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_development_dependency "bundler", "~> 1.5"
22
+ spec.add_development_dependency "rake"
23
+ end
metadata ADDED
@@ -0,0 +1,83 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: mina_slack_promulgator
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Evan Closson
8
+ - Matthew Powers
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2015-09-01 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: bundler
16
+ requirement: !ruby/object:Gem::Requirement
17
+ requirements:
18
+ - - ~>
19
+ - !ruby/object:Gem::Version
20
+ version: '1.5'
21
+ type: :development
22
+ prerelease: false
23
+ version_requirements: !ruby/object:Gem::Requirement
24
+ requirements:
25
+ - - ~>
26
+ - !ruby/object:Gem::Version
27
+ version: '1.5'
28
+ - !ruby/object:Gem::Dependency
29
+ name: rake
30
+ requirement: !ruby/object:Gem::Requirement
31
+ requirements:
32
+ - - '>='
33
+ - !ruby/object:Gem::Version
34
+ version: '0'
35
+ type: :development
36
+ prerelease: false
37
+ version_requirements: !ruby/object:Gem::Requirement
38
+ requirements:
39
+ - - '>='
40
+ - !ruby/object:Gem::Version
41
+ version: '0'
42
+ description: Mina Deploy Notifications in Slack.
43
+ email:
44
+ - eclosson@medivo.com
45
+ - mpowers@medivo.com
46
+ executables: []
47
+ extensions: []
48
+ extra_rdoc_files: []
49
+ files:
50
+ - .gitignore
51
+ - Gemfile
52
+ - LICENSE.txt
53
+ - README.md
54
+ - Rakefile
55
+ - lib/mina/slack/promulgator.rb
56
+ - lib/mina/slack/promulgator/helper.rb
57
+ - lib/mina/slack/promulgator/version.rb
58
+ - mina_slack_promulgator.gemspec
59
+ homepage: ''
60
+ licenses:
61
+ - MIT
62
+ metadata: {}
63
+ post_install_message:
64
+ rdoc_options: []
65
+ require_paths:
66
+ - lib
67
+ required_ruby_version: !ruby/object:Gem::Requirement
68
+ requirements:
69
+ - - '>='
70
+ - !ruby/object:Gem::Version
71
+ version: '0'
72
+ required_rubygems_version: !ruby/object:Gem::Requirement
73
+ requirements:
74
+ - - '>='
75
+ - !ruby/object:Gem::Version
76
+ version: '0'
77
+ requirements: []
78
+ rubyforge_project:
79
+ rubygems_version: 2.1.5
80
+ signing_key:
81
+ specification_version: 4
82
+ summary: Mina Deploy Notifications in Slack
83
+ test_files: []