15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
|
# File 'lib/sanctuary/generator.rb', line 15
def create_lib_file
if type == 'recipe'
File.open(Sanctuary::HOME_DIR.gsub("templates", "recipes/") + template) do |file|
file.each do |line|
copy_file "#{line.gsub("||", "/").chomp}", "#{line.split("||")[1..-1].join("/").chomp}"
end
end
if Dir.entries(".").include?('sanctuary-post-recipe-copy-hook.sh')
system "sh ./sanctuary-post-recipe-copy-hook.sh"
end
elsif type == 'script'
if name.nil?
system "sh #{Sanctuary::HOME_DIR.gsub("templates", "scripts/")}#{template}"
else
system "sh #{Sanctuary::HOME_DIR.gsub("templates", "scripts/")}#{template} #{name}"
end
else
if name.empty?
copy_file "#{template}", "#{template.split("/").last}"
else
copy_file "#{template}", "#{name + "." + template.split("/").last.split(".").last}"
gsub_file "#{name + "." + template.split("/").last.split(".").last}", "#name", name
end
end
end
|