zip_kit 6.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (54) hide show
  1. checksums.yaml +7 -0
  2. data/.codeclimate.yml +7 -0
  3. data/.document +5 -0
  4. data/.github/workflows/ci.yml +29 -0
  5. data/.gitignore +61 -0
  6. data/.rspec +1 -0
  7. data/.standard.yml +8 -0
  8. data/.yardopts +1 -0
  9. data/CHANGELOG.md +255 -0
  10. data/CODE_OF_CONDUCT.md +46 -0
  11. data/CONTRIBUTING.md +153 -0
  12. data/Gemfile +4 -0
  13. data/IMPLEMENTATION_DETAILS.md +97 -0
  14. data/LICENSE.txt +20 -0
  15. data/README.md +234 -0
  16. data/Rakefile +21 -0
  17. data/bench/buffered_crc32_bench.rb +109 -0
  18. data/examples/archive_size_estimate.rb +15 -0
  19. data/examples/config.ru +7 -0
  20. data/examples/deferred_write.rb +58 -0
  21. data/examples/parallel_compression_with_block_deflate.rb +86 -0
  22. data/examples/rack_application.rb +63 -0
  23. data/examples/s3_upload.rb +23 -0
  24. data/lib/zip_kit/block_deflate.rb +130 -0
  25. data/lib/zip_kit/block_write.rb +47 -0
  26. data/lib/zip_kit/file_reader/inflating_reader.rb +36 -0
  27. data/lib/zip_kit/file_reader/stored_reader.rb +35 -0
  28. data/lib/zip_kit/file_reader.rb +740 -0
  29. data/lib/zip_kit/null_writer.rb +12 -0
  30. data/lib/zip_kit/output_enumerator.rb +150 -0
  31. data/lib/zip_kit/path_set.rb +163 -0
  32. data/lib/zip_kit/rack_chunked_body.rb +32 -0
  33. data/lib/zip_kit/rack_tempfile_body.rb +61 -0
  34. data/lib/zip_kit/rails_streaming.rb +37 -0
  35. data/lib/zip_kit/remote_io.rb +114 -0
  36. data/lib/zip_kit/remote_uncap.rb +22 -0
  37. data/lib/zip_kit/size_estimator.rb +84 -0
  38. data/lib/zip_kit/stream_crc32.rb +60 -0
  39. data/lib/zip_kit/streamer/deflated_writer.rb +45 -0
  40. data/lib/zip_kit/streamer/entry.rb +37 -0
  41. data/lib/zip_kit/streamer/filler.rb +9 -0
  42. data/lib/zip_kit/streamer/heuristic.rb +68 -0
  43. data/lib/zip_kit/streamer/stored_writer.rb +39 -0
  44. data/lib/zip_kit/streamer/writable.rb +36 -0
  45. data/lib/zip_kit/streamer.rb +614 -0
  46. data/lib/zip_kit/uniquify_filename.rb +39 -0
  47. data/lib/zip_kit/version.rb +5 -0
  48. data/lib/zip_kit/write_and_tell.rb +40 -0
  49. data/lib/zip_kit/write_buffer.rb +71 -0
  50. data/lib/zip_kit/write_shovel.rb +22 -0
  51. data/lib/zip_kit/zip_writer.rb +436 -0
  52. data/lib/zip_kit.rb +24 -0
  53. data/zip_kit.gemspec +41 -0
  54. metadata +335 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 6ff2f42664629263c431e566c3aacdce8172f3d2623bb5b18a0a57b8740bb600
