Sha256: 250da6615fcfcea762321ebe585ecd32eedb7c1c5bdf0ec57d30d8295b225cfc

Contents?: true

Size: 1.48 KB

Versions: 11

Compression:

Stored size: 1.48 KB

Contents

module Eye::Dsl::Main

  attr_accessor :parsed_config, :parsed_filename, :parsed_default_app

  def application(name, &block)
    Eye::Dsl.check_name(name)
    name = name.to_s

    Eye::Dsl.debug { "=> app: #{name}" }

    if name == '__default__'
      @parsed_default_app ||= Eye::Dsl::ApplicationOpts.new(name)
      @parsed_default_app.instance_eval(&block)
    else
      opts = Eye::Dsl::ApplicationOpts.new(name, @parsed_default_app)
      opts.instance_eval(&block)
      @parsed_config.applications[name] = opts.config if opts.config
    end

    Eye::Dsl.debug { "<= app: #{name}" }
  end

  alias project application
  alias app application

  def load(glob = '')
    return if glob.blank?

    loaded = false
    Eye::Dsl::Opts.with_parsed_file(glob) do |mask|
      Dir[mask].each do |path|
        loaded = true
        Eye::Dsl.debug { "=> load #{path}" }
        Eye.parsed_filename = path
        res = Kernel.load(path)
        Eye.info "load: subload #{path} (#{res})"
        Eye::Dsl.debug { "<= load #{path}" }
      end
    end

    unless loaded
      puts "Warning! Eye.load not found: '#{glob}'"
      warn "not found: '#{glob}'"
    end
  end

  def config(&block)
    Eye::Dsl.debug { '=> config' }

    opts = Eye::Dsl::ConfigOpts.new
    opts.instance_eval(&block)
    Eye::Utils.deep_merge!(@parsed_config.settings, opts.config)

    Eye::Dsl.debug { '<= config' }
  end

  alias settings config

  def shared
    require 'ostruct'
    @shared_object ||= OpenStruct.new
  end

end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
eye-0.10.1.pre lib/eye/dsl/main.rb
eye-0.10.0 lib/eye/dsl/main.rb
eye-0.10.0.alpha2 lib/eye/dsl/main.rb
eye-0.10.0.alpha lib/eye/dsl/main.rb
eye-0.9.4.nosigar lib/eye/dsl/main.rb
eye-0.9.4 lib/eye/dsl/main.rb
eye-0.9.3 lib/eye/dsl/main.rb
eye-0.9.2.nosigar lib/eye/dsl/main.rb
eye-0.9.2 lib/eye/dsl/main.rb
eye-0.9.1 lib/eye/dsl/main.rb
eye-0.9.pre lib/eye/dsl/main.rb