Permalink
Browse files

Get rid of String#ensure_end

  • Loading branch information...
byroot committed Feb 1, 2012
1 parent a92b601 commit dc159646e6076b80d4b750f585b0fc4e4ca2fc78
Showing with 6 additions and 30 deletions.
  1. +0 −4 lib/zip/stdrubyext.rb
  2. +3 −1 lib/zip/zip_file.rb
  3. +3 −2 lib/zip/zipfilesystem.rb
  4. +0 −1 test/alltests.rb
  5. +0 −22 test/stdrubyexttest.rb
View
@@ -1,9 +1,5 @@
class String #:nodoc:all
def ensure_end(aString)
end_with?(aString) ? self : self + aString
end
def lchop
slice(1, length)
end
View
@@ -258,7 +258,9 @@ def mkdir(entryName, permissionInt = 0755)
if find_entry(entryName)
raise Errno::EEXIST, "File exists - #{entryName}"
end
@entrySet << ZipStreamableDirectory.new(@name, entryName.to_s.ensure_end("/"), nil, permissionInt)
entryName = entryName.to_s
entryName << '/' unless entryName.end_with?('/')
@entrySet << ZipStreamableDirectory.new(@name, entryName, nil, permissionInt)
end
private
View
@@ -471,7 +471,8 @@ def foreach(aDirectoryName)
unless @file.stat(aDirectoryName).directory?
raise Errno::ENOTDIR, aDirectoryName
end
path = @file.expand_path(aDirectoryName).ensure_end("/")
path = @file.expand_path(aDirectoryName)
path << '/' unless path.end_with?('/')
path = Regexp.escape(path)
subDirEntriesRegex = Regexp.new("^#{path}([^/]+)$")
@mappedZip.each {
@@ -593,7 +594,7 @@ def each
end
def expand_path(aPath)
expanded = aPath.start_with?("/") ? aPath : @pwd.ensure_end("/") + aPath
expanded = aPath.start_with?("/") ? aPath : ::File.join(@pwd, aPath)
expanded.gsub!(/\/\.(\/|$)/, "")
expanded.gsub!(/[^\/]+\/\.\.(\/|$)/, "")
expanded.empty? ? "/" : expanded
View
@@ -2,7 +2,6 @@
$VERBOSE = true
require 'stdrubyexttest'
require 'ioextrastest'
require 'ziptest'
require 'zipfilesystemtest'
View

This file was deleted.

Oops, something went wrong.

0 comments on commit dc15964

Please sign in to comment.