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.
Files changed (45) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/ci.yml +111 -0
  3. data/.gitignore +2 -5
  4. data/.rubocop.yml +81 -0
  5. data/CHANGELOG.md +166 -0
  6. data/Gemfile +12 -1
  7. data/MULTI_RUBY_SETUP.md +160 -0
  8. data/README.md +260 -23
  9. data/Rakefile +26 -3
  10. data/TESTING.md +226 -0
  11. data/config_files.gemspec +12 -9
  12. data/docker/Dockerfile.test +32 -0
  13. data/lib/config_files/file_factory.rb +7 -3
  14. data/lib/config_files/loader_factory.rb +35 -11
  15. data/lib/config_files/loaders/base_parser.rb +133 -0
  16. data/lib/config_files/loaders/conf.rb +61 -0
  17. data/lib/config_files/loaders/default.rb +3 -1
  18. data/lib/config_files/loaders/ini.rb +48 -0
  19. data/lib/config_files/loaders/json.rb +3 -1
  20. data/lib/config_files/loaders/xml.rb +67 -0
  21. data/lib/config_files/loaders/yaml.rb +12 -1
  22. data/lib/config_files/loaders.rb +6 -1
  23. data/lib/config_files/version.rb +3 -1
  24. data/lib/config_files.rb +52 -17
  25. data/lib/meta.rb +3 -1
  26. data/scripts/install_rubies_asdf.sh +187 -0
  27. data/scripts/test_docker.sh +96 -0
  28. data/scripts/test_multiple_rubies.sh +295 -0
  29. data/test/comprehensive_multi_directory_test.rb +168 -0
  30. data/test/config/dummy.json +10 -0
  31. data/test/config/dummy.yml +6 -0
  32. data/test/config_files_test.rb +8 -6
  33. data/test/etc/dummy.conf +14 -2
  34. data/test/etc/dummy.ini +12 -0
  35. data/test/etc/dummy.xml +13 -0
  36. data/test/load_robustness_test.rb +87 -0
  37. data/test/loader_factory_test.rb +10 -10
  38. data/test/loaders_test.rb +362 -0
  39. data/test/local/dummy.json +10 -0
  40. data/test/local/dummy.yml +6 -0
  41. data/test/mixed_format_test.rb +152 -0
  42. data/test/multi_directory_test.rb +126 -0
  43. data/test/stray_files_test.rb +72 -0
  44. data/test/test_helper.rb +3 -0
  45. metadata +45 -25
data/README.md CHANGED
@@ -1,38 +1,275 @@
1
- *Description*
1
+ # ConfigFiles
2
2
 
