unity-configuration-container 1.0.0 → 1.1.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f2f37b899e37f018a33dcdd28dc0f66332580ffe3d9b3c2e796f94e5e82a2b5d
4
- data.tar.gz: d5d5b2e9da10a7646d941a86e020659ba0fa774cd0575566dc89af7db6e7ac43
3
+ metadata.gz: 5b8088e80c0b04a599711b76ce5de567b8a2a5afa8ccf349b74d6302f91adef6
4
+ data.tar.gz: a71327d24a339d28f2c80ecd98e4151bc53f35e8ac2237b3ad7def0270cb93e4
5
5
  SHA512:
6
- metadata.gz: aaf0e7e2b2dafd683cf88daee1c5fbf20662a850d02c3c1705e3563fe56fab7fd9c19e6645e90f4094df1596258a765ad0784659029565770f4e2a93ef70f1e5
7
- data.tar.gz: d920ca5437ed29b6c0bd0a516fcd7936f1981f01308b5674994495a8f4037dd21f761339ad8ff325540347cd65929ba0ec5c428b38ed5f1b5050eb55228b4cb8
6
+ metadata.gz: 42833f28b908f021ce3b9421842cad1cc93203a4a11796f6ed364f88558a9e639c47b2c143268ad6c807d7523706464d3cd68f4bdd21a766ca6bd093f4d5cd06
7
+ data.tar.gz: 721907e1323369a63e610921b4662f2557fedea04467c2fdcc9a65105a766be75b614a308c998b43ab4773d143cef421fb1176db8eb4fb267fd1e528b647fe00
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- unity-configuration-container (1.0.0)
4
+ unity-configuration-container (1.1.0)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
@@ -9,6 +9,7 @@ GEM
9
9
  rake (13.0.6)
10
10
 
11
11
  PLATFORMS
12
+ arm64-darwin-21
12
13
  x86_64-darwin-20
13
14
 
14
15
  DEPENDENCIES
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Unity
4
4
  module ConfigurationContainer
5
- VERSION = "1.0.0"
5
+ VERSION = '1.1.0'
6
6
  end
7
7
  end
@@ -7,26 +7,26 @@ module Unity
7
7
  class Error < StandardError; end
8
8
 
9
9
  def self.extended(base)
10
- base.instance_variable_set(:@configurations_container, {})
11
- base.instance_variable_set(:@configurations_container_mutex, Mutex.new)
10
+ base.instance_variable_set(:@unity_configuration_values, {})
11
+ base.instance_variable_set(:@unity_configurations, {})
12
+ base.instance_variable_set(:@unity_configuration_mutex, Mutex.new)
12
13
  end
13
14
 
14
15
  def configurations_container
15
16
  @configurations_container
16
17
  end
17
18
 
18
- def configuration_for(type, path)
19
- config = @configurations_container[path]
19
+ def configuration(name, lazy: false, &block)
20
+ @unity_configurations[name] = block
21
+ configuration_for(name) if lazy == false
22
+ end
23
+
24
+ def configuration_for(name)
25
+ config = @unity_configuration_values[name]
20
26
  return config unless config.nil?
21
27
 
22
- @configurations_container_mutex.synchronize do
23
- @configurations_container[path] ||= \
24
- case type
25
- when :yaml, :yml then YAML.load_file(path)
26
- when :json then JSON.load(File.new(path))
27
- else
28
- raise Error, "File type '#{type}' not supported"
29
- end
28
+ @unity_configuration_mutex.synchronize do
29
+ @unity_configuration_values[name] ||= @unity_configurations[name].call
30
30
  end
31
31
  end
32
32
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: unity-configuration-container
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - saluzafa
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-03-16 00:00:00.000000000 Z
11
+ date: 2022-05-12 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Thread-safe configuration container
14
14
  email:
@@ -49,7 +49,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
49
49
  - !ruby/object:Gem::Version
50
50
  version: '0'
51
51
  requirements: []
52
- rubygems_version: 3.2.3
52
+ rubygems_version: 3.3.3
53
53
  signing_key:
54
54
  specification_version: 4
55
55
  summary: Configuration Container