gonfic 0.6.0 → 0.6.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/gonfic/version.rb +1 -1
- data/lib/gonfic.rb +26 -9
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7b8810655c20a36c4ae9220d82652bd740f7a9b108f62fa6c34400c39d8af4d0
|
4
|
+
data.tar.gz: 4202e4993d903c3fe560730ff88e798728617f2db71d92bc9f5de1127ca30888
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4dd9ed806e8982e2be4103930ab51291b3c93c4163f044b5ebbdd63edc72b6bf369d4b2be8c597c5da66a8d83bce4e116171f1021c4238284e54cc6a3f36092b
|
7
|
+
data.tar.gz: 6828d7979ccc5589531c81d2f4f063fcf5d8511749f97445d58c6a8aff6ce2befa75a808d67f6f1e8db89d843a837cee237a5feb40a981146e9567b9a1473432
|
data/lib/gonfic/version.rb
CHANGED
data/lib/gonfic.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
require 'yaml'
|
2
|
+
|
1
3
|
require_relative 'gonfic/version'
|
2
4
|
require_relative 'gonfic/config'
|
3
5
|
require_relative 'gonfic/env_extractor'
|
@@ -12,16 +14,25 @@ module Gonfic
|
|
12
14
|
filename: nil, file_loader: YAML_FILE_LOADER, directories: Directories.home_then_here,
|
13
15
|
env_variable_prefix: EnvExtractor.env_prefix_from_filename(filename)
|
14
16
|
)
|
15
|
-
|
16
|
-
|
17
|
-
directories
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
17
|
+
configs =
|
18
|
+
configs_from_defaults(defaults: defaults) +
|
19
|
+
configs_from_files(filename: filename, file_loader: file_loader, directories: directories) +
|
20
|
+
configs_from_env(env_variable_prefix: env_variable_prefix, defaults: defaults)
|
21
|
+
|
22
|
+
configs.reduce(:merge!)
|
23
|
+
end
|
24
|
+
|
25
|
+
def self.configs_from_defaults(defaults:)
|
26
|
+
[Config.new(defaults)]
|
27
|
+
end
|
28
|
+
|
29
|
+
def self.configs_from_files(filename:, file_loader:, directories:)
|
30
|
+
return [] unless filename
|
31
|
+
|
32
|
+
directories.map do |directory|
|
33
|
+
filepath = File.expand_path(File.join(directory, filename))
|
34
|
+
load_configuration_file(filepath, file_loader)
|
23
35
|
end
|
24
|
-
config
|
25
36
|
end
|
26
37
|
|
27
38
|
def self.load_configuration_file(filename, file_loader)
|
@@ -32,4 +43,10 @@ module Gonfic
|
|
32
43
|
Hashie.logger.error(e)
|
33
44
|
{}
|
34
45
|
end
|
46
|
+
|
47
|
+
def self.configs_from_env(env_variable_prefix:, defaults:)
|
48
|
+
return [] unless env_variable_prefix
|
49
|
+
|
50
|
+
[EnvExtractor.extract_variables_from_env(prefix: env_variable_prefix, defaults: defaults)]
|
51
|
+
end
|
35
52
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gonfic
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.6.
|
4
|
+
version: 0.6.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Emil Chludziński
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-08-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: hashie
|