Class: XCBootstrap::Bootstrap

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(template_root, template_name, project_dir) ⇒ Bootstrap

Returns a new instance of Bootstrap.



10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/xcbootstrap/bootstrap.rb', line 10

def initialize template_root, template_name, project_dir
  @template_dir = File.join template_root, template_name
  raise "Invalid template: could not find template directory #{@template_dir}" unless File.directory?(@template_dir)
  
  manifest_file = File.join @template_dir, "manifest.yml"
  raise "Invalid template: could not find template manifest #{manifest_file}" unless File.exists?(manifest_file)
  
  @manifest = YAML.load_file manifest_file
  raise "Invalid template: manifest file did not contain a hash of file mappings #{manifest_file}" unless manifest_data_is_valid(@manifest)
  
  @project_dir = File.expand_path(project_dir, Dir.pwd)
end

Instance Attribute Details

#project_dirObject

Returns the value of attribute project_dir.



8
9
10
# File 'lib/xcbootstrap/bootstrap.rb', line 8

def project_dir
  @project_dir
end

#template_dirObject

Returns the value of attribute template_dir.



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

def template_dir
  @template_dir
end

Instance Method Details

#finishObject



31
32
33
34
# File 'lib/xcbootstrap/bootstrap.rb', line 31

def finish
  print_output_project_files
  print_next_steps
end

#processObject



23
24
25
26
27
28
29
# File 'lib/xcbootstrap/bootstrap.rb', line 23

def process
  FileUtils.mkdir_p project_dir
  
  @manifest["files"].each do |file|
    Template.new(file, @template_dir, @project_dir).process
  end
end