Skip to content

Commit

Permalink
Add Faker::Company.department generator (#2737)
Browse files Browse the repository at this point in the history
* Add Faker::Company.department generator

- Companies often include departments (e.g., "Information Technology), so
this adds a few common department names to the Company generator.
- All examples are strings with a few having '/' as well.

Example:
`Faker::Company.department #=> "Information Technology"`:

* Declare `@faker.version next`

* Add Faker::Company.department documentation
  • Loading branch information
acuppy authored Apr 14, 2023
1 parent afa3215 commit e32083a
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 0 deletions.
3 changes: 3 additions & 0 deletions doc/default/company.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ Faker::Company.type #=> "Privately Held"
# Get a random profession
Faker::Company.profession #=> "firefighter"

# Get a random department
Faker::Company.department #=> "Information Technology"

###############################################################
# Generate country specific identifiers
###############################################################
Expand Down
13 changes: 13 additions & 0 deletions lib/faker/default/company.rb
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,19 @@ def profession
fetch('company.profession')
end

##
# Produces a company department.
#
# @return [String]
#
# @example
# Faker::Company.department #=> "Information Technology"
#
# @faker.version next
def department
fetch('company.department')
end

##
# Produces a company spanish organisation number.
#
Expand Down
1 change: 1 addition & 0 deletions lib/locales/en/company.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,4 @@ en:
profession: ["teacher", "actor", "musician", "philosopher", "writer", "doctor", "accountant", "agriculturist", "architect", "economist", "engineer", "interpreter", "attorney at law", "advocate", "librarian", "statistician", "human resources", "firefighter", "judge", "police officer", "astronomer", "biologist", "chemist", "physicist", "programmer", "web developer", "designer", "actress", "air traffic controller", "artist", "attorney", "banker", "bartender", "barber", "bookkeeper", "builder", "businessman", "butcher", "carpenter", "cashier", "chef", "coach", "dentist", "dental hygienist", "developer", "dietician", "editor", "electrician", "factory worker", "farmer", "fisherman", "gardener", "hairdresser", "journalist", "lawyer", "lecturer", "lifeguard", "mechanic", "model", "newsreader", "nurse", "optician", "painter", "pharmacist", "photographer", "pilot", "plumber", "politician", "postman", "receptionist", "scientist", "secretary", "shop assistant", "soldier", "tailor", "taxi driver", "translator", "traffic warden", "travel agent", "veterinary doctor", "waiter", "window cleaner"]
type: ["Public Company", "Educational Institution", "Self-Employed", "Government Agency", "Nonprofit", "Sole Proprietorship", "Privately Held", "Partnership"]
sic_code: ["0111", "0112", "0115", "0116", "0119", "0131", "0132", "0133", "0134", "0139", "0161", "0171", "0172", "0173", "0174", "0175", "0179", "0181", "0182", "0191", "0211", "0212", "0213", "0214", "0219", "0241", "0251", "0252", "0253", "0254", "0259", "0271", "0272", "0273", "0279", "0291", "0711", "0721", "0722", "0723", "0724", "0741", "0742", "0751", "0752", "0761", "0762", "0781", "0782", "0783", "0811", "0831", "0851", "0912", "0913", "0919", "0921", "0971", "1011", "1021", "1031", "1041", "1044", "1061", "1081", "1094", "1099", "1221", "1222", "1231", "1241", "1311", "1321", "1381", "1382", "1389", "1411", "1422", "1423", "1429", "1442", "1446", "1455", "1459", "1474", "1475", "1479", "1481", "1499", "1521", "1522", "1531", "1541", "1542", "1611", "1622", "1623", "1629", "1711", "1721", "1731", "1741", "1742", "1743", "1751", "1752", "1761", "1771", "1781", "1791", "1793", "1794", "1795", "1796", "1799", "2011", "2013", "2015", "2021", "2022", "2023", "2024", "2026", "2032", "2033", "2034", "2035", "2037", "2038", "2041", "2043", "2044", "2045", "2046", "2047", "2048", "2051", "2052", "2053", "2061", "2062", "2063", "2064", "2066", "2067", "2068", "2074", "2075", "2076", "2077", "2079", "2082", "2083", "2084", "2085", "2086", "2087", "2091", "2092", "2095", "2096", "2097", "2098", "2099", "2111", "2121", "2131", "2141", "2211", "2221", "2231", "2241", "2251", "2252", "2253", "2254", "2257", "2258", "2259", "2261", "2262", "2269", "2273", "2281", "2282", "2284", "2295", "2296", "2297", "2298", "2299", "2311", "2321", "2322", "2323", "2325", "2326", "2329", "2331", "2335", "2337", "2339", "2341", "2342", "2353", "2361", "2369", "2371", "2381", "2384", "2385", "2386", "2387", "2389", "2391", "2392", "2393", "2394", "2395", "2396", "2397", "2399", "2411", "2421", "2426", "2429", "2431", "2434", "2435", "2436", "2439", "2441", "2448", "2449", "2451", "2452", "2491", "2493", "2499", "2511", "2512", "2514", "2515", "2517", "2519", "2521", "2522", "2531", "2541", "2542", "2591", "2599", "2611", "2621", "2631", "2652", "2653", "2655", "2656", "2657", "2671", "2672", "2673", "2674", "2675", "2676", "2677", "2678", "2679", "2711", "2721", "2731", "2732", "2741", "2752", "2754", "2759", "2761", "2771", "2782", "2789", "2791", "2796", "2812", "2813", "2816", "2819", "2821", "2822", "2823", "2824", "2833", "2834", "2835", "2836", "2841", "2842", "2843", "2844", "2851", "2861", "2865", "2869", "2873", "2874", "2875", "2879", "2891", "2892", "2893", "2895", "2899", "2911", "2951", "2952", "2992", "2999", "3011", "3021", "3052", "3053", "3061", "3069", "3081", "3082", "3083", "3084", "3085", "3086", "3087", "3088", "3089", "3111", "3131", "3142", "3143", "3144", "3149", "3151", "3161", "3171", "3172", "3199", "3211", "3221", "3229", "3231", "3241", "3251", "3253", "3255", "3259", "3261", "3262", "3263", "3264", "3269", "3271", "3272", "3273", "3274", "3275", "3281", "3291", "3292", "3295", "3296", "3297", "3299", "3312", "3313", "3315", "3316", "3317", "3321", "3322", "3324", "3325", "3331", "3334", "3339", "3341", "3351", "3353", "3354", "3355", "3356", "3357", "3363", "3364", "3365", "3366", "3369", "3398", "3399", "3411", "3412", "3421", "3423", "3425", "3429", "3431", "3432", "3433", "3441", "3442", "3443", "3444", "3446", "3448", "3449", "3451", "3452", "3462", "3463", "3465", "3466", "3469", "3471", "3479", "3482", "3483", "3484", "3489", "3491", "3492", "3493", "3494", "3495", "3496", "3497", "3498", "3499", "3511", "3519", "3523", "3524", "3531", "3532", "3533", "3534", "3535", "3536", "3537", "3541", "3542", "3543", "3544", "3545", "3546", "3547", "3548", "3549", "3552", "3553", "3554", "3555", "3556", "3559", "3561", "3562", "3563", "3564", "3565", "3566", "3567", "3568", "3569", "3571", "3572", "3575", "3577", "3578", "3579", "3581", "3582", "3585", "3586", "3589", "3592", "3593", "3594", "3596", "3599", "3612", "3613", "3621", "3624", "3625", "3629", "3631", "3632", "3633", "3634", "3635", "3639", "3641", "3643", "3644", "3645", "3646", "3647", "3648", "3651", "3652", "3661", "3663", "3669", "3671", "3672", "3674", "3675", "3676", "3677", "3678", "3679", "3691", "3692", "3694", "3695", "3699", "3711", "3713", "3714", "3715", "3716", "3721", "3724", "3728", "3731", "3732", "3743", "3751", "3761", "3764", "3769", "3792", "3795", "3799", "3812", "3821", "3822", "3823", "3824", "3825", "3826", "3827", "3829", "3841", "3842", "3843", "3844", "3845", "3851", "3861", "3873", "3911", "3914", "3915", "3931", "3942", "3944", "3949", "3951", "3952", "3953", "3955", "3961", "3965", "3991", "3993", "3995", "3996", "3999", "4011", "4013", "4111", "4119", "4121", "4131", "4141", "4142", "4151", "4173", "4212", "4213", "4214", "4215", "4221", "4222", "4225", "4226", "4231", "4311", "4412", "4424", "4432", "4449", "4481", "4482", "4489", "4491", "4492", "4493", "4499", "4512", "4513", "4522", "4581", "4612", "4613", "4619", "4724", "4725", "4729", "4731", "4741", "4783", "4785", "4789", "4812", "4813", "4822", "4832", "4833", "4841", "4899", "4911", "4922", "4923", "4924", "4925", "4931", "4932", "4939", "4941", "4952", "4953", "4959", "4961", "4971", "5012", "5013", "5014", "5015", "5021", "5023", "5031", "5032", "5033", "5039", "5043", "5044", "5045", "5046", "5047", "5048", "5049", "5051", "5052", "5063", "5064", "5065", "5072", "5074", "5075", "5078", "5082", "5083", "5084", "5085", "5087", "5088", "5091", "5092", "5093", "5094", "5099", "5111", "5112", "5113", "5122", "5131", "5136", "5137", "5139", "5141", "5142", "5143", "5144", "5145", "5146", "5147", "5148", "5149", "5153", "5154", "5159", "5162", "5169", "5171", "5172", "5181", "5182", "5191", "5192", "5193", "5194", "5198", "5199", "5211", "5231", "5251", "5261", "5271", "5311", "5331", "5399", "5411", "5421", "5431", "5441", "5451", "5461", "5499", "5511", "5521", "5531", "5541", "5551", "5561", "5571", "5599", "5611", "5621", "5632", "5641", "5651", "5661", "5699", "5712", "5713", "5714", "5719", "5722", "5731", "5734", "5735", "5736", "5812", "5813", "5912", "5921", "5932", "5941", "5942", "5943", "5944", "5945", "5946", "5947", "5948", "5949", "5961", "5962", "5963", "5983", "5984", "5989", "5992", "5993", "5994", "5995", "5999", "6011", "6019", "6021", "6022", "6029", "6035", "6036", "6061", "6062", "6081", "6082", "6091", "6099", "6111", "6141", "6153", "6159", "6162", "6163", "6211", "6221", "6231", "6282", "6289", "6311", "6321", "6324", "6331", "6351", "6361", "6371", "6399", "6411", "6512", "6513", "6514", "6515", "6517", "6519", "6531", "6541", "6552", "6553", "6712", "6719", "6722", "6726", "6732", "6733", "6792", "6794", "6798", "6799", "7011", "7021", "7032", "7033", "7041", "7211", "7212", "7213", "7215", "7216", "7217", "7218", "7219", "7221", "7231", "7241", "7251", "7261", "7291", "7299", "7311", "7312", "7313", "7319", "7322", "7323", "7331", "7334", "7335", "7336", "7338", "7342", "7349", "7352", "7353", "7359", "7361", "7363", "7371", "7372", "7373", "7374", "7375", "7376", "7377", "7378", "7379", "7381", "7382", "7383", "7384", "7389", "7513", "7514", "7515", "7519", "7521", "7532", "7533", "7534", "7536", "7537", "7538", "7539", "7542", "7549", "7622", "7623", "7629", "7631", "7641", "7692", "7694", "7699", "7812", "7819", "7822", "7829", "7832", "7833", "7841", "7911", "7922", "7929", "7933", "7941", "7948", "7991", "7992", "7993", "7996", "7997", "7999", "8011", "8021", "8031", "8041", "8042", "8043", "8049", "8051", "8052", "8059", "8062", "8063", "8069", "8071", "8072", "8082", "8092", "8093", "8099", "8111", "8211", "8221", "8222", "8231", "8243", "8244", "8249", "8299", "8322", "8331", "8351", "8361", "8399", "8412", "8422", "8611", "8621", "8631", "8641", "8651", "8661", "8699", "8711", "8712", "8713", "8721", "8731", "8732", "8733", "8734", "8741", "8742", "8743", "8744", "8748", "8811", "8999", "9111", "9121", "9131", "9199", "9211", "9221", "9222", "9223", "9224", "9229", "9311", "9411", "9431", "9441", "9451", "9511", "9512", "9531", "9532", "9611", "9621", "9631", "9641", "9651", "9661", "9711", "9721", "9999"]
department: ["Asset Management", "Board of Directors", "Business Development", "Corporate Communications", "Creative Services", "Customer Service", "Information Technology", "Engineering", "Finance / Accounting", "General Management", "Human Resources", "Investor Relations", "Legal", "Marketing", "Operations", "Product Management", "Production", "Project Management", "Purchasing / Sourcing", "Quality Assurance", "Risk Management", "Sales", "Strategic Initiatives", "Information Technology"]
4 changes: 4 additions & 0 deletions test/faker/default/test_faker_company.rb
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,10 @@ def test_profession
assert_match(/[a-z ]+\.?/, @tester.profession)
end

def test_department
assert_match(/\w+/, @tester.department)
end

def test_polish_taxpayer_identification_number
number = @tester.polish_taxpayer_identification_number
control_sum = 0
Expand Down

0 comments on commit e32083a

Please sign in to comment.