8000 Add configs of rubocop gem and fix some rubocop warnings by ShockwaveNN · Pull Request #226 · rubyzip/rubyzip · GitHub
[go: up one dir, main page]

Skip to content

Add configs of rubocop gem and fix some rubocop warnings #226

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 107 commits into from
Jun 8, 2015
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
107 commits
Select commit Hold shift + click to select a range
715f064
add rubocop configs
ShockwaveNN Mar 20, 2015
7c4fed2
fix name of file
ShockwaveNN Mar 20, 2015
fc8e042
fix rubocop Style/WordArray warning
ShockwaveNN Mar 20, 2015
7a8a8b6
fix rubocop Style/WhileUntilModifier warning
ShockwaveNN Mar 20, 2015
f507a01
rename .rubocop.yml .rubocop_rubyzip.yml
ShockwaveNN Mar 20, 2015
b7cda26
fix rubocop Style/WhileUntilDo сщз
ShockwaveNN Mar 20, 2015
c677730
fix rubocop Style/UnneededPercentQ cop
ShockwaveNN Mar 20, 2015
6fac8c7
fix rubocop Style/TrailingWhitespace cop
ShockwaveNN Mar 20, 2015
7dcba79
fix rubocop Style/TrailingComma cop
ShockwaveNN Mar 20, 2015
c45a639
fix rubocop Style/TrailingBlankLines cop
ShockwaveNN Mar 20, 2015
5d47830
fix rubocop Style/Tab cop
ShockwaveNN Mar 20, 2015
d928aee
make parse_zip64_extra check for empty @extra['Zip64'] easier to read
ShockwaveNN Mar 20, 2015
6d19df4
fix rubocop Lint/AssignmentInCondition cop
ShockwaveNN Mar 20, 2015
52623a4
fix rubocop Lint/DeprecatedClassMethods cop
ShockwaveNN Mar 20, 2015
67838e1
fix rubocop Lint/EndAlignment cop
ShockwaveNN Mar 20, 2015
bfc8b3c
fix rubocop Lint/ShadowingOuterLocalVariable cop
ShockwaveNN Mar 20, 2015
eae8112
fix rubocop Lint/StringConversionInInterpolation cop
ShockwaveNN Mar 20, 2015
d3e911f
fix rubocop Lint/UnusedBlockArgument cop
ShockwaveNN Mar 20, 2015
4ee6d6b
fix rubocop Lint/UnusedMethodArgument cop
ShockwaveNN Mar 20, 2015
7ef15bd
fix rubocop Lint/UselessAssignment cop
ShockwaveNN Mar 20, 2015
bb08213
fix rubocop Style/Alias cop
ShockwaveNN Mar 20, 2015
f401fff
fix rubocop Style/AlignArray cop
ShockwaveNN Mar 20, 2015
98e6b5d
fix rubocop Style/AlignParameters cop
ShockwaveNN Mar 21, 2015
a2afbaf
fix rubocop Style/AndOr cop
ShockwaveNN Mar 21, 2015
0c6a10e
fix rubocop Style/AndOr cop
ShockwaveNN Mar 21, 2015
d2d8590
fix rubocop Style/Blocks cop
ShockwaveNN Mar 21, 2015
a0da550
fix rubocop Style/CaseIndentation cop
ShockwaveNN Mar 21, 2015
6c46c21
fix rubocop Style/ColonMethodCall cop
ShockwaveNN Mar 21, 2015
0aa70b8
fix rubocop Style/DefWithParentheses cop
ShockwaveNN Mar 21, 2015
d0c8e8d
fix rubocop Style/EmptyLines cop
ShockwaveNN Mar 21, 2015
eba5fa1
fix rubocop Style/EmptyLinesAroundAccessModifier cop
ShockwaveNN Mar 21, 2015
b1c0dc2
fix rubocop Style/EmptyLinesAroundBlockBody cop
ShockwaveNN Mar 21, 2015
b9a757e
fix rubocop Style/EmptyLinesAroundClassBody cop
ShockwaveNN Mar 21, 2015
2ac8086
fix rubocop Style/EmptyLinesAroundMethodBody cop
ShockwaveNN Mar 21, 2015
f67cf18
fix rubocop Style/EmptyLinesAroundModuleBody cop
ShockwaveNN Mar 21, 2015
f0dc815
fix rubocop Style/EndOfLine cop
ShockwaveNN Mar 21, 2015
70dd0d0
fix rubocop Style/IndentArray cop
ShockwaveNN Mar 21, 2015
b93ef12
fix rubocop Style/StringLiterals cop
ShockwaveNN Mar 21, 2015
3efd167
Merge pull request #1 from rubyzip/master
ShockwaveNN Mar 21, 2015
da863e4
Merge branch 'master' into rubocop_fixes
ShockwaveNN Mar 21, 2015
b730387
redone fixes by rubocop Style/Alias to be in style of https://github.…
ShockwaveNN Mar 21, 2015
e0d5617
update .rubocop_rubyzip.yml after all previous changes
ShockwaveNN Mar 22, 2015
7624740
fix rubocop Style/IndentationWidth cop
ShockwaveNN Mar 22, 2015
06e5a93
fix rubocop Style/ParenthesesAroundCondition cop
ShockwaveNN Mar 22, 2015
225a4f7
fix rubocop Style/RedundantReturn cop
ShockwaveNN Mar 22, 2015
abf9cbe
fix rubocop Style/RedundantSelf cop
ShockwaveNN Mar 22, 2015
105c2c7
fix rubocop Style/RedundantException cop
ShockwaveNN Mar 22, 2015
735a055
fix rubocop Style/RedundantBegin cop
ShockwaveNN Mar 22, 2015
707bd44
fix rubocop Style/SingleLineMethods cop
ShockwaveNN Mar 22, 2015
d2b4a52
fix rubocop Style/SpaceAfterComma cop
ShockwaveNN Mar 22, 2015
73e5f70
fix rubocop Style/SpaceAfterMethodName cop
ShockwaveNN Mar 22, 2015
77ef05c
fix rubocop Style/SpaceAfterNot cop
ShockwaveNN Mar 22, 2015
cb143f0
fix rubocop Style/SpaceAroundEqualsInParameterDefault cop
ShockwaveNN Mar 22, 2015
b311998
fix rubocop Style/SpaceInsideBlockBraces cop
ShockwaveNN Mar 22, 2015
2c7a990
fix rubocop Style/TrailingWhitespace cop
ShockwaveNN Mar 22, 2015
b13fafb
fix rubocop Style/StringLiterals cop
ShockwaveNN Mar 22, 2015
d92d8d6
fix rubocop Style/SpaceInsideParens cop
ShockwaveNN Mar 22, 2015
987dbf1
fix rubocop Style/SpaceInsideBrackets cop
ShockwaveNN Mar 22, 2015
5ea5710
fix rubocop Style/SpaceBeforeBlockBraces cop
ShockwaveNN Mar 22, 2015
8d6f23b
fix rubocop Style/SpaceAroundOperators cop
ShockwaveNN Mar 22, 2015
7eb06a1
fix some rubocop Style/Semicolon cop
ShockwaveNN Mar 22, 2015
edf3126
EntrySet.dub fix for code-style
ShockwaveNN Mar 23, 2015
d5f7982
fix rubocop Style/LineEndConcatenation cop
ShockwaveNN Mar 23, 2015
b6f9176
fix rubocop Style/Lambda cop
ShockwaveNN Mar 23, 2015
47b72f5
fix rubocop Style/LeadingCommentSpace cop
ShockwaveNN Mar 23, 2015
930b5ae
fix rubocop Style/MethodCallParentheses cop
ShockwaveNN Mar 23, 2015
04f6902
fix rubocop Style/MultilineBlockLayout cop
ShockwaveNN Mar 23, 2015
6a7a22f
fix rubocop Style/MultilineOperationIndentation cop
ShockwaveNN Mar 23, 2015
f291e1f
fix rubocop Style/NegatedIf cop
ShockwaveNN Mar 23, 2015
31fb9d7
fix rubocop Style/PredicateName cop
ShockwaveNN Mar 23, 2015
77b7d6c
fix rubocop Style/PercentLiteralDelimiters cop
ShockwaveNN Mar 23, 2015
1ba81ff
fix rubocop Style/NumericLiterals cop
ShockwaveNN Mar 23, 2015
8533708
fix rubocop Style/Not cop
ShockwaveNN Mar 23, 2015
abb8c02
fix rubocop Style/Next cop
ShockwaveNN Mar 23, 2015
d6cc880
fix rubocop Style/MultilineTernaryOperator cop
ShockwaveNN Mar 23, 2015
b1bfb1a
fix some rubocop Style/ModuleFunction cop
ShockwaveNN Mar 23, 2015
23cfcc7
fix rubocop Style/MethodName cop
ShockwaveNN Mar 24, 2015
2c8f6f8
fix correct initialization for ExtraField
ShockwaveNN Mar 24, 2015
b9aefaf
fix rubocop Style/IfUnlessModifier cop
ShockwaveNN Mar 24, 2015
63b3ee3
fix rubocop Style/HashSyntax cop
ShockwaveNN Mar 24, 2015
b920a1e
fix rubocop Style/GuardClause cop
ShockwaveNN Mar 24, 2015
112a77d
fix some Style/FormatString cop
ShockwaveNN Mar 24, 2015
68b5fcf
fix some Style/FormatString cop
ShockwaveNN Mar 24, 2015
068a3e7
fix rubocop Style/FileName cop
ShockwaveNN Mar 24, 2015
f6693af
fix rubocop Style/EmptyLinesAroundMethodBody cop
ShockwaveNN Mar 24, 2015
94c1df1
fix rubocop Style/EmptyLinesAroundAccessModifier cop
ShockwaveNN Mar 24, 2015
4b60095
fix rubocop Style/EmptyLines cop
ShockwaveNN Mar 24, 2015
784e70b
fix rubocop Style/EmptyElse cop
ShockwaveNN Mar 24, 2015
ce7e01a
fix rubocop Style/CommentIndentation cop
ShockwaveNN Mar 24, 2015
96f3997
fix rubocop Style/GuardClause cop
ShockwaveNN Mar 24, 2015
1759f71
fix rubocop Style/CommentAnnotation cop
ShockwaveNN Mar 24, 2015
aa83776
fix rubocop Style/ClassMethods cop
ShockwaveNN Mar 24, 2015
fd864bd
fix rubocop Style/CaseEquality cop
ShockwaveNN Mar 24, 2015
2007be0
fix rubocop Lint/UselessAccessModifier cop
ShockwaveNN Mar 24, 2015
e211434
fix rubocop Lint/UnusedBlockArgument cop
ShockwaveNN Mar 24, 2015
63d388c
Merge pull request #2 from rubyzip/master
ShockwaveNN Jun 8, 2015
c0177a4
Merge branch 'master' into rubocop_fixes
ShockwaveNN Jun 8, 2015
53fba8a
fix after merge fix
ShockwaveNN Jun 8, 2015
47aa16f
update .rubocop_rubyzip for latest version of rubocop
ShockwaveNN Jun 8, 2015
68181da
fix rubocop cop Style/TrailingBlankLines
ShockwaveNN Jun 8, 2015
f7eec2d
fix rubocop cop Style/SpaceAroundOperators
ShockwaveNN Jun 8, 2015
37ede3c
fix rubocop cop Style/SingleSpaceBeforeFirstArg
ShockwaveNN Jun 8, 2015
13658b0
fix rubocop cop Style/NonNilCheck
ShockwaveNN Jun 8, 2015
4c81b11
fix rubocop cop Style/NilComparison
ShockwaveNN Jun 8, 2015
753eab1
fix rubocop cop Style/EmptyLinesAroundClassBody
ShockwaveNN Jun 8, 2015
8c13dfc
fix rubocop cop Style/ClassCheck
ShockwaveNN Jun 8, 2015
1e99ff6
Revert "fix rubocop cop Style/ClassCheck". It cause regression in tests
ShockwaveNN Jun 8, 2015
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix rubocop Style/StringLiterals cop
  • Loading branch information
