Class: FsTemplate::Project
- Inherits:
-
Object
- Object
- FsTemplate::Project
- Includes:
- FromHash
- Defined in:
- lib/fs_template/project.rb
Instance Attribute Summary collapse
-
#path ⇒ Object
Returns the value of attribute path.
Instance Method Summary collapse
- #commands(phase) ⇒ Object
- #config_body ⇒ Object
- #git_commit(output_path, message, init = false) ⇒ Object
- #overlay_paths ⇒ Object
- #write_to!(output_path) ⇒ Object
Instance Attribute Details
#path ⇒ Object
Returns the value of attribute path.
4 5 6 |
# File 'lib/fs_template/project.rb', line 4 def path @path end |
Instance Method Details
#commands(phase) ⇒ Object
27 28 29 |
# File 'lib/fs_template/project.rb', line 27 def commands(phase) config.commands.select { |x| x[:phase] == phase }.map { |x| x[:command] } end |
#config_body ⇒ Object
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 |
#git_commit(output_path, message, init = false) ⇒ Object
51 52 53 54 55 56 57 |
# File 'lib/fs_template/project.rb', line 51 def git_commit(output_path,,init=false) if init `rm -rf #{output_path}/.git` ec "cd #{output_path} && git init && git config user.email [email protected] && git config user.name 'John Smith'", :silent => true end ec "cd #{output_path} && git add . && git commit -m '#{}'", :silent => true end |
#overlay_paths ⇒ Object
23 24 25 |
# File 'lib/fs_template/project.rb', line 23 def config. + [path] end |
#write_to!(output_path) ⇒ Object
60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 |
# File 'lib/fs_template/project.rb', line 60 def write_to!(output_path) commands(:before).each do |cmd| FsTemplate.ec "cd #{output_path} && #{cmd}", :silent => true git_commit output_path, "Ran Command: #{cmd}" end base_files.write_to! output_path git_commit output_path, "Base Files #{config.base}", true combined_files.write_to!(output_path) git_commit output_path, "Overlay Files #{path}" commands(:after).each do |cmd| FsTemplate.ec "cd #{output_path} && #{cmd}", :silent => true git_commit output_path, "Ran Command: #{cmd}" end end |