Sha256: e2f12a716c53c714d267120059475ff4c04746a110619797118970a913f67db6

Contents?: true

Size: 1.6 KB

Versions: 1

Compression:

Stored size: 1.6 KB

Contents

# 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

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
KCommercialPipeline-0.2.5.1 lib/KCommercialPipeline/core/resource/component_resources_config.rb