config_files 0.1.6 → 0.2.1

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 +94 -0
  3. data/.gitignore +2 -3
  4. data/.rubocop.yml +81 -0
  5. data/CHANGELOG.md +154 -0
  6. data/Gemfile +12 -1
  7. data/MULTI_RUBY_SETUP.md +158 -0
  8. data/README.md +246 -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 +20 -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 +2 -0
  22. data/lib/config_files/loaders.rb +6 -1
  23. data/lib/config_files/version.rb +3 -1
  24. data/lib/config_files.rb +34 -18
  25. data/lib/meta.rb +3 -1
  26. data/scripts/install_rubies_asdf.sh +187 -0
  27. data/scripts/test_docker.sh +91 -0
  28. data/scripts/test_multiple_rubies.sh +290 -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 +10 -8
  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/etc/dummy.yml +2 -2
  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/test_helper.rb +3 -0
  44. metadata +49 -26
  45. data/Gemfile.lock +0 -34
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0e601554ecea9bc4ad625f62936f005413b5cc13e76c25776a6abd1455dca6ff
4
- data.tar.gz: 91b7f6eeb1e07b2646c3086d4ef008b91ee04d63fee1b7b6ccb9a73c8adfd67a
3
+ metadata.gz: b055f4295d3850db10ef3fe3258f97f9c511ad4f1b244d873a0e385dba79ab1a
4
+ data.tar.gz: 6829995c49c7faf3bdc1a08b3898cf0548598a60d73202f50da76b9c4302a754
5
5
  SHA512:
