zipr 0.3.1 → 0.3.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: 1d81272a9a6533e52cc6e92c391aa1a36ec48443b8899bc17cb1f0570115c177
4
- data.tar.gz: b3a559a665e86be77ebe99ae33b9bb8b1932be918bbd40bb9b486b1071b90358
3
+ metadata.gz: 29d17a3bd1b8b10a97dca34e9bb8c7b7dd27ac3a9ccdb63a79a4b3e6bc71138f
4
+ data.tar.gz: 408ed3fd53d0537b559ca1ead8b2aa2e87e47abfefc9848ab2bb0df59f5f9492
5
5
  SHA512:
6
- metadata.gz: bf058b81ca99e1c7a1ea413fab134a4cff198ca92a0b5e99fd1c8903d452ca616bc2d3a530bf57a160b7c3a49a236f6101392297a49c58dd548a3eb71b228323
7
- data.tar.gz: 39219668c4a9a9606d82cbcb614d3ef110488132f7e19e5494518efcb56d5fd3ac58edaec06fb512072a2d8cf56204bd9e3b513fdf73dad961b647920f36c4d8
6
+ metadata.gz: a8b6f6ab632bdf5dd884fd1cf4d5cf1a650c068ae86c0f3dfcc3649cba993f9ee01df70bcc2fb4e30dc3f57ae39c7404fe15266271267676bfe30c03e6ecf3dd
7
+ data.tar.gz: 9833cb57b68c4af55aefd5c25c9c2be2e7eb5f4b90ed9629388b3533b6b6683f9570007afa56318fd44bc1264281fe223832596c69c512e40fa202f2499a4a68
data/lib/zipr/archive.rb CHANGED
@@ -234,13 +234,22 @@ module Zipr
234
234
  # An array of files to be added (or the :all symbol).
235
235
  # Parameters:
236
236
  # source_folder: The filesystem directory where files are being added from.
237
- # files_to_check: Array of files intended to be added to an archive. Can be exact names/paths or names/paths with wildcards (glob style).
237
+ # files_to_check: Array of files intended to be added to an archive. Can be exact names/paths or names/paths with wildcards (glob style) or a Regexp.
238
238
  # default: All files and folders under the source_folder.
239
239
  def determine_files_to_add(source_folder, files_to_check: nil)
240
240
  files_to_check ||= Dir.glob("#{source_folder}/**/*".tr('\\', '/')) if files_to_check.nil?
241
241
  files_to_add = []
242
+ source_folder_glob = nil
242
243
  files_to_check.each do |target_search|
243
- files = Dir.glob(Zipr.prepend_source_folder(source_folder, target_search))
244
+ files = if target_search.is_a?(Regexp)
245
+ source_folder_glob ||= Dir.glob("#{source_folder.tr('\\', '/')}/**/*")
246
+ source_folder_glob.select do |path|
247
+ path =~ target_search
248
+ end
249
+ source_folder_glob.select { |path| path.to_s =~ target_search }
250
+ else
251
+ Dir.glob(Zipr.prepend_source_folder(source_folder, target_search))
252
+ end
244
253
  files.each do |source_file|
245
254
  relative_path = Zipr.slice_source_folder(source_folder, source_file)
246
255
  exists_in_zip = !!@checksums[relative_path]
data/lib/zipr/helper.rb CHANGED
@@ -21,13 +21,21 @@ module Zipr
21
21
  def flattened_paths(source_folder, files)
22
22
  return files if source_folder.nil? || source_folder.empty?
23
23
  result = []
24
+ source_folder_glob = nil
24
25
  files.each do |entry|
26
+ if entry.is_a?(Regexp)
27
+ source_folder_glob ||= Dir.glob("#{source_folder.tr('\\', '/')}/**/*")
28
+ matched_files = source_folder_glob.select { |path| path =~ entry }
29
+ result += matched_files.map { |f| slice_source_folder(source_folder, f) }
30
+ next
31
+ end
32
+
25
33
  standardized_entry = "#{source_folder.tr('\\', '/')}/#{slice_source_folder(source_folder, entry)}"
26
34
  files_found = Dir.glob(standardized_entry)
27
35
  if files_found.empty?
28
36
  result.push(entry)
29
37
  else
30
- result += files_found.map { |e| slice_source_folder(source_folder, e) }
38
+ result += files_found.map { |f| slice_source_folder(source_folder, f) }
31
39
  end
32
40
  end
33
41
  result
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.1
4
+ version: 0.3.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alex Munoz