Class: XCBootstrap::Template

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

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#fromObject

Returns the value of attribute from.



6
7
8
# File 'lib/xcbootstrap/template.rb', line 6

def from
  @from
end

#toObject

Returns the value of attribute to.



7
8
9
# File 'lib/xcbootstrap/template.rb', line 7

def to
  @to
end

Instance Method Details

#processObject



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