diff --git a/src/faker/provider/internet/interfaces.nim b/src/faker/provider/internet/interfaces.nim index 3418151..81756b1 100644 --- a/src/faker/provider/internet/interfaces.nim +++ b/src/faker/provider/internet/interfaces.nim @@ -14,3 +14,17 @@ proc safeEmail*(f: Faker): string proc freeEmail*(f: Faker): string proc email*(f: Faker): string proc topLevelDomain*(f: Faker): string + +const + safeDomainNames = @["example.org", "example.com", "example.net"] + freeDomainNames = @["gmail.com", "yahoo.co.jp", "hotmail.com"] + topLevelDomains = @["com", "biz", "info", "net", "org"] + +proc safeDomainName*(f: Faker): string = + f.rand.sample(safeDomainNames) + +proc freeDomainName*(f: Faker): string = + f.rand.sample(freeDomainNames) + +proc topLevelDomain*(f: Faker): string = + f.rand.sample(topLevelDomains) diff --git a/src/faker/provider/internet/internet_en_US.nim b/src/faker/provider/internet/internet_en_US.nim index 5eeb6fc..eae4219 100644 --- a/src/faker/provider/internet/internet_en_US.nim +++ b/src/faker/provider/internet/internet_en_US.nim @@ -2,17 +2,6 @@ include interfaces import strutils import ../person -const - safeDomainNames = @["example.org", "example.com", "example.net"] - freeDomainNames = @["gmail.com", "yahoo.co.jp", "hotmail.com"] - topLevelDomains = @["com", "biz", "info", "net", "org"] - -proc safeDomainName*(f: Faker): string = - f.rand.sample(safeDomainNames) - -proc freeDomainName*(f: Faker): string = - f.rand.sample(freeDomainNames) - proc safeEmail*(f: Faker): string = f.firstName.toLower & "@" & f.safeDomainName @@ -26,6 +15,3 @@ proc email*(f: Faker): string = else: f.safeDomainName f.firstName.toLower & "@" & domain - -proc topLevelDomain*(f: Faker): string = - f.rand.sample(topLevelDomains) diff --git a/src/faker/provider/internet/internet_ja_JP.nim b/src/faker/provider/internet/internet_ja_JP.nim new file mode 100644 index 0000000..1e0640d --- /dev/null +++ b/src/faker/provider/internet/internet_ja_JP.nim @@ -0,0 +1,17 @@ +include interfaces +import strutils +import ../person/person_ja_JP + +proc safeEmail*(f: Faker): string = + f.firstRomanizedName.toLower & "@" & f.safeDomainName + +proc freeEmail*(f: Faker): string = + f.firstRomanizedName.toLower & "@" & f.freeDomainName + +proc email*(f: Faker): string = + let domain = + if rand(1) == 0: + f.freeDomainName + else: + f.safeDomainName + f.firstRomanizedName.toLower & "@" & domain