collapsium-config 0.1.0 → 0.1.1

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: 741381d93d430ecc5543a6078668afa243e37411
4
- data.tar.gz: 95ede2d38dfa692e8fd280b588af56abd50038e3
3
+ metadata.gz: b003113648d35417f65b7f142c1e1957df44390e
4
+ data.tar.gz: 4c6ddaf1aafe5804b918877b5663169a85206afe
5
5
  SHA512:
6
- metadata.gz: 3395ffe0c860a7b1a87c3ea302aedec670c2c59b0267c7dc2dba223a3a18e29b6c5f36b78ed28696de3000c6af7cee38493d7f7168373d09b3d4ccb5283e7451
7
- data.tar.gz: 321173292d3886f27a0686e6286441b2d8ae104cef74a6737bf2639261cd31830870f9b6e393c71365a17cb07548501987f53a56f8a1b75001162f619261621f
6
+ metadata.gz: 07fd37c0e483fb12ecbd24924a27af10a49f4c07a8ffaff28bf9555b983b26377fdd5ab7b3a29b19ff0687d95a64c746db21df980838b9e87aed4be2a551dfa9
7
+ data.tar.gz: a0df3d326c1a71bd9001517b5f801fd9d7aab93054dd105d42a4604382881eb8b790c452b7ab2d7245534bb93ce19dc78460c74695eb665fd41cd787cfd3dfed
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- collapsium-config (0.1.0)
4
+ collapsium-config (0.1.1)
5
5
  collapsium (~> 0.1)
6
6
 
7
7
  GEM
@@ -31,21 +31,24 @@ module Collapsium
31
31
  def config_file
32
32
  return @config_file || DEFAULT_CONFIG_PATH
33
33
  end
34
+
35
+ # @api private
36
+ attr_accessor :config
34
37
  end # module ClassMethods
35
38
  extend ClassMethods
36
39
 
37
40
  ##
38
- # Access the global configuration
41
+ # Access the global configuration.
39
42
  def config
40
- if @config.nil?
43
+ if Config.config.nil? or Config.config.empty?
41
44
  begin
42
- @config = Configuration.load_config(Config.config_file)
45
+ Config.config = Configuration.load_config(Config.config_file)
43
46
  rescue Errno::ENOENT
44
- @config = {}
47
+ Config.config = {}
45
48
  end
46
49
  end
47
50
 
48
- return @config
51
+ return Config.config
49
52
  end
50
53
  end # module Config
51
54
  end # module Collapsium
@@ -9,6 +9,6 @@
9
9
  module Collapsium
10
10
  module Config
11
11
  # The current release version
12
- VERSION = "0.1.0".freeze
12
+ VERSION = "0.1.1".freeze
13
13
  end # module Config
14
14
  end # module Collapsium
data/spec/module_spec.rb CHANGED
@@ -9,17 +9,35 @@ describe Collapsium::Config do
9
9
  end
10
10
 
11
11
  it "fails to load configuration from the default path (it does not exist)" do
12
+ expect(Collapsium::Config.config_file).to eql \
13
+ Collapsium::Config::DEFAULT_CONFIG_PATH
12
14
  expect(config.empty?).to be_truthy
13
15
  end
14
16
 
15
- it "fails to load configuration files of unrecognized formats" do
16
- Collapsium::Config.config_file = File.join(@data_path, 'foo.bar')
17
- expect { config.empty? }.to raise_error(ArgumentError)
18
- end
17
+ describe "providing a config file path" do
18
+ before :each do
19
+ Collapsium::Config.config_file = Collapsium::Config::DEFAULT_CONFIG_PATH
20
+ end
21
+
22
+ it "fails to load configuration files of unrecognized formats" do
23
+ Collapsium::Config.config_file = File.join(@data_path, 'foo.bar')
24
+ expect { config.empty? }.to raise_error(ArgumentError)
25
+ end
26
+
27
+ it "loads configuration from an existing path" do
28
+ Collapsium::Config.config_file = File.join(@data_path, 'global.yml')
29
+ expect { config.empty? }.not_to raise_error(ArgumentError)
30
+ expect(config.empty?).to be_falsy
31
+ end
32
+
33
+ it "does not load the same configuration twice" do
34
+ Collapsium::Config.config_file = File.join(@data_path, 'global.yml')
35
+ cfg1 = config
36
+
37
+ Collapsium::Config.config_file = File.join(@data_path, 'global.yml')
38
+ cfg2 = config
19
39
 
20
- it "loads configuration from an existing path" do
21
- Collapsium::Config.config_file = File.join(@data_path, 'global.yml')
22
- expect { config.empty? }.not_to raise_error(ArgumentError)
23
- expect(config.empty?).to be_falsy
40
+ expect(cfg1.object_id).to eql cfg2.object_id
41
+ end
24
42
  end
25
43
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: collapsium-config
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jens Finkhaeuser