mini_exiftool 1.7.0 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1d1b5a3906b34606e231c3ffda6a4df3d5a6026b
4
- data.tar.gz: 9e63ae2193c37ab53810d371fae213200babb0e9
3
+ metadata.gz: 555a757bd0d6fa9f173ad23a76f48bd2117e3ae9
4
+ data.tar.gz: 7c68e025c963a564740852f4b28d4d647aa657f9
5
5
  SHA512:
6
- metadata.gz: ff0a627dd02d2e7b42aa38094c591d688c7d352795f704e96c0e405215f468708472ea3f11365c46f3268615fc1825a72019a0862e2a13b54005047643cfbd04
7
- data.tar.gz: 671b31da0a3925b287d2bc688292d706f00d12206384e8cbaf06a952ad86f96804a4ed8a3e79a3b0e8b0bfd2680e67e3b5d80feebb743c4908f089e622ff969d
6
+ metadata.gz: 0fa67b34cdfd38f95eea037087e1c9add9c203a62c8ddd907cb8a5c965daa3fbb3b24fe6114c51bf42085ffd829e6c18bd75f256274267538d90e881b4277b64
7
+ data.tar.gz: f074cd5e8087a431e282c923b6723330b12b547b1fc9b8f3b0cf718c6a5bc176555d6be9c931ee023cb832bc7f1daad85a05bb741f1f9b4c069eb5a831c41988
data/Changelog CHANGED
@@ -1,3 +1,8 @@
1
+ 2.0.0
2
+ - Drop Ruby 1.8 compatibility.
3
+ - Using JSON to parse exiftool output (need
4
+ exiftool 7.65 or higher).
5
+
1
6
  1.7.0
2
7
  - Support exiftool -c option for formatting GPS
3
8
  coordinates.
data/README.rdoc CHANGED
@@ -6,7 +6,10 @@ Read and write access is done in a clean OO manner.
6
6
 
7
7
  == Requirements
8
8
 
9
- An installation of the Exiftool command-line application.
9
+ Ruby 1.9 or higher and an installation of the Exiftool
10
+ command-line application at least version 7.65.
11
+ If you run on Ruby 1.8 or with a prior exiftool version
12
+ install mini_exiftool version 1.x.x.
10
13
  Instructions for installation you can find under
11
14
  http://www.sno.phy.queensu.ca/~phil/exiftool/install.html .
12
15
 
@@ -23,6 +26,9 @@ install the gem with
23
26
  respectively (on *nix sytems)
24
27
  sudo gem install mini_exiftool
25
28
 
29
+ If you need support of older versione (see Requirements above)
30
+ gem install --version "< 2.0.0" mini_exiftool
31
+
26
32
  Alternative you can download the tarball or zip file and run
27
33
  ruby setup.rb config
28
34
  ruby setup.rb setup
@@ -32,13 +38,15 @@ Alternative you can download the tarball or zip file and run
32
38
 
33
39
  The code is also hostet in a git repository on Gitorious at
34
40
  http://gitorious.org/projects/mini_exiftool
41
+ and github at
42
+ https://github.com/janfri/mini_exiftool
35
43
  feel free to contribute!
36
44
 
37
45
  == Author
38
- Jan Friedrich <janfri26 AT gmail DOT com>
46
+ Jan Friedrich <janfri26@gmail.com>
39
47
 
40
48
  == Copyright / License
41
- Copyright (c) 2007-2011 by Jan Friedrich
49
+ Copyright (c) 2007-2013 by Jan Friedrich
42
50
 
43
51
  Licensed under terms of the GNU LESSER GENERAL PUBLIC LICENSE, Version 2.1,
44
52
  February 1999 (see file COPYING for more details)
data/Rakefile CHANGED
@@ -15,9 +15,13 @@ Rim.setup do |p|
15
15
  p.homepage = 'http://gitorious.org/mini_exiftool'
16
16
  p.install_message = %q{
17
17
  +-----------------------------------------------------------------------+
18
- | Please ensure you have installed exiftool and it's found in your PATH |
19
- | (Try "exiftool -ver" on your commandline). For more details see |
18
+ | Please ensure you have installed exiftool at least version 7.65 |
19
+ | and it's found in your PATH (Try "exiftool -ver" on your commandline).|
20
+ | For more details see |
20
21
  | http://www.sno.phy.queensu.ca/~phil/exiftool/install.html |
22
+ | You need also Ruby 1.9 or higher. |
23
+ | If you need support for Ruby 1.8 or exiftool prior 7.65 install |
24
+ | mini_exiftool version < 2.0.0. |
21
25
  +-----------------------------------------------------------------------+
22
26
  }
23
27
  end
data/lib/mini_exiftool.rb CHANGED
@@ -8,7 +8,7 @@
8
8
  # Read and write access is done in a clean OO manner.
9
9
  #
10
10
  # Author: Jan Friedrich