ShockwaveNN committed Mar 21, 2015
commit b93ef1266f3e974a81b06c558bf94c2c70e16d05
6 changes: 0 additions & 6 deletions .rubocop_rubyzip.yml
Original file line number Diff line number Diff line change
Expand Up @@ -340,12 +340,6 @@ Style/SpaceInsideParens:
Style/SpecialGlobalVars:
Enabled: false

# Offense count: 1005
# Cop supports --auto-correct.
# Configuration parameters: EnforcedStyle, SupportedStyles.
Style/StringLiterals:
Enabled: false

# Offense count: 22
# Cop supports --auto-correct.
# Configuration parameters: IgnoredMethods.
Expand Down
12 changes: 6 additions & 6 deletions lib/zip/central_directory.rb
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ def read_64_e_o_c_d(buf) #:nodoc:
@size_in_bytes = Entry.read_zip_64_long(buf)
@cdir_offset = Entry.read_zip_64_long(buf)
@zip_64_extensible = buf.slice!(0, buf.bytesize)
raise Error, "Zip consistency problem while reading eocd structure" unless buf.size == 0
raise Error, 'Zip consistency problem while reading eocd structure' unless buf.size == 0
end

def read_e_o_c_d(buf) #:nodoc:
Expand All @@ -113,14 +113,14 @@ def read_e_o_c_d(buf) #:nodoc:
else
buf.read(comment_length)
end
raise Error, "Zip consistency problem while reading eocd structure" unless buf.size == 0
raise Error, 'Zip consistency problem while reading eocd structure' unless buf.size == 0
end

