rake-delphi 0.0.17 → 0.0.18

Sign up to get free protection for your applications and to get access to all the features.
@@ -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
- filename = File.basename(file)
65
- @task.out "Zipping #{file}..."
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 != '.'
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Rake
4
4
  module Delphi
5
- VERSION = '0.0.17'
5
+ VERSION = '0.0.18'
6
6
  end
7
7
  end
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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rake-delphi
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.17
4
+ version: 0.0.18
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: