mds_file_utils 0.4.1 → 0.4.2

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
  SHA256:
3
- metadata.gz: 4397ac9fb6d6375d6c4094e432a1d4892ce0b2545014b8f2a33698f9733577ac
4
- data.tar.gz: ae162e0bd938e53a9fe975763cd516bc6300f0f1879a7c8b00cf5cc85920e9d4
3
+ metadata.gz: f4922919722fa024374d42c8bc739b2ec80c8922c8047dc643675194fe7c7163
4
+ data.tar.gz: 59b410c799c42972ea3905c6bf8a0e4d16899b81f9a9ceeee0b3b27949d41da2
5
5
  SHA512:
6
- metadata.gz: 2da669f6a590cfb20188af1b1d9b23e773cb281208908d6ecc9bb26768d35eca81cd2cf318e683b29c415f7099abd9bac481fe138228a09ed46021e557e305d8
7
- data.tar.gz: 17287ebbc3611652782d50cca31e1b1ccfbad598312299d73b0f37691a1c2a08436ba2342958566410609c506a6533cab880f14976e538e953f11da2a02031dc
6
+ metadata.gz: 9dca16d1ebbf8ee0f64f667e067b3ef2fcd7cf8ae22414d869d3e54da58440ead5c5ca0e4cc86ca2e5d834dd9e7575fcaefe7ba2d599c1d1ecdfa63d3efceae0
7
+ data.tar.gz: 18a01149f20216ccaa8c743e5bf5dea3197d33c5d27668b9542293dc34b1bc3ca40c60065a605b5b5ac100986dbe432129b4cada3fbba6218f0af4266c8cf120
data/Gemfile CHANGED
@@ -1,13 +1,13 @@
1
1
  source "http://rubygems.org"
2
2
  # Add dependencies required to use your gem here.
3
3
  # Example:
4
- gem "activesupport", "= 7.0.8"
4
+ gem 'activesupport', '6.1.7.6'
5
5
  gem "unzipMe", "~> 1.1.2"
6
- gem 'rubyzip', '~> 2.3'
6
+ gem 'zipruby', '~> 0.3.6'
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", "~> 3.6"
11
11
  gem "rdoc", "~> 4.1"
12
12
  gem "bundler", "~> 2.4"
13
13
  gem 'psych', '~> 5.1'
@@ -1,4 +1,3 @@
1
- require 'zip'
2
1
  module MdsFileUtils
3
2
 
4
3
  class ZipAnalyzer
@@ -14,16 +13,10 @@ module MdsFileUtils
14
13
  end
15
14
 
16
15
  def valid_zip?
17
- return false if @path.blank? || !File.exist?(@path)
16
+ return false if @path.blank?
17
+ return false unless File.exist?(@path)
18
18
  return false unless has_valid_extension?
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
19
+ UnzipmeValidator.new(@path).valid_zip?
27
20
  end
28
21
 
29
22
  def has_valid_extension?
@@ -33,7 +26,6 @@ module MdsFileUtils
33
26
 
34
27
  def is_composite?
35
28
  return false unless valid_zip?
36
- puts "file_list: #{file_list}"
37
29
  file_list.count { | file | file =~ EXTENSION_REGEX } > 0
38
30
  end
39
31
 
@@ -1,6 +1,5 @@
1
1
  require 'fileutils'
2
2
  require 'active_support/core_ext/object'
3
3
  require 'unzipMe'
4
- require 'zip'
5
4
  require 'mds_file_utils/zip_analyzer'
6
5
  require 'mds_file_utils/zip_splitter'
@@ -6,12 +6,12 @@
6
6
 
7
7
  Gem::Specification.new do |s|
8
8
  s.name = "mds_file_utils"
9
- s.version = "0.4.1"
9
+ s.version = "0.4.2"
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 = "2023-10-04"
14
+ s.date = "2017-07-18"
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 = "3.2.2"
40
+ s.rubygems_version = "2.4.8"
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>.freeze, ["~> 7.0"])
47
+ s.add_runtime_dependency(%q<activesupport>, ["6.1.7.6"])
48
48
  s.add_runtime_dependency(%q<unzipMe>, ["~> 1.1.2"])
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"])
49
+ s.add_development_dependency(%q<rspec>, ["~> 3.6"])
50
+ s.add_development_dependency(%q<rdoc>, ["~> 4.1"])
51
+ s.add_development_dependency(%q<bundler>, ["~> 2.4"])
52
+ s.add_development_dependency(%q<jeweler>, ["~> 2.3"])
53
53
  else
54
- s.add_dependency(%q<activesupport>.freeze, ["~> 7.0"])
54
+ s.add_dependency(%q<activesupport>, ["6.1.7.6"])
55
55
  s.add_dependency(%q<unzipMe>, ["~> 1.1.2"])
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"])
56
+ s.add_dependency(%q<rspec>, ["~> 3.6"])
57
+ s.add_dependency(%q<rdoc>, ["~> 4.1"])
58
+ s.add_dependency(%q<bundler>, ["~> 2.4"])
59
+ s.add_dependency(%q<jeweler>, ["~> 2.3"])
60
60
  end
61
61
  else
