Created
July 30, 2011 08:57
-
-
Save sofadesign/1115349 to your computer and use it in GitHub Desktop.
Faker use example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby -wKU | |
puts RUBY_VERSION | |
require 'faker' | |
def initiatives | |
initiatives = [] | |
20.times do | |
begin_at = Time.now - rand(50*3600*24) | |
initiatives << { | |
:title => Faker::Lorem.sentence, | |
:begin_at => begin_at, | |
:end_at => begin_at + rand(50*3600*24), | |
:excerpt => Faker::Lorem.paragraph, | |
:comments_num => rand(20) | |
} | |
end | |
initiatives.sort{|a,b| b[:begin_at] <=> a[:begin_at] } | |
end | |
puts initiatives.to_yaml |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment