From b972a9d90fe53ddbfc497f66edbfbf777ebda7a0 Mon Sep 17 00:00:00 2001 From: Mau Magnaguagno Date: Mon, 13 Jun 2022 21:41:02 -0300 Subject: [PATCH 1/2] Refactor mkmf with safe navigation operator and split with block With safe navigation operator (Ruby 2.3) and split with block (Ruby 2.6) it is possible to avoid the intermediate variable ``opt``and array created by split, resulting in a more compact and clear code for the mkmf method. --- lib/un.rb | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/lib/un.rb b/lib/un.rb index 5feac92..5aa1a14 100644 --- a/lib/un.rb +++ b/lib/un.rb @@ -289,14 +289,14 @@ def wait_writable def mkmf setup("d:h:l:f:v:t:m:c:", "vendor") do |argv, options| require 'mkmf' - opt = options[:d] and opt.split(/:/).each {|n| dir_config(*n.split(/,/))} - opt = options[:h] and opt.split(/:/).each {|n| have_header(*n.split(/,/))} - opt = options[:l] and opt.split(/:/).each {|n| have_library(*n.split(/,/))} - opt = options[:f] and opt.split(/:/).each {|n| have_func(*n.split(/,/))} - opt = options[:v] and opt.split(/:/).each {|n| have_var(*n.split(/,/))} - opt = options[:t] and opt.split(/:/).each {|n| have_type(*n.split(/,/))} - opt = options[:m] and opt.split(/:/).each {|n| have_macro(*n.split(/,/))} - opt = options[:c] and opt.split(/:/).each {|n| have_const(*n.split(/,/))} + options[:d]&.split(/:/) {|n| dir_config(*n.split(/,/))} + options[:h]&.split(/:/) {|n| have_header(*n.split(/,/))} + options[:l]&.split(/:/) {|n| have_library(*n.split(/,/))} + options[:f]&.split(/:/) {|n| have_func(*n.split(/,/))} + options[:v]&.split(/:/) {|n| have_var(*n.split(/,/))} + options[:t]&.split(/:/) {|n| have_type(*n.split(/,/))} + options[:m]&.split(/:/) {|n| have_macro(*n.split(/,/))} + options[:c]&.split(/:/) {|n| have_const(*n.split(/,/))} $configure_args["--vendor"] = true if options[:vendor] create_makefile(*argv) end From c2b6ffd2dcf03fc5bf9ce79fbbf4530d1ad7133d Mon Sep 17 00:00:00 2001 From: Mau Magnaguagno Date: Mon, 20 Jun 2022 15:24:43 -0300 Subject: [PATCH 2/2] Bump required Ruby version to 2.6.0 --- un.gemspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/un.gemspec b/un.gemspec index de8e6ec..d955f61 100644 --- a/un.gemspec +++ b/un.gemspec @@ -9,7 +9,7 @@ Gem::Specification.new do |spec| spec.summary = "Utilities to replace common UNIX commands" spec.description = spec.summary spec.homepage = "https://github.com/ruby/un" - spec.required_ruby_version = Gem::Requirement.new(">= 2.3.0") + spec.required_ruby_version = Gem::Requirement.new(">= 2.6.0") spec.licenses = ["Ruby", "BSD-2-Clause"] spec.metadata["homepage_uri"] = spec.homepage