bearychat-notifier 0.0.5 → 0.0.6

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 5fa9b8632f7fc862ba434639e8d432ac87acaeaa
4
- data.tar.gz: 06078fb1302702835b2c5eaf8c1cac425878b13f
3
+ metadata.gz: a39956f764203265f908738642193d187ad3956c
4
+ data.tar.gz: 7d27732444bef027978f7a3bc636c014a115d730
5
5
  SHA512:
6
- metadata.gz: 637f9195a55dc49e2a50530fb8e91088ba90761ceb64f119ead041de252e44829ab1e79ac316e8539cc9fd7c50e28c2fec921d78bd1fbe32dfaeaaa4d1b41865
7
- data.tar.gz: d6de2c766283ed34f84b8d612d9e7a885864bc615e8fd37c1670d26c6eb182c823d4e0af0b15a73f4893172b81105d5654fe2e4e6250ec38e64b520f5a9d1c61
6
+ metadata.gz: 06c6f48f7a1e635dd01c65e99d2b67d19a95e8ab8bc37a6655331d14148ac8b39d07e2bc43338e8f9d0cf9f5ea58ed95b7ed39ccf5a8b6cf22375b54324cde07
7
+ data.tar.gz: 3c71a9e3cc9eabe78959e1d46f90bc37d61551481f34ca7be7be4353757c900ba2a5313ccccf563859d07e1ce08619ff6e7c6ff8c5f45732b1917dc6031d2424
data/README.md CHANGED
@@ -54,7 +54,28 @@ Rails.application.config.middleware.use ExceptionNotification::Rack,
54
54
  attachments: []
55
55
  }
56
56
  ```
57
+ ## With Capistrano3(git)
57
58
 
59
+ ```
60
+ require 'bearychat-notifier/capistrano'
61
+
62
+ set :bearychat_hook, your_bearychat_hook_uri
63
+ ```
64
+
65
+ #### options
66
+ ```
67
+ #default: true
68
+ set :bearychat_enabled
69
+
70
+ #default: #E51C23
71
+ set :bearychat_failed_color
72
+
73
+ #default: #259B24
74
+ set :bearychat_successed_color
75
+
76
+ #default: #FFC107
77
+ set :bearychat_starting_color
78
+ ```
58
79
 
59
80
  ## Contributing
60
81
 
@@ -0,0 +1 @@
1
+ load File.expand_path('capistrano/tasks/bearychat.rake', File.dirname(__FILE__))
@@ -0,0 +1,64 @@
1
+ require 'bearychat-notifier'
2
+
3
+ namespace :bearychat do
4
+ task :notify_deploy_started do
5
+ attachments = [{title: "#{default_title('is deploying')}" , color: starting_color }]
6
+ send_message nil, attachments
7
+ end
8
+
9
+ task :notify_deploy_finished do
10
+ attachments = [{title: "#{default_title('finished deploying')}", color: successed_color }]
11
+ send_message nil, attachments
12
+ end
13
+
14
+ task :notify_deploy_fail do
15
+ attachments = [{title: "#{default_title('cancelled deployment of')}", color: failed_color }]
16
+ send_message nil, attachments
17
+ end
18
+
19
+ before 'deploy:starting', 'bearychat:notify_deploy_started'
20
+ after 'deploy:finishing', 'bearychat:notify_deploy_finished'
21
+ if Rake::Task.task_defined? 'deploy:failed'
22
+ after 'deploy:failed', 'bearychat:notify_deploy_fail'
23
+ end
24
+
25
+ def git_user
26
+ `git config user.name`.gsub "\n", ''
27
+ end
28
+
29
+ def failed_color
30
+ fetch(:bearychat_failed_color, "#E51C23")
31
+ end
32
+
33
+ def successed_color
34
+ fetch(:bearychat_successed_color, "#259B24")
35
+ end
36
+
37
+ def starting_color
38
+ fetch(:bearychat_starting_color, "#FFC107")
39
+ end
40
+
41
+ def default_title(action)
42
+ "#{git_user} #{action} #{deployment_info} to #{stage_string} @ #{Time.now}."
43
+ end
44
+
45
+ def deployment_info
46
+ "#{fetch(:application)}/#{fetch(:branch)} (#{fetch(:current_revision)})"
47
+ end
48
+
49
+ def stage_string
50
+ fetch(:stage)
51
+ end
52
+
53
+ def send_message(text, attachments)
54
+ return unless enabled?
55
+ return unless bearychat_hook = fetch(:bearychat_hook)
56
+ text ||= "#{fetch(:application)} deployment:"
57
+ Bearychat::Notifier.new(bearychat_hook, { attachments: attachments }).ping text
58
+ end
59
+
60
+ def enabled?
61
+ fetch(:bearychat_enabled, true)
62
+ end
63
+
64
+ end
@@ -1,6 +1,6 @@
1
1
  # coding: utf-8
2
2
  module Bearychat
3
3
  class Notifier
4
- VERSION = "0.0.5"
4
+ VERSION = "0.0.6"
5
5
  end
6
6
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bearychat-notifier
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - villins
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-06-22 00:00:00.000000000 Z
11
+ date: 2015-08-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -67,6 +67,8 @@ files:
67
67
  - Rakefile
68
68
  - bearychat-notifier.gemspec
69
69
  - lib/bearychat-notifier.rb
70
+ - lib/bearychat-notifier/capistrano.rb
71
+ - lib/bearychat-notifier/capistrano/tasks/bearychat.rake
70
72
  - lib/bearychat-notifier/http_client.rb
71
73
  - lib/bearychat-notifier/version.rb
72
74
  - lib/exception_notifier/bearychat_notifier.rb