zipr 0.3.0 → 0.3.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 937bdb977ae3c5773f446384d75a99909dce1525b37a7178d962d0e0b0e7303d
4
- data.tar.gz: 520bd57c12f5cd9418fe94eff77c9760d3a04e67d2b45ae773fae8722fe7636b
3
+ metadata.gz: 1d81272a9a6533e52cc6e92c391aa1a36ec48443b8899bc17cb1f0570115c177
4
+ data.tar.gz: b3a559a665e86be77ebe99ae33b9bb8b1932be918bbd40bb9b486b1071b90358
5
5
  SHA512:
6
- metadata.gz: 937864d6924a089ede4705c5cba15bd361c050bfc5548230362b4c29eb6c03abcae3209d3178a6e168838cf4078fbcda7792b43c2548d365c76f04a87a905acc
7
- data.tar.gz: d529bd61f887f1a663245cfa4ce16e2a7469990a071d18b3b49fd9f359352bee4ac3a880cb803b45ed949f2eada808f91bb3cd803035507e6e2deb79418d186b
6
+ metadata.gz: bf058b81ca99e1c7a1ea413fab134a4cff198ca92a0b5e99fd1c8903d452ca616bc2d3a530bf57a160b7c3a49a236f6101392297a49c58dd548a3eb71b228323
7
+ data.tar.gz: 39219668c4a9a9606d82cbcb614d3ef110488132f7e19e5494518efcb56d5fd3ac58edaec06fb512072a2d8cf56204bd9e3b513fdf73dad961b647920f36c4d8
data/lib/zipr/archive.rb CHANGED
@@ -210,7 +210,7 @@ module Zipr
210
210
  unless ::File.exist?(@path)
211
211
  # If the archive doesn't exist but checksums were provided, check for files to extract based off of checksums
212
212
  return @checksums.select { |entry_name, checksum| _extract_file?(entry_name, checksum == 'directory', destination_folder, files_to_check) }.keys unless @checksums.nil? || @checksums.empty?
213
- # If the archive doesn't exist and no checksums were found, extract all files_to_check or :all files
213
+ # If the archive doesn't exist and no checksums were found, extract all files_to_check
214
214
  return files_to_check
215
215
  end
216
216
 
@@ -443,13 +443,19 @@ module Zipr
443
443
  @options[:exclude_files] ||= []
444
444
  @options[:exclude_unless_missing] ||= []
445
445
  @options[:exclude_unless_archive_changed] ||= []
446
- return true if @options[:exclude_files].any? { |e| file_path.tr('\\', '/') =~ /^#{Zipr.wildcard_to_regex(e.tr('\\', '/'))}$/i }
447
- return true if ::File.exist?(destination_path) && @options[:exclude_unless_missing].any? { |e| file_path.tr('\\', '/') =~ /^#{Zipr.wildcard_to_regex(e.tr('\\', '/'))}$/i }
448
- return true if exists_in_zip && @options[:exclude_unless_missing].any? { |e| file_path.tr('\\', '/') =~ /^#{Zipr.wildcard_to_regex(e.tr('\\', '/'))}$/i }
449
- return true if !@archive_changed && ::File.exist?(destination_path) && @options[:exclude_unless_archive_changed].any? { |e| file_path.tr('\\', '/') =~ /^#{Zipr.wildcard_to_regex(e.tr('\\', '/'))}$/i }
446
+ return true if @options[:exclude_files].any? { |e| file_path.tr('\\', '/') =~ _convert_backslashes_and_cast_to_regexp(e) }
447
+ return true if ::File.exist?(destination_path) && @options[:exclude_unless_missing].any? { |e| file_path.tr('\\', '/') =~ _convert_backslashes_and_cast_to_regexp(e) }
448
+ return true if exists_in_zip && @options[:exclude_unless_missing].any? { |e| file_path.tr('\\', '/') =~ _convert_backslashes_and_cast_to_regexp(e) }
449
+ return true if !@archive_changed && ::File.exist?(destination_path) && @options[:exclude_unless_archive_changed].any? { |e| file_path.tr('\\', '/') =~ _convert_backslashes_and_cast_to_regexp(e) }
450
450
  false
451
451
  end
452
452
 
453
+ def _convert_backslashes_and_cast_to_regexp(path)
454
+ return path if path.is_a?(Regexp) # If it's already a regexp, leave it alone
455
+ path = path.tr('\\', '/')
456
+ /^#{Zipr.wildcard_to_regexp(path)}$/i
457
+ end
458
+
453
459
  def _assign_common_accessors(options: nil, checksums: nil, mode: nil)
454
460
  _assign_checksums(checksums)
455
461
  @options = options || @options || {}
data/lib/zipr/helper.rb CHANGED
@@ -33,7 +33,7 @@ module Zipr
33
33
  result
34
34
  end
35
35
 
36
- def wildcard_to_regex(entry)
36
+ def wildcard_to_regexp(entry)
37
37
  return entry if entry.is_a?(Regexp)
38
38
  escaped_entry = Regexp.escape(entry).gsub(/\\\*/, '.*') # Convert asterisks to .*
39
39
  /#{escaped_entry}/
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: zipr
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alex Munoz