Class: CLI::Mastermind::Configuration::DSL
- Inherits:
-
Object
- Object
- CLI::Mastermind::Configuration::DSL
- Defined in:
- lib/cli/mastermind/configuration.rb
Instance Method Summary collapse
- #alias(name, arguments) ⇒ Object
-
#configure(attribute, value = nil, &block) ⇒ Object
Add arbitrary configuration attributes to the configuration object.
-
#initialize(config, filename) ⇒ DSL
constructor
A new instance of DSL.
-
#plan_file(*files) ⇒ Object
Specifies that a specific plan file exists at the given
filename. -
#plan_files(directory = File.join(File.dirname(@filename), 'plans')) ⇒ Object
(also: #has_plan_files)
With no arguments, specifies that plans exist in a /plans/ directory under the directory the masterplan is in.
-
#project_root(root = File.dirname(@filename)) ⇒ Object
(also: #at_project_root)
With no arguments, specifies that the current directory containing this masterplan is at the root of your project.
-
#see_also(filename) ⇒ Object
Specifies that another masterplan should also be loaded when loading this masterplan.
Constructor Details
#initialize(config, filename) ⇒ DSL
Returns a new instance of DSL.
132 133 134 135 136 |
# File 'lib/cli/mastermind/configuration.rb', line 132 def initialize(config, filename) @config = config @filename = filename instance_eval(File.read(filename), filename, 0) if File.exists? filename end |
Instance Method Details
#alias(name, arguments) ⇒ Object
171 172 173 |
# File 'lib/cli/mastermind/configuration.rb', line 171 def alias(name, arguments) @config.define_alias(name, arguments) end |
#configure(attribute, value = nil, &block) ⇒ Object
Add arbitrary configuration attributes to the configuration object. Use this to add plan specific configuration options.
166 167 168 169 |
# File 'lib/cli/mastermind/configuration.rb', line 166 def configure(attribute, value=nil, &block) Configuration.add_attribute(attribute) @config.public_send "#{attribute}=", value, &block end |
#plan_file(*files) ⇒ Object
Specifies that a specific plan file exists at the given filename.
160 161 162 |
# File 'lib/cli/mastermind/configuration.rb', line 160 def plan_file(*files) @config.add_plans(files) end |
#plan_files(directory = File.join(File.dirname(@filename), 'plans')) ⇒ Object Also known as: has_plan_files
With no arguments, specifies that plans exist in a /plans/ directory under the directory the masterplan is in.
154 155 156 |
# File 'lib/cli/mastermind/configuration.rb', line 154 def plan_files(directory = File.join(File.dirname(@filename), 'plans')) @config.add_plans(Dir.glob(File.join(directory, '**', "*{#{supported_extensions}}"))) end |
#project_root(root = File.dirname(@filename)) ⇒ Object Also known as: at_project_root
With no arguments, specifies that the current directory containing this masterplan is at the root of your project. Otherwise, specifies the root of the project.
147 148 149 |
# File 'lib/cli/mastermind/configuration.rb', line 147 def project_root(root = File.dirname(@filename)) @config.project_root = root end |
#see_also(filename) ⇒ Object
Specifies that another masterplan should also be loaded when loading this masterplan. NOTE: This immediately loads the other masterplan.
140 141 142 |
# File 'lib/cli/mastermind/configuration.rb', line 140 def see_also(filename) @config.load_masterplan(filename) end |