exiftool 1.4.1 → 1.4.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d366da3c032228ce55518f4135d1b4fcfa10080cc8cfbd6ccc6ce4069003bfe7
4
- data.tar.gz: b1d57d1cdf42903f6b89aae48e28a8c77ab94ee182fd4e9a93fa2ac06df1e84c
3
+ metadata.gz: 0cae0346f74ff5e98290205477b94e40b000639d016e856e2cd175d0e6a7af75
4
+ data.tar.gz: 6e3e97c13a6ed3262d236161d970a278995cd98031cb4698717c892f4a302529
5
5
  SHA512:
6
- metadata.gz: d2490ea974066486fa54257751edfa550b4649ec010043f271cfcb3dc59df73a1e6eb9cb091468107b1408ce80b1ea2f23a1d812f74b19dac29e4d49ebf7731b
7
- data.tar.gz: 01b2c53488d1df6e69ff010d3a14f3ee3b0746e94b4f6b20e428fb29036fadf78e8fb18f655fcfe9f7b117e356c1bbfa708914b4814073d666c27a7a4c94e3c2
6
+ metadata.gz: 8349818edbe27e85fbb6ce6f2289c376a2db05eb513d3a4ece79633cc92aca5411239af8b1cedf04efcdaa506da6cf1a7ba7eb6d06e2a8860414584a2000f1a4
7
+ data.tar.gz: 46c87fca75ec1562a49338a28da08ed5420abdf1260d1e9241af05475fd14982f121e06d38662c76f53719e5dc1b65aece1943cdc3db3670a25bb28e9a87c6ba
@@ -14,7 +14,8 @@ class Exiftool
14
14
 
15
15
  def initialize(key, raw_value)
16
16
  @key = key
17
- @display_key = WORD_BOUNDARY_RES.inject(key) { |k, regex| k.gsub(regex, '\1 \2') }
17
+ sanitized_key = key.gsub(Exiftool::CONTROL_CHAR_RE, ' ')
18
+ @display_key = WORD_BOUNDARY_RES.inject(sanitized_key) { |k, regex| k.gsub(regex, '\1 \2') }
18
19
  @sym_key = display_key.downcase.gsub(' ', '_').to_sym
19
20
  @raw_value = raw_value
20
21
  end
@@ -30,9 +31,7 @@ class Exiftool
30
31
  raw_value
31
32
  end
32
33
  rescue StandardError => e
33
- # :nocov:
34
34
  "Warning: Parsing '#{raw_value}' for attribute '#{key}' raised #{e.message}"
35
- # :nocov:
36
35
  end
37
36
 
38
37
  def civil_date
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class Exiftool
4
- VERSION = Gem::Version.new('1.4.1')
4
+ VERSION = Gem::Version.new('1.4.3')
5
5
  end
data/lib/exiftool.rb CHANGED
@@ -10,22 +10,30 @@ require 'stringio'
10
10
 
11
11
  # Exiftool Class
12
12
  class Exiftool
13
+ CONTROL_CHAR_RE = /[[:cntrl:]]/
14
+
13
15
  class NoSuchFile < StandardError; end
14
16
 
15
17
  class NotAFile < StandardError; end
16
18
 
19
+ class InvalidCommand < StandardError; end
20
+
21
+ class InvalidOption < StandardError; end
22
+
17
23
  class ExiftoolNotInstalled < StandardError; end
18
24
 
19
25
  class NoDefaultResultWithMultiget < StandardError; end
20
26
 
21
- class << self
22
- attr_writer :command
23
- end
24
-
25
27
  def self.command
26
28
  @command ||= 'exiftool'
27
29
  end
28
30
 
31
+ def self.command=(command)
32
+ raise(InvalidCommand, command.inspect) if command.match?(CONTROL_CHAR_RE)
33
+
34
+ @command = command
35
+ end
36
+
29
37
  def self.exiftool_installed?
30
38
  exiftool_version.to_f.positive?
31
39
  end
@@ -49,6 +57,9 @@ class Exiftool
49
57
  end
50
58
 
51
59
  def self.expand_path(filename)
60
+ filename = filename.to_s
61
+ raise(NoSuchFile, filename.inspect) if filename.match?(CONTROL_CHAR_RE)
62
+
52
63
  raise(NoSuchFile, filename) unless File.exist?(filename)
53
64
 
54
65
  raise(NotAFile, filename) unless File.file?(filename)
@@ -56,6 +67,18 @@ class Exiftool
56
67
  File.expand_path(filename)
57
68
  end
58
69
 
70
+ def self.expand_paths(filenames)
71
+ filenames.map do |f|
72
+ f == '-' ? '-' : expand_path(f.to_s)
73
+ end
74
+ end
75
+
76
+ def self.exiftool_args(exiftool_opts)
77
+ raise(InvalidOption, exiftool_opts.inspect) if exiftool_opts.match?(CONTROL_CHAR_RE)
78
+
79
+ Shellwords.split(exiftool_opts)
80
+ end
81
+
59
82
  extend Forwardable
60
83
 
61
84
  def_delegators :first_result, :to_hash, :to_display_hash, :symbol_display_hash, :raw, :[]
@@ -71,12 +94,10 @@ class Exiftool
71
94
  filenames = [filenames] if filenames.is_a?(String) || filenames.is_a?(Pathname)
72
95
  return if filenames.empty?
73
96
 
74
- expanded_filenames = filenames.map do |f|
75
- f == '-' ? '-' : self.class.expand_path(f.to_s)
76
- end
97
+ expanded_filenames = self.class.expand_paths(filenames)
77
98
  args = [
78
99
  self.class.command,
79
- *Shellwords.split(exiftool_opts),
100
+ *self.class.exiftool_args(exiftool_opts),
80
101
  '-j',
81
102
  '-coordFormat', '%.8f',
82
103
  *expanded_filenames
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: exiftool
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.4.1
4
+ version: 1.4.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matthew McEachen
@@ -56,7 +56,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
56
56
  version: '0'
57
57
  requirements:
58
58
  - ExifTool (see http://exiftool.org)
59
- rubygems_version: 4.0.8
59
+ rubygems_version: 4.0.10
60
60
  specification_version: 4
61
61
  summary: Multiget ExifTool wrapper for ruby
62
62
  test_files: []