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
Jan-Joost Spanjers
4e28f7286c
Untangle encryption and decompression
2020-01-26 15:34:17 +01: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
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
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
ecb2776218
Zip::File.add_stored() to add uncompressed files.
...
Adding uncompressed files to a zip archive can be overly complex, so
this convenience method makes it easier.
2019-09-14 13:58:30 +01:00
Robert Haines
84c208982f
Switch newly created StringIOs to binmode.
...
StringIO objects created within File.open_buffer were not being switched into
binmode, but those passed in were. Fix this inconsistency and add a test.
2018-04-04 16:02:19 +01:00
Robert Haines
15ccc25da1
Fix File.open_buffer when no changes are made.
...
Things are now more carefully set up, and if a buffer is passed in which
represents a file that already exists then this is taken into account. All
initialization is now done in File.new, rather than being split between there
and File.open_buffer.
This has also needed a bit of a re-write of Zip::File.initialize. I've tried to
bring some logic to it as a result, and have added comments to explain what is
now happening.
2018-04-04 15:54:12 +01:00
Robert Haines
03633933eb
No need to require stringio in Zip::File.open_buffer.
...
It's already required in zip.rb.
2018-04-04 14:31:34 +01:00
Robert Haines
cfa9441914
Handle passing an IO to Zip::File.new better.
...
This now actually extracts the path from the IO if one is passed in.
2018-04-03 23:48:54 +01:00
Robert Haines
7cd263e6a0
Clean up use of file_name in Zip::File::initialize.
2018-04-03 23:45:04 +01:00
Phil
792266dbf3
Added fix for calling 'close' on a StringIO-backed zip file, and specs
2018-02-21 11:48:56 -08:00
Takumasa Ochi
cf91112b57
Apply automatic correction by rubocop
2017-06-29 11:57:12 +09:00
mwlang
14b8fed18c
allows open_buffer to work without a given block
2017-01-16 13:24:22 -06:00
Robert Haines
c00d767533
Fix rubocop offence caused by temp files changes.
2016-09-05 17:34:12 +01:00
Robert Haines
fc23f68f77
Refactor the create logic in Zip::File.
...
Make the internal @create varible more consistent and actually match the
documentation.
Zip::File::CREATE is now true, rather than 1.
A new test is added to check if passing 1 in still works to ensure backwards
compatibility.
2016-09-05 15:16:57 +01:00
Robert Haines
63ed0d970b
Refactor the code which manages temp files.
...
Combine the creation of the temporary filename with the writing to it.
2016-09-05 15:07:18 +01:00
Robert Haines
7b14d11c00
Stop using 0600 perms for temporary files.
...
This fixes #294 in what I hope is a more sensible way than trying to mess with
umasks, etc, directly.
Temporary files were being created with 0600 permissions and then being set to
different permissions, based on umask, etc, afterwards. I don't know what the
rationale for this was, but there were errors in the umask calculations when
moving from the temporary file to the intended end result.
2016-09-01 12:10:56 +01:00
Mike Naberezny
6e1dea4f66
Fix accidental unlink ( #185 ) without using ObjectSpace ( #252 )
2015-11-22 14:40:59 -08:00
Alexander Simonov
8447f0e230
Fix #252
2015-11-21 12:07:30 +02:00
Seth Kingsley
05a9ba3f20
Use duck typing to detect IO-like objects.
2015-09-03 06:16:32 -07:00
Claire Pitman
a1f75a3ab9
Added error for empty (zero bit) zip file. Added tests for empty and non existant zips
2015-07-27 23:20:59 -07:00
Victor Costan
37a5baad96
Accept StringIO in Zip.open_buffer.
2015-07-02 14:17:17 -04:00
Robert Haines
9acc50f004
Do something more expected with new file permissions.
...
Instead of inheriting the permissions from the tmp directory, new files should
have permissions that reflect the defaults on the system taking umask into
account.
It seems that (unix) permissions of 666 - umask are as close to a standard as
anything [1] and that 'touch' uses this. On Windows it seems sensible to just
use 644 directly [2].
[1] http://unix.stackexchange.com/a/102080
[2] http://ruby-doc.org/core-1.9.3/File.html
2015-06-24 18:25:22 +01:00
Pavel Lobashov
1e99ff69b9
Revert "fix rubocop cop Style/ClassCheck". It cause regression in tests
...
This reverts commit 8c13dfc265
.
2015-06-08 10:45:23 +03:00
Pavel Lobashov
8c13dfc265
fix rubocop cop Style/ClassCheck
2015-06-08 10:36:41 +03:00
Pavel Lobashov
f7eec2dd76
fix rubocop cop Style/SpaceAroundOperators
2015-06-08 10:26:13 +03:00
Pavel Lobashov
c0177a455b
Merge branch 'master' into rubocop_fixes
...
Conflicts:
README.md
samples/example_recursive.rb
2015-06-08 10:14:25 +03:00
Vít Ondruch
32016ab1bf
Remove executable bit.
2015-03-31 13:15:46 +02:00
Pavel Lobashov
112a77de7c
fix some Style/FormatString cop
2015-03-24 19:20:39 +03:00
Pavel Lobashov
b920a1eb49
fix rubocop Style/GuardClause cop
2015-03-24 19:16:03 +03:00
Pavel Lobashov
b9aefaffb5
fix rubocop Style/IfUnlessModifier cop
2015-03-24 19:09:22 +03:00
Pavel Lobashov
1ba81ff46f
fix rubocop Style/NumericLiterals cop
2015-03-23 19:23:04 +03:00
Pavel Lobashov
31fb9d729b
fix rubocop Style/PredicateName cop
2015-03-23 19:18:51 +03:00
Pavel Lobashov
d5f79822c1
fix rubocop Style/LineEndConcatenation cop
2015-03-23 19:03:28 +03:00
Pavel.Lobashov
8d6f23ba9a
fix rubocop Style/SpaceAroundOperators cop
2015-03-22 20:03:50 +03:00
Pavel.Lobashov
abf9cbec23
fix rubocop Style/RedundantSelf cop
2015-03-22 19:30:24 +03:00
Pavel Lobashov
b93ef1266f
fix rubocop Style/StringLiterals cop
2015-03-21 11:27:44 +03:00
Pavel Lobashov
b9a757e045
fix rubocop Style/EmptyLinesAroundClassBody cop
2015-03-21 11:21:26 +03:00
Pavel Lobashov
d0c8e8df60
fix rubocop Style/EmptyLines cop
2015-03-21 11:19:14 +03:00
Alexander Simonov
721c1f05ed
Merge pull request #201 from mcantor/master
...
Be smarter about handling buffer file modes
2015-01-17 12:21:32 +02:00
Max Cantor
7c7d786f02
Be smarter about handling buffer file modes.
2014-12-17 16:16:02 -05:00
James Williams
3b639b6c62
prevent tempfile path from being unlinked by garbage collection
2014-08-29 08:31:56 -06:00
Alexander Simonov
2fcdc3a3ea
Revert "Return created zip file from Zip::File.open when supplied a block"
...
This reverts commit e3029d0b10
.
2014-07-02 18:15:54 +03:00
Michael Yin
fe1d4ade49
treat empty file as non-exists
2014-07-02 12:46:44 +08:00
Tyler Pickett
e3029d0b10
Return created zip file from Zip::File.open when supplied a block
...
This change is to match ruby zip’s behavior to core’s IO.open when
supplied a block.
2014-06-17 10:08:26 -06:00
Ian Young
37ed325783
Clean up tempfiles from output stream, fixes #57
2014-04-04 14:32:11 -07:00