6
- metadata.gz: d086ca2975a90d9035a7e81eac2a7ddaadfcbd42ca61a3cb33fbde4675b42c226bfd181c48a9dcc6206f6fd6167e26b016af977fee61b2ab02d5bb132c67da53
7
- data.tar.gz: 84211ae6ba278ebec36df53a7e0f7275b35430118b135ae6ecc5e73f3ad5ca02833691e4655e38f61f67857c62beb7a041189d3b00a3395e33526f96730c1520
6
+ metadata.gz: 6565a866a1b7bf89490dab66c8a4a8067cd3ae24884124377473a6a6dd1b54025454d3ef6cdd75228e3e6fe9d40453e71e9be98e8b3afc2d5e4b03f5f9fb2cac
7
+ data.tar.gz: ff4326c805b88cf2cd2ac04a699889f582a41185fd569c6daace7876425613f150cba406cc0c7bd1d6bd14dc609094436ba4a79e0d76be3a2f73132ab8bb742b
@@ -0,0 +1,94 @@
1
+ name: CI
2
+
3
+ on:
4
+ push:
5
+ branches: [ main, master ]
6
+ pull_request:
7
+ branches: [ main, master ]
8
+
9
+ jobs:
10
+ test:
11
+ runs-on: ubuntu-latest
12
+ strategy:
13
+ fail-fast: false
14
+ matrix:
15
+ ruby-version:
16
+ - '2.7'
17
+ - '3.0'
18
+ - '3.1'
19
+ - '3.2'
20
+ - '3.3'
21
+ - '3.4'
22
+ activesupport-version:
23
+ - '~> 6.1.0'
24
+ - '~> 7.0.0'
25
+ - '~> 7.1.0'
26
+ - '~> 7.2.0'
27
+ exclude:
28
+ # ActiveSupport 7.1+ requires Ruby 3.1+
29
+ - ruby-version: '2.7'
30
+ activesupport-version: '~> 7.1.0'
31
+ - ruby-version: '3.0'
32
+ activesupport-version: '~> 7.1.0'
33
+ - ruby-version: '2.7'
34
+ activesupport-version: '~> 7.2.0'
35
+ - ruby-version: '3.0'
36
+ activesupport-version: '~> 7.2.0'
37
+
38
+ env:
39
+ ACTIVESUPPORT_VERSION: ${{ matrix.activesupport-version }}
40
+
41
+ steps:
42
+ - uses: actions/checkout@v4
43
+
44
+ - name: Set up Ruby ${{ matrix.ruby-version }}
45
+ uses: ruby/setup-ruby@v1
46
+ with:
47
+ ruby-version: ${{ matrix.ruby-version }}
48
+ bundler-cache: false
49
+
50
+ - name: Create Gemfile for testing
51
+ run: |
52
+ cat > Gemfile.ci << EOF
53
+ source 'https://rubygems.org'
54
+
55
+ gemspec
56
+
57
+ gem 'activesupport', '${{ matrix.activesupport-version }}'
58
+ gem 'minitest', '~> 5.20'
59
+ gem 'mutex_m' if RUBY_VERSION >= '3.4'
60
+ gem 'rake'
61
+ EOF
62
+
63
+ - name: Install dependencies
64
+ run: |
65
+ cp Gemfile.ci Gemfile
66
+ bundle install
67
+
68
+ - name: Run tests
69
+ run: |
70
+ bundle exec rake test || bundle exec ruby -I test -e "Dir['test/*_test.rb'].each { |f| require f }"
71
+
72
+ - name: Run individual test files (fallback)
73
+ if: failure()
74
+ run: |
75
+ find test -name "*_test.rb" -exec bundle exec ruby {} \;
76
+
77
+ lint:
78
+ runs-on: ubuntu-latest
79
+ steps:
80
+ - uses: actions/checkout@v4
81
+
82
+ - name: Set up Ruby
83
+ uses: ruby/setup-ruby@v1
84
+ with:
85
+ ruby-version: '3.3'
86
+ bundler-cache: true
87
+
88
+ - name: Install RuboCop
89
+ run: |
90
+ gem install rubocop rubocop-minitest
91
+
92
+ - name: Run RuboCop
93
+ run: |
94
+ rubocop --format github || true # Don't fail on style issues for now
data/.gitignore CHANGED
@@ -1,3 +1,2 @@
1
- # Created by .ignore support plugin (hsz.mobi)
2
- .idea/
3
-
1
+ /.idea
2
+ /Gemfile.lock
data/.rubocop.yml ADDED
@@ -0,0 +1,81 @@
1
+ AllCops:
2
+ TargetRubyVersion: 2.7
3
+ NewCops: enable
4
+ Exclude:
5
+ - 'vendor/**/*'
6
+ - 'tmp/**/*'
7
+ - 'bin/**/*'
8
+
9
+ plugins:
10
+ - rubocop-minitest
11
+ - rubocop-rake
12
+
13
+ # Allow longer lines for readability
14
+ Layout/LineLength:
15
+ Max: 120
16
+ Exclude:
17
+ - 'test/**/*'
18
+
19
+ # Allow longer methods in tests
20
+ Metrics/MethodLength:
21
+ Max: 20
22
+ Exclude:
23
+ - 'test/**/*'
24
+
25
+ # Allow longer classes in tests
26
+ Metrics/ClassLength:
27
+ Max: 200
28
+ Exclude:
29
+ - 'test/**/*'
30
+
31
+ # Allow longer blocks in tests
32
+ Metrics/BlockLength:
33
+ Max: 50
34
+ Exclude:
35
+ - 'test/**/*'
36
+ - '*.gemspec'
37
+
38
+ # Don't require documentation for every class/module
39
+ Style/Documentation:
40
+ Enabled: false
41
+
42
+ # Allow both single and double quotes
43
+ Style/StringLiterals:
44
+ Enabled: false
45
+
46
+ # Allow trailing commas in multiline structures
47
+ Style/TrailingCommaInArrayLiteral:
48
+ EnforcedStyleForMultiline: consistent_comma
49
+
50
+ Style/TrailingCommaInHashLiteral:
51
+ EnforcedStyleForMultiline: consistent_comma
52
+
53
+ # Allow compact module/class definitions
54
+ Style/ClassAndModuleChildren:
55
+ Enabled: false
56
+
57
+ # Allow empty methods
58
+ Style/EmptyMethod:
59
+ Enabled: false
60
+
61
+ # Don't require frozen string literals (for compatibility)
62
+ Style/FrozenStringLiteralComment:
63
+ Enabled: false
64
+
65
+ # Allow assignment in conditions (common pattern)
66
+ Lint/AssignmentInCondition:
67
+ Enabled: false
68
+
69
+ # Allow safe navigation operator
70
+ Style/SafeNavigation:
71
+ Enabled: true
72
+
73
+ # Allow multiple assertions in test methods
74
+ Minitest/MultipleAssertions:
75
+ Exclude:
76
+ - 'test/**/*'
77
+
78
+ # Allow high ABC size in test methods
79
+ Metrics/AbcSize:
80
+ Exclude:
81
+ - 'test/**/*'
data/CHANGELOG.md ADDED
@@ -0,0 +1,154 @@
1
+ # Changelog
2
+
3
+ All notable changes to this project will be documented in this file.
4
+
5
+ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
+ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
+
8
+ ## [0.2.1] - 2025-09-27
9
+
10
+ ### Fixed
11
+ - Incorrect active_support dependency version range
12
+
13
+ ## [0.2.0] - 2025-09-27 (yanked due to issue installing active_support versions. Use 0.2.1 instead)
14
+
15
+ ### Added
16
+ - Support for xml, conf and ini files in addition to the yaml and json formats
17
+ - Multi-directory configuration support - load and merge configs from multiple directories
18
+ - Directory precedence system - earlier directories override later ones
19
+ - Mixed file format support - YAML, JSON, and other formats in the same project
20
+ - Deep merging of nested configuration structures
21
+ - Comprehensive test suite with multi-Ruby version support (2.7-3.4)
22
+ - GitHub Actions CI/CD pipeline
23
+ - Support for asdf, rbenv, and rvm version managers
24
+ - Docker-based testing environment
25
+ - Extensive documentation and examples
26
+
27
+ ### Changed
28
+ - **BREAKING**: Directory precedence now works correctly - first directory wins
29
+ - Ruby version requirement updated to >= 2.7.0
30
+ - ActiveSupport dependency updated to >= 6.1, < 8.0
31
+ - Improved error handling for missing directories and files
32
+ - Updated development dependencies (minitest ~> 5.20, mutex_m for Ruby 3.4+)
33
+
34
+ ### Fixed
35
+ - Safe navigation operator compatibility with older Ruby versions
36
+ - Minitest constant name (MiniTest -> Minitest)
37
+ - File processing order within directories (alphabetical)
38
+
39
+ ## [0.1.7] - 2023-01-15
40
+
41
+ ### Added
42
+ - HashWithIndifferentAccess support for consistent key access with strings and symbols
43
+
44
+ ### Changed
45
+ - Configuration hashes now return HashWithIndifferentAccess instead of regular Hash
46
+ - Improved key access flexibility
47
+
48
+ ## [0.1.6] - 2022-12-10
49
+
50
+ ### Added
51
+ - Default directory support - directories are used even if not explicitly declared
52
+ - Better handling of missing configuration scenarios
53
+
54
+ ### Fixed
55
+ - Empty file handling improvements
56
+ - Default directory initialization
57
+
58
+ ## [0.1.5] - 2022-11-20
59
+
60
+ ### Added
61
+ - 'config' directory added to default :etc directory list
62
+ - Improved empty file and missing file handling
63
+
64
+ ### Fixed
65
+ - Better error handling for non-existent configuration files
66
+ - More robust directory scanning
67
+
68
+ ## [0.1.3] - 2022-10-15
69
+
70
+ ### Fixed
71
+ - JSON.load now properly receives an IO object instead of filename
72
+ - Improved JSON file parsing reliability
73
+
74
+ ## [0.1.2] - 2022-09-28
75
+
76
+ ### Changed
77
+ - JSON parsing now uses quirks mode for better compatibility
78
+ - More flexible JSON file format support
79
+
80
+ ## [0.1.1] - 2022-09-20
81
+
82
+ ### Changed
83
+ - Configuration objects now return Hash instead of OpenStruct
84
+ - Simplified data structure for better performance and compatibility
85
+
86
+ ## [0.1.0] - 2022-09-15
87
+
88
+ ### Added
89
+ - Initial release
90
+ - Basic YAML configuration file loading
91
+ - Single directory support
92
+ - Static and dynamic configuration file loading
93
+ - Support for multiple file extensions (.yml, .json, .conf)
94
+ - File-based configuration discovery
95
+ - Basic directory searching functionality
96
+
97
+ ### Features
98
+ - `config_directories` method to define search paths
99
+ - `static_config_files` for cached configuration loading
100
+ - `dynamic_config_files` for real-time configuration reloading
101
+ - Automatic file extension detection and parsing
102
+ - Integration with ActiveSupport for deep merging capabilities
103
+
104
+ ---
105
+
106
+ ## Migration Guide
107
+
108
+ ### Upgrading from 0.1.x to 0.2.0
109
+
110
+ The major change in 0.2.0 is the addition of multi-directory support and corrected directory precedence.
111
+
112
+ #### Before (0.1.x)
113
+ ```ruby
114
+ class MyApp
115
+ include ConfigFiles
116
+ config_directories etc: ['/etc/myapp'] # Single directory
117
+ static_config_files :config
118
+ end
119
+ ```
120
+
121
+ #### After (0.2.0)
122
+ ```ruby
123
+ class MyApp
124
+ include ConfigFiles
125
+ config_directories etc: [
126
+ 'config/production', # Highest priority
127
+ 'config/defaults' # Fallback values
128
+ ]
129
+ static_config_files :config
130
+ end
131
+ ```
132
+
133
+ #### Key Changes
134
+ 1. **Multi-directory support**: You can now specify multiple directories
135
+ 2. **Directory precedence**: Earlier directories in the list override later ones
136
+ 3. **Deep merging**: Configurations from all directories are intelligently merged
137
+ 4. **Mixed formats**: YAML and JSON files can coexist and are merged together
138
+
139
+ #### Compatibility
140
+ - Single directory configurations continue to work unchanged
141
+ - Existing method signatures are preserved
142
+ - Return values maintain the same structure (HashWithIndifferentAccess)
143
+
144
+ ## Development
145
+
146
+ ### Version History Summary
147
+ - **0.1.x series**: Basic single-directory YAML configuration loading
148
+ - **0.2.0**: Major enhancement with multi-directory support and mixed formats
149
+
150
+ ### Contributors
151
+ - Paul McKibbin - Original author and maintainer
152
+
153
+ ### License
154
+ MIT License - see [LICENCE.txt](LICENCE.txt) for details.
data/Gemfile CHANGED
@@ -1,3 +1,14 @@
1
+ # frozen_string_literal: true
2
+
1
3
  source 'https://rubygems.org'
