Class: Treebis::Task

Inherits:
Object
  • Object
show all
Defined in:
lib/treebis.rb

Defined Under Namespace

Classes: RunContext

Instance Method Summary collapse

Constructor Details

#initialize(name = nil, &block) ⇒ Task

Returns a new instance of Task.



565
566
567
568
569
570
571
# File 'lib/treebis.rb', line 565

def initialize name=nil, &block
  @block = block
  @file_utils = nil
  @from = nil
  @name = name
  @ui_stack = []
end

Instance Method Details

#erb_values(hash) ⇒ Object



572
573
574
575
# File 'lib/treebis.rb', line 572

def erb_values hash
  @erb_values = hash
  self
end

#erb_values_bindingObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



577
578
579
580
581
582
583
584
585
586
587
588
589
590
# File 'lib/treebis.rb', line 577

def erb_values_binding
  @erb_values_binding ||= begin
    obj = Object.new
    bnd = obj.send(:binding)
    sing = class << obj; self end
    sing2 = class << bnd; self end
    hash = @erb_values or fail("need @erb_values")
    ks = hash.keys
    sing2.send(:define_method, :keys){ ks }
    sing2.send(:define_method, :inspect){'#<TreebisErbBinding>'}
    ks.each{ |k| sing.send(:define_method, k){ hash[k] } }
    bnd
  end
end

#file_utilsObject



591
592
593
# File 'lib/treebis.rb', line 591

def file_utils
  @file_utils ||= Config.new_default_file_utils_proxy
end

#file_utils=(mixed) ⇒ Object



594
595
596
# File 'lib/treebis.rb', line 594

def file_utils= mixed
  @file_utils = mixed
end

#from(path) ⇒ Object



597
598
599
# File 'lib/treebis.rb', line 597

def from path
  @from = path
end

#on(path) ⇒ Object



600
601
602
# File 'lib/treebis.rb', line 600

def on path
  RunContext.new(self, @block, @from, path, file_utils)
end

#ui_capture(&block) ⇒ Object



603
604
605
606
607
# File 'lib/treebis.rb', line 603

def ui_capture &block
  file_utils.ui_push
  instance_eval(&block)
  file_utils.ui_pop
end