Sha256: 392d295ab9a287d19c4279483950552c9c6ca8ab1c18cc75617ce31682c973f4

Contents?: true

Size: 1.02 KB

Versions: 1

Compression:

Stored size: 1.02 KB

Contents

require 'appraisal/dependency_list'
require 'appraisal/utils'

module Appraisal
  class PathSource
    def initialize(source, options = {})
      @dependencies = DependencyList.new
      @source = source
      @options = options
    end

    def gem(name, *requirements)
      @dependencies.add(name, requirements)
    end

    def run(&block)
      instance_exec(&block)
    end

    def to_s
      dependencies = @dependencies.to_s.strip.gsub(/^/, '  ')

      if @options.empty?
        "path #{Utils.prefix_path(@source).inspect} do\n#{dependencies}\nend"
      else
        "path #{Utils.prefix_path(@source).inspect}, #{Utils.format_string(@options)} do\n" +
          "#{dependencies}\nend"
      end
    end

    # :nodoc:
    def for_dup
      dependencies = @dependencies.for_dup.strip.gsub(/^/, '  ')

      if @options.empty?
        "path #{@source.inspect} do\n#{dependencies}\nend"
      else
        "path #{@source.inspect}, #{Utils.format_string(@options)} do\n" +
          "#{dependencies}\nend"
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
appraisal-1.0.3 lib/appraisal/path_source.rb