tar 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +9 -0
- data/.rubocop.yml +40 -0
- data/.ruby-version +1 -0
- data/.travis.yml +8 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/Gemfile +6 -0
- data/LICENSE.txt +21 -0
- data/README.md +68 -0
- data/Rakefile +16 -0
- data/bin/console +8 -0
- data/bin/setup +6 -0
- data/lib/char_size.rb +123 -0
- data/lib/tar.rb +4 -0
- data/lib/tar/backports.rb +51 -0
- data/lib/tar/error.rb +11 -0
- data/lib/tar/file_reader.rb +357 -0
- data/lib/tar/file_reader/line.rb +122 -0
- data/lib/tar/header.rb +58 -0
- data/lib/tar/header_reader.rb +37 -0
- data/lib/tar/polyfills.rb +14 -0
- data/lib/tar/reader.rb +30 -0
- data/lib/tar/schema.rb +87 -0
- data/lib/tar/ustar.rb +27 -0
- data/lib/tar/version.rb +5 -0
- data/tar.gemspec +28 -0
- metadata +139 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 5fc0388fb9c71adc340179c36a4cc5513b883bc9
|
4
|
+
data.tar.gz: fcaecab867effc1ea47fcb50b9a1716487190eea
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 8ab2e208e1a6dc24bff1287d5d8d2df88d7ede28e60206c77c6d81c6cc6a5ac70c2068d2017c257034b482be7b2f8741b504d961324b03c214e156e21b1af43b
|
7
|
+
data.tar.gz: 7d7f8edfdd0c6aab371de136698e76d59e2dca14c7906bbaef66c893c8285b299023e2407ed7c15bb7d1b896719f3a068dae70f415aabd8f29ddd3eb8ed63b47
|
data/.gitignore
ADDED
data/.rubocop.yml
ADDED
@@ -0,0 +1,40 @@
|
|
1
|
+
AllCops:
|
2
|
+
TargetRubyVersion: 2.4
|
3
|
+
|
4
|
+
Metrics/AbcSize:
|
5
|
+
Enabled: false
|
6
|
+
|
7
|
+
Metrics/ClassLength:
|
8
|
+
Enabled: false
|
9
|
+
|
10
|
+
Metrics/LineLength:
|
11
|
+
Enabled: false
|
12
|
+
|
13
|
+
Metrics/MethodLength:
|
14
|
+
Enabled: false
|
15
|
+
|
16
|
+
Metrics/ModuleLength:
|
17
|
+
Enabled: false
|
18
|
+
|
19
|
+
Style/BlockDelimiters:
|
20
|
+
EnforcedStyle: semantic
|
21
|
+
|
22
|
+
Style/Documentation:
|
23
|
+
Enabled: false
|
24
|
+
|
25
|
+
Style/HashSyntax:
|
26
|
+
Exclude:
|
27
|
+
- Rakefile
|
28
|
+
|
29
|
+
Style/NumericPredicate:
|
30
|
+
Exclude:
|
31
|
+
- lib/tar/backports.rb
|
32
|
+
|
33
|
+
Style/StringLiterals:
|
34
|
+
EnforcedStyle: double_quotes
|
35
|
+
|
36
|
+
Style/SymbolArray:
|
37
|
+
EnforcedStyle: brackets
|
38
|
+
|
39
|
+
Style/WordArray:
|
40
|
+
EnforcedStyle: brackets
|
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
ruby-2.4.1
|
data/.travis.yml
ADDED
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,74 @@
|
|
1
|
+
# Contributor Covenant Code of Conduct
|
2
|
+
|
3
|
+
## Our Pledge
|
4
|
+
|
5
|
+
In the interest of fostering an open and welcoming environment, we as
|
6
|
+
contributors and maintainers pledge to making participation in our project and
|
7
|
+
our community a harassment-free experience for everyone, regardless of age, body
|
8
|
+
size, disability, ethnicity, gender identity and expression, level of experience,
|
9
|
+
nationality, personal appearance, race, religion, or sexual identity and
|
10
|
+
orientation.
|
11
|
+
|
12
|
+
## Our Standards
|
13
|
+
|
14
|
+
Examples of behavior that contributes to creating a positive environment
|
15
|
+
include:
|
16
|
+
|
17
|
+
* Using welcoming and inclusive language
|
18
|
+
* Being respectful of differing viewpoints and experiences
|
19
|
+
* Gracefully accepting constructive criticism
|
20
|
+
* Focusing on what is best for the community
|
21
|
+
* Showing empathy towards other community members
|
22
|
+
|
23
|
+
Examples of unacceptable behavior by participants include:
|
24
|
+
|
25
|
+
* The use of sexualized language or imagery and unwelcome sexual attention or
|
26
|
+
advances
|
27
|
+
* Trolling, insulting/derogatory comments, and personal or political attacks
|
28
|
+
* Public or private harassment
|
29
|
+
* Publishing others' private information, such as a physical or electronic
|
30
|
+
address, without explicit permission
|
31
|
+
* Other conduct which could reasonably be considered inappropriate in a
|
32
|
+
professional setting
|
33
|
+
|
34
|
+
## Our Responsibilities
|
35
|
+
|
36
|
+
Project maintainers are responsible for clarifying the standards of acceptable
|
37
|
+
behavior and are expected to take appropriate and fair corrective action in
|
38
|
+
response to any instances of unacceptable behavior.
|
39
|
+
|
40
|
+
Project maintainers have the right and responsibility to remove, edit, or
|
41
|
+
reject comments, commits, code, wiki edits, issues, and other contributions
|
42
|
+
that are not aligned to this Code of Conduct, or to ban temporarily or
|
43
|
+
permanently any contributor for other behaviors that they deem inappropriate,
|
44
|
+
threatening, offensive, or harmful.
|
45
|
+
|
46
|
+
## Scope
|
47
|
+
|
48
|
+
This Code of Conduct applies both within project spaces and in public spaces
|
49
|
+
when an individual is representing the project or its community. Examples of
|
50
|
+
representing a project or community include using an official project e-mail
|
51
|
+
address, posting via an official social media account, or acting as an appointed
|
52
|
+
representative at an online or offline event. Representation of a project may be
|
53
|
+
further defined and clarified by project maintainers.
|
54
|
+
|
55
|
+
## Enforcement
|
56
|
+
|
57
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
58
|
+
reported by contacting the project team at andrew@haines.org.nz. All
|
59
|
+
complaints will be reviewed and investigated and will result in a response that
|
60
|
+
is deemed necessary and appropriate to the circumstances. The project team is
|
61
|
+
obligated to maintain confidentiality with regard to the reporter of an incident.
|
62
|
+
Further details of specific enforcement policies may be posted separately.
|
63
|
+
|
64
|
+
Project maintainers who do not follow or enforce the Code of Conduct in good
|
65
|
+
faith may face temporary or permanent repercussions as determined by other
|
66
|
+
members of the project's leadership.
|
67
|
+
|
68
|
+
## Attribution
|
69
|
+
|
70
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
|
71
|
+
available at [http://contributor-covenant.org/version/1/4][version]
|
72
|
+
|
73
|
+
[homepage]: http://contributor-covenant.org
|
74
|
+
[version]: http://contributor-covenant.org/version/1/4/
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2017 Andrew Haines
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,68 @@
|
|
1
|
+
# Tar
|
2
|
+
|
3
|
+
[![Latest version](https://img.shields.io/gem/v/tar.svg?style=flat-square)](https://rubygems.org/gems/tar)
|
4
|
+
[![Travis CI status](https://img.shields.io/travis/haines/tar.svg?style=flat-square)](https://travis-ci.org/haines/tar)
|
5
|
+
[![Code Climate GPA](https://img.shields.io/codeclimate/github/haines/tar.svg?style=flat-square)](https://codeclimate.com/github/haines/tar)
|
6
|
+
[![Test coverage](https://img.shields.io/codeclimate/coverage/github/haines/tar.svg?style=flat-square)](https://codeclimate.com/github/haines/tar/coverage)
|
7
|
+
|
8
|
+
Read and write tar files with Ruby.
|
9
|
+
|
10
|
+
|
11
|
+
## Installation
|
12
|
+
|
13
|
+
Add this line to your application's Gemfile:
|
14
|
+
|
15
|
+
```ruby
|
16
|
+
gem "tar"
|
17
|
+
```
|
18
|
+
|
19
|
+
And then execute:
|
20
|
+
|
21
|
+
```console
|
22
|
+
$ bundle
|
23
|
+
```
|
24
|
+
|
25
|
+
Or install it yourself as:
|
26
|
+
|
27
|
+
```console
|
28
|
+
$ gem install tar
|
29
|
+
```
|
30
|
+
|
31
|
+
|
32
|
+
## Usage
|
33
|
+
|
34
|
+
### Reading tar files
|
35
|
+
|
36
|
+
Tar files can be read from IO streams, for example `File`s or `Zlib::GzipReader`s, using a `Tar::Reader`.
|
37
|
+
For example, to print the contents of the archive to stdout:
|
38
|
+
|
39
|
+
```ruby
|
40
|
+
require "tar/reader"
|
41
|
+
|
42
|
+
File.open "example.tar" do |archive|
|
43
|
+
Tar::Reader.new(archive).each do |file|
|
44
|
+
puts "==> #{file.header.path} (#{file.header.size} bytes)"
|
45
|
+
puts file.read
|
46
|
+
end
|
47
|
+
end
|
48
|
+
```
|
49
|
+
|
50
|
+
## Development
|
51
|
+
|
52
|
+
After checking out the repo, run `bin/setup` to install dependencies.
|
53
|
+
Then, run `bundle exec rake` to run the tests.
|
54
|
+
You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
55
|
+
|
56
|
+
To install this gem onto your local machine, run `bundle exec rake install`.
|
57
|
+
To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
58
|
+
|
59
|
+
|
60
|
+
## Contributing
|
61
|
+
|
62
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/haines/tar.
|
63
|
+
This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
64
|
+
|
65
|
+
|
66
|
+
## License
|
67
|
+
|
68
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
data/Rakefile
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "bundler/gem_tasks"
|
4
|
+
require "rake/testtask"
|
5
|
+
|
6
|
+
Rake::TestTask.new(:test) do |t|
|
7
|
+
t.test_files = FileList["test/**/*_test.rb"]
|
8
|
+
t.warning = true
|
9
|
+
end
|
10
|
+
|
11
|
+
if RUBY_ENGINE == "ruby"
|
12
|
+
require "char_size/rake/generator_task"
|
13
|
+
CharSize::Rake::GeneratorTask.new
|
14
|
+
end
|
15
|
+
|
16
|
+
task :default => :test
|
data/bin/console
ADDED
data/bin/setup
ADDED
data/lib/char_size.rb
ADDED
@@ -0,0 +1,123 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# This module was generated using the CharSize gem.
|
4
|
+
# To regenerate, run
|
5
|
+
# rake char_size
|
6
|
+
module CharSize
|
7
|
+
CHAR_SIZES = {
|
8
|
+
"ASCII-8BIT" => [1, 1].freeze,
|
9
|
+
"UTF-8" => [1, 4].freeze,
|
10
|
+
"US-ASCII" => [1, 1].freeze,
|
11
|
+
"UTF-16BE" => [2, 4].freeze,
|
12
|
+
"UTF-16LE" => [2, 4].freeze,
|
13
|
+
"UTF-32BE" => [4, 4].freeze,
|
14
|
+
"UTF-32LE" => [4, 4].freeze,
|
15
|
+
"UTF-16" => [2, 4].freeze,
|
16
|
+
"UTF-32" => [4, 4].freeze,
|
17
|
+
"UTF8-MAC" => [1, 4].freeze,
|
18
|
+
"EUC-JP" => [1, 3].freeze,
|
19
|
+
"Windows-31J" => [1, 2].freeze,
|
20
|
+
"Big5" => [1, 2].freeze,
|
21
|
+
"Big5-HKSCS" => [1, 2].freeze,
|
22
|
+
"Big5-UAO" => [1, 2].freeze,
|
23
|
+
"CP949" => [1, 2].freeze,
|
24
|
+
"Emacs-Mule" => [1, 4].freeze,
|
25
|
+
"EUC-KR" => [1, 2].freeze,
|
26
|
+
"EUC-TW" => [1, 4].freeze,
|
27
|
+
"GB2312" => [1, 2].freeze,
|
28
|
+
"GB18030" => [1, 4].freeze,
|
29
|
+
"GBK" => [1, 2].freeze,
|
30
|
+
"ISO-8859-1" => [1, 1].freeze,
|
31
|
+
"ISO-8859-2" => [1, 1].freeze,
|
32
|
+
"ISO-8859-3" => [1, 1].freeze,
|
33
|
+
"ISO-8859-4" => [1, 1].freeze,
|
34
|
+
"ISO-8859-5" => [1, 1].freeze,
|
35
|
+
"ISO-8859-6" => [1, 1].freeze,
|
36
|
+
"ISO-8859-7" => [1, 1].freeze,
|
37
|
+
"ISO-8859-8" => [1, 1].freeze,
|
38
|
+
"ISO-8859-9" => [1, 1].freeze,
|
39
|
+
"ISO-8859-10" => [1, 1].freeze,
|
40
|
+
"ISO-8859-11" => [1, 1].freeze,
|
41
|
+
"ISO-8859-13" => [1, 1].freeze,
|
42
|
+
"ISO-8859-14" => [1, 1].freeze,
|
43
|
+
"ISO-8859-15" => [1, 1].freeze,
|
44
|
+
"ISO-8859-16" => [1, 1].freeze,
|
45
|
+
"KOI8-R" => [1, 1].freeze,
|
46
|
+
"KOI8-U" => [1, 1].freeze,
|
47
|
+
"Shift_JIS" => [1, 2].freeze,
|
48
|
+
"Windows-1250" => [1, 1].freeze,
|
49
|
+
"Windows-1251" => [1, 1].freeze,
|
50
|
+
"Windows-1252" => [1, 1].freeze,
|
51
|
+
"Windows-1253" => [1, 1].freeze,
|
52
|
+
"Windows-1254" => [1, 1].freeze,
|
53
|
+
"Windows-1257" => [1, 1].freeze,
|
54
|
+
"IBM437" => [1, 1].freeze,
|
55
|
+
"IBM737" => [1, 1].freeze,
|
56
|
+
"IBM775" => [1, 1].freeze,
|
57
|
+
"CP850" => [1, 1].freeze,
|
58
|
+
"IBM852" => [1, 1].freeze,
|
59
|
+
"CP852" => [1, 1].freeze,
|
60
|
+
"IBM855" => [1, 1].freeze,
|
61
|
+
"CP855" => [1, 1].freeze,
|
62
|
+
"IBM857" => [1, 1].freeze,
|
63
|
+
"IBM860" => [1, 1].freeze,
|
64
|
+
"IBM861" => [1, 1].freeze,
|
65
|
+
"IBM862" => [1, 1].freeze,
|
66
|
+
"IBM863" => [1, 1].freeze,
|
67
|
+
"IBM864" => [1, 1].freeze,
|
68
|
+
"IBM865" => [1, 1].freeze,
|
69
|
+
"IBM866" => [1, 1].freeze,
|
70
|
+
"IBM869" => [1, 1].freeze,
|
71
|
+
"Windows-1258" => [1, 1].freeze,
|
72
|
+
"GB1988" => [1, 1].freeze,
|
73
|
+
"macCentEuro" => [1, 1].freeze,
|
74
|
+
"macCroatian" => [1, 1].freeze,
|
75
|
+
"macCyrillic" => [1, 1].freeze,
|
76
|
+
"macGreek" => [1, 1].freeze,
|
77
|
+
"macIceland" => [1, 1].freeze,
|
78
|
+
"macRoman" => [1, 1].freeze,
|
79
|
+
"macRomania" => [1, 1].freeze,
|
80
|
+
"macThai" => [1, 1].freeze,
|
81
|
+
"macTurkish" => [1, 1].freeze,
|
82
|
+
"macUkraine" => [1, 1].freeze,
|
83
|
+
"CP950" => [1, 2].freeze,
|
84
|
+
"CP951" => [1, 2].freeze,
|
85
|
+
"IBM037" => [1, 1].freeze,
|
86
|
+
"stateless-ISO-2022-JP" => [1, 4].freeze,
|
87
|
+
"eucJP-ms" => [1, 3].freeze,
|
88
|
+
"CP51932" => [1, 3].freeze,
|
89
|
+
"EUC-JIS-2004" => [1, 3].freeze,
|
90
|
+
"GB12345" => [1, 2].freeze,
|
91
|
+
"ISO-2022-JP" => [1, 1].freeze,
|
92
|
+
"ISO-2022-JP-2" => [1, 1].freeze,
|
93
|
+
"CP50220" => [1, 1].freeze,
|
94
|
+
"CP50221" => [1, 1].freeze,
|
95
|
+
"Windows-1256" => [1, 1].freeze,
|
96
|
+
"Windows-1255" => [1, 1].freeze,
|
97
|
+
"TIS-620" => [1, 1].freeze,
|
98
|
+
"Windows-874" => [1, 1].freeze,
|
99
|
+
"MacJapanese" => [1, 2].freeze,
|
100
|
+
"UTF-7" => [1, 1].freeze,
|
101
|
+
"UTF8-DoCoMo" => [1, 4].freeze,
|
102
|
+
"SJIS-DoCoMo" => [1, 2].freeze,
|
103
|
+
"UTF8-KDDI" => [1, 4].freeze,
|
104
|
+
"SJIS-KDDI" => [1, 2].freeze,
|
105
|
+
"ISO-2022-JP-KDDI" => [1, 1].freeze,
|
106
|
+
"stateless-ISO-2022-JP-KDDI" => [1, 4].freeze,
|
107
|
+
"UTF8-SoftBank" => [1, 4].freeze,
|
108
|
+
"SJIS-SoftBank" => [1, 2].freeze
|
109
|
+
}.freeze
|
110
|
+
private_constant :CHAR_SIZES
|
111
|
+
|
112
|
+
def self.min(encoding_or_name)
|
113
|
+
minmax(encoding_or_name).first
|
114
|
+
end
|
115
|
+
|
116
|
+
def self.max(encoding_or_name)
|
117
|
+
minmax(encoding_or_name).last
|
118
|
+
end
|
119
|
+
|
120
|
+
def self.minmax(encoding_or_name)
|
121
|
+
CHAR_SIZES.fetch(Encoding.find(encoding_or_name).name)
|
122
|
+
end
|
123
|
+
end
|
data/lib/tar.rb
ADDED
@@ -0,0 +1,51 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Tar
|
4
|
+
module Backports
|
5
|
+
unless Enumerable.public_method_defined?(:sum)
|
6
|
+
refine Array do
|
7
|
+
def sum(identity = 0)
|
8
|
+
reduce(identity) { |acc, value| acc + (block_given? ? yield(value) : value) }
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
unless Numeric.public_method_defined?(:negative?)
|
14
|
+
refine Numeric do
|
15
|
+
def negative?
|
16
|
+
self < 0
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
unless Regexp.public_method_defined?(:match?)
|
22
|
+
refine Regexp do
|
23
|
+
# https://github.com/marcandre/backports/blob/v3.8.0/lib/backports/2.4.0/regexp/match.rb
|
24
|
+
def match?(*args)
|
25
|
+
Fiber.new {
|
26
|
+
!match(*args).nil?
|
27
|
+
}.resume
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
unless String.public_method_defined?(:+@)
|
33
|
+
refine String do
|
34
|
+
# https://github.com/marcandre/backports/blob/v3.8.0/lib/backports/2.3.0/string/uplus.rb
|
35
|
+
def +@
|
36
|
+
frozen? ? dup : self
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
begin
|
42
|
+
String.new(encoding: Encoding::BINARY)
|
43
|
+
rescue TypeError
|
44
|
+
refine String.singleton_class do
|
45
|
+
def new(string = "", encoding: nil)
|
46
|
+
super(string).force_encoding(encoding)
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|