alerty 0.2.1 → 0.2.2
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 +4 -4
- data/CHANGELOG.md +6 -0
- data/alerty.gemspec +1 -1
- data/lib/alerty.rb +2 -1
- data/lib/alerty/cli.rb +1 -1
- data/lib/alerty/command.rb +2 -1
- data/lib/alerty/config.rb +5 -7
- data/lib/alerty/plugin_factory.rb +15 -0
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5fc316a256dd8602e31c41ef562ed53cfc0a258b
|
4
|
+
data.tar.gz: ff1605bba990d182928b595f01bd81293323b815
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 101536294726ed307ffca6fbe18df13686dbab8f5b025ec1e8f4f86db2f840fbae940434a40eb1ed684a5cdcf29db29f1d8db50952109e3b162dab4de2989005
|
7
|
+
data.tar.gz: 3af90a92c88c7e7cda3a891432c37c88fb407b0d72891c7ed196db79aaa7959afd1b9a3b78ec241ffcd59b9ec874605b4f478a90887ce2ffbfd9e291656dc8cd
|
data/CHANGELOG.md
CHANGED
data/alerty.gemspec
CHANGED
data/lib/alerty.rb
CHANGED
@@ -1,9 +1,10 @@
|
|
1
|
-
require_relative 'alerty/string_util'
|
2
1
|
require_relative 'alerty/error'
|
3
2
|
require_relative 'alerty/config'
|
4
3
|
require_relative 'alerty/command'
|
5
4
|
require_relative 'alerty/logger'
|
6
5
|
require_relative 'alerty/cli'
|
6
|
+
require_relative 'alerty/string_util'
|
7
|
+
require_relative 'alerty/plugin_factory'
|
7
8
|
|
8
9
|
class Alerty
|
9
10
|
def self.logger
|
data/lib/alerty/cli.rb
CHANGED
data/lib/alerty/command.rb
CHANGED
@@ -51,10 +51,11 @@ class Alerty
|
|
51
51
|
record
|
52
52
|
end
|
53
53
|
unless record[:exitstatus] == 0
|
54
|
-
|
54
|
+
PluginFactory.plugins.each do |plugin|
|
55
55
|
begin
|
56
56
|
plugin.alert(record)
|
57
57
|
rescue => e
|
58
|
+
puts "#{e.class} #{e.message} #{e.backtrace.join("\n")}" if Config.debug?
|
58
59
|
Alerty.logger.warn "#{e.class} #{e.message} #{e.backtrace.join("\n")}"
|
59
60
|
end
|
60
61
|
end
|
data/lib/alerty/config.rb
CHANGED
@@ -39,11 +39,13 @@ class Alerty
|
|
39
39
|
end
|
40
40
|
|
41
41
|
def log_shift_age
|
42
|
-
|
42
|
+
# config.shift_age is for old version compatibility
|
43
|
+
opts[:log_shift_age] || config.shift_age || config.log_shift_age || 0
|
43
44
|
end
|
44
45
|
|
45
46
|
def log_shift_size
|
46
|
-
|
47
|
+
# config.log_shift_age is for old version compatibility
|
48
|
+
opts[:log_shift_size] || config.shift_size || config.log_shift_size || 1048576
|
47
49
|
end
|
48
50
|
|
49
51
|
def timeout
|
@@ -77,11 +79,7 @@ class Alerty
|
|
77
79
|
end
|
78
80
|
|
79
81
|
def plugins
|
80
|
-
@plugins ||= config.fetch('plugins')
|
81
|
-
require "alerty/plugin/#{plugin.type}"
|
82
|
-
class_name = "Alerty::Plugin::#{StringUtil.camelize(plugin.type)}"
|
83
|
-
Object.const_get(class_name).new(plugin)
|
84
|
-
end
|
82
|
+
@plugins ||= config.fetch('plugins')
|
85
83
|
end
|
86
84
|
|
87
85
|
# for debug
|
@@ -0,0 +1,15 @@
|
|
1
|
+
class Alerty
|
2
|
+
class PluginFactory
|
3
|
+
class << self
|
4
|
+
def plugins
|
5
|
+
@plugins ||= Config.plugins.map {|config| new_plugin(config) }
|
6
|
+
end
|
7
|
+
|
8
|
+
def new_plugin(config)
|
9
|
+
require "alerty/plugin/#{config.type}"
|
10
|
+
class_name = "Alerty::Plugin::#{StringUtil.camelize(config.type)}"
|
11
|
+
Object.const_get(class_name).new(config)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: alerty
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Naotoshi Seo
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2017-01-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: hashie
|
@@ -162,6 +162,7 @@ files:
|
|
162
162
|
- lib/alerty/plugin/exec.rb
|
163
163
|
- lib/alerty/plugin/file.rb
|
164
164
|
- lib/alerty/plugin/stdout.rb
|
165
|
+
- lib/alerty/plugin_factory.rb
|
165
166
|
- lib/alerty/string_util.rb
|
166
167
|
- log/.gitkeep
|
167
168
|
- spec/cli_spec.rb
|
@@ -189,7 +190,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
189
190
|
version: '0'
|
190
191
|
requirements: []
|
191
192
|
rubyforge_project:
|
192
|
-
rubygems_version: 2.5.
|
193
|
+
rubygems_version: 2.5.2
|
193
194
|
signing_key:
|
194
195
|
specification_version: 4
|
195
196
|
summary: Send an alert if a given command failed
|