zip_tricks 4.5.2 → 4.6.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3ce4c704f1804988604b5d2f284ba0c4d3bc895d
4
- data.tar.gz: a552adf97b21cffa0d060fd6932d143f5a0ee7a2
3
+ metadata.gz: 387773a063a44c69ac3da83da89fe85731c78331
4
+ data.tar.gz: 96d6763cc05e7c21f206ecaa013786f822df0d42
5
5
  SHA512:
6
- metadata.gz: 9292155b3b566695087807d9ca31dbc359866996c45a7467bd1e365f3eb0f1b6789990dea7eba88fe901dcade7e1874903fe467e1cc523168963b771106c8c0e
7
- data.tar.gz: d5e95f1279ba5437334531ba741af474271972d256491b6ac774e4354fc28409e0bb2df033569a9ee55cbbfd8895795cee98886e24e384df277bc468b9bd2597
6
+ metadata.gz: 80f07ed5042f76c6e0edf5843a4b51ee468bde57d5fc4ab28b0a53f9f819a1160e339126173ebbe306add30902ac69270d271e61c81aab5a3261098b5ed79b1c
7
+ data.tar.gz: 8203289c9445f009f65ccaa924a7b07f1ecb5257ac9cb4d7fc6ce7a2204e49ed125cba6c4d1345a933203aa61ab562fe2d40b3bab3db074fccc5141636eb8c2e
data/.rubocop.yml CHANGED
@@ -1,82 +1,10 @@
1
- inherit_from: .rubocop_todo.yml
2
-
3
- Metrics/LineLength:
4
- Max: 120
5
-
6
- AllCops:
7
- Exclude:
8
- - spec/**/*.rb
9
- - zip_tricks.gemspec
10
- - Gemfile
11
- - Rakefile
12
- - vendor/**/*
13
- - julik_scratchpad/**/*
14
-
15
- Style/ClassAndModuleChildren:
16
- Enabled:
17
- false
18
-
19
- # "begin; ... rescue; end " without saying that we only rescue StandardError and below.
20
- # Can be debated, but I think it is reasonable to expect any Rubyist to know what errors
21
- # the standard rescue clause covers.
22
- Lint/RescueWithoutErrorClass:
23
- Enabled: false
24
-
25
- Lint/AssignmentInCondition:
26
- Enabled: false
27
-
28
- # We use % all over and nothing ever came out of it
29
- Style/FormatString:
1
+ inherit_gem:
2
+ wetransfer_style: ruby/default.yml
3
+ Layout/FirstMethodArgumentLineBreak:
30
4
  Enabled: false
31
-
32
- # We have classes with methods having long bodies. We apply a lot of literal small
33
- # operations which have to be applied in one locality specifically. Additionally,
34
- # class length is a bit of a boilerplate metric
35
- Metrics/ClassLength:
5
+ Layout/FirstMethodParameterLineBreak:
36
6
  Enabled: false
37
-
38
- # Idem. We have quite some methods that do a lot of small writes/reads in rapid
39
- # succession - not because those methods have high cyclomatic complexity, but
40
- # because they perform a single operation consisting of many sequential small
41
- # ones.
42
- Metrics/MethodLength:
43
- Enabled: false
44
-
45
- Metrics/AbcSize:
46
- Exclude:
47
- - examples/rack_application.rb
48
- - lib/zip_tricks/file_reader.rb
49
- - lib/zip_tricks/remote_io.rb
50
- - lib/zip_tricks/streamer.rb
51
- - testing/support.rb
52
-
53
- Metrics/BlockLength:
54
- Exclude:
55
- - lib/zip_tricks/file_reader.rb
56
-
57
- Layout/MultilineOperationIndentation:
58
- Exclude:
59
- - lib/zip_tricks/file_reader.rb
60
-
61
- Metrics/ParameterLists:
62
- Exclude:
63
- - lib/zip_tricks/streamer.rb
64
-
65
7
  Style/GlobalVars:
