sensu-settings 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: 5b6fd2ff7cfbb87b1395809280a22abac6b15f82
4
- data.tar.gz: 5a6bfcdd10dcd7cb836e95788e7abc032ce2dd9a
3
+ metadata.gz: ad536528eb8bf91f1470fae3523172d95a5385e5
4
+ data.tar.gz: 23d2d733d4b216b7660d4d58216edeb0070e041c
5
5
  SHA512:
6
- metadata.gz: bfb6873c4156668eff7b9a76d577f46632d98fca2e6c93c38ba4ab2f1c97668c8f39919dffa86dc3538686a088f04687b8246a46b283ad49d9a55475c2e32f5d
7
- data.tar.gz: cdd96c0197b1b9c32dce6b582571e807b8f86d6fdeb6ea419e0a71132239bc195c36170d3b6e4a7dc539fda4aba68637f1faf1c7c242b7855492bf15911eb1e2
6
+ metadata.gz: b61759a73625b9dc32700ed75fba57c2be7ab41fe5478eeed317c536a51097ebfb3a4263e22a848b4c3aa8f695dd3f404000619b5408bf050ac05ef1e5a9303a
7
+ data.tar.gz: 69b96d5e8b2e9511ac5404649066457f2175bcf5bee6edbc71c45e3a2ac661f8b4287870ad20373d96f5888a79e682cd51044a4853d83645ea1ec40999b162fc
@@ -2,29 +2,41 @@ require "sensu/settings/loader"
2
2
 
3
3
  module Sensu
4
4
  module Settings
5
- # Load Sensu settings.
6
- #
7
- # @param [Hash] options
8
- # @option options [String] :config_file to load.
9
- # @option options [String] :config_dir to load.
10
- # @option options [Array] :config_dirs to load.
11
- # @return [Loader] a loaded instance of Loader.
12
- def self.load(options={})
13
- loader = Loader.new
14
- loader.load_env
15
- if options[:config_file]
16
- loader.load_file(options[:config_file])
17
- end
18
- if options[:config_dir]
19
- loader.load_directory(options[:config_dir])
20
- end
21
- if options[:config_dirs]
22
- options[:config_dirs].each do |directory|
23
- loader.load_directory(directory)
5
+ class << self
6
+ # Load Sensu settings.
7
+ #
8
+ # @param [Hash] options
9
+ # @option options [String] :config_file to load.
10
+ # @option options [String] :config_dir to load.
11
+ # @option options [Array] :config_dirs to load.
12
+ # @return [Loader] a loaded instance of Loader.
13
+ def load(options={})
14
+ @loader = Loader.new
15
+ @loader.load_env
16
+ if options[:config_file]
17
+ @loader.load_file(options[:config_file])
18
+ end
19
+ if options[:config_dir]
20
+ @loader.load_directory(options[:config_dir])
24
21
  end
22
+ if options[:config_dirs]
23
+ options[:config_dirs].each do |directory|
24
+ @loader.load_directory(directory)
25
+ end
26
+ end
27
+ @loader.set_env!
28
+ @loader
29
+ end
30
+
31
+ # Retrieve the current loaded settings loader or load one up if
32
+ # there isn't one. Note: We may need to add a mutex for thread
33
+ # safety.
34
+ #
35
+ # @param [Hash] options to pass to load().
36
+ # @return [Loader] instance of a loaded loader.
37
+ def get(options={})
38
+ @loader || load(options)
25
39
  end
26
- loader.set_env!
27
- loader
28
40
  end
29
41
  end
30
42
  end
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |spec|
4
4
  spec.name = "sensu-settings"
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 settings library, loader and validator"
@@ -18,6 +18,18 @@ describe "Sensu::Settings" do
18
18
  settings.should respond_to(:validate)
19
19
  end
20
20
 
21
+ it "can retrive the current loaded loader" do
22
+ settings = Sensu::Settings.load
23
+ Sensu::Settings.get.should eq(settings)
24
+ Sensu::Settings.get.should eq(settings)
25
+ end
26
+
27
+ it "can load up a loader if one doesn't exist" do
28
+ settings = Sensu::Settings.get
29
+ settings.should be_an_instance_of(Sensu::Settings::Loader)
30
+ Sensu::Settings.get.should eq(settings)
31
+ end
32
+
21
33
  it "can load settings from the environment, a file, and a directory" do
22
34
  ENV["RABBITMQ_URL"] = "amqp://guest:guest@localhost:5672/"
23
35
  settings = Sensu::Settings.load(:config_file => @config_file, :config_dir => @config_dir)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sensu-settings
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: multi_json