lib/chamber/keys/base.rb in chamber-2.13.1 vs lib/chamber/keys/base.rb in chamber-2.14.0

- old
+ new

@@ -1,22 +1,22 @@ # frozen_string_literal: true module Chamber module Keys class Base - def self.resolve(*args) - new(*args).resolve + def self.resolve(**args) + new(**args).resolve end attr_accessor :rootpath attr_reader :filenames, :namespaces - def initialize(options = {}) - self.rootpath = Pathname.new(options.fetch(:rootpath)) - self.namespaces = options.fetch(:namespaces) - self.filenames = options[:filenames] + def initialize(rootpath:, namespaces:, filenames: nil) + self.rootpath = Pathname.new(rootpath) + self.namespaces = namespaces + self.filenames = filenames end def resolve key_paths.each_with_object({}) do |path, memo| namespace = namespace_from_path(path) || '__default' @@ -39,24 +39,24 @@ namespaces.map { |n| namespace_to_key_path(n) } end # rubocop:disable Performance/ChainArrayAllocation def filenames=(other) - @filenames = Array(other). - map { |o| Pathname.new(o) }. - compact + @filenames = Array(other) + .map { |o| Pathname.new(o) } + .compact end # rubocop:enable Performance/ChainArrayAllocation def namespaces=(other) @namespaces = other + %w{signature} end def namespace_from_path(path) - path. - basename. - to_s. - match(self.class::NAMESPACE_PATTERN) { |m| m[1].upcase } + path + .basename + .to_s + .match(self.class::NAMESPACE_PATTERN) { |m| m[1].upcase } end def namespace_to_key_path(namespace) rootpath + ".chamber.#{namespace.to_s.tr('.-', '')}#{key_filename_extension}" end