Class: CabbageDoc::Task
- Inherits:
-
Rake::TaskLib
- Object
- Rake::TaskLib
- CabbageDoc::Task
- Defined in:
- lib/cabbage_doc/task.rb
Instance Attribute Summary collapse
-
#name ⇒ Object
Returns the value of attribute name.
-
#processors ⇒ Object
Returns the value of attribute processors.
Class Method Summary collapse
Instance Method Summary collapse
- #define! ⇒ Object
-
#initialize ⇒ Task
constructor
A new instance of Task.
- #sort! ⇒ Object
- #validate! ⇒ Object
Constructor Details
#initialize ⇒ Task
Returns a new instance of Task.
17 18 19 20 |
# File 'lib/cabbage_doc/task.rb', line 17 def initialize @processors = [:documentation] @name = :cabbagedoc end |
Instance Attribute Details
#name ⇒ Object
Returns the value of attribute name.
6 7 8 |
# File 'lib/cabbage_doc/task.rb', line 6 def name @name end |
#processors ⇒ Object
Returns the value of attribute processors.
6 7 8 |
# File 'lib/cabbage_doc/task.rb', line 6 def processors @processors end |
Class Method Details
.define ⇒ Object
8 9 10 11 12 13 14 15 |
# File 'lib/cabbage_doc/task.rb', line 8 def self.define new.tap do |instance| yield instance if block_given? instance.validate! instance.sort! instance.define! end end |
Instance Method Details
#define! ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/cabbage_doc/task.rb', line 26 def define! namespace name do processors.each do |processor| desc "Process #{processor}" namespace :process do task processor.to_s => :environment do Processor.all[processor].new.perform end end end desc "Customize Web UI" task :customize => :environment do Customizer.new.perform end end desc "Run all processors" task name => :environment do processors.each do |name| Processor.all[name].new.perform end end end |
#sort! ⇒ Object
22 23 24 |
# File 'lib/cabbage_doc/task.rb', line 22 def sort! processors.sort! { |processor| Processor::PRIORITIES.index(Processor.all[processor].priority) } end |
#validate! ⇒ Object
51 52 53 54 55 56 57 58 |
# File 'lib/cabbage_doc/task.rb', line 51 def validate! fail "Invalid 'name'" unless name.is_a?(Symbol) fail "No 'processors' configured" unless processors.any? processors.each do |processor| fail "Invalid 'processor' #{processor}" unless Processor.all.has_key?(processor) end end |