Skip to content

Commit 4129aa3

Browse files
committed
chore: Fix Ruby Version Management
Prior to this change, the RUBY_REQUIREMENT file was used to keep Ruby versions in sync, however toys will not detect a change to gem since the gemspec file was unaltered. Rather than modify toys to be more flexible in this case, it will be easier to update the Ruby requirement in each gemspec using a script. The script will write out diagnostic output of the gemspecs that were changed. E.g. ```ruby $> bin/update-ruby-version 3.2 Updating Ruby version requirement to: >= 3.2 Finding gemspec files... Found 62 gemspec files to update: Updated: helpers/mysql/opentelemetry-helpers-mysql.gemspec Updated: helpers/sql/opentelemetry-helpers-sql.gemspec Updated: helpers/sql-obfuscation/opentelemetry-helpers-sql-obfuscation.gemspec Updated: helpers/sql-processor/opentelemetry-helpers-sql-processor.gemspec Updated: instrumentation/action_mailer/opentelemetry-instrumentation-action_mailer.gemspec ... Updated: resources/google_cloud_platform/opentelemetry-resource-detector-google_cloud_platform.gemspec Updated: sampler/xray/opentelemetry-sampler-xray.gemspec Summary: - Total files found: 62 - Successfully updated: 62 Done! All gemspecs have been updated to require Ruby >= 3.2 ```
1 parent d554343 commit 4129aa3

File tree

64 files changed

+150
-63
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

64 files changed

+150
-63
lines changed

bin/update-ruby-version

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
#!/usr/bin/env ruby
2+
# frozen_string_literal: true
3+
4+
# Script to update Ruby version requirements in all gemspecs
5+
# Usage: bin/update-ruby-version [new_version]
6+
# Example: bin/update-ruby-version 3.3
7+
8+
require 'fileutils'
9+
require 'rubygems'
10+
11+
def update_gemspec_ruby_version(file_path, new_version)
12+
content = File.read(file_path)
13+
14+
# Pattern to match existing inline version (supports alpha/beta/pre-release versions)
15+
inline_pattern = /spec\.required_ruby_version = '>= [^']+'/
16+
replacement = "spec.required_ruby_version = '>= #{new_version}'"
17+
18+
updated_content = content.gsub(inline_pattern, replacement)
19+
File.write(file_path, updated_content)
20+
end
21+
22+
def find_gemspecs_with_ruby_requirement
23+
# Find all .gemspec files that contain inline Ruby version requirements
24+
gemspec_files = Dir.glob('**/*.gemspec')
25+
26+
gemspec_files.select do |file|
27+
content = File.read(file)
28+
# Match inline version pattern (supports alpha/beta/pre-release versions)
29+
content.match?(/spec\.required_ruby_version = '>= [^']+/)
30+
end
31+
end
32+
33+
# Main execution
34+
def main
35+
new_version = ARGV[0]
36+
37+
# Check if version parameter is provided
38+
if new_version.nil? || new_version.empty?
39+
puts 'Error: No Ruby version specified.'
40+
puts
41+
puts "Usage: #{$0} <new_ruby_version>"
42+
puts 'Examples:'
43+
puts " #{$0} 3.2"
44+
puts " #{$0} 3.3"
45+
puts " #{$0} 3.1.0"
46+
puts
47+
puts 'The version should be a valid Ruby version number (e.g., 3.2, 3.3, 3.1.0)'
48+
exit 1
49+
end
50+
51+
# Validate version format using Ruby's Gem::Version parser
52+
begin
53+
# Try to parse as a valid gem version (this will raise ArgumentError for malformed versions)
54+
Gem::Version.new(new_version)
55+
rescue ArgumentError => e
56+
puts "Error: Invalid Ruby version format '#{new_version}'"
57+
puts "Details: #{e.message}"
58+
puts
59+
puts 'The version must be a valid Ruby version number like:'
60+
puts ' - 3.2'
61+
puts ' - 3.3'
62+
puts ' - 3.1.0'
63+
puts ' - 3.4.0.alpha'
64+
puts ' - 3.3.0.beta1'
65+
puts
66+
puts "Usage: #{$0} <new_ruby_version>"
67+
exit 1
68+
end
69+
70+
puts "Updating Ruby version requirement to: >= #{new_version}"
71+
puts 'Finding gemspec files...'
72+
73+
gemspec_files = find_gemspecs_with_ruby_requirement
74+
puts "Found #{gemspec_files.length} gemspec files to update:"
75+
76+
gemspec_files.each do |file|
77+
update_gemspec_ruby_version(file, new_version)
78+
puts "Updated: #{file}"
79+
end
80+
81+
puts "\nSummary:"
82+
puts "- Total files found: #{gemspec_files.length}"
83+
puts "- Successfully updated: #{gemspec_files.length}"
84+
85+
puts "\nDone! All gemspecs have been updated to require Ruby >= #{new_version}"
86+
end
87+
88+
main if __FILE__ == $0

