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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7e8514222f9d30f9529bb65aefef3b44281a34fc
4
- data.tar.gz: 1df34b31d04c6aec0984043abde447c44880a8ac
3
+ metadata.gz: 5fc316a256dd8602e31c41ef562ed53cfc0a258b
4
+ data.tar.gz: ff1605bba990d182928b595f01bd81293323b815
5
5
  SHA512:
6
- metadata.gz: c5f2f853bea3d7ee5f27db0aab9e3d5af087a7d8022210db406d664b7889bee558bbaa10061341a54a05ede6add4688fe8bdfd8514e6acb9ad66670adce349fd
7
- data.tar.gz: fadb6a86ea8f2a7b79bee38cc9f068aa7d26d28fe5d1fc4950cc824e44ab78e3e904172da2d0c5f0438d55da863303d07c7fdafec50df3e2d86282d802f2f2cd
6
+ metadata.gz: 101536294726ed307ffca6fbe18df13686dbab8f5b025ec1e8f4f86db2f840fbae940434a40eb1ed684a5cdcf29db29f1d8db50952109e3b162dab4de2989005
7
+ data.tar.gz: 3af90a92c88c7e7cda3a891432c37c88fb407b0d72891c7ed196db79aaa7959afd1b9a3b78ec241ffcd59b9ec874605b4f478a90887ce2ffbfd9e291656dc8cd
@@ -1,3 +1,9 @@
1
+ # 0.2.2 (2017/01/20)
2
+
3
+ Fixes:
4
+
5
+ * Fix log_shift_age and log_shift_size config were not working (instead, shift_age and shift_size were working)
6
+
1
7
  # 0.2.1 (2016/09/25)
2
8
 
3
9
  Enhancements:
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |gem|
2
2
  gem.name = "alerty"
3
- gem.version = '0.2.1'
3
+ gem.version = '0.2.2'
4
4
  gem.author = ['Naotoshi Seo']
5
5
  gem.email = ['sonots@gmail.com']
6
6
  gem.homepage = 'https://github.com/sonots/alerty'
@@ -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
@@ -68,7 +68,7 @@ class Alerty
68
68
  end
69
69
 
70
70
  Config.configure(opts)
71
- Config.plugins # load plugins in early stage
71
+ PluginFactory.plugins # load plugins in early stage
72
72
  command = Command.new(command: opts[:command])
73
73
  command.run!
74
74
  end
@@ -51,10 +51,11 @@ class Alerty
51
51
  record
52
52
  end
53
53
  unless record[:exitstatus] == 0
54
- Config.plugins.each do |plugin|
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
@@ -39,11 +39,13 @@ class Alerty
39
39
  end
40
40
 
41
41
  def log_shift_age
42
- opts[:log_shift_age] || config.shift_age || 0
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
- opts[:log_shift_size] || config.shift_size || 1048576
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').map do |plugin|
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.1
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: 2016-09-21 00:00:00.000000000 Z
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.1
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