Sha256: de1aaeb345b2a6b785c5f9889157f207be40a6b73780fa51197a6f49e456415f
Contents?: true
Size: 1008 Bytes
Versions: 1
Compression:
Stored size: 1008 Bytes
Contents
require 'ffaker/utils/array_utils' require 'ffaker/utils/random_utils' require 'ffaker/utils/unique_utils' module FFaker module ModuleUtils include RandomUtils def k(arg) FFaker::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 = "#{FFaker::BASE_LIB_PATH}/ffaker/data/#{underscore(mod_name)}/#{underscore(const_name.to_s)}" data = k File.read(data_path).split("\n") const_set const_name, 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 def unique(max_retries = 10_000) @unique_generator ||= FFaker::UniqueUtils.new(self, max_retries) end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
ffaker-2.7.0 | lib/ffaker/utils/module_utils.rb |