multi_exiftool 0.9.1 → 0.10.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.aspell.pws +8 -5
- data/Changelog +5 -0
- data/README.md +63 -0
- data/lib/multi_exiftool.rb +1 -1
- data/lib/multi_exiftool/values.rb +29 -20
- data/multi_exiftool.gemspec +4 -4
- data/regtest/read_all_tags.yml +1 -1
- metadata +2 -8
- data/test/temp/a.jpg +0 -0
- data/test/temp/a.jpg_original +0 -0
- data/test/temp/b.jpg +0 -0
- data/test/temp/b.jpg_original +0 -0
- data/test/temp/c.jpg +0 -0
- data/test/temp/c.jpg_original +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4c14256fd34812250504b309d7c3a3c9675c69f2e6da13e3001a557561ac3b1d
|
4
|
+
data.tar.gz: c95ff092b037374f294afb75a6a892074576b4bbdf0aed8a083f994ffff82cfd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 410889a498ece01c7b8181c05a8f6c2f3eb63fd4355e89f6978db1f541d1a86097ec576b35aafef47286dfc50ecc1026ff07dfe5d9857d6e5ab4452bc792804e
|
7
|
+
data.tar.gz: 60a9ca8ef167f6b4ef8c8ac70b893243deb1c4291f9a5e4288619779403e2137cc0bfe6135e5beb2c35d0b910cbc83a071ac2b6812cc3c3defc00de40c38eac3
|
data/.aspell.pws
CHANGED
@@ -1,30 +1,33 @@
|
|
1
|
-
personal_ws-1.1 en
|
1
|
+
personal_ws-1.1 en 32
|
2
|
+
utc
|
2
3
|
UTC
|
3
|
-
NONINFRINGEMENT
|
4
4
|
szTheory
|
5
5
|
janfri
|
6
6
|
multi
|
7
7
|
dir
|
8
|
+
MultiExiftool
|
9
|
+
MERCHANTABILITY
|
8
10
|
api
|
9
11
|
Gemfile
|
10
12
|
sublicense
|
11
13
|
tmpdir
|
12
|
-
exiftool
|
13
14
|
ExifTool
|
15
|
+
exiftool
|
14
16
|
gmail
|
15
17
|
ok
|
16
18
|
timestamps
|
17
19
|
jpg
|
18
20
|
refactoring
|
21
|
+
NONINFRINGEMENT
|
19
22
|
Gitorious
|
23
|
+
MyConversion
|
20
24
|
gemspec
|
21
25
|
Friedrich
|
22
|
-
|
26
|
+
prepend
|
23
27
|
filenames
|
24
28
|
PartOfSet
|
25
29
|
README
|
26
30
|
stdin
|
27
|
-
MERCHANTABILITY
|
28
31
|
Coenen
|
29
32
|
stderr
|
30
33
|
gittycat
|
data/Changelog
CHANGED
@@ -1,3 +1,8 @@
|
|
1
|
+
0.10.0
|
2
|
+
Values#convert is now a public method. So you can simply adapt the value
|
3
|
+
conversion to your needs.
|
4
|
+
|
5
|
+
|
1
6
|
0.9.1
|
2
7
|
Fix bug in handling of timestamps with fractions of second introduced in
|
3
8
|
version 0.6.0. Thanks to Andrew Kendall for reporting and analyzing.
|
data/README.md
CHANGED
@@ -85,6 +85,69 @@ end
|
|
85
85
|
See the examples in the examples directory.
|
86
86
|
|
87
87
|
|
88
|
+
## Automatic conversion of values
|
89
|
+
|
90
|
+
By default values are converted to useful instances of Ruby classes. The
|
91
|
+
following conversions are implemented at the moment:
|
92
|
+
|
93
|
+
* Timestamps => Time (with local time zone of no one given)
|
94
|
+
* values of form "n/m" => Rational except PartOfSet and Track
|
95
|
+
|
96
|
+
The conversion is done in the method Values#convert. So you can change it's
|
97
|
+
behaviour as following examples shows.
|
98
|
+
|
99
|
+
### Example 1
|
100
|
+
|
101
|
+
```ruby
|
102
|
+
module MyConversion
|
103
|
+
def convert tag, val
|
104
|
+
val # no conversion at all
|
105
|
+
end
|
106
|
+
end
|
107
|
+
|
108
|
+
MultiExiftool::Values.prepend MyConversion
|
109
|
+
```
|
110
|
+
|
111
|
+
### Example 2
|
112
|
+
|
113
|
+
```ruby
|
114
|
+
module MultiExiftool
|
115
|
+
module MyConversion
|
116
|
+
def convert tag, val
|
117
|
+
converted_val = super
|
118
|
+
case converted_val
|
119
|
+
when Time
|
120
|
+
converted_val.utc # convert Time objects to utc
|
121
|
+
when Rational
|
122
|
+
val # no conversion
|
123
|
+
else
|
124
|
+
converted_val # use default conversion
|
125
|
+
end
|
126
|
+
end
|
127
|
+
end
|
128
|
+
|
129
|
+
Values.prepend MyConversion
|
130
|
+
end
|
131
|
+
```
|
132
|
+
|
133
|
+
### Example 3
|
134
|
+
|
135
|
+
```ruby
|
136
|
+
m = Module.new do
|
137
|
+
def convert tag, val
|
138
|
+
if val =~ MultiExiftool::Values::REGEXP_TIMESTAMP
|
139
|
+
val # no conversion
|
140
|
+
else
|
141
|
+
super # use default conversion
|
142
|
+
end
|
143
|
+
end
|
144
|
+
end
|
145
|
+
MultiExiftool::Values.prepend m
|
146
|
+
```
|
147
|
+
|
148
|
+
The method Values#convert is called each time a value is fetched.
|
149
|
+
|
150
|
+
|
88
151
|
## Requirements
|
89
152
|
|
90
153
|
- Ruby 1.9.1 or higher
|
data/lib/multi_exiftool.rb
CHANGED
@@ -11,6 +11,12 @@ module MultiExiftool
|
|
11
11
|
# method_missing.
|
12
12
|
class Values
|
13
13
|
|
14
|
+
# Regular expression to determine timestamp values
|
15
|
+
REGEXP_TIMESTAMP = /^(\d{4}):(\d\d):(\d\d) (\d\d):(\d\d)(?::((?:\d\d)(?:\.\d+)?))?((?:[-+]\d\d:\d\d)|(?:Z))?(?: *DST)?$/
|
16
|
+
|
17
|
+
# Regular expression to determine rational values
|
18
|
+
REGEXP_RATIONAL = %r(^(\d+)/(\d+)$)
|
19
|
+
|
14
20
|
@tag_map = {}
|
15
21
|
|
16
22
|
def initialize values
|
@@ -31,6 +37,29 @@ module MultiExiftool
|
|
31
37
|
convert(unified_tag, @values[unified_tag])
|
32
38
|
end
|
33
39
|
|
40
|
+
# Convert values on the basis of tag name and value. It is calles each time
|
41
|
+
# a value is fethed from a Values instance.
|
42
|
+
# @return (maybe) converted value
|
43
|
+
def convert tag, val
|
44
|
+
return val unless val.kind_of?(String)
|
45
|
+
case tag
|
46
|
+
when 'partofset', 'track'
|
47
|
+
return val
|
48
|
+
end
|
49
|
+
case val
|
50
|
+
when REGEXP_TIMESTAMP
|
51
|
+
year, month, day, hour, minute = $~.captures[0,5].map {|cap| cap.to_i}
|
52
|
+
second = $6.to_f
|
53
|
+
zone = $7
|
54
|
+
zone = '+00:00' if zone == 'Z'
|
55
|
+
Time.new(year, month, day, hour, minute, second, zone)
|
56
|
+
when REGEXP_RATIONAL
|
57
|
+
Rational($1, $2)
|
58
|
+
else
|
59
|
+
val
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
34
63
|
# Gets the original tag names of this instance
|
35
64
|
def tags
|
36
65
|
@values.keys.map {|tag| Values.tag_map[tag]}
|
@@ -73,26 +102,6 @@ module MultiExiftool
|
|
73
102
|
res
|
74
103
|
end
|
75
104
|
|
76
|
-
def convert tag, val
|
77
|
-
return val unless val.kind_of?(String)
|
78
|
-
case tag
|
79
|
-
when 'partofset', 'track'
|
80
|
-
return val
|
81
|
-
end
|
82
|
-
case val
|
83
|
-
when /^(\d{4}):(\d\d):(\d\d) (\d\d):(\d\d)(?::((?:\d\d)(?:\.\d+)?))?((?:[-+]\d\d:\d\d)|(?:Z))?(?: *DST)?$/
|
84
|
-
year, month, day, hour, minute = $~.captures[0,5].map {|cap| cap.to_i}
|
85
|
-
second = $6.to_f
|
86
|
-
zone = $7
|
87
|
-
zone = '+00:00' if zone == 'Z'
|
88
|
-
Time.new(year, month, day, hour, minute, second, zone)
|
89
|
-
when %r(^(\d+)/(\d+)$)
|
90
|
-
Rational($1, $2)
|
91
|
-
else
|
92
|
-
val
|
93
|
-
end
|
94
|
-
end
|
95
|
-
|
96
105
|
end
|
97
106
|
|
98
107
|
end
|
data/multi_exiftool.gemspec
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
2
|
-
# stub: multi_exiftool 0.
|
2
|
+
# stub: multi_exiftool 0.10.0 ruby lib
|
3
3
|
#
|
4
4
|
# This file is automatically generated by rim.
|
5
5
|
# PLEASE DO NOT EDIT IT DIRECTLY!
|
@@ -7,15 +7,15 @@
|
|
7
7
|
|
8
8
|
Gem::Specification.new do |s|
|
9
9
|
s.name = "multi_exiftool"
|
10
|
-
s.version = "0.
|
10
|
+
s.version = "0.10.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 = "2018-
|
15
|
+
s.date = "2018-08-21"
|
16
16
|
s.description = "This library a is wrapper for the ExifTool command-line application (http://www.sno.phy.queensu.ca/~phil/exiftool) 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
|
-
s.files = ["./.aspell.pws", "Changelog", "Gemfile", "LICENSE", "README.md", "Rakefile", "lib/multi_exiftool", "lib/multi_exiftool.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/
|
18
|
+
s.files = ["./.aspell.pws", "Changelog", "Gemfile", "LICENSE", "README.md", "Rakefile", "lib/multi_exiftool", "lib/multi_exiftool.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_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"]
|
19
19
|
s.homepage = "https://github.com/janfri/multi_exiftool"
|
20
20
|
s.licenses = ["MIT"]
|
21
21
|
s.post_install_message = "\n+-----------------------------------------------------------------------+\n| Please ensure you have installed exiftool version 7.65 or higher and |\n| it's found in your PATH (Try \"exiftool -ver\" on your commandline). |\n| For more details see |\n| http://www.sno.phy.queensu.ca/~phil/exiftool/install.html |\n+-----------------------------------------------------------------------+\n "
|
data/regtest/read_all_tags.yml
CHANGED
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.10.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: 2018-
|
11
|
+
date: 2018-08-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -108,12 +108,6 @@ files:
|
|
108
108
|
- test/data/b.jpg
|
109
109
|
- test/data/c.jpg
|
110
110
|
- test/helper.rb
|
111
|
-
- test/temp/a.jpg
|
112
|
-
- test/temp/a.jpg_original
|
113
|
-
- test/temp/b.jpg
|
114
|
-
- test/temp/b.jpg_original
|
115
|
-
- test/temp/c.jpg
|
116
|
-
- test/temp/c.jpg_original
|
117
111
|
- test/test_executable.rb
|
118
112
|
- test/test_exiftool_stuff.rb
|
119
113
|
- test/test_functional_api.rb
|
data/test/temp/a.jpg
DELETED
Binary file
|
data/test/temp/a.jpg_original
DELETED
Binary file
|
data/test/temp/b.jpg
DELETED
Binary file
|
data/test/temp/b.jpg_original
DELETED
Binary file
|
data/test/temp/c.jpg
DELETED
Binary file
|
data/test/temp/c.jpg_original
DELETED
Binary file
|