Skip to content
This repository
Browse code

Exiftool version detection delayed.

Delayed till first use of MiniExiftool#load or MiniExiftool#save methods.
It allows for setting up MiniExiftool.command attribute before version
checking happens.
  • Loading branch information...
commit 5f576fa9c8ded0c1c9af347bc06c9c92d65f5612 1 parent 2169ffd
Sebastian Skałacki authored June 11, 2012 janfri committed July 09, 2012

Showing 1 changed file with 15 additions and 8 deletions. Show diff stats Hide diff stats

  1. 23  lib/mini_exiftool.rb
23  lib/mini_exiftool.rb
@@ -73,6 +73,7 @@ def initialize_from_hash hash # :nodoc:
73 73
 
74 74
   # Load the tags of filename.
75 75
   def load filename
  76
+    self.class.setup
76 77
     unless filename && File.exist?(filename)
77 78
       raise MiniExiftool::Error.new("File '#{filename}' does not exist.")
78 79
     end
@@ -145,6 +146,7 @@ def changed_tags
145 146
 
146 147
   # Save the changes to the file.
147 148
   def save
  149
+    self.class.setup
148 150
     return false if @changed_values.empty?
149 151
     @errors.clear
150 152
     temp_file = Tempfile.new('mini_exiftool')
@@ -270,15 +272,20 @@ class MiniExiftool::Error < StandardError; end
270 272
   private
271 273
   ############################################################################
272 274
 
273  
-  @@error_file = Tempfile.new 'errors'
274  
-  @@error_file.close
  275
+  @@setup_done = false
  276
+  def self.setup
  277
+    return if @@setup_done
  278
+    @@error_file = Tempfile.new 'errors'
  279
+    @@error_file.close
275 280
 
276  
-  if Float(exiftool_version) < 7.41
277  
-    @@separator = ', '
278  
-    @@sep_op = ''
279  
-  else
280  
-    @@separator = '@@'
281  
-    @@sep_op = '-sep @@'
  281
+    if Float(exiftool_version) < 7.41
  282
+      @@separator = ', '
  283
+      @@sep_op = ''
  284
+    else
  285
+      @@separator = '@@'
  286
+      @@sep_op = '-sep @@'
  287
+    end
  288
+    @@setup_done = true
282 289
   end
283 290
 
284 291
   def run cmd

0 notes on commit 5f576fa

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