3
- Since it no longer just deals with yaml files as an input, *blackrat_yaml_config* has been renamed to *config_files*
4
- Configuration file manager.
3
+ [![CI](https://github.com/blackrat/config_files/workflows/CI/badge.svg)](https://github.com/blackrat/config_files/actions)
4
+ [![Ruby Version](https://img.shields.io/badge/ruby-%3E%3D%202.7.0-ruby.svg)](https://www.ruby-lang.org/en/downloads/)
5
+ [![Gem Version](https://badge.fury.io/rb/config_files.svg)](https://badge.fury.io/rb/config_files)
6
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
5
7
 
6
- *Features*
8
+ Load configuration files from multiple directories and merge them together. Supports YAML, JSON, and other formats.
7
9
 
8
- Searches for first match in multiple directories for configuration file
9
- Allows for dynamically updated or static config files
10
+ ## Features
10
11
 
11
- *Example*
12
+ - Load configs from multiple directories
13
+ - Merge YAML, JSON, and other file formats
14
+ - Directory precedence (first directory wins)
15
+ - Static (cached) or dynamic (reloaded) config files
16
+ - Returns `HashWithIndifferentAccess` for easy key access
12
17
 
13
- require 'config_files'
18
+ ## Installation
14
19
 
15
- class Dummy
16
- include ConfigFiles #mixin the config_directories and config_files generators
20
+ Add to your Gemfile:
17
21
 
18
- #search directories (in order). The system will search for the file in the following directories
19
- config_directories :etc=>['~/.dummy','/opt/dummy/config','/etc/default/dummy','/etc']
22
+ ```ruby
23
+ gem 'config_files'
24
+ ```
20
25
 
21
- #The dummy.yml and another_yaml_file.yml will be pre-loaded.
22
- static_config_files :dummy, :another_yaml_file
26
+ Or install it:
23
27
 
24
- #yet_another_yaml_file.yml will be read every time the .yet_another_yaml_file method is accessed.
25
- dynamic_config_files :yet_another_yaml_file
28
+ ```bash
29
+ gem install config_files
30
+ ```
26
31
 
27
- def use_config
28
- some_method(Dummy.dummy[:key]) #extract the constant values from the :key in dummy.yml
29
- another_method(Dummy.yet_another_yaml_file[:another_key]) #extract the constant value from the :another_key in yet_another_yaml_file.yml
30
- end
32
+ ### Security: ActiveSupport version
31
33
 
32
- end
34
+ ActiveSupport releases before 8.0.5.2 are affected by a denial-of-service advisory in `safe_constantize`. config_files supports ActiveSupport 6.1 and later so that older Rubies keep working, which means your bundle may resolve to an affected version.
33
35
 
36
+ If you are on Ruby 3.2 or later, require a fixed version in your Gemfile:
34
37
 
38
+ ```ruby
39
+ gem 'activesupport', '>= 8.0.5.2'
40
+ ```
35
41
 
36
- *Todo*
42
+ On Ruby 2.7 to 3.1, ActiveSupport 8 is not available; whether to accept the advisory or upgrade Ruby is your call.
37
43
 
38
- Allow for different keys to be stored in files in different subdirectories to allow for overridable defaults
44
+ ## Usage
45
+
46
+ ```ruby
47
+ require 'config_files'
48
+
49
+ class MyApp
50
+ include ConfigFiles
51
+
52
+ # Search these directories in order (first wins)
53
+ config_directories etc: [
54
+ 'config/production',
55
+ 'config/staging',
56
+ 'config/defaults'
57
+ ]
58
+
59
+ # Load these config files
60
+ static_config_files :database, :app_settings
61
+ dynamic_config_files :feature_flags
62
+ end
63
+
64
+ # Use the configs
65
+ MyApp.database[:host] # => "prod-db.example.com"
66
+ MyApp.app_settings[:debug] # => false
67
+ MyApp.feature_flags[:new_ui] # => true (reloaded each time)
68
+ ```
69
+
70
+ ## How it works
71
+
72
+ The gem searches for config files in each directory you specify. If you have:
73
+
74
+ ```
75
+ config/production/database.yml
76
+ config/staging/database.yml
77
+ config/defaults/database.yml
78
+ ```
79
+
80
+ And you configure directories as `['config/production', 'config/staging', 'config/defaults']`, then:
81
+
82
+ 1. It loads all three files
83
+ 2. Merges them together
84
+ 3. Values from `production` override `staging` and `defaults`
85
+ 4. Values from `staging` override `defaults`
86
+ 5. Returns the merged result
87
+
88
+ ## Multiple file formats
89
+
90
+ You can mix YAML and JSON files:
91
+
92
+ ```
93
+ config/
94
+ ├── app.yml # YAML format
95
+ ├── app.json # JSON format
96
+ └── app.conf # Other formats
97
+ ```
98
+
99
+ Files named `<name>.<ext>` get merged together when `<ext>` is a supported format: `yaml`, `yml`, `json`, `xml`, `conf` or `ini` (case-insensitive). Anything else beside them, such as `app.yml.save`, `app.yml~` or `app.old.yml`, is ignored. Files are processed alphabetically, so `app.json` loads before `app.yml`.
100
+
101
+ ## Static vs Dynamic
102
+
103
+ ```ruby
104
+ class AppConfig
105
+ include ConfigFiles
106
+ config_directories etc: ['config']
107
+
108
+ # Static: loaded once and cached
109
+ static_config_files :database
110
+
111
+ # Dynamic: reloaded from disk each time
112
+ dynamic_config_files :feature_flags
113
+ end
114
+
115
+ AppConfig.database # Fast (cached)
116
+ AppConfig.feature_flags # Slower (reads from disk)
117
+ ```
118
+
119
+ Use static for configs that don't change. Use dynamic for configs that might change while your app is running.
120
+
121
+ ## Directory precedence
122
+
123
+ Earlier directories in the list win:
124
+
125
+ ```ruby
126
+ config_directories etc: [
127
+ 'config/production', # Highest priority
128
+ 'config/staging', # Medium priority
129
+ 'config/defaults' # Lowest priority
130
+ ]
131
+ ```
132
+
133
+ So if `production/app.yml` has `debug: false` and `defaults/app.yml` has `debug: true`, the result will have `debug: false`.
134
+
135
+ ## Configuration merging
136
+
137
+ Configs are deep-merged. Given these files:
138
+
139
+ ```yaml
140
+ # config/defaults/app.yml
141
+ database:
142
+ host: localhost
143
+ port: 5432
144
+ pool_size: 5
145
+ app:
146
+ debug: true
147
+ name: MyApp
148
+ ```
149
+
150
+ ```yaml
151
+ # config/production/app.yml
152
+ database:
153
+ host: prod-db.example.com
154
+ pool_size: 20
155
+ app:
156
+ debug: false
157
+ ```
158
+
159
+ The result is:
160
+
161
+ ```ruby
162
+ {
163
+ database: {
164
+ host: "prod-db.example.com", # from production
165
+ port: 5432, # from defaults
166
+ pool_size: 20 # from production
167
+ },
168
+ app: {
169
+ debug: false, # from production
170
+ name: "MyApp" # from defaults
171
+ }
172
+ }
173
+ ```
174
+
175
+ ## Custom directory keys
176
+
177
+ You can use different directory sets:
178
+
179
+ ```ruby
180
+ class AppConfig
181
+ include ConfigFiles
182
+
183
+ config_directories(
184
+ etc: ['config/app', '/etc/myapp'],
185
+ secrets: ['secrets/production', 'secrets/shared']
186
+ )
187
+
188
+ static_config_files :database # searches in 'etc' directories
189
+ end
190
+
191
+ # Access the directory paths
192
+ AppConfig.etc_dir # => ["/full/path/to/config/app", "/etc/myapp"]
193
+ AppConfig.secrets_dir # => ["/full/path/to/secrets/production", ...]
194
+ ```
195
+
196
+ ## Error handling
197
+
198
+ Missing files and directories are ignored:
199
+
200
+ ```ruby
201
+ class AppConfig
202
+ include ConfigFiles
203
+
204
+ config_directories etc: [
205
+ 'config/nonexistent', # ignored
206
+ 'config/existing' # used
207
+ ]
208
+
209
+ static_config_files :missing_file
210
+ end
211
+
212
+ AppConfig.missing_file # => {} (empty hash)
213
+ ```
214
+
215
+ An empty or comment-only file contributes nothing. A file whose top level is not a mapping (a list or a plain value) raises `ConfigFiles::InvalidConfigError` naming the file.
216
+
217
+ ## Testing
218
+
219
+ Run the tests:
220
+
221
+ ```bash
222
+ bundle exec rake test
223
+ ```
224
+
225
+ Test with multiple Ruby versions:
226
+
227
+ ```bash
228
+ ./scripts/test_multiple_rubies.sh
229
+ ```
230
+
231
+ The gem is tested on Ruby 2.7+ with ActiveSupport 6.1+. See [TESTING.md](TESTING.md) for details.
232
+
233
+ ## API
234
+
235
+ ### config_directories(hash)
236
+
237
+ Define search directories:
238
+
239
+ ```ruby
240
+ config_directories etc: ['dir1', 'dir2']
241
+ ```
242
+
243
+ ### static_config_files(*files)
244
+
245
+ Load files once and cache them:
246
+
247
+ ```ruby
248
+ static_config_files :database, :app_settings
249
+ ```
250
+
251
+ ### dynamic_config_files(*files)
252
+
253
+ Reload files on each access:
254
+
255
+ ```ruby
256
+ dynamic_config_files :feature_flags
257
+ ```
258
+
259
+ ## Contributing
260
+
261
+ 1. Fork it
262
+ 2. Create your feature branch (`git checkout -b my-feature`)
263
+ 3. Make your changes
264
+ 4. Run the tests (`bundle exec rake test`)
265
+ 5. Commit your changes (`git commit -am 'Add feature'`)
266
+ 6. Push to the branch (`git push origin my-feature`)
267
+ 7. Create a Pull Request
268
+
269
+ ## License
270
+
271
+ MIT License. See [LICENCE.txt](LICENCE.txt) for details.
272
+
273
+ ## Changelog
274
+
275
+ See [CHANGELOG.md](CHANGELOG.md) for version history and changes.
data/Rakefile CHANGED
@@ -1,8 +1,31 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'rake/testtask'
2
4
 
3
- Rake::TestTask.new do |t|
5
+ Rake::TestTask.new(:test) do |t|
4
6
  t.libs << 'test'
7
+ t.libs << 'lib'
8
+ t.test_files = FileList['test/*_test.rb']
9
+ t.verbose = true
10
+ end
11
+
12
+ task default: :test
13
+
14
+ desc "Run tests with verbose output"
15
+ task :test_verbose do
16
+ sh "find test -name '*_test.rb' -exec bundle exec ruby {} \\;"
5
17
  end
6
18
 
7
- desc "Run tests"
8
- task :default => :test
19
+ desc "Run tests for a specific Ruby version (for local testing)"
20
+ task :test_ruby_version do
21
+ ruby_version = ENV['RUBY_VERSION'] || RUBY_VERSION
22
+ puts "Running tests with Ruby #{ruby_version}"
23
+ Rake::Task[:test].invoke
24
+ end
25
+
26
+ desc "Clean up test artifacts"
27
+ task :clean do
28
+ FileUtils.rm_rf('test/format_test')
29
+ FileUtils.rm_rf('test/comprehensive')
30
+ FileUtils.rm_rf('test/order_test')
31
+ end
data/TESTING.md ADDED
@@ -0,0 +1,226 @@
1
+ # Testing ConfigFiles
2
+
3
+ This document describes how to test the ConfigFiles gem across multiple Ruby versions and ActiveSupport versions.
4
+
5
+ ## Supported Versions
6
+
7
+ ### Ruby Versions
8
+ - **Ruby 2.7+**: Full support with ActiveSupport 6.1+ and 7.0+
9
+ - **Ruby 3.0+**: Full support with all ActiveSupport versions
10
+ - **Ruby 3.1+**: Full support with all ActiveSupport versions including 7.1+ and 7.2+
11
+
12
+ ### ActiveSupport Versions
13
+ - **ActiveSupport 6.1**: Compatible with Ruby 2.7+
14
+ - **ActiveSupport 7.0**: Compatible with Ruby 2.7+
15
+ - **ActiveSupport 7.1**: Compatible with Ruby 3.1+
16
+ - **ActiveSupport 7.2**: Compatible with Ruby 3.1+
17
+
18
+ ## Testing Methods
19
+
20
+ ### 1. GitHub Actions (Recommended for CI/CD)
21
+
22
+ The project uses GitHub Actions for automated testing across multiple Ruby and ActiveSupport versions.
23
+
24
+ **Configuration**: `.github/workflows/ci.yml`
25
+
26
+ **Features**:
27
+ - Tests Ruby 2.7, 3.0, 3.1, 3.2, 3.3, and 3.4
28
+ - Tests ActiveSupport 6.1, 7.0, 7.1, and 7.2
29
+ - Automatically excludes incompatible combinations
30
+ - Includes linting with RuboCop
31
+ - Runs on every push and pull request
32
+
33
+ ### 2. Local Testing with Multiple Ruby Versions
34
+
35
+ #### Using Multi-Manager Script (asdf/rbenv/rvm)
36
+
37
+ ```bash
38
+ # The script automatically detects which Ruby version manager you have installed:
39
+ # - asdf (recommended)
40
+ # - rbenv
41
+ # - rvm
42
+
43
+ # Install Ruby versions (choose your manager):
44
+ # asdf: ./scripts/install_rubies_asdf.sh
45
+ # rbenv: rbenv install 2.7.8 3.0.6 3.1.4 3.2.2 3.3.0 3.4.1
46
+ # rvm: rvm install 2.7.8 3.0.6 3.1.4 3.2.2 3.3.0 3.4.1
47
+
48
+ # Run the multi-Ruby test script
49
+ ./scripts/test_multiple_rubies.sh
50
+ ```
51
+
52
+ This script will:
53
+ - Auto-detect your Ruby version manager (asdf, rbenv, or rvm)
54
+ - Check which Ruby versions are installed
55
+ - Offer to install missing Ruby versions
56
+ - Test each Ruby version with multiple ActiveSupport versions
57
+ - Skip incompatible combinations
58
+ - Provide a summary of results
59
+
60
+ #### asdf-Specific Installation
61
+
62
+ ```bash
63
+ # Install all Ruby versions at once with asdf
64
+ ./scripts/install_rubies_asdf.sh
65
+
66
+ # Then run tests
67
+ ./scripts/test_multiple_rubies.sh
68
+ ```
69
+
70
+ #### Using Docker
71
+
72
+ ```bash
73
+ # Test all combinations using Docker
74
+ ./scripts/test_docker.sh
75
+
76
+ # Test a specific Ruby version
77
+ docker build --build-arg RUBY_VERSION=3.3 --build-arg ACTIVESUPPORT_VERSION="~> 7.0" -f docker/Dockerfile.test -t config_files_test .
78
+ docker run --rm config_files_test
79
+ ```
80
+
81
+ ### 3. Single Version Testing
82
+
83
+ #### Standard Testing
84
+ ```bash
85
+ # Install dependencies
86
+ bundle install
87
+
88
+ # Run all tests
89
+ bundle exec rake test
90
+
91
+ # Run tests with verbose output
92
+ bundle exec rake test_verbose
93
+
94
+ # Run individual test files
95
+ find test -name "*_test.rb" -exec bundle exec ruby {} \;
96
+ ```
97
+
98
+ #### Testing with Specific ActiveSupport Version
99
+ ```bash
100
+ # Create a custom Gemfile
101
+ cat > Gemfile.custom << EOF
102
+ source 'https://rubygems.org'
103
+ gemspec
104
+ gem 'activesupport', '~> 6.1.0'
105
+ gem 'minitest', '~> 5.20'
106
+ gem 'rake'
107
+ EOF
108
+
109
+ # Install and test
110
+ BUNDLE_GEMFILE=Gemfile.custom bundle install
111
+ BUNDLE_GEMFILE=Gemfile.custom bundle exec rake test
112
+ ```
113
+
114
+ ## Test Structure
115
+
116
+ ### Test Files
117
+ - `test/config_files_test.rb` - Core functionality tests
118
+ - `test/loader_factory_test.rb` - File loader tests
119
+ - `test/multi_directory_test.rb` - Multi-directory functionality
120
+ - `test/mixed_format_test.rb` - Mixed YAML/JSON format tests
121
+ - `test/comprehensive_multi_directory_test.rb` - Complex scenarios
122
+
123
+ ### Test Data
124
+ - `test/etc/` - Sample configuration files
125
+ - `test/config/` - Additional test configurations
126
+ - `test/local/` - Local override test files
127
+
128
+ ## Compatibility Testing
129
+
130
+ ### Ruby Version Compatibility
131
+
132
+ The gem uses these Ruby features that affect compatibility:
133
+
134
+ 1. **Safe Navigation Operator (`&.`)** - Requires Ruby 2.3+
135
+ 2. **Keyword Arguments** - Requires Ruby 2.0+
136
+ 3. **ActiveSupport Dependencies** - Varies by version
137
+
138
+ ### ActiveSupport Compatibility
139
+
140
+ Different ActiveSupport versions have different Ruby requirements:
141
+
142
+ - ActiveSupport 5.2: Ruby 2.2.2+
143
+ - ActiveSupport 6.0: Ruby 2.5.0+
144
+ - ActiveSupport 6.1: Ruby 2.5.0+
145
+ - ActiveSupport 7.0: Ruby 2.7.0+
146
+ - ActiveSupport 7.1: Ruby 3.1.0+
147
+ - ActiveSupport 7.2: Ruby 3.1.0+
148
+
149
+ ## Troubleshooting
150
+
151
+ ### Common Issues
152
+
153
+ 1. **Safe Navigation Operator Error**
154
+ ```
155
+ undefined method `&' for nil:NilClass
156
+ ```
157
+ **Solution**: Use Ruby 2.3+ or replace `&.` with `&& obj.`
158
+
159
+ 2. **ActiveSupport Version Conflicts**
160
+ ```
161
+ Gem::ConflictError: Unable to activate activesupport
162
+ ```
163
+ **Solution**: Check Ruby/ActiveSupport compatibility matrix above
164
+
165
+ 3. **Minitest Version Issues**
166
+ ```
167
+ cannot load such file -- mutex_m
168
+ ```
169
+ **Solution**: Add `mutex_m` gem for Ruby 3.4+
170
+
171
+ ### Running Specific Test Combinations
172
+
173
+ ```bash
174
+ # Test Ruby 3.3 with ActiveSupport 7.0
175
+ RUBY_VERSION=3.3 ACTIVESUPPORT_VERSION="~> 7.0" ./scripts/test_combination.sh
176
+
177
+ # Test with Docker
178
+ docker build --build-arg RUBY_VERSION=3.3 --build-arg ACTIVESUPPORT_VERSION="~> 7.0" -f docker/Dockerfile.test -t test .
179
+ docker run --rm test
180
+ ```
181
+
182
+ ## CI/CD Integration
183
+
184
+ ### GitHub Actions
185
+
186
+ The project automatically tests all supported combinations on:
187
+ - Push to main/master branch
188
+ - Pull requests
189
+ - Manual workflow dispatch
190
+
191
+ ### Other CI Systems
192
+
193
+ The testing approach can be adapted for other CI systems:
194
+
195
+ - **GitLab CI**: Use similar matrix strategy with `.gitlab-ci.yml`
196
+ - **CircleCI**: Use workflow matrix with different Ruby Docker images
197
+ - **Jenkins**: Use pipeline with multiple Ruby environments
198
+
199
+ ## Performance Testing
200
+
201
+ For performance testing across versions:
202
+
203
+ ```bash
204
+ # Run benchmarks (if implemented)
205
+ bundle exec rake benchmark
206
+
207
+ # Memory usage testing
208
+ bundle exec ruby -r memory_profiler test/memory_test.rb
209
+ ```
210
+
211
+ ## Contributing
212
+
213
+ When adding new features:
214
+
215
+ 1. Ensure tests pass on all supported Ruby versions
216
+ 2. Add tests for new functionality
217
+ 3. Update compatibility documentation if needed
218
+ 4. Run the full test matrix before submitting PRs
219
+
220
+ ```bash
221
+ # Quick local test
222
+ bundle exec rake test
223
+
224
+ # Full compatibility test
225
+ ./scripts/test_multiple_rubies.sh
226
+ ```
data/config_files.gemspec CHANGED
@@ -1,25 +1,28 @@
1
- lib = File.expand_path('../lib', __FILE__)
1
+ # frozen_string_literal: true
2
+
3
+ lib = File.expand_path('lib', __dir__)
2
4
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
5
  require 'config_files/version'
4
6
 
5
7
  Gem::Specification.new do |spec|
6
8
  spec.authors = ['Paul McKibbin']
7
9
  spec.email = ['pmckibbin@gmail.com']
8
- spec.description = 'A configuration tool for using multiple configuration files with multiple formats by presenting them as a hash.'
10
+ spec.description = 'Configuration tool for cascading configuration files with multiple formats'
9
11
  spec.summary = <<-SUMMARY
10
12
  ConfigFiles is a configuration file access tool. It parses multiple configuration files in multiple formats and
11
- presents a consistent block to the application with options to cache or use the files dynamically
12
- SUMMARY
13
+ presents a consistent block to the application with options to cache or use the files dynamically. It uses a priority
14
+ directory ordering to find the files, and an alphabetical ordering to give precedence to the files in that directory.
15
+ SUMMARY
13
16
 
14
17
  spec.homepage = 'https://github.com/blackrat/config_files'
15
18
  spec.files = `git ls-files`.split($OUTPUT_RECORD_SEPARATOR)
16
- spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
17
19
  spec.name = 'config_files'
18
20
  spec.require_paths = ['lib']
19
21
  spec.version = ConfigFiles::VERSION
20
22
  spec.license = 'MIT'
21
- spec.date = '2012-11-11'
23
+ spec.required_ruby_version = '>= 2.7.0'
22
24
 
23
- spec.add_runtime_dependency 'activesupport', '>=2.2.1'
24
- spec.add_development_dependency 'rake'
25
- end
25
+ spec.add_dependency 'activesupport', '>= 6.1'
26
+ spec.add_dependency 'rexml', '~> 3.2'
27
+ spec.metadata['rubygems_mfa_required'] = 'true'
28
+ end
@@ -0,0 +1,32 @@
1
+ ARG RUBY_VERSION=3.3
2
+ FROM ruby:${RUBY_VERSION}-slim
3
+
4
+ # Install system dependencies
5
+ RUN apt-get update && apt-get install -y \
6
+ build-essential \
7
+ git \
8
+ && rm -rf /var/lib/apt/lists/*
9
+
10
+ # Set working directory
11
+ WORKDIR /app
12
+
13
+ # Copy gemspec and version file first for better caching
14
+ COPY config_files.gemspec ./
15
+ COPY lib/config_files/version.rb ./lib/config_files/
16
+
17
+ # Copy Gemfile if it exists
18
+ COPY Gemfile* ./
19
+
20
+ # Install gems
21
+ ARG ACTIVESUPPORT_VERSION="~> 7.0"
22
+ RUN echo "gem 'activesupport', '${ACTIVESUPPORT_VERSION}'" >> Gemfile.docker && \
23
+ echo "gem 'minitest', '~> 5.20'" >> Gemfile.docker && \
24
+ echo "gem 'mutex_m'" >> Gemfile.docker && \
25
+ echo "gem 'rake'" >> Gemfile.docker && \
26
+ BUNDLE_GEMFILE=Gemfile.docker bundle install
27
+
28
+ # Copy the rest of the application
29
+ COPY . .
30
+
31
+ # Run tests
32
+ CMD ["sh", "-c", "BUNDLE_GEMFILE=Gemfile.docker bundle exec rake test"]
@@ -1,14 +1,18 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module ConfigFiles
2
4
  class FileFactory
3
5
  class << self
4
6
  private
7
+
5
8
  def loader(file_name, options)
6
- LoaderFactory.(file_name, options)
9
+ LoaderFactory.call(file_name, options)
7
10
  end
8
11
 
9
12
  public
10
- def call(file_name, options={})
11
- loader(file_name, options).(file_name)
13
+
14
+ def call(file_name, options = {})
15
+ loader(file_name, options).call(file_name)
12
16
  end
13
17
  end
14
18
  end