def read_central_directory_entries(io) #:nodoc:
begin
io.seek(@cdir_offset, IO::SEEK_SET)
rescue Errno::EINVAL
raise Error, "Zip consistency problem while reading central directory entry"
raise Error, 'Zip consistency problem while reading central directory entry'
end
@entry_set = EntrySet.new
@size.times do
Expand All @@ -140,7 +140,7 @@ def read_from_stream(io) #:nodoc:

def get_e_o_c_d(buf) #:nodoc:
sig_index = buf.rindex([END_OF_CDS].pack('V'))
raise Error, "Zip end of central directory signature not found" unless sig_index
raise Error, 'Zip end of central directory signature not found' unless sig_index
buf = buf.slice!((sig_index + 4)..(buf.bytesize))

def buf.read(count)
Expand All @@ -165,9 +165,9 @@ def start_buf(io)

def get_64_e_o_c_d(buf) #:nodoc:
zip_64_start = buf.rindex([ZIP64_END_OF_CDS].pack('V'))
raise Error, "Zip64 end of central directory signature not found" unless zip_64_start
raise Error, 'Zip64 end of central directory signature not found' unless zip_64_start
zip_64_locator = buf.rindex([ZIP64_EOCD_LOCATOR].pack('V'))
raise Error, "Zip64 end of central directory signature locator not found" unless zip_64_locator
raise Error, 'Zip64 end of central directory signature locator not found' unless zip_64_locator
buf = buf.slice!((zip_64_start + 4)..zip_64_locator)

