Sha256: 0b6eb5a0f458ce0c322b25193105c76a105b29e9ffbda80f4b9d42a7b2bd410f

Contents?: true

Size: 1.1 KB

Versions: 14

Compression:

Stored size: 1.1 KB

Contents

require 'appraisal/utils'

module Appraisal
  # Dependency on a gem and optional version requirements
  class Dependency
    attr_accessor :requirements
    attr_reader :name

    def initialize(name, requirements)
      @name = name
      @requirements = requirements
    end

    def to_s
      formatted_output Utils.format_arguments(path_prefixed_requirements)
    end

    # :nodoc:
    def for_dup
      formatted_output Utils.format_arguments(requirements)
    end

    private

    def path_prefixed_requirements
      requirements.map do |requirement|
        if requirement.is_a?(Hash)
          if requirement[:path]
            requirement[:path] = Utils.prefix_path(requirement[:path])
          end

          if requirement[:git]
            requirement[:git] = Utils.prefix_path(requirement[:git])
          end
        end

        requirement
      end
    end

    def formatted_output(output_requirements)
      [gem_name, output_requirements].compact.join(", ")
    end

    def gem_name
      %{gem "#{name}"}
    end

    def no_requirements?
      requirements.nil? || requirements.empty?
    end
  end
end

Version data entries

14 entries across 14 versions & 3 rubygems

Version Path
honeybadger-5.4.0 vendor/bundle/ruby/3.2.0/gems/appraisal-2.5.0/lib/appraisal/dependency.rb
honeybadger-5.3.0 vendor/bundle/ruby/3.2.0/gems/appraisal-2.5.0/lib/appraisal/dependency.rb
appraisal-2.5.0 lib/appraisal/dependency.rb
appraisal-2.4.1 lib/appraisal/dependency.rb
appraisal-2.4.0 lib/appraisal/dependency.rb
appraisal-2.3.0 lib/appraisal/dependency.rb
honeybadger-4.5.3 vendor/bundle/ruby/2.6.0/gems/appraisal-2.2.0/lib/appraisal/dependency.rb
enju_leaf-1.2.1 vendor/bundle/ruby/2.3/gems/appraisal-2.2.0/lib/appraisal/dependency.rb
appraisal-2.2.0 lib/appraisal/dependency.rb
appraisal-2.1.0 lib/appraisal/dependency.rb
appraisal-2.0.2 lib/appraisal/dependency.rb
appraisal-2.0.1 lib/appraisal/dependency.rb
appraisal-2.0.0 lib/appraisal/dependency.rb
appraisal-1.0.3 lib/appraisal/dependency.rb