From 7928e71f5b99673e65cffd9ee8256d7db7264249 Mon Sep 17 00:00:00 2001 From: jiro4989 Date: Mon, 30 Dec 2019 17:21:08 +0900 Subject: [PATCH 1/4] :arrow_up: Version up #11 --- faker.nimble | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/faker.nimble b/faker.nimble index 86b8681..25ac3dc 100644 --- a/faker.nimble +++ b/faker.nimble @@ -1,6 +1,6 @@ # Package -version = "0.5.2" +version = "0.6.0" author = "jiro4989" description = "A new awesome nimble package" license = "MIT" From bf6333493a14f8475730fcf84b77f06c3c79b6d1 Mon Sep 17 00:00:00 2001 From: jiro4989 Date: Mon, 30 Dec 2019 17:21:28 +0900 Subject: [PATCH 2/4] :white_check_mark: Add test for company module #11 --- tests/test1.nim | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/test1.nim b/tests/test1.nim index 87c71ac..b8e2766 100644 --- a/tests/test1.nim +++ b/tests/test1.nim @@ -17,4 +17,5 @@ suite "basic usage": echo fake.phoneNumber() echo fake.job() echo fake.name() + echo fake.company() echo "-----" From 4939e055a72c96e01764e3e7478945888d4d32e8 Mon Sep 17 00:00:00 2001 From: jiro4989 Date: Mon, 30 Dec 2019 17:21:46 +0900 Subject: [PATCH 3/4] :sparkles: Add company module #11 --- src/faker/provider.nim | 4 +- src/faker/provider/company.nim | 20 + src/faker/provider/company/company_en_US.nim | 532 +++++++++++++++++++ src/faker/provider/company/company_ja_JP.nim | 67 +++ src/faker/provider/company/interfaces.nim | 14 + 5 files changed, 635 insertions(+), 2 deletions(-) create mode 100644 src/faker/provider/company.nim create mode 100644 src/faker/provider/company/company_en_US.nim create mode 100644 src/faker/provider/company/company_ja_JP.nim create mode 100644 src/faker/provider/company/interfaces.nim diff --git a/src/faker/provider.nim b/src/faker/provider.nim index a694271..b2f7789 100644 --- a/src/faker/provider.nim +++ b/src/faker/provider.nim @@ -1,2 +1,2 @@ -import provider/[address, phone_number, job, person] -export address, phone_number, job, person +import provider/[address, phone_number, job, person, company] +export address, phone_number, job, person, company diff --git a/src/faker/provider/company.nim b/src/faker/provider/company.nim new file mode 100644 index 0000000..fd21ec4 --- /dev/null +++ b/src/faker/provider/company.nim @@ -0,0 +1,20 @@ +# ----------------------------------------------- # +# This module was generated by 'nimble genProvs'. # +# See 'faker.nimble'. # +# ----------------------------------------------- # + +import util +import ../base +import company/[company_en_US, company_ja_JP] +export base + +genProc company, + [ + bs, + catchPhrase, + company, + companySuffix, + ], [ + en_US, + ja_JP, + ] \ No newline at end of file diff --git a/src/faker/provider/company/company_en_US.nim b/src/faker/provider/company/company_en_US.nim new file mode 100644 index 0000000..33b42bc --- /dev/null +++ b/src/faker/provider/company/company_en_US.nim @@ -0,0 +1,532 @@ +## company_en_US is a module to generate random company names in English. +## +## Usage +## ------ +## + +runnableExamples: + import faker/provider/company/company_en_US + + let fake = newFaker("en_US") + echo fake.company() + +from strutils import join +from sequtils import mapIt +from ../person import lastName + +include interfaces + +const + formats = @[ + "$lastName $companySuffix", + "$lastName-$lastName", + "$lastName, $lastName and $lastName", + ] + + companySuffixes = @["Inc", "and Sons", "LLC", "Group", "PLC", "Ltd"] + + catchPhraseWords = @[ + @["Adaptive", + "Advanced", + "Ameliorated", + "Assimilated", + "Automated", + "Balanced", + "Business-focused", + "Centralized", + "Cloned", + "Compatible", + "Configurable", + "Cross-group", + "Cross-platform", + "Customer-focused", + "Customizable", + "Decentralized", + "De-engineered", + "Devolved", + "Digitized", + "Distributed", + "Diverse", + "Down-sized", + "Enhanced", + "Enterprise-wide", + "Ergonomic", + "Exclusive", + "Expanded", + "Extended", + "Face-to-face", + "Focused", + "Front-line", + "Fully-configurable", + "Function-based", + "Fundamental", + "Future-proofed", + "Grass-roots", + "Horizontal", + "Implemented", + "Innovative", + "Integrated", + "Intuitive", + "Inverse", + "Managed", + "Mandatory", + "Monitored", + "Multi-channeled", + "Multi-lateral", + "Multi-layered", + "Multi-tiered", + "Networked", + "Object-based", + "Open-architected", + "Open-source", + "Operative", + "Optimized", + "Optional", + "Organic", + "Organized", + "Persevering", + "Persistent", + "Phased", + "Polarized", + "Pre-emptive", + "Proactive", + "Profit-focused", + "Profound", + "Programmable", + "Progressive", + "Public-key", + "Quality-focused", + "Reactive", + "Realigned", + "Re-contextualized", + "Re-engineered", + "Reduced", + "Reverse-engineered", + "Right-sized", + "Robust", + "Seamless", + "Secured", + "Self-enabling", + "Sharable", + "Stand-alone", + "Streamlined", + "Switchable", + "Synchronized", + "Synergistic", + "Synergized", + "Team-oriented", + "Total", + "Triple-buffered", + "Universal", + "Up-sized", + "Upgradable", + "User-centric", + "User-friendly", + "Versatile", + "Virtual", + "Visionary", + "Vision-oriented"], + @["24hour", + "24/7", + "3rdgeneration", + "4thgeneration", + "5thgeneration", + "6thgeneration", + "actuating", + "analyzing", + "asymmetric", + "asynchronous", + "attitude-oriented", + "background", + "bandwidth-monitored", + "bi-directional", + "bifurcated", + "bottom-line", + "clear-thinking", + "client-driven", + "client-server", + "coherent", + "cohesive", + "composite", + "context-sensitive", + "contextually-based", + "content-based", + "dedicated", + "demand-driven", + "didactic", + "directional", + "discrete", + "disintermediate", + "dynamic", + "eco-centric", + "empowering", + "encompassing", + "even-keeled", + "executive", + "explicit", + "exuding", + "fault-tolerant", + "foreground", + "fresh-thinking", + "full-range", + "global", + "grid-enabled", + "heuristic", + "high-level", + "holistic", + "homogeneous", + "human-resource", + "hybrid", + "impactful", + "incremental", + "intangible", + "interactive", + "intermediate", + "leadingedge", + "local", + "logistical", + "maximized", + "methodical", + "mission-critical", + "mobile", + "modular", + "motivating", + "multimedia", + "multi-state", + "multi-tasking", + "national", + "needs-based", + "neutral", + "next generation", + "non-volatile", + "object-oriented", + "optimal", + "optimizing", + "radical", + "real-time", + "reciprocal", + "regional", + "responsive", + "scalable", + "secondary", + "solution-oriented", + "stable", + "static", + "systematic", + "systemic", + "system-worthy", + "tangible", + "tertiary", + "transitional", + "uniform", + "upward-trending", + "user-facing", + "value-added", + "web-enabled", + "well-modulated", + "zero administration", + "zero-defect", + "zero tolerance"], + @["ability", + "access", + "adapter", + "algorithm", + "alliance", + "analyzer", + "application", + "approach", + "architecture", + "archive", + "artificial intelligence", + "array", + "attitude", + "benchmark", + "budgetary management", + "capability", + "capacity", + "challenge", + "circuit", + "collaboration", + "complexity", + "concept", + "conglomeration", + "contingency", + "core", + "customer loyalty", + "database", + "data-warehouse", + "definition", + "emulation", + "encoding", + "encryption", + "extranet", + "firmware", + "flexibility", + "focus group", + "forecast", + "frame", + "framework", + "function", + "functionalities", + "Graphic Interface", + "groupware", + "Graphical User Interface", + "hardware", + "help-desk", + "hierarchy", + "hub", + "implementation", + "info-mediaries", + "infrastructure", + "initiative", + "installation", + "instruction set", + "interface", + "Internet solution", + "intranet", + "knowledge user", + "knowledgebase", + "Local Area Network", + "leverage", + "matrices", + "matrix", + "methodology", + "middleware", + "migration", + "model", + "moderator", + "monitoring", + "moratorium", + "neural-net", + "open architecture", + "open system", + "orchestration", + "paradigm", + "parallelism", + "policy", + "portal", + "pricing structure", + "process improvement", + "product", + "productivity", + "project", + "projection", + "protocol", + "secured line", + "service-desk", + "software", + "solution", + "standardization", + "strategy", + "structure", + "success", + "superstructure", + "support", + "synergy", + "system engine", + "task-force", + "throughput", + "time-frame", + "toolset", + "utilization", + "website", + "workforce"]] + + bsWords = @[ + @["implement", + "utilize", + "integrate", + "streamline", + "optimize", + "evolve", + "transform", + "embrace", + "enable", + "orchestrate", + "leverage", + "reinvent", + "aggregate", + "architect", + "enhance", + "incentivize", + "morph", + "empower", + "envisioneer", + "monetize", + "harness", + "facilitate", + "seize", + "disintermediate", + "synergize", + "strategize", + "deploy", + "brand", + "grow", + "target", + "syndicate", + "synthesize", + "deliver", + "mesh", + "incubate", + "engage", + "maximize", + "benchmark", + "expedite", + "re-intermediate", + "whiteboard", + "visualize", + "repurpose", + "innovate", + "scale", + "unleash", + "drive", + "extend", + "engineer", + "revolutionize", + "generate", + "exploit", + "transition", + "e-enable", + "iterate", + "cultivate", + "matrix", + "productize", + "redefine", + "re-contextualize"], + @["clicks-and-mortar", + "value-added", + "vertical", + "proactive", + "robust", + "revolutionary", + "scalable", + "leading-edge", + "innovative", + "intuitive", + "strategic", + "e-business", + "mission-critical", + "sticky", + "one-to-one", + "24/7", + "end-to-end", + "global", + "B2B", + "B2C", + "granular", + "frictionless", + "virtual", + "viral", + "dynamic", + "24/365", + "best-of-breed", + "killer", + "magnetic", + "bleeding-edge", + "web-enabled", + "interactive", + "dot-com", + "sexy", + "back-end", + "real-time", + "efficient", + "front-end", + "distributed", + "seamless", + "extensible", + "turn-key", + "world-class", + "open-source", + "cross-platform", + "cross-media", + "synergistic", + "bricks-and-clicks", + "out-of-the-box", + "enterprise", + "integrated", + "impactful", + "wireless", + "transparent", + "next-generation", + "cutting-edge", + "user-centric", + "visionary", + "customized", + "ubiquitous", + "plug-and-play", + "collaborative", + "compelling", + "holistic", + "rich"], + @["synergies", + "web-readiness", + "paradigms", + "markets", + "partnerships", + "infrastructures", + "platforms", + "initiatives", + "channels", + "eyeballs", + "communities", + "ROI", + "solutions", + "e-tailers", + "e-services", + "action-items", + "portals", + "niches", + "technologies", + "content", + "vortals", + "supply-chains", + "convergence", + "relationships", + "architectures", + "interfaces", + "e-markets", + "e-commerce", + "systems", + "bandwidth", + "info-mediaries", + "models", + "mindshare", + "deliverables", + "users", + "schemas", + "networks", + "applications", + "metrics", + "e-business", + "functionalities", + "experiences", + "web services", + "methodologies"]] + +proc companySuffix*(f: Faker): string = + runnableExamples: + let f = newFaker("en_US") + echo f.companySuffix() + + f.rand.sample(companySuffixes) + +proc company*(f: Faker): string = + runnableExamples: + let f = newFaker("en_US") + echo f.company() + + # FIXME: all lastNames are same + let + fmt = f.rand.sample(formats) + companySuffix = f.companySuffix() + lastName = f.lastName() + fmt % @[ + "companySuffix", companySuffix, + "lastName", lastName, + ] + +proc bs*(f: Faker): string = + bsWords.mapIt(f.rand.sample(it)).join(" ") + +proc catchPhrase*(f: Faker): string = + catchPhraseWords.mapIt(f.rand.sample(it)).join(" ") diff --git a/src/faker/provider/company/company_ja_JP.nim b/src/faker/provider/company/company_ja_JP.nim new file mode 100644 index 0000000..043c717 --- /dev/null +++ b/src/faker/provider/company/company_ja_JP.nim @@ -0,0 +1,67 @@ +## company_ja_JP は日本語用のランダム会社名生成モジュールです。 +## +## 使用例 +## ------ +## + +runnableExamples: + import faker/provider/company/company_ja_JP + + let fake = newFaker("ja_JP") + echo fake.company() + +from ../person import lastName + +include interfaces + +const + formats = @[ + "$companyPrefix$lastName$companyCategory", + "$lastName$companyCategory$companyPrefix", + ] + + companyPrefixes = @["株式会社", "有限会社", "合同会社"] + companyCategories = @["水産", "農林", "鉱業", "建設", "食品", "印刷", "電気", "ガス", "情報", "通信", "運輸", "銀行", "保険"] + +proc companyPrefix*(f: Faker): string = + ## ランダムに会社名の接頭語を返却する。 + runnableExamples: + let f = newFaker("ja_JP") + echo f.companyPrefix() + ## Output: + ## 株式会社 + + f.rand.sample(companyPrefixes) + +proc companyCategory*(f: Faker): string = + ## ランダムに会社名のカテゴリを返却する。 + runnableExamples: + let f = newFaker("ja_JP") + echo f.companyCategory() + ## Output: + ## 電気 + + f.rand.sample(companyCategories) + +proc company*(f: Faker): string = + ## ランダムに会社名を返却する。 + runnableExamples: + let f = newFaker("ja_JP") + echo f.company() + ## Output: + ## 株式会社田辺銀行 + + let + fmt = f.rand.sample(formats) + companyPrefix = f.companyPrefix() + companyCategory = f.companyCategory() + lastName = f.lastName() + fmt % @[ + "companyPrefix", companyPrefix, + "companyCategory", companyCategory, + "lastName", lastName, + ] + +proc bs*(f: Faker): string = discard +proc catchPhrase*(f: Faker): string = discard +proc companySuffix*(f: Faker): string = discard diff --git a/src/faker/provider/company/interfaces.nim b/src/faker/provider/company/interfaces.nim new file mode 100644 index 0000000..febf75d --- /dev/null +++ b/src/faker/provider/company/interfaces.nim @@ -0,0 +1,14 @@ +# interfaces はプロシージャの定義のみをまとめたモジュール。 +# C言語でいうヘッダファイルのように使用する。 +# +# このモジュールをincludeしたモジュールは、このモジュールに定義しているプロシー +# ジャを全て実装しないと、コンパイルが通らない。 + +import random, strutils +import ../../base +export base + +proc bs*(f: Faker): string +proc catchPhrase*(f: Faker): string +proc company*(f: Faker): string +proc companySuffix*(f: Faker): string From 128e162c4458d77e27ab47a8084f1b65c43ba56a Mon Sep 17 00:00:00 2001 From: jiro4989 Date: Mon, 30 Dec 2019 21:16:48 +0900 Subject: [PATCH 4/4] :wrench: Change package description --- faker.nimble | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/faker.nimble b/faker.nimble index 25ac3dc..b402dd0 100644 --- a/faker.nimble +++ b/faker.nimble @@ -2,7 +2,7 @@ version = "0.6.0" author = "jiro4989" -description = "A new awesome nimble package" +description = "faker is a Nim package that generates fake data for you." license = "MIT" srcDir = "src" installExt = @["nim"]