Commit Graph

1180 Commits

Author SHA1 Message Date
Robert Haines 0620fba13d Don't use raw numbers for Entry compression types.
Constants for Store and Deflate are already available, so use them. It
might be sensible to remove these local versions, but they do have their
uses as a shortened form.
2020-08-31 17:48:08 +01:00
Robert Haines 156b0f3dee Tidy up accessors in `Entry`.
Remove a load of accessors from the 'public' API by not documenting
them, and remove access to `header_signature` completely.

Also, `Entry#extra` has been created to allow extra fields to be set
correctly after initialization.
2020-08-31 17:48:08 +01:00
Robert Haines e4ceedaa58 Use keyword arguments for the `Entry` initializer.
This greatly simplifies the creation of `Entry` objects when only a
couple of fields are not set to their defaults, while at the same time
allowing an `Entry` to be fully configured at creation time if
appropriate.

This fundamentally changes the `Entry` API and  means that some
convenience methods in `OutputStream` and `File` have needed to be
refactored.
2020-08-31 17:48:08 +01:00
Robert Haines 2775f529b4 Set the compression level general purpose flags. 2020-08-31 17:48:08 +01:00
Robert Haines 072fa27e78 Refactor `Entry#compression_method` access.
As per the conversation here [1], make `compression_method` a method and
enforce the correct type of compression for directories by default.

[1] https://github.com/rubyzip/rubyzip/pull/448#discussion_r436268506
2020-08-31 17:48:08 +01:00
Robert Haines d4bc24dcb3 Clean up `OutputStream` internals.
There was some fairly odd stuff going on in `put_next_entry` that
allowed for data within an `Entry` to be overridden and prevented an
`Entry` from being a single point of truth. Fixing this also simplifies
the code within `File` and still passes all tests.

Also, fixing the above means we can stop passing the compression level
around as a parameter and use the value stored in each `Entry` directly.

Let's keep `compression_level` out of the `Entry` public API though as
it only makes sense when writing an `Entry`: there doesn't seem to be an
obvious way to read what level of compression was used when reading an
`Entry` from a zip file.
2020-08-31 17:48:08 +01:00
Robert Haines 14451e63e7 Add setting a compression level to the File options.
It looks like it needs to be surfaced in `add` and `get_output_stream`.
The compression level defaults to whatever the global default is unless
it is overridden on opening the Zip::File.

Also needed to reorder some of the requires in the top-level module file
now that we are using defaults in the File class.
2020-08-31 17:48:08 +01:00
Robert Haines ef520b4b94 Add `compression_level` to the Entry API.
Allow an Entry to specify a compression level and pass this down to the
underlying OutputStream infrastructure. OutputStream has been able to
specify a compression level for a while but this has, up until now, only
ever been set to the default.

This fundamentally changes the API so will need a major version bump.
2020-08-31 17:48:08 +01:00
Robert Haines 0790695e8c Clean up OutputStream#init_next_entry.
There's no need for this private method to specify a default.
2020-08-31 17:48:08 +01:00
John Lees-Miller e5e3f97ec8
Merge pull request #450 from gogainda/patch-2
enable truffle ruby in Travis CI
2020-08-24 15:34:11 +01:00
Igor Victor e4f6d5ec56
Allow failures for truffleruby-head and truffleruby 2020-08-24 13:19:53 +02:00
Igor Victor cf73152560
enable truffle ruby in Travis CI
@eregon enabling truffle ruby support for rubyzip
2020-08-13 17:37:09 +01:00
John Lees-Miller b653d57635 Update changelog for #445 2020-04-11 10:37:05 +01:00
John Lees-Miller 214f75a4d8
Merge pull request #445 from lucaskanashiro/fix-test-in-s390x
test/file_extract_test.rb: fix test_extract_incorrect_size in s390x arch
2020-04-11 10:33:22 +01:00
Lucas Kanashiro 262ba001a4 test/file_extract_test.rb: fix test_extract_incorrect_size in s390x arch
Using the current pack directives makes test_extract_incorrect_size fail
in s390x architecture because of the endian probably. This is the output
of the command executed by the test in amd64:

irb(main):001:0> [501, 500000, 1].pack('LLS')
=> "\xF5\x01\x00\x00 \xA1\a\x00\x01\x00"

And the output of the same command in s390x:

irb(main):001:0> [501, 500000, 1].pack('LLS')
=> "\x00\x00\x01\xF5\x00\a\xA1 \x00\x01"

