file_pipeline 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.rdoc +2 -2
- data/lib/file_pipeline/errors/failed_modification_error.rb +18 -2
- data/lib/file_pipeline/file_operations/exif_manipulable.rb +2 -0
- data/lib/file_pipeline/file_operations/file_operation.rb +1 -0
- data/lib/file_pipeline/pipeline.rb +6 -0
- data/lib/file_pipeline/versioned_file.rb +6 -9
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 228340816e7d09bd3f7eb9f5bac1b2c3ed0f1bf8912f4f8e963d04fcafcd167a
|
4
|
+
data.tar.gz: 2b9623501c37d0a70d2dbc22435b4af87d19f343f7750de38f4ea50b9677a2c9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7f738902aeb500a5cf05cff992da3eb30ef48e477a4001ef2380de412315638fb90822c1ba66f809e6fdfd1ce35e04d6ccc4a1061c574bfa5ff7abebdbfeef80
|
7
|
+
data.tar.gz: 6e231ba3deaabfa09166795aed6fa491ce54cb363a8a5893d4e32d70f18c5342835b85490df073e34b1df5e45dc1a9ca9b59eba28f0c094da9499477f3df1486
|
data/README.rdoc
CHANGED
@@ -384,11 +384,11 @@ The initializer can call +super+ and pass the +options+ hash and any
|
|
384
384
|
defaults (a hash with default options). This will update the defaults with
|
385
385
|
the actual options passed to +initialize+ and assign them to the
|
386
386
|
{#options}[rdoc-ref:FilePipeline::FileOperations::FileOperation#options]
|
387
|
-
attribute.
|
387
|
+
attribute. It will also transform any keys passed as strings into symbols.
|
388
388
|
|
389
389
|
If the initializer does not call +super+, it _must_ assign the options to
|
390
390
|
the <tt>@options</tt> instance variable or expose them through an
|
391
|
-
<tt>#options</tt> getter method.
|
391
|
+
<tt>#options</tt> getter method. It _should_ transform keys into symbols.
|
392
392
|
|
393
393
|
If it calls +super+ but must ensure some options are always set to a
|
394
394
|
specific value, those should be set after the call to +super+.
|
@@ -8,16 +8,32 @@ module FilePipeline
|
|
8
8
|
# The file opration that caused the error.
|
9
9
|
attr_reader :info
|
10
10
|
|
11
|
-
|
11
|
+
# FIXME: should contain original file name file name!
|
12
|
+
def initialize(msg = nil, info: nil, file: nil)
|
13
|
+
@file = file
|
12
14
|
@info = info
|
15
|
+
|
13
16
|
if info.respond_to?(:operation) && info.respond_to?(:log)
|
14
17
|
msg ||= "#{@info.operation&.name} with options"\
|
15
|
-
" #{@info.operation&.options} failed
|
18
|
+
" #{@info.operation&.options} failed on #{file}."
|
19
|
+
if original_error
|
20
|
+
msg += "\nException raised by the operation:"\
|
21
|
+
" #{original_error.inspect}. Backtrace:\n"
|
22
|
+
msg += original_backtrace if original_backtrace
|
23
|
+
end
|
16
24
|
else
|
17
25
|
msg ||= 'Operation failed' unless info
|
18
26
|
end
|
19
27
|
super msg
|
20
28
|
end
|
29
|
+
|
30
|
+
def original_backtrace
|
31
|
+
original_error&.backtrace&.join("\n")
|
32
|
+
end
|
33
|
+
|
34
|
+
def original_error
|
35
|
+
@info.log.find { |item| item.is_a? Exception }
|
36
|
+
end
|
21
37
|
end
|
22
38
|
end
|
23
39
|
end
|
@@ -28,6 +28,8 @@ module FilePipeline
|
|
28
28
|
exif, = read_exif out_file
|
29
29
|
values = exif.select { |tag| tags_to_delete.include? tag }
|
30
30
|
values_to_delete = values.transform_values { nil }
|
31
|
+
return 'Info: nothing to delete.' if values.empty?
|
32
|
+
|
31
33
|
log, = write_exif out_file, values_to_delete
|
32
34
|
[log, values]
|
33
35
|
end
|
@@ -31,6 +31,7 @@ module FilePipeline
|
|
31
31
|
# * +defaults+ - Default options for the subclass (hash).
|
32
32
|
# * +opts+ - Options passed to the sublass initializer (hash).
|
33
33
|
def initialize(opts, defaults = {})
|
34
|
+
opts.transform_keys!(&:to_sym)
|
34
35
|
@options = defaults.update(opts)
|
35
36
|
end
|
36
37
|
|
@@ -59,6 +59,12 @@ module FilePipeline
|
|
59
59
|
def batch_apply(versioned_files)
|
60
60
|
versioned_files.map { |file| Thread.new(file) { apply_to(file) } }
|
61
61
|
.map(&:value)
|
62
|
+
#--
|
63
|
+
# FIXME: This should obviously not just raise the same error again, but
|
64
|
+
# rather do someting meaningful.
|
65
|
+
#++
|
66
|
+
rescue Errors::FailedModificationError => e
|
67
|
+
raise e
|
62
68
|
end
|
63
69
|
|
64
70
|
# Initializes the class for <tt>file_operation</tt> (a string in
|
@@ -30,17 +30,13 @@ module FilePipeline
|
|
30
30
|
# *Caveat* it can not be ruled out that buggy or malignant file operations
|
31
31
|
# modify the original.
|
32
32
|
#
|
33
|
-
#--
|
34
|
-
# FIXME: protect the original
|
35
|
-
#++
|
36
|
-
#
|
37
33
|
# ===== Options
|
38
34
|
#
|
39
35
|
# <tt>target_suffix</ttm> is a string to be appended to the file that
|
40
36
|
# will be written by #finalize (the last version) if #finalize is to
|
41
|
-
# preserve the original. It is recommended to use a
|
42
|
-
# avoid clashes with other files in the directory.
|
43
|
-
def initialize(file, target_suffix: SecureRandom.
|
37
|
+
# preserve the original. It is recommended to use a randomized string
|
38
|
+
# (_default_) to avoid clashes with other files in the directory.
|
39
|
+
def initialize(file, target_suffix: SecureRandom.hex(4))
|
44
40
|
raise Errors::MissingVersionFileError, file: file unless File.exist? file
|
45
41
|
|
46
42
|
@original = file
|
@@ -72,8 +68,9 @@ module FilePipeline
|
|
72
68
|
# Will move the file to #directory if it is in another directory.
|
73
69
|
def <<(version_info)
|
74
70
|
file, info = version_info
|
75
|
-
|
76
|
-
|
71
|
+
if info&.failure
|
72
|
+
raise Errors::FailedModificationError, info: info, file: original
|
73
|
+
end
|
77
74
|
version = validate(file)
|
78
75
|
@history[version] = info
|
79
76
|
self
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: file_pipeline
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Martin Stein
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-
|
11
|
+
date: 2019-08-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: multi_exiftool
|