Module: RactorRailsShim::Version
- Defined in:
- lib/ractor_rails_shim/version_check.rb
Constant Summary collapse
- SUPPORTED_RUBY =
Ruby version the shim was developed against (major.minor.patch). Ractor semantics are still settling; the frozen-iseq call-cache fix (#22075) and the cross-ractor env-string fix that the shim relies on both shipped in 4.0.6, so earlier 4.0.x patch releases are NOT supported.
"4.0.6"- TESTED_RAILS =
Rails versions each patch was tested against. Patches are registered with one or more entries from this list; the dispatcher applies a patch only if the runtime Rails version matches one of its tags. To add 7.x support, write the version-specific patch variants and add the tag here.
["8.1"].freeze
Class Method Summary collapse
-
.rails ⇒ Object
Runtime Rails version as a Gem::Version, or nil if Rails isn't loaded yet (the normal config/boot.rb case — install is called before
require "rails"). -
.rails_segment ⇒ Object
Major.minor segment as a String ("8.1"), or nil if Rails isn't loaded.
-
.ruby ⇒ Object
Runtime Ruby version as a Gem::Version (e.g. "4.0.6").
-
.ruby_segment ⇒ Object
Major.minor segment of the running Ruby.
-
.satisfies?(segment, requirement) ⇒ Boolean
Compare a runtime segment ("8.1") against a Gem::Requirement string (e.g. ">= 7.0", "~> 8.1").
-
.supported_rails? ⇒ Boolean
True if the runtime Rails major.minor is in the tested set (or Rails isn't loaded yet — can't decide, so optimistic).
-
.supported_ruby? ⇒ Boolean
True if the runtime Ruby is >= the supported version (4.0.6).
Class Method Details
.rails ⇒ Object
Runtime Rails version as a Gem::Version, or nil if Rails isn't
loaded yet (the normal config/boot.rb case — install is called before
require "rails").
47 48 49 50 51 52 53 54 55 |
# File 'lib/ractor_rails_shim/version_check.rb', line 47 def rails return nil unless defined?(::Rails) && defined?(::Rails::VERSION) return nil if ::Rails::VERSION::STRING.nil? || ::Rails::VERSION::STRING.empty? begin Gem::Version.new(::Rails::VERSION::STRING) rescue ArgumentError nil end end |
.rails_segment ⇒ Object
Major.minor segment as a String ("8.1"), or nil if Rails isn't loaded.
58 59 60 61 |
# File 'lib/ractor_rails_shim/version_check.rb', line 58 def rails_segment return nil unless (rv = rails) "#{rv.segments[0]}.#{rv.segments[1]}" end |
.ruby ⇒ Object
Runtime Ruby version as a Gem::Version (e.g. "4.0.6"). Always available — Ruby is obviously loaded.
40 41 42 |
# File 'lib/ractor_rails_shim/version_check.rb', line 40 def ruby Gem::Version.new(RUBY_VERSION) end |
.ruby_segment ⇒ Object
Major.minor segment of the running Ruby.
64 65 66 67 |
# File 'lib/ractor_rails_shim/version_check.rb', line 64 def ruby_segment v = ruby "#{v.segments[0]}.#{v.segments[1]}" end |
.satisfies?(segment, requirement) ⇒ Boolean
Compare a runtime segment ("8.1") against a Gem::Requirement string (e.g. ">= 7.0", "~> 8.1"). Returns true if the segment satisfies the requirement. Used by the patch registry to decide applicability.
86 87 88 89 |
# File 'lib/ractor_rails_shim/version_check.rb', line 86 def satisfies?(segment, requirement) return false if segment.nil? Gem::Requirement.new(requirement).satisfied_by?(Gem::Version.new(segment)) end |
.supported_rails? ⇒ Boolean
True if the runtime Rails major.minor is in the tested set (or Rails isn't loaded yet — can't decide, so optimistic).
78 79 80 81 |
# File 'lib/ractor_rails_shim/version_check.rb', line 78 def supported_rails? return true unless rails # Rails not loaded: defer decision. TESTED_RAILS.include?(rails_segment) end |
.supported_ruby? ⇒ Boolean
True if the runtime Ruby is >= the supported version (4.0.6). Uses a full Gem::Version compare (not a segment match) so the minimum patch release is enforced — the shim relies on fixes that shipped in 4.0.6.
72 73 74 |
# File 'lib/ractor_rails_shim/version_check.rb', line 72 def supported_ruby? ruby >= Gem::Version.new(SUPPORTED_RUBY) end |