def buf.read(count)
Expand Down
8 changes: 4 additions & 4 deletions lib/zip/crypto/traditional_encryption.rb
Original file line number Diff line number Diff line change
Expand Up @@ -46,15 +46,15 @@ def header(mtime)
end
header << (mtime.to_binary_dos_time & 0xff)
header << (mtime.to_binary_dos_time >> 8)
end.map{|x| encode x}.pack("C*")
end.map{|x| encode x}.pack('C*')
end

def encrypt(data)
data.unpack("C*").map{|x| encode x}.pack("C*")
data.unpack('C*').map{|x| encode x}.pack('C*')
end

def data_descriptor(crc32, compressed_size, uncomprssed_size)
[0x08074b50, crc32, compressed_size, uncomprssed_size].pack("VVVV")
[0x08074b50, crc32, compressed_size, uncomprssed_size].pack('VVVV')
end

def reset!
Expand All @@ -74,7 +74,7 @@ class TraditionalDecrypter < Decrypter
include TraditionalEncryption

def decrypt(data)
data.unpack("C*").map{|x| decode x}.pack("C*")
data.unpack('C*').map{|x| decode x}.pack('C*')
end

def reset!(header)
Expand Down
18 changes: 9 additions & 9 deletions lib/zip/entry.rb
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ def read_local_entry(io) #:nodoc:all
static_sized_fields_buf = io.read(::Zip::LOCAL_ENTRY_STATIC_HEADER_LENGTH) || ''

