mds_file_utils 0.2.0 → 0.4.0

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
- SHA1:
3
- metadata.gz: 41949ba49d502cf6a84eca24d16a6e98bcfecb24
4
- data.tar.gz: 138ead39b6dc7689f6f8e7ec2423bfa747541293
2
+ SHA256:
3
+ metadata.gz: 210de87700f78960e9355f4ef008e7ca7177fc6729df2b679591131a9aa219f1
4
+ data.tar.gz: 6d6f580a6b86562aa27fe0c8cd8a01dc27549c867ec9cb0a94639b60a2cc05fc
5
5
  SHA512:
6
- metadata.gz: 263026e46f18b50c6c4231f10f8533c0de45456c16e625dfc921ce50a16e23be9f789c3526d38c02890775726ae2ffff4901b08ccb3cdc40ace987513b9a77ee
7
- data.tar.gz: 5e2dce6e9ca6efd902206ec4b6973b8fb8d99378795689abcff0ffadf21debce20ad330b404db2670312f0dacf2e789d6a4f088bb0f45b7bfa1191906b8af52d
6
+ metadata.gz: 136adc6995983b488e1b9c16f3888e98c71a768abaea12d8dc2816714ee1d39389276ec41d2c1863e804799450e4a2fd63a8d33f2b51288d2c62aa0241aa7085
7
+ data.tar.gz: 37d20bbdd3dce461cb5a5483ffea5a47033761a331434ca51364093d98a6025519bd6de7d086ae2a6ebf0e4704d096fd105e03f5b2178d5a2a99a02b4bff8c95
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", "~> 5.1"
4
+ gem "activesupport", "~> 6.0"
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", "~> 3.6"
10
+ gem "rspec"
11
11
  gem "rdoc", "~> 4.1"
12
- gem "bundler", "~> 1.15"
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
- UnzipmeValidator.new(@path).valid_zip?
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
 
@@ -1,5 +1,6 @@
1
1
  require 'fileutils'
2
2
  require 'active_support/core_ext/object'
3
3
  require 'unzipMe'
4
+ require 'zip'
4
5
  require 'mds_file_utils/zip_analyzer'
5
6
  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.2.0"
9
+ s.version = "0.4.0"
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 = "2017-07-18"
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.4.8"
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>, ["~> 5.1"])
47
+ s.add_runtime_dependency(%q<activesupport>.freeze, ["~> 6.0"])
48
48
  s.add_runtime_dependency(%q<unzipMe>, ["~> 1.1.2"])
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>, ["~> 1.15"])
52
- s.add_development_dependency(%q<jeweler>, ["~> 2.3"])
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>, ["~> 5.1"])
54
+ s.add_dependency(%q<activesupport>.freeze, ["~> 6.0"])
55
55
  s.add_dependency(%q<unzipMe>, ["~> 1.1.2"])
56
- s.add_dependency(%q<rspec>, ["~> 3.6"])
57
- s.add_dependency(%q<rdoc>, ["~> 4.1"])
58
- s.add_dependency(%q<bundler>, ["~> 1.15"])
59
- s.add_dependency(%q<jeweler>, ["~> 2.3"])
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>, ["~> 5.1"])
62
+ s.add_dependency(%q<activesupport>, ["~> 6.0"])
63
63
  s.add_dependency(%q<unzipMe>, ["~> 1.1.2"])
64
- s.add_dependency(%q<rspec>, ["~> 3.6"])
65
- s.add_dependency(%q<rdoc>, ["~> 4.1"])
66
- s.add_dependency(%q<bundler>, ["~> 1.15"])
67
- s.add_dependency(%q<jeweler>, ["~> 2.3"])
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
 
@@ -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
- 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
-
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.ZIP')
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
- 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
-
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.exists?(@file_to_test)
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
- # 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
-
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.2.0
4
+ version: 0.4.0
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: 2017-07-18 00:00:00.000000000 Z
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: '5.1'
20
+ version: '6.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: '5.1'
27
+ version: '6.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: '3.6'
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: '3.6'
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: '1.15'
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: '1.15'
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
- rubyforge_project:
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.