Class: FsTemplate::Project

Inherits:
Object
  • Object
show all
Includes:
FromHash
Defined in:
lib/fs_template/project.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#pathObject

Returns the value of attribute path.



4
5
6
# File 'lib/fs_template/project.rb', line 4

def path
  @path
end

Instance Method Details

#config_bodyObject



6
7
8
9
10
11
12
13
14
# File 'lib/fs_template/project.rb', line 6

def config_body
  if FileTest.exist?("#{path}/.fstemplate")
    File.read("#{path}/.fstemplate")
  elsif FileTest.exist?("#{path}/.overlay")
    File.read("#{path}/.overlay")
  else
    raise "no config"
  end
end

#overlay_pathsObject



23
24
25
# File 'lib/fs_template/project.rb', line 23

def overlay_paths
  config.overlays + [path]
end

#write_to!(output_path) ⇒ Object



43
44
45
46
47
48
49
50
51
# File 'lib/fs_template/project.rb', line 43

def write_to!(output_path)
  base_files.write_to! output_path
  `rm -rf #{output_path}/.git`

  full_init = 'git init && git config user.email [email protected] && git config user.name "John Smith"'
  ec "cd #{output_path} && #{full_init} && git add . && git commit -m 'Base Files #{config.base}'", :silent => true
  combined_files.write_to!(output_path)
  ec "cd #{output_path} && git add . && git commit -m 'Overlay Files #{path}'", :silent => true
end