# 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