class Laranja::Generator
Constants
- ALL
- NUMBERS
Attributes
static_data[W]
Protected Class Methods
data(key, scope = nil)
click to toggle source
# File lib/laranja/generator.rb, line 27 def data(key, scope = nil) static_data[scope || to_s.split('::')[-1].downcase][key] end
strf(format)
click to toggle source
# File lib/laranja/generator.rb, line 11 def strf(format) symbolize(format).gsub(/(:(?<scope>[^:\s\z]+))?%(?<key>[^%\s\z]+)/) do data($~[:key], $~[:scope]).sample end end
symbolize(format)
click to toggle source
# File lib/laranja/generator.rb, line 17 def symbolize(format) format.gsub(/#/) { NUMBERS.sample }.gsub(/\*/) { (1 + rand(9)).to_s }.gsub(/&/) { (ALL).sample } end
Private Class Methods
static_data()
click to toggle source
# File lib/laranja/generator.rb, line 33 def static_data @static_data ||= YAML.load_file(File.join(File.expand_path(File.dirname(__FILE__)), 'data', "#{Laranja.locale}.yml")) end