From 570310274b0c01ef965650af375f666bd268ed0e Mon Sep 17 00:00:00 2001 From: Portnyagin Maxim Date: Wed, 25 Oct 2023 13:56:51 +0200 Subject: [PATCH 1/3] Fix frozen_string_literal: true --- lib/mini_exiftool.rb | 28 +++++++++++++--------------- 1 file changed, 13 insertions(+), 15 deletions(-) diff --git a/lib/mini_exiftool.rb b/lib/mini_exiftool.rb index 9147d3d..5d93dc5 100644 --- a/lib/mini_exiftool.rb +++ b/lib/mini_exiftool.rb @@ -147,14 +147,14 @@ def load filename_or_io end @values.clear @changed_values.clear - params = '-j ' - params << (@opts[:numerical] ? '-n ' : '') - params << (@opts[:composite] ? '' : '-e ') + params = ['-j '] + params << (@opts[:numerical] ? '-n' : '') + params << (@opts[:composite] ? '' : '-e') params << (@opts[:coord_format] ? "-c #{escape(@opts[:coord_format])}" : '') - params << (@opts[:fast] ? '-fast ' : '') - params << (@opts[:fast2] ? '-fast2 ' : '') + params << (@opts[:fast] ? '-fast' : '') + params << (@opts[:fast2] ? '-fast2' : '') params << generate_encoding_params - if run(cmd_gen(params, @filename)) + if run(cmd_gen(params.join(' '), @filename)) parse_output else raise MiniExiftool::Error.new(@error_text) @@ -225,14 +225,14 @@ def save original_tag = MiniExiftool.original_tag(tag) arr_val = val.kind_of?(Array) ? val : [val] arr_val.map! {|e| convert_before_save(e)} - params = '-q -P -overwrite_original ' - params << (arr_val.detect {|x| x.kind_of?(Numeric)} ? '-n ' : '') - params << (@opts[:ignore_minor_errors] ? '-m ' : '') + params = ['-q -P -overwrite_original'] + params << (arr_val.detect {|x| x.kind_of?(Numeric)} ? '-n' : '') + params << (@opts[:ignore_minor_errors] ? '-m' : '') params << generate_encoding_params arr_val.each do |v| params << %Q(-#{original_tag}=#{escape(v)} ) end - result = run(cmd_gen(params, temp_filename)) + result = run(cmd_gen(params.join(' '), temp_filename)) unless result all_ok = false @errors[tag] = @error_text.gsub(/Nothing to do.\n\z/, '').chomp @@ -545,13 +545,11 @@ def escape val end def generate_encoding_params - params = '' - @@encoding_types.each do |enc_type| + @@encoding_types.map do |enc_type| if enc_val = @opts[MiniExiftool.encoding_opt(enc_type)] - params << "-charset #{enc_type}=#{enc_val} " + "-charset #{enc_type}=#{enc_val}" end - end - params + end.join(' ') end # Backport YAML.unsafe_load From 5fa67cb268944173bea1983a532da0273b462417 Mon Sep 17 00:00:00 2001 From: Portnyagin Maxim Date: Wed, 25 Oct 2023 14:11:07 +0200 Subject: [PATCH 2/3] Fix tests --- lib/mini_exiftool.rb | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/lib/mini_exiftool.rb b/lib/mini_exiftool.rb index 5d93dc5..95338d2 100644 --- a/lib/mini_exiftool.rb +++ b/lib/mini_exiftool.rb @@ -147,14 +147,14 @@ def load filename_or_io end @values.clear @changed_values.clear - params = ['-j '] - params << (@opts[:numerical] ? '-n' : '') - params << (@opts[:composite] ? '' : '-e') - params << (@opts[:coord_format] ? "-c #{escape(@opts[:coord_format])}" : '') - params << (@opts[:fast] ? '-fast' : '') - params << (@opts[:fast2] ? '-fast2' : '') + params = ['-j'] + params << ('-n' if @opts[:numerical]) + params << ('-e' unless @opts[:composite]) + params << ("-c #{escape(@opts[:coord_format])}" if @opts[:coord_format]) + params << ('-fast' if @opts[:fast]) + params << ('-fast2' if @opts[:fast2]) params << generate_encoding_params - if run(cmd_gen(params.join(' '), @filename)) + if run(cmd_gen(params.compact.join(' '), @filename)) parse_output else raise MiniExiftool::Error.new(@error_text) @@ -232,7 +232,7 @@ def save arr_val.each do |v| params << %Q(-#{original_tag}=#{escape(v)} ) end - result = run(cmd_gen(params.join(' '), temp_filename)) + result = run(cmd_gen(params.compact.join(' '), temp_filename)) unless result all_ok = false @errors[tag] = @error_text.gsub(/Nothing to do.\n\z/, '').chomp @@ -549,7 +549,7 @@ def generate_encoding_params if enc_val = @opts[MiniExiftool.encoding_opt(enc_type)] "-charset #{enc_type}=#{enc_val}" end - end.join(' ') + end.compact.join(' ') end # Backport YAML.unsafe_load From de75ea847c948c51702f5893169bf87f3bb45c90 Mon Sep 17 00:00:00 2001 From: Portnyagin Maxim Date: Wed, 25 Oct 2023 14:12:33 +0200 Subject: [PATCH 3/3] Dump version --- Changelog | 3 +++ lib/mini_exiftool.rb | 2 +- mini_exiftool.gemspec | 4 ++-- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/Changelog b/Changelog index e06b03d..999c42d 100644 --- a/Changelog +++ b/Changelog @@ -1,3 +1,6 @@ +2.10.5 +- Fix a problem with frozen string in newer Ruby versions. + 2.10.4 - Maintenance release. diff --git a/lib/mini_exiftool.rb b/lib/mini_exiftool.rb index 95338d2..8dc0e3b 100644 --- a/lib/mini_exiftool.rb +++ b/lib/mini_exiftool.rb @@ -27,7 +27,7 @@ # Simple OO access to the ExifTool command-line application. class MiniExiftool - VERSION = '2.10.4' + VERSION = '2.10.5' # Name of the ExifTool command-line application @@cmd = 'exiftool' diff --git a/mini_exiftool.gemspec b/mini_exiftool.gemspec index 7ba75a2..2ba6d0c 100644 --- a/mini_exiftool.gemspec +++ b/mini_exiftool.gemspec @@ -1,5 +1,5 @@ # -*- encoding: utf-8 -*- -# stub: mini_exiftool 2.10.4 ruby lib +# stub: mini_exiftool 2.10.5 ruby lib # # This file is automatically generated by rim. # PLEASE DO NOT EDIT IT DIRECTLY! @@ -7,7 +7,7 @@ Gem::Specification.new do |s| s.name = "mini_exiftool" - s.version = "2.10.4" + s.version = "2.10.5" s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version= s.require_paths = ["lib"]