rake-delphi 0.0.17 → 0.0.18
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.
- data/lib/rake/common/ziptask.rb +14 -3
- data/lib/rake/delphi/version.rb +1 -1
- data/test/test-zip.rb +18 -0
- metadata +1 -1
data/lib/rake/common/ziptask.rb
CHANGED
@@ -60,10 +60,21 @@ module Rake
|
|
60
60
|
|
61
61
|
private
|
62
62
|
def zip_addfile(zipfile, file)
|
63
|
+
filename_set = false
|
64
|
+
if file.kind_of?(Hash)
|
65
|
+
filename = file.values.first
|
66
|
+
file = file.keys.first
|
67
|
+
filename_set = true
|
68
|
+
# if directory name given append filename to its path
|
69
|
+
if /\/$/.match(filename)
|
70
|
+
filename += File.basename(file)
|
71
|
+
end
|
72
|
+
else
|
73
|
+
filename = File.basename(file)
|
74
|
+
end
|
63
75
|
return if ! File.exists?(file)
|
64
|
-
|
65
|
-
@
|
66
|
-
if @options[:preserve_paths]
|
76
|
+
@task.out "Zipping '#{file}' as '#{filename}'..."
|
77
|
+
if @options[:preserve_paths] && ! filename_set
|
67
78
|
dir = File.dirname(file)
|
68
79
|
# avoid "./<filename>" entries (instead of "<filename>")
|
69
80
|
filename = File.join(dir, filename) if dir != '.'
|
data/lib/rake/delphi/version.rb
CHANGED
data/test/test-zip.rb
CHANGED
@@ -46,4 +46,22 @@ public
|
|
46
46
|
assert_equal 2, z.entries.length, 'Files in an archive'
|
47
47
|
end
|
48
48
|
end
|
49
|
+
|
50
|
+
def test_add_to_zip_file_customname
|
51
|
+
test_add_to_zip_file
|
52
|
+
Rake::Delphi::ZipTask.new(@rake_task, @zip, [{__FILE__ => 'folder/custom_name'}], { :preserve_paths => true, :add => true })
|
53
|
+
assert(File.exists?(@zip))
|
54
|
+
Zip::ZipFile.open(@zip) do |z|
|
55
|
+
assert_equal 3, z.entries.length, 'Files in an archive'
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
def test_add_to_zip_file_customname_foldername
|
60
|
+
test_add_to_zip_file
|
61
|
+
Rake::Delphi::ZipTask.new(@rake_task, @zip, [{__FILE__ => 'folder/custom_name/'}], { :preserve_paths => true, :add => true })
|
62
|
+
assert(File.exists?(@zip))
|
63
|
+
Zip::ZipFile.open(@zip) do |z|
|
64
|
+
assert_equal 3, z.entries.length, 'Files in an archive'
|
65
|
+
end
|
66
|
+
end
|
49
67
|
end
|