sensu-settings 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/settings.rb +33 -21
- data/sensu-settings.gemspec +1 -1
- data/spec/settings_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: ad536528eb8bf91f1470fae3523172d95a5385e5
|
4
|
+
data.tar.gz: 23d2d733d4b216b7660d4d58216edeb0070e041c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b61759a73625b9dc32700ed75fba57c2be7ab41fe5478eeed317c536a51097ebfb3a4263e22a848b4c3aa8f695dd3f404000619b5408bf050ac05ef1e5a9303a
|
7
|
+
data.tar.gz: 69b96d5e8b2e9511ac5404649066457f2175bcf5bee6edbc71c45e3a2ac661f8b4287870ad20373d96f5888a79e682cd51044a4853d83645ea1ec40999b162fc
|
data/lib/sensu/settings.rb
CHANGED
@@ -2,29 +2,41 @@ require "sensu/settings/loader"
|
|
2
2
|
|
3
3
|
module Sensu
|
4
4
|
module Settings
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
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
|
data/sensu-settings.gemspec
CHANGED
data/spec/settings_spec.rb
CHANGED
@@ -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
|
+
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: multi_json
|