Sha256: 39a00c19f54c92f3bba2127a61150d8b8040d10911c7c6136ce0e70887abb01d

Contents?: true

Size: 703 Bytes

Versions: 2

Compression:

Stored size: 703 Bytes

Contents

require 'data_magic/core_ext/string'
require "data_magic/version"
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_accessor :yml
  
    def default_directory
      'config/data'
    end
  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
data_magic-0.11 lib/data_magic.rb
data_magic-0.10 lib/data_magic.rb