file-dependencies 0.1.5 → 0.1.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/lib/file-dependencies/archive.rb +56 -42
- data/lib/file-dependencies/version.rb +1 -1
- data/lib/rubygems_plugin.rb +1 -1
- data/spec/file-dependencies/archive_spec.rb +2 -2
- metadata +37 -53
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 16ff079c67078c08116d4845c5553480d46e8c18
|
4
|
+
data.tar.gz: ddd56e8f570a0d1b3db3ca8468525bfe189fa90a
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 4c7a49ef3fbf5b46f68026ff09d1e5a53209b6b5f7f983baf5a13047b4fdb078edbede115dc7935b3643077c776bfc34f0c8a8edd61d74c63778000a1b4803f8
|
7
|
+
data.tar.gz: 625e720434aba86b7706f515c887b596d917e15660e5766eee689fc77ab9428dfe29c07a885fa658216bb8876ec172b9a592cc1dce774019c498ae4a3482744a
|
@@ -6,60 +6,74 @@ module FileDependencies
|
|
6
6
|
module Archive
|
7
7
|
def ungzip(file, outdir)
|
8
8
|
output = ::File.join(outdir, file.gsub('.gz', '').split(::File::SEPARATOR).last)
|
9
|
-
|
10
|
-
|
11
|
-
::
|
12
|
-
|
9
|
+
|
10
|
+
::File.open(file) do |gzip_file|
|
11
|
+
tgz = Zlib::GzipReader.new(gzip_file)
|
12
|
+
|
13
|
+
begin
|
14
|
+
::File.open(output, "w") do |out|
|
15
|
+
IO.copy_stream(tgz, out)
|
16
|
+
end
|
17
|
+
rescue
|
18
|
+
::File.unlink(output) if ::File.exist?(output)
|
19
|
+
raise
|
20
|
+
ensure
|
21
|
+
tgz.close
|
13
22
|
end
|
14
|
-
::File.unlink(file)
|
15
|
-
rescue
|
16
|
-
::File.unlink(output) if ::File.file?(output)
|
17
|
-
raise
|
18
23
|
end
|
19
|
-
|
24
|
+
ensure
|
25
|
+
::File.unlink(file) if ::File.file?(file)
|
20
26
|
end
|
21
27
|
module_function :ungzip
|
22
28
|
|
23
29
|
def untar(tarball, &block)
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
path = block.call(entry)
|
28
|
-
next if path.nil?
|
29
|
-
parent = ::File.dirname(path)
|
30
|
+
::File.open(tarball) do |tgzfile|
|
31
|
+
tgz = Zlib::GzipReader.new(tgzfile)
|
32
|
+
tar = ::Archive::Tar::Minitar::Input.open(tgz)
|
30
33
|
|
31
|
-
|
34
|
+
begin
|
35
|
+
tar.each do |entry|
|
36
|
+
path = block.call(entry)
|
37
|
+
next if path.nil?
|
38
|
+
parent = ::File.dirname(path)
|
32
39
|
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
40
|
+
FileUtils.mkdir_p(parent) unless ::File.directory?(parent)
|
41
|
+
|
42
|
+
# Skip this file if the output file is the same size
|
43
|
+
if entry.directory?
|
44
|
+
FileUtils.mkdir_p(path) unless ::File.directory?(path)
|
45
|
+
else
|
46
|
+
entry_mode = entry.instance_eval { @mode } & 0777
|
47
|
+
if ::File.exist?(path)
|
48
|
+
stat = ::File.stat(path)
|
49
|
+
# TODO(sissel): Submit a patch to archive-tar-minitar upstream to
|
50
|
+
# expose headers in the entry.
|
51
|
+
entry_size = entry.instance_eval { @size }
|
52
|
+
# If file sizes are same, skip writing.
|
53
|
+
next if stat.size == entry_size && (stat.mode & 0777) == entry_mode
|
54
|
+
end
|
55
|
+
puts "Extracting #{entry.full_name} from #{tarball} #{entry_mode.to_s(8)}" if $DEBUG
|
56
|
+
::File.open(path, "w") do |fd|
|
57
|
+
# eof? check lets us skip empty files. Necessary because the API provided by
|
58
|
+
# Archive::Tar::Minitar::Reader::EntryStream only mostly acts like an
|
59
|
+
# IO object. Something about empty files in this EntryStream causes
|
60
|
+
# IO.copy_stream to throw "can't convert nil into String" on JRuby
|
61
|
+
# TODO(sissel): File a bug about this.
|
62
|
+
until entry.eof?
|
63
|
+
chunk = entry.read(16_384)
|
64
|
+
fd.write(chunk)
|
65
|
+
end
|
66
|
+
# IO.copy_stream(entry, fd)
|
67
|
+
end
|
68
|
+
::File.chmod(entry_mode, path)
|
56
69
|
end
|
57
|
-
# IO.copy_stream(entry, fd)
|
58
70
|
end
|
59
|
-
|
71
|
+
ensure
|
72
|
+
tar.close
|
73
|
+
tgz.close
|
60
74
|
end
|
61
75
|
end
|
62
|
-
|
76
|
+
ensure
|
63
77
|
::File.unlink(tarball) if ::File.file?(tarball)
|
64
78
|
end # def untar
|
65
79
|
module_function :untar
|
data/lib/rubygems_plugin.rb
CHANGED
@@ -7,7 +7,7 @@ describe FileDependencies::Archive do
|
|
7
7
|
|
8
8
|
after do
|
9
9
|
FileUtils.remove_entry_secure(gzipfile) if ::File.exist?(gzipfile)
|
10
|
-
FileUtils.remove_entry_secure(expected_file)
|
10
|
+
FileUtils.remove_entry_secure(expected_file) if ::File.exist?(expected_file)
|
11
11
|
FileUtils.remove_entry_secure(tmpdir)
|
12
12
|
end
|
13
13
|
let(:gzipfile) { Assist.generate_gzip('some_content') }
|
@@ -29,7 +29,7 @@ describe FileDependencies::Archive do
|
|
29
29
|
|
30
30
|
after do
|
31
31
|
FileUtils.remove_entry_secure(tmpdir)
|
32
|
-
FileUtils.remove_entry_secure(file)
|
32
|
+
FileUtils.remove_entry_secure(file) if ::File.file?(file)
|
33
33
|
end
|
34
34
|
|
35
35
|
let(:file) { Assist.generate_file('some_content') }
|
metadata
CHANGED
@@ -1,126 +1,111 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: file-dependencies
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
5
|
-
prerelease:
|
4
|
+
version: 0.1.6
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Richard Pijnenburg
|
9
|
-
autorequire:
|
8
|
+
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date: 2015-02-
|
11
|
+
date: 2015-02-18 00:00:00.000000000 Z
|
13
12
|
dependencies:
|
14
13
|
- !ruby/object:Gem::Dependency
|
15
|
-
name: minitar
|
16
14
|
requirement: !ruby/object:Gem::Requirement
|
17
|
-
none: false
|
18
15
|
requirements:
|
19
|
-
- -
|
16
|
+
- - '>='
|
20
17
|
- !ruby/object:Gem::Version
|
21
18
|
version: '0'
|
22
|
-
|
19
|
+
name: minitar
|
23
20
|
prerelease: false
|
21
|
+
type: :runtime
|
24
22
|
version_requirements: !ruby/object:Gem::Requirement
|
25
|
-
none: false
|
26
23
|
requirements:
|
27
|
-
- -
|
24
|
+
- - '>='
|
28
25
|
- !ruby/object:Gem::Version
|
29
26
|
version: '0'
|
30
27
|
- !ruby/object:Gem::Dependency
|
31
|
-
name: rake
|
32
28
|
requirement: !ruby/object:Gem::Requirement
|
33
|
-
none: false
|
34
29
|
requirements:
|
35
30
|
- - ~>
|
36
31
|
- !ruby/object:Gem::Version
|
37
32
|
version: '10.2'
|
38
|
-
|
33
|
+
name: rake
|
39
34
|
prerelease: false
|
35
|
+
type: :development
|
40
36
|
version_requirements: !ruby/object:Gem::Requirement
|
41
|
-
none: false
|
42
37
|
requirements:
|
43
38
|
- - ~>
|
44
39
|
- !ruby/object:Gem::Version
|
45
40
|
version: '10.2'
|
46
41
|
- !ruby/object:Gem::Dependency
|
47
|
-
name: rspec
|
48
42
|
requirement: !ruby/object:Gem::Requirement
|
49
|
-
none: false
|
50
43
|
requirements:
|
51
|
-
- -
|
44
|
+
- - '>='
|
52
45
|
- !ruby/object:Gem::Version
|
53
46
|
version: '0'
|
54
|
-
|
47
|
+
name: rspec
|
55
48
|
prerelease: false
|
49
|
+
type: :development
|
56
50
|
version_requirements: !ruby/object:Gem::Requirement
|
57
|
-
none: false
|
58
51
|
requirements:
|
59
|
-
- -
|
52
|
+
- - '>='
|
60
53
|
- !ruby/object:Gem::Version
|
61
54
|
version: '0'
|
62
55
|
- !ruby/object:Gem::Dependency
|
63
|
-
name: stud
|
64
56
|
requirement: !ruby/object:Gem::Requirement
|
65
|
-
none: false
|
66
57
|
requirements:
|
67
|
-
- -
|
58
|
+
- - '>='
|
68
59
|
- !ruby/object:Gem::Version
|
69
60
|
version: '0'
|
70
|
-
|
61
|
+
name: stud
|
71
62
|
prerelease: false
|
63
|
+
type: :development
|
72
64
|
version_requirements: !ruby/object:Gem::Requirement
|
73
|
-
none: false
|
74
65
|
requirements:
|
75
|
-
- -
|
66
|
+
- - '>='
|
76
67
|
- !ruby/object:Gem::Version
|
77
68
|
version: '0'
|
78
69
|
- !ruby/object:Gem::Dependency
|
79
|
-
name: webmock
|
80
70
|
requirement: !ruby/object:Gem::Requirement
|
81
|
-
none: false
|
82
71
|
requirements:
|
83
|
-
- -
|
72
|
+
- - '>='
|
84
73
|
- !ruby/object:Gem::Version
|
85
74
|
version: '0'
|
86
|
-
|
75
|
+
name: webmock
|
87
76
|
prerelease: false
|
77
|
+
type: :development
|
88
78
|
version_requirements: !ruby/object:Gem::Requirement
|
89
|
-
none: false
|
90
79
|
requirements:
|
91
|
-
- -
|
80
|
+
- - '>='
|
92
81
|
- !ruby/object:Gem::Version
|
93
82
|
version: '0'
|
94
83
|
- !ruby/object:Gem::Dependency
|
95
|
-
name: coveralls
|
96
84
|
requirement: !ruby/object:Gem::Requirement
|
97
|
-
none: false
|
98
85
|
requirements:
|
99
|
-
- -
|
86
|
+
- - '>='
|
100
87
|
- !ruby/object:Gem::Version
|
101
88
|
version: '0'
|
102
|
-
|
89
|
+
name: coveralls
|
103
90
|
prerelease: false
|
91
|
+
type: :development
|
104
92
|
version_requirements: !ruby/object:Gem::Requirement
|
105
|
-
none: false
|
106
93
|
requirements:
|
107
|
-
- -
|
94
|
+
- - '>='
|
108
95
|
- !ruby/object:Gem::Version
|
109
96
|
version: '0'
|
110
97
|
- !ruby/object:Gem::Dependency
|
111
|
-
name: codeclimate-test-reporter
|
112
98
|
requirement: !ruby/object:Gem::Requirement
|
113
|
-
none: false
|
114
99
|
requirements:
|
115
|
-
- -
|
100
|
+
- - '>='
|
116
101
|
- !ruby/object:Gem::Version
|
117
102
|
version: '0'
|
118
|
-
|
103
|
+
name: codeclimate-test-reporter
|
119
104
|
prerelease: false
|
105
|
+
type: :development
|
120
106
|
version_requirements: !ruby/object:Gem::Requirement
|
121
|
-
none: false
|
122
107
|
requirements:
|
123
|
-
- -
|
108
|
+
- - '>='
|
124
109
|
- !ruby/object:Gem::Version
|
125
110
|
version: '0'
|
126
111
|
description: manage file dependencies for gems
|
@@ -152,26 +137,25 @@ files:
|
|
152
137
|
homepage: https://github.com/electrical/file-dependencies
|
153
138
|
licenses:
|
154
139
|
- APACHE 2.0
|
155
|
-
|
140
|
+
metadata: {}
|
141
|
+
post_install_message:
|
156
142
|
rdoc_options: []
|
157
143
|
require_paths:
|
158
144
|
- lib
|
159
145
|
required_ruby_version: !ruby/object:Gem::Requirement
|
160
|
-
none: false
|
161
146
|
requirements:
|
162
|
-
- -
|
147
|
+
- - '>='
|
163
148
|
- !ruby/object:Gem::Version
|
164
149
|
version: '0'
|
165
150
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
166
|
-
none: false
|
167
151
|
requirements:
|
168
|
-
- -
|
152
|
+
- - '>='
|
169
153
|
- !ruby/object:Gem::Version
|
170
154
|
version: '0'
|
171
155
|
requirements: []
|
172
|
-
rubyforge_project:
|
173
|
-
rubygems_version: 1.
|
174
|
-
signing_key:
|
175
|
-
specification_version:
|
156
|
+
rubyforge_project:
|
157
|
+
rubygems_version: 2.1.9
|
158
|
+
signing_key:
|
159
|
+
specification_version: 4
|
176
160
|
summary: manage file dependencies for gems
|
177
161
|
test_files: []
|