62
- s.add_dependency(%q<activesupport>, ["~> 7.0"])
62
+ s.add_dependency(%q<activesupport>, ["6.1.7.6"])
63
63
  s.add_dependency(%q<unzipMe>, ["~> 1.1.2"])
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"])
64
+ s.add_dependency(%q<rspec>, ["~> 3.6"])
65
+ s.add_dependency(%q<rdoc>, ["~> 4.1"])
66
+ s.add_dependency(%q<bundler>, ["~> 2.4"])
67
+ s.add_dependency(%q<jeweler>, ["~> 2.3"])
68
68
  end
69
69
  end
70
70
 
@@ -1,4 +1,6 @@
1
1
  require 'spec_helper'
2
+ require 'zipruby'
3
+
2
4
 
3
5
  describe MdsFileUtils::ZipAnalyzer do
4
6
 
@@ -57,35 +59,38 @@ describe MdsFileUtils::ZipAnalyzer do
57
59
  it "should respond with true if asked if a valid zip file has an extension of '.zip'" do
58
60
  @file_to_test = File.join('/tmp', 'file_to_test.zip')
59
61
  contained_file = File.join('/tmp', 'contained_file')
60
-
61
- # Create the contained file
62
62
  File.open(contained_file, 'w') { |f| f.puts "Hello" }
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)
63
+
64
+ Zip::Archive.open(@file_to_test, Zip::CREATE) do |archive|
65
+ archive.add_file('file.txt', contained_file)
67
66
  end
67
+
68
+ # Optionally, remove the contained file after creating the ZIP.
69
+ FileUtils.rm contained_file
70
+
68
71
 
69
72
  za = MdsFileUtils::ZipAnalyzer.new(@file_to_test)
70
73
 
71
74
  za.valid_zip?.should be_truthy
72
-
73
-
74
75
  end
76
+
75
77
 
76
- it "should respond with true if asked if a valid zip file has an extension of '.ZIP'" do
77
- @file_to_test = File.join('/tmp', 'file_to_test.zip')
78
- contained_file = File.join('/tmp', 'contained_file')
78
+ it "should respond with true if asked if a valid zip file has an extension of '.zip'" do
79
+ @file_to_test = File.join('/tmp', 'file_to_test.zip') # Use .zip extension for the ZIP file
80
+ contained_file = File.join('/tmp', 'contained_file.txt')
79
81
 
80
- # Create the contained file
81
82
  File.open(contained_file, 'w') { |f| f.puts "Hello" }
82
83
 
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)
84
+ # Create a new ZIP file
85
+ Zip::Archive.open(@file_to_test, Zip::CREATE) do |archive|
86
+ entry = archive.add_file('file.txt', contained_file) # Add the contained file to the ZIP archive
86
87
  end
87
88
 
89
+ # Optionally, remove the contained file after creating the ZIP.
90
+ FileUtils.rm contained_file
91
+
88
92
  za = MdsFileUtils::ZipAnalyzer.new(@file_to_test)
93
+
89
94
 
90
95
  za.valid_zip?.should be_truthy
91
96
  end
@@ -102,17 +107,28 @@ describe MdsFileUtils::ZipAnalyzer do
102
107
 
103
108
  it "should respond with true when asked if the file composite for a zip that contains nothing but files with a zip extension" do
104
109
  @file_to_test = File.join('/tmp', 'file_to_test.zip')
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)
110
+
111
+ # Create the ZIP files to go into the zip file
112
+ contained_paths = (1..2).map { |idx| File.join('/tmp', "contained_#{idx}.zip") }
113
+ contained_paths.each do |path|
114
+ # Create a dummy text file in /tmp directory
115
+ dummy_file_path = File.join('/tmp', 'dummy.txt')
116
+ File.open(dummy_file_path, 'w') { |f| f.puts "Hello, dummy!" }
117
+
118
+ # Create a new ZIP file containing the dummy.txt file
119
+ Zip::Archive.open(path, Zip::CREATE) do |archive|
120
+ entry = archive.add_file("dummy.txt", dummy_file_path)
113
121
  end
114
-
115
- za = MdsFileUtils::ZipAnalyzer.new(@file_to_test)
122
+ end
123
+
124
+ # Create a new ZIP file containing only ZIP files
125
+ Zip::Archive.open(@file_to_test, Zip::CREATE) do |archive|
126
+ contained_paths.each do |path|
127
+ entry = archive.add_file(File.basename(path), path) # Add the contained ZIP files to the ZIP archive
128
+ end
129
+ end
130
+
131
+ za = MdsFileUtils::ZipAnalyzer.new(@file_to_test)
116
132
 
117
133
  za.is_composite?.should be_truthy
118
134
  end
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.1
4
+ version: 0.4.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dave
@@ -9,22 +9,22 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2023-10-04 00:00:00.000000000 Z
12
+ date: 2017-07-18 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activesupport
16
16
  requirement: !ruby/object:Gem::Requirement
17
17
  requirements:
18
- - - "~>"
18
+ - - '='
19
19
  - !ruby/object:Gem::Version
20
- version: '7.0'
20
+ version: 6.1.7.6
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: '7.0'
27
+ version: 6.1.7.6
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: '0'
48
+ version: '3.6'
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: '0'
55
+ version: '3.6'
56
56
  - !ruby/object:Gem::Dependency
57
57
  name: rdoc
58
58
  requirement: !ruby/object:Gem::Requirement