Commit Graph

398 Commits

Author SHA1 Message Date
Robert Haines cfe4972e71 Fix Layout/EmptyLineAfterGuardClause cop. 2020-02-15 16:26:32 +00:00
Robert Haines fff2c41d68 Configure Lint/SuppressedException cop.
In the tests we can say "anything goes", but in the main body of the
code we should at least comment if we're not handling an exception
fully.
2020-02-15 16:26:32 +00:00
Robert Haines 0d49421711 Fix Lint/UselessAccessModifier cop. 2020-02-15 16:26:32 +00:00
Robert Haines b528cae084 Fix Lint/LiteralAsCondition cop.
This fixes Style/InfiniteLoop as a side-effect.
2020-02-15 16:26:32 +00:00
Robert Haines 98c6969c18 Fix Layout/SpaceAroundOperators cop. 2020-02-15 16:26:32 +00:00
Robert Haines 73e405acef Fix Security/Open cop errors. 2020-02-15 15:56:17 +00:00
taichi 976dbd3408 reverted the change according to comment below:
https://github.com/rubyzip/rubyzip/pull/431#discussion_r376698387
2020-02-08 19:54:45 +09:00
taichi b326d17438 use @+ operator instead of #dup to get unfrozen string 2020-02-05 11:40:56 +09:00
taichi 3bc85ccdec fixed frozen error caseud by frozen string literal 2020-02-05 11:30:30 +09:00
John Lees-Miller f42827e99c Bump version to 2.2.0 2020-02-01 13:24:50 +00:00
John Lees-Miller 040962a59f Remove unused error argument 2020-02-01 13:19:15 +00:00
John Lees-Miller 666fb8c03f
Merge pull request #427 from jspanjers/refactor-decompressor
Support decompressor plugins
2020-02-01 13:15:03 +00:00
Jan-Joost Spanjers a5d068d3e8 Support Decompressor plugins 2020-01-26 15:34:17 +01:00
Jan-Joost Spanjers 2b7268373a Define compression methods 2020-01-26 15:34:17 +01:00
Jan-Joost Spanjers 456bd4d92c Mimic IO#read return values in Decompressor#read 2020-01-26 15:34:17 +01:00
Jan-Joost Spanjers c66277db58 Rename Decompressor#sysread to #read 2020-01-26 15:34:17 +01:00
Jan-Joost Spanjers 00b525d76e Fix returned outbuf for Inflater#sysread 2020-01-26 15:34:17 +01:00
Jan-Joost Spanjers cda7127107 Add Decompressor#input_stream 2020-01-26 15:34:17 +01:00
Jan-Joost Spanjers 5707c52a15 Move PassTruDecompressor#decompressed_size to Decompressor 2020-01-26 15:34:17 +01:00
Jan-Joost Spanjers 2bbcec0e34 Cleanup PassTruDecompressor 2020-01-26 15:34:17 +01:00
Jan-Joost Spanjers 4ac83737b1 Cleanup Inflater 2020-01-26 15:34:17 +01:00
Jan-Joost Spanjers dd74bc0e73 Cleanup NullDecompressor 2020-01-26 15:34:17 +01:00
Jan-Joost Spanjers b80ce3cc57 Make decryption generic for all compression methods
Now, STORED files can be decrypted, just like DEFLATED files.
2020-01-26 15:34:17 +01:00
Jan-Joost Spanjers 4e28f7286c Untangle encryption and decompression 2020-01-26 15:34:17 +01:00
Jan-Joost Spanjers 8f7c5caf29 Drop #produce_input from Decompressor class 2020-01-26 15:34:17 +01:00
Jan-Joost Spanjers d20a6834a3 Rework Inflater#produce_input to use sysread
This aligns Inflater#produce_input with
PassThruDecompresser#produce_input.
2020-01-26 15:34:17 +01:00
Jan-Joost Spanjers 1b6aeb2cd0 Replace Decompressor#input_finished? with #eof 2020-01-26 15:34:17 +01:00
Jan-Joost Spanjers 4a4c553b1e Move :eof from InputStream to AbastractInputStream 2020-01-26 15:34:17 +01:00
Jan-Joost Spanjers e072c57beb Add Entry#incomplete? 2020-01-26 15:34:17 +01:00
Jan-Joost Spanjers c897bbdf77 Add Entry#encrypted? 2020-01-26 15:34:17 +01:00
Jan-Joost Spanjers 0b7b78dc4a Encapsulate Zlib errors within DecompressionError 2020-01-26 15:34:13 +01:00
John Lees-Miller f6639f9b55 Bump version to 2.1.0 2020-01-25 18:12:57 +00:00
Robert Haines ee028d2746 UniversalTime: more ruby-like (readable) code. 2019-12-15 22:42:09 +00:00
Robert Haines 9849500d73 UniversalTime: correctly parse included timestamps.
From the documentation: "...times that are present will appear in the
order indicated, but any combination of times may be omitted. (Creation
time may be present without access time, for example.)"

