capistrano-around_chatwork 0.1.1 → 1.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/CHANGELOG.md +26 -1
- data/README.md +23 -4
- data/capistrano-around_chatwork.gemspec +9 -10
- data/lib/capistrano/around_chatwork/version.rb +1 -1
- data/lib/capistrano/around_chatwork.rb +60 -8
- metadata +22 -20
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: af33eb9e410ee6bbb301b1066238060a96e6090202244424bae547a6698dc06d
|
4
|
+
data.tar.gz: a54735fc4dca586c91a3fe0c16d0b7305045132b32a5016418f5dc75323a8542
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 802be193d45fbb36e362111f546786f3e6579569413ecb2693e579c38a77727de798ba98c9dc39d282256380e32f665c3b26012d6d88d63dbf221baf515ac6a9
|
7
|
+
data.tar.gz: 1f8a26a12aaf349a19a123b387b1317e1fa5d781ca913f924a9a45d68e7b36a7059d2b811ed8ac5745eb7aeb80c35a2aa0a1a57ea9cb2c5659537fc888878095
|
data/CHANGELOG.md
CHANGED
@@ -1,6 +1,31 @@
|
|
1
1
|
# Changelog
|
2
2
|
## Unreleased
|
3
|
-
[full changelog](
|
3
|
+
[full changelog](https://github.com/sue445/capistrano-around_chatwork/compare/v1.0.2...master)
|
4
|
+
|
5
|
+
## 1.0.2
|
6
|
+
[full changelog](https://github.com/sue445/capistrano-around_chatwork/compare/v1.0.1...v1.0.2)
|
7
|
+
|
8
|
+
* Enable MFA requirement for gem releasing
|
9
|
+
* https://github.com/sue445/capistrano-around_chatwork/pull/5
|
10
|
+
|
11
|
+
## 1.0.1
|
12
|
+
[full changelog](https://github.com/sue445/capistrano-around_chatwork/compare/v1.0.0...v1.0.1)
|
13
|
+
|
14
|
+
* Skip notify when message is empty
|
15
|
+
* https://github.com/sue445/capistrano-around_chatwork/pull/4
|
16
|
+
|
17
|
+
## 1.0.0
|
18
|
+
[full changelog](https://github.com/sue445/capistrano-around_chatwork/compare/v0.2.0...v1.0.0)
|
19
|
+
|
20
|
+
* Drop support ruby older than 2.1 :bomb:
|
21
|
+
* Notify failure message if task is failed
|
22
|
+
* https://github.com/sue445/capistrano-around_chatwork/pull/3
|
23
|
+
|
24
|
+
## 0.2.0
|
25
|
+
[full changelog](https://github.com/sue445/capistrano-around_chatwork/compare/v0.1.1...v0.2.0)
|
26
|
+
|
27
|
+
* Use cha gem instead of chatwork gem
|
28
|
+
* https://github.com/sue445/capistrano-around_chatwork/pull/2
|
4
29
|
|
5
30
|
## 0.1.1
|
6
31
|
[full changelog](https://github.com/sue445/capistrano-around_chatwork/compare/v0.1.0...v0.1.1)
|
data/README.md
CHANGED
@@ -2,7 +2,6 @@
|
|
2
2
|
|
3
3
|
[![Gem Version](https://badge.fury.io/rb/capistrano-around_chatwork.svg)](http://badge.fury.io/rb/capistrano-around_chatwork)
|
4
4
|
[![Code Climate](https://codeclimate.com/github/sue445/capistrano-around_chatwork/badges/gpa.svg)](https://codeclimate.com/github/sue445/capistrano-around_chatwork)
|
5
|
-
[![Dependency Status](https://gemnasium.com/sue445/capistrano-around_chatwork.svg)](https://gemnasium.com/sue445/capistrano-around_chatwork)
|
6
5
|
|
7
6
|
post to [ChatWork](http://www.chatwork.com/) before and after the specified task
|
8
7
|
|
@@ -36,10 +35,9 @@ around_chatwork "deploy"
|
|
36
35
|
```
|
37
36
|
|
38
37
|
## Customize
|
39
|
-
If you want to customize
|
40
|
-
|
41
|
-
example
|
38
|
+
If you want to customize messages, set `starting_message`, `ending_message` and `failure_message`
|
42
39
|
|
40
|
+
### Example
|
43
41
|
```ruby
|
44
42
|
set :starting_message, -> {
|
45
43
|
"[info][title][#{fetch(:stage)}] :task_name: @#{fetch(:user)}[/title]started[/info]"
|
@@ -48,10 +46,31 @@ set :starting_message, -> {
|
|
48
46
|
set :ending_message, -> {
|
49
47
|
"[info][title][#{fetch(:stage)}] :task_name: @#{fetch(:user)}[/title]done (:elapsed_time: sec)[/info]"
|
50
48
|
}
|
49
|
+
|
50
|
+
set :failure_message, -> {
|
51
|
+
<<-MSG
|
52
|
+
[info][title][#{fetch(:stage)}] :task_name: @#{fetch(:user)}[/title]failed (:elapsed_time: sec)
|
53
|
+
:error_inspect:
|
54
|
+
:error_backtrace:[/info]
|
55
|
+
MSG
|
56
|
+
}
|
57
|
+
```
|
58
|
+
|
59
|
+
When these are falsy (e.g. `nil` or `false`) or empty string (e.g. `""`), notification is skipped.
|
60
|
+
|
61
|
+
e.g.
|
62
|
+
|
63
|
+
```ruby
|
64
|
+
set :starting_message, nil
|
65
|
+
set :ending_message, ""
|
51
66
|
```
|
52
67
|
|
68
|
+
### Variables
|
53
69
|
* `:task_name:` is replaced to current task name (e.g. `deploy`)
|
54
70
|
* `:elapsed_time:` is replaced to elapsed time of task (e.g. `1.234`)
|
71
|
+
* `:error_message:` is replaced to error message (i.e. `Exception#message`) if task is failed
|
72
|
+
* `:error_inspect:` is replaced to error inspected message (i.e. `Exception#inspect`) if task is failed
|
73
|
+
* `:error_backtrace:` is replaced to error backtrace (i.e. `Exception#backtrace`) if task is failed
|
55
74
|
|
56
75
|
## Development
|
57
76
|
|
@@ -14,13 +14,12 @@ Gem::Specification.new do |spec|
|
|
14
14
|
spec.homepage = "https://github.com/sue445/capistrano-around_chatwork"
|
15
15
|
spec.license = "MIT"
|
16
16
|
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
end
|
17
|
+
spec.required_ruby_version = ">= 2.1.0"
|
18
|
+
|
19
|
+
spec.metadata["homepage_uri"] = spec.homepage
|
20
|
+
spec.metadata["source_code_uri"] = spec.homepage
|
21
|
+
spec.metadata["changelog_uri"] = "#{spec.homepage}/blob/master/CHANGELOG.md"
|
22
|
+
spec.metadata["rubygems_mfa_required"] = "true"
|
24
23
|
|
25
24
|
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
26
25
|
%w(img/).each do |exclude_dir|
|
@@ -32,8 +31,8 @@ Gem::Specification.new do |spec|
|
|
32
31
|
spec.require_paths = ["lib"]
|
33
32
|
|
34
33
|
spec.add_dependency "capistrano", ">= 3.0.0"
|
35
|
-
spec.add_dependency "
|
34
|
+
spec.add_dependency "cha", ">= 1.2.0"
|
36
35
|
|
37
|
-
spec.add_development_dependency "bundler"
|
38
|
-
spec.add_development_dependency "rake"
|
36
|
+
spec.add_development_dependency "bundler"
|
37
|
+
spec.add_development_dependency "rake"
|
39
38
|
end
|
@@ -1,15 +1,30 @@
|
|
1
1
|
require "capistrano/around_chatwork/version"
|
2
|
-
require "
|
2
|
+
require "cha"
|
3
3
|
|
4
4
|
module Capistrano
|
5
5
|
module AroundChatwork
|
6
|
-
def self.format_message(message
|
7
|
-
|
6
|
+
def self.format_message(message:, task_name:, elapsed_time: 0, error: nil)
|
7
|
+
return "" unless message
|
8
|
+
|
9
|
+
formatted_message = message.
|
10
|
+
gsub(":task_name:", task_name).
|
11
|
+
gsub(":elapsed_time:", sprintf("%5.3f", elapsed_time))
|
12
|
+
|
13
|
+
if error
|
14
|
+
formatted_message = formatted_message.
|
15
|
+
gsub(":error_message:", error.message).
|
16
|
+
gsub(":error_inspect:", error.inspect).
|
17
|
+
gsub(":error_backtrace:", error.backtrace.join("\n"))
|
18
|
+
end
|
19
|
+
|
20
|
+
formatted_message
|
8
21
|
end
|
9
22
|
|
10
23
|
def self.post_chatwork(message)
|
11
|
-
|
12
|
-
|
24
|
+
return if message.empty?
|
25
|
+
|
26
|
+
client = Cha.new(api_token: fetch(:chatwork_api_token))
|
27
|
+
client.create_room_message(fetch(:chatwork_room_id), message)
|
13
28
|
end
|
14
29
|
end
|
15
30
|
end
|
@@ -18,18 +33,47 @@ def around_chatwork(task_name)
|
|
18
33
|
start_time = nil
|
19
34
|
|
20
35
|
before_task = Rake::Task.define_task("#{task_name}:__before__") do
|
21
|
-
message = Capistrano::AroundChatwork.format_message(
|
36
|
+
message = Capistrano::AroundChatwork.format_message(
|
37
|
+
message: fetch(:starting_message),
|
38
|
+
task_name: task_name,
|
39
|
+
)
|
22
40
|
Capistrano::AroundChatwork.post_chatwork(message)
|
23
41
|
start_time = Time.now
|
24
42
|
end
|
25
43
|
|
26
44
|
after_task = Rake::Task.define_task("#{task_name}:__after__") do
|
27
45
|
elapsed_time = Time.now - start_time
|
28
|
-
message = Capistrano::AroundChatwork.format_message(
|
46
|
+
message = Capistrano::AroundChatwork.format_message(
|
47
|
+
message: fetch(:ending_message),
|
48
|
+
task_name: task_name,
|
49
|
+
elapsed_time: elapsed_time,
|
50
|
+
)
|
29
51
|
Capistrano::AroundChatwork.post_chatwork(message)
|
30
52
|
end
|
31
53
|
|
32
|
-
Rake::Task[task_name]
|
54
|
+
target_task = Rake::Task[task_name]
|
55
|
+
|
56
|
+
target_task.instance_eval do
|
57
|
+
define_singleton_method :invoke_with_failure_message do |*args|
|
58
|
+
begin
|
59
|
+
invoke_without_failure_message(*args)
|
60
|
+
rescue Exception => error
|
61
|
+
elapsed_time = Time.now - start_time
|
62
|
+
message = Capistrano::AroundChatwork.format_message(
|
63
|
+
message: fetch(:failure_message),
|
64
|
+
task_name: task_name,
|
65
|
+
elapsed_time: elapsed_time,
|
66
|
+
error: error,
|
67
|
+
)
|
68
|
+
Capistrano::AroundChatwork.post_chatwork(message)
|
69
|
+
raise
|
70
|
+
end
|
71
|
+
end
|
72
|
+
alias :invoke_without_failure_message :invoke
|
73
|
+
alias :invoke :invoke_with_failure_message
|
74
|
+
end
|
75
|
+
|
76
|
+
target_task.enhance([before_task]) do
|
33
77
|
Rake::Task[after_task].invoke
|
34
78
|
end
|
35
79
|
end
|
@@ -42,4 +86,12 @@ set :ending_message, -> {
|
|
42
86
|
"[info][title][#{fetch(:stage)}] :task_name: @#{fetch(:user)}[/title]done (:elapsed_time: sec)[/info]"
|
43
87
|
}
|
44
88
|
|
89
|
+
set :failure_message, -> {
|
90
|
+
<<-MSG
|
91
|
+
[info][title][#{fetch(:stage)}] :task_name: @#{fetch(:user)}[/title]failed (:elapsed_time: sec)
|
92
|
+
:error_inspect:
|
93
|
+
:error_backtrace:[/info]
|
94
|
+
MSG
|
95
|
+
}
|
96
|
+
|
45
97
|
set :user, local_user
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: capistrano-around_chatwork
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 1.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- sue445
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-11-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: capistrano
|
@@ -25,47 +25,47 @@ dependencies:
|
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: 3.0.0
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
|
-
name:
|
28
|
+
name: cha
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
31
|
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version:
|
33
|
+
version: 1.2.0
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version:
|
40
|
+
version: 1.2.0
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: bundler
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- - "
|
45
|
+
- - ">="
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: '
|
47
|
+
version: '0'
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- - "
|
52
|
+
- - ">="
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: '
|
54
|
+
version: '0'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: rake
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
|
-
- - "
|
59
|
+
- - ">="
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: '
|
61
|
+
version: '0'
|
62
62
|
type: :development
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
|
-
- - "
|
66
|
+
- - ">="
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version: '
|
68
|
+
version: '0'
|
69
69
|
description: post to ChatWork before and after the specified task
|
70
70
|
email:
|
71
71
|
- sue445@sue445.net
|
@@ -88,8 +88,11 @@ homepage: https://github.com/sue445/capistrano-around_chatwork
|
|
88
88
|
licenses:
|
89
89
|
- MIT
|
90
90
|
metadata:
|
91
|
-
|
92
|
-
|
91
|
+
homepage_uri: https://github.com/sue445/capistrano-around_chatwork
|
92
|
+
source_code_uri: https://github.com/sue445/capistrano-around_chatwork
|
93
|
+
changelog_uri: https://github.com/sue445/capistrano-around_chatwork/blob/master/CHANGELOG.md
|
94
|
+
rubygems_mfa_required: 'true'
|
95
|
+
post_install_message:
|
93
96
|
rdoc_options: []
|
94
97
|
require_paths:
|
95
98
|
- lib
|
@@ -97,16 +100,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
97
100
|
requirements:
|
98
101
|
- - ">="
|
99
102
|
- !ruby/object:Gem::Version
|
100
|
-
version:
|
103
|
+
version: 2.1.0
|
101
104
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
102
105
|
requirements:
|
103
106
|
- - ">="
|
104
107
|
- !ruby/object:Gem::Version
|
105
108
|
version: '0'
|
106
109
|
requirements: []
|
107
|
-
|
108
|
-
|
109
|
-
signing_key:
|
110
|
+
rubygems_version: 3.2.22
|
111
|
+
signing_key:
|
110
112
|
specification_version: 4
|
111
113
|
summary: post to ChatWork before and after the specified task
|
112
114
|
test_files: []
|