Class: Dply::AppConfig
- Inherits:
-
Object
- Object
- Dply::AppConfig
- Includes:
- Logger
- Defined in:
- lib/dply/app_config.rb
Instance Method Summary collapse
-
#initialize ⇒ AppConfig
constructor
A new instance of AppConfig.
- #load_config ⇒ Object
- #run_task(name, optional: false) ⇒ Object
Methods included from Logger
#debug?, #logger, stderr, #stderr
Constructor Details
#initialize ⇒ AppConfig
Returns a new instance of AppConfig.
10 11 12 13 14 15 |
# File 'lib/dply/app_config.rb', line 10 def initialize @tasks = {} @namespace = nil @inside_namespace = false @config_read = false end |
Instance Method Details
#load_config ⇒ Object
31 32 33 34 35 36 37 38 39 40 |
# File 'lib/dply/app_config.rb', line 31 def load_config return if @config_read bundler_setup check_config_exists read_config "drakefile.rb", optional: true Dir["dply/*.rb"].each do |i| read_config i end @config_read = true end |
#run_task(name, optional: false) ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/dply/app_config.rb', line 17 def run_task(name, optional: false) load_config name = name.to_s task_proc = @tasks[name] if task_proc task_dsl = TaskDsl.new(self) task_dsl.instance_eval &task_proc elsif optional logger.warn "task #{name} not found: skipping" else raise Error, "task '#{name}' not defined" end end |