Class: CLI::Mastermind::Configuration::DSL
- Inherits:
-
Object
- Object
- CLI::Mastermind::Configuration::DSL
- Defined in:
- lib/cli/mastermind/configuration.rb
Instance Method Summary collapse
-
#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.
100 101 102 103 104 |
# File 'lib/cli/mastermind/configuration.rb', line 100 def initialize(config, filename) @config = config @filename = filename instance_eval(File.read(filename), filename, 0) if File.exists? filename end |
Instance Method Details
#configure(attribute, value = nil, &block) ⇒ Object
Add arbitrary configuration attributes to the configuration object. Use this to add plan specific configuration options.
134 135 136 137 |
# File 'lib/cli/mastermind/configuration.rb', line 134 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.
128 129 130 |
# File 'lib/cli/mastermind/configuration.rb', line 128 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.
122 123 124 |
# File 'lib/cli/mastermind/configuration.rb', line 122 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.
115 116 117 |
# File 'lib/cli/mastermind/configuration.rb', line 115 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.
108 109 110 |
# File 'lib/cli/mastermind/configuration.rb', line 108 def see_also(filename) @config.load_masterplan(filename) end |