Class: Treebis::Task
- Inherits:
-
Object
- Object
- Treebis::Task
- Defined in:
- lib/treebis.rb
Defined Under Namespace
Classes: RunContext
Instance Attribute Summary collapse
-
#erb_values(hash) ⇒ Object
readonly
Returns the value of attribute erb_values.
Instance Method Summary collapse
- #erb_values_binding ⇒ Object private
- #file_utils ⇒ Object
- #file_utils=(mixed) ⇒ Object
- #from(path) ⇒ Object
-
#initialize(name = nil, &block) ⇒ Task
constructor
A new instance of Task.
- #on(path) ⇒ Object
- #ui_capture(&block) ⇒ Object
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 Attribute Details
#erb_values(hash) ⇒ Object (readonly)
Returns the value of attribute erb_values.
572 573 574 |
# File 'lib/treebis.rb', line 572 def erb_values @erb_values end |
Instance Method Details
#erb_values_binding ⇒ Object
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.
578 579 580 581 582 583 584 585 586 587 588 589 590 591 |
# File 'lib/treebis.rb', line 578 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_utils ⇒ Object
592 593 594 |
# File 'lib/treebis.rb', line 592 def file_utils @file_utils ||= Config.new_default_file_utils_proxy end |
#file_utils=(mixed) ⇒ Object
595 596 597 |
# File 'lib/treebis.rb', line 595 def file_utils= mixed @file_utils = mixed end |
#from(path) ⇒ Object
598 599 600 |
# File 'lib/treebis.rb', line 598 def from path @from = path end |
#on(path) ⇒ Object
601 602 603 |
# File 'lib/treebis.rb', line 601 def on path RunContext.new(self, @block, @from, path, file_utils) end |
#ui_capture(&block) ⇒ Object
604 605 606 607 608 |
# File 'lib/treebis.rb', line 604 def ui_capture &block file_utils.ui_push instance_eval(&block) file_utils.ui_pop end |