multi_exiftool 0.5.0 → 0.6.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: '08cd6e1d9c6c6ee77dcfc1a92dd00772419d0148'
4
- data.tar.gz: 0e1252f4eebe67f630e7c4e6d79b8632a8bc8e08
3
+ metadata.gz: 850f9bf3ffdcf1fad5edae5579ce7b3a30161004
4
+ data.tar.gz: b1b87707b148d66125eb53c42a9795e90b4ea415
5
5
  SHA512:
6
- metadata.gz: a50fefa13b79f31013369a5441416f01ca0f521302ab47c5e1f9bbf3da2872aa716bc859e22fc5ed9c8c710781f34093fd4b6d31de7364b42d155c8fe7c20eaa
7
- data.tar.gz: add6854570c75de94fcb73aa2bdcd309cb3fbc4b424ac040ad1d518ff10e4d772e1c86a4cefbf3e753e286606c5654fc900f5d7c4cc0b46cd0d01583ba253e54
6
+ metadata.gz: 945117c1a4e70ca45ba9d57bf144d6ae4ad5170c155371d5e1c3a1e2f27839ce6c3c05c0cedc521a0b1ca8be90d6cfc0ef3ff59133233556aaf0e064c8a83a92
7
+ data.tar.gz: 1054902f432fdfab692da7cf23e7067f774f1bb92ad119dcd8680ddf94e283c352ecd9cc78ae4463a4a230eeb2affbd39e2ddc20e52b85efd71b573c887df610
data/Changelog CHANGED
@@ -1,3 +1,7 @@
1
+ 0.6.0
2
+ Handle UTC timestamps.
3
+ Support timestamps with fractions of second.
4
+
1
5
  0.5.0
2
6
  New methods Values#to_h and #to_hash.
3
7
  Values#tags gives now an array instead of a set.
data/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  The MIT License
2
2
 