11
- # Copyright (c) 2007-2012 by Jan Friedrich
11
+ # Copyright (c) 2007-2013 by Jan Friedrich
12
12
  # Licensed under the GNU LESSER GENERAL PUBLIC LICENSE,
13
13
  # Version 2.1, February 1999
14
14
  #
@@ -32,7 +32,7 @@ class MiniExiftool
32
32
  attr_reader :filename
33
33
  attr_accessor :numerical, :composite, :convert_encoding, :ignore_minor_errors, :errors, :timestamps
34
34
 
35
- VERSION = '1.7.0'
35
+ VERSION = '2.0.0'
36
36
 
37
37
  # +opts+ support at the moment
38
38
  # * <code>:numerical</code> for numerical values, default is +false+
@@ -89,7 +89,7 @@ class MiniExiftool
89
89
  opt_params << (@composite ? '' : '-e ')
90
90
  opt_params << (@convert_encoding ? '-L ' : '')
91
91
  opt_params << (@coord_format ? "-c \"#{@coord_format}\"" : '')
92
- cmd = %Q(#@@cmd -q -q -s -t #{opt_params} #{@@sep_op} #{MiniExiftool.escape(filename)})
92
+ cmd = %Q(#@@cmd -j -q -q -s -t #{opt_params} #{MiniExiftool.escape(filename)})
93
93
  if run(cmd)
94
94
  parse_output
95
95
  else
@@ -168,8 +168,8 @@ class MiniExiftool
168
168
  opt_params << (@convert_encoding ? '-L ' : '')
169
169
  opt_params << (@ignore_minor_errors ? '-m' : '')
170
170
  cmd = %Q(#@@cmd -q -P -overwrite_original #{opt_params} #{tag_params} #{temp_filename})
171
- if convert_encoding && cmd.respond_to?(:encode)
172
- cmd.encode('ISO-8859-1')
171
+ if convert_encoding
172
+ cmd.encode!('ISO-8859-1')
173
173
  end
174
174
  result = run(cmd)
175
175
  unless result
@@ -288,14 +288,6 @@ class MiniExiftool
288
288
  return if @@setup_done
289
289
  @@error_file = Tempfile.new 'errors'
290
290
  @@error_file.close
291
-
292
- if Float(exiftool_version) < 7.41
293
- @@separator = ', '
294
- @@sep_op = ''
295
- else
296
- @@separator = '@@'
297
- @@sep_op = '-sep @@'
298
- end
299
291
  @@setup_done = true
300
292
  end
301
293
 
@@ -304,9 +296,6 @@ class MiniExiftool
304
296
  $stderr.puts cmd
305
297
  end
306
298
  @output = `#{cmd} 2>#{@@error_file.path}`
307
- if convert_encoding && @output.respond_to?(:force_encoding)
308
- @output.force_encoding('ISO-8859-1')
309
- end
310
299
  @status = $?
311
300
  unless @status.exitstatus == 0
312
301
  @error_text = File.readlines(@@error_file.path).join
@@ -335,50 +324,43 @@ class MiniExiftool
335
324
  end
336
325
 
337
326
  def parse_output
338
- @output.each_line do |line|
339
- tag, value = parse_line line
327
+ JSON.parse(@output)[0].each do |tag,value|
328
+ value = perform_conversions(value)
340
329
  set_value tag, value
341
330
  end
342
331
  end
343
332
 
344
- def parse_line line
345
- if line =~ /^([^\t]+)\t(.*)$/
346
- tag, value = $1, perform_conversions($2)
347
- else
348
- raise MiniExiftool::Error.new("Malformed line #{line.inspect} of exiftool output.")
349
- end
350
- return [tag, value]
351
- end
352
-
353
333
  def perform_conversions(value)
354
- case value
355
- when /^\d{4}:\d\d:\d\d \d\d:\d\d:\d\d/
356
- s = value.sub(/^(\d+):(\d+):/, '\1-\2-')
357
- begin
358
- if @timestamps == Time
359
- value = Time.parse(s)
360
- elsif @timestamps == DateTime
361
- value = DateTime.parse(s)
362
- else
363
- raise MiniExiftool::Error.new("Value #@timestamps not allowed for option timestamps.")
364
- end
365
- rescue ArgumentError
366
- value = false
334
+ return value unless value.kind_of?(String)
335
+ if convert_encoding
336
+ value.encode!('ISO-8859-1')
337
+ end
338
+ case value
339
+ when /^\d{4}:\d\d:\d\d \d\d:\d\d:\d\d/
340
+ s = value.sub(/^(\d+):(\d+):/, '\1-\2-')
341
+ begin
342
+ if @timestamps == Time
343
+ value = Time.parse(s)
344
+ elsif @timestamps == DateTime
345
+ value = DateTime.parse(s)
346
+ else
347
+ raise MiniExiftool::Error.new("Value #@timestamps not allowed for option timestamps.")
367
348
  end
368
- when /^\d+\.\d+$/
369
- value = value.to_f
370
- when /^0+[1-9]+$/
371
- # nothing => String
372
- when /^-?\d+$/
373
- value = value.to_i
374
- when %r(^(\d+)/(\d+)$)
375
- value = Rational($1.to_i, $2.to_i)
376
- when /^[\d ]+$/
377
- # nothing => String
378
- when /#{@@separator}/
379
- value = value.split @@separator
349
+ rescue ArgumentError
350
+ value = false
380
351
  end
381
- value
352
+ when /^\+\d+\.\d+$/
353
+ value = value.to_f
354
+ when /^0+[1-9]+$/
355
+ # nothing => String
356
+ when /^-?\d+$/
357
+ value = value.to_i
358
+ when %r(^(\d+)/(\d+)$)
359
+ value = Rational($1.to_i, $2.to_i)
360
+ when /^[\d ]+$/
361
+ # nothing => String
362
+ end
363
+ value
382
364
  end
383
365
 
384
366
  def set_value tag, value
data/test/test_read.rb CHANGED
@@ -42,11 +42,9 @@ class TestRead < TestCase
42
42
 
43
43
  def test_encoding_conversion
44
44
  @mini_exiftool_converted = MiniExiftool.new @filename_test, :convert_encoding => true
45
- assert_equal 'Abenddämmerung', @mini_exiftool.title
46
- converted = "Abendd\344mmerung"
47
- if converted.respond_to?(:force_encoding)
48
- converted.force_encoding('ISO-8859-1')
49
- end
45
+ title_utf8 = 'Abenddämmerung'
46
+ assert_equal title_utf8, @mini_exiftool.title
47
+ converted = title_utf8.encode('ISO-8859-1')
50
48
  assert_equal converted, @mini_exiftool_converted.title
51
49
  end
52
50
 
@@ -10,8 +10,9 @@ class TestReadCoordinates < TestCase
10
10
 
11
11
  def test_access_coordinates
12
12
  mini_exiftool_coord = MiniExiftool.new @filename_test, :coord_format => "%+.6f"
13
- assert_equal '+43.653167', mini_exiftool_coord['GPSLatitude']
14
- assert_equal '-79.373167', mini_exiftool_coord['GPSLongitude']
13
+ # checking float equality is here ok ;-)
14
+ assert_equal +43.653167, mini_exiftool_coord['GPSLatitude']
15
+ assert_equal -79.373167, mini_exiftool_coord['GPSLongitude']
15
16
  assert_equal '+43.653167, -79.373167', mini_exiftool_coord['GPSPosition']
16
17
  end
17
18
 
data/test/test_save.rb CHANGED
@@ -51,11 +51,7 @@ class TestSave < TestCase
51
51
 
52
52
  def test_encoding_conversion
53
53
  special_string = 'äöü'
54
- if special_string.respond_to?(:encode)
55
- special_string_latin1 = special_string.encode('ISO-8859-1')
56
- else
57
- special_string_latin1 = "\xE4\xF6\xFC"
58
- end
54
+ special_string_latin1 = special_string.encode('ISO-8859-1')
59
55
  @mini_exiftool.title = special_string
60
56
  assert @mini_exiftool.save
61
57
  assert_equal false, @mini_exiftool.convert_encoding
@@ -64,9 +60,7 @@ class TestSave < TestCase
64
60
  @mini_exiftool.title = special_string_latin1
65
61
  assert @mini_exiftool.save
66
62
  assert_equal true, @mini_exiftool.convert_encoding
67
- if special_string_latin1.respond_to?(:encode)
68
- special_string_latin1.encode!('ISO-8859-1')
69
- end
63
+ special_string_latin1.encode!('ISO-8859-1')
70
64
  assert_equal special_string_latin1, @mini_exiftool.title
71
65
  end
72
66
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mini_exiftool
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.7.0
4
+ version: 2.0.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: 2013-05-07 00:00:00.000000000 Z
11
+ date: 2013-05-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rim
@@ -59,9 +59,12 @@ homepage: http://gitorious.org/mini_exiftool
59
59
  licenses: []
60
60
  metadata: {}
61
61
  post_install_message: "\n+-----------------------------------------------------------------------+\n|
62
- Please ensure you have installed exiftool and it's found in your PATH |\n| (Try
63
- \"exiftool -ver\" on your commandline). For more details see |\n| http://www.sno.phy.queensu.ca/~phil/exiftool/install.html
64
- \ |\n+-----------------------------------------------------------------------+\n
62
+ Please ensure you have installed exiftool at least version 7.65 |\n| and it's
63
+ found in your PATH (Try \"exiftool -ver\" on your commandline).|\n| For more details
64
+ see |\n| http://www.sno.phy.queensu.ca/~phil/exiftool/install.html
65
+ \ |\n| You need also Ruby 1.9 or higher. |\n|
66
+ If you need support for Ruby 1.8 or exiftool prior 7.65 install |\n| mini_exiftool
67
+ version < 2.0.0. |\n+-----------------------------------------------------------------------+\n
65
68
  \ "
66
69
  rdoc_options: []
67
70
  require_paths: