jumpstart 0.3.1 → 0.3.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,4 +1,4 @@
1
1
  ---
2
2
  :jumpstart_version_major: 0
3
3
  :jumpstart_version_minor: 3
4
- :jumpstart_version_patch: 1
4
+ :jumpstart_version_patch: 2
@@ -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, files = [], []
305
- Find.find(FileUtils.join_paths(JumpStart.templates_path, template)) do |x|
306
- case
307
- when File.file?(x) && !x.match(/\/jumpstart_config\/*/)
308
- files << x.sub(FileUtils.join_paths(JumpStart.templates_path, template), '')
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
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 3
8
- - 1
9
- version: 0.3.1
8
+ - 2
9
+ version: 0.3.2
10
10
  platform: ruby
11
11
  authors:
12
12
  - Ian Alexander Wood (i0n)