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

Update to Crystal 0.19.4

This commit is contained in:
Serdar Dogruyol 2016-10-20 14:29:47 +03:00
parent fb5c4708f7
commit ae84c91f94
8 changed files with 130 additions and 130 deletions

File diff suppressed because one or more lines are too long

View File

@ -3,7 +3,7 @@ require "./faker/*"
module Faker
def self.numerify(number_string)
number_string = number_string as String
number_string = number_string.as String
number_string.sub(/#/) { (rand(9) + 1).to_s }.gsub(/#/) { rand(10).to_s }
end
@ -30,13 +30,13 @@ module Faker
end
def self.fetch(data)
data = data as Array
fetched = data.sample as String
data = data.as Array
fetched = data.sample.as String
if fetched.match(/^\//) && fetched.match(/\/$/) # A regex
fetched = Faker.regexify(fetched)
end
Faker.parse(fetched) as String
Faker.parse(fetched).as String
end
def self.parse(st)

View File

@ -5,7 +5,7 @@ module Faker
end
def self.credit_card_expiry_date
credit_card_expiry_date = Faker.fetch(Data["business"]["credit_card_expiry_dates"]) as String
credit_card_expiry_date = Faker.fetch(Data["business"]["credit_card_expiry_dates"]).as String
Time.parse(credit_card_expiry_date, "%Y-%m-%d")
end

View File

@ -18,12 +18,12 @@ module Faker
end
def self.material
product_name = Data["commerce"]["product_name"] as Hash
product_name = Data["commerce"]["product_name"].as Hash
Faker.fetch(product_name["material"])
end
def self.product_name
product_name = Data["commerce"]["product_name"] as Hash
product_name = Data["commerce"]["product_name"].as Hash
Faker.fetch(product_name["adjective"]) + " " + Faker.fetch(product_name["material"]) + " " + Faker.fetch(product_name["product"])
end

View File

@ -9,12 +9,12 @@ module Faker
end
def self.catch_phrase
data = Data["company"]["buzzwords"] as Array(Array(String))
data = Data["company"]["buzzwords"].as Array(Array(String))
Faker.fetch(data.flatten)
end
def self.bs
data = Data["company"]["bs"] as Array(Array(String))
data = Data["company"]["bs"].as Array(Array(String))
Faker.fetch(data.flatten)
end

View File

@ -1,6 +1,6 @@
module Faker
class Finance
CREDIT_CARD_TYPES = (Data["credit_card"] as Hash).keys
CREDIT_CARD_TYPES = (Data["credit_card"].as(Hash)).keys
def self.credit_card(types : Array = [] of Array(String))
types = CREDIT_CARD_TYPES if types.empty?

View File

@ -11,13 +11,13 @@ module Faker
end
def self.word
words = Data["lorem"]["words"] as Array
words = Data["lorem"]["words"].as Array
Faker.fetch(words)
end
def self.words(num = 3, supplemental = false)
words = Data["lorem"]["words"] as Array(String)
words += (Data["lorem"]["supplemental"] as Array(String)) if supplemental
words = Data["lorem"]["words"].as Array(String)
words += (Data["lorem"]["supplemental"].as Array(String)) if supplemental
words.shuffle[0, num]
end

View File

@ -7,7 +7,7 @@ module Faker
{% end %}
def self.title
title = Data["name"]["title"] as Hash
title = Data["name"]["title"].as Hash
Faker.fetch(title["descriptor"]) + " " + Faker.fetch(title["level"]) + " " + Faker.fetch(title["job"])
end
end