jumpstart 0.3.1 → 0.3.2
Sign up to get free protection for your applications and to get access to all the features.
- data/config/jumpstart_version.yml +1 -1
- data/lib/jumpstart/base.rb +7 -20
- metadata +2 -2
data/lib/jumpstart/base.rb
CHANGED
@@ -281,7 +281,6 @@ module JumpStart
|
|
281
281
|
end
|
282
282
|
|
283
283
|
# TODO Write tests for duplicate_template
|
284
|
-
# TODO Look at refactoring this.
|
285
284
|
def duplicate_template(template)
|
286
285
|
input = gets.chomp.strip
|
287
286
|
case
|
@@ -299,29 +298,17 @@ module JumpStart
|
|
299
298
|
puts " The template name ".red + input.red_bold + " begins or ends with an invalid character. Please enter a name that begins with a letter or a number.".red
|
300
299
|
duplicate_template(template)
|
301
300
|
else
|
301
|
+
files_and_dirs = FileUtils.sort_contained_files_and_dirs(FileUtils.join_paths(JumpStart.templates_path, template))
|
302
302
|
FileUtils.mkdir_p(FileUtils.join_paths(JumpStart.templates_path, input, "jumpstart_config"))
|
303
303
|
FileUtils.touch(FileUtils.join_paths(JumpStart.templates_path, input, "jumpstart_config", "#{input}.yml"))
|
304
|
-
dirs
|
305
|
-
|
306
|
-
|
307
|
-
|
308
|
-
|
309
|
-
when File.file?(x) && x.match(/\/jumpstart_config\/*/)
|
310
|
-
FileUtils.copy_file(x, FileUtils.join_paths(JumpStart.templates_path, input, "jumpstart_config", "#{input}.yml") )
|
311
|
-
when File.directory?(x)
|
312
|
-
dirs << x.sub(FileUtils.join_paths(JumpStart.templates_path, template), '')
|
313
|
-
end
|
314
|
-
end
|
315
|
-
dirs.each do |x|
|
316
|
-
unless x.length < 1
|
317
|
-
FileUtils.mkdir_p(FileUtils.join_paths(JumpStart.templates_path, input, x))
|
318
|
-
end
|
319
|
-
end
|
320
|
-
files.each do |x|
|
321
|
-
unless x.length < 0
|
304
|
+
files_and_dirs[:dirs].each {|x| FileUtils.mkdir_p(FileUtils.join_paths(JumpStart.templates_path, input, x))}
|
305
|
+
files_and_dirs[:files].each do |x|
|
306
|
+
if x.match(/\/jumpstart_config\/#{template}\.yml/)
|
307
|
+
FileUtils.copy_file(FileUtils.join_paths(JumpStart.templates_path, template, x), FileUtils.join_paths(JumpStart.templates_path, input, "jumpstart_config", "#{input}.yml") )
|
308
|
+
else
|
322
309
|
FileUtils.cp(FileUtils.join_paths(JumpStart.templates_path, template, x), FileUtils.join_paths(JumpStart.templates_path, input, x))
|
323
310
|
end
|
324
|
-
end
|
311
|
+
end
|
325
312
|
puts "\n Duplication complete!".green_bold
|
326
313
|
puts " Template " + template.green + " has been duplicated to " + input.green
|
327
314
|
jumpstart_menu
|