From 98f6d2048b616a825780fb1ab89275e82afbe205 Mon Sep 17 00:00:00 2001 From: Bruno Martins <25222614+bruno-b-martins@users.noreply.github.com> Date: Fri, 15 Feb 2019 20:48:21 +0000 Subject: [PATCH] Add sic_code to company #355 (#1540) * Add sic_code to company * Update documentation --- doc/unreleased/default/company.md | 3 +++ lib/faker/default/company.rb | 4 ++++ lib/locales/en/company.yml | 1 + test/faker/default/test_faker_company.rb | 4 ++++ 4 files changed, 12 insertions(+) diff --git a/doc/unreleased/default/company.md b/doc/unreleased/default/company.md index 674e1703a8..e8c1435057 100644 --- a/doc/unreleased/default/company.md +++ b/doc/unreleased/default/company.md @@ -62,4 +62,7 @@ Faker::Company.brazilian_company_number #=> "18553414000618" # Generate a formatted Brazilian company number (CNPJ) Faker::Company.brazilian_company_number(formatted: true) #=> "00.000.000/0000-00" + +# Generate a USA Standard Industrial Classification code (SIC) +Faker::Company.sic_code #=> "0851" ``` diff --git a/lib/faker/default/company.rb b/lib/faker/default/company.rb index 104cc6c7d0..1229d189cd 100644 --- a/lib/faker/default/company.rb +++ b/lib/faker/default/company.rb @@ -168,6 +168,10 @@ def brazilian_company_number(formatted: false) formatted ? format('%s.%s.%s/%s-%s', *number.scan(/(\d{2})(\d{3})(\d{3})(\d{4})(\d{2})/).flatten) : number end + def sic_code + fetch('company.sic_code') + end + private # Mod11 functionality from https://github.com/badmanski/mod11/blob/master/lib/mod11.rb diff --git a/lib/locales/en/company.yml b/lib/locales/en/company.yml index 5ac58fbbf5..860ae2b88d 100644 --- a/lib/locales/en/company.yml +++ b/lib/locales/en/company.yml @@ -19,3 +19,4 @@ en: industry: ["Defense & Space", "Computer Hardware", "Computer Software", "Computer Networking", "Internet", "Semiconductors", "Telecommunications", "Law Practice", "Legal Services", "Management Consulting", "Biotechnology", "Medical Practice", "Hospital & Health Care", "Pharmaceuticals", "Veterinary", "Medical Devices", "Cosmetics", "Apparel & Fashion", "Sporting Goods", "Tobacco", "Supermarkets", "Food Production", "Consumer Electronics", "Consumer Goods", "Furniture", "Retail", "Entertainment", "Gambling & Casinos", "Leisure, Travel & Tourism", "Hospitality", "Restaurants", "Sports", "Food & Beverages", "Motion Pictures and Film", "Broadcast Media", "Museums and Institutions", "Fine Art", "Performing Arts", "Recreational Facilities and Services", "Banking", "Insurance", "Financial Services", "Real Estate", "Investment Banking", "Investment Management", "Accounting", "Construction", "Building Materials", "Architecture & Planning", "Civil Engineering", "Aviation & Aerospace", "Automotive", "Chemicals", "Machinery", "Mining & Metals", "Oil & Energy", "Shipbuilding", "Utilities", "Textiles", "Paper & Forest Products", "Railroad Manufacture", "Farming", "Ranching", "Dairy", "Fishery", "Primary / Secondary Education", "Higher Education", "Education Management", "Research", "Military", "Legislative Office", "Judiciary", "International Affairs", "Government Administration", "Executive Office", "Law Enforcement", "Public Safety", "Public Policy", "Marketing and Advertising", "Newspapers", "Publishing", "Printing", "Information Services", "Libraries", "Environmental Services", "Package / Freight Delivery", "Individual & Family Services", "Religious Institutions", "Civic & Social Organization", "Consumer Services", "Transportationg / Trucking / Railroad", "Warehousing", "Airlines / Aviation", "Maritime", "Information Technology and Services", "Market Research", "Public Relations and Communications", "Design", "Nonprofit Organization Management", "Fund-Raising", "Program Development", "Writing and Editing", "Staffing and Recruiting", "Professional Training & Coaching", "Venture Capital & Private Equity", "Political Organization", "Translation and Localization", "Computer Games", "Events Services", "Arts and Crafts", "Electrical / Electronic Manufacturing", "Online Media", "Nanotechnology", "Music", "Logistics and Supply Chain", "Plastics", "Computer & Network Security", "Wireless", "Alternative Dispute Resolution", "Security and Investigations", "Facilities Services", "Outsourcing / Offshoring", "Health, Wellness and Fitness", "Alternative Medicine", "Media Production", "Animation", "Commercial Real Estate", "Capital Markets", "Think Tanks", "Philanthropy", "E-Learning", "Wholesale", "Import and Export", "Mechanical or Industrial Engineering", "Photography", "Human Resources", "Business Supplies and Equipment", "Mental Health Care", "Graphic Design", "International Trade and Development", "Wine and Spirits", "Luxury Goods & Jewelry", "Renewables & Environment", "Glass, Ceramics & Concrete", "Packaging and Containers", "Industrial Automation", "Government Relations"] 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", "fiherman", "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"] diff --git a/test/faker/default/test_faker_company.rb b/test/faker/default/test_faker_company.rb index cdcb30cc17..88ac86c987 100644 --- a/test/faker/default/test_faker_company.rb +++ b/test/faker/default/test_faker_company.rb @@ -186,6 +186,10 @@ def test_brazilian_company_number_formatted assert_match(/^\d{2}\.\d{3}\.\d{3}\/\d{4}-\d{2}$/, sample) end + def test_sic_code + assert @tester.sic_code.match(/\d\d\d\d/) + end + private def czech_o_n_checksum(org_no)