1
0
mirror of https://github.com/askn/faker.git synced 2023-08-10 21:13:01 +03:00

add password and price

This commit is contained in:
Aşkın Gedik 2016-01-07 09:26:30 +02:00
parent bbd1a10a42
commit d0044abb6d
5 changed files with 22 additions and 0 deletions

View File

@ -50,6 +50,7 @@ Faker::Address.longitude
Faker::Commerce.color
Faker::Commerce.department
Faker::Commerce.product_name
Faker::Commerce.price
```
### Faker::Company

View File

@ -25,6 +25,7 @@ puts "\n### Faker::Commerce\n\n"
puts Faker::Commerce.color
puts Faker::Commerce.department
puts Faker::Commerce.product_name
puts Faker::Commerce.price
puts "\n### Faker::Company\n\n"
@ -46,6 +47,9 @@ puts Faker::Internet.user_name
puts Faker::Internet.user_name("Nancy")
puts Faker::Internet.user_name("Nancy Johnson", %w(. _ -))
puts Faker::Internet.password
puts Faker::Internet.password(12)
puts Faker::Internet.domain_name
puts Faker::Internet.domain_word
puts Faker::Internet.domain_suffix

View File

@ -12,5 +12,9 @@ module Faker
product_name = Data["commerce"]["product_name"] as Hash
Faker.fetch(product_name["adjective"]) + " " + Faker.fetch(product_name["material"]) + " " + Faker.fetch(product_name["product"])
end
def self.price
(rand(100) + rand).round(2)
end
end
end

View File

@ -53,5 +53,13 @@ module Faker
glue ||= %w(- _ .).sample
(words || Lorem.words(2).join(' ')).gsub(' ', glue).downcase
end
def self.password(min_length = 0)
temp = Lorem.words.join
while temp.size < min_length
temp += Lorem.word
end
return temp
end
end
end

View File

@ -6,6 +6,11 @@ module Faker
Array(String).new(char_count < 0 ? 0 : char_count, "").map { chars.sample }.join("")
end
def self.word
words = Data["lorem"]["words"] as Array
Faker.fetch(words)
end
def self.words(num = 3, supplemental = false)
words = Data["lorem"]["words"] as Array
words += (Data["lorem"]["supplemental"] as Array) if supplemental