# frozen_string_literal: true require_relative 'key_defines' module KCommercial class Component CONFIGURATION_ROOT = 'Configurations'.freeze RESOURCES_CONFIGURATION_ROOT = 'Resources'.freeze def configurations_root path.join CONFIGURATION_ROOT end # Get the root for the resources configurations. it may # be contains i18n or images keys # @return [Pathname] def resources_configuration_root path = configurations_root.join 'resources' return path if path.exist? configurations_root.join CONFIGURATION_ROOT end # Get the i18ns key defines # @return [KeyDefines] def i18ns_keys @i18n_keys ||= key_defines_for_name('i18ns') end # Get the images key defines # @return [KeyDefines] def images_keys @images_keys ||= key_defines_for_name('images') end # Get the resources key defines # @return [KeyDefines] def files_keys @files_keys ||= key_defines_for_name('files') end # Get the fonts key defines # @return [KeyDefines] def fonts_keys @fonts_keys ||= key_defines_for_name('fonts') end # Get the colors key defines # @return [KeyDefines] def colors_keys @colors_keys ||= key_defines_for_name('colors') end private def key_defines_for_name(name) path = resources_configuration_root.join "#{name}.yaml" return KCommercial::Resources::KeyDefines.from_file(path) if path.exist? path = resources_configuration_root.join "#{name}.yml" return KCommercial::Resources::KeyDefines.from_file(path) if path.exist? nil end end end