Sha256: 6783aaa375e0c20fb5d059b2e96883a9ddef12c98b877078e600a34396494138

Contents?: true

Size: 1.61 KB

Versions: 15

Compression:

Stored size: 1.61 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, :newrelic_gemfile_options
    attr_reader :before, :after, :mode, :skip_message

    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

    # string representation options hash to append to the newrelic_rpm line
    # when setting up Gemfile
    # e.g. ":require => false"
    def newrelic_gemfile_options=(options_string)
      @newrelic_gemfile_options = options_string
    end


    def gemfile(content)
      @gemfiles.push content
    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

15 entries across 15 versions & 1 rubygems

Version Path
newrelic_rpm-3.6.4.113.beta test/multiverse/lib/multiverse/envfile.rb
newrelic_rpm-3.6.3.111 test/multiverse/lib/multiverse/envfile.rb
newrelic_rpm-3.6.3.106 test/multiverse/lib/multiverse/envfile.rb
newrelic_rpm-3.6.3.105.beta test/multiverse/lib/multiverse/envfile.rb
newrelic_rpm-3.6.3.104 test/multiverse/lib/multiverse/envfile.rb
newrelic_rpm-3.6.3.103.beta test/multiverse/lib/multiverse/envfile.rb
newrelic_rpm-3.6.2.96 test/multiverse/lib/multiverse/envfile.rb
newrelic_rpm-3.6.2.90.beta test/multiverse/lib/multiverse/envfile.rb
newrelic_rpm-3.6.1.88 test/multiverse/lib/multiverse/envfile.rb
newrelic_rpm-3.6.1.87 test/multiverse/lib/multiverse/envfile.rb
newrelic_rpm-3.6.1.86.beta test/multiverse/lib/multiverse/envfile.rb
newrelic_rpm-3.6.1.85.beta test/multiverse/lib/multiverse/envfile.rb
newrelic_rpm-3.6.0.83 test/multiverse/lib/multiverse/envfile.rb
newrelic_rpm-3.6.0.78 test/multiverse/lib/multiverse/envfile.rb
newrelic_rpm-3.6.0.74.beta test/multiverse/lib/multiverse/envfile.rb