Sha256: d8596d606cd200308367706618e7544ad79cdc4431a3c24d23da91775a0e7d42

Contents?: true

Size: 1.5 KB

Versions: 41

Compression:

Stored size: 1.5 KB

Contents

module RubyDep
  class Travis
    class RubyVersion
      REGEXP = /^
      (?:
       (?<engine>ruby|jruby)
      -)?
        (?<version>\d+\.\d+\.\d+(?:\.\d+)?)
      (?:-p\d+)?
      (?:-clang)?
      $/x

      class Error < RuntimeError
        class Unrecognized < Error
          def initialize(invalid_version_string)
            @invalid_version_string = invalid_version_string
          end

          def message
            "Unrecognized Ruby version: #{@invalid_version_string.inspect}"
          end

          class JRubyVersion < Unrecognized
            def message
              "Unrecognized JRuby version: #{@invalid_version_string.inspect}"
            end
          end
        end
      end

      def initialize(travis_version_string)
        ruby_version_string = version_for(travis_version_string)
        @version = Gem::Version.new(ruby_version_string)
      end

      def segments
        @version.segments
      end

      private

      def version_for(travis_version_string)
        match = REGEXP.match(travis_version_string)
        raise Error::Unrecognized, travis_version_string unless match
        return match[:version] unless match[:engine]
        return jruby_version(match[:version]) if match[:engine] == 'jruby'
        match[:version] # if match[:engine] == 'ruby'
      end

      def jruby_version(version)
        return '2.2.3' if version == '9.0.5.0'
        return '2.2.2' if version == '9.0.4.0'
        raise Error::Unrecognized::JRubyVersion, version
      end
    end
  end
end

Version data entries

41 entries across 34 versions & 4 rubygems

Version Path
vagrant-unbundled-2.2.16.0 vendor/bundle/ruby/2.7.0/gems/ruby_dep-1.3.1/lib/ruby_dep/travis/ruby_version.rb
vagrant-unbundled-2.2.14.0 vendor/bundle/ruby/2.7.0/gems/ruby_dep-1.3.1/lib/ruby_dep/travis/ruby_version.rb
vagrant-unbundled-2.2.10.0 vendor/bundle/ruby/2.7.0/gems/ruby_dep-1.3.1/lib/ruby_dep/travis/ruby_version.rb
vagrant-unbundled-2.2.9.0 vendor/bundle/ruby/2.7.0/gems/ruby_dep-1.3.1/lib/ruby_dep/travis/ruby_version.rb
vagrant-unbundled-2.2.8.0 vendor/bundle/ruby/2.7.0/gems/ruby_dep-1.3.1/lib/ruby_dep/travis/ruby_version.rb
vagrant-unbundled-2.2.7.0 vendor/bundle/ruby/2.4.0/gems/ruby_dep-1.3.1/lib/ruby_dep/travis/ruby_version.rb
vagrant-unbundled-2.2.7.0 vendor/bundle/ruby/2.6.0/gems/ruby_dep-1.3.1/lib/ruby_dep/travis/ruby_version.rb
vagrant-unbundled-2.2.7.0 vendor/bundle/ruby/2.7.0/gems/ruby_dep-1.3.1/lib/ruby_dep/travis/ruby_version.rb
vagrant-unbundled-2.2.6.2 vendor/bundle/ruby/2.6.0/gems/ruby_dep-1.3.1/lib/ruby_dep/travis/ruby_version.rb
vagrant-unbundled-2.2.6.1 vendor/bundle/ruby/2.6.0/gems/ruby_dep-1.3.1/lib/ruby_dep/travis/ruby_version.rb
vagrant-unbundled-2.2.6.0 vendor/bundle/ruby/2.6.0/gems/ruby_dep-1.3.1/lib/ruby_dep/travis/ruby_version.rb
vagrant-unbundled-2.2.5.0 vendor/bundle/ruby/2.5.0/gems/ruby_dep-1.3.1/lib/ruby_dep/travis/ruby_version.rb
vagrant-unbundled-2.2.5.0 vendor/bundle/ruby/2.6.0/gems/ruby_dep-1.3.1/lib/ruby_dep/travis/ruby_version.rb
vagrant-unbundled-2.2.4.0 vendor/bundle/ruby/2.5.0/gems/ruby_dep-1.3.1/lib/ruby_dep/travis/ruby_version.rb
vagrant-unbundled-2.2.4.0 vendor/bundle/ruby/2.6.0/gems/ruby_dep-1.3.1/lib/ruby_dep/travis/ruby_version.rb
vagrant-unbundled-2.2.3.0 vendor/bundle/ruby/2.5.0/gems/ruby_dep-1.3.1/lib/ruby_dep/travis/ruby_version.rb
vagrant-unbundled-2.2.2.0 vendor/bundle/ruby/2.5.0/gems/ruby_dep-1.3.1/lib/ruby_dep/travis/ruby_version.rb
vagrant-unbundled-2.2.0.0 vendor/bundle/ruby/2.5.0/gems/ruby_dep-1.3.1/lib/ruby_dep/travis/ruby_version.rb
vagrant-unbundled-2.1.4.0 vendor/bundle/ruby/2.5.0/gems/ruby_dep-1.3.1/lib/ruby_dep/travis/ruby_version.rb
vagrant-unbundled-2.1.2.0 vendor/bundle/ruby/2.3.0/gems/ruby_dep-1.3.1/lib/ruby_dep/travis/ruby_version.rb