Sha256: 712e9324bb26b8ec26820ba590080be7cb41ab3d2dafbe7be2eb5611c406bae8

Contents?: true

Size: 862 Bytes

Versions: 4

Compression:

Stored size: 862 Bytes

Contents

require 'appraisal/appraisal'
require 'appraisal/errors'
require 'appraisal/gemfile'

module Appraisal
  # Loads and parses Appraisals file
  class File
    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.exists? 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

    private

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

    def path
      'Appraisals'
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
appraisal-1.0.0 lib/appraisal/file.rb
appraisal-1.0.0.beta3 lib/appraisal/file.rb
appraisal-1.0.0.beta2 lib/appraisal/file.rb
appraisal-1.0.0.beta1 lib/appraisal/file.rb