multi_exiftool 0.4.3 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Changelog +5 -0
- data/Rakefile +1 -1
- data/lib/multi_exiftool/values.rb +33 -6
- data/test/temp/a.jpg +0 -0
- data/test/temp/b.jpg +0 -0
- data/test/temp/c.jpg +0 -0
- data/test/test_reader.rb +2 -2
- data/test/test_values.rb +13 -4
- data/test/test_writer.rb +5 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: '08cd6e1d9c6c6ee77dcfc1a92dd00772419d0148'
|
4
|
+
data.tar.gz: 0e1252f4eebe67f630e7c4e6d79b8632a8bc8e08
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a50fefa13b79f31013369a5441416f01ca0f521302ab47c5e1f9bbf3da2872aa716bc859e22fc5ed9c8c710781f34093fd4b6d31de7364b42d155c8fe7c20eaa
|
7
|
+
data.tar.gz: add6854570c75de94fcb73aa2bdcd309cb3fbc4b424ac040ad1d518ff10e4d772e1c86a4cefbf3e753e286606c5654fc900f5d7c4cc0b46cd0d01583ba253e54
|
data/Changelog
CHANGED
data/Rakefile
CHANGED
@@ -5,7 +5,7 @@ require 'regtest/task'
|
|
5
5
|
|
6
6
|
Rim.setup do |p|
|
7
7
|
p.name = 'multi_exiftool'
|
8
|
-
p.version = '0.
|
8
|
+
p.version = '0.5.0'
|
9
9
|
p.authors = 'Jan Friedrich'
|
10
10
|
p.email = 'janfri26@gmail.com'
|
11
11
|
p.summary = 'This library is a wrapper for the ExifTool command-line application (http://www.sno.phy.queensu.ca/~phil/exiftool).'
|
@@ -9,28 +9,55 @@ module MultiExiftool
|
|
9
9
|
# method_missing.
|
10
10
|
class Values
|
11
11
|
|
12
|
-
|
12
|
+
@tag_map = {}
|
13
13
|
|
14
14
|
def initialize values
|
15
15
|
@values = {}
|
16
|
-
@tags = Set.new
|
17
16
|
values.map do |tag,val|
|
18
|
-
|
17
|
+
unified_tag = Values.unify_tag(tag)
|
18
|
+
Values.tag_map[unified_tag] = tag
|
19
19
|
val = val.kind_of?(Hash) ? Values.new(val) : val
|
20
|
-
@values[
|
20
|
+
@values[unified_tag] = val
|
21
21
|
end
|
22
22
|
end
|
23
23
|
|
24
|
+
# Gets the (posible converted) value for a tag
|
25
|
+
# (tag will be unified, i.e. FNumber, fnumber or f_number
|
26
|
+
# can be used for FNumber)
|
24
27
|
def [](tag)
|
25
28
|
parse_value(@values[Values.unify_tag(tag)])
|
26
29
|
end
|
27
30
|
|
28
|
-
|
29
|
-
|
31
|
+
# Gets the original tag names of this instance
|
32
|
+
def tags
|
33
|
+
@values.keys.map {|tag| Values.tag_map[tag]}
|
34
|
+
end
|
35
|
+
|
36
|
+
# Generate a hash representation of this instance
|
37
|
+
# with original tag names es keys and converted
|
38
|
+
# values as values
|
39
|
+
def to_h
|
40
|
+
@values.inject(Hash.new) do |h,a|
|
41
|
+
k, v = a
|
42
|
+
h[Values.tag_map[k]] = parse_value(v)
|
43
|
+
h
|
44
|
+
end
|
30
45
|
end
|
31
46
|
|
47
|
+
alias to_hash to_h
|
48
|
+
|
32
49
|
private
|
33
50
|
|
51
|
+
class << self
|
52
|
+
|
53
|
+
attr_reader :tag_map
|
54
|
+
|
55
|
+
def unify_tag tag
|
56
|
+
tag.gsub(/[-_]/, '').downcase
|
57
|
+
end
|
58
|
+
|
59
|
+
end
|
60
|
+
|
34
61
|
def method_missing tag, *args, &block
|
35
62
|
res = self[Values.unify_tag(tag.to_s)]
|
36
63
|
if res && block_given?
|
data/test/temp/a.jpg
CHANGED
Binary file
|
data/test/temp/b.jpg
CHANGED
Binary file
|
data/test/temp/c.jpg
CHANGED
Binary file
|
data/test/test_reader.rb
CHANGED
@@ -119,7 +119,7 @@ class TestReader < Test::Unit::TestCase
|
|
119
119
|
@reader.tags = %w(fnumber)
|
120
120
|
res = @reader.read
|
121
121
|
assert_equal [5.6, 6.7, 8], res.map {|e| e['FNumber']}
|
122
|
-
assert_equal
|
122
|
+
assert_equal %w(SourceFile FNumber), res.first.tags
|
123
123
|
assert_equal [], @reader.errors
|
124
124
|
end
|
125
125
|
end
|
@@ -130,7 +130,7 @@ class TestReader < Test::Unit::TestCase
|
|
130
130
|
@reader.tags = :fnumber
|
131
131
|
res = @reader.read
|
132
132
|
assert_equal [5.6, 6.7, 8], res.map {|e| e.fnumber}
|
133
|
-
assert_equal
|
133
|
+
assert_equal %w(SourceFile FNumber), res.first.tags
|
134
134
|
assert_equal [], @reader.errors
|
135
135
|
end
|
136
136
|
end
|
data/test/test_values.rb
CHANGED
@@ -86,12 +86,21 @@ class TestValues < Test::Unit::TestCase
|
|
86
86
|
|
87
87
|
end
|
88
88
|
|
89
|
-
context 'tags' do
|
89
|
+
context 'tags and to_h' do
|
90
|
+
|
91
|
+
setup do
|
92
|
+
@hash = {'FNumber' => 8, 'Author' => 'janfri', 'E-MailAddress' => 'janfri26@gmail.com', 'DateTimeOriginal' => '2017:02:20 21:07:00'}
|
93
|
+
@values = MultiExiftool::Values.new(@hash)
|
94
|
+
end
|
90
95
|
|
91
96
|
test 'tags preserves the original tag names' do
|
92
|
-
hash
|
93
|
-
|
94
|
-
|
97
|
+
assert_equal @hash.keys, @values.tags.to_a
|
98
|
+
end
|
99
|
+
|
100
|
+
test 'to_h preserves original tag names but uses converted values' do
|
101
|
+
dto = Time.new(2017, 2, 20, 21, 7, 0)
|
102
|
+
@hash['DateTimeOriginal'] = dto
|
103
|
+
assert_equal @hash, @values.to_h
|
95
104
|
end
|
96
105
|
|
97
106
|
end
|
data/test/test_writer.rb
CHANGED
@@ -121,7 +121,11 @@ class TestWriter < Test::Unit::TestCase
|
|
121
121
|
@writer.values = {comment: 'foo', bar: 'x'}
|
122
122
|
rc = @writer.write
|
123
123
|
assert !rc
|
124
|
-
|
124
|
+
if MultiExiftool.exiftool_version >= 10.38
|
125
|
+
assert_equal ["Warning: Tag 'bar' is not defined", "Error: File not found - xxx"], @writer.errors
|
126
|
+
else
|
127
|
+
assert_equal ["Warning: Tag 'bar' is not supported", "Error: File not found - xxx"], @writer.errors
|
128
|
+
end
|
125
129
|
end
|
126
130
|
end
|
127
131
|
|
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.5.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:
|
11
|
+
date: 2017-02-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rim
|
@@ -114,7 +114,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
114
114
|
requirements:
|
115
115
|
- exiftool, version 7.65 or higher
|
116
116
|
rubyforge_project:
|
117
|
-
rubygems_version: 2.6.
|
117
|
+
rubygems_version: 2.6.10
|
118
118
|
signing_key:
|
119
119
|
specification_version: 4
|
120
120
|
summary: This library is a wrapper for the ExifTool command-line application (http://www.sno.phy.queensu.ca/~phil/exiftool).
|