gonfic 0.5.0 → 0.6.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 +4 -4
- data/README.md +6 -3
- data/gonfic.gemspec +1 -3
- data/lib/gonfic/directories.rb +11 -0
- data/lib/gonfic/env_extractor.rb +1 -1
- data/lib/gonfic/version.rb +1 -3
- data/lib/gonfic.rb +8 -6
- metadata +3 -4
- data/.rubocop.yml +0 -53
- data/Rakefile +0 -16
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 14e15052de540978cafed0765ee7799009e3090aabea1aa603520c4f663ce5d2
|
4
|
+
data.tar.gz: 628692d67ffafb2e96b2442817f2549b804a3d2d01370f0b12019d54bfb7bcd7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 40db1c5163d6e7654def37a1769b3ca1de9d8fb669e324cb4b1f0d35f192bf9cc5682a85d18eab82f5ad49c9ec62d60036f8496238946a2c7f4793cacd4de728
|
7
|
+
data.tar.gz: 67a77a4d33896fbced469633dcd5fa82e513abf97fe8349c8d7713c940b5d32dbd96fd4a9d8f0c608971f489d06beef4e84dd33671b1f1fcdb9967ef7b0f298e
|
data/README.md
CHANGED
@@ -58,6 +58,11 @@ The `Gonfic.new` call will peform file I/O and other operations, which can poten
|
|
58
58
|
In this way you are lazily deferring the "dangerous" operations until first usage, then memoizing.
|
59
59
|
Additionally, with access to your config via a method that's easy to stub, your test suite will be happy :)
|
60
60
|
|
61
|
+
### Providing custom list of directories
|
62
|
+
|
63
|
+
By default, `Gonfic.new` will look for `filename:` in `~/` and `./` (merging them, if both are present).
|
64
|
+
If you want to load from other directories, just set the `directories:` parameter to your list.
|
65
|
+
|
61
66
|
### Loading configuration from ENV
|
62
67
|
|
63
68
|
If you provide `filename:`, `Gonfic.new` will also check `ENV` for variables it considers relevant.
|
@@ -83,9 +88,7 @@ Your first steps should be:
|
|
83
88
|
|
84
89
|
This will run tests (Minitest) and linter (Rubocop, custom config, see `.rubocop.yml`).
|
85
90
|
|
86
|
-
Note: the repo does not force the bundle to be vendorized,
|
87
|
-
but should work fine if you set `BUNDLE_PATH: "vendor"` in your `~/.bundle/config`.
|
88
|
-
Hint, hint ;)
|
91
|
+
Note: the repo does not force the bundle to be vendorized, but should work fine if you set `BUNDLE_PATH: "vendor"` in your `~/.bundle/config`. Hint, hint ;)
|
89
92
|
|
90
93
|
You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
91
94
|
|
data/gonfic.gemspec
CHANGED
@@ -1,5 +1,3 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
1
|
require_relative 'lib/gonfic/version'
|
4
2
|
|
5
3
|
Gem::Specification.new do |spec|
|
@@ -25,7 +23,7 @@ Gem::Specification.new do |spec|
|
|
25
23
|
spec.files = Dir.chdir(__dir__) do
|
26
24
|
`git ls-files -z`.split("\x0").reject do |f|
|
27
25
|
File.expand_path(f) == __FILE__ ||
|
28
|
-
f.start_with?(*%w[bin/ test/
|
26
|
+
f.start_with?(*%w[bin/ test/ .git .rubocop.yml Gemfile Rakefile])
|
29
27
|
end
|
30
28
|
end
|
31
29
|
spec.bindir = 'exe'
|
data/lib/gonfic/env_extractor.rb
CHANGED
@@ -30,7 +30,7 @@ module Gonfic
|
|
30
30
|
|
31
31
|
def self.extract_variable(prefix:, key_name:, into:)
|
32
32
|
env_var_name = prefix + upcase_and_simplify(key_name)
|
33
|
-
into[key_name] = env
|
33
|
+
into[key_name] = env.fetch(env_var_name) if env.key?(env_var_name)
|
34
34
|
end
|
35
35
|
|
36
36
|
def self.env
|
data/lib/gonfic/version.rb
CHANGED
data/lib/gonfic.rb
CHANGED
@@ -1,21 +1,23 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
1
|
require_relative 'gonfic/version'
|
4
2
|
require_relative 'gonfic/config'
|
5
3
|
require_relative 'gonfic/env_extractor'
|
4
|
+
require_relative 'gonfic/directories'
|
6
5
|
|
7
6
|
# external interface to creating a Config with data loaded from files
|
8
7
|
module Gonfic
|
9
|
-
|
8
|
+
YAML_FILE_LOADER = ->(filename){ YAML.safe_load(File.read(filename)) }
|
10
9
|
|
11
10
|
def self.new(
|
12
11
|
defaults: {},
|
13
|
-
filename: nil, file_loader:
|
12
|
+
filename: nil, file_loader: YAML_FILE_LOADER, directories: Directories.home_then_here,
|
14
13
|
env_variable_prefix: EnvExtractor.env_prefix_from_filename(filename)
|
15
14
|
)
|
16
15
|
config = Config.new(defaults)
|
17
|
-
|
18
|
-
|
16
|
+
if filename
|
17
|
+
directories.each do |directory|
|
18
|
+
config.merge!(load_configuration_file(File.join(directory, filename), file_loader))
|
19
|
+
end
|
20
|
+
end
|
19
21
|
if env_variable_prefix
|
20
22
|
config.merge!(EnvExtractor.extract_variables_from_env(prefix: env_variable_prefix, defaults: defaults))
|
21
23
|
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.6.0
|
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-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: hashie
|
@@ -34,13 +34,12 @@ executables: []
|
|
34
34
|
extensions: []
|
35
35
|
extra_rdoc_files: []
|
36
36
|
files:
|
37
|
-
- ".rubocop.yml"
|
38
37
|
- LICENSE.txt
|
39
38
|
- README.md
|
40
|
-
- Rakefile
|
41
39
|
- gonfic.gemspec
|
42
40
|
- lib/gonfic.rb
|
43
41
|
- lib/gonfic/config.rb
|
42
|
+
- lib/gonfic/directories.rb
|
44
43
|
- lib/gonfic/env_extractor.rb
|
45
44
|
- lib/gonfic/version.rb
|
46
45
|
homepage: https://gitlab.com/tanstaafl/gonfic
|
data/.rubocop.yml
DELETED
@@ -1,53 +0,0 @@
|
|
1
|
-
---
|
2
|
-
AllCops:
|
3
|
-
TargetRubyVersion: 2.6
|
4
|
-
SuggestExtensions: false
|
5
|
-
NewCops: enable
|
6
|
-
|
7
|
-
Style/FrozenStringLiteralComment:
|
8
|
-
Enabled: false
|
9
|
-
|
10
|
-
Layout/EndOfLine:
|
11
|
-
Enabled: true
|
12
|
-
EnforcedStyle: lf
|
13
|
-
|
14
|
-
# tab country begins
|
15
|
-
Layout/IndentationStyle:
|
16
|
-
Enabled: true
|
17
|
-
EnforcedStyle: tabs
|
18
|
-
|
19
|
-
Layout/IndentationWidth: # weird setting to enable other Layout cops to work with tabs
|
20
|
-
Enabled: true
|
21
|
-
Width: 1
|
22
|
-
# tab country ends
|
23
|
-
|
24
|
-
Layout/MultilineMethodCallIndentation:
|
25
|
-
Enabled: true
|
26
|
-
EnforcedStyle: indented
|
27
|
-
|
28
|
-
Layout/SpaceBeforeBlockBraces:
|
29
|
-
Enabled: true
|
30
|
-
EnforcedStyle: no_space
|
31
|
-
|
32
|
-
Layout/LineLength:
|
33
|
-
Max: 120
|
34
|
-
|
35
|
-
Style/StringLiterals:
|
36
|
-
Enabled: true
|
37
|
-
EnforcedStyle: single_quotes
|
38
|
-
|
39
|
-
Style/StringLiteralsInInterpolation:
|
40
|
-
Enabled: true
|
41
|
-
EnforcedStyle: single_quotes
|
42
|
-
|
43
|
-
Style/TrailingCommaInArrayLiteral:
|
44
|
-
Enabled: true
|
45
|
-
EnforcedStyleForMultiline: comma
|
46
|
-
|
47
|
-
Style/TrailingCommaInHashLiteral:
|
48
|
-
Enabled: true
|
49
|
-
EnforcedStyleForMultiline: comma
|
50
|
-
|
51
|
-
Layout/SpaceInsideHashLiteralBraces:
|
52
|
-
Enabled: true
|
53
|
-
EnforcedStyle: no_space
|
data/Rakefile
DELETED
@@ -1,16 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'bundler/gem_tasks'
|
4
|
-
require 'rake/testtask'
|
5
|
-
|
6
|
-
Rake::TestTask.new(:test) do |t|
|
7
|
-
t.libs << 'test'
|
8
|
-
t.libs << 'lib'
|
9
|
-
t.test_files = FileList['test/**/test_*.rb']
|
10
|
-
end
|
11
|
-
|
12
|
-
require 'rubocop/rake_task'
|
13
|
-
|
14
|
-
RuboCop::RakeTask.new
|
15
|
-
|
16
|
-
task default: %i[rubocop test]
|