Sha256: e66d4acdb6357a7f8ff7c3ef76298aaa9f1ed41e3f026ba00a815258a9b4cba3

Contents?: true

Size: 1.48 KB

Versions: 12

Compression:

Stored size: 1.48 KB

Contents

# encoding: utf-8
# This file is distributed under New Relic's license terms.
# See https://github.com/newrelic/rpm/blob/master/LICENSE for complete details.

module Multiverse
  # Reads an envfile.rb and converts it into gemfiles that can be used by
  # bundler
  class Envfile
    attr_accessor :file_path, :condition
    attr_reader :before, :after, :mode, :skip_message, :omit_mocha, :omit_collector

    def initialize(file_path)
      self.file_path = file_path
      @gemfiles = []
      @mode = 'fork'
      if File.exist? file_path
        @text = File.read self.file_path
        instance_eval @text
      end
      @gemfiles = [''] if @gemfiles.empty?
    end

    def suite_condition(skip_message, &block)
      @skip_message = skip_message
      @condition = block
    end

    def gemfile(content)
      @gemfiles.push content
    end

    def omit_mocha!
      @omit_mocha = true
    end

    def omit_collector!
      @omit_collector = true
    end

    def before_suite(&block)
      @before = block
    end

    def after_suite(&block)
      @after = block
    end

    def execute_mode(mode)
      valid_modes = %w| fork spawn |
      unless valid_modes.member? mode
        raise ArgumentError, "#{mode.inspect} is not a valid execute mode.  Valid modes: #{valid_modes.inspect}"
      end
      @mode = mode
    end

    include Enumerable
    def each(&block)
      @gemfiles.each(&block)
    end

    def [](key)
      @gemfiles[key]
    end

    def size
      @gemfiles.size
    end

  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
newrelic_rpm-3.7.1.188 test/multiverse/lib/multiverse/envfile.rb
newrelic_rpm-3.7.1.182 test/multiverse/lib/multiverse/envfile.rb
newrelic_rpm-3.7.1.180 test/multiverse/lib/multiverse/envfile.rb
newrelic_rpm-3.7.0.177 test/multiverse/lib/multiverse/envfile.rb
newrelic_rpm-3.7.0.174.beta test/multiverse/lib/multiverse/envfile.rb
newrelic_rpm-3.6.9.171 test/multiverse/lib/multiverse/envfile.rb
newrelic_rpm-3.6.8.168 test/multiverse/lib/multiverse/envfile.rb
newrelic_rpm-3.6.8.164 test/multiverse/lib/multiverse/envfile.rb
newrelic_rpm-3.6.7.159 test/multiverse/lib/multiverse/envfile.rb
newrelic_rpm-3.6.7.159.beta test/multiverse/lib/multiverse/envfile.rb
newrelic_rpm-3.6.7.152 test/multiverse/lib/multiverse/envfile.rb
newrelic_rpm-3.6.6.147 test/multiverse/lib/multiverse/envfile.rb