unless static_sized_fields_buf.bytesize == ::Zip::LOCAL_ENTRY_STATIC_HEADER_LENGTH
raise Error, "Premature end of file. Not enough data for zip entry local header"
raise Error, 'Premature end of file. Not enough data for zip entry local header'
end

unpack_local_entry(static_sized_fields_buf)
Expand All @@ -239,7 +239,7 @@ def read_local_entry(io) #:nodoc:all
@name.gsub!('\\', '/')

if extra && extra.bytesize != @extra_length
raise ::Zip::Error, "Truncated local zip entry header"
raise ::Zip::Error, 'Truncated local zip entry header'
else
if ::Zip::ExtraField === @extra
@extra.merge(extra)
Expand Down Expand Up @@ -345,7 +345,7 @@ def check_c_dir_entry_signature

def check_c_dir_entry_comment_size
unless @comment && @comment.bytesize == @comment_length
raise ::Zip::Error, "Truncated cdir zip entry header"
raise ::Zip::Error, 'Truncated cdir zip entry header'
end
end

Expand Down Expand Up @@ -557,7 +557,7 @@ def get_raw_input_stream(&block)
if @zipfile.is_a?(::IO) || @zipfile.is_a?(::StringIO)
yield @zipfile
else
::File.open(@zipfile, "rb", &block)
::File.open(@zipfile, 'rb', &block)
end
end

Expand All @@ -570,15 +570,15 @@ def clean_up
def set_time(binary_dos_date, binary_dos_time)
@time = ::Zip::DOSTime.parse_binary_dos_format(binary_dos_date, binary_dos_time)
rescue ArgumentError
puts "Invalid date/time in zip entry" if ::Zip.warn_invalid_date
puts 'Invalid date/time in zip entry' if ::Zip.warn_invalid_date
end

def create_file(dest_path, _continue_on_exists_proc = proc { Zip.continue_on_exists_proc })
if ::File.exist?(dest_path) && !yield(self, dest_path)
raise ::Zip::DestinationFileExistsError,
"Destination '#{dest_path}' already exists"
end
::File.open(dest_path, "wb") do |os|
::File.open(dest_path, 'wb') do |os|
get_input_stream do |is|
set_extra_attributes_on_path(dest_path)

Expand All @@ -598,7 +598,7 @@ def create_directory(dest_path)
else
raise ::Zip::DestinationFileExistsError,
"Cannot create directory '#{dest_path}'. "+
"A file already exists with that name"
'A file already exists with that name'
end
end
::FileUtils.mkdir_p(dest_path)
Expand All @@ -623,12 +623,12 @@ def create_symlink(dest_path)
else
raise ::Zip::DestinationFileExistsError,
"Cannot create symlink '#{dest_path}'. "+
"A symlink already exists with that name"
'A symlink already exists with that name'
end
else
raise ::Zip::DestinationFileExistsError,
"Cannot create symlink '#{dest_path}'. "+
"A file already exists with that name"
'A file already exists with that name'
end
end

Expand Down
10 changes: 5 additions & 5 deletions lib/zip/extra_field/generic.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ def self.register_map
end

def self.name
@name ||= self.to_s.split("::")[-1]
@name ||= self.to_s.split('::')[-1]
end

