mds_file_utils 0.2.0 → 0.4.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/Gemfile +5 -4
- data/lib/mds_file_utils/zip_analyzer.rb +11 -3
- data/lib/mds_file_utils.rb +1 -0
- data/mds_file_utils.gemspec +18 -18
- data/spec/zip_analyzer_spec.rb +31 -16
- metadata +11 -12
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 4397ac9fb6d6375d6c4094e432a1d4892ce0b2545014b8f2a33698f9733577ac
|
4
|
+
data.tar.gz: ae162e0bd938e53a9fe975763cd516bc6300f0f1879a7c8b00cf5cc85920e9d4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2da669f6a590cfb20188af1b1d9b23e773cb281208908d6ecc9bb26768d35eca81cd2cf318e683b29c415f7099abd9bac481fe138228a09ed46021e557e305d8
|
7
|
+
data.tar.gz: 17287ebbc3611652782d50cca31e1b1ccfbad598312299d73b0f37691a1c2a08436ba2342958566410609c506a6533cab880f14976e538e953f11da2a02031dc
|
data/Gemfile
CHANGED
@@ -1,14 +1,15 @@
|
|
1
1
|
source "http://rubygems.org"
|
2
2
|
# Add dependencies required to use your gem here.
|
3
3
|
# Example:
|
4
|
-
gem "activesupport", "
|
4
|
+
gem "activesupport", "= 7.0.8"
|
5
5
|
gem "unzipMe", "~> 1.1.2"
|
6
|
-
|
6
|
+
gem 'rubyzip', '~> 2.3'
|
7
7
|
# Add dependencies to develop your gem here.
|
8
8
|
# Include everything needed to run rake, tests, features, etc.
|
9
9
|
group :development do
|
10
|
-
gem "rspec"
|
10
|
+
gem "rspec"
|
11
11
|
gem "rdoc", "~> 4.1"
|
12
|
-
gem "bundler", "~>
|
12
|
+
gem "bundler", "~> 2.4"
|
13
|
+
gem 'psych', '~> 5.1'
|
13
14
|
gem "jeweler", "~> 2.3"
|
14
15
|
end
|
@@ -1,3 +1,4 @@
|
|
1
|
+
require 'zip'
|
1
2
|
module MdsFileUtils
|
2
3
|
|
3
4
|
class ZipAnalyzer
|
@@ -13,10 +14,16 @@ module MdsFileUtils
|
|
13
14
|
end
|
14
15
|
|
15
16
|
def valid_zip?
|
16
|
-
return false if @path.blank?
|
17
|
-
return false unless File.exists?(@path)
|
17
|
+
return false if @path.blank? || !File.exist?(@path)
|
18
18
|
return false unless has_valid_extension?
|
19
|
-
|
19
|
+
|
20
|
+
begin
|
21
|
+
Zip::File.open(@path) { |zip_file| }
|
22
|
+
|
23
|
+
true # The zip file is valid
|
24
|
+
rescue Zip::Error => e
|
25
|
+
false # The zip file is not valid
|
26
|
+
end
|
20
27
|
end
|
21
28
|
|
22
29
|
def has_valid_extension?
|
@@ -26,6 +33,7 @@ module MdsFileUtils
|
|
26
33
|
|
27
34
|
def is_composite?
|
28
35
|
return false unless valid_zip?
|
36
|
+
puts "file_list: #{file_list}"
|
29
37
|
file_list.count { | file | file =~ EXTENSION_REGEX } > 0
|
30
38
|
end
|
31
39
|
|
data/lib/mds_file_utils.rb
CHANGED
data/mds_file_utils.gemspec
CHANGED
@@ -6,12 +6,12 @@
|
|
6
6
|
|
7
7
|
Gem::Specification.new do |s|
|
8
8
|
s.name = "mds_file_utils"
|
9
|
-
s.version = "0.
|
9
|
+
s.version = "0.4.1"
|
10
10
|
|
11
11
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
12
12
|
s.require_paths = ["lib"]
|
13
13
|
s.authors = ["Dave", "Kendra"]
|
14
|
-
s.date = "
|
14
|
+
s.date = "2023-10-04"
|
15
15
|
s.description = "A set of useful MDS file utilities."
|
16
16
|
s.email = "kmulvey@providigm.com"
|
17
17
|
s.extra_rdoc_files = [
|
@@ -37,34 +37,34 @@ Gem::Specification.new do |s|
|
|
37
37
|
]
|
38
38
|
s.homepage = "http://github.com/GitHubAdmin/mds_file_utils"
|
39
39
|
s.licenses = ["MIT"]
|
40
|
-
s.rubygems_version = "2.
|
40
|
+
s.rubygems_version = "3.2.2"
|
41
41
|
s.summary = "A collection of MDS file utilities."
|
42
42
|
|
43
43
|
if s.respond_to? :specification_version then
|
44
44
|
s.specification_version = 4
|
45
45
|
|
46
46
|
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
47
|
-
s.add_runtime_dependency(%q<activesupport
|
47
|
+
s.add_runtime_dependency(%q<activesupport>.freeze, ["~> 7.0"])
|
48
48
|
s.add_runtime_dependency(%q<unzipMe>, ["~> 1.1.2"])
|
49
|
-
s.add_development_dependency(%q<rspec
|
50
|
-
s.add_development_dependency(%q<rdoc
|
51
|
-
s.add_development_dependency(%q<bundler
|
52
|
-
s.add_development_dependency(%q<jeweler
|
49
|
+
s.add_development_dependency(%q<rspec>.freeze, [">= 0"])
|
50
|
+
s.add_development_dependency(%q<rdoc>.freeze, ["~> 4.1"])
|
51
|
+
s.add_development_dependency(%q<bundler>.freeze, ["~> 2.4"])
|
52
|
+
s.add_development_dependency(%q<jeweler>.freeze, ["~> 2.3"])
|
53
53
|
else
|
54
|
-
s.add_dependency(%q<activesupport
|
54
|
+
s.add_dependency(%q<activesupport>.freeze, ["~> 7.0"])
|
55
55
|
s.add_dependency(%q<unzipMe>, ["~> 1.1.2"])
|
56
|
-
s.add_dependency(%q<rspec
|
57
|
-
s.add_dependency(%q<rdoc
|
58
|
-
s.add_dependency(%q<bundler
|
59
|
-
s.add_dependency(%q<jeweler
|
56
|
+
s.add_dependency(%q<rspec>.freeze, [">= 0"])
|
57
|
+
s.add_dependency(%q<rdoc>.freeze, ["~> 4.1"])
|
58
|
+
s.add_dependency(%q<bundler>.freeze, ["~> 2.4"])
|
59
|
+
s.add_dependency(%q<jeweler>.freeze, ["~> 2.3"])
|
60
60
|
end
|
61
61
|
else
|
62
|
-
s.add_dependency(%q<activesupport>, ["~>
|
62
|
+
s.add_dependency(%q<activesupport>, ["~> 7.0"])
|
63
63
|
s.add_dependency(%q<unzipMe>, ["~> 1.1.2"])
|
64
|
-
s.add_dependency(%q<rspec
|
65
|
-
s.add_dependency(%q<rdoc
|
66
|
-
s.add_dependency(%q<bundler
|
67
|
-
s.add_dependency(%q<jeweler
|
64
|
+
s.add_dependency(%q<rspec>.freeze, [">= 0"])
|
65
|
+
s.add_dependency(%q<rdoc>.freeze, ["~> 4.1"])
|
66
|
+
s.add_dependency(%q<bundler>.freeze, ["~> 2.4"])
|
67
|
+
s.add_dependency(%q<jeweler>.freeze, ["~> 2.3"])
|
68
68
|
end
|
69
69
|
end
|
70
70
|
|
data/spec/zip_analyzer_spec.rb
CHANGED
@@ -57,22 +57,34 @@ describe MdsFileUtils::ZipAnalyzer do
|
|
57
57
|
it "should respond with true if asked if a valid zip file has an extension of '.zip'" do
|
58
58
|
@file_to_test = File.join('/tmp', 'file_to_test.zip')
|
59
59
|
contained_file = File.join('/tmp', 'contained_file')
|
60
|
+
|
61
|
+
# Create the contained file
|
60
62
|
File.open(contained_file, 'w') { |f| f.puts "Hello" }
|
61
|
-
|
62
|
-
|
63
|
-
|
63
|
+
|
64
|
+
# Create the zip file using RubyZip
|
65
|
+
::Zip::File.open(@file_to_test, ::Zip::File::CREATE) do |zip_file|
|
66
|
+
zip_file.add('contained_file', contained_file)
|
67
|
+
end
|
68
|
+
|
64
69
|
za = MdsFileUtils::ZipAnalyzer.new(@file_to_test)
|
65
|
-
|
70
|
+
|
66
71
|
za.valid_zip?.should be_truthy
|
72
|
+
|
73
|
+
|
67
74
|
end
|
68
75
|
|
69
76
|
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.
|
77
|
+
@file_to_test = File.join('/tmp', 'file_to_test.zip')
|
71
78
|
contained_file = File.join('/tmp', 'contained_file')
|
79
|
+
|
80
|
+
# Create the contained file
|
72
81
|
File.open(contained_file, 'w') { |f| f.puts "Hello" }
|
73
|
-
|
74
|
-
|
75
|
-
|
82
|
+
|
83
|
+
# Create the zip file using RubyZip
|
84
|
+
::Zip::File.open(@file_to_test, ::Zip::File::CREATE) do |zip_file|
|
85
|
+
zip_file.add('contained_file', contained_file)
|
86
|
+
end
|
87
|
+
|
76
88
|
za = MdsFileUtils::ZipAnalyzer.new(@file_to_test)
|
77
89
|
|
78
90
|
za.valid_zip?.should be_truthy
|
@@ -85,18 +97,21 @@ describe MdsFileUtils::ZipAnalyzer do
|
|
85
97
|
context "when testing whether the zip file is a composite MDS file" do
|
86
98
|
|
87
99
|
after(:each) do
|
88
|
-
FileUtils.rm @file_to_test if @file_to_test.present? && File.
|
100
|
+
FileUtils.rm @file_to_test if @file_to_test.present? && File.exist?(@file_to_test)
|
89
101
|
end
|
90
102
|
|
91
103
|
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
104
|
@file_to_test = File.join('/tmp', 'file_to_test.zip')
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
105
|
+
contained_file = File.join('/tmp', 'contained_file')
|
106
|
+
|
107
|
+
# Create the contained file
|
108
|
+
File.open(contained_file, 'w') { |f| f.puts "Hello" }
|
109
|
+
|
110
|
+
# Create the zip file using RubyZip
|
111
|
+
::Zip::File.open(@file_to_test, ::Zip::File::CREATE) do |zip_file|
|
112
|
+
zip_file.add('contained_file.zip', contained_file)
|
113
|
+
end
|
114
|
+
|
100
115
|
za = MdsFileUtils::ZipAnalyzer.new(@file_to_test)
|
101
116
|
|
102
117
|
za.is_composite?.should be_truthy
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mds_file_utils
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dave
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2023-10-04 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activesupport
|
@@ -17,14 +17,14 @@ dependencies:
|
|
17
17
|
requirements:
|
18
18
|
- - "~>"
|
19
19
|
- !ruby/object:Gem::Version
|
20
|
-
version: '
|
20
|
+
version: '7.0'
|
21
21
|
type: :runtime
|
22
22
|
prerelease: false
|
23
23
|
version_requirements: !ruby/object:Gem::Requirement
|
24
24
|
requirements:
|
25
25
|
- - "~>"
|
26
26
|
- !ruby/object:Gem::Version
|
27
|
-
version: '
|
27
|
+
version: '7.0'
|
28
28
|
- !ruby/object:Gem::Dependency
|
29
29
|
name: unzipMe
|
30
30
|
requirement: !ruby/object:Gem::Requirement
|
@@ -43,16 +43,16 @@ dependencies:
|
|
43
43
|
name: rspec
|
44
44
|
requirement: !ruby/object:Gem::Requirement
|
45
45
|
requirements:
|
46
|
-
- - "
|
46
|
+
- - ">="
|
47
47
|
- !ruby/object:Gem::Version
|
48
|
-
version: '
|
48
|
+
version: '0'
|
49
49
|
type: :development
|
50
50
|
prerelease: false
|
51
51
|
version_requirements: !ruby/object:Gem::Requirement
|
52
52
|
requirements:
|
53
|
-
- - "
|
53
|
+
- - ">="
|
54
54
|
- !ruby/object:Gem::Version
|
55
|
-
version: '
|
55
|
+
version: '0'
|
56
56
|
- !ruby/object:Gem::Dependency
|
57
57
|
name: rdoc
|
58
58
|
requirement: !ruby/object:Gem::Requirement
|
@@ -73,14 +73,14 @@ dependencies:
|
|
73
73
|
requirements:
|
74
74
|
- - "~>"
|
75
75
|
- !ruby/object:Gem::Version
|
76
|
-
version: '
|
76
|
+
version: '2.4'
|
77
77
|
type: :development
|
78
78
|
prerelease: false
|
79
79
|
version_requirements: !ruby/object:Gem::Requirement
|
80
80
|
requirements:
|
81
81
|
- - "~>"
|
82
82
|
- !ruby/object:Gem::Version
|
83
|
-
version: '
|
83
|
+
version: '2.4'
|
84
84
|
- !ruby/object:Gem::Dependency
|
85
85
|
name: jeweler
|
86
86
|
requirement: !ruby/object:Gem::Requirement
|
@@ -137,8 +137,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
137
137
|
- !ruby/object:Gem::Version
|
138
138
|
version: '0'
|
139
139
|
requirements: []
|
140
|
-
|
141
|
-
rubygems_version: 2.4.8
|
140
|
+
rubygems_version: 3.0.3.1
|
142
141
|
signing_key:
|
143
142
|
specification_version: 4
|
144
143
|
summary: A collection of MDS file utilities.
|