Sha256: 54fc8828eaa6d240bd28aa13da857e7b3c733c45d98020940dfc8e14343b0d4f

Contents?: true

Size: 888 Bytes

Versions: 2

Compression:

Stored size: 888 Bytes

Contents

# frozen_string_literal: true

require 'mwc/options/project'
require 'mwc/options/mruby'

module Mwc
  # The compile environment manager
  #
  # @since 0.3.0
  # @api private
  class Environment
    # @since 0.3.0
    # @api private
    attr_reader :environments, :project, :mruby

    # @since 0.3.0
    # @api private
    def initialize(parent = nil, &block)
      @parent = parent
      @environments = {}
      @project = Options::Project.new(parent&.project)
      @mruby = Options::MRuby.new(parent&.mruby)
      instance_exec(self, &block) if block_given?
    end

    # Define new environment
    #
    # @param name [Symbol] the environment name
    # @param block [Proc] the environment config block
    #
    # @since 0.3.0
    # @api private
    def env(name, &block)
      return if @parent

      @environments[name.to_sym] = Environment.new(self, &block)
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
mwc-0.4.0 lib/mwc/environment.rb
mwc-0.3.0 lib/mwc/environment.rb