From 7be6b5e2c9560b95171f0f6f1d1f80042c417828 Mon Sep 17 00:00:00 2001 From: Michael Overmeyer Date: Sat, 30 Nov 2024 17:52:56 -0500 Subject: [PATCH] Fix list parameter parsing Broke in thor v1.3.0 https://github.com/rails/thor/pull/784 --- lib/cldr/thor.rb | 14 ++++---------- ruby-cldr.gemspec | 4 ++-- 2 files changed, 6 insertions(+), 12 deletions(-) diff --git a/lib/cldr/thor.rb b/lib/cldr/thor.rb index 0d6bb2f..8a15620 100644 --- a/lib/cldr/thor.rb +++ b/lib/cldr/thor.rb @@ -37,8 +37,8 @@ def download desc "export [--locales=de fr-FR en-ZA] [--components=Numbers Plurals] [--target=#{Cldr::Export::DEFAULT_TARGET}] [--merge/--no-merge]", "Export CLDR data by locales and components to target dir" - option :locales, aliases: [:l], type: :array, banner: "de fr-FR en-ZA", enum: Cldr::Export::Data::RAW_DATA.locales - option :components, aliases: [:c], type: :array, banner: "Numbers Plurals", enum: Cldr::Export::Data.components + option :locales, aliases: [:l], type: :array, banner: "de fr-FR en-ZA", enum: Cldr::Export::Data::RAW_DATA.locales.map(&:to_s) + option :components, aliases: [:c], type: :array, banner: "Numbers Plurals", enum: Cldr::Export::Data.components.map(&:to_s) option :target, aliases: [:t], type: :string, default: Cldr::Export::DEFAULT_TARGET, banner: Cldr::Export::DEFAULT_TARGET option :draft_status, aliases: [:d], @@ -53,17 +53,11 @@ def export formatted_options = options.dup.symbolize_keys - # We do this validation, since thor doesn't - # https://github.com/rails/thor/issues/783 if formatted_options.key?(:locales) - formatted_options[:locales] = formatted_options[:locales].map(&:to_sym) if formatted_options.key?(:locales) - unknown_locales = formatted_options[:locales] - Cldr::Export::Data::RAW_DATA.locales - raise ArgumentError, "Unknown locales: #{unknown_locales.map { |l| "`#{l}`" }.join(", ")}" unless unknown_locales.empty? + formatted_options[:locales] = formatted_options[:locales].map(&:to_sym) end if formatted_options.key?(:components) - formatted_options[:components] = formatted_options[:components].map(&:to_sym) if formatted_options.key?(:components) - unknown_components = formatted_options[:components] - Cldr::Export::Data.components - raise ArgumentError, "Unknown components: #{unknown_components.join(", ")}" unless unknown_components.empty? + formatted_options[:components] = formatted_options[:components].map(&:to_sym) end if formatted_options.key?(:draft_status) diff --git a/ruby-cldr.gemspec b/ruby-cldr.gemspec index 011b5b5..4fdd84a 100644 --- a/ruby-cldr.gemspec +++ b/ruby-cldr.gemspec @@ -147,7 +147,7 @@ Gem::Specification.new do |s| s.add_runtime_dependency("nokogiri", [">= 0"]) s.add_runtime_dependency("psych", [">= 4.0.0"]) s.add_runtime_dependency("rubyzip", [">= 0"]) - s.add_runtime_dependency("thor", [">= 0"]) + s.add_runtime_dependency("thor", [">= 1.3.0"]) s.add_development_dependency("jeweler", [">= 0"]) s.add_development_dependency("pry", [">= 0"]) s.add_development_dependency("pry-nav", [">= 0"]) @@ -165,6 +165,6 @@ Gem::Specification.new do |s| s.add_dependency("ruby-lsp", [">= 0"]) s.add_dependency("rubyzip", [">= 0"]) s.add_dependency("test-unit", [">= 0"]) - s.add_dependency("thor", [">= 0"]) + s.add_dependency("thor", [">= 1.3.0"]) end end