alerty 0.2.3 → 0.3.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 4dc317e075c9f5dbdf24fd431e6b7dddd3f68d1a
4
- data.tar.gz: 6288a780b49cbac9d68b662bd5381430270547de
3
+ metadata.gz: 3ae60fa6de1c6a296b2aaefc0429cf84d716a9f8
4
+ data.tar.gz: b499e6edb6b41470af44ffad38c07f21ea5daff4
5
5
  SHA512:
6
- metadata.gz: 3ea49ad7c8ab76fa41268896872061bc2c826d42cae620c8cd900c1b29f6b33afb82a7d6f3b871fbf50b7bd7eaea1e23d3450bfba91a046fb0906016b35df775
7
- data.tar.gz: f29f8d6cb14926057761e55e5e0bc1d78ff62375ab9780529f4a94b518a7c825b9f06a646d299227d2f58acc315b6cea173e1b49c2c859806b94851e57927ad9
6
+ metadata.gz: f88a28b14ce75957b38708936969d8e77fa1f2a8b2789ddbb838fb23ca1af0a9efb3e0cba9b06b92a107f783908727389822c8988f036591f26dee7e03935ddf
7
+ data.tar.gz: 3bd9c34db9e0140f0e096e284dea90dc23fdee11d3a43772bd0f57c363c2a4e47034d0ffeec197bd75437f97932f8bfee3bc6e0aa9584503ff01359e76140eba
@@ -1,3 +1,9 @@
1
+ # 0.3.0 (2017/03/20)
2
+
3
+ Enhancements:
4
+
5
+ * Use popen2e rather than `2>&1`
6
+
1
7
  # 0.2.3 (2017/01/20)
2
8
 
3
9
  Enhancements:
data/README.md CHANGED
@@ -77,14 +77,14 @@ Following plugins are available:
77
77
 
78
78
  ### Naming Convention
79
79
 
80
- You must follow the below naming conventions:
80
+ You must follow following naming conventions:
81
81
 
82
82
  * gem name: alerty-plugin-xxx (xxx_yyy)
83
83
  * file name: lib/alerty/plugin/xxx.rb (xxx_yyy.rb)
84
84
  * class name: Alerty::Plugin:Xxx (XxxYyy)
85
85
 
86
86
  ### Interface
87
-
87
+ u
88
88
  What you have to implement is `#initialize` and `#alert` methods. Here is an example of `file` plugin:
89
89
 
