Sha256: ff7d2de4f610fda1865793117962277d475e903b2e75ea688e9edb944188d0a2

Contents?: true

Size: 804 Bytes

Versions: 1

Compression:

Stored size: 804 Bytes

Contents

require 'data_magic/core_ext/string'
require 'data_magic/core_ext/fixnum'
require "data_magic/version"
require "data_magic/translation"
require "data_magic/date_translation"
require 'yml_reader'

require 'faker'

module DataMagic
  include Translation
  include DateTranslation
  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

1 entries across 1 versions & 1 rubygems

Version Path
data_magic-0.12 lib/data_magic.rb