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 +4 -4
- data/lib/zipr/archive.rb +11 -2
- data/lib/zipr/helper.rb +9 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 29d17a3bd1b8b10a97dca34e9bb8c7b7dd27ac3a9ccdb63a79a4b3e6bc71138f
|
4
|
+
data.tar.gz: 408ed3fd53d0537b559ca1ead8b2aa2e87e47abfefc9848ab2bb0df59f5f9492
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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 =
|
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 { |
|
38
|
+
result += files_found.map { |f| slice_source_folder(source_folder, f) }
|
31
39
|
end
|
32
40
|
end
|
33
41
|
result
|