lib/anyway/config.rb in runger_config-2.6.1 vs lib/anyway/config.rb in runger_config-2.7.0
- old
+ new
@@ -1,7 +1,8 @@
# frozen_string_literal: true
+require "active_support/all"
require "anyway/optparse_config"
require "anyway/dynamic_config"
module Anyway # :nodoc:
using RubyNext
@@ -290,19 +291,15 @@
unless name
raise "Please, specify config name explicitly for anonymous class " \
"via `config_name :my_config`"
end
- # handle two cases:
- # - SomeModule::Config => "some_module"
- # - SomeConfig => "some"
- unless name =~ /^(\w+)(::)?Config$/
+ unless name.underscore.gsub("/", "_") =~ /(\w+)_config\z/
raise "Couldn't infer config name, please, specify it explicitly " \
"via `config_name :my_config`"
end
- # TODO(v3.0): Replace downcase with underscore
- Regexp.last_match[1].tap(&:downcase!)
+ Regexp.last_match[1].delete_suffix("_config").tap(&:downcase!)
end
def validate_param_names!(names)
invalid_names = names.reject { |name| name =~ PARAM_NAME }
return if invalid_names.empty?