Sha256: 9ae38f242fcf7ee8e83af476dbbecea43ba28f537cbef48b3bc299c7e78e873a
Contents?: true
Size: 864 Bytes
Versions: 2
Compression:
Stored size: 864 Bytes
Contents
require "data_builder/version" require "data_reader" module DataBuilder extend DataReader class << self attr_accessor :data_source def default_data_path 'data' end end def data_about(key, specified = {}) if key.is_a?(String) && key.match(%r{/}) file, record = key.split('/') DataBuilder.load("#{file}.yml") else record = key.to_s DataBuilder.load(builder_source) unless DataBuilder.data_source end data = DataBuilder.data_source[record] raise ArgumentError, "Undefined key for data: #{key}" unless data data.merge(specified).clone end alias data_from data_about alias data_for data_about alias using_data_for data_about alias using_data_from data_about private def builder_source ENV['DATA_BUILDER_SOURCE'] ? ENV['DATA_BUILDER_SOURCE'] : 'default.yml' end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
data_builder-0.2.0 | lib/data_builder.rb |
data_builder-0.1.0 | lib/data_builder.rb |