Sha256: 4f0e010a48433dd1ea8d7d0f79d65c80942952dfd49a361489574130ece7885c

Contents?: true

Size: 766 Bytes

Versions: 1

Compression:

Stored size: 766 Bytes

Contents

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

require 'faker'

module DataMagic
  include Translation

  def data_for(key)
    DataMagic.load('default.yml') unless DataMagic.yml
    data = DataMagic.yml[key]
    prep_data data.clone
  end

  private

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


  class << self
    attr_reader :yml
    
    #
    # load the provided filename from the config directory
    #
    def load(filename)
      @yml = reader.load_file(filename)
    end

    private
  
    def reader
      @reader ||= DataMagic::Reader.new
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
data_magic-0.2 lib/data_magic.rb