Sha256: 76a328dcb16c41e45220ba39d06fc6c7059563b5e51484b503e27eb1de1c3431

Contents?: true

Size: 970 Bytes

Versions: 3

Compression:

Stored size: 970 Bytes

Contents

require 'appraisal/appraisal'
require "appraisal/customize"
require 'appraisal/errors'
require 'appraisal/gemfile'

module Appraisal
  # Loads and parses Appraisals file
  class AppraisalFile
    attr_reader :appraisals, :gemfile

    def self.each(&block)
      new.each(&block)
    end

    def initialize
      @appraisals = []
      @gemfile = Gemfile.new
      @gemfile.load(ENV['BUNDLE_GEMFILE'] || 'Gemfile')

      if File.exist? path
        run IO.read(path)
      else
        raise AppraisalsNotFound
      end
    end

    def each(&block)
      appraisals.each(&block)
    end

    def appraise(name, &block)
      appraisal = Appraisal.new(name, gemfile)
      appraisal.instance_eval(&block)
      @appraisals << appraisal
    end

    def customize_gemfiles(&_block)
      Customize.new(yield)
    end

    private

    def run(definitions)
      instance_eval(definitions, __FILE__, __LINE__)
    end

    def path
      'Appraisals'
    end
  end
end

Version data entries

3 entries across 3 versions & 2 rubygems

Version Path
honeybadger-5.4.0 vendor/bundle/ruby/3.2.0/gems/appraisal-2.5.0/lib/appraisal/appraisal_file.rb
honeybadger-5.3.0 vendor/bundle/ruby/3.2.0/gems/appraisal-2.5.0/lib/appraisal/appraisal_file.rb
appraisal-2.5.0 lib/appraisal/appraisal_file.rb