jumpstart 0.1.13 → 0.1.14
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 +4 -4
- data/lib/jumpstart/filetools.rb +20 -11
- data/test/jumpstart/test_base.rb +1 -1
- data/test/jumpstart/test_filetools.rb +9 -11
- metadata +2 -2
data/lib/jumpstart/base.rb
CHANGED
@@ -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(
|
45
|
-
@config_file = YAML.load_file(FileUtils.join_paths(
|
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 ||=
|
49
|
+
@install_path ||= @config_file[:install_path]
|
50
50
|
else
|
51
51
|
jumpstart_menu
|
52
52
|
end
|
data/lib/jumpstart/filetools.rb
CHANGED
@@ -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 =
|
237
|
-
paths.flatten!
|
235
|
+
paths = []
|
238
236
|
full_path = []
|
239
|
-
|
240
|
-
|
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
|
-
|
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
|
253
|
-
|
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)
|
data/test/jumpstart/test_base.rb
CHANGED
@@ -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
|
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
|
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
|
337
|
-
a,b,c,d,e,f,g,h,i,k = "
|
338
|
-
|
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,
|
344
|
-
|
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
|