2
4
 
3
- gemspec
5
+ gemspec
6
+
7
+ group :development, :test do
8
+ gem 'minitest', '~> 5.20', '>= 5.20.0'
9
+ gem 'mutex_m', '~> 0.3.0'
10
+ gem 'rake', '~> 13.0', '>= 13.0.0'
11
+ gem 'rubocop', '~> 1.50'
12
+ gem 'rubocop-minitest', '~> 0.30'
13
+ gem 'rubocop-rake', '~> 0.6'
14
+ end
@@ -0,0 +1,158 @@
1
+ # Multi-Ruby Testing Setup Summary
2
+
3
+ This document summarizes the multi-Ruby version testing setup for the ConfigFiles gem.
4
+
5
+ ## 🎯 What Was Accomplished
6
+
7
+ ### ✅ Universal Ruby Version Manager Support
8
+ - **asdf** (recommended) - Modern, universal version manager
9
+ - **rbenv** - Popular Ruby-specific version manager
10
+ - **rvm** - Traditional Ruby version manager
11
+ - **Auto-detection** - Script automatically detects which manager you have
12
+
13
+ ### ✅ Comprehensive Testing Scripts
14
+
15
+ #### 1. Main Testing Script (`scripts/test_multiple_rubies.sh`)
16
+ - **Auto-detects** your Ruby version manager
17
+ - **Interactive installation** of missing Ruby versions
18
+ - **Tests all combinations** of Ruby + ActiveSupport versions
19
+ - **Skips incompatible** combinations automatically
20
+ - **Detailed reporting** with pass/fail summary
21
+ - **Help system** with `--help` flag
22
+
23
+ #### 2. asdf-Specific Installation (`scripts/install_rubies_asdf.sh`)
24
+ - **Bulk installation** of all required Ruby versions
25
+ - **System dependency checks** for different platforms
26
+ - **Progress tracking** and error handling
27
+ - **Installation summary** with troubleshooting tips
28
+
29
+ #### 3. Docker Testing (`scripts/test_docker.sh`)
30
+ - **Isolated testing** environment
31
+ - **No local Ruby installation** required
32
+ - **Consistent results** across different machines
33
+
34
+ ### ✅ CI/CD Integration
35
+
36
+ #### GitHub Actions (`.github/workflows/ci.yml`)
37
+ - **Matrix testing** across Ruby 2.7-3.4 and ActiveSupport 6.1-7.2
38
+ - **Automatic exclusion** of incompatible combinations
39
+ - **RuboCop linting** integration
40
+ - **Free for open source** projects
41
+
42
+ ### ✅ Documentation & Configuration
43
+
44
+ #### Testing Documentation (`TESTING.md`)
45
+ - **Comprehensive guide** for all testing methods
46
+ - **Compatibility matrix** for Ruby/ActiveSupport versions
47
+ - **Troubleshooting section** for common issues
48
+ - **Performance testing** guidelines
49
+
50
+ #### Configuration Files
51
+ - **RuboCop config** (`.rubocop.yml`) with sensible defaults
52
+ - **Rakefile** with test tasks
53
+ - **Gemspec updates** with proper version constraints
54
+
55
+ ## 🚀 Quick Start
56
+
57
+ ### For asdf Users
58
+ ```bash
59
+ # Install all Ruby versions
60
+ ./scripts/install_rubies_asdf.sh
61
+
62
+ # Run comprehensive tests
63
+ ./scripts/test_multiple_rubies.sh
64
+ ```
65
+
66
+ ### For rbenv/rvm Users
67
+ ```bash
68
+ # Install Ruby versions manually:
69
+ # rbenv: rbenv install 2.7.8 3.0.6 3.1.4 3.2.2 3.3.0 3.4.1
70
+ # rvm: rvm install 2.7.8 3.0.6 3.1.4 3.2.2 3.3.0 3.4.1
71
+
72
+ # Run tests (auto-detects your version manager)
73
+ ./scripts/test_multiple_rubies.sh
74
+ ```
75
+
76
+ ### For Docker Users
77
+ ```bash
78
+ # Test all combinations in isolated containers
79
+ ./scripts/test_docker.sh
80
+ ```
81
+
82
+ ## 📊 Test Coverage
83
+
84
+ | Ruby Version | ActiveSupport 6.1 | ActiveSupport 7.0 | ActiveSupport 7.1 | ActiveSupport 7.2 |
85
+ |--------------|-------------------|-------------------|-------------------|-------------------|
86
+ | 2.7.8 | ✅ | ✅ | ❌ | ❌ |
87
+ | 3.0.6 | ✅ | ✅ | ❌ | ❌ |
88
+ | 3.1.4 | ✅ | ✅ | ✅ | ✅ |
89
+ | 3.2.2 | ✅ | ✅ | ✅ | ✅ |
90
+ | 3.3.0 | ✅ | ✅ | ✅ | ✅ |
91
+ | 3.4.1 | ✅ | ✅ | ✅ | ✅ |
92
+
93
+ **Total Combinations Tested**: 20 valid combinations (4 incompatible combinations automatically skipped)
94
+
95
+ ## 🛠 Key Features
96
+
97
+ ### Smart Version Management
98
+ - **Auto-detection** of asdf, rbenv, or rvm
99
+ - **Graceful fallbacks** when version managers aren't available
100
+ - **Plugin management** for asdf (auto-installs Ruby plugin)
101
+
102
+ ### Intelligent Testing
103
+ - **Compatibility checking** - skips Ruby 2.x + ActiveSupport 7.1/7.2
104
+ - **Dependency management** - handles mutex_m for Ruby 3.4+
105
+ - **Isolated environments** - each test uses its own Gemfile
106
+
107
+ ### User Experience
108
+ - **Colored output** for easy reading
109
+ - **Progress indicators** during installations
110
+ - **Interactive prompts** for missing versions
111
+ - **Comprehensive help** system
112
+
113
+ ### CI/CD Ready
114
+ - **GitHub Actions** integration out of the box
115
+ - **Badge-ready** with version compatibility info
116
+ - **Extensible** to other CI systems (GitLab, CircleCI, Jenkins)
117
+
118
+ ## 🔧 Maintenance
119
+
120
+ ### Adding New Ruby Versions
121
+ 1. Update `RUBY_VERSIONS` array in scripts
122
+ 2. Update GitHub Actions matrix
123
+ 3. Update documentation tables
124
+ 4. Test compatibility with ActiveSupport versions
125
+
126
+ ### Adding New ActiveSupport Versions
127
+ 1. Update `ACTIVESUPPORT_VERSIONS` array
128
+ 2. Update compatibility exclusions if needed
129
+ 3. Update GitHub Actions matrix
130
+ 4. Update documentation
131
+
132
+ ## 🎉 Benefits
133
+
134
+ ### For Developers
135
+ - **Confidence** in multi-version compatibility
136
+ - **Easy local testing** with any version manager
137
+ - **Quick feedback** on compatibility issues
138
+
139
+ ### For Contributors
140
+ - **Clear testing guidelines** in TESTING.md
141
+ - **Automated CI** catches issues early
142
+ - **Consistent environment** via Docker
143
+
144
+ ### For Users
145
+ - **Reliable gem** tested across many Ruby versions
146
+ - **Clear compatibility** information
147
+ - **Predictable behavior** across environments
148
+
149
+ ## 📈 Modern Best Practices
150
+
151
+ ### Why This Setup is Superior to Travis CI
152
+ 1. **GitHub Actions** - Free, integrated, reliable
153
+ 2. **Multi-manager support** - Works with any Ruby version manager
154
+ 3. **Docker option** - Completely isolated testing
155
+ 4. **Local testing** - Don't wait for CI to catch issues
156
+ 5. **Comprehensive documentation** - Easy to understand and maintain
157
+
158
+ This setup provides a robust, maintainable, and user-friendly testing environment that supports the diverse Ruby ecosystem while ensuring the ConfigFiles gem works reliably for all users! 🚀