Skip to content
This repository
Browse code

Bugfix [#8073]: Handling '-' in tag names like Self-timer.

  • Loading branch information...
commit 1a10120a78576f6dcf10056296fe38c1cc336512 1 parent 972e77b
authored
5  Changelog
... ...
@@ -1,3 +1,8 @@
  1
+Version 0.1.1
  2
+- Fixing bug [#8073]
  3
+  Handling the '-' in tag Self-timer
  4
+  Thanks to Eric Young
  5
+
1 6
 Version 0.1.0
2 7
 - New method "revert"
3 8
 - More tests
2  Rakefile
@@ -45,7 +45,7 @@ REQUIRE_PATHS << EXT_DIR if HAVE_EXT
45 45
 $LOAD_PATH.concat(REQUIRE_PATHS)
46 46
 # This library file defines the MyProject::VERSION constant.
47 47
 require "#{UNIX_NAME}"
48  
-PROJECT_VERSION = eval("#{PROJECT}::Version") # e.g. "1.0.2"
  48
+PROJECT_VERSION = eval("#{PROJECT}::VERSION") # e.g. "1.0.2"
49 49
 #---
50 50
 # Clobber object files and Makefiles generated by extconf.rb.
51 51
 CLOBBER.include("#{EXT_DIR}/**/*.{so,dll,o}", "#{EXT_DIR}/**/Makefile")
6  lib/mini_exiftool.rb
@@ -25,7 +25,7 @@ class MiniExiftool
25 25
   attr_reader :filename
26 26
   attr_accessor :numerical
27 27
 
28  
-  Version = '0.1.0'
  28
+  VERSION = '0.1.1'
29 29
 
30 30
   # opts at the moment only support :numerical for numerical values
31 31
   # (the -n parameter in the command line)
@@ -121,7 +121,7 @@ def run cmd
121 121
   end
122 122
 
123 123
   def unify name
124  
-    name.gsub(/_/, '').downcase
  124
+    name.gsub(/[_\-]/, '').downcase
125 125
   end
126 126
 
127 127
   def convert val
@@ -151,7 +151,7 @@ def parse_output
151 151
   end
152 152
 
153 153
   def parse_line line
154  
-    if line =~ /^(\w+?)\t(.*)$/
  154
+    if line =~ /^([^\t]+?)\t(.*)$/
155 155
       tag, value = $1, $2
156 156
       case value
157 157
       when /^\d{4}:\d\d:\d\d \d\d:\d\d:\d\d$/
BIN  test/data/Canon.jpg
3  test/data/INFORMATION
... ...
@@ -0,0 +1,3 @@
  1
+Following files are borrowed from the original Exiftool perl package.
  2
+
  3
+Canon.jpg
28  test/test_special.rb
... ...
@@ -0,0 +1,28 @@
  1
+require 'mini_exiftool'
  2
+require 'test/unit'
  3
+begin
  4
+  require 'turn'
  5
+rescue LoadError
  6
+end
  7
+
  8
+class TestSpecial < Test::Unit::TestCase
  9
+
  10
+  def setup
  11
+    @data_dir = File.dirname(__FILE__) + '/data'
  12
+    @filename_canon = @data_dir + '/Canon.jpg'
  13
+    @canon = MiniExiftool.new @filename_canon
  14
+  end
  15
+
  16
+  # Catching bug [#8073]
  17
+  # Thanks to Eric Young
  18
+  def test_special_chars
  19
+    assert_equal 0, @canon['Self-timer']
  20
+    assert_equal 0, @canon.self_timer
  21
+    # preserving the original tag name
  22
+    assert @canon.tags.include?('Self-timer')
  23
+    assert !@canon.tags.include?('self_timer')
  24
+  end
  25
+
  26
+
  27
+
  28
+end

0 notes on commit 1a10120

Please sign in to comment.
Something went wrong with that request. Please try again.