4
+ data.tar.gz: '09fafbaf3a56c9200a48618fadaacbbfb44efb95cf802b089ecdd7b5de290774'
5
+ SHA512:
6
+ metadata.gz: 16c5e3100a7f514212b93e4862dfd0e00da93158c251cb4e6491a56cf96769f5dee3f5cb194b0bb67e2b3ac6a62da7b2b490509225735fa3374fdeb0394da6df
7
+ data.tar.gz: c56e949d2a7ec86dfbbd3fbea70494756e19059cae897be417e34ee2dbb6532a203488ff5b7cb716e2dd400b2222bb3d3232743822fcef73b0ce2b3c21bcb97b
data/.codeclimate.yml ADDED
@@ -0,0 +1,7 @@
1
+ engines:
2
+ rubocop:
3
+ enabled: true
4
+
5
+ ratings:
6
+ paths:
7
+ - "**.rb"
data/.document ADDED
@@ -0,0 +1,5 @@
1
+ lib/**/*.rb
2
+ bin/*
3
+ -
4
+ features/**/*.feature
5
+ LICENSE.txt
@@ -0,0 +1,29 @@
1
+ name: CI
2
+
3
+ on:
4
+ - push
5
+
6
+ env:
7
+ BUNDLE_PATH: vendor/bundle
8
+
9
+ jobs:
10
+ test:
11
+ name: Tests and Lint
12
+ runs-on: ubuntu-22.04
13
+ strategy:
14
+ matrix:
15
+ ruby:
16
+ - '2.6'
17
+ - '3.2'
18
+ steps:
19
+ - name: Checkout
20
+ uses: actions/checkout@v4
21
+ - name: Setup Ruby
22
+ uses: ruby/setup-ruby@v1
23
+ with:
24
+ ruby-version: ${{ matrix.ruby }}
25
+ bundler-cache: true
26
+ - name: "Tests"
27
+ run: bundle exec rspec --backtrace --fail-fast
28
+ - name: "Lint"
29
+ run: bundle exec rake standard
data/.gitignore ADDED
@@ -0,0 +1,61 @@
1
+ # rcov generated
2
+ coverage
3
+ coverage.data
4
+
5
+ # rdoc generated
6
+ rdoc
7
+
8
+ # yard generated
9
+ doc
10
+ .yardoc
11
+
12
+ # Rubocop
13
+ rubocop.html
14
+
15
+ # bundler
16
+ .bundle
17
+ Gemfile.lock
18
+
19
+ # jeweler generated
20
+ pkg
21
+
22
+ # Have editor/IDE/OS specific files you need to ignore? Consider using a global gitignore:
23
+ #
24
+ # * Create a file at ~/.gitignore
25
+ # * Include files you want ignored
26
+ # * Run: git config --global core.excludesfile ~/.gitignore
27
+ #
28
+ # After doing this, these files will be ignored in all your git projects,
29
+ # saving you from having to 'pollute' every project you touch with them
30
+ #
31
+ # Not sure what to needs to be ignored for particular editors/OSes? Here's some ideas to get you started. (Remember, remove the leading # of the line)
32
+ #
33
+ # For MacOS:
34
+ #
35
+ #.DS_Store
36
+
37
+ tmp
38
+ testing/*.zip
39
+ .ruby-version
40
+
41
+ # For TextMate
42
+ #*.tmproj
43
+ #tmtags
44
+
45
+ # For emacs:
46
+ #*~
47
+ #\#*
48
+ #.\#*
49
+
50
+ # For vim:
51
+ #*.swp
52
+
53
+ # For redcar:
54
+ #.redcar
55
+
56
+ # For rubinius:
57
+ #*.rbc
58
+
59
+ # Rubocop report
60
+ rubocop.html
61
+
data/.rspec ADDED
@@ -0,0 +1 @@
1
+ --color
data/.standard.yml ADDED
@@ -0,0 +1,8 @@
1
+ ruby_version: 2.7
2
+ ignore:
3
+ - 'spec/**/*':
4
+ - Lint/ConstantDefinitionInBlock
5
+ - Style/GlobalVars
6
+ - 'lib/zip_kit/rack_body.rb': # Erroneous detection
7
+ - Lint/OrderedMagicComments
8
+ - Layout/EmptyLineAfterMagicComment
data/.yardopts ADDED
@@ -0,0 +1 @@
1
+ --markup markdown
data/CHANGELOG.md ADDED
@@ -0,0 +1,255 @@
1
+ ## 6.0
2
+
3
+ * Remove `RackBody` because it is just `OutputEnumerator`. Add a convenience method for Rack response generation.
4
+ * Rebirth as zip_kit
5
+ * Adopt MIT license. The changes from 5.x get grandfathered in. The base for the fork is the 4.x version which was still MIT-licensed.
6
+ * Bump minimum Ruby version to 2.6
7
+ * Respond to `#write` in all objects that respond to `#<<`, because they should be usable with `IO.copy_stream`
8
+ * Allow the last file to be suppressed in the central directory via Streamer#rollback!
9
+ * Allow heuristic compression. Use `Streamer#write_file` to let zip_kit pick the right compression method for you. If a file will benefit from
10
+ compression, it is going to be written deflated. If it will not - it will be written stored. Evaluation is based on the first 128KB of the file contents.
11
+ * Make RackBody future-proof for Rack 3.x by adding a chunked body encoder
12
+ * Fix Rails buffering the response unexpectedly, which could happen due to either of wrong content encoding, HTTP/1.0 protocol being requested or the Rack::ETag
13
+ * Allow objects that only respond to `#write` as streaming destination. The Rails `stream` object in ActionController::Live is like that.
14
+ * Fix uses of `Time.now` in tests for Ruby 3 compatibility
15
+
16
+ # zip_tricks version history
17
+
18
+ ## 5.6.0
19
+
20
+ * Add customisable `unix_permissions` to Streamer and ZipWriter. Beware that customising these permissions can lead to the archive failing to expand with some unarchiving applications, and is especially sensitive for directories.
21
+
22
+ ## 5.5.0
23
+
24
+ * In `OutputEnumerator` apply some amount of buffering to be within a UNIX socket size for metatada writes. This
25
+ speeds up usage with Puma by about 20 percent, as there won't be as many `syswrite` calls on the socket.
26
+ * Make `StoredWriter` and `DeflatedWriter` public constants so that standalone tests can be written for them
27
+
28
+ ## 5.4.0
29
+
30
+ * Use block form for zlib Deflater calls to conserve memory
31
+ * Do not change string encoding in writer wrappers (avoid extra work)
32
+ * Fix a zlib deflater object being leaked per archived file
33
+ * Speed up streaming CRC32 computation
34
+ * When running tests, assign the port for the Puma server dynamically
35
+ * Reduce string allocations in the block deflate spec
36
+ * Make sure RemoteUncap specs run under JRuby correctly
37
+ * Replace Rails::Live streaming with iterable body streaming to avoid issues with Rails::Live across the board
38
+ * Remove `qa/` directory and scripts, as the tests for the library proper should now be sufficient
39
+ * Fix some documentation and sample code omissions and inconsistencies.
40
+
41
+ ## 5.3.1
42
+
43
+ * Fix extended timestamp timestamp value encoding. Previously we would use an incorrect encoding for the timestamp value, which would output correct but nonsensical timestamps. The pack specifier is now changed to output the correct value.
44
+
45
+ ## 5.3.0
46
+
47
+ * Raise in `Streamer#close` when the IO offset of the Streamer does not match the size of the written entries. This is a situation which
48
+ can occur if one adds the local headers, writes the bodies of the files to the socket/output directly, and forgets to adjust the internal
49
+ Streamer offset. The unadjusted offset would then produce incorrect values in both the local headers which come after the missing
50
+ offset adjustment _and_ in the central directory headers. Some ZIP unarchivers are able to recover from this (ones that read
51
+ files "straight-ahead" but others aren't - if the ZIP unarchiver uses central directory entries it would be using incorrect offsets.
52
+ Instead of producing an invalid ZIP, raise an exception which explains what happened and how it can be resolved.
53
+
54
+ ## 5.2.0
55
+
56
+ * Remove `Streamer#add_compressed_entry` and `SizeEstimator#add_compressed_entry`
57
+
58
+ ## 5.1.1
59
+
60
+ * Fix extended timestamp extra field output. The first bit of the flag would be set instead of the last bit of
61
+ the flag, which made it impossible for Rubyzip to read the timestamp of the entry - and it would also make
62
+ the extra field useless for most reading applications.
63
+
64
+ ## 5.1.0
65
+
66
+ * Slightly rework `RemoteIO` and `RemoteUncap` and make sure they work correctly by spinning up a test webserver
67
+ to verify their operation. The changes to the documented API are fairly small so this is still marked as a minor
68
+ release.
69
+
70
+ ## 5.0.0
71
+
72
+ * Disable automatic filename deduplication by default, because it does not play nice with file/directory
73
+ clobbering. The option can still be enabled by passing `auto_rename_duplicate_filenames: true` to the Streamer
74
+ and all modules that use it
75
+ * Adopt [Hippocratic license v. 1.2](https://firstdonoharm.dev/version/1/2/license.html)
76
+ Note that this might make the license conditions unacceptable for your project. If that is the case,
77
+ you can use the 4.x branch of the library which stays under the original, exact MIT license.
78
+
79
+ ## 4.8.0
80
+
81
+ * Make sure that when directories clobber files and vice versa we raise a clear error. Add `PathSet` which keeps track of entries
82
+ and all the directories needed to create them, document `PathSet`
83
+ * Move the `uniquify_filenames` function into a module for easier removal later
84
+ * Add the `auto_rename_duplicate_filenames` parameter to `Streamer` constructor. We need to make this optional
85
+ because making filenames unique can be very tricky when subdirectories are involved, and strictly
86
+ speaking we should not be applying this transformation at all - there should be no output of
87
+ duplicate filenames by the caller. So making the filenames should be available, but optional.
88
+
89
+ ## 4.7.4
90
+
91
+ * Use a single fixed capacity string in `StreamCRC32.from_io` to avoid unnecessary allocations
92
+ * Fix a few tests that were calling out to external binaries
93
+
94
+ ## 4.7.3
95
+
96
+ * Fix `RemoteUncap#request_object_size` to function correctly
97
+
98
+ ## 4.7.2
99
+
100
+ * Relax bundler dependency so that both bundler 1.x and 2.x are supported cleanly
101
+
102
+ ## 4.7.1
103
+
104
+ * Bump rubyzip to 1.2.2 to mitigate CVE-2018-1000544
105
+
106
+ ## 4.7.0
107
+
108
+ * Replace `RackBody` with `OutputEnumerator` since we want to provide a generic way of deferring ZIP output, also when using enumerators.
109
+ * Remove `RackBody#close` since we got nothing to close 🤷‍♂️
110
+ * Hint nginx that response buffering should be disabled when using Rails zip streaming
111
+
112
+ ## 4.6.0
113
+
114
+ * Add `mtime:` option to all Streamer methods for adding files and directories, to permit setting modification time per-entry
115
+ * Optimize EOCD signature lookup when reading archives
116
+ * Reformat using the [we_transfer_style](https://rubygems.org/gems/we_transfer_style) Rubocop rules and conventions
117
+ * Add code of conduct and contribution guidelines
118
+ * Reduce the size of the CRC32 buffer to 64KB (backed by a benchmark), extract buffering into a wrapper proxy
119
+
120
+ ## 4.5.2
121
+
122
+ * Replace the incorrectly used `file` type for empty directory entries with the appropriate `directory` type
123
+
124
+ ## 4.5.1
125
+
126
+ * Speed up CRC32 calculation using a buffer of 5MB (have to combine CRCs less often)
127
+
128
+ ## 4.5.0
129
+
130
+ * Rename `Streamer#add_compressed_entry` and `SizeEstimator#add_compressed_entry` to `add_deflated_entry`
131
+ to indicate the type of compression that is going to get used.
132
+ * Make `Streamer#write_(deflated|stored)_file` return a writable object that can be `.close`d, to
133
+ permit usage of those methods in situations where suspending a block is inconvenient (make deferred writing possible).
134
+ * Fix CRC32 checksums in `Streamer#write_deflated_file`
135
+ * Add `Streamer#update_last_entry_and_write_data_descriptor` to permit externally-driven flows that use data descriptors
136
+
137
+ ## 4.4.2
138
+
139
+ * Add 2.4 to Travis rubies
140
+ * Fix a severe performance degradation in Streamer with large file counts (https://github.com/WeTransfer/zip_kit/pull/14)
141
+
142
+ ## 4.4.1
143
+
144
+ * Tweak documentation a little
145
+
146
+ ## 4.4.0
147
+
148
+ * Add `Streamer#add_empty_directory_entry` for writing empty directories/folders into the ZIP
149
+
150
+ ## 4.3.0
151
+
152
+ * Add a native Rails streaming module for easier integration of ZipKit into Rails controllers
153
+
154
+ ## 4.2.4
155
+
156
+ * Get rid of Jeweler in favor of the standard Bundler/rubygems gem tasks
157
+
158
+ ## 4.2.3
159
+
160
+ * Instead of BlockWrite, use intrim flushes of the same zlib Deflater
161
+
162
+ ## 4.2.2
163
+
164
+ * Rewrite small data writes to perform less calls to `pack`
165
+
166
+ ## 4.2.1
167
+
168
+ * Uniquify filenames during writes, so that the caller doesn't have to.
169
+
170
+ ## 4.2.0
171
+
172
+ * Make it possible to swap the destination for Streamer writes, to improve `Range` support in the
173
+ download server. Sometimes it might be useful to actually "redirect" the output to a different IO
174
+ or buffer, without having to provide our own implementation of this switching.
175
+
176
+ ## 4.1.0
177
+
178
+ * Implement brute-force straight-ahead reading of local file headers, for damaged or
179
+ incomplete ZIP files
180
+
181
+ ## 4.0.0
182
+
183
+ * Make reading local headers optional, since we need it but we don't have to use it for all archives. Ideally
184
+ we should only do it when a reasonable central directory cannot be found. This can also happen under normal
185
+ usage, when we are dealing with a ZIP-within-a-ZIP or when the end of the ZIP file has been truncated on
186
+ write.
187
+ * Make sure `Writable#write` returns the number of bytes written (fix `IO.copy_stream` compatibility)
188
+
189
+ ## 3.1.1
190
+
191
+ * Fix reading Zip64 extra fields. Only read fields that have corresponding "normal" fields set to overflow value.
192
+
193
+ ## 3.1.0
194
+
195
+ * Fix `FileReader` failing where the EOCD marker would be detected multiple times at the end of a ZIP, which
196
+ is something that _can_ happen during normal usage - a byte pattern has to appear twice to trigger the bug.
197
+ * Add support for archive comment customization
198
+
199
+ ## 2.8.1
200
+
201
+ * Fix the bug with older versions of The Unarchiver refusing to open our Zip64 files
202
+
203
+ ## 2.8.0
204
+
205
+ * Replace RubyZip with a clean-room ZIP writer, due to the overly elaborate Java-esque structure of RubyZip being hostile
206
+ to modifications. The straw that broke the camel's back in this case is the insistence of RubyZip on writing out padding
207
+ for the Zip64 extra fields in the local entries that it would never replace with useful data, which was breaking unarchiving
208
+ when using Windows Explorer.
209
+
210
+ ## 2.7.0
211
+
212
+ * Add `Streamer#write` so that the Streamer can be used as argument to `IO.copy_stream`
213
+
214
+ ## 2.6.1
215
+
216
+ * Fi 0-byte reads in RemoteIO of RemoteUncap
217
+
218
+ ## 2.6.0
219
+
220
+ * Set up open-source facilities (Github, Travis CI...)
221
+ * Add RemoteUncap for listing ZIP archives located on HTTP servers without having to download them.
222
+ RemoteUncap downloads the central directory only using HTTP `Range` headers.
223
+
224
+ ## 2.5.0
225
+
226
+ * Add Manifest for building a map of the ZIP file (for later Range support)
227
+
228
+ ## 2.4.3 (Internal rel)
229
+
230
+ * Extract [very_tiny_state_machine](https://rubygems.org/gems/very_tiny_state_machine) gem from ZipKit
231
+
232
+ ## 2.4.1 (Internal rel)
233
+
234
+ * Include StreamCRC32 in the README
235
+
236
+ ## 2.3.1 (Internal rel)
237
+
238
+ * Restore a streaming CRC facility
239
+
240
+ ## 2.2.1 (Internal rel)
241
+
242
+ * Ensure WriteAndTell plays nice with strings in other encodings than BINARY
243
+
244
+ ## 2.2.0 (Internal rel)
245
+
246
+ * Fix bytes_written return from deflate_in_blocks
247
+ * Raise on invalid Streamer IO arguments
248
+ * Set the EFS flag for UTF-8 filenames
249
+ * Add a RackBody object for plugging ZipKit into Rack
250
+ * Add an offset wrapper for IOs given to Streamer, to support size estimation
251
+ * Ensure the given compression level is supported
252
+
253
+ ## 2.0.0 (Internal rel)
254
+
255
+ * Implements streaming zip based on RubyZip
@@ -0,0 +1,46 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to making participation in our project and our community a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, gender identity and expression, level of experience, nationality, personal appearance, race, religion, or sexual identity and orientation.
6
+
7
+ ## Our Standards
8
+
9
+ Examples of behavior that contributes to creating a positive environment include:
10
+
11
+ * Using welcoming and inclusive language
12
+ * Being respectful of differing viewpoints and experiences
13
+ * Gracefully accepting constructive criticism
14
+ * Focusing on what is best for the community
15
+ * Showing empathy towards other community members
16
+
17
+ Examples of unacceptable behavior by participants include:
18
+
19
+ * The use of sexualized language or imagery and unwelcome sexual attention or advances
20
+ * Trolling, insulting/derogatory comments, and personal or political attacks
21
+ * Public or private harassment
22
+ * Publishing others' private information, such as a physical or electronic address, without explicit permission
23
+ * Other conduct which could reasonably be considered inappropriate in a professional setting
24
+
25
+ ## Our Responsibilities
26
+
27
+ Project maintainers are responsible for clarifying the standards of acceptable behavior and are expected to take appropriate and fair corrective action in response to any instances of unacceptable behavior.
28
+
29
+ Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, or to ban temporarily or permanently any contributor for other behaviours that they deem inappropriate, threatening, offensive, or harmful.
30
+
31
+ ## Scope
32
+
33
+ This Code of Conduct applies both within project spaces and in public spaces when an individual is representing the project or its community. Examples of representing a project or community include using an official project e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. Representation of a project may be further defined and clarified by project maintainers.
34
+
35
+ ## Enforcement
36
+
37
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team at me@julik.nl. The project team will review and investigate all complaints, and will respond in a way that it deems appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. Further details of specific enforcement policies may be posted separately.
38
+
39
+ Project maintainers who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent repercussions as determined by other members of the project's leadership.
40
+
41
+ ## Attribution
42
+
43
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, available at [http://contributor-covenant.org/version/1/4][version]
44
+
45
+ [homepage]: http://contributor-covenant.org
46
+ [version]: http://contributor-covenant.org/version/1/4/
data/CONTRIBUTING.md ADDED
@@ -0,0 +1,153 @@
1
+ # Contributing to zip_kit
2
+
3
+ Please take a moment to review this document in order to make the contribution
4
+ process easy and effective for everyone involved.
5
+
6
+ Following these guidelines helps to communicate that you respect the time of
7
+ the developers managing and developing this open source project. In return,
8
+ they should reciprocate that respect in addressing your issue or assessing
9
+ patches and features.
10
+
11
+ ## What do I need to know to help?
12
+
13
+ If you are already familiar with the [Ruby Programming Language](https://www.ruby-lang.org/) you can start contributing code right away, otherwise look for issues labeled with *documentation* or *good first issue* to get started.
14
+
15
+ If you are interested in contributing code and would like to learn more about the technologies that we use, check out the (non-exhaustive) list below. You can also get in touch with us via an issue or email to get additional information.
16
+
17
+ - [ruby](https://ruby-doc.org)
18
+ - [rubyzip](https://github.com/rubyzip/rubyzip) as we like to test "our implementation against theirs"
19
+ - [rspec](http://rspec.info/) and [appraisal]() https://github.com/thoughtbot/appraisal) for testing
20
+ - [zip files](https://en.wikipedia.org/wiki/Zip_(file_format))
21
+
22
+ # How do I make a contribution?
23
+
24
+ ## Using the issue tracker
25
+
26
+ The issue tracker is the preferred channel for [bug reports](#bug-reports),
27
+ [feature requests](#feature-requests) and [submitting pull
28
+ requests](#pull-requests), but please respect the following restrictions:
29
+
30
+ * Please **do not** derail or troll issues. Keep the discussion on topic and respect the opinions of others. Adhere to the principles set out in the [Code of Conduct](https://github.com/WeTransfer/zip_kit/blob/main/CODE_OF_CONDUCT.md).
31
+
32
+ ## Bug reports
33
+
34
+ A bug is a _demonstrable problem_ that is caused by code in the repository.
35
+
36
+ Good bug reports are extremely helpful-thank you!
37
+
38
+ Guidelines for bug reports:
39
+
40
+ 1. **Use the GitHub issue search** &mdash; check if the issue has already been
41
+ reported.
42
+
43
+ 2. **Check if the issue has been fixed** &mdash; try to reproduce it using the
44
+ latest `main` branch in the repository.
45
+
46
+ 3. **Isolate the problem** &mdash; create a [reduced test
47
+ case](http://css-tricks.com/reduced-test-cases/) and a live example.
48
+
49
+ A good bug report shouldn't leave others needing to chase you up for more
50
+ information. Please try to be as detailed as possible in your report. What is
51
+ your environment? What steps will reproduce the issue? What tool(s) or OS will
52
+ experience the problem? What would you expect to be the outcome? All these
53
+ details will help people to fix any potential bugs.
54
+
55
+ Example:
56
+
57
+ > Short and descriptive example bug report title
58
+ >
59
+ > A summary of the issue and the OS environment in which it occurs. If
60
+ > suitable, include the steps required to reproduce the bug.
61
+ >
62
+ > 1. This is the first step
63
+ > 2. This is the second step
64
+ > 3. Further steps, etc.
65
+ >
66
+ > `<url>` - a link to the reduced test case, if possible. Feel free to use a [Gist](https://gist.github.com).
67
+ >
68
+ > Any other information you want to share that is relevant to the issue being
69
+ > reported. This might include the lines of code that you have identified as
70
+ > causing the bug, and potential solutions (and your opinions on their
71
+ > merits).
72
+
73
+
74
+ ## Feature requests
75
+
76
+ Feature requests are welcome. But take a moment to find out whether your idea
77
+ fits with the scope and aims of the project. It's up to *you* to make a strong
78
+ case to convince the project's developers of the merits of this feature. Please
79
+ provide as much detail and context as possible.
80
+
81
+
82
+ ## Pull requests
83
+
84
+ Good pull requests-patches, improvements, new features-are a fantastic
85
+ help. They should remain focused in scope and avoid containing unrelated
86
+ commits.
87
+
88
+ **Please ask first** before embarking on any significant pull request (e.g.
89
+ implementing features, refactoring code, porting to a different language),
90
+ otherwise you risk spending a lot of time working on something that the
91
+ project's developers might not want to merge into the project.
92
+
93
+ Please adhere to the coding conventions used throughout the project (indentation,
94
+ accurate comments, etc.) and any other requirements (such as test coverage).
95
+
96
+ The project uses Rubocop which can be run using `bundle exec rubocop`. The test
97
+ suite can be run with `bundle exec rspec`. You are also encouraged to use the
98
+ script in the `testing` directory to create test files that you can then verify
99
+ with various zip/unzip utilities. Further instructions are [here](https://github.com/WeTransfer/zip_kit/blob/main/testing/README_TESTING.md).
100
+
101
+ Follow this process if you'd like your work considered for inclusion in the
102
+ project:
103
+
104
+ 1. [Fork](http://help.github.com/fork-a-repo/) the project, clone your fork,
105
+ and configure the remotes:
106
+
107
+ ```bash
108
+ # Clone your fork of the repo into the current directory
109
+ git clone git@github.com:WeTransfer/zip_kit.git
110
+ # Navigate to the newly cloned directory
111
+ cd zip_kit
112
+ # Assign the original repo to a remote called "upstream"
113
+ git remote add upstream git@github.com:WeTransfer/zip_kit.git
114
+ ```
115
+
116
+ 2. If you cloned a while ago, get the latest changes from upstream:
117
+
118
+ ```bash
119
+ git checkout <dev-branch>
120
+ git pull upstream <dev-branch>
121
+ ```
122
+
123
+ 3. Create a new topic branch (off the main project development branch) to
124
+ contain your feature, change, or fix:
125
+
126
+ ```bash
127
+ git checkout -b <topic-branch-name>
128
+ ```
129
+
130
+ 4. Commit your changes in logical chunks and/or squash them for readability and
131
+ conciseness. Check out [this post](https://chris.beams.io/posts/git-commit/) or
132
+ [this other post](http://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html) for some tips re: writing good commit messages.
133
+
134
+ 5. Locally merge (or rebase) the upstream development branch into your topic branch:
135
+
136
+ ```bash
137
+ git pull [--rebase] upstream <dev-branch>
138
+ ```
139
+
140
+ 6. Push your topic branch up to your fork:
141
+
142
+ ```bash
143
+ git push origin <topic-branch-name>
144
+ ```
145
+
146
+ Make sure to run `bundle exec appraisal rspec` to make sure your changes are compatible with all the Rails versions we support.
147
+
148
+ 7. [Open a Pull Request](https://help.github.com/articles/using-pull-requests/)
149
+ with a clear title and description.
150
+
151
+ **IMPORTANT**: By submitting a patch, you agree to allow the project owner to
152
+ license your work under the same license as that used by the project, which you
153
+ can see by clicking [here](LICENSE.txt).
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "https://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in zip_kit.gemspec
4
+ gemspec