multi_exiftool 0.18.1 → 0.19.0

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.
@@ -1,63 +0,0 @@
1
- # encoding: utf-8
2
- # frozen_string_literal: true
3
-
4
- require_relative 'helper'
5
-
6
- class TestValuesUsingGroups < Test::Unit::TestCase
7
-
8
- setup do
9
- hash = {'EXIF' => {'FNumber' => 8, 'Author' => 'janfri'}}
10
- @values = MultiExiftool::Values.new(hash)
11
- end
12
-
13
- test 'bracket access' do
14
- assert_equal 8, @values['EXIF']['FNumber']
15
- assert_equal 'janfri', @values['EXIF']['Author']
16
- end
17
-
18
- test 'method access' do
19
- assert_equal 8, @values.exif.fnumber
20
- assert_equal 'janfri', @values.exif.author
21
- end
22
-
23
- test 'mixed access' do
24
- assert_equal 8, @values.exif['FNumber']
25
- assert_equal 'janfri', @values.exif['Author']
26
- assert_equal 8, @values['EXIF'].fnumber
27
- assert_equal 'janfri', @values['EXIF'].author
28
- end
29
-
30
- test 'block access without block parameter' do
31
- $ok = false
32
- $block_self = nil
33
- res = @values.exif do
34
- $ok = true
35
- $block_self = self
36
- end
37
- assert $ok, "Block for exif wasn't executed."
38
- assert_equal @values.exif, $block_self
39
- assert_equal @values.exif, res
40
- @values.iptc do
41
- assert false, "This block should not be executed because IPTC isn't available."
42
- end
43
- end
44
-
45
- test 'block access with block parameter' do
46
- $ok = false
47
- $self = self
48
- $block_param = nil
49
- res = @values.exif do |e|
50
- $ok = true
51
- $self = self
52
- $block_param = e
53
- end
54
- assert $ok, "Block for exif wasn't executed."
55
- assert_equal @values.exif, $block_param
56
- assert_equal self, $self
57
- assert_equal @values.exif, res
58
- @values.iptc do
59
- assert false, "This block should not be executed because IPTC isn't available."
60
- end
61
- end
62
-
63
- end
data/test/test_writer.rb DELETED
@@ -1,132 +0,0 @@
1
- # encoding: utf-8
2
- # frozen_string_literal: true
3
-
4
- require_relative 'helper'
5
-
6
- class TestWriter < Test::Unit::TestCase
7
-
8
- MANDATORY_ARGS = MultiExiftool::Writer.mandatory_args
9
-
10
- setup do
11
- @writer = MultiExiftool::Writer.new
12
- end
13
-
14
- context 'various filename combinations' do
15
-
16
- test 'exiftool_args method, no filenames set' do
17
- @writer.values = {comment: 'foo'}
18
- assert_raises MultiExiftool::Error do
19
- @writer.exiftool_args
20
- end
21
- @writer.filenames = []
22
- assert_raises MultiExiftool::Error do
23
- @writer.exiftool_args
24
- end
25
- end
26
-
27
- test 'one filename as string' do
28
- @writer.values = {comment: 'foo'}
29
- @writer.filenames = 'a.jpg'
30
- exiftool_args = MANDATORY_ARGS + %w(-comment=foo a.jpg)
31
- assert_equal exiftool_args, @writer.exiftool_args
32
- end
33
-
34
- test 'filenames with spaces' do
35
- @writer.filenames = ['one file with spaces.jpg', 'another file with spaces.tif']
36
- @writer.values = {comment: 'foo'}
37
- exiftool_args = MANDATORY_ARGS + ['-comment=foo', 'one file with spaces.jpg',
38
- 'another file with spaces.tif']
39
- assert_equal exiftool_args, @writer.exiftool_args
40
- end
41
-
42
- end
43
-
44
- context 'exiftool_args method, various tags' do
45
-
46
- setup do
47
- @writer.filenames = %w(a.jpg b.jpg c.jpg)
48
- end
49
-
50
- test 'simple case' do
51
- @writer.values = {comment: 'foo'}
52
- exiftool_args = MANDATORY_ARGS + %w(-comment=foo a.jpg b.jpg c.jpg)
53
- assert_equal exiftool_args, @writer.exiftool_args
54
- end
55
-
56
- test 'no values set' do
57
- assert_raises MultiExiftool::Error do
58
- @writer.exiftool_args
59
- end
60
- @writer.values = {}
61
- assert_raises MultiExiftool::Error do
62
- @writer.exiftool_args
63
- end
64
- end
65
-
66
- test 'tags with spaces in values' do
67
- @writer.values = {title: 'title', comment: 'some comment'}
68
- exiftool_args = MANDATORY_ARGS + ['-title=title', '-comment=some comment', 'a.jpg', 'b.jpg', 'c.jpg']
69
- assert_equal exiftool_args, @writer.exiftool_args
70
- end
71
-
72
- test 'tags with rational value' do
73
- @writer.values ={shutterspeed: Rational(1, 125)}
74
- exiftool_args = MANDATORY_ARGS + %w(-shutterspeed=1/125 a.jpg b.jpg c.jpg)
75
- assert_equal exiftool_args, @writer.exiftool_args
76
- end
77
-
78
- test 'tags with array-like values' do
79
- @writer.values = {keywords: ['one', 'two', 'and three']}
80
- exiftool_args = MANDATORY_ARGS + ['-keywords=one', '-keywords=two', '-keywords=and three',
81
- 'a.jpg', 'b.jpg', 'c.jpg']
82
- assert_equal exiftool_args, @writer.exiftool_args
83
- end
84
-
85
- test 'options with boolean argument' do
86
- @writer.values = {comment: 'foo'}
87
- @writer.options = {overwrite_original: true}
88
- exiftool_args = MANDATORY_ARGS + %w(-overwrite_original -comment=foo a.jpg b.jpg c.jpg)
89
- assert_equal exiftool_args, @writer.exiftool_args
90
- end
91
-
92
- test 'numerical flag' do
93
- @writer.values = {comment: 'foo'}
94
- @writer.numerical = true
95
- exiftool_args = MANDATORY_ARGS + %w(-n -comment=foo a.jpg b.jpg c.jpg)
96
- assert_equal exiftool_args, @writer.exiftool_args
97
- end
98
-
99
- test 'overwrite_original flag' do
100
- @writer.values = {comment: 'foo'}
101
- @writer.overwrite_original = true
102
- exiftool_args = MANDATORY_ARGS + %w(-overwrite_original -comment=foo a.jpg b.jpg c.jpg)
103
- assert_equal exiftool_args, @writer.exiftool_args
104
- end
105
-
106
- end
107
-
108
- context 'write method' do
109
-
110
- test 'successful write' do
111
- run_in_temp_dir do
112
- @writer.filenames = %w(a.jpg b.jpg c.jpg)
113
- @writer.values = {comment: 'foo'}
114
- rc = @writer.write
115
- assert rc
116
- assert_equal [], @writer.errors
117
- end
118
- end
119
-
120
- test 'unsuccessful write' do
121
- run_in_temp_dir do
122
- @writer.filenames = %w(a.jpg xxx)
123
- @writer.values = {comment: 'foo', bar: 'x'}
124
- rc = @writer.write
125
- assert !rc
126
- assert_equal ["Warning: Tag 'bar' is not defined", "Error: File not found - xxx"], @writer.errors
127
- end
128
- end
129
-
130
- end
131
-
132
- end
@@ -1,50 +0,0 @@
1
- # encoding: utf-8
2
- # frozen_string_literal: true
3
-
4
- require_relative 'helper'
5
- require 'yaml'
6
-
7
- class TestWriterGroups < Test::Unit::TestCase
8
-
9
- MANDATORY_ARGS = MultiExiftool::Writer.mandatory_args
10
-
11
- setup do
12
- @writer = MultiExiftool::Writer.new
13
- @writer.filenames = %w(a.jpg b.jpg c.jpg)
14
- end
15
-
16
- test 'simple case' do
17
- @writer.values = {exif: {comment: 'test'} }
18
- exiftool_args = MANDATORY_ARGS + %w(-exif:comment=test a.jpg b.jpg c.jpg)
19
- assert_equal exiftool_args, @writer.exiftool_args
20
- end
21
-
22
- test 'more than one groups and tags' do
23
- @writer.values = YAML.load <<-END
24
- exif:
25
- author: Mr. X
26
- comment: some comment
27
- xmp:
28
- author: Mr. X
29
- subjectlocation: somewhere else
30
- END
31
- exiftool_args = MANDATORY_ARGS + ['-exif:author=Mr. X', '-exif:comment=some comment',
32
- '-xmp:author=Mr. X', '-xmp:subjectlocation=somewhere else',
33
- 'a.jpg', 'b.jpg', 'c.jpg']
34
- assert_equal exiftool_args, @writer.exiftool_args
35
- end
36
-
37
- test 'tags with array-like values' do
38
- @writer.values = YAML.load <<-END
39
- exif:
40
- keywords:
41
- - one
42
- - two
43
- - and three
44
- END
45
- exiftool_args = MANDATORY_ARGS + ['-exif:keywords=one', '-exif:keywords=two', '-exif:keywords=and three',
46
- 'a.jpg', 'b.jpg', 'c.jpg']
47
- assert_equal exiftool_args, @writer.exiftool_args
48
- end
49
-
50
- end