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

add Address.country_code

This commit is contained in:
Aşkın Gedik
2016-03-28 10:41:33 +03:00
parent 0b5942bf58
commit bc5c00e912
5 changed files with 220 additions and 4 deletions

View File

@@ -55,6 +55,7 @@ module Faker
Name.name,
Name.prefix,
Name.suffix,
Team.creature,
], $1)
end
end

View File

@@ -4,7 +4,7 @@ module Faker
Faker.numerify(["#####", "#####-####"].sample)
end
{% for data_type in %w(state state_abbr city_suffix city_prefix country street_suffix) %}
{% for data_type in %w(state state_abbr city_suffix city_prefix country street_suffix country_code) %}
def self.{{data_type.id}}
Faker.fetch(Data["address"]["{{data_type.id}}"])
end
@@ -56,7 +56,7 @@ module Faker
end
def self.time_zone
Faker.bothify(Faker.fetch(Data["address"]["time_zone"]))
Faker.fetch(Data["address"]["time_zone"])
end
end
end

View File

@@ -103,13 +103,13 @@ module Faker
temp = temp[0..min_length] if min_length > 0
if mix_case
temp = temp.gsub(/.{1,2}/) { |s| "#{s[0]}#{s[1].upcase if s[1]?}" }
temp = temp.gsub(/.{1,2}/) { |s| s.capitalize }
end
if special_chars
chars = %w(! @ # $ % ^ & *)
Random.rand(min_length).times do |i|
temp = temp.sub({ temp[i] => chars[Random.rand(chars.size)] })
temp = temp.sub({temp[i] => chars[Random.rand(chars.size)]})
end
end