Class: ConfStack::DSL
- Inherits:
-
Object
- Object
- ConfStack::DSL
- Defined in:
- lib/conf_stack.rb
Overview
Describes the DSL used in configuration files.
Instance Method Summary collapse
-
#at_project_root ⇒ Object
Syntactic sugar on top of
project_rootto specify that the current file resides in the root of the project. -
#backward_compatability(*args, **kwargs) ⇒ Object
(also: #plan_files, #has_plan_files, #plan_file, #define_alias, #skip_confirmation)
The following methods are maintained for backwards compatability with .masterplan files used by Mastermind.
-
#configure(attribute, value = nil, &block) ⇒ Object
(also: #set)
Add arbitrary configuration attributes to the configuration object.
-
#initialize(config, filename) ⇒ DSL
constructor
A new instance of DSL.
-
#project_root(root) ⇒ Object
Specifies the root of the project.
-
#see_also(filename) ⇒ Object
Specifies that another file should also be loaded when loading this file.
Constructor Details
#initialize(config, filename) ⇒ DSL
Returns a new instance of DSL.
136 137 138 139 140 |
# File 'lib/conf_stack.rb', line 136 def initialize(config, filename) @config = config @filename = filename instance_eval(File.read(filename), filename, 0) if File.exists? filename end |
Instance Method Details
#at_project_root ⇒ Object
Syntactic sugar on top of project_root to specify that the current file resides in the root of the project.
167 168 169 |
# File 'lib/conf_stack.rb', line 167 def at_project_root project_root File.dirname(@filename) end |
#backward_compatability(*args, **kwargs) ⇒ Object Also known as: plan_files, has_plan_files, plan_file, define_alias, skip_confirmation
The following methods are maintained for backwards compatability with .masterplan files used by Mastermind
196 197 |
# File 'lib/conf_stack.rb', line 196 def backward_compatability(*args, **kwargs) end |
#configure(attribute, value = nil, &block) ⇒ Object #configure(attribute) ⇒ Object Also known as: set
Add arbitrary configuration attributes to the configuration object. Use this to add plan specific configuration options.
186 187 188 189 190 191 |
# File 'lib/conf_stack.rb', line 186 def configure(attribute, value=nil, &block) attribute, value = attribute.first if attribute.is_a? Hash ConfStack.add_attribute(attribute) @config.public_send "#{attribute}=", value, &block end |
#project_root(root) ⇒ Object
Specifies the root of the project. root must be a directory.
155 156 157 158 159 160 161 |
# File 'lib/conf_stack.rb', line 155 def project_root(root) unless Dir.exist? root raise InvalidDirectoryError.new('Invalid project root', root) end @config.project_root = root end |
#see_also(filename) ⇒ Object
Specifies that another file should also be loaded when loading this file. NOTE: This immediately loads the other file.
146 147 148 |
# File 'lib/conf_stack.rb', line 146 def see_also(filename) @config.load_configuration_file(File.(filename)) end |