rundock-plugin-hook-chatwork 0.1.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 +7 -0
- data/.gitignore +36 -0
- data/Gemfile +4 -0
- data/LICENSE +21 -0
- data/README.md +72 -0
- data/Rakefile +37 -0
- data/bin/console +14 -0
- data/bin/setup +7 -0
- data/circle.yml +7 -0
- data/lib/rundock/plugin/hook/chatwork/version.rb +9 -0
- data/lib/rundock/plugin/hook/chatwork.rb +29 -0
- data/rundock-plugin-hook-chatwork.gemspec +25 -0
- metadata +111 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 3b114818d375fa192466f9a391182f8e5ca2db36
|
4
|
+
data.tar.gz: a3eade6947c80e1225730fc7856d5b56950c6c41
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: c269df1f4458ab6b47f947c496553650c5b8b3609a8603127151d2c557c57ad3a5a16dfd85635d49b2661f53749662d17cc9f31895a748a42cb0386704df00b1
|
7
|
+
data.tar.gz: bae6ec224e22a519d173972a81049adfb1c5711e741285814ab7f433a43535380d4a2aeff49847571f949e045b1bebb502eff93c4f2702c1603e6831ee323d7e
|
data/.gitignore
ADDED
@@ -0,0 +1,36 @@
|
|
1
|
+
*.gem
|
2
|
+
*.rbc
|
3
|
+
/.config
|
4
|
+
/coverage/
|
5
|
+
/InstalledFiles
|
6
|
+
/pkg/
|
7
|
+
/spec/reports/
|
8
|
+
/test/tmp/
|
9
|
+
/test/version_tmp/
|
10
|
+
/tmp/
|
11
|
+
Gemfile.lock
|
12
|
+
|
13
|
+
## Specific to RubyMotion:
|
14
|
+
.dat*
|
15
|
+
.repl_history
|
16
|
+
build/
|
17
|
+
|
18
|
+
## Documentation cache and generated files:
|
19
|
+
/.yardoc/
|
20
|
+
/_yardoc/
|
21
|
+
/doc/
|
22
|
+
/rdoc/
|
23
|
+
|
24
|
+
## Environment normalisation:
|
25
|
+
/.bundle/
|
26
|
+
/vendor/bundle
|
27
|
+
/lib/bundler/man/
|
28
|
+
|
29
|
+
# for a library or gem, you might want to ignore these files since the code is
|
30
|
+
# intended to run in multiple environments; otherwise, check them in:
|
31
|
+
# Gemfile.lock
|
32
|
+
# .ruby-version
|
33
|
+
# .ruby-gemset
|
34
|
+
|
35
|
+
# unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
|
36
|
+
.rvmrc
|
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2015 hiracy
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,72 @@
|
|
1
|
+
# Rundock::Plugin::Hook::Chatwork
|
2
|
+
[](http://badge.fury.io/rb/rundock-plugin-hook-chatwork)
|
3
|
+
<!--
|
4
|
+
[](https://circleci.com/gh/hiracy/rundock-plugin-hook-chatwork/tree/master)
|
5
|
+
-->
|
6
|
+
|
7
|
+
[Rundock](https://github.com/hiracy/rundock) plugin for [ChatWork API](http://developer.chatwork.com/) hook.
|
8
|
+
|
9
|
+
## Installation
|
10
|
+
|
11
|
+
```
|
12
|
+
$ gem install rundock
|
13
|
+
```
|
14
|
+
|
15
|
+
```
|
16
|
+
$ gem install rundock-plugin-hook-chatwork
|
17
|
+
```
|
18
|
+
|
19
|
+
## Usage
|
20
|
+
|
21
|
+
Edit your operation scenario to hooks.yml like this sample.
|
22
|
+
|
23
|
+
```
|
24
|
+
send_chatwork_room: # hook name
|
25
|
+
hook_type: chatwork # hook_type(always specify 'chatwork')
|
26
|
+
token: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx # sender token(required)
|
27
|
+
room_id: xxxxxxxx # room id(required)
|
28
|
+
|
29
|
+
# another hook(optional)
|
30
|
+
sub_chatwork_room:
|
31
|
+
hook_type: chatwork
|
32
|
+
token: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
|
33
|
+
room_id: xxxxxxxx
|
34
|
+
```
|
35
|
+
|
36
|
+
And edit your operation scenario to "[scenario.yml](https://github.com/hiracy/rundock/blob/master/scenario_sample.yml)" like this sample.
|
37
|
+
|
38
|
+
```
|
39
|
+
- node: anyhost-01
|
40
|
+
deploy:
|
41
|
+
- src: /path/to/great/middleware/conf_src.rb # deploy source file from localhost
|
42
|
+
dst: /path/to/great/middleware/conf_dst.rb # deploy destination file to remotehost
|
43
|
+
command:
|
44
|
+
- /etc/init.d/great_middleware start
|
45
|
+
hook:
|
46
|
+
- send_chatwork_room # enable hook(hooks.yml/send_chatwork_room)
|
47
|
+
- sub_chatwork_room
|
48
|
+
---
|
49
|
+
anyhost-01: # see rundock options(https://github.com/hiracy/rundock/blob/master/README.md)
|
50
|
+
host: 192.168.10.11
|
51
|
+
ssh_opts:
|
52
|
+
port: 22
|
53
|
+
user: anyuser
|
54
|
+
key: ~/.ssh/id_rsa
|
55
|
+
```
|
56
|
+
|
57
|
+
and execute rundock.
|
58
|
+
|
59
|
+
$ rundock do /path/to/your-dir/scenario.yml -k /path/to/your-dir/hooks.yml
|
60
|
+
|
61
|
+
## Contributing
|
62
|
+
|
63
|
+
1. Fork it ( https://github.com/[my-github-username]/rundock-plugin-hook-chatwork/fork )
|
64
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
65
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
66
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
67
|
+
5. Create a new Pull Request
|
68
|
+
|
69
|
+
## License
|
70
|
+
|
71
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
72
|
+
|
data/Rakefile
ADDED
@@ -0,0 +1,37 @@
|
|
1
|
+
require 'bundler/gem_tasks'
|
2
|
+
require 'yaml'
|
3
|
+
|
4
|
+
SECRET_FILE = "#{Dir.home}/.rundock/chatwork.yml"
|
5
|
+
|
6
|
+
task :default => [:spec]
|
7
|
+
|
8
|
+
desc 'Run all tests.'
|
9
|
+
task :spec => ['setup', 'rundock']
|
10
|
+
|
11
|
+
desc 'Setup environments'
|
12
|
+
|
13
|
+
task :setup do
|
14
|
+
Bundler.with_clean_env do
|
15
|
+
unless FileTest.exist?(SECRET_FILE)
|
16
|
+
puts "#{SECRET_FILE} not found."
|
17
|
+
exit
|
18
|
+
end
|
19
|
+
options = YAML.load_file(SECRET_FILE)
|
20
|
+
|
21
|
+
token = options['token'].to_s
|
22
|
+
room_id = options['room_id'].to_s
|
23
|
+
src = File.read('./spec/integration/hooks.yml')
|
24
|
+
|
25
|
+
File.write(
|
26
|
+
"#{Dir.home}/.rundock/rundock-plugin-hook-chatwork-hooks.yml",
|
27
|
+
src.gsub(/<TOKEN>/, token).gsub(/<ROOM_ID>/, room_id))
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
desc "Run rundock-chatwork plugin"
|
32
|
+
|
33
|
+
task :rundock do
|
34
|
+
cmd = "bundle exec rundock do ./spec/integration/scenario.yml -k #{Dir.home}/.rundock/rundock-plugin-hook-chatwork-hooks.yml -l debug"
|
35
|
+
puts "[EXEC: ] #{cmd}"
|
36
|
+
system cmd
|
37
|
+
end
|
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "rundock/plugin/hook/chatwork"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start
|
data/bin/setup
ADDED
data/circle.yml
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
require "rundock/plugin/hook/chatwork/version"
|
2
|
+
require 'faraday'
|
3
|
+
|
4
|
+
module Rundock
|
5
|
+
module Hook
|
6
|
+
class Chatwork < Base
|
7
|
+
def hook(operation_attributes, log_buffer)
|
8
|
+
|
9
|
+
conn = Faraday::Connection.new(url: 'https://api.chatwork.com') do |builder|
|
10
|
+
builder.use Faraday::Request::UrlEncoded
|
11
|
+
builder.use Faraday::Response::Logger
|
12
|
+
builder.use Faraday::Adapter::NetHttp
|
13
|
+
end
|
14
|
+
|
15
|
+
response = conn.post do |request|
|
16
|
+
request.url "/v1/rooms/#{@contents[:room_id]}/messages"
|
17
|
+
request.headers = {'X-ChatWorkToken' => @contents[:token]}
|
18
|
+
|
19
|
+
out_msg = ''
|
20
|
+
log_buffer.each do |log|
|
21
|
+
out_msg += log.formatted_message
|
22
|
+
end
|
23
|
+
|
24
|
+
request.params[:body] = out_msg
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'rundock/plugin/hook/chatwork/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "rundock-plugin-hook-chatwork"
|
8
|
+
spec.version = Rundock::Plugin::Hook::Chatwork::VERSION
|
9
|
+
spec.authors = ["hiracy"]
|
10
|
+
spec.email = ["leizhen@mbr.nifty.com"]
|
11
|
+
|
12
|
+
spec.summary = %q{rundock plugin for ChatWork API hook}
|
13
|
+
spec.homepage = 'https://github.com/hiracy/rundock-plugin-hook-chatwork'
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
17
|
+
spec.bindir = "exe"
|
18
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_development_dependency 'bundler', '~> 1.9'
|
22
|
+
spec.add_development_dependency 'rake', '~> 10.0'
|
23
|
+
spec.add_development_dependency 'rundock'
|
24
|
+
spec.add_runtime_dependency 'faraday'
|
25
|
+
end
|
metadata
ADDED
@@ -0,0 +1,111 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: rundock-plugin-hook-chatwork
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- hiracy
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-08-31 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ~>
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.9'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ~>
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.9'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ~>
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ~>
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rundock
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - '>='
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: faraday
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - '>='
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
description:
|
70
|
+
email:
|
71
|
+
- leizhen@mbr.nifty.com
|
72
|
+
executables: []
|
73
|
+
extensions: []
|
74
|
+
extra_rdoc_files: []
|
75
|
+
files:
|
76
|
+
- .gitignore
|
77
|
+
- Gemfile
|
78
|
+
- LICENSE
|
79
|
+
- README.md
|
80
|
+
- Rakefile
|
81
|
+
- bin/console
|
82
|
+
- bin/setup
|
83
|
+
- circle.yml
|
84
|
+
- lib/rundock/plugin/hook/chatwork.rb
|
85
|
+
- lib/rundock/plugin/hook/chatwork/version.rb
|
86
|
+
- rundock-plugin-hook-chatwork.gemspec
|
87
|
+
homepage: https://github.com/hiracy/rundock-plugin-hook-chatwork
|
88
|
+
licenses:
|
89
|
+
- MIT
|
90
|
+
metadata: {}
|
91
|
+
post_install_message:
|
92
|
+
rdoc_options: []
|
93
|
+
require_paths:
|
94
|
+
- lib
|
95
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
96
|
+
requirements:
|
97
|
+
- - '>='
|
98
|
+
- !ruby/object:Gem::Version
|
99
|
+
version: '0'
|
100
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
101
|
+
requirements:
|
102
|
+
- - '>='
|
103
|
+
- !ruby/object:Gem::Version
|
104
|
+
version: '0'
|
105
|
+
requirements: []
|
106
|
+
rubyforge_project:
|
107
|
+
rubygems_version: 2.4.5
|
108
|
+
signing_key:
|
109
|
+
specification_version: 4
|
110
|
+
summary: rundock plugin for ChatWork API hook
|
111
|
+
test_files: []
|