Skip to content

Commit 33b742b

Browse files
authored
chore: import文の書き方を変更 (#78)
* importの書き方を変更 * code format * importの生成処理を変更 * code format * import文を修正 * providerの生成処理を修正 * import文を修正 * import文を修正 * Add ignore * Add task * Fix CI * Fix test * Rename * Fix test * Fix test * Code format * Fix test * Remove unused * bump patch
1 parent 86b316b commit 33b742b

27 files changed

+276
-158
lines changed

.github/workflows/test.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ jobs:
3232
nim-version: ${{ matrix.nim-version }}
3333
- run: nimble build -Y
3434
- run: nimble install -Y
35-
- run: nimble test -Y
35+
- run: nimble tests
3636

3737
docs:
3838
runs-on: ubuntu-latest

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,5 @@ tests/*.exe
77

88
tools/generator
99
!tests/testdata
10+
testresults/
11+
nimcache/

faker.nimble

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Package
22

3-
version = "0.15.1"
3+
version = "0.15.2"
44
author = "jiro4989"
55
description = "faker is a Nim package that generates fake data for you."
66
license = "MIT"
@@ -20,6 +20,9 @@ requires "nim >= 1.0.0"
2020
let
2121
providerDir = "src" / "faker" / "provider"
2222

23+
task tests, "Run test":
24+
exec "testament p 'tests/test_*.nim'"
25+
2326
task docs, "Generate API documents":
2427
exec "nimble doc --index:on --project --out:docs --hints:off src/faker.nim"
2528

src/faker.nim

+5-2
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,8 @@ runnableExamples:
99
let fake = newFaker()
1010
echo fake.address()
1111

12-
import faker/[base, provider]
13-
export base, provider
12+
import ./faker/base
13+
import ./faker/provider
14+
15+
export base
16+
export provider

src/faker/base.nim

+6-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1-
import random, times, os, strutils
1+
import std/os
2+
import std/random
3+
import std/strutils
4+
import std/times
5+
26
export random
37

48
type
@@ -11,7 +15,7 @@ proc newFaker*(locale = "", seed = 0): Faker =
1115
# seed値で乱数を初期化。seedが0以下なら現在時刻をseed値とする
1216
result.rand =
1317
if 0 < seed: initRand(seed)
14-
else:
18+
else:
1519
let now = times.getTime()
1620
initRand(convert(Seconds, Nanoseconds, now.toUnix) + now.nanosecond)
1721
# 言語をセット

src/faker/provider.nim

+29-2
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,32 @@
33
# See 'tools/generator'. #
44
# ----------------------------------------------- #
55

6-
import provider/[address, automotive, bank, company, currency, file, internet, isbn, job, lorem, misc, person, phone_number, user_agent]
7-
export address, automotive, bank, company, currency, file, internet, isbn, job, lorem, misc, person, phone_number, user_agent
6+
import provider/address
7+
import provider/automotive
8+
import provider/bank
9+
import provider/company
10+
import provider/currency
11+
import provider/file
12+
import provider/internet
13+
import provider/isbn
14+
import provider/job
15+
import provider/lorem
16+
import provider/misc
17+
import provider/person
18+
import provider/phone_number
19+
import provider/user_agent
20+
21+
export address
22+
export automotive
23+
export bank
24+
export company
25+
export currency
26+
export file
27+
export internet
28+
export isbn
29+
export job
30+
export lorem
31+
export misc
32+
export person
33+
export phone_number
34+
export user_agent

src/faker/provider/address.nim

+25-23
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
# ----------------------------------------------- #
2-
# This module was generated by 'nimble genProvs'. #
3-
# See 'faker.nimble'. #
2+
# This module was generated by 'generator' tool . #
3+
# See 'tools/generator'. #
44
# ----------------------------------------------- #
55

66
import ../base
7-
import address/[address_ja_JP, address_en_US, address_fa_IR]
7+
import address/address_en_US
8+
import address/address_fa_IR
9+
import address/address_ja_JP
810
export base
911

1012
proc address*(f: Faker): string =
@@ -14,9 +16,9 @@ proc address*(f: Faker): string =
1416
echo f.address()
1517

1618
case f.locale
17-
of "ja_JP": address_ja_JP.address(f)
1819
of "en_US": address_en_US.address(f)
1920
of "fa_IR": address_fa_IR.address(f)
21+
of "ja_JP": address_ja_JP.address(f)
2022
else: address_en_US.address(f)
2123

2224
proc buildingNumber*(f: Faker): string =
@@ -26,9 +28,9 @@ proc buildingNumber*(f: Faker): string =
2628
echo f.buildingNumber()
2729

2830
case f.locale
29-
of "ja_JP": address_ja_JP.buildingNumber(f)
3031
of "en_US": address_en_US.buildingNumber(f)
3132
of "fa_IR": address_fa_IR.buildingNumber(f)
33+
of "ja_JP": address_ja_JP.buildingNumber(f)
3234
else: address_en_US.buildingNumber(f)
3335

3436
proc city*(f: Faker): string =
@@ -38,9 +40,9 @@ proc city*(f: Faker): string =
3840
echo f.city()
3941

4042
case f.locale
41-
of "ja_JP": address_ja_JP.city(f)
4243
of "en_US": address_en_US.city(f)
4344
of "fa_IR": address_fa_IR.city(f)
45+
of "ja_JP": address_ja_JP.city(f)
4446
else: address_en_US.city(f)
4547

4648
proc cityPrefix*(f: Faker): string =
@@ -50,9 +52,9 @@ proc cityPrefix*(f: Faker): string =
5052
echo f.cityPrefix()
5153

5254
case f.locale
53-
of "ja_JP": address_ja_JP.cityPrefix(f)
5455
of "en_US": address_en_US.cityPrefix(f)
5556
of "fa_IR": address_fa_IR.cityPrefix(f)
57+
of "ja_JP": address_ja_JP.cityPrefix(f)
5658
else: address_en_US.cityPrefix(f)
5759

5860
proc citySuffix*(f: Faker): string =
@@ -62,9 +64,9 @@ proc citySuffix*(f: Faker): string =
6264
echo f.citySuffix()
6365

6466
case f.locale
65-
of "ja_JP": address_ja_JP.citySuffix(f)
6667
of "en_US": address_en_US.citySuffix(f)
6768
of "fa_IR": address_fa_IR.citySuffix(f)
69+
of "ja_JP": address_ja_JP.citySuffix(f)
6870
else: address_en_US.citySuffix(f)
6971

7072
proc country*(f: Faker): string =
@@ -74,9 +76,9 @@ proc country*(f: Faker): string =
7476
echo f.country()
7577

7678
case f.locale
77-
of "ja_JP": address_ja_JP.country(f)
7879
of "en_US": address_en_US.country(f)
7980
of "fa_IR": address_fa_IR.country(f)
81+
of "ja_JP": address_ja_JP.country(f)
8082
else: address_en_US.country(f)
8183

8284
proc militaryApo*(f: Faker): string =
@@ -86,9 +88,9 @@ proc militaryApo*(f: Faker): string =
8688
echo f.militaryApo()
8789

8890
case f.locale
89-
of "ja_JP": address_ja_JP.militaryApo(f)
9091
of "en_US": address_en_US.militaryApo(f)
9192
of "fa_IR": address_fa_IR.militaryApo(f)
93+
of "ja_JP": address_ja_JP.militaryApo(f)
9294
else: address_en_US.militaryApo(f)
9395

9496
proc militaryDpo*(f: Faker): string =
@@ -98,9 +100,9 @@ proc militaryDpo*(f: Faker): string =
98100
echo f.militaryDpo()
99101

100102
case f.locale
101-
of "ja_JP": address_ja_JP.militaryDpo(f)
102103
of "en_US": address_en_US.militaryDpo(f)
103104
of "fa_IR": address_fa_IR.militaryDpo(f)
105+
of "ja_JP": address_ja_JP.militaryDpo(f)
104106
else: address_en_US.militaryDpo(f)
105107

106108
proc militaryShip*(f: Faker): string =
@@ -110,9 +112,9 @@ proc militaryShip*(f: Faker): string =
110112
echo f.militaryShip()
111113

112114
case f.locale
113-
of "ja_JP": address_ja_JP.militaryShip(f)
114115
of "en_US": address_en_US.militaryShip(f)
115116
of "fa_IR": address_fa_IR.militaryShip(f)
117+
of "ja_JP": address_ja_JP.militaryShip(f)
116118
else: address_en_US.militaryShip(f)
117119

118120
proc militaryState*(f: Faker): string =
@@ -122,9 +124,9 @@ proc militaryState*(f: Faker): string =
122124
echo f.militaryState()
123125

124126
case f.locale
125-
of "ja_JP": address_ja_JP.militaryState(f)
126127
of "en_US": address_en_US.militaryState(f)
127128
of "fa_IR": address_fa_IR.militaryState(f)
129+
of "ja_JP": address_ja_JP.militaryState(f)
128130
else: address_en_US.militaryState(f)
129131

130132
proc postalcode*(f: Faker): string =
@@ -134,9 +136,9 @@ proc postalcode*(f: Faker): string =
134136
echo f.postalcode()
135137

136138
case f.locale
137-
of "ja_JP": address_ja_JP.postalcode(f)
138139
of "en_US": address_en_US.postalcode(f)
139140
of "fa_IR": address_fa_IR.postalcode(f)
141+
of "ja_JP": address_ja_JP.postalcode(f)
140142
else: address_en_US.postalcode(f)
141143

142144
proc postalcodePlus4*(f: Faker): string =
@@ -146,9 +148,9 @@ proc postalcodePlus4*(f: Faker): string =
146148
echo f.postalcodePlus4()
147149

148150
case f.locale
149-
of "ja_JP": address_ja_JP.postalcodePlus4(f)
150151
of "en_US": address_en_US.postalcodePlus4(f)
151152
of "fa_IR": address_fa_IR.postalcodePlus4(f)
153+
of "ja_JP": address_ja_JP.postalcodePlus4(f)
152154
else: address_en_US.postalcodePlus4(f)
153155

154156
proc postcode*(f: Faker): string =
@@ -158,9 +160,9 @@ proc postcode*(f: Faker): string =
158160
echo f.postcode()
159161

160162
case f.locale
161-
of "ja_JP": address_ja_JP.postcode(f)
162163
of "en_US": address_en_US.postcode(f)
163164
of "fa_IR": address_fa_IR.postcode(f)
165+
of "ja_JP": address_ja_JP.postcode(f)
164166
else: address_en_US.postcode(f)
165167

166168
proc secondaryAddress*(f: Faker): string =
@@ -170,9 +172,9 @@ proc secondaryAddress*(f: Faker): string =
170172
echo f.secondaryAddress()
171173

172174
case f.locale
173-
of "ja_JP": address_ja_JP.secondaryAddress(f)
174175
of "en_US": address_en_US.secondaryAddress(f)
175176
of "fa_IR": address_fa_IR.secondaryAddress(f)
177+
of "ja_JP": address_ja_JP.secondaryAddress(f)
176178
else: address_en_US.secondaryAddress(f)
177179

178180
proc state*(f: Faker): string =
@@ -182,9 +184,9 @@ proc state*(f: Faker): string =
182184
echo f.state()
183185

184186
case f.locale
185-
of "ja_JP": address_ja_JP.state(f)
186187
of "en_US": address_en_US.state(f)
187188
of "fa_IR": address_fa_IR.state(f)
189+
of "ja_JP": address_ja_JP.state(f)
188190
else: address_en_US.state(f)
189191

190192
proc streetAddress*(f: Faker): string =
@@ -194,9 +196,9 @@ proc streetAddress*(f: Faker): string =
194196
echo f.streetAddress()
195197

196198
case f.locale
197-
of "ja_JP": address_ja_JP.streetAddress(f)
198199
of "en_US": address_en_US.streetAddress(f)
199200
of "fa_IR": address_fa_IR.streetAddress(f)
201+
of "ja_JP": address_ja_JP.streetAddress(f)
200202
else: address_en_US.streetAddress(f)
201203

202204
proc streetName*(f: Faker): string =
@@ -206,9 +208,9 @@ proc streetName*(f: Faker): string =
206208
echo f.streetName()
207209

208210
case f.locale
209-
of "ja_JP": address_ja_JP.streetName(f)
210211
of "en_US": address_en_US.streetName(f)
211212
of "fa_IR": address_fa_IR.streetName(f)
213+
of "ja_JP": address_ja_JP.streetName(f)
212214
else: address_en_US.streetName(f)
213215

214216
proc streetSuffix*(f: Faker): string =
@@ -218,9 +220,9 @@ proc streetSuffix*(f: Faker): string =
218220
echo f.streetSuffix()
219221

220222
case f.locale
221-
of "ja_JP": address_ja_JP.streetSuffix(f)
222223
of "en_US": address_en_US.streetSuffix(f)
223224
of "fa_IR": address_fa_IR.streetSuffix(f)
225+
of "ja_JP": address_ja_JP.streetSuffix(f)
224226
else: address_en_US.streetSuffix(f)
225227

226228
proc zipcode*(f: Faker): string =
@@ -230,9 +232,9 @@ proc zipcode*(f: Faker): string =
230232
echo f.zipcode()
231233

232234
case f.locale
233-
of "ja_JP": address_ja_JP.zipcode(f)
234235
of "en_US": address_en_US.zipcode(f)
235236
of "fa_IR": address_fa_IR.zipcode(f)
237+
of "ja_JP": address_ja_JP.zipcode(f)
236238
else: address_en_US.zipcode(f)
237239

238240
proc zipcodePlus4*(f: Faker): string =
@@ -242,7 +244,7 @@ proc zipcodePlus4*(f: Faker): string =
242244
echo f.zipcodePlus4()
243245

244246
case f.locale
245-
of "ja_JP": address_ja_JP.zipcodePlus4(f)
246247
of "en_US": address_en_US.zipcodePlus4(f)
247248
of "fa_IR": address_fa_IR.zipcodePlus4(f)
249+
of "ja_JP": address_ja_JP.zipcodePlus4(f)
248250
else: address_en_US.zipcodePlus4(f)

src/faker/provider/automotive.nim

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
# ----------------------------------------------- #
55

66
import ../base
7-
import automotive/[automotive_en_US]
7+
import automotive/automotive_en_US
88
export base
99

1010
proc licensePlate*(f: Faker): string =

src/faker/provider/bank.nim

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
# ----------------------------------------------- #
55

66
import ../base
7-
import bank/[bank_en_US]
7+
import bank/bank_en_US
88
export base
99

1010
proc bankCountry*(f: Faker): string =

src/faker/provider/bank/bank_en_US.nim

+1-12
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,10 @@
11
include interfaces
22

3-
import tables
4-
from strutils import join, parseBiggestUInt
5-
from strformat import `&`
6-
from sequtils import mapIt
3+
from std/strformat import `&`
74

85
const
96
countryCode = "GB"
107
bbanFormat = "????#############"
11-
asciiUpperCase = {'A'..'Z'}
12-
13-
let
14-
alpha = block:
15-
var tbl = initTable[char, string]()
16-
for ch in asciiUpperCase:
17-
tbl.add(ch, $(ch.ord mod 55))
18-
tbl
198

209
proc bankCountry*(f: Faker): string =
2110
countryCode

src/faker/provider/company.nim

+2-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44
# ----------------------------------------------- #
55

66
import ../base
7-
import company/[company_en_US, company_ja_JP]
7+
import company/company_en_US
8+
import company/company_ja_JP
89
export base
910

1011
proc bs*(f: Faker): string =

src/faker/provider/currency.nim

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
# ----------------------------------------------- #
55

66
import ../base
7-
import currency/[currency_en_US]
7+
import currency/currency_en_US
88
export base
99

1010
proc currency*(f: Faker): (string, string) =

0 commit comments

Comments
 (0)