# return field [size, content] or false
Expand All @@ -16,10 +16,10 @@ def initial_parse(binstr)
# If nil, start with empty.
return false
elsif binstr[0, 2] != self.class.const_get(:HEADER_ID)
$stderr.puts "Warning: weired extra feild header ID. skip parsing"
$stderr.puts 'Warning: weired extra feild header ID. skip parsing'
return false
end
[binstr[2, 2].unpack("v")[0], binstr[4..-1]]
[binstr[2, 2].unpack('v')[0], binstr[4..-1]]
end

def ==(other)
Expand All @@ -32,12 +32,12 @@ def ==(other)

def to_local_bin
s = pack_for_local
self.class.const_get(:HEADER_ID) + [s.bytesize].pack("v") << s
self.class.const_get(:HEADER_ID) + [s.bytesize].pack('v') << s
end

def to_c_dir_bin
s = pack_for_c_dir
self.class.const_get(:HEADER_ID) + [s.bytesize].pack("v") << s
self.class.const_get(:HEADER_ID) + [s.bytesize].pack('v') << s
end
end
end
4 changes: 2 additions & 2 deletions lib/zip/extra_field/ntfs.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def merge(binstr)

tag1 = tags[1]
if tag1
ntfs_mtime, ntfs_atime, ntfs_ctime = tag1.unpack("Q<Q<Q<")
ntfs_mtime, ntfs_atime, ntfs_ctime = tag1.unpack('Q<Q<Q<')
ntfs_mtime && @mtime ||= from_ntfs_time(ntfs_mtime)
ntfs_atime && @atime ||= from_ntfs_time(ntfs_atime)
ntfs_ctime && @ctime ||= from_ntfs_time(ntfs_ctime)
Expand All @@ -48,7 +48,7 @@ def pack_for_local
# But 7-zip for Windows only stores at central dir
def pack_for_c_dir
# reserved 0 and tag 1
s = [0, 1].pack("Vv")
s = [0, 1].pack('Vv')

tag1 = ''.force_encoding(Encoding::BINARY)
if @mtime
Expand Down
8 changes: 4 additions & 4 deletions lib/zip/extra_field/old_unix.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
module Zip
# Olf Info-ZIP Extra for UNIX uid/gid and file timestampes
class ExtraField::OldUnix < ExtraField::Generic
HEADER_ID = "UX"
HEADER_ID = 'UX'
register_map

def initialize(binstr = nil)
Expand All @@ -19,7 +19,7 @@ def merge(binstr)
size, content = initial_parse(binstr)
# size: 0 for central directory. 4 for local header
return if (!size || size == 0)
atime, mtime, uid, gid = content.unpack("VVvv")
atime, mtime, uid, gid = content.unpack('VVvv')
@uid ||= uid
@gid ||= gid
@atime ||= atime
Expand All @@ -34,11 +34,11 @@ def ==(other)
end

def pack_for_local
[@atime, @mtime, @uid, @gid].pack("VVvv")
[@atime, @mtime, @uid, @gid].pack('VVvv')
end

def pack_for_c_dir
[@atime, @mtime].pack("VV")
[@atime, @mtime].pack('VV')
end
end
end
16 changes: 8 additions & 8 deletions lib/zip/extra_field/universal_time.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
module Zip
# Info-ZIP Additional timestamp field
class ExtraField::UniversalTime < ExtraField::Generic
HEADER_ID = "UT"
HEADER_ID = 'UT'
register_map

def initialize(binstr = nil)
Expand All @@ -18,7 +18,7 @@ def merge(binstr)
return if binstr.empty?
size, content = initial_parse(binstr)
size || return
@flag, mtime, atime, ctime = content.unpack("CVVV")
@flag, mtime, atime, ctime = content.unpack('CVVV')
mtime && @mtime ||= ::Zip::DOSTime.at(mtime)
atime && @atime ||= ::Zip::DOSTime.at(atime)
ctime && @ctime ||= ::Zip::DOSTime.at(ctime)
Expand All @@ -31,16 +31,16 @@ def ==(other)
end

