Class: XCBootstrap::Template
- Inherits:
-
Object
- Object
- XCBootstrap::Template
- Defined in:
- lib/xcbootstrap/template.rb
Instance Attribute Summary collapse
-
#from ⇒ Object
Returns the value of attribute from.
-
#to ⇒ Object
Returns the value of attribute to.
Instance Method Summary collapse
-
#initialize(file_info, template_dir, project_dir) ⇒ Template
constructor
A new instance of Template.
- #process ⇒ Object
Constructor Details
#initialize(file_info, template_dir, project_dir) ⇒ Template
Returns a new instance of Template.
9 10 11 12 13 14 15 16 |
# File 'lib/xcbootstrap/template.rb', line 9 def initialize file_info, template_dir, project_dir @template_name = File.basename template_dir @project_name = File.basename project_dir @from = File.join template_dir, file_info["from"] relative_path_to = file_info["to"] || file_info["from"].gsub(@template_name, @project_name) @to = File.join project_dir, relative_path_to end |
Instance Attribute Details
#from ⇒ Object
Returns the value of attribute from.
6 7 8 |
# File 'lib/xcbootstrap/template.rb', line 6 def from @from end |
#to ⇒ Object
Returns the value of attribute to.
7 8 9 |
# File 'lib/xcbootstrap/template.rb', line 7 def to @to end |
Instance Method Details
#process ⇒ Object
18 19 20 21 22 23 24 25 26 |
# File 'lib/xcbootstrap/template.rb', line 18 def process FileUtils.mkdir_p File.dirname(to) if File.binary?(from) || File.image?(from) FileUtils.cp from, to else sed_copy from, to end end |