sensu-extension 1.4.0 → 1.5.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: 941ab203672e43dcfb491dfb58773b4a6736cd09
4
- data.tar.gz: 9de1c6b6854722ce87a26834bf3e7ae09c81cc51
3
+ metadata.gz: 66d4b42c107bd8c3222c6bf9bde3d51416d2994e
4
+ data.tar.gz: de237f24063a3e5090c5014a0d25b43c85f50010
5
5
  SHA512:
6
- metadata.gz: 02c4d28bcbf8755a5eef699a27affa19299526cdb89a5942c0b08c7f0e46873175fe9a291f79abbd29fb24f8f981fa554966da20c8d5948dc1d6cb4819b92b7f
7
- data.tar.gz: 2381e0dde4d250db42c83ff48e20470626346640250882d32a86b9539e2316a359a111ab9708dc4ba14c5a1e246fb6d5e8ffc95407744fbfd39d0309f84aea1d
6
+ metadata.gz: da4a0a2de45cb011e69f4a59c4280e62d969d021deeac6ec86f685cea3abecd084c2c266c5e38996b3cba817647b9ec62ce0bda686f40362473ba2e57c564ddf
7
+ data.tar.gz: 2c997462ea1119b396d7ed561a140c6f7ddd09dd739b808594a9d1bc9fafcacc1ce9253b7d2e173c599c3c2f02f2eb83e8197945cf810b963fb8d99e082c4218
@@ -61,14 +61,12 @@ module Sensu
61
61
  # an output string and exit code.
62
62
  #
63
63
  # @param data [Object, nil] provided by Sensu.
64
- # @param options [Hash] provided by Sensu, may contain
65
- # connection objects, eg. redis.
66
64
  # @yield [output, status] callback/block provided by Sensu,
67
65
  # expecting to be called with two parameters, an output string
68
66
  # and exit status code.
69
67
  # @yieldparam output [String]
70
68
  # @yieldparam status [Integer]
71
- def run(data=nil, options={})
69
+ def run(data=nil)
72
70
  yield("noop", 0)
73
71
  end
74
72
 
@@ -97,27 +95,28 @@ module Sensu
97
95
  end
98
96
 
99
97
  # Run the extension with a few safeties. This method wraps
100
- # run() with a begin;rescue, and duplicates data before passing
101
- # it to ensure the extension doesn't mutate the original. Do
102
- # not override this method!
98
+ # run() with a begin;rescue and determines if the extension
99
+ # utilizes the provided data (i.e. event data). Do not override
100
+ # this method!
103
101
  #
104
- # @param data [Object, nil) to dup() and pass to run(), if run()
105
- # has an absolue arity of 1 or more.
106
- # @param options [Hash] to pass to run(), if run() has an
107
- # absolute arity of 2.
102
+ # @param data [Object, nil) to pass to run(), if run() has an
103
+ # absolue arity of 1 or more.
108
104
  # @yield [output, status] callback/block provided by Sensu,
109
105
  # expecting to be called with two parameters, an output string
110
106
  # and exit status code.
111
107
  # @yieldparam output [String]
112
108
  # @yieldparam status [Integer]
113
- def safe_run(data=nil, options={})
109
+ def safe_run(data=nil)
114
110
  begin
115
111
  @run_arity ||= method(:run).arity.abs
116
- arguments = []
117
- arguments << (data ? data.dup : data) if @run_arity >= 1
118
- arguments << options if @run_arity == 2
119
- run(*arguments) do |output, status|
120
- yield(output, status)
112
+ if @run_arity >= 1
113
+ run(data) do |output, status|
114
+ yield(output, status)
115
+ end
116
+ else
117
+ run do |output, status|
118
+ yield(output, status)
119
+ end
121
120
  end
122
121
  rescue => error
123
122
  klass = error.class.name
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |spec|
4
4
  spec.name = "sensu-extension"
5
- spec.version = "1.4.0"
5
+ spec.version = "1.5.0"
6
6
  spec.authors = ["Sean Porter"]
7
7
  spec.email = ["portertech@gmail.com"]
8
8
  spec.summary = "The Sensu extension library"
@@ -18,7 +18,7 @@ Gem::Specification.new do |spec|
18
18
  spec.add_dependency "eventmachine"
19
19
 
20
20
  spec.add_development_dependency "bundler", "~> 1.6"
21
- spec.add_development_dependency "rake"
21
+ spec.add_development_dependency "rake", "10.5.0"
22
22
  spec.add_development_dependency "rspec"
23
23
  spec.add_development_dependency "codeclimate-test-reporter" unless RUBY_VERSION < "1.9"
24
24
  end
data/spec/base_spec.rb CHANGED
@@ -69,19 +69,7 @@ describe "Sensu::Extension::Base" do
69
69
  end
70
70
  end
71
71
 
72
- it "can run with options" do
73
- async_wrapper do
74
- event = {:foo => 1}
75
- options = {:test => 1}
76
- @extension.run(event, options) do |output, status|
77
- expect(output).to eq("noop")
78
- expect(status).to eq(0)
79
- async_done
80
- end
81
- end
82
- end
83
-
84
- it "can pass duplicated event data to run" do
72
+ it "can pass event data to run" do
85
73
  async_wrapper do
86
74
  event = {:foo => 1}
87
75
  @extension.safe_run(event) do |output, status|
@@ -92,18 +80,6 @@ describe "Sensu::Extension::Base" do
92
80
  end
93
81
  end
94
82
 
95
- it "can pass options to run" do
96
- async_wrapper do
97
- event = {:foo => 1}
98
- options = {:test => 1}
99
- @extension.safe_run(event, options) do |output, status|
100
- expect(output).to eq("noop")
101
- expect(status).to eq(0)
102
- async_done
103
- end
104
- end
105
- end
106
-
107
83
  it "can catch some run errors" do
108
84
  async_wrapper do
109
85
  @extension.safe_run do |output, status|
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sensu-extension
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.4.0
4
+ version: 1.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sean Porter
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-02-23 00:00:00.000000000 Z
11
+ date: 2016-03-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: eventmachine
@@ -42,16 +42,16 @@ dependencies:
42
42
  name: rake
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - ">="
45
+ - - '='
46
46
  - !ruby/object:Gem::Version
47
- version: '0'
47
+ version: 10.5.0
48
48
  type: :development
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'
54
+ version: 10.5.0
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: rspec
57
57
  requirement: !ruby/object:Gem::Requirement