Sha256: e1a1fd131a0d93a83aee9e1082f5dd133f0ba6b69910e3c26ccbde3b602551a5
Contents?: true
Size: 766 Bytes
Versions: 2
Compression:
Stored size: 766 Bytes
Contents
require 'ffaker/utils/array_utils' module Faker module ModuleUtils def k(arg) Faker::ArrayUtils.const_array(arg) end def const_missing(const_name) if const_name =~ /[a-z]/ # Not a constant, probably a class/module name. super const_name else mod_name = ancestors.first.to_s.split("::").last data_path = "#{Faker::BASE_LIB_PATH}/ffaker/data/#{underscore(mod_name)}/#{underscore(const_name.to_s)}" data = File.read(data_path).split("\n") const_set const_name, k(data) data end end def underscore(string) string.gsub(/::/, '/'). gsub(/([A-Z]+)([A-Z][a-z])/,'\1_\2'). gsub(/([a-z\d])([A-Z])/,'\1_\2'). tr("-", "_"). downcase end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
ffaker-1.22.1 | lib/ffaker/utils/module_utils.rb |
ffaker-1.22.0 | lib/ffaker/utils/module_utils.rb |