3
- Copyright (c) 2009-2016 Jan Friedrich
3
+ Copyright (c) 2009-2017 Jan Friedrich
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
data/README.md ADDED
@@ -0,0 +1,104 @@
1
+ # MultiExiftool
2
+
3
+ ## Description
4
+
5
+ This library is a wrapper for the ExifTool command-line application
6
+ (http://www.sno.phy.queensu.ca/~phil/exiftool) written by Phil Harvey.
7
+ It is designed for dealing with multiple files at once by creating
8
+ commands to call exiftool with various arguments, call it and parsing
9
+ the results.
10
+
11
+ ## Examples
12
+
13
+ ### Reading
14
+
15
+ ```ruby
16
+ require 'multi_exiftool'
17
+
18
+ # Object oriented approach
19
+ reader = MultiExiftool::Reader.new
20
+ reader.filenames = Dir['*.jpg']
21
+ results = reader.read
22
+ unless reader.errors.empty?
23
+ $stderr.puts reader.errors
24
+ end
25
+ results.each do |values|
26
+ puts "#{values.file_name}: #{values.comment}"
27
+ end
28
+
29
+ # Functional approach
30
+ results, errors = MultiExiftool.read(Dir['*.jpg'])
31
+ unless reader.errors.empty?
32
+ $stderr.puts reader.errors
33
+ end
34
+ results.each do |values|
35
+ puts "#{values.file_name}: #{values.comment}"
36
+ end
37
+ ```
38
+
39
+ ### Writing
40
+
41
+ ```ruby
42
+ require 'multi_exiftool'
43
+
44
+ # Object oriented approach
45
+ writer = MultiExiftool::Writer.new
46
+ writer.filenames = Dir['*.jpg']
47
+ writer.values = {creator: 'Jan Friedrich', copyright: 'Public Domain'}
48
+ if writer.write
49
+ puts 'ok'
50
+ else
51
+ puts writer.errors
52
+ end
53
+
54
+ # Functional approach
55
+ errors = MultiExiftool.write(Dir['*.jpg'], {creator: 'Jan Friedrich', copyright: 'Public Domain'})
56
+ if errors.empty?
57
+ puts 'ok'
58
+ else
59
+ puts writer.errors
60
+ end
61
+ ```
62
+
63
+ ### Further Examples
64
+
65
+ See the examples in the examples directory.
66
+
67
+
68
+ ## Requirements
69
+
70
+ - Ruby 1.9.1 or higher
71
+ - An installation of the ExifTool command-line application (version 7.65 or
72
+ higher). Instructions for installation you can find under
73
+ http://www.sno.phy.queensu.ca/~phil/exiftool/install.html .
74
+ - If you have problems with special characters (like German umlauts) in
75
+ filenames on windows system it is recommended to use exiftool version 9.79
76
+ or higher.
77
+
78
+ ## Installation
79
+
80
+ First you need ExifTool (see under Requirements above). Then you can simply
81
+ install the gem with
82
+ ```sh
83
+ gem install multi_exiftool
84
+ ```
85
+ or in your Gemfile
86
+ ```ruby
87
+ gem 'multi_exiftool'
88
+ ```
89
+
90
+ ## Contribution
91
+
92
+ The code is also hosted in a git repository at
93
+ http://github.com/janfri/multi_exiftool
94
+ or
95
+ https://bitbucket.org/janfri/multi_exiftool
96
+ feel free to contribute!
97
+
98
+ ## Author
99
+
100
+ Jan Friedrich <janfri26gmail.com>
101
+
102
+ ## MIT License
103
+
104
+ See file LICENSE for details.
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.5.0'
8
+ p.version = '0.6.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).'
@@ -73,9 +73,11 @@ module MultiExiftool
73
73
  def parse_value val
74
74
  return val unless val.kind_of?(String)
75
75
  case val
76
- when /^(\d{4}):(\d\d):(\d\d) (\d\d):(\d\d)(?::(\d\d))?([-+]\d\d:\d\d)?(?: *DST)?$/
76
+ when /^(\d{4}):(\d\d):(\d\d) (\d\d):(\d\d)(?::(\d\d)(?:\.\d+)?)?((?:[-+]\d\d:\d\d)|(?:Z))?(?: *DST)?$/
77
77
  arr = $~.captures[0,6].map {|cap| cap.to_i}
78
- arr << $7 if $7
78
+ zone = $7
79
+ zone = '+00:00' if zone == 'Z'
80
+ arr << zone if zone
79
81
  Time.new(*arr)
80
82
  when %r(^(\d+)/(\d+)$)
81
83
  Rational($1, $2)
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
@@ -61,14 +61,14 @@ class TestReader < Test::Unit::TestCase
61
61
 
62
62
  test 'options with boolean argument' do
63
63
  @reader.filenames = %w(a.jpg b.jpg c.jpg)
64
- @reader.options = {:e => true}
64
+ @reader.options = {e: true}
65
65
  exiftool_args = MANDATORY_ARGS + %w(-e a.jpg b.jpg c.jpg)
66
66
  assert_equal exiftool_args, @reader.exiftool_args
67
67
  end
68
68
 
69
69
  test 'options with value argument' do
70
70
  @reader.filenames = %w(a.jpg b.jpg c.jpg)
71
- @reader.options = {:lang => 'de'}
71
+ @reader.options = {lang: 'de'}
72
72
  exiftool_args = MANDATORY_ARGS + %w(-lang de a.jpg b.jpg c.jpg)
73
73
  assert_equal exiftool_args, @reader.exiftool_args
74
74
  end
data/test/test_values.rb CHANGED
@@ -35,10 +35,14 @@ class TestValues < Test::Unit::TestCase
35
35
  setup do
36
36
  hash = {
37
37
  'TimestampWithoutSeconds' => '2009:08:25 12:35',
38
- 'TimestampWithoutZone' => '2009:08:25 12:35:42',
38
+ 'Timestamp' => '2009:08:25 12:35:42',
39
+ 'TimestampWithFraction' => '2009:08:25 12:35:42.123',
39
40
  'TimestampWithPositiveZone' => '2009:08:26 20:22:24+05:00',
40
41
  'TimestampWithNegativeZone' => '2009:08:26 20:22:24-07:00',
41
- 'TimestampWithZoneAndDST' => '2016:07:23 15:40:55+02:00 DST'
42
+ 'TimestampWithFractionAndZone' => '2016:07:23 15:40:55.123+02:00',
43
+ 'TimestampWithZoneAndDST' => '2016:07:23 15:40:55+02:00 DST',
44
+ 'TimestampWithZ' => '2017:04:08 17:57:27Z',
45
+ 'TimestampWithFractionAndZ' => '2017:04:08 17:57:27.123Z'
42
46
  }
43
47
  @values = MultiExiftool::Values.new(hash)
44
48
  end
@@ -47,7 +51,8 @@ class TestValues < Test::Unit::TestCase
47
51
  time = Time.local(2009, 8, 25, 12, 35)
48
52
  assert_equal time, @values['TimestampWithoutSeconds']
49
53
  time = Time.local(2009, 8, 25, 12, 35, 42)
50
- assert_equal time, @values['TimestampWithoutZone']
54
+ assert_equal time, @values['Timestamp']
55
+ assert_equal time, @values['TimestampWithFraction']
51
56
  end
52
57
 
53
58
  test 'Time object with given zone' do
@@ -59,6 +64,9 @@ class TestValues < Test::Unit::TestCase
59
64
  values_time = @values['TimestampWithNegativeZone']
60
65
  assert_equal time, values_time
61
66
  assert_equal -7 * 3600, values_time.utc_offset
67
+ time = Time.new(2016,7, 23,15, 40,55,'+02:00')
68
+ values_time = @values['TimestampWithFractionAndZone']
69
+ assert_equal time, values_time
62
70
  end
63
71
 
64
72
  test 'Time object with zone and DST' do
@@ -67,6 +75,16 @@ class TestValues < Test::Unit::TestCase
67
75
  assert_equal time, values_time
68
76
  end
69
77
 
78
+ test 'Time object with UTC zone' do
79
+ time = Time.new(2017, 4, 8, 17, 57, 27, '+00:00')
80
+ values_time = @values['TimestampWithZ']
81
+ assert_equal time, values_time
82
+ assert_equal 0, values_time.utc_offset
83
+ values_time = @values['TimestampWithFractionAndZ']
84
+ assert_equal time, values_time
85
+ assert_equal 0, values_time.utc_offset
86
+ end
87
+
70
88
  end
71
89
 
72
90
  context 'other values' do
data/test/test_writer.rb CHANGED
@@ -62,7 +62,7 @@ class TestWriter < Test::Unit::TestCase
62
62
  end
63
63
 
64
64
  test 'tags with spaces in values' do
65
- @writer.values = {title: 'title', :comment => 'some comment'}
65
+ @writer.values = {title: 'title', comment: 'some comment'}
66
66
  exiftool_args = MANDATORY_ARGS + ['-title=title', '-comment=some comment', 'a.jpg', 'b.jpg', 'c.jpg']
67
67
  assert_equal exiftool_args, @writer.exiftool_args
68
68
  end
@@ -82,7 +82,7 @@ class TestWriter < Test::Unit::TestCase
82
82
 
83
83
  test 'options with boolean argument' do
84
84
  @writer.values = {comment: 'foo'}
85
- @writer.options = {:overwrite_original => true}
85
+ @writer.options = {overwrite_original: true}
86
86
  exiftool_args = MANDATORY_ARGS + %w(-overwrite_original -comment=foo a.jpg b.jpg c.jpg)
87
87
  assert_equal exiftool_args, @writer.exiftool_args
88
88
  end
@@ -12,7 +12,7 @@ class TestWriterGroups < Test::Unit::TestCase
12
12
  end
13
13
 
14
14
  test 'simple case' do
15
- @writer.values = {:exif => {:comment => 'test'} }
15
+ @writer.values = {exif: {comment: 'test'} }
16
16
  exiftool_args = MANDATORY_ARGS + %w(-exif:comment=test a.jpg b.jpg c.jpg)
17
17
  assert_equal exiftool_args, @writer.exiftool_args
18
18
  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.5.0
4
+ version: 0.6.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: 2017-02-20 00:00:00.000000000 Z
11
+ date: 2017-08-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rim
@@ -63,7 +63,7 @@ extra_rdoc_files: []
63
63
  files:
64
64
  - Changelog
65
65
  - LICENSE
66
- - README.rdoc
66
+ - README.md
67
67
  - Rakefile
68
68
  - lib/multi_exiftool.rb
69
69
  - lib/multi_exiftool/executable.rb
@@ -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.10
117
+ rubygems_version: 2.6.12
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).
data/README.rdoc DELETED
@@ -1,115 +0,0 @@
1
- = MultiExiftool
2
-
3
- == Description
4
-
5
- This library is wrapper for the ExifTool command-line application
6
- (http://www.sno.phy.queensu.ca/~phil/exiftool) written by Phil Harvey.
7
- It is designed for dealing with multiple files at once by creating
8
- commands to call exiftool with various arguments, call it and parsing
9
- the results.
10
-
11
- == Examples
12
-
13
- === Reading
14
-
15
- require 'multi_exiftool'
16
-
17
- # Object oriented approach
18
- reader = MultiExiftool::Reader.new
19
- reader.filenames = Dir['*.jpg']
20
- results = reader.read
21
- unless reader.errors.empty?
22
- $stderr.puts reader.errors
23
- end
24
- results.each do |values|
25
- puts "#{values.file_name}: #{values.comment}"
26
- end
27
-
28
- # Functional approach
29
- results, errors = MultiExiftool.read(Dir['*.jpg'])
30
- unless reader.errors.empty?
31
- $stderr.puts reader.errors
32
- end
33
- results.each do |values|
34
- puts "#{values.file_name}: #{values.comment}"
35
- end
36
-
37
- === Writing
38
-
39
- require 'multi_exiftool'
40
-
41
- # Object oriented approach
42
- writer = MultiExiftool::Writer.new
43
- writer.filenames = Dir['*.jpg']
44
- writer.values = {creator: 'Jan Friedrich', copyright: 'Public Domain'}
45
- if writer.write
46
- puts 'ok'
47
- else
48
- puts writer.errors
49
- end
50
-
51
- # Functional approach
52
- errors = MultiExiftool.write(Dir['*.jpg'], {creator: 'Jan Friedrich', copyright: 'Public Domain'})
53
- if errors.empty?
54
- puts 'ok'
55
- else
56
- puts writer.errors
57
- end
58
-
59
- === Further Examples
60
-
61
- See the examples in the examples directory.
62
-
63
-
64
- == Requirements
65
-
66
- - Ruby 1.9.1 or higher
67
- - An installation of the ExifTool command-line application (version 7.65 or
68
- higher). Instructions for installation you can find under
69
- http://www.sno.phy.queensu.ca/~phil/exiftool/install.html .
70
- - If you have problems with special characters (like German umlauts) in
71
- filenames on windows system it is recommended to use exiftool version 9.79
72
- or higher.
73
-
74
- == Installation
75
-
76
- First you need ExifTool (see under Requirements above). Then you can simply
77
- install the gem with
78
- gem install multi_exiftool
79
-
80
- == Contribution
81
-
82
- The code is also hosted in a git repository at
83
- http://github.com/janfri/multi_exiftool
84
- or
85
- https://bitbucket.org/janfri/multi_exiftool
86
- feel free to contribute!
87
-
88
- == Author
89
-
90
- Jan Friedrich <janfri26gmail.com>
91
-
92
- == Copyright / License
93
-
94
- The MIT License
95
-
96
- Copyright (c) 2009-2016 Jan Friedrich
97
-
98
- Permission is hereby granted, free of charge, to any person obtaining a copy
99
- of this software and associated documentation files (the "Software"), to deal
100
- in the Software without restriction, including without limitation the rights
101
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
102
- copies of the Software, and to permit persons to whom the Software is
103
- furnished to do so, subject to the following conditions:
104
-
105
- The above copyright notice and this permission notice shall be included in
106
- all copies or substantial portions of the Software.
107
-
108
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
109
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
110
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
111
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
112
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
113
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
114
- THE SOFTWARE.
115
-