sensu-extensions 1.3.0 → 1.4.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e6d74d6dca4bedd84982073aec8854a28593db8f
4
- data.tar.gz: 06921a9ef24d4fae7424dd0098147a98b5370488
3
+ metadata.gz: dc93781349822980f313d64c414cdf1f1e44803e
4
+ data.tar.gz: 7330fceb5626310ecc80fbf71bbabdfaf7c9485b
5
5
  SHA512:
6
- metadata.gz: 24ceb6922fe73c311a0306efd0945e382e7111472d99ce881af0cb4040df298fe163953aaa0025e8865b94a714c10867a45847118632dd45d34d91fe87b27aa8
7
- data.tar.gz: 871b598b516ac95181f0a62b475c3a133cdc826ca7d48dac37980e737948871167ebe85dbe0bd9406a4b0c7e4eaff64b727bad43924ab729edca0496730a9008
6
+ metadata.gz: d432073a2da2b54fe5cbe8e11672f54e22a2668532314539ec202bae0b23c651e70785f26a7eaa2de8b74e9a6d2b7eb6f8c105d64c9f92eb8292ef4b538a5f77
7
+ data.tar.gz: 677aa3cd32515c7969197060bcd16b3ead89798bb3f6fef0668fe1f6fb6185cf403613de8052c2ac33e670d24992c7426d977f0c488692b11fb50e35e910559a
@@ -53,9 +53,9 @@ module Sensu
53
53
  # @return [Array<object>] extensions.
54
54
  def all
55
55
  @extensions.map { |category, extensions|
56
- extensions.map do |name, extension|
56
+ extensions.map { |name, extension|
57
57
  extension
58
- end
58
+ }.uniq
59
59
  }.flatten
60
60
  end
61
61
 
@@ -95,6 +95,9 @@ module Sensu
95
95
  Extension.const_get(extension_type.capitalize).descendants.each do |klass|
96
96
  extension = klass.new
97
97
  @extensions[category][extension.name] = extension
98
+ if extension.name_alias
99
+ @extensions[category][extension.name_alias] = extension
100
+ end
98
101
  warning("loaded extension", {
99
102
  :type => extension_type,
100
103
  :name => extension.name,
@@ -111,9 +114,9 @@ module Sensu
111
114
  # @param [Symbol] category to retrive.
112
115
  # @return [Array<Hash>] category definitions.
113
116
  def extension_category(category)
114
- @extensions[category].map do |name, extension|
117
+ @extensions[category].map { |name, extension|
115
118
  extension.definition
116
- end
119
+ }.uniq
117
120
  end
118
121
 
119
122
  # Check to see if an extension exists in a category.
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |spec|
4
4
  spec.name = "sensu-extensions"
5
- spec.version = "1.3.0"
5
+ spec.version = "1.4.0"
6
6
  spec.authors = ["Sean Porter"]
7
7
  spec.email = ["portertech@gmail.com"]
8
8
  spec.summary = "The Sensu extension loader library"
@@ -5,6 +5,10 @@ module Sensu
5
5
  "test"
6
6
  end
7
7
 
8
+ def name_alias
9
+ "test_alias"
10
+ end
11
+
8
12
  def description
9
13
  "test extension"
10
14
  end
@@ -23,7 +23,7 @@ describe "Sensu::Extensions::Loader" do
23
23
  expect(@loader.loaded_files.size).to eq(1)
24
24
  expect(@loader.loaded_files.first).to eq(File.expand_path(@extension_file))
25
25
  extension = Sensu::Extension::Test.new
26
- expect(extension).to respond_to(:name, :description, :definition, :safe_run, :stop, :has_key?, :[])
26
+ expect(extension).to respond_to(:name, :name_alias, :description, :definition, :safe_run, :stop, :has_key?, :[])
27
27
  end
28
28
 
29
29
  it "can attempt to load an extension with a script error" do
@@ -44,9 +44,9 @@ describe "Sensu::Extensions::Loader" do
44
44
  expect(@loader.warnings.size).to eq(7)
45
45
  expect(@loader.loaded_files.size).to eq(3)
46
46
  extension = Sensu::Extension::Test.new
47
- expect(extension).to respond_to(:name, :description, :definition, :safe_run, :stop, :has_key?, :[])
47
+ expect(extension).to respond_to(:name, :name_alias, :description, :definition, :safe_run, :stop, :has_key?, :[])
48
48
  extension = Sensu::Extension::MockCheck.new
49
- expect(extension).to respond_to(:name, :description, :definition, :safe_run, :stop, :has_key?, :[])
49
+ expect(extension).to respond_to(:name, :name_alias, :description, :definition, :safe_run, :stop, :has_key?, :[])
50
50
  end
51
51
 
52
52
  it "can attempt to load extensions from a nonexistent directory" do
@@ -60,7 +60,7 @@ describe "Sensu::Extensions::Loader" do
60
60
  expect(@loader.handler_exists?("debug")).to be(true)
61
61
  extension = @loader[:handlers]["debug"]
62
62
  expect(extension).to be_instance_of(Sensu::Extension::Debug)
63
- expect(extension).to respond_to(:name, :description, :definition, :safe_run, :stop, :has_key?, :[])
63
+ expect(extension).to respond_to(:name, :name_alias, :description, :definition, :safe_run, :stop, :has_key?, :[])
64
64
  expect(@loader.handlers).to include(extension.definition)
65
65
  expect(@loader.all).to include(extension)
66
66
  expect(@loader.mutator_exists?("json")).to be(true)
@@ -74,9 +74,14 @@ describe "Sensu::Extensions::Loader" do
74
74
  expect(@loader.handler_exists?("test")).to be(true)
75
75
  extension = @loader[:handlers]["test"]
76
76
  expect(extension).to be_instance_of(Sensu::Extension::Test)
77
- expect(extension).to respond_to(:name, :description, :definition, :safe_run, :stop, :has_key?, :[])
77
+ expect(extension).to respond_to(:name, :name_alias, :description, :definition, :safe_run, :stop, :has_key?, :[])
78
78
  expect(@loader.handlers).to include(extension.definition)
79
79
  expect(@loader.all).to include(extension)
80
+ extension_alias = @loader[:handlers]["test_alias"]
81
+ expect(extension_alias).to eq(extension)
82
+ expect(@loader.handlers).to include(extension_alias.definition)
83
+ expect(@loader.all).to include(extension_alias)
84
+ expect(@loader.all.size).to eq(@loader.all.uniq.size)
80
85
  expect(@loader.handler_exists?("debug")).to be(true)
81
86
  expect(@loader.mutator_exists?("only_check_output")).to be(true)
82
87
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sensu-extensions
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.0
4
+ version: 1.4.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: 2015-09-16 00:00:00.000000000 Z
11
+ date: 2015-11-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: sensu-logger