sensu-extensions 0.0.4 → 0.0.5

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: a70c9420e9ef4c2dab2a6cf6779ee760e0c5a0ef
4
- data.tar.gz: 0321f2582670a20f127d149b769c1f8e7397a2c9
3
+ metadata.gz: 6f22bdfd2101a4eed988383d6e556628c8aebbb9
4
+ data.tar.gz: 9fb6182c93f47b801663a53a3ff97949f00a7842
5
5
  SHA512:
6
- metadata.gz: 7cbdd74714cf3278ba63688c574e4b5de7797a402ff7b178dc68c9e303a9c2253041573f8a79a857be10e1fa5c86a62fe4316c6dceac26b4894e93cadd197de6
7
- data.tar.gz: d0799591f7564b4059604201ad14807c78c7370e7e319d262e4034663ff3a82fb50d91adeec8046b9efe049baa9b658b68462f4ccafc74fc588e5a87cd7d0c1d
6
+ metadata.gz: 37554eff083995189efe88e118a62535f816b51748a7b9139b5aa0138ecdd2eace226d3e952445cd12ab3ddf0b3ef1a40cfa0bf45354d68735fe8477c9ddb079
7
+ data.tar.gz: 42e83135922064522c13ff2c02635a7a60bc5dab13401545420841e4e29611fce4580d3dd0df9dcb6a6d75c6a5bcda584d200c19d198ff6d515793200970c228
@@ -2,28 +2,40 @@ require "sensu/extensions/loader"
2
2
 
3
3
  module Sensu
4
4
  module Extensions
5
- # Load Sensu extensions.
6
- #
7
- # @param [Hash] options
8
- # @option options [String] :extension_file to load.
9
- # @option options [String] :extension_dir to load.
10
- # @option options [Array] :extension_dirs to load.
11
- # @return [Loader] a loaded instance of Loader.
12
- def self.load(options={})
13
- loader = Loader.new
14
- if options[:extension_file]
15
- loader.load_file(options[:extension_file])
16
- end
17
- if options[:extension_dir]
18
- loader.load_directory(options[:extension_dir])
19
- end
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
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |spec|
4
4
  spec.name = "sensu-extensions"
5
- spec.version = "0.0.4"
5
+ spec.version = "0.0.5"
6
6
  spec.authors = ["Sean Porter"]
7
7
  spec.email = ["portertech@gmail.com"]
8
8
  spec.summary = "The Sensu extension loader library"
@@ -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
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-25 00:00:00.000000000 Z
11
+ date: 2014-05-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: sensu-em