Sha256: a5f111cab92cbebb1cc60f3b07d7d517e85a4eb50cab2c2474a2a859fe4eb421

Contents?: true

Size: 1.19 KB

Versions: 88

Compression:

Stored size: 1.19 KB

Contents

# frozen_string_literal: true

require 'avm/source_generators/base'
require 'eac_ruby_utils/core_ext'

module Avm
  module EacRubyBase1
    module SourceGenerators
      class Base < ::Avm::SourceGenerators::Base
        class VersionBuilder
          enable_simple_cache
          common_constructor :gem_name, :options

          def to_s
            r = "'~> #{two_segments}'"
            r += ", '>= #{three_segments}'" if segments.count >= 3 && segments[2].positive?
            r
          end

          # @return [Gem::Version]
          def version
            (options_version || default_version)
          end

          def two_segments
            segments.first(2).join('.')
          end

          def three_segments
            segments.first(3).join('.')
          end

          private

          def segments_uncached
            version.release.to_s.split('.').map(&:to_i)
          end

          def default_version
            ::Gem.loaded_specs[gem_name].version
          end

          def options_version
            options["#{gem_name}_version".dasherize.to_sym].if_present do |v|
              ::Gem::Version.new(v)
            end
          end
        end
      end
    end
  end
end

Version data entries

88 entries across 88 versions & 2 rubygems

Version Path
eac_tools-0.74.1 sub/avm-eac_ruby_base1/lib/avm/eac_ruby_base1/source_generators/base/version_builder.rb
eac_tools-0.74.0 sub/avm-eac_ruby_base1/lib/avm/eac_ruby_base1/source_generators/base/version_builder.rb
eac_tools-0.73.0 sub/avm-eac_ruby_base1/lib/avm/eac_ruby_base1/source_generators/base/version_builder.rb
eac_tools-0.72.0 sub/avm-eac_ruby_base1/lib/avm/eac_ruby_base1/source_generators/base/version_builder.rb
eac_tools-0.70.1 sub/avm-eac_ruby_base1/lib/avm/eac_ruby_base1/source_generators/base/version_builder.rb
eac_tools-0.70.0 sub/avm-eac_ruby_base1/lib/avm/eac_ruby_base1/source_generators/base/version_builder.rb
eac_tools-0.69.1 sub/avm-eac_ruby_base1/lib/avm/eac_ruby_base1/source_generators/base/version_builder.rb
eac_tools-0.69.0 sub/avm-eac_ruby_base1/lib/avm/eac_ruby_base1/source_generators/base/version_builder.rb
eac_tools-0.68.0 sub/avm-eac_ruby_base1/lib/avm/eac_ruby_base1/source_generators/base/version_builder.rb
eac_tools-0.67.1 sub/avm-eac_ruby_base1/lib/avm/eac_ruby_base1/source_generators/base/version_builder.rb
eac_tools-0.67.0 sub/avm-eac_ruby_base1/lib/avm/eac_ruby_base1/source_generators/base/version_builder.rb
eac_tools-0.66.0 sub/avm-eac_ruby_base1/lib/avm/eac_ruby_base1/source_generators/base/version_builder.rb
avm-eac_ruby_base1-0.30.3 lib/avm/eac_ruby_base1/source_generators/base/version_builder.rb
eac_tools-0.65.1 sub/avm-eac_ruby_base1/lib/avm/eac_ruby_base1/source_generators/base/version_builder.rb
eac_tools-0.65.0 sub/avm-eac_ruby_base1/lib/avm/eac_ruby_base1/source_generators/base/version_builder.rb
eac_tools-0.64.0 sub/avm-eac_ruby_base1/lib/avm/eac_ruby_base1/source_generators/base/version_builder.rb
eac_tools-0.63.0 sub/avm-eac_ruby_base1/lib/avm/eac_ruby_base1/source_generators/base/version_builder.rb
eac_tools-0.62.1 sub/avm-eac_ruby_base1/lib/avm/eac_ruby_base1/source_generators/base/version_builder.rb
eac_tools-0.62.0 sub/avm-eac_ruby_base1/lib/avm/eac_ruby_base1/source_generators/base/version_builder.rb
eac_tools-0.61.1 sub/avm-eac_ruby_base1/lib/avm/eac_ruby_base1/source_generators/base/version_builder.rb