jumpstart 0.1.13 → 0.1.14

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
1
  ---
2
2
  :jumpstart_version_major: 0
3
3
  :jumpstart_version_minor: 1
4
- :jumpstart_version_patch: 13
4
+ :jumpstart_version_patch: 14
@@ -39,14 +39,14 @@ module JumpStart
39
39
 
40
40
  # Look into moving @install_path or refactoring to make setting this variable easier.
41
41
  def set_config_file_options
42
- if @template_name.nil?
42
+ if @template_name.nil? || @template_path.nil?
43
43
  jumpstart_menu
44
- elsif File.exists?(FileUtils.join_paths(JumpStart::Setup.templates_path, @template_name, "/jumpstart_config/", "#{@template_name}.yml"))
45
- @config_file = YAML.load_file(FileUtils.join_paths(JumpStart::Setup.templates_path, @template_name, "/jumpstart_config/", "#{@template_name}.yml"))
44
+ elsif File.exists?(FileUtils.join_paths(@template_path, '/jumpstart_config/',"#{@template_name}.yml"))
45
+ @config_file = YAML.load_file(FileUtils.join_paths(@template_path, "/jumpstart_config/", "#{@template_name}.yml"))
46
46
  @install_command ||= @config_file[:install_command]
47
47
  @install_command_args ||= @config_file[:install_command_args]
48
48
  @replace_strings ||= @config_file[:replace_strings].each {|x| x}
49
- @install_path ||= FileUtils.join_paths(@config_file[:install_path])
49
+ @install_path ||= @config_file[:install_path]
50
50
  else
51
51
  jumpstart_menu
52
52
  end
@@ -230,27 +230,36 @@ module JumpStart::FileTools
230
230
  # If too many or not enough forward slashes are provided at the start/end of the paths, this will be corrected.
231
231
  # Accidentally passing nil values mixed with strings/arrays will be corrected.
232
232
  # Whitespace and line breaks mixed with the path will be corrected.
233
- # If too many files (paths containing one or more '.' fullstops) are specified in the supplied paths, the first one that creates a path will be returned.
234
233
  # If the path is an absolute path (starting with /) this will be preserved.
235
234
  def join_paths(*args)
236
- paths = args.dup
237
- paths.flatten!
235
+ paths = []
238
236
  full_path = []
239
- file_detected = false
240
- absolute_path = true if paths[0].to_s.start_with?('/')
237
+ temp_paths = []
238
+ args.each {|x| temp_paths << x }
239
+ temp_paths.flatten!
240
+ temp_paths.each do |x|
241
+ unless x.nil?
242
+ paths << x.to_s.dup
243
+ end
244
+ end
245
+ if paths[0].start_with?('/')
246
+ absolute_path = true
247
+ else
248
+ absolute_path = false
249
+ end
241
250
  paths.each do |path|
242
251
  unless path.nil?
243
252
  path.strip!
244
253
  path.slice!(0) while path.start_with?('/')
245
254
  path.chop! while path.end_with?('/')
246
- if file_detected == false
247
- file_detected = true if path =~ /\w*\.\w*/
248
- full_path << path
249
- end
255
+ full_path << path
250
256
  end
251
257
  end
252
- full_path[0].insert(0, '/') if absolute_path
253
- full_path.join('/')
258
+ full_path_string = full_path.join('/')
259
+ full_path_string.slice!(0) while full_path_string.start_with?('/')
260
+ full_path_string.chop! while full_path_string.end_with?('/')
261
+ full_path_string.insert(0, '/') if absolute_path == true
262
+ full_path_string
254
263
  end
255
264
 
256
265
  def sort_contained_files_and_dirs(path)
@@ -1154,6 +1154,6 @@ class TestJumpstartBase < Test::Unit::TestCase
1154
1154
  end
1155
1155
 
1156
1156
  end
1157
-
1157
+
1158
1158
  end
1159
1159
  end
@@ -328,21 +328,19 @@ class TestJumpstartFileTools < Test::Unit::TestCase
328
328
  assert_equal "this/array/of/paths/has/far/too/many/forward/slashes.txt", FileUtils.join_paths(a,b,c,d,e,f,g,h,i,j)
329
329
  end
330
330
 
331
- should "return a valid path, even if too many files are specified" do
332
- a,b,c,d,e,f,g,h,i,j,k = 'this/', '//array///', nil, %w[/of/], '/paths/', %w[/has// /far/], nil, '//too/', nil, %w[////many/ /forward// /slashes.txt], "another_file.rb"
333
- assert_equal "this/array/of/paths/has/far/too/many/forward/slashes.txt", FileUtils.join_paths(a,b,c,d,e,f,g,h,i,j,k)
331
+ should "return a valid path, even if path ends with many forward slashes" do
332
+ a,b,c,d,e,f,g,h,i,j,k = 'this/', '//array///', nil, %w[/of/], '/paths/', %w[/has// /far/], nil, '//too/', nil, %w[////many/ /forward// /slashes.txt/////]
333
+ assert_equal "this/array/of/paths/has/far/too/many/forward/slashes.txt", FileUtils.join_paths(a,b,c,d,e,f,g,h,i,j)
334
334
  end
335
335
 
336
- should "return a valid path, even if too many files are specified and the supplied paths contain whitespace and line breaks" do
337
- a,b,c,d,e,f,g,h,i,k = "this/\n", ' //array///', nil, %w[/of/], '/paths/ ', %w[/has// /far/], nil, "//too/\n", nil, "another_file.rb"
338
- j = ["////many/\n", " /forward// ", "\n /slashes.txt\n\n\n"]
339
- assert_equal "this/array/of/paths/has/far/too/many/forward/slashes.txt", FileUtils.join_paths(a,b,c,d,e,f,g,h,i,j,k)
336
+ should "return a valid path, even if the first path is all forward slashes and the supplied paths contain whitespace and line breaks" do
337
+ a,b,c,d,e,f,g,h,i,j,k = "////", ' this/array///', nil, %w[/of/], '/paths/ ', %w[/has// /far/], nil, "//too/\n", nil, ["////many/\n", " /forward// ", "\n /slashes.txt\n\n\n"]
338
+ assert_equal "/this/array/of/paths/has/far/too/many/forward/slashes.txt", FileUtils.join_paths(a,b,c,d,e,f,g,h,i,j,k)
340
339
  end
341
340
 
342
- should "return an absolute path" do
343
- a,b,c,d,e,f,g,h,i,k = "///this/\n", ' //array///', nil, %w[/of/], '/paths/ ', %w[/has// /far/], nil, "//too/\n", nil, "another_file.rb"
344
- j = ["////many/\n", " /forward// ", "\n /slashes.txt\n\n\n"]
345
- assert_equal "/this/array/of/paths/has/far/too/many/forward/slashes.txt", FileUtils.join_paths(a,b,c,d,e,f,g,h,i,j,k)
341
+ should "return an absolute path with symbols included in the values entered." do
342
+ a,b,c,d,e,f,g,h,i,j = "///this/\n", ' //array///', nil, %w[/of/], :paths, %w[/has// /far/], nil, "//too/\n", nil, ["////many/\n", :forward, "\n /slashes.txt\n\n\n"]
343
+ assert_equal "/this/array/of/paths/has/far/too/many/forward/slashes.txt", FileUtils.join_paths(a,b,c,d,e,f,g,h,i,j)
346
344
  end
347
345
 
348
346
  end
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 1
8
- - 13
9
- version: 0.1.13
8
+ - 14
9
+ version: 0.1.14
10
10
  platform: ruby
11
11
  authors:
12
12
  - Ian Alexander Wood (i0n)