config_files 0.1.7 → 0.2.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/.github/workflows/ci.yml +111 -0
- data/.gitignore +2 -5
- data/.rubocop.yml +81 -0
- data/CHANGELOG.md +166 -0
- data/Gemfile +12 -1
- data/MULTI_RUBY_SETUP.md +160 -0
- data/README.md +260 -23
- data/Rakefile +26 -3
- data/TESTING.md +226 -0
- data/config_files.gemspec +12 -9
- data/docker/Dockerfile.test +32 -0
- data/lib/config_files/file_factory.rb +7 -3
- data/lib/config_files/loader_factory.rb +35 -11
- data/lib/config_files/loaders/base_parser.rb +133 -0
- data/lib/config_files/loaders/conf.rb +61 -0
- data/lib/config_files/loaders/default.rb +3 -1
- data/lib/config_files/loaders/ini.rb +48 -0
- data/lib/config_files/loaders/json.rb +3 -1
- data/lib/config_files/loaders/xml.rb +67 -0
- data/lib/config_files/loaders/yaml.rb +12 -1
- data/lib/config_files/loaders.rb +6 -1
- data/lib/config_files/version.rb +3 -1
- data/lib/config_files.rb +52 -17
- data/lib/meta.rb +3 -1
- data/scripts/install_rubies_asdf.sh +187 -0
- data/scripts/test_docker.sh +96 -0
- data/scripts/test_multiple_rubies.sh +295 -0
- data/test/comprehensive_multi_directory_test.rb +168 -0
- data/test/config/dummy.json +10 -0
- data/test/config/dummy.yml +6 -0
- data/test/config_files_test.rb +8 -6
- data/test/etc/dummy.conf +14 -2
- data/test/etc/dummy.ini +12 -0
- data/test/etc/dummy.xml +13 -0
- data/test/load_robustness_test.rb +87 -0
- data/test/loader_factory_test.rb +10 -10
- data/test/loaders_test.rb +362 -0
- data/test/local/dummy.json +10 -0
- data/test/local/dummy.yml +6 -0
- data/test/mixed_format_test.rb +152 -0
- data/test/multi_directory_test.rb +126 -0
- data/test/stray_files_test.rb +72 -0
- data/test/test_helper.rb +3 -0
- metadata +45 -25
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
$LOAD_PATH.push(File.join(File.dirname(__FILE__), '..', 'lib'))
|
|
4
|
+
require 'minitest/autorun'
|
|
5
|
+
require 'config_files'
|
|
6
|
+
require 'fileutils'
|
|
7
|
+
require 'tmpdir'
|
|
8
|
+
|
|
9
|
+
# Files next to a config file that share its name but are not config files
|
|
10
|
+
# (editor backups, saved copies) must not be loaded or merged.
|
|
11
|
+
class StrayFilesTest < Minitest::Test
|
|
12
|
+
def setup
|
|
13
|
+
@dir = Dir.mktmpdir('config_files_stray')
|
|
14
|
+
File.write(File.join(@dir, 'dds.yaml'), "current: yes\nshared: new\n")
|
|
15
|
+
@klass = Class.new do
|
|
16
|
+
include ConfigFiles
|
|
17
|
+
end
|
|
18
|
+
@klass.config_directories(etc: [@dir])
|
|
19
|
+
@klass.dynamic_config_files(:dds)
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def teardown
|
|
23
|
+
FileUtils.rm_rf(@dir)
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
def write(name, content = "shared: old\nstale: true\n")
|
|
27
|
+
File.write(File.join(@dir, name), content)
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
def loaded_names
|
|
31
|
+
@klass.send(:all_config_files, :dds).map { |f| File.basename(f) }
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
def test_save_file_beside_yaml_is_ignored
|
|
35
|
+
write('dds.yaml.save')
|
|
36
|
+
|
|
37
|
+
assert_equal(['dds.yaml'], loaded_names)
|
|
38
|
+
assert_equal('new', @klass.dds[:shared])
|
|
39
|
+
assert_nil(@klass.dds[:stale])
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
def test_common_backup_suffixes_are_ignored
|
|
43
|
+
%w[dds.yaml.bak dds.yaml.orig dds.yaml~ dds.bak dds.txt].each { |name| write(name) }
|
|
44
|
+
|
|
45
|
+
assert_equal(['dds.yaml'], loaded_names)
|
|
46
|
+
assert_equal('new', @klass.dds[:shared])
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
def test_differently_named_file_with_registered_extension_is_ignored
|
|
50
|
+
write('dds.old.yaml')
|
|
51
|
+
|
|
52
|
+
assert_equal(['dds.yaml'], loaded_names)
|
|
53
|
+
assert_equal('new', @klass.dds[:shared])
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
def test_every_registered_extension_is_still_loaded
|
|
57
|
+
write('dds.yml', "yml: true\n")
|
|
58
|
+
write('dds.json', '{"json": true}')
|
|
59
|
+
write('dds.conf', "conf=true\n")
|
|
60
|
+
write('dds.ini', "ini=true\n")
|
|
61
|
+
write('dds.xml', '<config><xml>true</xml></config>')
|
|
62
|
+
|
|
63
|
+
assert_equal(%w[dds.conf dds.ini dds.json dds.xml dds.yaml dds.yml], loaded_names)
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
def test_extension_match_is_case_insensitive
|
|
67
|
+
FileUtils.rm(File.join(@dir, 'dds.yaml'))
|
|
68
|
+
write('dds.YAML', "upper: true\n")
|
|
69
|
+
|
|
70
|
+
assert_equal(['dds.YAML'], loaded_names)
|
|
71
|
+
end
|
|
72
|
+
end
|
data/test/test_helper.rb
ADDED
metadata
CHANGED
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: config_files
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.2.2
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Paul McKibbin
|
|
8
|
-
autorequire:
|
|
9
8
|
bindir: bin
|
|
10
9
|
cert_chain: []
|
|
11
|
-
date:
|
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
12
11
|
dependencies:
|
|
13
12
|
- !ruby/object:Gem::Dependency
|
|
14
13
|
name: activesupport
|
|
@@ -16,61 +15,86 @@ dependencies:
|
|
|
16
15
|
requirements:
|
|
17
16
|
- - ">="
|
|
18
17
|
- !ruby/object:Gem::Version
|
|
19
|
-
version:
|
|
18
|
+
version: '6.1'
|
|
20
19
|
type: :runtime
|
|
21
20
|
prerelease: false
|
|
22
21
|
version_requirements: !ruby/object:Gem::Requirement
|
|
23
22
|
requirements:
|
|
24
23
|
- - ">="
|
|
25
24
|
- !ruby/object:Gem::Version
|
|
26
|
-
version:
|
|
25
|
+
version: '6.1'
|
|
27
26
|
- !ruby/object:Gem::Dependency
|
|
28
|
-
name:
|
|
27
|
+
name: rexml
|
|
29
28
|
requirement: !ruby/object:Gem::Requirement
|
|
30
29
|
requirements:
|
|
31
|
-
- - "
|
|
30
|
+
- - "~>"
|
|
32
31
|
- !ruby/object:Gem::Version
|
|
33
|
-
version: '
|
|
34
|
-
type: :
|
|
32
|
+
version: '3.2'
|
|
33
|
+
type: :runtime
|
|
35
34
|
prerelease: false
|
|
36
35
|
version_requirements: !ruby/object:Gem::Requirement
|
|
37
36
|
requirements:
|
|
38
|
-
- - "
|
|
37
|
+
- - "~>"
|
|
39
38
|
- !ruby/object:Gem::Version
|
|
40
|
-
version: '
|
|
41
|
-
description:
|
|
42
|
-
formats by presenting them as a hash.
|
|
39
|
+
version: '3.2'
|
|
40
|
+
description: Configuration tool for cascading configuration files with multiple formats
|
|
43
41
|
email:
|
|
44
42
|
- pmckibbin@gmail.com
|
|
45
43
|
executables: []
|
|
46
44
|
extensions: []
|
|
47
45
|
extra_rdoc_files: []
|
|
48
46
|
files:
|
|
47
|
+
- ".github/workflows/ci.yml"
|
|
49
48
|
- ".gitignore"
|
|
49
|
+
- ".rubocop.yml"
|
|
50
|
+
- CHANGELOG.md
|
|
50
51
|
- Gemfile
|
|
51
52
|
- LICENCE.txt
|
|
53
|
+
- MULTI_RUBY_SETUP.md
|
|
52
54
|
- README.md
|
|
53
55
|
- Rakefile
|
|
56
|
+
- TESTING.md
|
|
54
57
|
- config_files.gemspec
|
|
58
|
+
- docker/Dockerfile.test
|
|
55
59
|
- lib/config_files.rb
|
|
56
60
|
- lib/config_files/file_factory.rb
|
|
57
61
|
- lib/config_files/loader_factory.rb
|
|
58
62
|
- lib/config_files/loaders.rb
|
|
63
|
+
- lib/config_files/loaders/base_parser.rb
|
|
64
|
+
- lib/config_files/loaders/conf.rb
|
|
59
65
|
- lib/config_files/loaders/default.rb
|
|
66
|
+
- lib/config_files/loaders/ini.rb
|
|
60
67
|
- lib/config_files/loaders/json.rb
|
|
68
|
+
- lib/config_files/loaders/xml.rb
|
|
61
69
|
- lib/config_files/loaders/yaml.rb
|
|
62
70
|
- lib/config_files/version.rb
|
|
63
71
|
- lib/meta.rb
|
|
72
|
+
- scripts/install_rubies_asdf.sh
|
|
73
|
+
- scripts/test_docker.sh
|
|
74
|
+
- scripts/test_multiple_rubies.sh
|
|
75
|
+
- test/comprehensive_multi_directory_test.rb
|
|
76
|
+
- test/config/dummy.json
|
|
77
|
+
- test/config/dummy.yml
|
|
64
78
|
- test/config_files_test.rb
|
|
65
79
|
- test/etc/dummy.conf
|
|
80
|
+
- test/etc/dummy.ini
|
|
66
81
|
- test/etc/dummy.json
|
|
82
|
+
- test/etc/dummy.xml
|
|
67
83
|
- test/etc/dummy.yml
|
|
84
|
+
- test/load_robustness_test.rb
|
|
68
85
|
- test/loader_factory_test.rb
|
|
86
|
+
- test/loaders_test.rb
|
|
87
|
+
- test/local/dummy.json
|
|
88
|
+
- test/local/dummy.yml
|
|
89
|
+
- test/mixed_format_test.rb
|
|
90
|
+
- test/multi_directory_test.rb
|
|
91
|
+
- test/stray_files_test.rb
|
|
92
|
+
- test/test_helper.rb
|
|
69
93
|
homepage: https://github.com/blackrat/config_files
|
|
70
94
|
licenses:
|
|
71
95
|
- MIT
|
|
72
|
-
metadata:
|
|
73
|
-
|
|
96
|
+
metadata:
|
|
97
|
+
rubygems_mfa_required: 'true'
|
|
74
98
|
rdoc_options: []
|
|
75
99
|
require_paths:
|
|
76
100
|
- lib
|
|
@@ -78,22 +102,18 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
78
102
|
requirements:
|
|
79
103
|
- - ">="
|
|
80
104
|
- !ruby/object:Gem::Version
|
|
81
|
-
version:
|
|
105
|
+
version: 2.7.0
|
|
82
106
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
83
107
|
requirements:
|
|
84
108
|
- - ">="
|
|
85
109
|
- !ruby/object:Gem::Version
|
|
86
110
|
version: '0'
|
|
87
111
|
requirements: []
|
|
88
|
-
rubygems_version:
|
|
89
|
-
signing_key:
|
|
112
|
+
rubygems_version: 4.0.16
|
|
90
113
|
specification_version: 4
|
|
91
114
|
summary: ConfigFiles is a configuration file access tool. It parses multiple configuration
|
|
92
115
|
files in multiple formats and presents a consistent block to the application with
|
|
93
|
-
options to cache or use the files dynamically
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
- test/etc/dummy.json
|
|
98
|
-
- test/etc/dummy.yml
|
|
99
|
-
- test/loader_factory_test.rb
|
|
116
|
+
options to cache or use the files dynamically. It uses a priority directory ordering
|
|
117
|
+
to find the files, and an alphabetical ordering to give precedence to the files
|
|
118
|
+
in that directory.
|
|
119
|
+
test_files: []
|