Sha256: 69cfc7779c379aad94a88ada416582c0e463c1b57dc19eca950fa0569dc5bf36

Contents?: true

Size: 1.42 KB

Versions: 6

Compression:

Stored size: 1.42 KB

Contents

module Eye::Dsl::Main
  attr_accessor :parsed_config, :parsed_filename

  def application(name, &block)
    Eye::Dsl.debug "=> app: #{name}"    
    opts = Eye::Dsl::ApplicationOpts.new(name)
    opts.instance_eval(&block)

    @parsed_config ||= {}
    @parsed_config[:applications] ||= {}
    @parsed_config[:applications][name.to_s] = opts.config if opts.config

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

  alias :app :application 

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

    Eye::Dsl::Opts.with_parsed_file(glob) do |mask|
      Dir[mask].each do |path|
        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
  end

  def config(&block)
    Eye::Dsl.debug "=> config"

    @parsed_config ||= {}
    @parsed_config[:config] ||= {}

    opts = Eye::Dsl::ConfigOpts.new
    opts.instance_eval(&block)
    @parsed_config[:config].merge!(opts.config)

    Eye::Dsl.debug "<= config"
  end

  def logger=(log_path)
    STDERR.puts "Eye.logger= is deprecated!"
    @parsed_config ||= {}
    @parsed_config[:config] ||= {}
    @parsed_config[:config][:logger] = log_path
  end
  
  def logger_level=(log_level)
    STDERR.puts "Eye.logger_level= is deprecated!"
    @parsed_config ||= {}
    @parsed_config[:config] ||= {}
    @parsed_config[:config][:logger_level] = log_level
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
eye-0.2.4 lib/eye/dsl/main.rb
eye-0.2.3 lib/eye/dsl/main.rb
eye-0.2.2 lib/eye/dsl/main.rb
eye-0.2.1 lib/eye/dsl/main.rb
eye-0.2 lib/eye/dsl/main.rb
eye-0.1.11 lib/eye/dsl/main.rb