gonfic 0.3.0 → 0.4.2
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/gonfic.gemspec +1 -1
- data/lib/gonfic/version.rb +5 -5
- data/lib/gonfic.rb +13 -5
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: dcb47c69de0e96e8ef069e61e166a70a7e40b8fe89128798ec9d49ace69e9607
|
4
|
+
data.tar.gz: b6556140b3495ddf655cc26365ebdc30dc9486a12e2179ca85b51d68c3f9710f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3b1a43a997e1fea31cd4338194c9a3db887623b4646b8939c910794b2efa11219d7ac26f671907d4c2520be9e745bb545ace7d91fd8135f7bc3b54e597c006cc
|
7
|
+
data.tar.gz: e7239f4d73c722b01ddc05a70789ec6c0461525029983f4d3777bbee15106d86899fab408fbcd9d4f2ffa93cd37d4df1b14a64cd71003f98dedebc7caf98647b
|
data/gonfic.gemspec
CHANGED
@@ -10,7 +10,7 @@ Gem::Specification.new do |spec|
|
|
10
10
|
|
11
11
|
spec.summary = 'Gonfic - merge config from ~/, ./, ENV, and OptionParser - access as Hashie::Mash.'
|
12
12
|
spec.description = <<~DESCRIPTION
|
13
|
-
Gonfic
|
13
|
+
Gonfic:
|
14
14
|
Configuration gem for commandline tools.
|
15
15
|
Provides easy access to config, merged from multiple sources in order of specificity.
|
16
16
|
DESCRIPTION
|
data/lib/gonfic/version.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Gonfic
|
4
|
-
VERSION = '0.
|
5
|
-
end
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Gonfic
|
4
|
+
VERSION = '0.4.2'
|
5
|
+
end
|
data/lib/gonfic.rb
CHANGED
@@ -5,13 +5,21 @@ require_relative 'gonfic/config'
|
|
5
5
|
|
6
6
|
# external interface to creating a Config with data loaded from files
|
7
7
|
module Gonfic
|
8
|
-
|
8
|
+
FILE_LOADER = ->(filename){ YAML.safe_load(File.read(filename)) }
|
9
|
+
|
10
|
+
def self.new(defaults: {}, filename: nil, file_loader: FILE_LOADER)
|
9
11
|
config = Config.new(defaults)
|
10
|
-
config.merge!(load_configuration_file("~/#{filename}"))
|
11
|
-
config.merge!(load_configuration_file("./#{filename}"))
|
12
|
+
config.merge!(load_configuration_file("~/#{filename}", file_loader)) if filename
|
13
|
+
config.merge!(load_configuration_file("./#{filename}", file_loader)) if filename
|
14
|
+
config
|
12
15
|
end
|
13
16
|
|
14
|
-
def self.load_configuration_file(filename)
|
15
|
-
|
17
|
+
def self.load_configuration_file(filename, file_loader)
|
18
|
+
return {} unless File.exist?(filename)
|
19
|
+
|
20
|
+
file_loader.call(filename)
|
21
|
+
rescue StandardError => e
|
22
|
+
Hashie.logger.error(e)
|
23
|
+
{}
|
16
24
|
end
|
17
25
|
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.
|
4
|
+
version: 0.4.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-07-
|
11
|
+
date: 2023-07-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: hashie
|
@@ -25,7 +25,7 @@ dependencies:
|
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '0'
|
27
27
|
description: |
|
28
|
-
Gonfic
|
28
|
+
Gonfic:
|
29
29
|
Configuration gem for commandline tools.
|
30
30
|
Provides easy access to config, merged from multiple sources in order of specificity.
|
31
31
|
email:
|