multi_exiftool 0.13.0 → 0.14.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Changelog +3 -0
- data/README.md +21 -6
- data/lib/multi_exiftool.rb +7 -2
- data/lib/multi_exiftool/batch.rb +1 -1
- data/multi_exiftool.gemspec +3 -3
- data/regtest/read_all_tags.yml +1 -1
- data/test/test_batch.rb +8 -14
- data/test/test_functional_api.rb +69 -27
- 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: 52fde3f1ec2afcca37970b15b006910cfe5204fb309d09d2fed6aaf1058f6d99
|
4
|
+
data.tar.gz: fe392422e2a5076648d8b8995cbb7cc15cb1a42c340948ba5670ab713a9426f5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6d53477588cd9280322452eff83a8c31e12c878afeaac0462374f138cb05289a4a963fc373528f7efbfdd475609444d9b090d4a81c54a48b1fbec074cd5a808a
|
7
|
+
data.tar.gz: 5b0c7b775164a0032a2da1f2896c354bc32df822c85ffda2e1a36544fac88abc1044bb437395bea4adfee0915d50568fa360b75c3e12953c82a6b91b9bfe80aa
|
data/Changelog
CHANGED
data/README.md
CHANGED
@@ -66,11 +66,11 @@ If it is necessary to write different values to multiple files there is batch pr
|
|
66
66
|
require 'multi_exiftool'
|
67
67
|
|
68
68
|
# Object oriented approach
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
69
|
+
|
70
|
+
batch = MultiExiftool::Batch.new
|
71
|
+
Dir['*.jpg'].each_with_index do |filename, i|
|
72
|
+
values = {creator: 'Jan Friedrich', copyright: 'Public Domain', comment: "This is file number #{i+1}."}
|
73
|
+
batch.write filename, values
|
74
74
|
end
|
75
75
|
if batch.execute
|
76
76
|
puts 'ok'
|
@@ -79,6 +79,7 @@ else
|
|
79
79
|
end
|
80
80
|
|
81
81
|
# Functional approach
|
82
|
+
|
82
83
|
errors = MultiExiftool.batch do
|
83
84
|
Dir['*.jpg'].each_with_index do |filename, i|
|
84
85
|
values = {creator: 'Jan Friedrich', copyright: 'Public Domain', comment: "This is file number #{i+1}."}
|
@@ -88,7 +89,21 @@ end
|
|
88
89
|
if errors.empty?
|
89
90
|
puts 'ok'
|
90
91
|
else
|
91
|
-
puts
|
92
|
+
puts errors
|
93
|
+
end
|
94
|
+
|
95
|
+
# or alternative with block parameter as yielded Batch instance
|
96
|
+
|
97
|
+
errors = MultiExiftool.batch do |batch|
|
98
|
+
Dir['*.jpg'].each_with_index do |filename, i|
|
99
|
+
values = {creator: 'Jan Friedrich', copyright: 'Public Domain', comment: "This is file number #{i+1}."}
|
100
|
+
batch.write filename, values
|
101
|
+
end
|
102
|
+
end
|
103
|
+
if errors.empty?
|
104
|
+
puts 'ok'
|
105
|
+
else
|
106
|
+
puts errors
|
92
107
|
end
|
93
108
|
```
|
94
109
|
|
data/lib/multi_exiftool.rb
CHANGED
@@ -8,7 +8,7 @@ require_relative 'multi_exiftool/batch'
|
|
8
8
|
|
9
9
|
module MultiExiftool
|
10
10
|
|
11
|
-
VERSION = '0.
|
11
|
+
VERSION = '0.14.0'
|
12
12
|
|
13
13
|
@exiftool_command = 'exiftool'
|
14
14
|
|
@@ -78,7 +78,12 @@ module MultiExiftool
|
|
78
78
|
# # do error handling
|
79
79
|
# end
|
80
80
|
def batch &block
|
81
|
-
batch = Batch.new
|
81
|
+
batch = Batch.new
|
82
|
+
if block.arity == 0
|
83
|
+
batch.instance_exec &block
|
84
|
+
else
|
85
|
+
yield batch
|
86
|
+
end
|
82
87
|
batch.execute
|
83
88
|
batch.errors
|
84
89
|
end
|
data/lib/multi_exiftool/batch.rb
CHANGED
data/multi_exiftool.gemspec
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
2
|
-
# stub: multi_exiftool 0.
|
2
|
+
# stub: multi_exiftool 0.14.0 ruby lib
|
3
3
|
#
|
4
4
|
# This file is automatically generated by rim.
|
5
5
|
# PLEASE DO NOT EDIT IT DIRECTLY!
|
@@ -7,12 +7,12 @@
|
|
7
7
|
|
8
8
|
Gem::Specification.new do |s|
|
9
9
|
s.name = "multi_exiftool"
|
10
|
-
s.version = "0.
|
10
|
+
s.version = "0.14.0"
|
11
11
|
|
12
12
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
13
13
|
s.require_paths = ["lib"]
|
14
14
|
s.authors = ["Jan Friedrich"]
|
15
|
-
s.date = "2020-02-
|
15
|
+
s.date = "2020-02-04"
|
16
16
|
s.description = "This library a is wrapper for the ExifTool command-line application (https://exiftool.org) written by Phil Harvey. It is designed for dealing with multiple files at once by creating commands to call exiftool with various arguments, call it and parsing the results."
|
17
17
|
s.email = "janfri26@gmail.com"
|
18
18
|
s.files = ["./.aspell.pws", "Changelog", "Gemfile", "LICENSE", "README.md", "Rakefile", "lib/multi_exiftool", "lib/multi_exiftool.rb", "lib/multi_exiftool/batch.rb", "lib/multi_exiftool/executable.rb", "lib/multi_exiftool/reader.rb", "lib/multi_exiftool/values.rb", "lib/multi_exiftool/writer.rb", "multi_exiftool.gemspec", "regtest/read_all_tags.rb", "regtest/read_all_tags.yml", "regtest/test.jpg", "test/data", "test/data/a.jpg", "test/data/b.jpg", "test/data/c.jpg", "test/helper.rb", "test/test_batch.rb", "test/test_executable.rb", "test/test_exiftool_stuff.rb", "test/test_functional_api.rb", "test/test_reader.rb", "test/test_values.rb", "test/test_values_using_groups.rb", "test/test_writer.rb", "test/test_writer_groups.rb"]
|
data/regtest/read_all_tags.yml
CHANGED
data/test/test_batch.rb
CHANGED
@@ -17,29 +17,23 @@ class TestBatch < Test::Unit::TestCase
|
|
17
17
|
end
|
18
18
|
|
19
19
|
test 'only filenames and values' do
|
20
|
-
|
21
|
-
multiple_values
|
22
|
-
|
23
|
-
filenames.zip multiple_values do |filename, values|
|
24
|
-
write filename, values
|
25
|
-
end
|
20
|
+
batch = MultiExiftool::Batch.new
|
21
|
+
@filenames.zip @multiple_values do |filename, values|
|
22
|
+
batch.write filename, values
|
26
23
|
end
|
27
|
-
exiftool_args = filenames.zip(multiple_values).map do |filename, values|
|
24
|
+
exiftool_args = @filenames.zip(@multiple_values).map do |filename, values|
|
28
25
|
[MANDATORY_WRITER_ARGS, '-author=janfri', "-comment=Comment for file #{filename}", filename, '-execute']
|
29
26
|
end.flatten
|
30
27
|
assert_equal exiftool_args, batch.exiftool_args
|
31
28
|
end
|
32
29
|
|
33
30
|
test 'filenames, values and options' do
|
34
|
-
filenames = @filenames
|
35
|
-
multiple_values = @multiple_values
|
36
31
|
options = {overwrite_original: true}
|
37
|
-
batch = MultiExiftool::Batch.new
|
38
|
-
|
39
|
-
|
40
|
-
end
|
32
|
+
batch = MultiExiftool::Batch.new
|
33
|
+
@filenames.zip @multiple_values do |filename, values|
|
34
|
+
batch.write filename, values, options
|
41
35
|
end
|
42
|
-
exiftool_args = filenames.zip(multiple_values).map do |filename, _values|
|
36
|
+
exiftool_args = @filenames.zip(@multiple_values).map do |filename, _values|
|
43
37
|
[MANDATORY_WRITER_ARGS, '-overwrite_original', '-author=janfri', "-comment=Comment for file #{filename}", filename, '-execute']
|
44
38
|
end.flatten
|
45
39
|
assert_equal exiftool_args, batch.exiftool_args
|
data/test/test_functional_api.rb
CHANGED
@@ -189,6 +189,7 @@ class TestFunctionalApi < Test::Unit::TestCase
|
|
189
189
|
end
|
190
190
|
|
191
191
|
context 'batch' do
|
192
|
+
|
192
193
|
setup do
|
193
194
|
@filenames = %w(a.jpg b.jpg c.jpg)
|
194
195
|
@multiple_values = @filenames.map do |fn|
|
@@ -196,41 +197,82 @@ class TestFunctionalApi < Test::Unit::TestCase
|
|
196
197
|
end
|
197
198
|
end
|
198
199
|
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
200
|
+
context 'instance_exec' do
|
201
|
+
|
202
|
+
test 'only filenames and values' do
|
203
|
+
run_in_temp_dir do
|
204
|
+
filenames = @filenames
|
205
|
+
multiple_values = @multiple_values
|
206
|
+
errors = MultiExiftool.batch do
|
207
|
+
filenames.zip multiple_values do |filename, values|
|
208
|
+
write filename, values
|
209
|
+
end
|
206
210
|
end
|
211
|
+
assert_equal [], errors
|
212
|
+
values, errors = MultiExiftool.read(@filenames)
|
213
|
+
assert_equal ['Jan Friedrich'] * 3, values.map {|e| e['Author']}
|
214
|
+
assert_equal ['Comment for file a.jpg', 'Comment for file b.jpg', 'Comment for file c.jpg'], values.map {|e| e['Comment']}
|
215
|
+
assert_equal [], errors
|
216
|
+
assert_equal 3, Dir['*_original'].size
|
207
217
|
end
|
208
|
-
assert_equal [], errors
|
209
|
-
values, errors = MultiExiftool.read(@filenames)
|
210
|
-
assert_equal ['Jan Friedrich'] * 3, values.map {|e| e['Author']}
|
211
|
-
assert_equal ['Comment for file a.jpg', 'Comment for file b.jpg', 'Comment for file c.jpg'], values.map {|e| e['Comment']}
|
212
|
-
assert_equal [], errors
|
213
|
-
assert_equal 3, Dir['*_original'].size
|
214
218
|
end
|
219
|
+
|
220
|
+
test 'options with boolean argument' do
|
221
|
+
run_in_temp_dir do
|
222
|
+
filenames = @filenames
|
223
|
+
multiple_values = @multiple_values
|
224
|
+
options = {overwrite_original: true}
|
225
|
+
errors = MultiExiftool.batch do
|
226
|
+
filenames.zip multiple_values do |filename, values|
|
227
|
+
write filename, values, options
|
228
|
+
end
|
229
|
+
end
|
230
|
+
assert_equal [], errors
|
231
|
+
values, errors = MultiExiftool.read(@filenames)
|
232
|
+
assert_equal ['Jan Friedrich'] * 3, values.map {|e| e['Author']}
|
233
|
+
assert_equal ['Comment for file a.jpg', 'Comment for file b.jpg', 'Comment for file c.jpg'], values.map {|e| e['Comment']}
|
234
|
+
assert_equal [], errors
|
235
|
+
assert_equal [], Dir['*_original']
|
236
|
+
end
|
237
|
+
end
|
238
|
+
|
215
239
|
end
|
216
240
|
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
241
|
+
context 'yield' do
|
242
|
+
|
243
|
+
test 'only filenames and values' do
|
244
|
+
run_in_temp_dir do
|
245
|
+
errors = MultiExiftool.batch do |batch|
|
246
|
+
@filenames.zip @multiple_values do |filename, values|
|
247
|
+
batch.write filename, values
|
248
|
+
end
|
225
249
|
end
|
250
|
+
assert_equal [], errors
|
251
|
+
values, errors = MultiExiftool.read(@filenames)
|
252
|
+
assert_equal ['Jan Friedrich'] * 3, values.map {|e| e['Author']}
|
253
|
+
assert_equal ['Comment for file a.jpg', 'Comment for file b.jpg', 'Comment for file c.jpg'], values.map {|e| e['Comment']}
|
254
|
+
assert_equal [], errors
|
255
|
+
assert_equal 3, Dir['*_original'].size
|
256
|
+
end
|
257
|
+
end
|
258
|
+
|
259
|
+
test 'options with boolean argument' do
|
260
|
+
run_in_temp_dir do
|
261
|
+
options = {overwrite_original: true}
|
262
|
+
errors = MultiExiftool.batch do |batch|
|
263
|
+
@filenames.zip @multiple_values do |filename, values|
|
264
|
+
batch.write filename, values, options
|
265
|
+
end
|
266
|
+
end
|
267
|
+
assert_equal [], errors
|
268
|
+
values, errors = MultiExiftool.read(@filenames)
|
269
|
+
assert_equal ['Jan Friedrich'] * 3, values.map {|e| e['Author']}
|
270
|
+
assert_equal ['Comment for file a.jpg', 'Comment for file b.jpg', 'Comment for file c.jpg'], values.map {|e| e['Comment']}
|
271
|
+
assert_equal [], errors
|
272
|
+
assert_equal [], Dir['*_original']
|
226
273
|
end
|
227
|
-
assert_equal [], errors
|
228
|
-
values, errors = MultiExiftool.read(@filenames)
|
229
|
-
assert_equal ['Jan Friedrich'] * 3, values.map {|e| e['Author']}
|
230
|
-
assert_equal ['Comment for file a.jpg', 'Comment for file b.jpg', 'Comment for file c.jpg'], values.map {|e| e['Comment']}
|
231
|
-
assert_equal [], errors
|
232
|
-
assert_equal [], Dir['*_original']
|
233
274
|
end
|
275
|
+
|
234
276
|
end
|
235
277
|
|
236
278
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: multi_exiftool
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.14.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jan Friedrich
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-02-
|
11
|
+
date: 2020-02-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|