Class: Eye::Dsl

Inherits:
Object show all
Defined in:
lib/eye/dsl.rb

Defined Under Namespace

Modules: Chain, Main, Validation Classes: ApplicationOpts, ChildProcessOpts, ConfigOpts, Error, GroupOpts, Opts, ProcessOpts, PureOpts

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.verboseObject

Returns the value of attribute verbose


22
23
24
# File 'lib/eye/dsl.rb', line 22

def verbose
  @verbose
end

Class Method Details

.check_name(name) ⇒ Object

Raises:


49
50
51
# File 'lib/eye/dsl.rb', line 49

def check_name(name)
  raise Error, "':' is not allowed in name '#{name}'" if name.to_s.include?(':')
end

.debug(msg = '') ⇒ Object


24
25
26
# File 'lib/eye/dsl.rb', line 24

def debug(msg = '')
  puts msg if verbose
end

.parse(content = nil, filename = nil) ⇒ Object


28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/eye/dsl.rb', line 28

def parse(content = nil, filename = nil)
  Eye.parsed_config = Eye::Config.new
  Eye.parsed_filename = filename

  content = File.read(filename) if content.blank?

  silence_warnings do
    Kernel.eval(content, Eye::BINDING, filename.to_s)
  end

  Eye.parsed_config.transform!
  Eye.parsed_config.validate!
  parsed_config = Eye.parsed_config
  Eye.parsed_config = nil # remove object for better GC
  parsed_config
end

.parse_apps(*args) ⇒ Object


45
46
47
# File 'lib/eye/dsl.rb', line 45

def parse_apps(*args)
  parse(*args).applications
end