90
90
  ```ruby
@@ -123,7 +123,7 @@ plugins:
123
123
 
124
124
  ### record
125
125
 
126
- `record` is a hash whose keys are
126
+ `record` is a hash whose keys are symbols of followings:
127
127
 
128
128
  * hostname: hostname
129
129
  * command: the executed command
@@ -17,7 +17,7 @@ Gem::Specification.new do |gem|
17
17
 
18
18
  gem.add_runtime_dependency 'hashie'
19
19
  gem.add_runtime_dependency 'oneline_log_formatter'
20
- gem.add_runtime_dependency 'frontkick', '>= 0.4.0'
20
+ gem.add_runtime_dependency 'frontkick', '>= 0.5.5'
21
21
  gem.add_runtime_dependency 'dotenv'
22
22
 
23
23
  gem.add_development_dependency 'rspec'
@@ -6,7 +6,7 @@ class Alerty
6
6
  class Command
7
7
  def initialize(command:)
8
8
  @command = command
9
- @opts = { timeout: Config.timeout, exclusive: Config.lock_path }
9
+ @opts = { timeout: Config.timeout, exclusive: Config.lock_path, popen2e: true }
10
10
  @hostname = Socket.gethostname
11
11
  end
12
12
 
@@ -15,7 +15,7 @@ class Alerty
15
15
  with_retry do |retries|
16
16
  started_at = Time.now
17
17
  begin
18
- result = with_clean_env { Frontkick.exec("#{@command} 2>&1", @opts) }
18
+ result = with_clean_env { Frontkick.exec(@command, @opts) }
19
19
  rescue Frontkick::Timeout => e
20
20
  record = {
21
21
  hostname: @hostname,
@@ -41,7 +41,7 @@ class Alerty
41
41
  hostname: @hostname,
42
42
  command: @command,
43
43
  exitstatus: result.exitstatus,
44
- output: result.stdout,
44
+ output: result.output,
45
45
  started_at: started_at.to_f,
46
46
  duration: result.duration,
47
47
  retries: retries,
@@ -41,7 +41,7 @@ class Alerty
41
41
  'lock_path' => lock_path,
42
42
  'retry_limit' => retry_limit,
43
43
  'retry_wait' => retry_wait,
44
- 'plugin' => yaml['plugins'],
44
+ 'plugins' => yaml['plugins'],
45
45
  }.to_yaml)
46
46
  end
47
47
  @config
@@ -1,3 +1,3 @@
1
1
  class Alerty
2
- VERSION = '0.2.3'
2
+ VERSION = '0.3.0'
3
3
  end
@@ -9,15 +9,17 @@ describe Alerty::Command do
9
9
  log_level: 'fatal',
10
10
  timeout: 20,
11
11
  lock_path: '/tmp/lock',
12
+ config_path: File.join(ROOT, 'spec/cli_spec.yml'),
12
13
  )
13
14
  end
14
15
 
15
16
  let(:command) { Alerty::Command.new(command: 'ls') }
16
17
 
17
18
  it do
18
- expect(Frontkick).to receive(:exec).with("ls 2>&1", {
19
+ expect(Frontkick).to receive(:exec).with("ls", {
19
20
  timeout: 20,
20
21
  exclusive: '/tmp/lock',
22
+ popen2e: true,
21
23
  }).and_return(Frontkick::Result.new(exit_code: 0))
22
24
  expect { command.run! }.not_to raise_error
23
25
  end
@@ -41,9 +43,10 @@ describe Alerty::Command do
41
43
  let(:command) { Alerty::Command.new(command: 'echo foo') }
42
44
 
43
45
  it do
44
- expect(Frontkick).to receive(:exec).with("echo foo 2>&1", {
46
+ expect(Frontkick).to receive(:exec).with("echo foo", {
45
47
  timeout: nil,
46
48
  exclusive: nil,
49
+ popen2e: true,
47
50
  }).and_return(Frontkick::Result.new(stdout: 'foo', exit_code: 1))
48
51
  stdout = capture_stdout { expect { command.run! }.to raise_error(SystemExit) }
49
52
  expect(JSON.parse(stdout)["output"]).to eql("foo")
@@ -68,10 +71,11 @@ describe Alerty::Command do
68
71
  let(:command) { Alerty::Command.new(command: 'sleep 1') }
69
72
 
70
73
  it do
71
- expect(Frontkick).to receive(:exec).with("sleep 1 2>&1", {
74
+ expect(Frontkick).to receive(:exec).with("sleep 1", {
72
75
  timeout: 0.1,
73
76
  exclusive: '/tmp/lock',
74
- }).and_raise(Frontkick::Timeout.new(111, 'sleep 1 2>&1', true))
77
+ popen2e: true,
78
+ }).and_raise(Frontkick::Timeout.new(111, 'sleep 1', true))
75
79
  stdout = capture_stdout { expect { command.run! }.to raise_error(SystemExit) }
76
80
  expect(JSON.parse(stdout)["output"]).to include("timeout")
77
81
  end
@@ -95,9 +99,10 @@ describe Alerty::Command do
95
99
  let(:command) { Alerty::Command.new(command: 'sleep 1') }
96
100
 
97
101
  it do
98
- expect(Frontkick).to receive(:exec).with("sleep 1 2>&1", {
102
+ expect(Frontkick).to receive(:exec).with("sleep 1", {
99
103
  timeout: 20,
100
104
  exclusive: '/tmp/lock',
105
+ popen2e: true,
101
106
  }).and_raise(Frontkick::Locked)
102
107
  stdout = capture_stdout { expect { command.run! }.to raise_error(SystemExit) }
103
108
  expect(JSON.parse(stdout)["output"]).to include("lock")
@@ -121,9 +126,10 @@ describe Alerty::Command do
121
126
  let(:command) { Alerty::Command.new(command: 'echo foo') }
122
127
 
123
128
  it do
124
- expect(Frontkick).to receive(:exec).twice.with("echo foo 2>&1", {
129
+ expect(Frontkick).to receive(:exec).twice.with("echo foo", {
125
130
  timeout: nil,
126
131
  exclusive: nil,
132
+ popen2e: true,
127
133
  }).and_return(Frontkick::Result.new(stdout: 'foo', exit_code: 1))
128
134
  stdout = capture_stdout { expect { command.run! }.to raise_error(SystemExit) }
129
135
  expect(JSON.parse(stdout)["retries"]).to eql(1)
@@ -76,8 +76,8 @@ describe Alerty::Config do
76
76
  end
77
77
 
78
78
  it do
79
- expect(Alerty::Config.plugins[0]).to be_a(Alerty::Plugin::Stdout)
80
- expect(Alerty::Config.plugins[1]).to be_a(Alerty::Plugin::File)
79
+ expect(Alerty::Config.plugins[0]['type']).to eql('stdout')
80
+ expect(Alerty::Config.plugins[1]['type']).to eql('file')
81
81
  end
82
82
  end
83
83
  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.3
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Naotoshi Seo
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-01-20 00:00:00.000000000 Z
11
+ date: 2017-03-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: hashie
@@ -44,14 +44,14 @@ dependencies:
44
44
  requirements:
45
45
  - - ">="
46
46
  - !ruby/object:Gem::Version
47
- version: 0.4.0
47
+ version: 0.5.5
48
48
  type: :runtime
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: 0.4.0
54
+ version: 0.5.5
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: dotenv
57
57
  requirement: !ruby/object:Gem::Requirement
@@ -191,7 +191,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
191
191
  version: '0'
192
192
  requirements: []
193
193
  rubyforge_project:
194
- rubygems_version: 2.5.2
194
+ rubygems_version: 2.5.1
195
195
  signing_key:
196
196
  specification_version: 4
197
197
  summary: Send an alert if a given command failed