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
- #shared ⇒ Object
Instance Attribute Details
#parsed_config ⇒ Object
Returns the value of attribute parsed_config.
3 4 5 |
# File 'lib/eye/dsl/main.rb', line 3 def parsed_config @parsed_config end |
#parsed_default_app ⇒ Object
Returns the value of attribute parsed_default_app.
3 4 5 |
# File 'lib/eye/dsl/main.rb', line 3 def parsed_default_app @parsed_default_app end |
#parsed_filename ⇒ Object
Returns the value of attribute parsed_filename.
3 4 5 |
# File 'lib/eye/dsl/main.rb', line 3 def parsed_filename @parsed_filename end |
Instance Method Details
#application(name, &block) ⇒ Object Also known as: project, app
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/eye/dsl/main.rb', line 5 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
47 48 49 50 51 52 53 54 55 |
# File 'lib/eye/dsl/main.rb', line 47 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
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/eye/dsl/main.rb', line 26 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 |
#shared ⇒ Object
59 60 61 62 |
# File 'lib/eye/dsl/main.rb', line 59 def shared require 'ostruct' @shared_object ||= OpenStruct.new end |