mini_exiftool 2.11.0 → 2.12.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.
- checksums.yaml +4 -4
- data/Changelog +4 -0
- data/lib/mini_exiftool.rb +1 -1
- metadata +42 -46
- data/.aspell.pws +0 -123
- data/Rakefile +0 -40
- data/mini_exiftool.gemspec +0 -31
- data/regtest/read_all.rb +0 -12
- data/regtest/read_all.yml +0 -575
- data/test/data/Bad_PreviewIFD.jpg +0 -0
- data/test/data/Canon.jpg +0 -0
- data/test/data/INFORMATION +0 -3
- data/test/data/invalid_byte_sequence_in_utf8.json +0 -4
- data/test/data/invalid_rational.json +0 -3
- data/test/data/test.jpg +0 -0
- data/test/data/test.jpg.json +0 -106
- data/test/data/test_coordinates.jpg +0 -0
- data/test/data/test_encodings.jpg +0 -0
- data/test/data/test_special_dates.jpg +0 -0
- data/test/helpers_for_test.rb +0 -25
- data/test/test_bad_preview_ifd.rb +0 -29
- data/test/test_class_methods.rb +0 -80
- data/test/test_composite.rb +0 -19
- data/test/test_copy_tags_from.rb +0 -55
- data/test/test_dumping.rb +0 -80
- data/test/test_encodings.rb +0 -30
- data/test/test_filename_access.rb +0 -60
- data/test/test_from_hash.rb +0 -22
- data/test/test_instance_methods.rb +0 -24
- data/test/test_invalid_byte_sequence_in_utf8.rb +0 -29
- data/test/test_invalid_rational.rb +0 -13
- data/test/test_io.rb +0 -67
- data/test/test_pstore.rb +0 -37
- data/test/test_read.rb +0 -49
- data/test/test_read_coordinates.rb +0 -18
- data/test/test_read_numerical.rb +0 -40
- data/test/test_save.rb +0 -73
- data/test/test_special.rb +0 -42
- data/test/test_special_dates.rb +0 -52
- data/test/test_write.rb +0 -161
data/test/test_read_numerical.rb
DELETED
@@ -1,40 +0,0 @@
|
|
1
|
-
# -- encoding: utf-8 --
|
2
|
-
require 'helpers_for_test'
|
3
|
-
|
4
|
-
class TestReadNumerical < TestCase
|
5
|
-
|
6
|
-
def setup
|
7
|
-
@data_dir = File.dirname(__FILE__) + '/data'
|
8
|
-
@filename_test = @data_dir + '/test.jpg'
|
9
|
-
@mini_exiftool_num = MiniExiftool.new @filename_test, :numerical => true
|
10
|
-
end
|
11
|
-
|
12
|
-
def test_access_numerical
|
13
|
-
assert_equal 'DYNAX 7D', @mini_exiftool_num['Model']
|
14
|
-
assert_equal 'MLT0', @mini_exiftool_num['maker_note_version']
|
15
|
-
assert_equal 'MLT0', @mini_exiftool_num[:MakerNoteVersion]
|
16
|
-
assert_equal 'MLT0', @mini_exiftool_num[:maker_note_version]
|
17
|
-
assert_equal 'MLT0', @mini_exiftool_num.maker_note_version
|
18
|
-
assert_equal 400, @mini_exiftool_num.iso
|
19
|
-
end
|
20
|
-
|
21
|
-
def test_conversion_numerical
|
22
|
-
assert_kind_of String, @mini_exiftool_num.model
|
23
|
-
assert_kind_of Time, @mini_exiftool_num['DateTimeOriginal']
|
24
|
-
assert_kind_of Float, @mini_exiftool_num['MaxApertureValue']
|
25
|
-
assert_kind_of Integer, @mini_exiftool_num.flash
|
26
|
-
assert_kind_of String, @mini_exiftool_num.exif_version
|
27
|
-
assert_kind_of Integer, @mini_exiftool_num['ExposureCompensation']
|
28
|
-
assert_kind_of String, (@mini_exiftool_num['SubjectLocation'] || @mini_exiftool_num['SubjectArea'])
|
29
|
-
assert_kind_of Array, @mini_exiftool_num['Keywords']
|
30
|
-
assert_kind_of String, @mini_exiftool_num['SupplementalCategories']
|
31
|
-
end
|
32
|
-
|
33
|
-
# Catching github issue [#40]
|
34
|
-
# Values with leading zeros can have further zeros in it
|
35
|
-
# Thanks to jvradelis
|
36
|
-
def test_digits_starting_with_zero_and_has_further_zeros
|
37
|
-
assert_equal '0300', @mini_exiftool_num['PrintIMVersion']
|
38
|
-
end
|
39
|
-
|
40
|
-
end
|
data/test/test_save.rb
DELETED
@@ -1,73 +0,0 @@
|
|
1
|
-
# -- encoding: utf-8 --
|
2
|
-
require 'digest/md5'
|
3
|
-
require 'fileutils'
|
4
|
-
require 'tempfile'
|
5
|
-
require 'helpers_for_test'
|
6
|
-
|
7
|
-
class TestSave < TestCase
|
8
|
-
|
9
|
-
include TempfileTest
|
10
|
-
|
11
|
-
def setup
|
12
|
-
super
|
13
|
-
@org_filename = @data_dir + '/test.jpg'
|
14
|
-
FileUtils.cp(@org_filename, @temp_filename)
|
15
|
-
@mini_exiftool = MiniExiftool.new @temp_filename
|
16
|
-
@mini_exiftool_num = MiniExiftool.new @temp_filename, :numerical => true
|
17
|
-
@org_md5 = Digest::MD5.hexdigest(File.read(@org_filename))
|
18
|
-
end
|
19
|
-
|
20
|
-
def test_allowed_value
|
21
|
-
@mini_exiftool_num['Orientation'] = 2
|
22
|
-
result = @mini_exiftool_num.save
|
23
|
-
assert_equal true, result
|
24
|
-
assert_equal @org_md5, Digest::MD5.hexdigest(File.read(@org_filename))
|
25
|
-
assert_not_equal @org_md5, Digest::MD5.hexdigest(File.read(@temp_filename))
|
26
|
-
assert_equal false, @mini_exiftool_num.changed?
|
27
|
-
result = @mini_exiftool_num.save
|
28
|
-
assert_equal false, result
|
29
|
-
end
|
30
|
-
|
31
|
-
def test_non_allowed_value
|
32
|
-
@mini_exiftool['Orientation'] = 'some string'
|
33
|
-
result = @mini_exiftool.save
|
34
|
-
assert_equal false, result
|
35
|
-
assert_equal 1, @mini_exiftool.errors.size
|
36
|
-
assert_match(/Can't convert IFD0:Orientation \(not in PrintConv\)/,
|
37
|
-
@mini_exiftool.errors['Orientation'])
|
38
|
-
assert @mini_exiftool.changed?
|
39
|
-
assert @mini_exiftool.changed_tags.include?('Orientation')
|
40
|
-
end
|
41
|
-
|
42
|
-
def test_no_changing_of_file_when_error
|
43
|
-
@mini_exiftool['ISO'] = 800
|
44
|
-
@mini_exiftool['Orientation'] = 'some value'
|
45
|
-
@mini_exiftool['ExposureTime'] = '1/30'
|
46
|
-
result = @mini_exiftool.save
|
47
|
-
assert_equal false, result
|
48
|
-
assert_equal @org_md5, Digest::MD5.hexdigest(File.read(@org_filename))
|
49
|
-
assert_equal @org_md5, Digest::MD5.hexdigest(File.read(@temp_filename))
|
50
|
-
end
|
51
|
-
|
52
|
-
def test_value_encoding
|
53
|
-
special_string = 'äöü'
|
54
|
-
@mini_exiftool.title = special_string
|
55
|
-
assert @mini_exiftool.save
|
56
|
-
@mini_exiftool.reload
|
57
|
-
assert_equal Encoding::UTF_8, @mini_exiftool.title.encoding
|
58
|
-
assert_equal special_string, @mini_exiftool.title
|
59
|
-
end
|
60
|
-
|
61
|
-
def test_save_bang
|
62
|
-
@mini_exiftool.orientation = 'some value'
|
63
|
-
exception = false
|
64
|
-
begin
|
65
|
-
@mini_exiftool.save!
|
66
|
-
rescue MiniExiftool::Error => e
|
67
|
-
assert_match /Orientation/, e.message
|
68
|
-
exception = true
|
69
|
-
end
|
70
|
-
assert exception, "No exception when save! with error."
|
71
|
-
end
|
72
|
-
|
73
|
-
end
|
data/test/test_special.rb
DELETED
@@ -1,42 +0,0 @@
|
|
1
|
-
# -- encoding: utf-8 --
|
2
|
-
require 'helpers_for_test'
|
3
|
-
|
4
|
-
class TestSpecial < TestCase
|
5
|
-
|
6
|
-
include TempfileTest
|
7
|
-
|
8
|
-
CAPTION_ABSTRACT = 'Some text for caption abstract'
|
9
|
-
|
10
|
-
def setup
|
11
|
-
super
|
12
|
-
@org_filename = @data_dir + '/Canon.jpg'
|
13
|
-
FileUtils.cp @org_filename, @temp_filename
|
14
|
-
@canon = MiniExiftool.new @temp_filename
|
15
|
-
end
|
16
|
-
|
17
|
-
# Catching bug [#8073]
|
18
|
-
# Thanks to Eric Young
|
19
|
-
def test_special_chars
|
20
|
-
assert_not_nil @canon['Self-timer']
|
21
|
-
assert_not_nil @canon.self_timer
|
22
|
-
# preserving the original tag name
|
23
|
-
assert @canon.tags.include?('Self-timer') || @canon.tags.include?('SelfTimer')
|
24
|
-
assert !@canon.tags.include?('self_timer')
|
25
|
-
end
|
26
|
-
|
27
|
-
# Catching bug with writing caption-abstract
|
28
|
-
# Thanks to Robin Romahn
|
29
|
-
def test_caption_abstract_sensitive
|
30
|
-
@canon['caption-abstract'] = CAPTION_ABSTRACT
|
31
|
-
assert @canon.changed_tags.include?('Caption-Abstract')
|
32
|
-
assert @canon.save
|
33
|
-
assert_equal CAPTION_ABSTRACT, @canon.caption_abstract
|
34
|
-
end
|
35
|
-
|
36
|
-
def test_caption_abstract_non_sesitive
|
37
|
-
@canon.caption_abstract = CAPTION_ABSTRACT.reverse
|
38
|
-
assert @canon.save
|
39
|
-
assert_equal CAPTION_ABSTRACT.reverse, @canon.caption_abstract
|
40
|
-
end
|
41
|
-
|
42
|
-
end
|
data/test/test_special_dates.rb
DELETED
@@ -1,52 +0,0 @@
|
|
1
|
-
# -- encoding: utf-8 --
|
2
|
-
require 'date'
|
3
|
-
require 'helpers_for_test'
|
4
|
-
|
5
|
-
class TestSpecialDates < TestCase
|
6
|
-
|
7
|
-
include TempfileTest
|
8
|
-
|
9
|
-
def setup
|
10
|
-
super
|
11
|
-
@org_filename = @data_dir + '/test_special_dates.jpg'
|
12
|
-
FileUtils.cp @org_filename, @temp_filename
|
13
|
-
@mini_exiftool = MiniExiftool.new @temp_filename
|
14
|
-
@mini_exiftool_datetime = MiniExiftool.new @temp_filename,
|
15
|
-
:timestamps => DateTime
|
16
|
-
end
|
17
|
-
|
18
|
-
# Catching bug [#16328] (1st part)
|
19
|
-
# Thanks to unknown
|
20
|
-
def test_datetime
|
21
|
-
datetime_original = @mini_exiftool.datetime_original
|
22
|
-
if datetime_original
|
23
|
-
assert_kind_of Time, datetime_original
|
24
|
-
else
|
25
|
-
assert_equal false, datetime_original
|
26
|
-
end
|
27
|
-
assert_kind_of DateTime, @mini_exiftool_datetime.datetime_original
|
28
|
-
assert_raise MiniExiftool::Error do
|
29
|
-
@mini_exiftool.timestamps = String
|
30
|
-
@mini_exiftool.reload
|
31
|
-
end
|
32
|
-
@mini_exiftool.timestamps = DateTime
|
33
|
-
@mini_exiftool.reload
|
34
|
-
assert_equal @mini_exiftool_datetime.datetime_original,
|
35
|
-
@mini_exiftool.datetime_original
|
36
|
-
end
|
37
|
-
|
38
|
-
# Catching bug [#16328] (2nd part)
|
39
|
-
# Thanks to Cecil Coupe
|
40
|
-
def test_invalid_date
|
41
|
-
assert_equal false, @mini_exiftool.modify_date
|
42
|
-
end
|
43
|
-
|
44
|
-
def test_time_zone
|
45
|
-
s = '1961-08-13 12:08:25+01:00'
|
46
|
-
assert_equal Time.parse(s), @mini_exiftool.preview_date_time
|
47
|
-
assert_equal DateTime.parse(s),
|
48
|
-
@mini_exiftool_datetime.preview_date_time
|
49
|
-
end
|
50
|
-
|
51
|
-
end
|
52
|
-
|
data/test/test_write.rb
DELETED
@@ -1,161 +0,0 @@
|
|
1
|
-
# -- encoding: utf-8 --
|
2
|
-
require 'digest/md5'
|
3
|
-
require 'fileutils'
|
4
|
-
require 'tempfile'
|
5
|
-
require 'helpers_for_test'
|
6
|
-
|
7
|
-
class TestWrite < TestCase
|
8
|
-
|
9
|
-
def setup
|
10
|
-
@temp_file = Tempfile.new('test')
|
11
|
-
@temp_file.close
|
12
|
-
@temp_filename = @temp_file.path
|
13
|
-
@org_filename = File.dirname(__FILE__) + '/data/test.jpg'
|
14
|
-
FileUtils.cp(@org_filename, @temp_filename)
|
15
|
-
@mini_exiftool = MiniExiftool.new @temp_filename
|
16
|
-
@mini_exiftool_num = MiniExiftool.new @temp_filename, :numerical => true
|
17
|
-
end
|
18
|
-
|
19
|
-
def teardown
|
20
|
-
@temp_file.delete
|
21
|
-
end
|
22
|
-
|
23
|
-
def test_access_existing_tags
|
24
|
-
assert_equal 'Horizontal (normal)', @mini_exiftool['Orientation']
|
25
|
-
@mini_exiftool['Orientation'] = 'some string'
|
26
|
-
assert_equal 'some string', @mini_exiftool['Orientation']
|
27
|
-
assert_equal false, @mini_exiftool.changed?('Orientation')
|
28
|
-
@mini_exiftool['Orientation'] = 2
|
29
|
-
assert_equal 2, @mini_exiftool['Orientation']
|
30
|
-
assert @mini_exiftool.changed_tags.include?('Orientation')
|
31
|
-
@mini_exiftool.save
|
32
|
-
assert_equal 'Mirror horizontal', @mini_exiftool['Orientation']
|
33
|
-
@mini_exiftool_num.reload
|
34
|
-
assert_equal 2, @mini_exiftool_num['Orientation']
|
35
|
-
end
|
36
|
-
|
37
|
-
def test_access_existing_tags_numerical
|
38
|
-
assert_equal 1, @mini_exiftool_num['Orientation']
|
39
|
-
@mini_exiftool_num['Orientation'] = 2
|
40
|
-
assert_equal 2, @mini_exiftool_num['Orientation']
|
41
|
-
assert_equal 2, @mini_exiftool_num.orientation
|
42
|
-
@mini_exiftool_num.orientation = 3
|
43
|
-
assert_equal 3, @mini_exiftool_num.orientation
|
44
|
-
assert @mini_exiftool_num.changed_tags.include?('Orientation')
|
45
|
-
@mini_exiftool_num.save
|
46
|
-
assert_equal 3, @mini_exiftool_num['Orientation']
|
47
|
-
@mini_exiftool.reload
|
48
|
-
assert_equal 'Rotate 180', @mini_exiftool['Orientation']
|
49
|
-
end
|
50
|
-
|
51
|
-
def test_access_non_writable_tags
|
52
|
-
@mini_exiftool_num['FileSize'] = 1
|
53
|
-
assert_equal true, @mini_exiftool_num.changed?
|
54
|
-
@mini_exiftool_num['SomeNonWritableName'] = 'test'
|
55
|
-
assert_equal true, @mini_exiftool_num.changed?
|
56
|
-
end
|
57
|
-
|
58
|
-
# Catching rubyforge bug [#29596]
|
59
|
-
# Thanks to Michael Grove for reporting
|
60
|
-
# Part 1
|
61
|
-
def test_quotes_in_values
|
62
|
-
caption = "\"String in quotes\""
|
63
|
-
@mini_exiftool.caption = caption
|
64
|
-
assert_equal true, @mini_exiftool.save, 'Saving error'
|
65
|
-
@mini_exiftool.reload
|
66
|
-
assert_equal caption, @mini_exiftool.caption
|
67
|
-
end
|
68
|
-
|
69
|
-
# Catching rubyforge bug [#29596]
|
70
|
-
# Thanks to Michael Grove for reporting
|
71
|
-
# Part 2
|
72
|
-
def test_quotes_and_apostrophe_in_values
|
73
|
-
caption = caption = "\"Watch your step, it's slippery.\""
|
74
|
-
@mini_exiftool.caption = caption
|
75
|
-
assert_equal true, @mini_exiftool.save, 'Saving error'
|
76
|
-
@mini_exiftool.reload
|
77
|
-
assert_equal caption, @mini_exiftool.caption
|
78
|
-
end
|
79
|
-
|
80
|
-
def test_time_conversion
|
81
|
-
t = Time.now
|
82
|
-
@mini_exiftool_num['DateTimeOriginal'] = t
|
83
|
-
assert_kind_of Time, @mini_exiftool_num['DateTimeOriginal']
|
84
|
-
assert_equal true, @mini_exiftool_num.changed_tags.include?('DateTimeOriginal')
|
85
|
-
@mini_exiftool_num.save
|
86
|
-
assert_equal false, @mini_exiftool_num.changed?
|
87
|
-
assert_kind_of Time, @mini_exiftool_num['DateTimeOriginal']
|
88
|
-
assert_equal t.to_s, @mini_exiftool_num['DateTimeOriginal'].to_s
|
89
|
-
end
|
90
|
-
|
91
|
-
def test_float_conversion
|
92
|
-
assert_kind_of Float, @mini_exiftool_num['BrightnessValue']
|
93
|
-
new_time = @mini_exiftool_num['BrightnessValue'] + 1
|
94
|
-
@mini_exiftool_num['BrightnessValue'] = new_time
|
95
|
-
assert_equal new_time, @mini_exiftool_num['BrightnessValue']
|
96
|
-
assert_equal true, @mini_exiftool_num.changed_tags.include?('BrightnessValue')
|
97
|
-
@mini_exiftool_num.save
|
98
|
-
assert_kind_of Float, @mini_exiftool_num['BrightnessValue']
|
99
|
-
assert_equal new_time, @mini_exiftool_num['BrightnessValue']
|
100
|
-
end
|
101
|
-
|
102
|
-
def test_integer_conversion
|
103
|
-
assert_kind_of Integer, @mini_exiftool_num['MeteringMode']
|
104
|
-
new_mode = @mini_exiftool_num['MeteringMode'] - 1
|
105
|
-
@mini_exiftool_num['MeteringMode'] = new_mode
|
106
|
-
assert_equal new_mode, @mini_exiftool_num['MeteringMode']
|
107
|
-
assert @mini_exiftool_num.changed_tags.include?('MeteringMode')
|
108
|
-
@mini_exiftool_num.save
|
109
|
-
assert_equal new_mode, @mini_exiftool_num['MeteringMode']
|
110
|
-
end
|
111
|
-
|
112
|
-
def test_rational_conversion
|
113
|
-
new_exposure_time = Rational(1, 125)
|
114
|
-
@mini_exiftool.exposure_time = new_exposure_time
|
115
|
-
assert @mini_exiftool.changed?, 'No changing of value.'
|
116
|
-
ok = @mini_exiftool.save
|
117
|
-
assert ok, 'Saving failed.'
|
118
|
-
@mini_exiftool.reload
|
119
|
-
assert_equal new_exposure_time, @mini_exiftool.exposure_time
|
120
|
-
end
|
121
|
-
|
122
|
-
def test_list_conversion
|
123
|
-
arr = ['a', 'b', 'c']
|
124
|
-
@mini_exiftool['Keywords'] = arr
|
125
|
-
ok = @mini_exiftool.save
|
126
|
-
assert ok
|
127
|
-
assert_equal arr, @mini_exiftool['Keywords']
|
128
|
-
arr = ['text, with', 'commas, let us look']
|
129
|
-
@mini_exiftool['Keywords'] = arr
|
130
|
-
ok = @mini_exiftool.save
|
131
|
-
assert ok
|
132
|
-
if MiniExiftool.exiftool_version.to_f < 7.41
|
133
|
-
assert_equal ['text', 'with', 'commas', 'let us look'], @mini_exiftool['Keywords']
|
134
|
-
else
|
135
|
-
assert_equal arr, @mini_exiftool['Keywords']
|
136
|
-
end
|
137
|
-
end
|
138
|
-
|
139
|
-
def test_revert_one
|
140
|
-
@mini_exiftool_num['Orientation'] = 2
|
141
|
-
@mini_exiftool_num['ISO'] = 200
|
142
|
-
res = @mini_exiftool_num.revert 'Orientation'
|
143
|
-
assert_equal 1, @mini_exiftool_num['Orientation']
|
144
|
-
assert_equal 200, @mini_exiftool_num['ISO']
|
145
|
-
assert_equal true, res
|
146
|
-
res = @mini_exiftool_num.revert 'Orientation'
|
147
|
-
assert_equal false, res
|
148
|
-
end
|
149
|
-
|
150
|
-
def test_revert_all
|
151
|
-
@mini_exiftool_num['Orientation'] = 2
|
152
|
-
@mini_exiftool_num['ISO'] = 200
|
153
|
-
res = @mini_exiftool_num.revert
|
154
|
-
assert_equal 1, @mini_exiftool_num['Orientation']
|
155
|
-
assert_equal 400, @mini_exiftool_num['ISO']
|
156
|
-
assert_equal true, res
|
157
|
-
res = @mini_exiftool_num.revert
|
158
|
-
assert_equal false, res
|
159
|
-
end
|
160
|
-
|
161
|
-
end
|