Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

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
@skalee skalee authored committed
Showing with 15 additions and 8 deletions.
  1. +15 −8 lib/mini_exiftool.rb
View
23 lib/mini_exiftool.rb
@@ -73,6 +73,7 @@ def initialize_from_hash hash # :nodoc:
# Load the tags of filename.
def load filename
+ self.class.setup
unless filename && File.exist?(filename)
raise MiniExiftool::Error.new("File '#{filename}' does not exist.")
end
@@ -145,6 +146,7 @@ def changed_tags
# Save the changes to the file.
def save
+ self.class.setup
return false if @changed_values.empty?
@errors.clear
temp_file = Tempfile.new('mini_exiftool')
@@ -270,15 +272,20 @@ class MiniExiftool::Error < StandardError; end
private
############################################################################
- @@error_file = Tempfile.new 'errors'
- @@error_file.close
+ @@setup_done = false
+ def self.setup
+ return if @@setup_done
+ @@error_file = Tempfile.new 'errors'
+ @@error_file.close
- if Float(exiftool_version) < 7.41
- @@separator = ', '
- @@sep_op = ''
- else
- @@separator = '@@'
- @@sep_op = '-sep @@'
+ if Float(exiftool_version) < 7.41
+ @@separator = ', '
+ @@sep_op = ''
+ else
+ @@separator = '@@'
+ @@sep_op = '-sep @@'
+ end
+ @@setup_done = true
end
def run cmd
Please sign in to comment.
Something went wrong with that request. Please try again.