Module: Kamaze::Project::Concern::Tasks
- Included in:
- Kamaze::Project
- Defined in:
- lib/kamaze/project/concern/tasks.rb
Overview
Concern tasks
Stores tasks to enable and provides method to load them.
Tasks are deignated by a string, preprocessing is applied on this strings
before each task
is required. Task prefixd by a @
character are
required without preprocessing, except first char removal.
Instance Method Summary collapse
-
#load_task!(task) ⇒ String
protected
Load task by given name.
-
#tasks ⇒ Array<Symbol>
Get tasks.
-
#tasks=(tasks) ⇒ Array<String>
Set tasks.
-
#tasks_load! ⇒ self
protected
Load tasks.
-
#tasks_ns ⇒ Pathname
protected
Get namespace for default tasks.
Instance Method Details
#load_task!(task) ⇒ String (protected)
Load task by given name
67 68 69 70 71 72 73 |
# File 'lib/kamaze/project/concern/tasks.rb', line 67 def load_task!(task) req = task[0] != '@' ? tasks_ns.join("tasks/#{task}") : task[1..-1] require req req end |
#tasks ⇒ Array<Symbol>
Get tasks
22 23 24 25 26 |
# File 'lib/kamaze/project/concern/tasks.rb', line 22 def tasks @tasks ||= [] @tasks.clone.freeze end |
#tasks=(tasks) ⇒ Array<String>
Set tasks
32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/kamaze/project/concern/tasks.rb', line 32 def tasks=(tasks) @tasks = (@tasks.to_a + tasks.to_a).map(&:to_s).map do |tn| if tn[0] != '@' { ':': '/', '-': '_' }.each do |k, v| tn = tn.tr(k.to_s, v) end end tn.to_s end.map(&:to_sym).uniq end |
#tasks_load! ⇒ self (protected)
Load tasks
Tasks are loaded only when Rake::DSL
is defined.
DSL::Definition
is loaded during tasks loading.
53 54 55 56 57 58 59 60 61 |
# File 'lib/kamaze/project/concern/tasks.rb', line 53 def tasks_load! return self unless Kernel.const_defined?('Rake::DSL') require tasks_ns.join('dsl/setup').to_s tasks.map { |task| load_task!(task) } self end |
#tasks_ns ⇒ Pathname (protected)
Get namespace for default tasks
78 79 80 |
# File 'lib/kamaze/project/concern/tasks.rb', line 78 def tasks_ns Pathname.new('kamaze/project') end |