lib/buildr/packaging/zip.rb in vic-buildr-1.3.1 vs lib/buildr/packaging/zip.rb in vic-buildr-1.3.3

- old
+ new

@@ -12,10 +12,11 @@ # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # License for the specific language governing permissions and limitations under # the License. +$LOADED_FEATURES.unshift 'ftools' if RUBY_VERSION >= '1.9.0' require 'zip/zip' require 'zip/zipfilesystem' module Buildr @@ -43,15 +44,15 @@ expand_src.call.each do |path| unless excluded?(path) if File.directory?(path) in_directory path do |file, rel_path| dest = "#{@path}#{rel_path}" - puts "Adding #{dest}" if Buildr.application.options.trace + trace "Adding #{dest}" file_map[dest] = file end else - puts "Adding #{@path}#{File.basename(path)}" if Buildr.application.options.trace + trace "Adding #{@path}#{File.basename(path)}" file_map["#{@path}#{File.basename(path)}"] = path end end end end @@ -148,15 +149,15 @@ if File.directory?(file) in_directory file do |file, rel_path| path = rel_path.split('/')[1..-1] path.unshift as unless as == '.' dest = "#{@path}#{path.join('/')}" - puts "Adding #{dest}" if Buildr.application.options.trace + trace "Adding #{dest}" file_map[dest] = file end else - puts "Adding #{@path}#{as}" if Buildr.application.options.trace + trace "Adding #{@path}#{as}" file_map["#{@path}#{as}"] = file end end end end @@ -216,11 +217,11 @@ Zip::ZipFile.open(@zip_file) do |source| source.entries.reject { |entry| entry.directory? }.each do |entry| if @includes.any? { |pattern| File.fnmatch(pattern, entry.name, File::FNM_PATHNAME) } && !@excludes.any? { |pattern| File.fnmatch(pattern, entry.name, File::FNM_PATHNAME) } dest = path =~ /^\/?$/ ? entry.name : Util.relative_path(path + "/" + entry.name) - puts "Adding #{dest}" if Buildr.application.options.trace + trace "Adding #{dest}" file_map[dest] = lambda { |output| output.write source.read(entry) } end end end end @@ -544,11 +545,11 @@ entries = zip.collect @paths.each do |path, patterns| patterns.map(entries).each do |dest, entry| next if entry.directory? dest = File.expand_path(dest, target.to_s) - puts "Extracting #{dest}" if Buildr.application.options.trace + trace "Extracting #{dest}" mkpath File.dirname(dest), :verbose=>false rescue nil entry.extract(dest) { true } end end end @@ -651,13 +652,15 @@ def map(entries) includes = @include || ['**/*'] excludes = @exclude || [] entries.inject({}) do |map, entry| - short = entry.name.sub(@path, '') - if includes.any? { |pat| File.fnmatch(pat, short, File::FNM_PATHNAME) } && - !excludes.any? { |pat| File.fnmatch(pat, short, File::FNM_PATHNAME) } - map[short] = entry + if entry.name =~ /^#{@path}/ + short = entry.name.sub(@path, '') + if includes.any? { |pat| File.fnmatch(pat, short, File::FNM_PATHNAME) } && + !excludes.any? { |pat| File.fnmatch(pat, short, File::FNM_PATHNAME) } + map[short] = entry + end end map end end