Module: Eye::Dsl::Main
- Defined in:
- lib/eye/dsl/main.rb
Instance Attribute Summary collapse
-
#parsed_config ⇒ Object
Returns the value of attribute parsed_config.
-
#parsed_default_app ⇒ Object
Returns the value of attribute parsed_default_app.
-
#parsed_filename ⇒ Object
Returns the value of attribute parsed_filename.
Instance Method Summary collapse
- #application(name, &block) ⇒ Object (also: #project, #app)
- #config(&block) ⇒ Object (also: #settings)
- #load(glob = '') ⇒ Object
Instance Attribute Details
#parsed_config ⇒ Object
Returns the value of attribute parsed_config.
2 3 4 |
# File 'lib/eye/dsl/main.rb', line 2 def parsed_config @parsed_config end |
#parsed_default_app ⇒ Object
Returns the value of attribute parsed_default_app.
2 3 4 |
# File 'lib/eye/dsl/main.rb', line 2 def parsed_default_app @parsed_default_app end |
#parsed_filename ⇒ Object
Returns the value of attribute parsed_filename.
2 3 4 |
# File 'lib/eye/dsl/main.rb', line 2 def parsed_filename @parsed_filename end |
Instance Method Details
#application(name, &block) ⇒ Object Also known as: project, app
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/eye/dsl/main.rb', line 4 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 |
#config(&block) ⇒ Object Also known as: settings
46 47 48 49 50 51 52 53 54 |
# File 'lib/eye/dsl/main.rb', line 46 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 |
#load(glob = '') ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/eye/dsl/main.rb', line 25 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 |