This fixes the parsing so that the times are read into the correct
fields, according to the flags. Before they were simply assumed to be in
order and all present.
2019-12-15 22:37:29 +00:00
Robert Haines a5e785c737 UniversalTime: better check for size on parse. 2019-12-15 22:26:06 +00:00
Robert Haines 65cfd8a9a5 UniversalTime: correctly pack/unpack the timestamps.
From the documentation: "The time values are in standard Unix signed-long
format, indicating the number of seconds since 1 January 1970 00:00:00."

The three time values were being unpacked with 'VVV', which is unsigned
32-bit, but they should be unpacked with 'l<l<l<': signed-long little
endian.
2019-12-15 22:26:06 +00:00
Robert Haines b58b97fe23 UniversalTime: correctly set the flags.
When a timestamp is set/unset the flags should reflect this.
2019-12-15 22:26:06 +00:00
Robert Haines 2d6b6e024b Ensure File#get/find_entry work consistently.
I have switched around the logic somewhat so that `get_entry` calls
`find_entry` and raises an exception if it gets `nil` back.
2019-10-31 18:12:18 +00:00
Robert Haines 0f6ca04a9d Set the default options in `Entry` the same as `File`. 2019-10-31 17:30:14 +00:00
Robert Haines 2bdd37d894 Add a convenience method for creating DOSTime instances.
DOSTime::from_time creates a DOSTime instance from a vanilla Time
instance.
2019-10-20 19:30:34 +01:00
Robert Haines 8c694d38ee Add functionality to restore file timestamps.
There has been an option in `Zip::File` (`:restore_times`) for a long
time, but it seems it has never worked. Firstly the actual timestamp of
an added file wasn't being saved, and secondly an extracted file wasn't
having its timestamp set correctly.

This commit fixes both of those issues, and adds tests to make sure.
2019-10-20 19:30:27 +01:00
Robert Haines 378293539d Make the attr_accessors in File more readable.
Note what the default is and that a couple of them will change at some
point soon.
2019-10-19 20:46:21 +01:00
Robert Haines 253457545e Correctly set/default options in the File class.
Fixes #395. Set the options to false for now for consistency.
2019-10-19 20:45:29 +01:00
John Lees-Miller 056c00cb16
Merge pull request #418 from hainesr/open-options
Add `options` parameter to `Zip::File.open`.
2019-10-19 17:38:38 +01:00
Robert Haines 3fea9958c2 Update comment for `Zip::File.open`. 2019-10-19 07:15:51 +01:00
Robert Haines f58e38012c Add the `options` parameter to `Zip::File.open`. 2019-10-19 07:04:04 +01:00
Robert Haines 935a4f31a2 Make warning messages consistent.
And fix a few spelling mistakes.
2019-10-12 12:52:04 +01:00
Robert Haines 340379f080 Use `warn` instead of `puts` for messages from the library code.
`warn` has the advantage of easily being disabled by, the `-W0` interpreter
flag or setting $VERBOSE to nil.
2019-10-11 19:31:42 +01:00
Robert Haines 506d557edc StreamableStream now uses the OS temp directory.
Rather than using the local folder.

Fixes #410
2019-09-27 16:13:56 +01:00
John Lees-Miller cb407b1065 Bump version to 2.0.0 2019-09-25 21:10:05 +01:00