Module: Mockingjay::Generator

Extended by:
Faker
Defined in:
lib/mockingjay/generators/base_generators.rb

Overview

Eventually this should start searching through a folder of other fixtures to see if they know how to make an object.

Takes Generator hooks in serialized data and returns values.

Class Method Summary collapse

Class Method Details

.fixnum(str_range) ⇒ Object



10
11
12
13
# File 'lib/mockingjay/generators/base_generators.rb', line 10

def fixnum(str_range)
  a, b = *str_range.split(/...?/).map(&:to_i)
  b ? rand(a..b).to_i : rand(a).to_i
end

.float(str_range) ⇒ Object



15
16
17
18
# File 'lib/mockingjay/generators/base_generators.rb', line 15

def float(str_range)
  a, b = *str_range.split(/...?/).map(&:to_i)
  b ? rand(a..b) : rand(a)
end

.string(type = 'Lorem.word') ⇒ Object

Anything that you can use in faker, you can use here.

github.com/stympy/faker



23
24
25
# File 'lib/mockingjay/generators/base_generators.rb', line 23

def string(type = 'Lorem.word')
  self.instance_eval type
end

.unknown(type) ⇒ Object

def time(str_range)

a, b = *str_range.split('..')
b ? time_rand(a,b) : time_rand(a)

end



36
37
38
# File 'lib/mockingjay/generators/base_generators.rb', line 36

def unknown(type)
  "Unknown Generator Type #{type}"
end