Module: ShopifyRubyDefinitions::RubyVersions
- Included in:
- ShopifyRubyDefinitions
- Defined in:
- lib/shopify_ruby_definitions/ruby_versions.rb
Constant Summary collapse
- VERSIONS_DIRECTORY =
File.("../../../rubies", __FILE__)
- ALL_VERSIONS =
Dir["#{VERSIONS_DIRECTORY}/*"].map { |f| File.basename(f) }
- VERSION_OVERRIDES =
build_version_overrides(ALL_VERSIONS)
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.build_version_overrides(all_versions) ⇒ Object
6 7 8 9 10 11 12 |
# File 'lib/shopify_ruby_definitions/ruby_versions.rb', line 6 def build_version_overrides(all_versions) all_versions.sort_by do |version| version.scan(/\d+/).map(&:to_i) end.to_h do |version| [version.partition("-pshopify").first, version] end.freeze end |
Instance Method Details
#resolve_version(version) ⇒ Object
23 24 25 26 27 28 29 30 31 32 |
# File 'lib/shopify_ruby_definitions/ruby_versions.rb', line 23 def resolve_version(version) if version.match?(/\A\d+\.\d+\z/) pattern = /\A#{Regexp.escape(version)}\.(\d+)\z/ versions = version_overrides.keys.grep(pattern) unless versions.empty? version = versions.max_by { |v| v.match(pattern)[1].to_i } end end version_overrides.fetch(version, version) end |
#version_overrides ⇒ Object
19 20 21 |
# File 'lib/shopify_ruby_definitions/ruby_versions.rb', line 19 def version_overrides VERSION_OVERRIDES end |