Changing to 'VVv' pack directives like is used in
lib/zib/entry.rb fixes the test in s390x and does not add a
regression in amd64.
2020-04-04 11:44:27 -03:00
John Lees-Miller 382cc84915 Update changelog for #444 2020-04-04 10:11:06 +01:00
John Lees-Miller 51a3b21c75
Merge pull request #444 from hainesr/travis-rubocop
Add rubocop to travis CI
2020-04-04 09:54:11 +01:00
Robert Haines 2f311541da Update the auto-config for Rubocop 0.80. 2020-03-15 12:25:46 +00:00
Robert Haines 0c34cc1814 Explicitly set Rubocop ruby version to 2.4. 2020-03-15 12:25:46 +00:00
Robert Haines ee06a8038a Bump Rubocop version and lock it down at patch level.
Now we're using Rubocop in CI we need to prevent CI from dragging in a
newer version than that which we are expecting. This will avoid
unexpected fails from the linting stage.
2020-03-15 12:24:47 +00:00
Robert Haines f37e679e7c Add a rubocop job to the Travis config. 2020-03-14 17:42:36 +00:00
John Lees-Miller 3bc55a5d98
Merge pull request #443 from rubyzip/v2-3-0
Bump version to 2.3.0
2020-03-14 12:00:50 +00:00
John Lees-Miller 69186f65cd Bump version to 2.3.0 2020-03-14 11:31:39 +00:00
John Lees-Miller 516941bec5 Update changelog for #439 and #440 2020-03-14 11:28:02 +00:00
John Lees-Miller a64a14767d Bump rake version (development dependency) 2020-03-14 11:09:33 +00:00
John Lees-Miller 4c789c2821 Remove unused constant from #439 2020-03-14 11:00:39 +00:00
John Lees-Miller fabacf1633
Merge pull request #440 from hainesr/rubocop-names
Rubocop name cops
2020-03-14 10:58:54 +00:00
John Lees-Miller b231b28998
Merge pull request #439 from henkeinfo/binary-outstream-buffer
Set OutputStream.write_buffer's default buffer to binmode
2020-03-14 10:32:28 +00:00
Sebastian Henke 66324a711c Remove duplicate binmode call 2020-03-02 11:06:50 +01:00
Sebastian Henke e33c07a6e7
Use existing constant for ASCII_8BIT
Co-Authored-By: John Lees-Miller <jdleesmiller@gmail.com>
2020-03-02 11:00:39 +01:00
Robert Haines ce17c57e2d Fix Naming/AccessorMethodName in the tests.
This was kind of a misfire of this cop, but no bother to change.
2020-02-29 18:11:52 +00:00
Robert Haines c30d9dfb26 Configure Naming/MemoizedInstanceVariableName in source.
Rather than turn it off for a whole file, it's better to mark these
exceptions in comments.
2020-02-29 18:11:52 +00:00
Robert Haines f9b161eb32 Fix Naming/VariableName cop in the library code. 2020-02-29 18:11:52 +00:00
Robert Haines e6f414f539 Fix Naming/VariableName cop in the tests. 2020-02-29 18:11:52 +00:00
Robert Haines 7626423994 Fix Naming/VariableName cop in the samples. 2020-02-29 18:11:52 +00:00
Robert Haines aa6ea05d45 Fix Naming/MethodParameterName cop in the library code. 2020-02-29 18:11:52 +00:00
Robert Haines b09f05d8d3 Fix Naming/MethodParameterName cop in the tests. 2020-02-29 18:11:52 +00:00
Robert Haines fcadea61e2 Fix Naming/MethodParameterName cop in the samples. 2020-02-29 17:12:45 +00:00
Sebastian Henke b0ee2683b0 Set buffers to binmode by default 2020-02-19 18:48:13 +01:00
Robert Haines 846e704048 Fix Naming/BlockParameterName cop. 2020-02-17 22:35:08 +00:00
John Lees-Miller 8d91d001fd Update changelog for #420 and #437 2020-02-16 08:14:43 +00:00
John Lees-Miller 10685a74e0
Merge pull request #437 from hainesr/rubocop-0.79
Rubocop 0.79
2020-02-16 08:10:56 +00:00
Robert Haines 87a63e0cc3 Set TargetRubyVersion to match that in the gemspec.
Currently 2.4 is the earliest supported ruby version.
2020-02-15 16:26:32 +00:00
Robert Haines c31ab81cf6 Fix Style/NumericLiterals cop. 2020-02-15 16:26:32 +00:00
Robert Haines 989a565340 Fix Style/TrailingCommaInHashLiteral cop. 2020-02-15 16:26:32 +00:00
Robert Haines d07b36b2e6 Fix Style/TernaryParentheses cop. 2020-02-15 16:26:32 +00:00
Robert Haines fae95e3c29 Fix Style/NumericLiteralPrefix cop. 2020-02-15 16:26:32 +00:00
Robert Haines 4b8f74042a Fix Layout/EmptyLinesAroundClassBody cop. 2020-02-15 16:26:32 +00:00
Robert Haines a187ec0c38 Configure Metrics/MethodLength and turn off for the tests. 2020-02-15 16:26:32 +00:00
Robert Haines a9adfa26d6 Configure Metrics/ClassLength and turn off for the tests. 2020-02-15 16:26:32 +00:00