Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions lib/random.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
require File.join(File.dirname(__FILE__), 'random_us_surname.rb')
require File.join(File.dirname(__FILE__), 'random_us_zip.rb')
require File.join(File.dirname(__FILE__), 'random_us_city.rb')
require File.join(File.dirname(__FILE__), 'random_sha1_hash.rb')
7 changes: 7 additions & 0 deletions lib/random_sha1_hash.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
require 'digest/sha1'

class RandomSha1Hash
def random
Digest::SHA1.hexdigest "#{Time.now.to_f}#{rand}"
end
end
3 changes: 2 additions & 1 deletion makefake.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,14 @@

opts.on("--records n", Integer, "Number of records to generate", '=MANDATORY') { |n| options[:count] = n }

opts.on("--fields x,y,z", Array, "Random fields to include", "Fields can be: city, zip, surname, firstname") do |fields|
opts.on("--fields x,y,z", Array, "Random fields to include", "Fields can be: city, zip, surname, firstname, sha1hash") do |fields|
fields.each do |field|
case field
when 'city' then options[:fields].push(RandomUSCity.new US_GEOGRAPHY)
when 'zip' then options[:fields].push(RandomUSZip.new US_GEOGRAPHY)
when 'surname' then options[:fields].push(RandomUSSurname.new US_SURNAMES)
when 'firstname' then options[:fields].push(RandomUSFirstname.new US_FIRSTNAMES)
when 'sha1hash' then options[:fields].push(RandomSha1Hash.new)
else
puts "Invalid field #{field}"
puts opts
Expand Down