Skip to content

Commit

Permalink
Use named parameters for File::split.
Browse files Browse the repository at this point in the history
  • Loading branch information
hainesr committed Jun 13, 2021
1 parent ccb5641 commit 4936d9a
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 10 deletions.
7 changes: 0 additions & 7 deletions .rubocop_todo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -107,13 +107,6 @@ Style/NumericPredicate:
- 'lib/zip/ioextras/abstract_input_stream.rb'
- 'test/test_helper.rb'

# Offense count: 1
# Configuration parameters: AllowedMethods.
# AllowedMethods: respond_to_missing?
Style/OptionalBooleanParameter:
Exclude:
- 'lib/zip/file_split.rb'

# Offense count: 29
# Cop supports --auto-correct.
Style/RedundantRegexpEscape:
Expand Down
7 changes: 5 additions & 2 deletions lib/zip/file_split.rb
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,10 @@ def save_splited_part(zip_file, partial_zip_file_name, zip_file_size, szip_file_
end

# Splits an archive into parts with segment size
def split(zip_file_name, segment_size = MAX_SEGMENT_SIZE, delete_zip_file = true, partial_zip_file_name = nil)
def split(
zip_file_name, segment_size: MAX_SEGMENT_SIZE,
delete_original: true, partial_zip_file_name: nil
)
raise Error, "File #{zip_file_name} not found" unless ::File.exist?(zip_file_name)
raise Errno::ENOENT, zip_file_name unless ::File.readable?(zip_file_name)

Expand All @@ -81,7 +84,7 @@ def split(zip_file_name, segment_size = MAX_SEGMENT_SIZE, delete_zip_file = true
save_splited_part(zip_file, partial_zip_file_name, zip_file_size, szip_file_index, segment_size, segment_count)
end
end
::File.delete(zip_file_name) if delete_zip_file
::File.delete(zip_file_name) if delete_original
szip_file_index
end
end
Expand Down
4 changes: 3 additions & 1 deletion test/file_split_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@ def test_split_method_respond
end

def test_split
result = ::Zip::File.split(TEST_ZIP.zip_name, 65_536, false)
result = ::Zip::File.split(
TEST_ZIP.zip_name, segment_size: 65_536, delete_original: false
)

return if result.nil?

Expand Down

0 comments on commit 4936d9a

Please sign in to comment.