sensu-extensions 0.0.4 → 0.0.5
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/lib/sensu/extensions.rb +32 -20
- data/sensu-extensions.gemspec +1 -1
- data/spec/extensions_spec.rb +12 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6f22bdfd2101a4eed988383d6e556628c8aebbb9
|
4
|
+
data.tar.gz: 9fb6182c93f47b801663a53a3ff97949f00a7842
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 37554eff083995189efe88e118a62535f816b51748a7b9139b5aa0138ecdd2eace226d3e952445cd12ab3ddf0b3ef1a40cfa0bf45354d68735fe8477c9ddb079
|
7
|
+
data.tar.gz: 42e83135922064522c13ff2c02635a7a60bc5dab13401545420841e4e29611fce4580d3dd0df9dcb6a6d75c6a5bcda584d200c19d198ff6d515793200970c228
|
data/lib/sensu/extensions.rb
CHANGED
@@ -2,28 +2,40 @@ require "sensu/extensions/loader"
|
|
2
2
|
|
3
3
|
module Sensu
|
4
4
|
module Extensions
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
if options[:extension_dirs]
|
21
|
-
options[:extension_dirs].each do |directory|
|
22
|
-
loader.load_directory(directory)
|
5
|
+
class << self
|
6
|
+
# Load Sensu extensions.
|
7
|
+
#
|
8
|
+
# @param [Hash] options
|
9
|
+
# @option options [String] :extension_file to load.
|
10
|
+
# @option options [String] :extension_dir to load.
|
11
|
+
# @option options [Array] :extension_dirs to load.
|
12
|
+
# @return [Loader] a loaded instance of Loader.
|
13
|
+
def load(options={})
|
14
|
+
@loader = Loader.new
|
15
|
+
if options[:extension_file]
|
16
|
+
@loader.load_file(options[:extension_file])
|
17
|
+
end
|
18
|
+
if options[:extension_dir]
|
19
|
+
@loader.load_directory(options[:extension_dir])
|
23
20
|
end
|
21
|
+
if options[:extension_dirs]
|
22
|
+
options[:extension_dirs].each do |directory|
|
23
|
+
@loader.load_directory(directory)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
@loader.load_instances
|
27
|
+
@loader
|
28
|
+
end
|
29
|
+
|
30
|
+
# Retrieve the current loaded extensions loader or load one up
|
31
|
+
# if there isn't one. Note: We may need to add a mutex for
|
32
|
+
# thread safety.
|
33
|
+
#
|
34
|
+
# @param [Hash] options to pass to load().
|
35
|
+
# @return [Loader] instance of a loaded loader.
|
36
|
+
def get(options={})
|
37
|
+
@loader || load(options)
|
24
38
|
end
|
25
|
-
loader.load_instances
|
26
|
-
loader
|
27
39
|
end
|
28
40
|
end
|
29
41
|
end
|
data/sensu-extensions.gemspec
CHANGED
data/spec/extensions_spec.rb
CHANGED
@@ -20,6 +20,18 @@ describe "Sensu::Extensions" do
|
|
20
20
|
extensions.loaded_files.should be_empty
|
21
21
|
end
|
22
22
|
|
23
|
+
it "can retrive the current loaded loader" do
|
24
|
+
extensions = Sensu::Extensions.load
|
25
|
+
Sensu::Extensions.get.should eq(extensions)
|
26
|
+
Sensu::Extensions.get.should eq(extensions)
|
27
|
+
end
|
28
|
+
|
29
|
+
it "can load up a loader if one doesn't exist" do
|
30
|
+
extensions = Sensu::Extensions.get
|
31
|
+
extensions.should be_an_instance_of(Sensu::Extensions::Loader)
|
32
|
+
Sensu::Extensions.get.should eq(extensions)
|
33
|
+
end
|
34
|
+
|
23
35
|
it "can load an extension from a file" do
|
24
36
|
extensions = Sensu::Extensions.load(:extension_file => @extension_file)
|
25
37
|
extensions.loaded_files.size.should eq(1)
|
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: 0.0.
|
4
|
+
version: 0.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sean Porter
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-05-
|
11
|
+
date: 2014-05-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: sensu-em
|