Class: Sprout::ERBResolver
- Inherits:
-
Rake::FileTask
- Object
- Rake::FileTask
- Sprout::ERBResolver
- Defined in:
- lib/sprout/tasks/erb_resolver.rb
Instance Attribute Summary collapse
-
#template ⇒ Object
Path to the input ERB template.
Class Method Summary collapse
Instance Method Summary collapse
- #define(args) ⇒ Object
-
#execute(args = nil) ⇒ Object
Modified from Rake::Task.execute.
- #execute_erb_task(action, args = nil) ⇒ Object
-
#initialize(name, app) ⇒ ERBResolver
constructor
:nodoc:.
- #output ⇒ Object
- #prepare ⇒ Object
Constructor Details
#initialize(name, app) ⇒ ERBResolver
:nodoc:
30 31 32 33 |
# File 'lib/sprout/tasks/erb_resolver.rb', line 30 def initialize(name, app) # :nodoc: super @context = ERBContext.new end |
Instance Attribute Details
#template ⇒ Object
Path to the input ERB template. This value will default to the value of “##output.erb”
28 29 30 |
# File 'lib/sprout/tasks/erb_resolver.rb', line 28 def template @template end |
Class Method Details
.define_task(*args, &block) ⇒ Object
69 70 71 72 73 74 75 76 |
# File 'lib/sprout/tasks/erb_resolver.rb', line 69 def self.define_task(*args, &block) t = super if(t.is_a?(ERBResolver)) t.define(args) t.prepare end return t end |
Instance Method Details
#define(args) ⇒ Object
35 36 |
# File 'lib/sprout/tasks/erb_resolver.rb', line 35 def define(args) end |
#execute(args = nil) ⇒ Object
Modified from Rake::Task.execute
43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/sprout/tasks/erb_resolver.rb', line 43 def execute(args=nil) args ||= EMPTY_TASK_ARGS if application..dryrun puts "** Execute (dry run) #{name}" return end if application..trace puts "** Execute #{name}" end application.enhance_with_matching_rule(name) if @actions.empty? @actions.each do |action| execute_erb_task(action, args) end end |
#execute_erb_task(action, args = nil) ⇒ Object
58 59 60 61 62 63 64 65 66 67 |
# File 'lib/sprout/tasks/erb_resolver.rb', line 58 def execute_erb_task(action, args=nil) case action.arity when 1 action.call(@context) else action.call(@context, args) end @context.execute(template, output, args) end |
#output ⇒ Object
82 83 84 |
# File 'lib/sprout/tasks/erb_resolver.rb', line 82 def output self.name end |
#prepare ⇒ Object
38 39 40 |
# File 'lib/sprout/tasks/erb_resolver.rb', line 38 def prepare prepare_prerequisites end |