mds_file_utils 0.1.0 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.document +5 -0
- data/.rspec +1 -0
- data/Gemfile +14 -0
- data/Gemfile.lock +78 -0
- data/LICENSE.txt +20 -0
- data/VERSION +1 -0
- data/lib/mds_file_utils/zip_analyzer.rb +10 -0
- data/lib/mds_file_utils/zip_splitter.rb +8 -1
- data/lib/mds_file_utils.rb +2 -0
- data/spec/spec_helper.rb +12 -0
- data/spec/test_data/clear.gif +0 -0
- data/spec/zip_analyzer_spec.rb +232 -0
- data/spec/zip_splitter_spec.rb +40 -0
- metadata +49 -38
- data/lib/mds_file_utils/version.rb +0 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e30ffd9798b90871ec890d0ab578a2c33eea5a51
|
4
|
+
data.tar.gz: d9b59a3cd9d37878964355d8c70d2816e542d9e7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cfc1088103e43c45fde10d7fe489ca573319012fae6f63d4c44b4b8ea3dfea905020d725b952c1f92b419b0922a997f696508b772740f9c75cf7fe597b558e06
|
7
|
+
data.tar.gz: cd9a3a1d1a238fc82e93ea2625d404aac2c898b52108174d8d5031024b2f7c4c5be76b2633713aec58e1082620f12e12bf4d89d3425612619488c8910d02ff32
|
data/.document
ADDED
data/.rspec
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
--color
|
data/Gemfile
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
source "http://rubygems.org"
|
2
|
+
# Add dependencies required to use your gem here.
|
3
|
+
# Example:
|
4
|
+
gem "activesupport", "~> 4.0"
|
5
|
+
gem "unzipMe", "~> 1.0"
|
6
|
+
|
7
|
+
# Add dependencies to develop your gem here.
|
8
|
+
# Include everything needed to run rake, tests, features, etc.
|
9
|
+
group :development do
|
10
|
+
gem "rspec", "~> 2.14"
|
11
|
+
gem "rdoc", "~> 4.1"
|
12
|
+
gem "bundler", "~> 1.5"
|
13
|
+
gem "jeweler", "~> 2.0"
|
14
|
+
end
|
data/Gemfile.lock
ADDED
@@ -0,0 +1,78 @@
|
|
1
|
+
GEM
|
2
|
+
remote: http://rubygems.org/
|
3
|
+
specs:
|
4
|
+
activesupport (4.1.4)
|
5
|
+
i18n (~> 0.6, >= 0.6.9)
|
6
|
+
json (~> 1.7, >= 1.7.7)
|
7
|
+
minitest (~> 5.1)
|
8
|
+
thread_safe (~> 0.1)
|
9
|
+
tzinfo (~> 1.1)
|
10
|
+
addressable (2.3.6)
|
11
|
+
builder (3.2.2)
|
12
|
+
descendants_tracker (0.0.4)
|
13
|
+
thread_safe (~> 0.3, >= 0.3.1)
|
14
|
+
diff-lcs (1.2.5)
|
15
|
+
faraday (0.9.0)
|
16
|
+
multipart-post (>= 1.2, < 3)
|
17
|
+
git (1.2.8)
|
18
|
+
github_api (0.12.0)
|
19
|
+
addressable (~> 2.3)
|
20
|
+
descendants_tracker (~> 0.0.4)
|
21
|
+
faraday (~> 0.8, < 0.10)
|
22
|
+
hashie (>= 3.2)
|
23
|
+
multi_json (>= 1.7.5, < 2.0)
|
24
|
+
nokogiri (~> 1.6.3)
|
25
|
+
oauth2
|
26
|
+
hashie (3.2.0)
|
27
|
+
highline (1.6.21)
|
28
|
+
i18n (0.6.11)
|
29
|
+
jeweler (2.0.1)
|
30
|
+
builder
|
31
|
+
bundler (>= 1.0)
|
32
|
+
git (>= 1.2.5)
|
33
|
+
github_api
|
34
|
+
highline (>= 1.6.15)
|
35
|
+
nokogiri (>= 1.5.10)
|
36
|
+
rake
|
37
|
+
rdoc
|
38
|
+
json (1.8.1)
|
39
|
+
jwt (1.0.0)
|
40
|
+
mini_portile (0.6.0)
|
41
|
+
minitest (5.4.0)
|
42
|
+
multi_json (1.10.1)
|
43
|
+
multi_xml (0.5.5)
|
44
|
+
multipart-post (2.0.0)
|
45
|
+
nokogiri (1.6.3.1)
|
46
|
+
mini_portile (= 0.6.0)
|
47
|
+
oauth2 (1.0.0)
|
48
|
+
faraday (>= 0.8, < 0.10)
|
49
|
+
jwt (~> 1.0)
|
50
|
+
multi_json (~> 1.3)
|
51
|
+
multi_xml (~> 0.5)
|
52
|
+
rack (~> 1.2)
|
53
|
+
rack (1.5.2)
|
54
|
+
rake (10.3.2)
|
55
|
+
rdoc (4.1.0)
|
56
|
+
rspec (2.14.1)
|
57
|
+
rspec-core (~> 2.14.0)
|
58
|
+
rspec-expectations (~> 2.14.0)
|
59
|
+
rspec-mocks (~> 2.14.0)
|
60
|
+
rspec-core (2.14.8)
|
61
|
+
rspec-expectations (2.14.5)
|
62
|
+
diff-lcs (>= 1.1.3, < 2.0)
|
63
|
+
rspec-mocks (2.14.6)
|
64
|
+
thread_safe (0.3.4)
|
65
|
+
tzinfo (1.2.1)
|
66
|
+
thread_safe (~> 0.1)
|
67
|
+
unzipMe (1.0.0)
|
68
|
+
|
69
|
+
PLATFORMS
|
70
|
+
ruby
|
71
|
+
|
72
|
+
DEPENDENCIES
|
73
|
+
activesupport (~> 4.0)
|
74
|
+
bundler (~> 1.5)
|
75
|
+
jeweler (~> 2.0)
|
76
|
+
rdoc (~> 4.1)
|
77
|
+
rspec (~> 2.14)
|
78
|
+
unzipMe (~> 1.0)
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2013 Dave
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.1.1
|
@@ -2,6 +2,8 @@ module MdsFileUtils
|
|
2
2
|
|
3
3
|
class ZipAnalyzer
|
4
4
|
|
5
|
+
MAX_MDS_FILE_SIZE = 5242880 # 5MB
|
6
|
+
|
5
7
|
EXTENSION_REGEX = /\.zip\z/i
|
6
8
|
VALID_COMPOSITE_CONTENTS_REGEX = /(\.zip|\/|\\)\z/i
|
7
9
|
|
@@ -35,6 +37,14 @@ module MdsFileUtils
|
|
35
37
|
file_list.count { | entry | !( entry =~ VALID_COMPOSITE_CONTENTS_REGEX) } > 0
|
36
38
|
end
|
37
39
|
|
40
|
+
def too_big_for_mds?
|
41
|
+
file_size > MAX_MDS_FILE_SIZE && !is_composite?
|
42
|
+
end
|
43
|
+
|
44
|
+
def file_size
|
45
|
+
File.size(@path)
|
46
|
+
end
|
47
|
+
|
38
48
|
end
|
39
49
|
|
40
50
|
end
|
@@ -1,6 +1,11 @@
|
|
1
1
|
module MdsFileUtils
|
2
2
|
|
3
3
|
class ZipSplitter
|
4
|
+
include FileUtils
|
5
|
+
|
6
|
+
FILES_PER_ZIP = 1500
|
7
|
+
EXTRACTED_DIR = 'extracted'
|
8
|
+
COMPONENTS_DIR = 'components'
|
4
9
|
|
5
10
|
def initialize(path, original_filename=path)
|
6
11
|
@path = path
|
@@ -22,13 +27,15 @@ module MdsFileUtils
|
|
22
27
|
|
23
28
|
entries = directory_entries(extracted_path)
|
24
29
|
|
30
|
+
puts "Number of entries: #{entries}"
|
31
|
+
|
25
32
|
if entries.size > FILES_PER_ZIP
|
26
33
|
result_zip_file = create_composite_zip_from_entries(zip_base_name, entries, splitter_path, extracted_path)
|
27
34
|
else
|
28
35
|
# The file is fine as is; just copy the file to the storage
|
29
36
|
# location and return the path
|
30
37
|
result_zip_file = File.join(splitter_path, File.basename(@path))
|
31
|
-
cp @path,
|
38
|
+
cp @path, result_zip_file
|
32
39
|
end
|
33
40
|
|
34
41
|
result_zip_file
|
data/lib/mds_file_utils.rb
CHANGED
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
2
|
+
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
3
|
+
require 'rspec'
|
4
|
+
require 'mds_file_utils'
|
5
|
+
|
6
|
+
# Requires supporting files with custom matchers and macros, etc,
|
7
|
+
# in ./support/ and its subdirectories.
|
8
|
+
Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}
|
9
|
+
|
10
|
+
RSpec.configure do |config|
|
11
|
+
|
12
|
+
end
|
Binary file
|
@@ -0,0 +1,232 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe MdsFileUtils::ZipAnalyzer do
|
4
|
+
|
5
|
+
context "when testing for a valid zip file" do
|
6
|
+
|
7
|
+
context "and provided with a file that does not have a zip extension" do
|
8
|
+
|
9
|
+
before(:each) do
|
10
|
+
@file_to_test = File.join('/tmp', 'file_to_test.txt')
|
11
|
+
File.open(@file_to_test, 'w') { |f| f.puts "TestFile" }
|
12
|
+
@za = MdsFileUtils::ZipAnalyzer.new(@file_to_test)
|
13
|
+
end
|
14
|
+
|
15
|
+
after(:each) do
|
16
|
+
FileUtils.rm_f @file_to_test
|
17
|
+
end
|
18
|
+
|
19
|
+
it "should respond with false if asked if a file that has a non-zip extension is a valid zip" do
|
20
|
+
@za.valid_zip?.should be_false
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
24
|
+
|
25
|
+
context "and provided with an invalid zip file" do
|
26
|
+
|
27
|
+
after(:each) do
|
28
|
+
FileUtils.rm @file_to_test if @file_to_test.present?
|
29
|
+
end
|
30
|
+
|
31
|
+
it "should respond with false if asked if a text file is a valid zip" do
|
32
|
+
@file_to_test = File.join('/tmp', 'file_to_test.txt')
|
33
|
+
File.open(@file_to_test, 'w') { |f| f.puts "TestFile" }
|
34
|
+
|
35
|
+
za = MdsFileUtils::ZipAnalyzer.new(@file_to_test)
|
36
|
+
|
37
|
+
za.valid_zip?.should be_false
|
38
|
+
end
|
39
|
+
|
40
|
+
it "should respond with false if asked if an image file is a valid zip" do
|
41
|
+
@file_to_test = File.join('/tmp', 'file_to_test.gif')
|
42
|
+
FileUtils.cp 'spec/test_data/clear.gif', @file_to_test
|
43
|
+
|
44
|
+
za = MdsFileUtils::ZipAnalyzer.new(@file_to_test)
|
45
|
+
|
46
|
+
za.valid_zip?.should be_false
|
47
|
+
end
|
48
|
+
|
49
|
+
end
|
50
|
+
|
51
|
+
context "and provided with a valid zip file" do
|
52
|
+
|
53
|
+
after(:each) do
|
54
|
+
FileUtils.rm @file_to_test if @file_to_test.present?
|
55
|
+
end
|
56
|
+
|
57
|
+
it "should respond with true if asked if a valid zip file has an extension of '.zip'" do
|
58
|
+
@file_to_test = File.join('/tmp', 'file_to_test.zip')
|
59
|
+
contained_file = File.join('/tmp', 'contained_file')
|
60
|
+
File.open(contained_file, 'w') { |f| f.puts "Hello" }
|
61
|
+
system "cd '#{File.dirname(@file_to_test)}'; zip '#{File.basename(@file_to_test)}' '#{File.basename(contained_file)}' > /dev/null 2>&1"
|
62
|
+
FileUtils.rm contained_file
|
63
|
+
|
64
|
+
za = MdsFileUtils::ZipAnalyzer.new(@file_to_test)
|
65
|
+
|
66
|
+
za.valid_zip?.should be_true
|
67
|
+
end
|
68
|
+
|
69
|
+
it "should respond with true if asked if a valid zip file has an extension of '.ZIP'" do
|
70
|
+
@file_to_test = File.join('/tmp', 'file_to_test.ZIP')
|
71
|
+
contained_file = File.join('/tmp', 'contained_file')
|
72
|
+
File.open(contained_file, 'w') { |f| f.puts "Hello" }
|
73
|
+
system "cd '#{File.dirname(@file_to_test)}'; zip '#{File.basename(@file_to_test)}' '#{File.basename(contained_file)}' > /dev/null 2>&1"
|
74
|
+
FileUtils.rm contained_file
|
75
|
+
|
76
|
+
za = MdsFileUtils::ZipAnalyzer.new(@file_to_test)
|
77
|
+
|
78
|
+
za.valid_zip?.should be_true
|
79
|
+
end
|
80
|
+
|
81
|
+
end
|
82
|
+
|
83
|
+
end
|
84
|
+
|
85
|
+
context "when testing whether the zip file is a composite MDS file" do
|
86
|
+
|
87
|
+
after(:each) do
|
88
|
+
FileUtils.rm @file_to_test if @file_to_test.present? && File.exists?(@file_to_test)
|
89
|
+
end
|
90
|
+
|
91
|
+
it "should respond with true when asked if the file composite for a zip that contains nothing but files with a zip extension" do
|
92
|
+
@file_to_test = File.join('/tmp', 'file_to_test.zip')
|
93
|
+
# Create the files to go into the zip file
|
94
|
+
contained_paths = (1..2).map { |idx| File.join('/tmp', "contained_#{idx}.zip") }
|
95
|
+
contained_paths.each { |path| File.open(path, 'w') { |f| f.puts "Hello #{path}" } }
|
96
|
+
paths_to_add = contained_paths.map { |path| File.basename(path) }.join(' ')
|
97
|
+
system "cd '#{File.dirname(@file_to_test)}'; zip '#{File.basename(@file_to_test)}' #{paths_to_add} > /dev/null 2>&1"
|
98
|
+
contained_paths.each { |path| FileUtils.rm path }
|
99
|
+
|
100
|
+
za = MdsFileUtils::ZipAnalyzer.new(@file_to_test)
|
101
|
+
|
102
|
+
za.is_composite?.should be_true
|
103
|
+
end
|
104
|
+
|
105
|
+
it "should respond with false when asked if the file is a composite and the zip contains only .xml files" do
|
106
|
+
@file_to_test = File.join('/tmp', 'file_to_test.zip')
|
107
|
+
# Create the files to go into the zip file
|
108
|
+
contained_paths = (1..2).map { |idx| File.join('/tmp', "contained_#{idx}.xml") }
|
109
|
+
contained_paths.each { |path| File.open(path, 'w') { |f| f.puts "Hello #{path}" } }
|
110
|
+
paths_to_add = contained_paths.map { |path| File.basename(path) }.join(' ')
|
111
|
+
system "cd '#{File.dirname(@file_to_test)}'; zip '#{File.basename(@file_to_test)}' '#{paths_to_add}' > /dev/null 2>&1"
|
112
|
+
contained_paths.each { |path| FileUtils.rm path }
|
113
|
+
|
114
|
+
za = MdsFileUtils::ZipAnalyzer.new(@file_to_test)
|
115
|
+
|
116
|
+
za.is_composite?.should be_false
|
117
|
+
end
|
118
|
+
|
119
|
+
it "should respond with false when asked if the file is a composite and the zip contains multiple .zip files and a single .xml file" do
|
120
|
+
@file_to_test = File.join('/tmp', 'file_to_test.zip')
|
121
|
+
# Create the files to go into the zip file
|
122
|
+
contained_paths = (1..4).map { |idx| extension = idx < 4 ? 'zip' : 'xml'; File.join('/tmp', "contained_#{idx}.#{extension}") }
|
123
|
+
contained_paths.each { |path| File.open(path, 'w') { |f| f.puts "Hello #{path}" } }
|
124
|
+
paths_to_add = contained_paths.map { |path| File.basename(path) }.join(' ')
|
125
|
+
system "cd '#{File.dirname(@file_to_test)}'; zip '#{File.basename(@file_to_test)}' '#{paths_to_add}' > /dev/null 2>&1"
|
126
|
+
contained_paths.each { |path| FileUtils.rm path }
|
127
|
+
|
128
|
+
za = MdsFileUtils::ZipAnalyzer.new(@file_to_test)
|
129
|
+
|
130
|
+
za.is_composite?.should be_false
|
131
|
+
end
|
132
|
+
|
133
|
+
it "should respond with false when asked if the file is a composite and the zip contains files with various extensions but no .zip files" do
|
134
|
+
EXTENSIONS ||= %W{ xml gif txt }
|
135
|
+
@file_to_test = File.join('/tmp', 'file_to_test.zip')
|
136
|
+
# Create the files to go into the zip file
|
137
|
+
contained_paths = (1..3).map { |idx| File.join('/tmp', "contained_#{idx}.#{EXTENSIONS[idx-1]}") }
|
138
|
+
contained_paths.each { |path| File.open(path, 'w') { |f| f.puts "Hello #{path}" } }
|
139
|
+
paths_to_add = contained_paths.map { |path| File.basename(path) }.join(' ')
|
140
|
+
system "cd '#{File.dirname(@file_to_test)}'; zip '#{File.basename(@file_to_test)}' '#{paths_to_add}' > /dev/null 2>&1"
|
141
|
+
contained_paths.each { |path| FileUtils.rm path }
|
142
|
+
|
143
|
+
za = MdsFileUtils::ZipAnalyzer.new(@file_to_test)
|
144
|
+
|
145
|
+
za.is_composite?.should be_false
|
146
|
+
end
|
147
|
+
|
148
|
+
it "should respond with true when the file listing has no directory entry and all files are in a subdirectory" do
|
149
|
+
za = MdsFileUtils::ZipAnalyzer.new('/tmp/baloney.zip')
|
150
|
+
za.should_receive(:valid_zip?).and_return(true)
|
151
|
+
|
152
|
+
mock_unzipper = double("UnzipmeUnzipper")
|
153
|
+
mock_unzipper.should_receive(:file_list).
|
154
|
+
and_return([ 'Abaqis Upload/Transmitted Files-01.zip',
|
155
|
+
'Abaqis Upload/Transmitted Files-02.zip',
|
156
|
+
'Abaqis Upload/Transmitted Files-03.zip' ])
|
157
|
+
|
158
|
+
UnzipmeUnzipper.should_receive(:new).with('/tmp/baloney.zip').and_return(mock_unzipper)
|
159
|
+
|
160
|
+
expect(za.is_composite?).to be_true
|
161
|
+
end
|
162
|
+
|
163
|
+
it "should respond with true when the file listing has a directory entry and all files are in a subdirectory" do
|
164
|
+
za = MdsFileUtils::ZipAnalyzer.new('/tmp/baloney.zip')
|
165
|
+
za.should_receive(:valid_zip?).and_return(true)
|
166
|
+
|
167
|
+
mock_unzipper = double("UnzipmeUnzipper")
|
168
|
+
mock_unzipper.should_receive(:file_list).
|
169
|
+
and_return([ 'Abaqis Upload/',
|
170
|
+
'Abaqis Upload/Transmitted Files-01.zip',
|
171
|
+
'Abaqis Upload/Transmitted Files-02.zip',
|
172
|
+
'Abaqis Upload/Transmitted Files-03.zip' ])
|
173
|
+
|
174
|
+
UnzipmeUnzipper.should_receive(:new).with('/tmp/baloney.zip').and_return(mock_unzipper)
|
175
|
+
|
176
|
+
expect(za.is_composite?).to be_true
|
177
|
+
end
|
178
|
+
|
179
|
+
it "should respond with true when the file listing has at least one .zip file" do
|
180
|
+
za = MdsFileUtils::ZipAnalyzer.new('/tmp/baloney.zip')
|
181
|
+
za.should_receive(:valid_zip?).and_return(true)
|
182
|
+
|
183
|
+
mock_unzipper = double("UnzipmeUnzipper")
|
184
|
+
mock_unzipper.should_receive(:file_list).
|
185
|
+
and_return([ 'Files0-00.zip',
|
186
|
+
'Abaqis Upload/Transmitted Files-01.xml',
|
187
|
+
'Abaqis Upload/Transmitted Files-02.png',
|
188
|
+
'Abaqis Upload/Transmitted Files-03' ])
|
189
|
+
|
190
|
+
UnzipmeUnzipper.should_receive(:new).with('/tmp/baloney.zip').and_return(mock_unzipper)
|
191
|
+
|
192
|
+
expect(za.is_composite?).to be_true
|
193
|
+
end
|
194
|
+
|
195
|
+
it "should respond with false when the file listing doesn't have at least one .zip file" do
|
196
|
+
za = MdsFileUtils::ZipAnalyzer.new('/tmp/baloney.zip')
|
197
|
+
za.should_receive(:valid_zip?).and_return(true)
|
198
|
+
|
199
|
+
mock_unzipper = double("UnzipmeUnzipper")
|
200
|
+
mock_unzipper.should_receive(:file_list).
|
201
|
+
and_return([ 'Files0-00.iso',
|
202
|
+
'Abaqis Upload/Transmitted Files-01.xml',
|
203
|
+
'Abaqis Upload/Transmitted Files-02.png',
|
204
|
+
'Abaqis Upload/Transmitted Files-03' ])
|
205
|
+
|
206
|
+
UnzipmeUnzipper.should_receive(:new).with('/tmp/baloney.zip').and_return(mock_unzipper)
|
207
|
+
|
208
|
+
expect(za.is_composite?).to be_false
|
209
|
+
end
|
210
|
+
|
211
|
+
end
|
212
|
+
|
213
|
+
context '#non_mds_data_in_composite?' do
|
214
|
+
|
215
|
+
before(:each) do
|
216
|
+
@cut = MdsFileUtils::ZipAnalyzer.new('afile')
|
217
|
+
end
|
218
|
+
|
219
|
+
it "should return true if the list of files in the zip file contain entries that are not ZIP files" do
|
220
|
+
@cut.should_receive(:file_list).and_return([ 'thing1.zip', 'thing2.jpg', 'dir/thing3.zip' ])
|
221
|
+
expect(@cut.non_mds_data_in_composite?).to be_true
|
222
|
+
end
|
223
|
+
|
224
|
+
it "should return false if the list of files in the zip file contain only directories and ZIP files" do
|
225
|
+
@cut.should_receive(:file_list).and_return([ 'thing1.zip', 'dir/', 'dir2\\', 'dir/thing2.ZIP' ])
|
226
|
+
expect(@cut.non_mds_data_in_composite?).to be_false
|
227
|
+
end
|
228
|
+
|
229
|
+
end
|
230
|
+
|
231
|
+
end
|
232
|
+
|
@@ -0,0 +1,40 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe MdsFileUtils::ZipSplitter do
|
4
|
+
|
5
|
+
context "#base_file_name" do
|
6
|
+
|
7
|
+
it "should return the base name of the path with the extension removed" do
|
8
|
+
zipper = MdsFileUtils::ZipSplitter.new("/tmp/path.ext")
|
9
|
+
zipper.send(:base_file_name).should == 'path'
|
10
|
+
end
|
11
|
+
|
12
|
+
it "should return the base name of the path even if the file has no extension" do
|
13
|
+
zipper = MdsFileUtils::ZipSplitter.new("/tmp/path")
|
14
|
+
zipper.send(:base_file_name).should == 'path'
|
15
|
+
end
|
16
|
+
|
17
|
+
it "should return the base name of the path even if the file has other '.'s in the name" do
|
18
|
+
zipper = MdsFileUtils::ZipSplitter.new("/tmp/path.thing1.thing2.ext")
|
19
|
+
zipper.send(:base_file_name).should == 'path.thing1.thing2'
|
20
|
+
end
|
21
|
+
|
22
|
+
end
|
23
|
+
|
24
|
+
context "#directory_entries" do
|
25
|
+
|
26
|
+
before(:each) do
|
27
|
+
@zipper = MdsFileUtils::ZipSplitter.new('/tmp')
|
28
|
+
end
|
29
|
+
|
30
|
+
it "should return the entries of a directory without the '.' and '..'" do
|
31
|
+
Dir.should_receive(:entries).with('/tmp/a_directory').and_return(['.', '..', 'file1', 'file2'])
|
32
|
+
|
33
|
+
@zipper.send(:directory_entries, '/tmp/a_directory').should == [ 'file1', 'file2' ]
|
34
|
+
end
|
35
|
+
|
36
|
+
end
|
37
|
+
|
38
|
+
|
39
|
+
end
|
40
|
+
|
metadata
CHANGED
@@ -1,114 +1,125 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mds_file_utils
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
|
-
-
|
7
|
+
- Dave
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-08-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- -
|
17
|
+
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version:
|
19
|
+
version: '4.0'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- -
|
24
|
+
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version:
|
26
|
+
version: '4.0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: unzipMe
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- - ~>
|
31
|
+
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: 1.0
|
33
|
+
version: '1.0'
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- - ~>
|
38
|
+
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: 1.0
|
40
|
+
version: '1.0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: rspec
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- - ~>
|
45
|
+
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: 2.
|
47
|
+
version: '2.14'
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- - ~>
|
52
|
+
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: 2.
|
54
|
+
version: '2.14'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: rdoc
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
|
-
- - ~>
|
59
|
+
- - "~>"
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: '
|
61
|
+
version: '4.1'
|
62
62
|
type: :development
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
|
-
- - ~>
|
66
|
+
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version: '
|
68
|
+
version: '4.1'
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: bundler
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
|
-
- - ~>
|
73
|
+
- - "~>"
|
74
74
|
- !ruby/object:Gem::Version
|
75
|
-
version: '1.
|
75
|
+
version: '1.5'
|
76
76
|
type: :development
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
|
-
- - ~>
|
80
|
+
- - "~>"
|
81
81
|
- !ruby/object:Gem::Version
|
82
|
-
version: '1.
|
82
|
+
version: '1.5'
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
84
|
name: jeweler
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
86
86
|
requirements:
|
87
|
-
- - ~>
|
87
|
+
- - "~>"
|
88
88
|
- !ruby/object:Gem::Version
|
89
|
-
version:
|
89
|
+
version: '2.0'
|
90
90
|
type: :development
|
91
91
|
prerelease: false
|
92
92
|
version_requirements: !ruby/object:Gem::Requirement
|
93
93
|
requirements:
|
94
|
-
- - ~>
|
94
|
+
- - "~>"
|
95
95
|
- !ruby/object:Gem::Version
|
96
|
-
version:
|
97
|
-
description:
|
98
|
-
email:
|
99
|
-
- klawlor@providigm.com
|
96
|
+
version: '2.0'
|
97
|
+
description: A set of useful MDS file utilities.
|
98
|
+
email: dave.sieh@providigm.com
|
100
99
|
executables: []
|
101
100
|
extensions: []
|
102
|
-
extra_rdoc_files:
|
101
|
+
extra_rdoc_files:
|
102
|
+
- LICENSE.txt
|
103
|
+
- README.rdoc
|
103
104
|
files:
|
105
|
+
- ".document"
|
106
|
+
- ".rspec"
|
107
|
+
- Gemfile
|
108
|
+
- Gemfile.lock
|
109
|
+
- LICENSE.txt
|
104
110
|
- README.rdoc
|
105
111
|
- Rakefile
|
112
|
+
- VERSION
|
106
113
|
- lib/mds_file_utils.rb
|
107
|
-
- lib/mds_file_utils/version.rb
|
108
114
|
- lib/mds_file_utils/zip_analyzer.rb
|
109
115
|
- lib/mds_file_utils/zip_splitter.rb
|
110
|
-
|
111
|
-
|
116
|
+
- spec/spec_helper.rb
|
117
|
+
- spec/test_data/clear.gif
|
118
|
+
- spec/zip_analyzer_spec.rb
|
119
|
+
- spec/zip_splitter_spec.rb
|
120
|
+
homepage: http://github.com/dj0hnve@gmail.com/mds_file_utils
|
121
|
+
licenses:
|
122
|
+
- MIT
|
112
123
|
metadata: {}
|
113
124
|
post_install_message:
|
114
125
|
rdoc_options: []
|
@@ -116,18 +127,18 @@ require_paths:
|
|
116
127
|
- lib
|
117
128
|
required_ruby_version: !ruby/object:Gem::Requirement
|
118
129
|
requirements:
|
119
|
-
- -
|
130
|
+
- - ">="
|
120
131
|
- !ruby/object:Gem::Version
|
121
132
|
version: '0'
|
122
133
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
123
134
|
requirements:
|
124
|
-
- -
|
135
|
+
- - ">="
|
125
136
|
- !ruby/object:Gem::Version
|
126
137
|
version: '0'
|
127
138
|
requirements: []
|
128
139
|
rubyforge_project:
|
129
|
-
rubygems_version: 2.
|
140
|
+
rubygems_version: 2.2.2
|
130
141
|
signing_key:
|
131
142
|
specification_version: 4
|
132
|
-
summary:
|
143
|
+
summary: A collection of MDS file utilities.
|
133
144
|
test_files: []
|