mini_exiftool 2.0.0 → 2.1.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: 555a757bd0d6fa9f173ad23a76f48bd2117e3ae9
4
- data.tar.gz: 7c68e025c963a564740852f4b28d4d647aa657f9
3
+ metadata.gz: 1912be3f9461bf694e7907689e59f190dd57b8e3
4
+ data.tar.gz: 936637b9820b7dfcde601b5a3651511e09735f05
5
5
  SHA512:
6
- metadata.gz: 0fa67b34cdfd38f95eea037087e1c9add9c203a62c8ddd907cb8a5c965daa3fbb3b24fe6114c51bf42085ffd829e6c18bd75f256274267538d90e881b4277b64
7
- data.tar.gz: f074cd5e8087a431e282c923b6723330b12b547b1fc9b8f3b0cf718c6a5bc176555d6be9c931ee023cb832bc7f1daad85a05bb741f1f9b4c069eb5a831c41988
6
+ metadata.gz: 3473fbaae4cf7b83d3e0ac540eb2929ae8ce49d28d2466584199f41ddbf8d8f432603e99db695349a73627de8fc9ec5ad4662528c9891beea133987e7661465a
7
+ data.tar.gz: d59167d91ce3b8d6ff5686d909a3d12e87a5861c9ea948fd814267e96a0c62c02b47725d08fb26bd37ffd1f63fc855442d7b6445cf71b964562fd21e9ca3db9b
data/Changelog CHANGED
@@ -1,3 +1,10 @@
1
+ 2.1.0
2
+ - insert require 'json'
3
+ - Drop option :convert_encoding (use Ruby String
4
+ methods instead)
5
+ - Make the test_access_coordinate work on different
6
+ exiftool version.
7
+
1
8
  2.0.0
2
9
  - Drop Ruby 1.8 compatibility.