66
8
  Exclude:
67
- - testing/generate_test_files.rb
68
- - testing/support.rb
69
-
70
- # The advice this cop gives varies depending on the Ruby version,
71
- # so no - I will not be following two conflicting recommendations.
72
- Style/MutableConstant:
73
- Enabled: false
74
-
75
- Layout/SpaceInsideHashLiteralBraces:
76
- EnforcedStyle: no_space
77
-
78
- Style/Alias:
79
- EnforcedStyle: prefer_alias_method
80
-
81
- Style/ZeroLengthPredicate:
82
- Enabled: false # Does not work for StringIOs
9
+ - qa/*.rb
10
+ - spec/spec_helper.rb
data/.travis.yml CHANGED
@@ -1,14 +1,18 @@
1
1
  rvm:
2
2
  - 2.1
3
- - 2.2
4
- - 2.3.0
5
- - 2.4.1
3
+ - 2.2.10
4
+ - 2.3.7
5
+ - 2.4.4
6
+ - 2.5.1
6
7
  - jruby-9.0
7
8
  sudo: false
8
9
  cache: bundler
10
+ before_install:
11
+ - gem update --system
12
+ - gem install bundler # https://github.com/travis-ci/travis-ci/issues/9333
9
13
  matrix:
10
14
  allow_failures:
11
15
  - rvm: jruby-9.0
12
16
  script:
13
- - bundle exec rubocop -c .rubocop.yml --force-exclusion
14
17
  - bundle exec rspec
18
+ - bundle exec rubocop
data/CHANGELOG.md CHANGED
@@ -1,3 +1,15 @@
1
+ ## 4.6.0
2
+
3
+ * Add `mtime:` option to all Streamer methods for adding files and directories, to permit setting modification time per-entry
4
+ * Optimize EOCD signature lookup when reading archives
5
+ * Reformat using the [we_transfer_style](https://rubygems.org/gems/we_transfer_style) Rubocop rules and conventions
6
+ * Add code of conduct and contribution guidelines
7
+ * Reduce the size of the CRC32 buffer to 64KB (backed by a benchmark), extract buffering into a wrapper proxy
8
+
9
+ ## 4.5.2
10
+
11
+ * Replace the incorrectly used `file` type for empty directory entries with the appropriate `directory` type
12
+
1
13
  ## 4.5.1
2
14
 
3
15
  * Speed up CRC32 calculation using a buffer of 5MB (have to combine CRCs less often)
@@ -83,7 +95,7 @@
83
95
  to modifications. The straw that broke the camel's back in this case is the insistence of RubyZip on writing out padding
84
96
  for the Zip64 extra fields in the local entries that it would never replace with useful data, which was breaking unarchiving
85
97
  when using Windows Explorer.
86
-
98
+
87
99
  ## 2.7.0
88
100
 
89
101
  * Add `Streamer#write` so that the Streamer can be used as argument to `IO.copy_stream`
@@ -129,4 +141,4 @@
129
141
 
130
142
  ## 2.0.0 (Internal rel)
131
143
 
132
- * Implements streaming zip based on RubyZip
144
+ * 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 behaviors 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 julik@wetransfer.com and/or noah@wetransfer.com. 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,151 @@
1
+ # Contributing to zip_tricks
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)
19
+ - [rspec](http://rspec.info/) (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_tricks/blob/master/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** — check if the issue has already been
41
+ reported.
42
+
43
+ 2. **Check if the issue has been fixed** — try to reproduce it using the
44
+ latest `master` branch in the repository.
45
+
46
+ 3. **Isolate the problem** — 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_tricks/blob/master/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_tricks.git
110
+ # Navigate to the newly cloned directory
111
+ cd zip_tricks
112
+ # Assign the original repo to a remote called "upstream"
113
+ git remote add upstream git@github.com:WeTransfer/zip_tricks.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
+ 7. [Open a Pull Request](https://help.github.com/articles/using-pull-requests/)
147
+ with a clear title and description.
148
+
149
+ **IMPORTANT**: By submitting a patch, you agree to allow the project owner to
150
+ license your work under the same license as that used by the project, which you
151
+ can see by clicking [here](https://github.com/WeTransfer/zip_tricks/blob/master/LICENSE.txt).
data/README.md CHANGED
@@ -167,7 +167,7 @@ that have not been formally verified (ours hasn't been).
167
167
  * Commit and push until you are happy with your contribution.
168
168
  * Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
169
169
  * Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
170
- * If you alter the `ZipWriter`, please take the time to run the test in the `testing/` directory and verify the generated files do open. You will need fast storage to run those tests.
170
+ * If you alter the `ZipWriter`, please take the time to run the test in the `qa/` directory. Ensure that the generated (large) files open manually - see README_QA for more.
171
171
 
172
172
  ## Copyright
173
173
 
@@ -0,0 +1,111 @@
1
+ require 'bundler'
2
+ Bundler.setup
3
+
4
+ require 'benchmark'
5
+ require 'benchmark/ips'
6
+ require_relative '../lib/zip_tricks'
7
+
8
+ n_bytes = 5 * 1024 * 1024
9
+ r = Random.new
10
+ bytes = (0...n_bytes).map { r.bytes(1) }
11
+ buffer_sizes = [
12
+ 1,
13
+ 256,
14
+ 512,
15
+ 1024,
16
+ 8 * 1024,
17
+ 16 * 1024,
18
+ 32 * 1024,
19
+ 64 * 1024,
20
+ 128 * 1024,
21
+ 256 * 1024,
22
+ 512 * 1024,
23
+ 1024 * 1024,
24
+ 2 * 1024 * 1024
25
+ ]
26
+
27
+ require 'benchmark/ips'
28
+
29
+ Benchmark.ips do |x|
30
+ x.config(time: 5, warmup: 2)
31
+ buffer_sizes.each do |buf_size|
32
+ x.report "Single-byte <<-writes of #{n_bytes} using a #{buf_size} byte buffer" do
33
+ crc = ZipTricks::WriteBuffer.new(ZipTricks::StreamCRC32.new, buf_size)
34
+ bytes.each { |b| crc << b }
35
+ crc.to_i
36
+ end
37
+ end
38
+ x.compare!
39
+ end
40
+
41
+ __END__
42
+
43
+ Warming up --------------------------------------
44
+ Single-byte <<-writes of 5242880 using a 1 byte buffer
45
+ 1.000 i/100ms
46
+ Single-byte <<-writes of 5242880 using a 256 byte buffer
47
+ 1.000 i/100ms
48
+ Single-byte <<-writes of 5242880 using a 512 byte buffer
49
+ 1.000 i/100ms
50
+ Single-byte <<-writes of 5242880 using a 1024 byte buffer
51
+ 1.000 i/100ms
52
+ Single-byte <<-writes of 5242880 using a 8192 byte buffer
53
+ 1.000 i/100ms
54
+ Single-byte <<-writes of 5242880 using a 16384 byte buffer
55
+ 1.000 i/100ms
56
+ Single-byte <<-writes of 5242880 using a 32768 byte buffer
57
+ 1.000 i/100ms
58
+ Single-byte <<-writes of 5242880 using a 65536 byte buffer
59
+ 1.000 i/100ms
60
+ Single-byte <<-writes of 5242880 using a 131072 byte buffer
61
+ 1.000 i/100ms
62
+ Single-byte <<-writes of 5242880 using a 262144 byte buffer
63
+ 1.000 i/100ms
64
+ Single-byte <<-writes of 5242880 using a 524288 byte buffer
65
+ 1.000 i/100ms
66
+ Single-byte <<-writes of 5242880 using a 1048576 byte buffer
67
+ 1.000 i/100ms
68
+ Single-byte <<-writes of 5242880 using a 2097152 byte buffer
69
+ 1.000 i/100ms
70
+ Calculating -------------------------------------
71
+ Single-byte <<-writes of 5242880 using a 1 byte buffer
72
+ 0.054 (± 0.0%) i/s - 1.000 in 18.383019s
73
+ Single-byte <<-writes of 5242880 using a 256 byte buffer
74
+ 0.121 (± 0.0%) i/s - 1.000 in 8.286061s
75
+ Single-byte <<-writes of 5242880 using a 512 byte buffer
76
+ 0.124 (± 0.0%) i/s - 1.000 in 8.038112s
77
+ Single-byte <<-writes of 5242880 using a 1024 byte buffer
78
+ 0.128 (± 0.0%) i/s - 1.000 in 7.828562s
79
+ Single-byte <<-writes of 5242880 using a 8192 byte buffer
80
+ 0.123 (± 0.0%) i/s - 1.000 in 8.121586s
81
+ Single-byte <<-writes of 5242880 using a 16384 byte buffer
82
+ 0.127 (± 0.0%) i/s - 1.000 in 7.872240s
83
+ Single-byte <<-writes of 5242880 using a 32768 byte buffer
84
+ 0.126 (± 0.0%) i/s - 1.000 in 7.911816s
85
+ Single-byte <<-writes of 5242880 using a 65536 byte buffer
86
+ 0.126 (± 0.0%) i/s - 1.000 in 7.917318s
87
+ Single-byte <<-writes of 5242880 using a 131072 byte buffer
88
+ 0.127 (± 0.0%) i/s - 1.000 in 7.897223s
89
+ Single-byte <<-writes of 5242880 using a 262144 byte buffer
90
+ 0.130 (± 0.0%) i/s - 1.000 in 7.675608s
91
+ Single-byte <<-writes of 5242880 using a 524288 byte buffer
92
+ 0.130 (± 0.0%) i/s - 1.000 in 7.679886s
93
+ Single-byte <<-writes of 5242880 using a 1048576 byte buffer
94
+ 0.128 (± 0.0%) i/s - 1.000 in 7.788439s
95
+ Single-byte <<-writes of 5242880 using a 2097152 byte buffer
96
+ 0.128 (± 0.0%) i/s - 1.000 in 7.797839s
97
+
98
+ Comparison:
99
+ Single-byte <<-writes of 5242880 using a 262144 byte buffer: 0.1 i/s
100
+ Single-byte <<-writes of 5242880 using a 524288 byte buffer: 0.1 i/s - 1.00x slower
101
+ Single-byte <<-writes of 5242880 using a 1048576 byte buffer: 0.1 i/s - 1.01x slower
102
+ Single-byte <<-writes of 5242880 using a 2097152 byte buffer: 0.1 i/s - 1.02x slower
103
+ Single-byte <<-writes of 5242880 using a 1024 byte buffer: 0.1 i/s - 1.02x slower
104
+ Single-byte <<-writes of 5242880 using a 16384 byte buffer: 0.1 i/s - 1.03x slower
105
+ Single-byte <<-writes of 5242880 using a 131072 byte buffer: 0.1 i/s - 1.03x slower
106
+ Single-byte <<-writes of 5242880 using a 32768 byte buffer: 0.1 i/s - 1.03x slower
107
+ Single-byte <<-writes of 5242880 using a 65536 byte buffer: 0.1 i/s - 1.03x slower
108
+ Single-byte <<-writes of 5242880 using a 512 byte buffer: 0.1 i/s - 1.05x slower
109
+ Single-byte <<-writes of 5242880 using a 8192 byte buffer: 0.1 i/s - 1.06x slower
110
+ Single-byte <<-writes of 5242880 using a 256 byte buffer: 0.1 i/s - 1.08x slower
111
+ Single-byte <<-writes of 5242880 using a 1 byte buffer: 0.1 i/s - 2.39x slower