Created
February 2, 2011 21:52
-
-
Save l1x/808530 to your computer and use it in GitHub Desktop.
generating test.yml
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
require 'rubygems' | |
require 'bcrypt' | |
require 'digest/md5' | |
require 'yaml' | |
#todo | |
# load schema.rb | |
# t.string "username", :limit => 30 | |
# t.string "email" | |
# t.string "password_hash" | |
# t.string "password_salt" | |
# t.string "reset_password_token" | |
# t.string "signature" | |
# t.boolean "active", :default => true | |
# t.integer "karma", :default => 0 | |
# t.integer "sign_in_count", :default => 0 | |
# t.integer "sign_in_failed", :default => 0 | |
# t.string "last_sign_in_ip" | |
# t.datetime "created_at" | |
# t.datetime "updated_at" | |
class NohupYamlWriter | |
def write(filename, hash) | |
File.open(filename, "w") do |f| | |
f.write(hash.to_yaml) | |
end | |
end | |
def gen_data(size) | |
hash = {} | |
(1..size).each { |i| | |
salt = BCrypt::Engine.generate_salt | |
pass = BCrypt::Engine.hash_secret("miez", salt) | |
user = Digest::MD5.hexdigest(i.to_s) | |
hash[i] = { | |
:username => user, | |
:email => "cigany@vagy.ok", | |
:password_salt => salt, | |
:password_hash => pass, | |
:reset_password_token => "asd", | |
:signature => "I am generated by a script", | |
:active => true, | |
:karma => 5, | |
:sign_in_count => 2, | |
:sign_in_failed => 2, | |
:last_sign_in_ip => "127.0.0.1", | |
:created_at => Time.now, | |
:updated_at => Time.now | |
} | |
} | |
return hash | |
end | |
end | |
begin | |
nyw=NohupYamlWriter.new | |
nyw.write("test.yml", nyw.gen_data(10)) | |
rescue => e | |
p "We fucked up, Huston" + e.inspect | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment