faker-indian 0.1.0 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +25 -1
- data/README.md +216 -55
- data/lib/faker/indian/address.rb +61 -15
- data/lib/faker/indian/company.rb +41 -0
- data/lib/faker/indian/data/address.yml +275 -22
- data/lib/faker/indian/data/company.yml +28 -0
- data/lib/faker/indian/data/food.yml +18 -0
- data/lib/faker/indian/data/name.yml +13 -0
- data/lib/faker/indian/data/phone.yml +17 -0
- data/lib/faker/indian/data/travel.yml +23 -0
- data/lib/faker/indian/food.rb +26 -6
- data/lib/faker/indian/identity.rb +39 -5
- data/lib/faker/indian/languages.rb +2 -2
- data/lib/faker/indian/name.rb +17 -5
- data/lib/faker/indian/payment.rb +24 -6
- data/lib/faker/indian/phone.rb +23 -2
- data/lib/faker/indian/profile.rb +27 -0
- data/lib/faker/indian/travel.rb +34 -0
- data/lib/faker/indian/vehicle.rb +18 -4
- data/lib/faker/indian/version.rb +1 -1
- data/lib/faker/indian.rb +4 -1
- metadata +9 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: ee4f61cd669d6888e72f22186c89e0e5059ff6a9c2e36021d78306be5741d6ee
|
|
4
|
+
data.tar.gz: '0699f78e34c57d567426daea6f253f3feaf6ab3d8602d8d1c2015336077e9687'
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: ccab041cad1ad3e9a7cc9dd18cdef831264b7a0ea84b544505d736c69c277495ea3ac81ba5c19f0d24f42b70eae6fe3b2d9831a7e32b336c5f46153ae2ab0201
|
|
7
|
+
data.tar.gz: 7c1fd92568fb6e6d22732c890ea1253bfd81305776eadf850275ca582ec1c202420c3d6bb78f2674e8be7026718b7a09d1cb949f51fac1e741d35a9b1a80f429
|
data/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,29 @@
|
|
|
1
1
|
## [Unreleased]
|
|
2
2
|
|
|
3
|
+
## [0.2.0] - 2026-07-01
|
|
4
|
+
|
|
5
|
+
### Added
|
|
6
|
+
|
|
7
|
+
- `Faker::Indian::Company` with `name`, `type`, and `cin`
|
|
8
|
+
- `Faker::Indian::Travel` with `pnr`, `train_name`, and `station`
|
|
9
|
+
- `Faker::Indian::Profile.generate` and `Faker::Indian.profile` for one-shot seed data
|
|
10
|
+
- `phone.yml` for telecom operator and STD code data
|
|
11
|
+
- `company.yml` and `travel.yml` data files
|
|
12
|
+
|
|
13
|
+
### Changed
|
|
14
|
+
|
|
15
|
+
- **Address** — fixed YAML nesting for 40+ cities; added `district`, `landmark`, `line1`, `state_code`, and `state:` filtering on location methods
|
|
16
|
+
- **Identity** — added `driving_license`, `aadhaar_masked`, and `gstin(pan:)`
|
|
17
|
+
- **Payment** — added `demat_account`, `bank_details`, and `upi_id(name:)`
|
|
18
|
+
- **Phone** — added `operator`, `landline`, `whatsapp_number`, and `mobile_number(formatted:)`
|
|
19
|
+
- **Vehicle** — added `registration_number(state:)`, public `rto_code`, and state name/code resolution
|
|
20
|
+
- **Name** — added `middle_name`, `suffix`, and `full_name(language:)`
|
|
21
|
+
- **Food** — added `meal`, `beverage`, `combo`, and `spice_level`
|
|
22
|
+
- **address.yml** — added `state_codes`, `districts`, and `landmarks`
|
|
23
|
+
|
|
3
24
|
## [0.1.0] - 2026-05-14
|
|
4
25
|
|
|
5
|
-
|
|
26
|
+
### Added
|
|
27
|
+
|
|
28
|
+
- Initial release with `Name`, `Identity`, `Payment`, `Vehicle`, `Address`, `Phone`, `Food`, and `Languages` generators
|
|
29
|
+
- YAML-backed data loading via `Faker::Indian::Data`
|
data/README.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
India-first fake data generator for Ruby apps.
|
|
4
4
|
|
|
5
|
-
`faker-indian` helps you generate realistic fake Indian data
|
|
5
|
+
`faker-indian` helps you generate realistic fake Indian data — names, identities, payments, addresses, vehicles, regional-language names, food, companies, railway PNRs, and more.
|
|
6
6
|
|
|
7
7
|
Perfect for:
|
|
8
8
|
|
|
@@ -17,13 +17,16 @@ Perfect for:
|
|
|
17
17
|
## Features
|
|
18
18
|
|
|
19
19
|
- 🇮🇳 Indian-first fake data generation
|
|
20
|
-
- 👤 Indian names & identities
|
|
20
|
+
- 👤 Indian names & identities (PAN, Aadhaar, GSTIN, driving license, and more)
|
|
21
21
|
- 🌐 Regional language names (Hindi, Tamil, Telugu, and more)
|
|
22
|
-
- 💳 Payment & banking details
|
|
22
|
+
- 💳 Payment & banking details (UPI, IFSC, demat account)
|
|
23
|
+
- 🏢 Company names & CIN numbers
|
|
24
|
+
- 🚂 Railway PNR, train names, and stations
|
|
23
25
|
- 🚗 Vehicle registration numbers
|
|
24
|
-
- 🏠 Indian addresses
|
|
25
|
-
- 📞 Mobile
|
|
26
|
+
- 🏠 Indian addresses across 70+ cities
|
|
27
|
+
- 📞 Mobile, landline, and telecom operators
|
|
26
28
|
- 🍛 Indian dishes, cuisines, and restaurants
|
|
29
|
+
- 📋 One-shot `Faker::Indian.profile` for seed data
|
|
27
30
|
- 📁 YAML-backed data — easy to extend without changing logic
|
|
28
31
|
- ⚡ Lightweight and easy to use
|
|
29
32
|
|
|
@@ -34,7 +37,7 @@ Perfect for:
|
|
|
34
37
|
Add this line to your application's Gemfile:
|
|
35
38
|
|
|
36
39
|
```ruby
|
|
37
|
-
gem
|
|
40
|
+
gem "faker-indian"
|
|
38
41
|
```
|
|
39
42
|
|
|
40
43
|
Then execute:
|
|
@@ -62,20 +65,17 @@ Faker::Indian::Name.full_name
|
|
|
62
65
|
Faker::Indian::Identity.pan
|
|
63
66
|
# => "ABCDE1234F"
|
|
64
67
|
|
|
65
|
-
Faker::Indian::Identity.aadhaar
|
|
66
|
-
# => "4567 8912 3456"
|
|
67
|
-
|
|
68
|
-
Faker::Indian::Identity.aadhaar
|
|
69
|
-
# => "4567 8912 3456"
|
|
70
|
-
|
|
71
68
|
Faker::Indian::Payment.upi_id
|
|
72
|
-
# => "
|
|
73
|
-
|
|
69
|
+
# => "rahul42@paytm"
|
|
70
|
+
|
|
74
71
|
Faker::Indian::Languages.full_name(language: :tamil)
|
|
75
72
|
# => "Karthik Iyer"
|
|
76
73
|
|
|
77
|
-
Faker::Indian::
|
|
78
|
-
# => "
|
|
74
|
+
Faker::Indian::Company.cin
|
|
75
|
+
# => "U72200MH2010PTC123456"
|
|
76
|
+
|
|
77
|
+
Faker::Indian.profile
|
|
78
|
+
# => { name: "...", phone: "...", pan: "...", ... }
|
|
79
79
|
```
|
|
80
80
|
|
|
81
81
|
---
|
|
@@ -93,11 +93,20 @@ Faker::Indian::Name.first_name
|
|
|
93
93
|
Faker::Indian::Name.last_name
|
|
94
94
|
# => "Patel"
|
|
95
95
|
|
|
96
|
+
Faker::Indian::Name.middle_name
|
|
97
|
+
# => "Kumar"
|
|
98
|
+
|
|
96
99
|
Faker::Indian::Name.full_name
|
|
97
100
|
# => "Rohan Verma"
|
|
98
101
|
|
|
102
|
+
Faker::Indian::Name.full_name(language: :hindi)
|
|
103
|
+
# => "Ananya Sharma"
|
|
104
|
+
|
|
99
105
|
Faker::Indian::Name.prefix
|
|
100
106
|
# => "Dr."
|
|
107
|
+
|
|
108
|
+
Faker::Indian::Name.suffix
|
|
109
|
+
# => "Ji"
|
|
101
110
|
```
|
|
102
111
|
|
|
103
112
|
---
|
|
@@ -146,14 +155,26 @@ Faker::Indian::Identity.pan
|
|
|
146
155
|
Faker::Indian::Identity.aadhaar
|
|
147
156
|
# => "1234 5678 9012"
|
|
148
157
|
|
|
158
|
+
Faker::Indian::Identity.aadhaar_masked
|
|
159
|
+
# => "XXXX XXXX 4567"
|
|
160
|
+
|
|
149
161
|
Faker::Indian::Identity.gstin
|
|
150
162
|
# => "27ABCDE1234F1Z5"
|
|
151
163
|
|
|
164
|
+
Faker::Indian::Identity.gstin(pan: "ABCDE1234F")
|
|
165
|
+
# => "27ABCDE1234F1Z5" # embeds the given PAN
|
|
166
|
+
|
|
152
167
|
Faker::Indian::Identity.voter_id
|
|
153
168
|
# => "ABC1234567"
|
|
154
169
|
|
|
155
170
|
Faker::Indian::Identity.passport
|
|
156
171
|
# => "N1234567"
|
|
172
|
+
|
|
173
|
+
Faker::Indian::Identity.driving_license
|
|
174
|
+
# => "MH-12-2018-4567890"
|
|
175
|
+
|
|
176
|
+
Faker::Indian::Identity.driving_license(state: "Karnataka")
|
|
177
|
+
# => "KA-04-2022-1234567"
|
|
157
178
|
```
|
|
158
179
|
|
|
159
180
|
---
|
|
@@ -166,6 +187,9 @@ Generate fake Indian banking and payment data.
|
|
|
166
187
|
Faker::Indian::Payment.upi_id
|
|
167
188
|
# => "amit@oksbi"
|
|
168
189
|
|
|
190
|
+
Faker::Indian::Payment.upi_id(name: "Rahul Sharma")
|
|
191
|
+
# => "rahulsharma42@paytm"
|
|
192
|
+
|
|
169
193
|
Faker::Indian::Payment.ifsc
|
|
170
194
|
# => "HDFC0001234"
|
|
171
195
|
|
|
@@ -174,12 +198,52 @@ Faker::Indian::Payment.bank_name
|
|
|
174
198
|
|
|
175
199
|
Faker::Indian::Payment.account_number
|
|
176
200
|
# => "123456789012"
|
|
201
|
+
|
|
202
|
+
Faker::Indian::Payment.demat_account
|
|
203
|
+
# => "120816001234567"
|
|
204
|
+
|
|
205
|
+
Faker::Indian::Payment.bank_details
|
|
206
|
+
# => { bank_name: "HDFC Bank", ifsc: "HDFC0001234", account_number: "123456789012" }
|
|
177
207
|
```
|
|
178
208
|
|
|
179
209
|
Aliases: `upi` (for `upi_id`), `ifsc_code` (for `ifsc`).
|
|
180
210
|
|
|
181
211
|
---
|
|
182
212
|
|
|
213
|
+
### Company
|
|
214
|
+
|
|
215
|
+
Generate Indian company names and CIN numbers.
|
|
216
|
+
|
|
217
|
+
```ruby
|
|
218
|
+
Faker::Indian::Company.name
|
|
219
|
+
# => "Bharat Tech Solutions Pvt Ltd"
|
|
220
|
+
|
|
221
|
+
Faker::Indian::Company.type
|
|
222
|
+
# => "Private Limited"
|
|
223
|
+
|
|
224
|
+
Faker::Indian::Company.cin
|
|
225
|
+
# => "U72200MH2010PTC123456"
|
|
226
|
+
```
|
|
227
|
+
|
|
228
|
+
---
|
|
229
|
+
|
|
230
|
+
### Travel
|
|
231
|
+
|
|
232
|
+
Generate railway-related fake data.
|
|
233
|
+
|
|
234
|
+
```ruby
|
|
235
|
+
Faker::Indian::Travel.pnr
|
|
236
|
+
# => "4829173056"
|
|
237
|
+
|
|
238
|
+
Faker::Indian::Travel.train_name
|
|
239
|
+
# => "Rajdhani Express"
|
|
240
|
+
|
|
241
|
+
Faker::Indian::Travel.station
|
|
242
|
+
# => "Mumbai CST"
|
|
243
|
+
```
|
|
244
|
+
|
|
245
|
+
---
|
|
246
|
+
|
|
183
247
|
### Vehicle
|
|
184
248
|
|
|
185
249
|
Generate Indian vehicle registration numbers.
|
|
@@ -188,39 +252,77 @@ Generate Indian vehicle registration numbers.
|
|
|
188
252
|
Faker::Indian::Vehicle.registration_number
|
|
189
253
|
# => "KA01MJ4587"
|
|
190
254
|
|
|
255
|
+
Faker::Indian::Vehicle.registration_number(state: "MH")
|
|
256
|
+
# => "MH14DT4321"
|
|
257
|
+
|
|
191
258
|
Faker::Indian::Vehicle.state_code
|
|
192
259
|
# => "MH"
|
|
260
|
+
|
|
261
|
+
Faker::Indian::Vehicle.rto_code
|
|
262
|
+
# => "12"
|
|
193
263
|
```
|
|
194
264
|
|
|
195
265
|
---
|
|
196
266
|
|
|
197
267
|
### Address
|
|
198
268
|
|
|
199
|
-
Generate realistic Indian addresses.
|
|
269
|
+
Generate realistic Indian addresses across 70+ cities.
|
|
270
|
+
|
|
271
|
+
Pass `state:` as a state name (`"Maharashtra"`) or code (`"MH"`) to filter location methods.
|
|
200
272
|
|
|
201
273
|
```ruby
|
|
202
274
|
Faker::Indian::Address.city
|
|
203
275
|
# => "Pune"
|
|
204
276
|
|
|
277
|
+
Faker::Indian::Address.city(state: "Karnataka")
|
|
278
|
+
# => "Bengaluru"
|
|
279
|
+
|
|
205
280
|
Faker::Indian::Address.state
|
|
206
281
|
# => "Maharashtra"
|
|
207
282
|
|
|
208
283
|
Faker::Indian::Address.pincode
|
|
209
284
|
# => "411001"
|
|
210
285
|
|
|
286
|
+
Faker::Indian::Address.state_code
|
|
287
|
+
# => "MH"
|
|
288
|
+
|
|
289
|
+
Faker::Indian::Address.district
|
|
290
|
+
# => "Koramangala"
|
|
291
|
+
|
|
292
|
+
Faker::Indian::Address.landmark
|
|
293
|
+
# => "Near Metro Station"
|
|
294
|
+
|
|
295
|
+
Faker::Indian::Address.line1
|
|
296
|
+
# => "221 MG Road"
|
|
297
|
+
|
|
211
298
|
Faker::Indian::Address.full_address
|
|
212
|
-
# => "221 MG Road, Pune, Maharashtra - 411001"
|
|
299
|
+
# => "221 MG Road, Koramangala, Pune, Maharashtra - 411001"
|
|
300
|
+
|
|
301
|
+
Faker::Indian::Address.full_address(state: "Gujarat")
|
|
302
|
+
# => "45 Ring Road, Satellite, Ahmedabad, Gujarat - 380001"
|
|
213
303
|
```
|
|
214
304
|
|
|
215
305
|
---
|
|
216
306
|
|
|
217
307
|
### Phone
|
|
218
308
|
|
|
219
|
-
Generate Indian
|
|
309
|
+
Generate Indian phone numbers and telecom data.
|
|
220
310
|
|
|
221
311
|
```ruby
|
|
222
312
|
Faker::Indian::Phone.mobile_number
|
|
223
313
|
# => "+91 9876543210"
|
|
314
|
+
|
|
315
|
+
Faker::Indian::Phone.mobile_number(formatted: false)
|
|
316
|
+
# => "9876543210"
|
|
317
|
+
|
|
318
|
+
Faker::Indian::Phone.landline
|
|
319
|
+
# => "022-1234567"
|
|
320
|
+
|
|
321
|
+
Faker::Indian::Phone.operator
|
|
322
|
+
# => "Jio"
|
|
323
|
+
|
|
324
|
+
Faker::Indian::Phone.whatsapp_number
|
|
325
|
+
# => "+91 9123456789"
|
|
224
326
|
```
|
|
225
327
|
|
|
226
328
|
---
|
|
@@ -244,6 +346,43 @@ Faker::Indian::Food.street_food
|
|
|
244
346
|
|
|
245
347
|
Faker::Indian::Food.sweet
|
|
246
348
|
# => "Gulab Jamun"
|
|
349
|
+
|
|
350
|
+
Faker::Indian::Food.meal
|
|
351
|
+
# => "lunch"
|
|
352
|
+
|
|
353
|
+
Faker::Indian::Food.beverage
|
|
354
|
+
# => "Filter Coffee"
|
|
355
|
+
|
|
356
|
+
Faker::Indian::Food.combo
|
|
357
|
+
# => "Masala Dosa with Filter Coffee"
|
|
358
|
+
|
|
359
|
+
Faker::Indian::Food.spice_level
|
|
360
|
+
# => "medium"
|
|
361
|
+
```
|
|
362
|
+
|
|
363
|
+
---
|
|
364
|
+
|
|
365
|
+
### Profile
|
|
366
|
+
|
|
367
|
+
Generate a complete Indian user profile in one call — ideal for seeds and demos.
|
|
368
|
+
|
|
369
|
+
```ruby
|
|
370
|
+
Faker::Indian.profile
|
|
371
|
+
# or
|
|
372
|
+
Faker::Indian::Profile.generate
|
|
373
|
+
|
|
374
|
+
# =>
|
|
375
|
+
# {
|
|
376
|
+
# name: "Sneha Kulkarni",
|
|
377
|
+
# phone: "+91 9123456789",
|
|
378
|
+
# pan: "BQWPE1234K",
|
|
379
|
+
# aadhaar: "4567 1234 8910",
|
|
380
|
+
# gstin: "27BQWPE1234K1Z5",
|
|
381
|
+
# upi: "sneha@okicici",
|
|
382
|
+
# vehicle: "MH14DT4321",
|
|
383
|
+
# address: "221 FC Road, Andheri, Pune, Maharashtra - 411001",
|
|
384
|
+
# dish: "Masala Dosa"
|
|
385
|
+
# }
|
|
247
386
|
```
|
|
248
387
|
|
|
249
388
|
---
|
|
@@ -252,17 +391,18 @@ Faker::Indian::Food.sweet
|
|
|
252
391
|
|
|
253
392
|
Static data lives in YAML files under `lib/faker/indian/data/` and is loaded by `Faker::Indian::Data`:
|
|
254
393
|
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
|
258
|
-
| `name.yml` | `Name` |
|
|
394
|
+
| File | Used by |
|
|
395
|
+
|------|---------|
|
|
396
|
+
| `name.yml` | `Name` |
|
|
259
397
|
| `languages.yml` | `Languages` |
|
|
260
|
-
| `identity.yml`
|
|
261
|
-
| `payment.yml`
|
|
262
|
-
| `
|
|
263
|
-
| `
|
|
264
|
-
| `
|
|
265
|
-
|
|
398
|
+
| `identity.yml` | `Identity` |
|
|
399
|
+
| `payment.yml` | `Payment` |
|
|
400
|
+
| `company.yml` | `Company` |
|
|
401
|
+
| `travel.yml` | `Travel` |
|
|
402
|
+
| `vehicle.yml` | `Vehicle` |
|
|
403
|
+
| `address.yml` | `Address` |
|
|
404
|
+
| `phone.yml` | `Phone` |
|
|
405
|
+
| `food.yml` | `Food` |
|
|
266
406
|
|
|
267
407
|
To add entries, edit the relevant YAML file. To add a new generator, create a new YAML file and a matching Ruby class that calls `Data.load(:your_file)`.
|
|
268
408
|
|
|
@@ -274,11 +414,14 @@ To add entries, edit the relevant YAML file. To add a new generator, create a ne
|
|
|
274
414
|
|
|
275
415
|
```ruby
|
|
276
416
|
10.times do
|
|
417
|
+
profile = Faker::Indian.profile
|
|
418
|
+
|
|
277
419
|
User.create!(
|
|
278
|
-
name:
|
|
279
|
-
phone:
|
|
280
|
-
pan:
|
|
281
|
-
upi:
|
|
420
|
+
name: profile[:name],
|
|
421
|
+
phone: profile[:phone],
|
|
422
|
+
pan: profile[:pan],
|
|
423
|
+
upi: profile[:upi],
|
|
424
|
+
address: profile[:address]
|
|
282
425
|
)
|
|
283
426
|
end
|
|
284
427
|
```
|
|
@@ -297,6 +440,11 @@ FactoryBot.define do
|
|
|
297
440
|
name { Faker::Indian::Food.restaurant_name }
|
|
298
441
|
cuisine { Faker::Indian::Food.cuisine }
|
|
299
442
|
end
|
|
443
|
+
|
|
444
|
+
factory :company do
|
|
445
|
+
name { Faker::Indian::Company.name }
|
|
446
|
+
cin { Faker::Indian::Company.cin }
|
|
447
|
+
end
|
|
300
448
|
end
|
|
301
449
|
```
|
|
302
450
|
|
|
@@ -319,12 +467,15 @@ Generated values are **not real identities** and must not be used for fraud, imp
|
|
|
319
467
|
|
|
320
468
|
Planned generators:
|
|
321
469
|
|
|
322
|
-
- Driving License Number
|
|
323
|
-
- CIN Number
|
|
324
|
-
- Demat Account
|
|
325
|
-
- Regional language names
|
|
326
|
-
- Telecom operators
|
|
327
|
-
- Railway PNR
|
|
470
|
+
- [ ] Driving License Number *(format implemented — checksum validation pending)*
|
|
471
|
+
- [x] CIN Number
|
|
472
|
+
- [x] Demat Account
|
|
473
|
+
- [x] Regional language names
|
|
474
|
+
- [x] Telecom operators
|
|
475
|
+
- [x] Railway PNR
|
|
476
|
+
- [ ] Indian company names *(basic generator added — expand data)*
|
|
477
|
+
- [ ] Commerce (HSN codes, invoice numbers)
|
|
478
|
+
- [ ] Education (schools, universities)
|
|
328
479
|
|
|
329
480
|
---
|
|
330
481
|
|
|
@@ -339,19 +490,19 @@ Bug reports and pull requests are welcome.
|
|
|
339
490
|
git checkout -b feature/my-feature
|
|
340
491
|
```
|
|
341
492
|
|
|
342
|
-
|
|
493
|
+
3. Commit changes
|
|
343
494
|
|
|
344
495
|
```bash
|
|
345
496
|
git commit -m "Add new generator"
|
|
346
497
|
```
|
|
347
498
|
|
|
348
|
-
|
|
499
|
+
4. Push to branch
|
|
349
500
|
|
|
350
501
|
```bash
|
|
351
502
|
git push origin feature/my-feature
|
|
352
503
|
```
|
|
353
504
|
|
|
354
|
-
|
|
505
|
+
5. Open a Pull Request
|
|
355
506
|
|
|
356
507
|
When adding generators, include YAML data, Ruby class, and RSpec tests.
|
|
357
508
|
|
|
@@ -382,18 +533,28 @@ Released under the MIT License.
|
|
|
382
533
|
## Example Output
|
|
383
534
|
|
|
384
535
|
```ruby
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
536
|
+
profile = Faker::Indian.profile
|
|
537
|
+
|
|
538
|
+
# {
|
|
539
|
+
# name: "Sneha Kulkarni",
|
|
540
|
+
# phone: "+91 9123456789",
|
|
541
|
+
# pan: "BQWPE1234K",
|
|
542
|
+
# aadhaar: "4567 1234 8910",
|
|
543
|
+
# gstin: "27BQWPE1234K1Z5",
|
|
544
|
+
# upi: "sneha@okicici",
|
|
545
|
+
# vehicle: "MH14DT4321",
|
|
546
|
+
# address: "221 FC Road, Andheri, Pune, Maharashtra - 411001",
|
|
547
|
+
# dish: "Masala Dosa"
|
|
548
|
+
# }
|
|
549
|
+
|
|
550
|
+
Faker::Indian::Languages.full_name(language: :tamil)
|
|
551
|
+
# => "Arun Iyer"
|
|
552
|
+
|
|
553
|
+
Faker::Indian::Travel.pnr
|
|
554
|
+
# => "4829173056"
|
|
555
|
+
|
|
556
|
+
Faker::Indian::Company.name
|
|
557
|
+
# => "Hindustan Logistics LLP"
|
|
397
558
|
```
|
|
398
559
|
|
|
399
560
|
---
|
|
@@ -402,4 +563,4 @@ Released under the MIT License.
|
|
|
402
563
|
|
|
403
564
|
Most fake-data libraries are heavily US-centric.
|
|
404
565
|
|
|
405
|
-
`faker-indian` focuses specifically on Indian systems, formats, and identifiers, making it easier to build and test applications for the Indian market.
|
|
566
|
+
`faker-indian` focuses specifically on Indian systems, formats, and identifiers, making it easier to build and test applications for the Indian market.
|
data/lib/faker/indian/address.rb
CHANGED
|
@@ -5,27 +5,46 @@ require "faker"
|
|
|
5
5
|
module Faker
|
|
6
6
|
module Indian
|
|
7
7
|
class Address
|
|
8
|
-
|
|
8
|
+
data = Data.load(:address)
|
|
9
9
|
|
|
10
|
-
LOCATIONS =
|
|
11
|
-
STREETS =
|
|
10
|
+
LOCATIONS = data.fetch(:locations).freeze
|
|
11
|
+
STREETS = data.fetch(:streets).freeze
|
|
12
|
+
STATE_CODES = data.fetch(:state_codes).freeze
|
|
13
|
+
DISTRICTS = data.fetch(:districts).freeze
|
|
14
|
+
LANDMARKS = data.fetch(:landmarks).freeze
|
|
12
15
|
|
|
13
16
|
class << self
|
|
14
|
-
def city
|
|
15
|
-
sample_location[:city]
|
|
17
|
+
def city(state: nil)
|
|
18
|
+
sample_location(state: state)[:city]
|
|
16
19
|
end
|
|
17
20
|
|
|
18
|
-
def state
|
|
19
|
-
sample_location[:state]
|
|
21
|
+
def state(state: nil)
|
|
22
|
+
sample_location(state: state)[:state]
|
|
20
23
|
end
|
|
21
24
|
|
|
22
|
-
def pincode
|
|
23
|
-
sample_location[:pincode]
|
|
25
|
+
def pincode(state: nil)
|
|
26
|
+
sample_location(state: state)[:pincode]
|
|
24
27
|
end
|
|
25
28
|
|
|
26
|
-
def
|
|
27
|
-
|
|
28
|
-
|
|
29
|
+
def state_code(state: nil)
|
|
30
|
+
sample_location(state: state)[:state_code]
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
def district
|
|
34
|
+
DISTRICTS.sample(random: random)
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
def landmark
|
|
38
|
+
LANDMARKS.sample(random: random)
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
def line1
|
|
42
|
+
"#{random_street_number} #{random_street}"
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
def full_address(state: nil)
|
|
46
|
+
loc = sample_location(state: state)
|
|
47
|
+
"#{line1}, #{district}, #{loc[:city]}, #{loc[:state]} - #{loc[:pincode]}"
|
|
29
48
|
end
|
|
30
49
|
|
|
31
50
|
private
|
|
@@ -34,9 +53,36 @@ module Faker
|
|
|
34
53
|
Faker::Config.random
|
|
35
54
|
end
|
|
36
55
|
|
|
37
|
-
def sample_location
|
|
38
|
-
city_name, details =
|
|
39
|
-
|
|
56
|
+
def sample_location(state: nil)
|
|
57
|
+
city_name, details = filtered_locations(state).to_a.sample(random: random)
|
|
58
|
+
state_name = details[:state]
|
|
59
|
+
{
|
|
60
|
+
city: city_name,
|
|
61
|
+
state: state_name,
|
|
62
|
+
pincode: details[:pincode],
|
|
63
|
+
state_code: lookup_state_code(state_name)
|
|
64
|
+
}
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
def filtered_locations(state)
|
|
68
|
+
return LOCATIONS if state.nil?
|
|
69
|
+
|
|
70
|
+
matches = LOCATIONS.select { |_, details| state_match?(details[:state], state) }
|
|
71
|
+
raise Error, "unknown state: #{state}" if matches.empty?
|
|
72
|
+
|
|
73
|
+
matches
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
def state_match?(state_name, filter)
|
|
77
|
+
normalized = filter.to_s.downcase.tr("_", " ")
|
|
78
|
+
return true if state_name.to_s.downcase == normalized
|
|
79
|
+
|
|
80
|
+
code = lookup_state_code(state_name)
|
|
81
|
+
code&.casecmp?(filter.to_s)
|
|
82
|
+
end
|
|
83
|
+
|
|
84
|
+
def lookup_state_code(state_name)
|
|
85
|
+
STATE_CODES[state_name.to_sym] || STATE_CODES[state_name.to_s]
|
|
40
86
|
end
|
|
41
87
|
|
|
42
88
|
def random_street
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "faker"
|
|
4
|
+
|
|
5
|
+
module Faker
|
|
6
|
+
module Indian
|
|
7
|
+
class Company
|
|
8
|
+
data = Data.load(:company)
|
|
9
|
+
|
|
10
|
+
PREFIXES = data.fetch(:prefixes).freeze
|
|
11
|
+
CORES = data.fetch(:cores).freeze
|
|
12
|
+
SUFFIXES = data.fetch(:suffixes).freeze
|
|
13
|
+
TYPES = data.fetch(:types).freeze
|
|
14
|
+
|
|
15
|
+
class << self
|
|
16
|
+
def name
|
|
17
|
+
"#{PREFIXES.sample(random: random)} #{CORES.sample(random: random)} #{SUFFIXES.sample(random: random)}"
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
def type
|
|
21
|
+
TYPES.sample(random: random)
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
def cin
|
|
25
|
+
state = Address::STATE_CODES.values.sample(random: random)
|
|
26
|
+
year = random.rand(2000..2024)
|
|
27
|
+
industry = format("%05d", random.rand(10_000..99_999))
|
|
28
|
+
serial = format("%06d", random.rand(100_000..999_999))
|
|
29
|
+
|
|
30
|
+
"U#{industry}#{state}#{year}PTC#{serial}"
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
private
|
|
34
|
+
|
|
35
|
+
def random
|
|
36
|
+
Faker::Config.random
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
end
|