def pack_for_local
s = [@flag].pack("C")
@flag & 1 != 0 && s << [@mtime.to_i].pack("V")
@flag & 2 != 0 && s << [@atime.to_i].pack("V")
@flag & 4 != 0 && s << [@ctime.to_i].pack("V")
s = [@flag].pack('C')
@flag & 1 != 0 && s << [@mtime.to_i].pack('V')
@flag & 2 != 0 && s << [@atime.to_i].pack('V')
@flag & 4 != 0 && s << [@ctime.to_i].pack('V')
s
end

def pack_for_c_dir
s = [@flag].pack("C")
@flag & 1 == 1 && s << [@mtime.to_i].pack("V")
s = [@flag].pack('C')
@flag & 1 == 1 && s << [@mtime.to_i].pack('V')
s
end
end
Expand Down
6 changes: 3 additions & 3 deletions lib/zip/extra_field/unix.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
module Zip
# Info-ZIP Extra for UNIX uid/gid
class ExtraField::IUnix < ExtraField::Generic
HEADER_ID = "Ux"
HEADER_ID = 'Ux'
register_map

def initialize(binstr = nil)
Expand All @@ -17,7 +17,7 @@ def merge(binstr)
size, content = initial_parse(binstr)
# size: 0 for central directory. 4 for local header
return if (!size || size == 0)
uid, gid = content.unpack("vv")
uid, gid = content.unpack('vv')
@uid ||= uid
@gid ||= gid
end
Expand All @@ -27,7 +27,7 @@ def ==(other)
end

def pack_for_local
[@uid, @gid].pack("vv")
[@uid, @gid].pack('vv')
end

def pack_for_c_dir
Expand Down
10 changes: 5 additions & 5 deletions lib/zip/extra_field/zip64.rb
Original file line number Diff line number Diff line change
Expand Up @@ -51,16 +51,16 @@ def extract(size, format)
def pack_for_local
# local header entries must contain original size and compressed size; other fields do not apply
return '' unless @original_size && @compressed_size
[@original_size, @compressed_size].pack("Q<Q<")
[@original_size, @compressed_size].pack('Q<Q<')
end

def pack_for_c_dir
# central directory entries contain only fields that didn't fit in the main entry part
packed = ''.force_encoding('BINARY')
packed << [@original_size].pack("Q<") if @original_size
packed << [@compressed_size].pack("Q<") if @compressed_size
packed << [@relative_header_offset].pack("Q<") if @relative_header_offset
packed << [@disk_start_number].pack("V") if @disk_start_number
packed << [@original_size].pack('Q<') if @original_size
packed << [@compressed_size].pack('Q<') if @compressed_size
packed << [@relative_header_offset].pack('Q<') if @relative_header_offset
packed << [@disk_start_number].pack('V') if @disk_start_number
packed
end
end
Expand Down
6 changes: 3 additions & 3 deletions lib/zip/file.rb
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ def open_buffer(io, options = {})
begin
zf.write_buffer(io)
rescue IOError => e
raise unless e.message == "not opened for writing"
raise unless e.message == 'not opened for writing'
end
end

Expand Down Expand Up @@ -263,7 +263,7 @@ def read(entry)
# Convenience method for adding the contents of a file to the archive
def add(entry, src_path, &continue_on_exists_proc)
continue_on_exists_proc ||= proc { ::Zip.continue_on_exists_proc }
check_entry_exists(entry, continue_on_exists_proc, "add")
check_entry_exists(entry, continue_on_exists_proc, 'add')
new_entry = entry.kind_of?(::Zip::Entry) ? entry : ::Zip::Entry.new(@name, entry.to_s)
new_entry.gather_fileinfo_from_srcpath(src_path)
new_entry.dirty = true
Expand Down Expand Up @@ -382,7 +382,7 @@ def is_directory(newEntry, srcPath)
"entry name '#{newEntry}' indicates directory entry, but "+
"'#{srcPath}' is not a directory"
elsif !newEntry.is_directory && srcPathIsDirectory
newEntry.name += "/"
newEntry.name += '/'
end
newEntry.is_directory && srcPathIsDirectory
end
Expand Down
Loading
0