Sha256: 95cb6c7b3d6e9efcc9a058ec71f7f8efb7dc1d2328422899872c07bde9510c14

Contents?: true

Size: 1010 Bytes

Versions: 1

Compression:

Stored size: 1010 Bytes

Contents

# frozen_string_literal: true
require 'yaml'

module KCommercial
  module Resources
    class KeyDefines

      class << self
        # Creat a new KeyDefines from a file
        # @return [KeyDefines]
        def from_file(file)
          unless file
            KCommercial::UI.debug "can not find the key defines file #{file}"
            return  nil
          end
          contents = File.read(file)
          hash = YAML.load contents
          unless hash.is_a? Hash
            raise KCommercial::Exception("The content is not an hash in #{file}")
          end
          keys = KeyDefines.new(hash)
          keys.defined_in_file = file
          keys
        end
      end
      # All the key defines for the generator
      attr_reader :keys

      # The configuration file defines in the storage path
      attr_accessor :defined_in_file

      def initialize(hash = {})
        @keys = hash['keys'] or hash[:keys]
        if @keys.nil?
          @keys = []
        end
      end

    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

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