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
@@ -0,0 +1,187 @@
1
+ #!/bin/bash
2
+
3
+ # Script to install all Ruby versions needed for testing using asdf
4
+ # This is a specialized script for asdf users
5
+
6
+ set -e
7
+
8
+ # Colors for output
9
+ RED='\033[0;31m'
10
+ GREEN='\033[0;32m'
11
+ YELLOW='\033[1;33m'
12
+ BLUE='\033[0;34m'
13
+ NC='\033[0m' # No Color
14
+
15
+ # Ruby versions to install
16
+ RUBY_VERSIONS=("2.7.8" "3.0.6" "3.1.4" "3.2.2" "3.3.0" "3.4.1")
17
+
18
+ echo -e "${BLUE}ConfigFiles Ruby Installation Script (asdf)${NC}"
19
+ echo -e "${BLUE}===========================================${NC}"
20
+
21
+ # Function to check if asdf is installed and configured
22
+ check_asdf() {
23
+ if ! command -v asdf >/dev/null 2>&1; then
24
+ echo -e "${RED}asdf not found. Please install asdf first.${NC}"
25
+ echo -e "${BLUE}Installation instructions:${NC}"
26
+ echo -e " macOS: brew install asdf"
27
+ echo -e " Linux: git clone https://github.com/asdf-vm/asdf.git ~/.asdf --branch v0.14.0"
28
+ echo -e " More info: https://asdf-vm.com/guide/getting-started.html"
29
+ exit 1
30
+ fi
31
+
32
+ echo -e "${GREEN}✓ asdf found${NC}"
33
+
34
+ # Check if ruby plugin is installed
35
+ if ! asdf plugin list | grep -q "^ruby$"; then
36
+ echo -e "${YELLOW}Installing Ruby plugin...${NC}"
37
+ if asdf plugin add ruby https://github.com/asdf-vm/asdf-ruby.git; then
38
+ echo -e "${GREEN}✓ Ruby plugin installed${NC}"
39
+ else
40
+ echo -e "${RED}✗ Failed to install Ruby plugin${NC}"
41
+ exit 1
42
+ fi
43
+ else
44
+ echo -e "${GREEN}✓ Ruby plugin already installed${NC}"
45
+ fi
46
+ }
47
+
48
+ # Function to check if Ruby version is installed
49
+ check_ruby_version() {
50
+ local version=$1
51
+ asdf list ruby 2>/dev/null | grep -q "^\s*${version}$"
52
+ }
53
+
54
+ # Function to install Ruby version
55
+ install_ruby_version() {
56
+ local version=$1
57
+ echo -e "${YELLOW}Installing Ruby ${version}...${NC}"
58
+
59
+ # Show progress
60
+ if asdf install ruby "$version"; then
61
+ echo -e "${GREEN}✓ Ruby ${version} installed successfully${NC}"
62
+ return 0
63
+ else
64
+ echo -e "${RED}✗ Failed to install Ruby ${version}${NC}"
65
+ return 1
66
+ fi
67
+ }
68
+
69
+ # Function to show system requirements
70
+ show_requirements() {
71
+ echo -e "\n${BLUE}System Requirements:${NC}"
72
+ echo -e "Before installing Ruby versions, make sure you have the required dependencies:"
73
+ echo
74
+
75
+ if [[ "$OSTYPE" == "darwin"* ]]; then
76
+ echo -e "${YELLOW}macOS:${NC}"
77
+ echo -e " brew install openssl readline sqlite3 xz zlib"
78
+ echo -e " xcode-select --install"
79
+ elif [[ "$OSTYPE" == "linux-gnu"* ]]; then
80
+ echo -e "${YELLOW}Ubuntu/Debian:${NC}"
81
+ echo -e " sudo apt-get install -y build-essential libssl-dev libreadline-dev zlib1g-dev"
82
+ echo -e " sudo apt-get install -y libsqlite3-dev libxml2-dev libxslt1-dev libcurl4-openssl-dev"
83
+ echo -e " sudo apt-get install -y libffi-dev libyaml-dev"
84
+ echo
85
+ echo -e "${YELLOW}CentOS/RHEL/Fedora:${NC}"
86
+ echo -e " sudo yum groupinstall -y 'Development Tools'"
87
+ echo -e " sudo yum install -y openssl-devel readline-devel zlib-devel sqlite-devel"
88
+ fi
89
+
90
+ echo
91
+ read -p "Have you installed the required dependencies? (y/N): " -n 1 -r
92
+ echo
93
+ if [[ ! $REPLY =~ ^[Yy]$ ]]; then
94
+ echo -e "${YELLOW}Please install the dependencies first, then run this script again.${NC}"
95
+ exit 1
96
+ fi
97
+ }
98
+
99
+ # Main execution
100
+ echo -e "\n${YELLOW}This script will install the following Ruby versions using asdf:${NC}"
101
+ for version in "${RUBY_VERSIONS[@]}"; do
102
+ echo -e " - Ruby ${version}"
103
+ done
104
+
105
+ echo
106
+ read -p "Continue? (y/N): " -n 1 -r
107
+ echo
108
+ if [[ ! $REPLY =~ ^[Yy]$ ]]; then
109
+ echo -e "${YELLOW}Installation cancelled.${NC}"
110
+ exit 0
111
+ fi
112
+
113
+ # Check asdf installation
114
+ check_asdf
115
+
116
+ # Show system requirements
117
+ show_requirements
118
+
119
+ # Check current installations
120
+ echo -e "\n${BLUE}Checking current Ruby installations...${NC}"
121
+ already_installed=()
122
+ to_install=()
123
+
124
+ for ruby_version in "${RUBY_VERSIONS[@]}"; do
125
+ if check_ruby_version "$ruby_version"; then
126
+ echo -e "${GREEN}✓ Ruby ${ruby_version} is already installed${NC}"
127
+ already_installed+=("$ruby_version")
128
+ else
129
+ echo -e "${YELLOW}○ Ruby ${ruby_version} needs to be installed${NC}"
130
+ to_install+=("$ruby_version")
131
+ fi
132
+ done
133
+
134
+ if [ ${#to_install[@]} -eq 0 ]; then
135
+ echo -e "\n${GREEN}All Ruby versions are already installed! 🎉${NC}"
136
+ exit 0
137
+ fi
138
+
139
+ # Install missing versions
140
+ echo -e "\n${BLUE}Installing ${#to_install[@]} Ruby versions...${NC}"
141
+ failed_installations=()
142
+ successful_installations=()
143
+
144
+ for ruby_version in "${to_install[@]}"; do
145
+ echo -e "\n${YELLOW}[$(date '+%H:%M:%S')] Installing Ruby ${ruby_version}...${NC}"
146
+
147
+ if install_ruby_version "$ruby_version"; then
148
+ successful_installations+=("$ruby_version")
149
+ else
150
+ failed_installations+=("$ruby_version")
151
+ echo -e "${RED}Installation of Ruby ${ruby_version} failed. Continuing with others...${NC}"
152
+ fi
153
+ done
154
+
155
+ # Summary
156
+ echo -e "\n${BLUE}=== Installation Summary ===${NC}"
157
+ echo -e "Already installed: ${#already_installed[@]}"
158
+ echo -e "${GREEN}Successfully installed: ${#successful_installations[@]}${NC}"
159
+ echo -e "${RED}Failed installations: ${#failed_installations[@]}${NC}"
160
+
161
+ if [ ${#successful_installations[@]} -gt 0 ]; then
162
+ echo -e "\n${GREEN}Successfully installed:${NC}"
163
+ for version in "${successful_installations[@]}"; do
164
+ echo -e "${GREEN} ✓ Ruby ${version}${NC}"
165
+ done
166
+ fi
167
+
168
+ if [ ${#failed_installations[@]} -gt 0 ]; then
169
+ echo -e "\n${RED}Failed installations:${NC}"
170
+ for version in "${failed_installations[@]}"; do
171
+ echo -e "${RED} ✗ Ruby ${version}${NC}"
172
+ done
173
+ echo -e "\n${YELLOW}Troubleshooting tips:${NC}"
174
+ echo -e " 1. Make sure you have all system dependencies installed"
175
+ echo -e " 2. Check asdf ruby plugin: asdf plugin update ruby"
176
+ echo -e " 3. Try installing manually: asdf install ruby <version>"
177
+ echo -e " 4. Check logs in ~/.asdf/installs/ruby/<version>/install.log"
178
+ fi
179
+
180
+ # Show next steps
181
+ echo -e "\n${BLUE}Next Steps:${NC}"
182
+ echo -e " 1. Run the test suite: ./scripts/test_multiple_rubies.sh"
183
+ echo -e " 2. Set a global Ruby version: asdf global ruby <version>"
184
+ echo -e " 3. Set a local Ruby version: asdf local ruby <version>"
185
+
186
+ total_available=$((${#already_installed[@]} + ${#successful_installations[@]}))
187
+ echo -e "\n${GREEN}You now have ${total_available} Ruby versions available for testing! 🚀${NC}"
@@ -0,0 +1,96 @@
1
+ #!/bin/bash
2
+
3
+ # Script to test multiple Ruby versions using Docker
4
+
5
+ set -e
6
+
7
+ # Colors for output
8
+ RED='\033[0;31m'
9
+ GREEN='\033[0;32m'
10
+ YELLOW='\033[1;33m'
11
+ NC='\033[0m' # No Color
12
+
13
+ # Ruby versions to test
14
+ RUBY_VERSIONS=("2.7" "3.0" "3.1" "3.2" "3.3" "3.4")
15
+
16
+ # ActiveSupport versions to test
17
+ ACTIVESUPPORT_VERSIONS=("~> 6.1.0" "~> 7.0.0" "~> 7.1.0" "~> 7.2.0" "~> 8.0.0" "~> 8.1.0")
18
+
19
+ # Function to test a specific Ruby and ActiveSupport combination
20
+ test_combination() {
21
+ local ruby_version=$1
22
+ local activesupport_version=$2
23
+
24
+ echo -e "${YELLOW}Testing Ruby ${ruby_version} with ActiveSupport ${activesupport_version}${NC}"
25
+
26
+ # Skip incompatible combinations
27
+ if [[ "$ruby_version" =~ ^2\.[67] ]] && [[ "$activesupport_version" =~ 7\.[12] ]]; then
28
+ echo -e "${YELLOW}Skipping incompatible combination${NC}"
29
+ return 0
30
+ fi
31
+ # ActiveSupport 8.x requires Ruby 3.2+
32
+ if [[ "$ruby_version" =~ ^(2\.|3\.[01]) ]] && [[ "$activesupport_version" =~ 8\. ]]; then
33
+ echo -e "${YELLOW}Skipping incompatible combination${NC}"
34
+ return 0
35
+ fi
36
+
37
+ # Build and run Docker container
38
+ if docker build \
39
+ --build-arg RUBY_VERSION="$ruby_version" \
40
+ --build-arg ACTIVESUPPORT_VERSION="$activesupport_version" \
41
+ -f docker/Dockerfile.test \
42
+ -t "config_files_test:ruby${ruby_version}-as${activesupport_version//[~>. ]/}" \
43
+ . && \
44
+ docker run --rm "config_files_test:ruby${ruby_version}-as${activesupport_version//[~>. ]/}"; then
45
+ echo -e "${GREEN}✓ Ruby ${ruby_version} with ActiveSupport ${activesupport_version} - PASSED${NC}"
46
+ return 0
47
+ else
48
+ echo -e "${RED}✗ Ruby ${ruby_version} with ActiveSupport ${activesupport_version} - FAILED${NC}"
49
+ return 1
50
+ fi
51
+ }
52
+
53
+ # Main execution
54
+ echo -e "${YELLOW}Starting Docker-based multi-Ruby testing...${NC}"
55
+
56
+ # Check if Docker is available
57
+ if ! command -v docker >/dev/null 2>&1; then
58
+ echo -e "${RED}Docker not found. Please install Docker to use this script.${NC}"
59
+ exit 1
60
+ fi
61
+
62
+ failed_combinations=()
63
+ total_tests=0
64
+ passed_tests=0
65
+
66
+ for ruby_version in "${RUBY_VERSIONS[@]}"; do
67
+ for activesupport_version in "${ACTIVESUPPORT_VERSIONS[@]}"; do
68
+ total_tests=$((total_tests + 1))
69
+
70
+ if test_combination "$ruby_version" "$activesupport_version"; then
71
+ passed_tests=$((passed_tests + 1))
72
+ else
73
+ failed_combinations+=("Ruby ${ruby_version} + ActiveSupport ${activesupport_version}")
74
+ fi
75
+ done
76
+ done
77
+
78
+ # Clean up Docker images
79
+ echo -e "\n${YELLOW}Cleaning up Docker images...${NC}"
80
+ docker images --format "table {{.Repository}}:{{.Tag}}" | grep "config_files_test" | xargs -r docker rmi
81
+
82
+ # Summary
83
+ echo -e "\n${YELLOW}=== Test Summary ===${NC}"
84
+ echo -e "Total combinations tested: ${total_tests}"
85
+ echo -e "${GREEN}Passed: ${passed_tests}${NC}"
86
+ echo -e "${RED}Failed: $((total_tests - passed_tests))${NC}"
87
+
88
+ if [ ${#failed_combinations[@]} -gt 0 ]; then
89
+ echo -e "\n${RED}Failed combinations:${NC}"
90
+ for combination in "${failed_combinations[@]}"; do
91
+ echo -e "${RED} - ${combination}${NC}"
92
+ done
93
+ exit 1
94
+ else
95
+ echo -e "\n${GREEN}All tests passed! 🎉${NC}"
96
+ fi
@@ -0,0 +1,295 @@
1
+ #!/bin/bash
2
+
3
+ # Script to test multiple Ruby versions locally
4
+ # Supports asdf, rbenv, and rvm
5
+
6
+ set -e
7
+
8
+ # Colors for output
9
+ RED='\033[0;31m'
10
+ GREEN='\033[0;32m'
11
+ YELLOW='\033[1;33m'
12
+ BLUE='\033[0;34m'
13
+ NC='\033[0m' # No Color
14
+
15
+ # Ruby versions to test
16
+ RUBY_VERSIONS=("2.7.8" "3.0.6" "3.1.4" "3.2.2" "3.3.0" "3.4.1")
17
+
18
+ # ActiveSupport versions to test
19
+ ACTIVESUPPORT_VERSIONS=("~> 6.1.0" "~> 7.0.0" "~> 7.1.0" "~> 7.2.0" "~> 8.0.0" "~> 8.1.0")
20
+
21
+ # Detect which Ruby version manager is available
22
+ RUBY_MANAGER=""
23
+
24
+ detect_ruby_manager() {
25
+ if command -v asdf >/dev/null 2>&1; then
26
+ RUBY_MANAGER="asdf"
27
+ echo -e "${BLUE}Detected asdf${NC}"
28
+ elif command -v rbenv >/dev/null 2>&1; then
29
+ RUBY_MANAGER="rbenv"
30
+ echo -e "${BLUE}Detected rbenv${NC}"
31
+ elif command -v rvm >/dev/null 2>&1; then
32
+ RUBY_MANAGER="rvm"
33
+ echo -e "${BLUE}Detected rvm${NC}"
34
+ else
35
+ echo -e "${RED}No Ruby version manager found!${NC}"
36
+ echo -e "${YELLOW}Please install one of the following:${NC}"
37
+ echo -e " - asdf: https://asdf-vm.com/guide/getting-started.html"
38
+ echo -e " - rbenv: https://github.com/rbenv/rbenv#installation"
39
+ echo -e " - rvm: https://rvm.io/rvm/install"
40
+ exit 1
41
+ fi
42
+ }
43
+
44
+ # Function to check if Ruby version is installed
45
+ check_ruby_version() {
46
+ local version=$1
47
+ case $RUBY_MANAGER in
48
+ "asdf")
49
+ asdf list ruby 2>/dev/null | grep -q "^\s*${version}$"
50
+ ;;
51
+ "rbenv")
52
+ rbenv versions --bare | grep -q "^${version}$"
53
+ ;;
54
+ "rvm")
55
+ rvm list | grep -q "${version}"
56
+ ;;
57
+ esac
58
+ }
59
+
60
+ # Function to install Ruby version if not present
61
+ install_ruby_version() {
62
+ local version=$1
63
+ echo -e "${YELLOW}Installing Ruby ${version} with ${RUBY_MANAGER}...${NC}"
64
+
65
+ case $RUBY_MANAGER in
66
+ "asdf")
67
+ # Check if ruby plugin is installed
68
+ if ! asdf plugin list | grep -q "^ruby$"; then
69
+ echo -e "${YELLOW}Installing Ruby plugin for asdf...${NC}"
70
+ asdf plugin add ruby https://github.com/asdf-vm/asdf-ruby.git
71
+ fi
72
+ asdf install ruby "$version"
73
+ ;;
74
+ "rbenv")
75
+ rbenv install "$version"
76
+ ;;
77
+ "rvm")
78
+ rvm install "$version"
79
+ ;;
80
+ esac
81
+
82
+ if [ $? -eq 0 ]; then
83
+ echo -e "${GREEN}✓ Ruby ${version} installed successfully${NC}"
84
+ return 0
85
+ else
86
+ echo -e "${RED}✗ Failed to install Ruby ${version}${NC}"
87
+ return 1
88
+ fi
89
+ }
90
+
91
+ # Function to switch Ruby version
92
+ switch_ruby() {
93
+ local version=$1
94
+
95
+ case $RUBY_MANAGER in
96
+ "asdf")
97
+ asdf local ruby "$version"
98
+ # Verify the switch worked
99
+ local current_version
100
+ current_version=$(asdf current ruby 2>/dev/null | awk '{print $2}')
101
+ if [[ "$current_version" != "$version" ]]; then
102
+ echo -e "${RED}Failed to switch to Ruby ${version}. Current: ${current_version}${NC}"
103
+ return 1
104
+ fi
105
+ ;;
106
+ "rbenv")
107
+ rbenv shell "$version"
108
+ # Verify the switch worked
109
+ local current_version
110
+ current_version=$(rbenv version-name)
111
+ if [[ "$current_version" != "$version" ]]; then
112
+ echo -e "${RED}Failed to switch to Ruby ${version}. Current: ${current_version}${NC}"
113
+ return 1
114
+ fi
115
+ ;;
116
+ "rvm")
117
+ rvm use "$version"
118
+ # rvm use typically handles verification internally
119
+ ;;
120
+ esac
121
+
122
+ echo -e "${BLUE}Switched to Ruby ${version} using ${RUBY_MANAGER}${NC}"
123
+ return 0
124
+ }
125
+
126
+ # Function to list available Ruby versions
127
+ list_available_versions() {
128
+ echo -e "\n${BLUE}Available Ruby versions:${NC}"
129
+ case $RUBY_MANAGER in
130
+ "asdf")
131
+ asdf list ruby 2>/dev/null || echo " No Ruby versions installed"
132
+ ;;
133
+ "rbenv")
134
+ rbenv versions --bare || echo " No Ruby versions installed"
135
+ ;;
136
+ "rvm")
137
+ rvm list || echo " No Ruby versions installed"
138
+ ;;
139
+ esac
140
+ }
141
+
142
+ # Function to test a specific Ruby and ActiveSupport combination
143
+ test_combination() {
144
+ local ruby_version=$1
145
+ local activesupport_version=$2
146
+
147
+ echo -e "${YELLOW}Testing Ruby ${ruby_version} with ActiveSupport ${activesupport_version}${NC}"
148
+
149
+ # Skip incompatible combinations
150
+ if [[ "$ruby_version" =~ ^2\.[67] ]] && [[ "$activesupport_version" =~ 7\.[12] ]]; then
151
+ echo -e "${YELLOW}Skipping incompatible combination${NC}"
152
+ return 0
153
+ fi
154
+ # ActiveSupport 8.x requires Ruby 3.2+
155
+ if [[ "$ruby_version" =~ ^(2\.|3\.[01]) ]] && [[ "$activesupport_version" =~ 8\. ]]; then
156
+ echo -e "${YELLOW}Skipping incompatible combination${NC}"
157
+ return 0
158
+ fi
159
+
160
+ # Create temporary Gemfile
161
+ cat > Gemfile.test << EOF
162
+ source 'https://rubygems.org'
163
+
164
+ gemspec
165
+
166
+ gem 'activesupport', '${activesupport_version}'
167
+ gem 'minitest', '~> 5.20'
168
+ gem 'mutex_m' if RUBY_VERSION >= '3.4'
169
+ gem 'rake'
170
+ EOF
171
+
172
+ # Install dependencies and run tests
173
+ if bundle install --gemfile=Gemfile.test && BUNDLE_GEMFILE=Gemfile.test bundle exec rake test; then
174
+ echo -e "${GREEN}✓ Ruby ${ruby_version} with ActiveSupport ${activesupport_version} - PASSED${NC}"
175
+ return 0
176
+ else
177
+ echo -e "${RED}✗ Ruby ${ruby_version} with ActiveSupport ${activesupport_version} - FAILED${NC}"
178
+ return 1
179
+ fi
180
+ }
181
+
182
+ # Handle command line arguments
183
+ if [[ "$1" == "--help" || "$1" == "-h" ]]; then
184
+ echo -e "${BLUE}ConfigFiles Multi-Ruby Testing Script${NC}"
185
+ echo -e "${BLUE}====================================${NC}"
186
+ echo
187
+ echo -e "${YELLOW}Usage:${NC} $0 [options]"
188
+ echo
189
+ echo -e "${YELLOW}Options:${NC}"
190
+ echo -e " -h, --help Show this help message"
191
+ echo -e " --list List available Ruby versions and exit"
192
+ echo -e " --auto-install Automatically install missing Ruby versions without prompting"
193
+ echo
194
+ echo -e "${YELLOW}Supported Ruby Version Managers:${NC}"
195
+ echo -e " - asdf (recommended)"
196
+ echo -e " - rbenv"
197
+ echo -e " - rvm"
198
+ echo
199
+ echo -e "${YELLOW}Ruby Versions Tested:${NC}"
200
+ for version in "${RUBY_VERSIONS[@]}"; do
201
+ echo -e " - Ruby ${version}"
202
+ done
203
+ echo
204
+ echo -e "${YELLOW}ActiveSupport Versions Tested:${NC}"
205
+ for version in "${ACTIVESUPPORT_VERSIONS[@]}"; do
206
+ echo -e " - ActiveSupport ${version}"
207
+ done
208
+ echo
209
+ echo -e "${YELLOW}Examples:${NC}"
210
+ echo -e " $0 # Run interactive testing"
211
+ echo -e " $0 --list # Show available Ruby versions"
212
+ echo -e " $0 --auto-install # Install missing versions automatically"
213
+ exit 0
214
+ fi
215
+
216
+ # Main execution
217
+ echo -e "${YELLOW}Starting multi-Ruby testing...${NC}"
218
+
219
+ # Detect Ruby version manager
220
+ detect_ruby_manager
221
+
222
+ # Show available versions
223
+ list_available_versions
224
+
225
+ failed_combinations=()
226
+ total_tests=0
227
+ passed_tests=0
228
+ installed_versions=()
229
+
230
+ # Check and install Ruby versions
231
+ echo -e "\n${BLUE}Checking required Ruby versions...${NC}"
232
+ for ruby_version in "${RUBY_VERSIONS[@]}"; do
233
+ if check_ruby_version "$ruby_version"; then
234
+ echo -e "${GREEN}✓ Ruby ${ruby_version} is already installed${NC}"
235
+ installed_versions+=("$ruby_version")
236
+ else
237
+ echo -e "${YELLOW}Ruby ${ruby_version} not found${NC}"
238
+ read -p "Install Ruby ${ruby_version}? (y/N): " -n 1 -r
239
+ echo
240
+ if [[ $REPLY =~ ^[Yy]$ ]]; then
241
+ if install_ruby_version "$ruby_version"; then
242
+ installed_versions+=("$ruby_version")
243
+ else
244
+ echo -e "${RED}Skipping Ruby ${ruby_version} due to installation failure${NC}"
245
+ fi
246
+ else
247
+ echo -e "${YELLOW}Skipping Ruby ${ruby_version}${NC}"
248
+ fi
249
+ fi
250
+ done
251
+
252
+ if [ ${#installed_versions[@]} -eq 0 ]; then
253
+ echo -e "${RED}No Ruby versions available for testing. Exiting.${NC}"
254
+ exit 1
255
+ fi
256
+
257
+ echo -e "\n${BLUE}Testing with ${#installed_versions[@]} Ruby versions...${NC}"
258
+
259
+ for ruby_version in "${installed_versions[@]}"; do
260
+ echo -e "\n${YELLOW}=== Testing Ruby ${ruby_version} ===${NC}"
261
+
262
+ if ! switch_ruby "$ruby_version"; then
263
+ echo -e "${RED}Failed to switch to Ruby ${ruby_version}. Skipping.${NC}"
264
+ continue
265
+ fi
266
+
267
+ for activesupport_version in "${ACTIVESUPPORT_VERSIONS[@]}"; do
268
+ total_tests=$((total_tests + 1))
269
+
270
+ if test_combination "$ruby_version" "$activesupport_version"; then
271
+ passed_tests=$((passed_tests + 1))
272
+ else
273
+ failed_combinations+=("Ruby ${ruby_version} + ActiveSupport ${activesupport_version}")
274
+ fi
275
+
276
+ # Clean up
277
+ rm -f Gemfile.test Gemfile.test.lock
278
+ done
279
+ done
280
+
281
+ # Summary
282
+ echo -e "\n${YELLOW}=== Test Summary ===${NC}"
283
+ echo -e "Total combinations tested: ${total_tests}"
284
+ echo -e "${GREEN}Passed: ${passed_tests}${NC}"
285
+ echo -e "${RED}Failed: $((total_tests - passed_tests))${NC}"
286
+
287
+ if [ ${#failed_combinations[@]} -gt 0 ]; then
288
+ echo -e "\n${RED}Failed combinations:${NC}"
289
+ for combination in "${failed_combinations[@]}"; do
290
+ echo -e "${RED} - ${combination}${NC}"
291
+ done
292
+ exit 1
293
+ else
294
+ echo -e "\n${GREEN}All tests passed! 🎉${NC}"
295
+ fi