Sha256: 80a3d43d8daabf046b8deaf463e32190b00bf787f4f7c96bb9a909de6e08cffc

Contents?: true

Size: 1.07 KB

Versions: 140

Compression:

Stored size: 1.07 KB

Contents

# frozen_string_literal: true

require 'avm/version_number'
require 'eac_ruby_utils/core_ext'

module Avm
  module EacRubyBase1
    class PreferredVersionRequirements
      enable_simple_cache
      common_constructor :version do
        self.version = ::Avm::VersionNumber.new(version)
      end

      # @return [Avm::VersionNumber]
      def prefix_version
        ::Avm::VersionNumber.new(
          normalized_version.segments[0..normalized_version.segments.count - 2]
        )
      end

      # @return [Gem::Requirement]
      def to_requirement
        r = ["~> #{prefix_version}"]
        r << ">= #{normalized_version}" unless normalized_version.segments[-1].zero?
        ::Gem::Requirement.new(r)
      end

      # @return [Array<String>]
      def to_requirements_list
        to_requirement.requirements.map { |r| "#{r[0]} #{r[1]}" }
      end

      private

      # @return [Avm::VersionNumber]
      def normalized_version_uncached
        r = version
        r = ::Avm::VersionNumber.new(r.segments + [0]) while r.segments.count < 3
        r
      end
    end
  end
end

Version data entries

140 entries across 140 versions & 2 rubygems

Version Path
avm-eac_ruby_base1-0.35.1 lib/avm/eac_ruby_base1/preferred_version_requirements.rb
eac_tools-0.96.1 sub/avm-eac_ruby_base1/lib/avm/eac_ruby_base1/preferred_version_requirements.rb
avm-eac_ruby_base1-0.35.0 lib/avm/eac_ruby_base1/preferred_version_requirements.rb
eac_tools-0.95.0 sub/avm-eac_ruby_base1/lib/avm/eac_ruby_base1/preferred_version_requirements.rb
avm-eac_ruby_base1-0.34.1 lib/avm/eac_ruby_base1/preferred_version_requirements.rb
eac_tools-0.91.1 sub/avm-eac_ruby_base1/lib/avm/eac_ruby_base1/preferred_version_requirements.rb
avm-eac_ruby_base1-0.34.0 lib/avm/eac_ruby_base1/preferred_version_requirements.rb
eac_tools-0.91.0 sub/avm-eac_ruby_base1/lib/avm/eac_ruby_base1/preferred_version_requirements.rb
avm-eac_ruby_base1-0.33.1 lib/avm/eac_ruby_base1/preferred_version_requirements.rb
eac_tools-0.83.0 sub/avm-eac_ruby_base1/lib/avm/eac_ruby_base1/preferred_version_requirements.rb
eac_tools-0.82.0 sub/avm-eac_ruby_base1/lib/avm/eac_ruby_base1/preferred_version_requirements.rb
eac_tools-0.81.0 sub/avm-eac_ruby_base1/lib/avm/eac_ruby_base1/preferred_version_requirements.rb
avm-eac_ruby_base1-0.33.0 lib/avm/eac_ruby_base1/preferred_version_requirements.rb
eac_tools-0.80.0 sub/avm-eac_ruby_base1/lib/avm/eac_ruby_base1/preferred_version_requirements.rb
eac_tools-0.79.0 sub/avm-eac_ruby_base1/lib/avm/eac_ruby_base1/preferred_version_requirements.rb
avm-eac_ruby_base1-0.32.1 lib/avm/eac_ruby_base1/preferred_version_requirements.rb
eac_tools-0.78.0 sub/avm-eac_ruby_base1/lib/avm/eac_ruby_base1/preferred_version_requirements.rb
avm-eac_ruby_base1-0.32.0 lib/avm/eac_ruby_base1/preferred_version_requirements.rb
eac_tools-0.77.1 sub/avm-eac_ruby_base1/lib/avm/eac_ruby_base1/preferred_version_requirements.rb
eac_tools-0.77.0 sub/avm-eac_ruby_base1/lib/avm/eac_ruby_base1/preferred_version_requirements.rb