Sha256: fdad03e156cf865401362104626f5354447b62357c566d32a6c1c1dab5f20ce2

Contents?: true

Size: 715 Bytes

Versions: 1

Compression:

Stored size: 715 Bytes

Contents

require "data_magic/version"
require "data_magic/config"
require "data_magic/reader"
require "data_magic/translation"
require 'yml_reader'

require 'faker'

module DataMagic
  include Translation
  extend YmlReader

  def data_for(key, additional={})
    DataMagic.load('default.yml') unless DataMagic.yml
    data = DataMagic.yml[key.to_s]
    prep_data data.merge(additional).clone
  end

  private

  def prep_data(data)
    data.each do |key, value|
      unless value.nil?
        next unless value.respond_to? '[]'
        data[key] = eval(value[1..-1]) if value[0,1] == "~"
      end
    end
    data
  end

  class << self
    attr_reader :yml
  
    def default_directory
      'config'
    end
  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
data_magic-0.6 lib/data_magic.rb