alerty-plugin-typetalk 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 4f733c31a161f352017b717f4dc28169de2fdd8102c2fc053a840a74c2ae354b
4
+ data.tar.gz: c877c937827f161ce9f154639d4e5e9084524bc6bfbedb55792527eb9eb4474a
5
+ SHA512:
6
+ metadata.gz: 8849af177d253ff25fffcece31d097aac0edff0b6063e034ce949ad395505e0995c7aed7c673342896c0f8683fddd49d7938542cf1fe756a344825f32bea56a0
7
+ data.tar.gz: 1c399df347c4ef0333cac84951ad69f043d097dfa36c6887b7bb41028f6fc0423e48801a8a796a0375517cf7f4cfb6360b64f6bc97144fa133fdb79801db4eaa
@@ -0,0 +1,50 @@
1
+ *.gem
2
+ *.rbc
3
+ /.config
4
+ /coverage/
5
+ /InstalledFiles
6
+ /pkg/
7
+ /spec/reports/
8
+ /spec/examples.txt
9
+ /test/tmp/
10
+ /test/version_tmp/
11
+ /tmp/
12
+
13
+ # Used by dotenv library to load environment variables.
14
+ # .env
15
+
16
+ ## Specific to RubyMotion:
17
+ .dat*
18
+ .repl_history
19
+ build/
20
+ *.bridgesupport
21
+ build-iPhoneOS/
22
+ build-iPhoneSimulator/
23
+
24
+ ## Specific to RubyMotion (use of CocoaPods):
25
+ #
26
+ # We recommend against adding the Pods directory to your .gitignore. However
27
+ # you should judge for yourself, the pros and cons are mentioned at:
28
+ # https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control
29
+ #
30
+ # vendor/Pods/
31
+
32
+ ## Documentation cache and generated files:
33
+ /.yardoc/
34
+ /_yardoc/
35
+ /doc/
36
+ /rdoc/
37
+
38
+ ## Environment normalization:
39
+ /.bundle/
40
+ /vendor/bundle
41
+ /lib/bundler/man/
42
+
43
+ # for a library or gem, you might want to ignore these files since the code is
44
+ # intended to run in multiple environments; otherwise, check them in:
45
+ # Gemfile.lock
46
+ # .ruby-version
47
+ # .ruby-gemset
48
+
49
+ # unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
50
+ .rvmrc
@@ -0,0 +1,5 @@
1
+ ## Example
2
+
3
+ ```
4
+ $ alerty -c example/example.yml -- ls /this_is_a_test
5
+ ```
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec
@@ -0,0 +1,30 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ alerty-plugin-typetalk (0.1.0)
5
+ alerty
6
+
7
+ GEM
8
+ remote: https://rubygems.org/
9
+ specs:
10
+ alerty (0.4.0)
11
+ dotenv
12
+ frontkick (>= 0.5.5)
13
+ hashie
14
+ oneline_log_formatter
15
+ dotenv (2.6.0)
16
+ frontkick (0.5.7)
17
+ hashie (3.6.0)
18
+ oneline_log_formatter (0.0.2)
19
+ rake (10.5.0)
20
+
21
+ PLATFORMS
22
+ ruby
23
+
24
+ DEPENDENCIES
25
+ alerty-plugin-typetalk!
26
+ bundler (~> 2.0)
27
+ rake (~> 10.0)
28
+
29
+ BUNDLED WITH
30
+ 2.0.1
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2019 Horie Issei
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 all
13
+ 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 THE
21
+ SOFTWARE.
@@ -0,0 +1,35 @@
1
+ Alerty::Plugin::Typetalk
2
+ ===
3
+
4
+ [Alerty](https://github.com/sonots/alerty) plugin for [Typetalk](https://www.typetalk.com/)
5
+
6
+ ## Installation
7
+
8
+ ```
9
+ $ gem install alerty-plugin-slack
10
+ ```
11
+
12
+ ## Configuration
13
+
14
+ `token`: Typetalk token
15
+ `topic_id`: Typetalk topic id
16
+ `template`: Template text. You can use placeholders listed below.
17
+
18
+ ## Placeholders
19
+
20
+ `${hostname}`: hostname which rans the command
21
+ `${command}`: a given command
22
+ `${exitstatus}`: exitstatus of the executed command
23
+ `${output}`: output of the executed command
24
+
25
+ ## Example configuration
26
+
27
+ ```yaml
28
+ log_path: STDOUT
29
+ log_level: debug
30
+ plugins:
31
+ - type: typetalk
32
+ token: xxxxxxxxxxxxxxxxxxxx
33
+ topic_id: 12345
34
+ template: "FAILURE: [${hostname}] ${command}\n${output}"
35
+ ```
@@ -0,0 +1,7 @@
1
+ require 'bundler/gem_tasks'
2
+ require 'rspec/core/rake_task'
3
+
4
+ RSpec::Core::RakeTask.new
5
+
6
+ desc 'Run specs'
7
+ task default: :spec
@@ -0,0 +1,27 @@
1
+ lib = File.expand_path('lib', __dir__)
2
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
+ require 'alerty/plugin/typetalk/version'
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = 'alerty-plugin-typetalk'
7
+ spec.version = Alerty::Plugin::Typetalk::VERSION
8
+ spec.authors = ['Issei Horie']
9
+ spec.email = ['is2ei.horie@gmail.com']
10
+
11
+ spec.summary = 'Alerty plugin for Typetalk'
12
+ spec.description = 'This plugin will send notification to Typetalk.'
13
+ spec.homepage = 'https://github.com/is2ei/alerty-plugin-typetalk'
14
+ spec.license = 'MIT'
15
+
16
+ spec.files = Dir.chdir(File.expand_path(__dir__)) do
17
+ `git ls-files -z`
18
+ .split("\x0")
19
+ .reject { |f| f.match(%r{^(test|spec|features)/}) }
20
+ end
21
+ spec.require_paths = ['lib']
22
+
23
+ spec.add_runtime_dependency 'alerty', '0.4.0'
24
+
25
+ spec.add_development_dependency 'bundler', '~> 2.0'
26
+ spec.add_development_dependency 'rake', '~> 10.0'
27
+ end
@@ -0,0 +1,7 @@
1
+ log_path: STDOUT
2
+ log_level: debug
3
+ plugins:
4
+ - type: typetalk
5
+ token: xxxxxxxxxxxxxxxxxxxx
6
+ topic_id: 12345
7
+ template: "FAILURE: [${hostname}] ${command}\n${output}"
@@ -0,0 +1,48 @@
1
+ require 'net/http'
2
+ require 'alerty'
3
+ require 'alerty/plugin/typetalk/version'
4
+
5
+ class Alerty
6
+ class Plugin
7
+ # Typetalk sends notifcation to Typetalk
8
+ class Typetalk
9
+ def initialize(config)
10
+ @token = config.token || ENV['TYPETALK_TOKEN']
11
+ @topic_id = config.topic_id || ENV['TYPETALK_TOPIC_ID']
12
+ @template = config.template || ''
13
+ end
14
+
15
+ def alert(record)
16
+ msg = parse_template(@template, record)
17
+ post_message(msg)
18
+ end
19
+
20
+ private
21
+
22
+ def post_message(msg)
23
+ uri = URI("https://typetalk.com/api/v1/topics/#{@topic_id}")
24
+ body = { message: msg }.to_json
25
+ post(uri, body)
26
+ end
27
+
28
+ def post(uri, body)
29
+ req = Net::HTTP::Post.new(uri)
30
+ req['X-Typetalk-Token'] = @token
31
+ req['Content-Type'] = 'application/json'
32
+ req.body = body
33
+ Net::HTTP.start(uri.host, uri.port, use_ssl: true) do |http|
34
+ res = http.request(req)
35
+ end
36
+ end
37
+
38
+ def parse_template(template, record)
39
+ template.dup.tap do |t|
40
+ t.gsub!('${hostname}', record[:hostname])
41
+ t.gsub!('${command}', record[:command])
42
+ t.gsub!('${exitstatus}', record[:exitstatus].to_s)
43
+ t.gsub!('${output}', record[:output])
44
+ end
45
+ end
46
+ end
47
+ end
48
+ end
@@ -0,0 +1,7 @@
1
+ class Alerty
2
+ class Plugin
3
+ class Typetalk
4
+ VERSION = '0.1.0'.freeze
5
+ end
6
+ end
7
+ end
metadata ADDED
@@ -0,0 +1,97 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: alerty-plugin-typetalk
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Issei Horie
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2019-01-23 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: alerty
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - '='
18
+ - !ruby/object:Gem::Version
19
+ version: 0.4.0
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - '='
25
+ - !ruby/object:Gem::Version
26
+ version: 0.4.0
27
+ - !ruby/object:Gem::Dependency
28
+ name: bundler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '2.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '2.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '10.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '10.0'
55
+ description: This plugin will send notification to Typetalk.
56
+ email:
57
+ - is2ei.horie@gmail.com
58
+ executables: []
59
+ extensions: []
60
+ extra_rdoc_files: []
61
+ files:
62
+ - ".gitignore"
63
+ - DEVELOPMENT.md
64
+ - Gemfile
65
+ - Gemfile.lock
66
+ - LICENSE
67
+ - README.md
68
+ - Rakefile
69
+ - alerty-plugin-typetalk.gemspec
70
+ - example/example.yml
71
+ - lib/alerty/plugin/typetalk.rb
72
+ - lib/alerty/plugin/typetalk/version.rb
73
+ homepage: https://github.com/is2ei/alerty-plugin-typetalk
74
+ licenses:
75
+ - MIT
76
+ metadata: {}
77
+ post_install_message:
78
+ rdoc_options: []
79
+ require_paths:
80
+ - lib
81
+ required_ruby_version: !ruby/object:Gem::Requirement
82
+ requirements:
83
+ - - ">="
84
+ - !ruby/object:Gem::Version
85
+ version: '0'
86
+ required_rubygems_version: !ruby/object:Gem::Requirement
87
+ requirements:
88
+ - - ">="
89
+ - !ruby/object:Gem::Version
90
+ version: '0'
91
+ requirements: []
92
+ rubyforge_project:
93
+ rubygems_version: 2.7.3
94
+ signing_key:
95
+ specification_version: 4
96
+ summary: Alerty plugin for Typetalk
97
+ test_files: []