Sha256: 808d14d41aaa2138058820554665ab83ac5d3e4b7d2dbd4e41a294fac0f470de

Contents?: true

Size: 958 Bytes

Versions: 1

Compression:

Stored size: 958 Bytes

Contents

require 'ffaker'

require 'comable/core'

require 'comable/sample/engine'
require 'comable/sample/address'
require 'comable/sample/name'
require 'comable/sample/phone_number'

module Comable
  module Sample
    class << self
      def translate(key, options = {})
        Comable.translate("sample.#{key}", options)
      end

      alias_method :t, :translate

      def import_all
        definitions.each do |definition|
          import(definition)
        end
      end

      def import(filename)
        filepath = Rails.root.join("db/samples/#{filename}.rb")
        filepath = "#{default_dir}/#{filename}.rb" unless File.exist?(filepath)
        require File.expand_path(filepath)
      end

      private

      def definitions
        Dir["#{default_dir}/*.rb"].map do |filepath|
          File.basename(filepath, '.rb')
        end
      end

      def default_dir
        "#{File.dirname(__FILE__)}/../../db/samples"
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
comable-sample-0.6.0 lib/comable/sample.rb