3
10
  - Using JSON to parse exiftool output (need
data/lib/mini_exiftool.rb CHANGED
@@ -14,10 +14,11 @@
14
14
  #
15
15
 
16
16
  require 'fileutils'
17
- require 'tempfile'
17
+ require 'json'
18
18
  require 'pstore'
19
19
  require 'rational'
20
20
  require 'set'
21
+ require 'tempfile'
21
22
  require 'time'
22
23
 
23
24
  # Simple OO access to the Exiftool command-line application.
@@ -27,21 +28,22 @@ class MiniExiftool
27
28
  @@cmd = 'exiftool'
28
29
 
29
30
  # Hash of the standard options used when call MiniExiftool.new
30
- @@opts = { :numerical => false, :composite => true, :convert_encoding => false, :ignore_minor_errors => false, :timestamps => Time }
31
+ @@opts = { :numerical => false, :composite => true, :ignore_minor_errors => false, :timestamps => Time }
31
32
 
32
33
  attr_reader :filename
33
- attr_accessor :numerical, :composite, :convert_encoding, :ignore_minor_errors, :errors, :timestamps
34
+ attr_accessor :numerical, :composite, :ignore_minor_errors, :errors, :timestamps
34
35
 
35
- VERSION = '2.0.0'
36
+ VERSION = '2.1.0'
36
37
 
37
38
  # +opts+ support at the moment
38
39
  # * <code>:numerical</code> for numerical values, default is +false+
39
40
  # * <code>:composite</code> for including composite tags while loading,
40
41
  # default is +true+
41
- # * <code>:convert_encoding</code> convert encoding (See -L-option of
42
- # the exiftool command-line application, default is +false+)
43
42
  # * <code>:ignore_minor_errors</code> ignore minor errors (See -m-option
44
43
  # of the exiftool command-line application, default is +false+)
44
+ # * <code>:coord_format</code> set format for GPS coordinates (See
45
+ # -c-option of the exiftool command-line application, default is +nil+
46
+ # that means exiftool standard)
45
47
  # * <code>:timestamps</code> generating DateTime objects instead of
46
48
  # Time objects if set to <code>DateTime</code>, default is +Time+
47
49
  #
@@ -52,7 +54,10 @@ class MiniExiftool
52
54
  opts = @@opts.merge opts
53
55
  @numerical = opts[:numerical]
54
56
  @composite = opts[:composite]
55
- @convert_encoding = opts[:convert_encoding]
57
+ if opts[:convert_encoding]
58
+ warn 'Option :convert_encoding is not longer supported!'
59
+ warn 'Please use the String#encod* methods.'
60
+ end
56
61
  @ignore_minor_errors = opts[:ignore_minor_errors]
57
62
  @timestamps = opts[:timestamps]
58
63
  @coord_format = opts[:coord_format]
@@ -87,7 +92,6 @@ class MiniExiftool
87
92
  opt_params = ''
88
93
  opt_params << (@numerical ? '-n ' : '')
89
94
  opt_params << (@composite ? '' : '-e ')
90
- opt_params << (@convert_encoding ? '-L ' : '')
91
95
  opt_params << (@coord_format ? "-c \"#{@coord_format}\"" : '')
92
96
  cmd = %Q(#@@cmd -j -q -q -s -t #{opt_params} #{MiniExiftool.escape(filename)})
93
97
  if run(cmd)
@@ -165,12 +169,8 @@ class MiniExiftool
165
169
  end
166
170
  opt_params = ''
167
171
  opt_params << (arr_val.detect {|x| x.kind_of?(Numeric)} ? '-n ' : '')
168
- opt_params << (@convert_encoding ? '-L ' : '')
169
172
  opt_params << (@ignore_minor_errors ? '-m' : '')
170
173
  cmd = %Q(#@@cmd -q -P -overwrite_original #{opt_params} #{tag_params} #{temp_filename})
171
- if convert_encoding
172
- cmd.encode!('ISO-8859-1')
173
- end
174
174
  result = run(cmd)
175
175
  unless result
176
176
  all_ok = false
@@ -332,9 +332,6 @@ class MiniExiftool
332
332
 
333
333
  def perform_conversions(value)
334
334
  return value unless value.kind_of?(String)
335
- if convert_encoding
336
- value.encode!('ISO-8859-1')
337
- end
338
335
  case value
339
336
  when /^\d{4}:\d\d:\d\d \d\d:\d\d:\d\d/
340
337
  s = value.sub(/^(\d+):(\d+):/, '\1-\2-')
@@ -371,7 +368,6 @@ class MiniExiftool
371
368
  def set_attributes_by_heuristic
372
369
  self.composite = tags.include?('ImageSize') ? true : false
373
370
  self.numerical = self.file_size.kind_of?(Integer) ? true : false
374
- # TODO: Is there a heuristic to determine @convert_encoding?
375
371
  self.timestamps = self.FileModifyDate.kind_of?(DateTime) ? DateTime : Time
376
372
  end
377
373
 
data/test/test_read.rb CHANGED
@@ -40,12 +40,10 @@ class TestRead < TestCase
40
40
  assert_equal ['Natur'], Array(@mini_exiftool['SupplementalCategories'])
41
41
  end
42
42
 
43
- def test_encoding_conversion
44
- @mini_exiftool_converted = MiniExiftool.new @filename_test, :convert_encoding => true
45
- title_utf8 = 'Abenddämmerung'
46
- assert_equal title_utf8, @mini_exiftool.title
47
- converted = title_utf8.encode('ISO-8859-1')
48
- assert_equal converted, @mini_exiftool_converted.title
43
+ def test_value_encoding
44
+ title= 'Abenddämmerung'
45
+ assert_equal Encoding::UTF_8, @mini_exiftool.title.encoding
46
+ assert_equal title, @mini_exiftool.title
49
47
  end
50
48
 
51
49
  end
@@ -9,11 +9,10 @@ class TestReadCoordinates < TestCase
9
9
  end
10
10
 
11
11
  def test_access_coordinates
12
- mini_exiftool_coord = MiniExiftool.new @filename_test, :coord_format => "%+.6f"
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']
16
- assert_equal '+43.653167, -79.373167', mini_exiftool_coord['GPSPosition']
12
+ mini_exiftool_coord = MiniExiftool.new @filename_test, :coord_format => "%.6f degrees"
13
+ assert_match /^43.653167 degrees/, mini_exiftool_coord['GPSLatitude']
14
+ assert_match /^79.373167 degrees/, mini_exiftool_coord['GPSLongitude']
15
+ assert_match /^43.653167 degrees.*, 79.373167 degrees/, mini_exiftool_coord['GPSPosition']
17
16
  end
18
17
 
19
18
  end
data/test/test_save.rb CHANGED
@@ -49,19 +49,13 @@ class TestSave < TestCase
49
49
  assert_equal @org_md5, Digest::MD5.hexdigest(File.read(@temp_filename))
50
50
  end
51
51
 
52
- def test_encoding_conversion
52
+ def test_value_encoding
53
53
  special_string = 'äöü'
54
- special_string_latin1 = special_string.encode('ISO-8859-1')
55
54
  @mini_exiftool.title = special_string
56
55
  assert @mini_exiftool.save
57
- assert_equal false, @mini_exiftool.convert_encoding
56
+ @mini_exiftool.reload
57
+ assert_equal Encoding::UTF_8, @mini_exiftool.title.encoding
58
58
  assert_equal special_string, @mini_exiftool.title
59
- @mini_exiftool.convert_encoding = true
60
- @mini_exiftool.title = special_string_latin1
61
- assert @mini_exiftool.save
62
- assert_equal true, @mini_exiftool.convert_encoding
63
- special_string_latin1.encode!('ISO-8859-1')
64
- assert_equal special_string_latin1, @mini_exiftool.title
65
59
  end
66
60
 
67
61
  def test_save_bang
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: 2.0.0
4
+ version: 2.1.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-23 00:00:00.000000000 Z
11
+ date: 2013-06-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rim
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - ~>
18
18
  - !ruby/object:Gem::Version
19
- version: 1.6.2
19
+ version: 1.7.0
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - ~>
25
25
  - !ruby/object:Gem::Version
26
- version: 1.6.2
26
+ version: 1.7.0
27
27
  description: ''
28
28
  email: janfri26@gmail.com
29
29
  executables: []