gemspecs/RUBY_REQUIREMENT

Lines changed: 0 additions & 1 deletion
This file was deleted.

helpers/mysql/opentelemetry-helpers-mysql.gemspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ Gem::Specification.new do |spec|
2323
Dir.glob('*.md') +
2424
['LICENSE', '.yardopts']
2525
spec.require_paths = ['lib']
26-
spec.required_ruby_version = ">= #{File.read(File.expand_path('../../gemspecs/RUBY_REQUIREMENT', __dir__))}"
26+
spec.required_ruby_version = '>= 3.2'
2727

2828
spec.add_dependency 'opentelemetry-api', '~> 1.7'
2929
spec.add_dependency 'opentelemetry-common', '~> 0.21'

helpers/sql-obfuscation/opentelemetry-helpers-sql-obfuscation.gemspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ Gem::Specification.new do |spec|
2323
Dir.glob('*.md') +
2424
['LICENSE', '.yardopts']
2525
spec.require_paths = ['lib']
26-
spec.required_ruby_version = ">= #{File.read(File.expand_path('../../gemspecs/RUBY_REQUIREMENT', __dir__))}"
26+
spec.required_ruby_version = '>= 3.2'
2727

2828
spec.add_dependency 'opentelemetry-common', '~> 0.21'
2929

helpers/sql-processor/opentelemetry-helpers-sql-processor.gemspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ Gem::Specification.new do |spec|
2323
Dir.glob('*.md') +
2424
['LICENSE', '.yardopts']
2525
spec.require_paths = ['lib']
26-
spec.required_ruby_version = ">= #{File.read(File.expand_path('../../gemspecs/RUBY_REQUIREMENT', __dir__))}"
26+
spec.required_ruby_version = '>= 3.2'
2727

2828
spec.add_dependency 'opentelemetry-common', '~> 0.21'
2929

helpers/sql/opentelemetry-helpers-sql.gemspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ Gem::Specification.new do |spec|
2323
Dir.glob('*.md') +
2424
['LICENSE', '.yardopts']
2525
spec.require_paths = ['lib']
26-
spec.required_ruby_version = ">= #{File.read(File.expand_path('../../gemspecs/RUBY_REQUIREMENT', __dir__))}"
26+
spec.required_ruby_version = '>= 3.2'
2727

2828
spec.add_dependency 'opentelemetry-api', '~> 1.7'
2929

instrumentation/action_mailer/opentelemetry-instrumentation-action_mailer.gemspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ Gem::Specification.new do |spec|
2323
Dir.glob('*.md') +
2424
['LICENSE', '.yardopts']
2525
spec.require_paths = ['lib']
26-
spec.required_ruby_version = ">= #{File.read(File.expand_path('../../gemspecs/RUBY_REQUIREMENT', __dir__))}"
26+
spec.required_ruby_version = '>= 3.2'
2727

2828
spec.add_dependency 'opentelemetry-instrumentation-active_support', '~> 0.10'
2929

instrumentation/action_pack/opentelemetry-instrumentation-action_pack.gemspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ Gem::Specification.new do |spec|
2323
Dir.glob('*.md') +
2424
['LICENSE', '.yardopts']
2525
spec.require_paths = ['lib']
26-
spec.required_ruby_version = ">= #{File.read(File.expand_path('../../gemspecs/RUBY_REQUIREMENT', __dir__))}"
26+
spec.required_ruby_version = '>= 3.2'
2727

2828
spec.add_dependency 'opentelemetry-instrumentation-rack', '~> 0.29'
2929

instrumentation/action_view/opentelemetry-instrumentation-action_view.gemspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ Gem::Specification.new do |spec|
2323
Dir.glob('*.md') +
2424
['LICENSE', '.yardopts']
2525
spec.require_paths = ['lib']
26-
spec.required_ruby_version = ">= #{File.read(File.expand_path('../../gemspecs/RUBY_REQUIREMENT', __dir__))}"
26+
spec.required_ruby_version = '>= 3.2'
2727

2828
spec.add_dependency 'opentelemetry-instrumentation-active_support', '~> 0.10'
2929

instrumentation/active_job/opentelemetry-instrumentation-active_job.gemspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ Gem::Specification.new do |spec|
2323
Dir.glob('*.md') +
2424
['LICENSE', '.yardopts']
2525
spec.require_paths = ['lib']
26-
spec.required_ruby_version = ">= #{File.read(File.expand_path('../../gemspecs/RUBY_REQUIREMENT', __dir__))}"
26+
spec.required_ruby_version = '>= 3.2'
2727

2828
spec.add_dependency 'opentelemetry-instrumentation-base', '~> 0.25'
2929

0 commit comments

Comments
 (0)