Permalink
Browse files

major refactor of faker

  • Loading branch information...
1 parent 32dc9fd commit d5d01a2abb5777da94e737b607941b7cd078d19d Emmanuel Oga committed Jan 15, 2010
View
@@ -0,0 +1,26 @@
+== 0.3.2 2010-01-14
+* Several Optimizations, renamed gem packege to ffaker.
+
+== 0.3.1 2008-04-03
+* 1 minor enhancement:
+ * Added city to Address
+
+== 0.3.0 2008-01-01
+* 3 major enhancements:
+ * Added Lorem to generate fake Latin
+ * Added secondary_address to Address, and made inclusion of
+ secondary address in street_address optional (false by
+ default).
+ * Added UK address methods [Caius Durling]
+
+== 0.2.1 2007-12-05
+* 1 major enhancement:
+ * Dropped facets to avoid conflict with ActiveSupport
+* 2 minor enhancements:
+ * Changed the output of user_name to randomly separate with a . or _
+ * Added a few tests
+
+== 0.1.0 2007-11-22
+
+* 1 major enhancement:
+ * Initial release
View
@@ -1,4 +1,5 @@
-Copyright (c) 2009 Emmanuel Oga
+Copyright (c) 2010 Emmanuel Oga
+Copyright (c) 2007 Benjamin Curtis
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
View
@@ -1,9 +1,28 @@
= ffaker
-Description goes here.
+Fast Faker == Faker refactored, cleaner and faster.
+
+= Faker
+
+A port of Perl's Data::Faker library that generates fake data.
+
+== Usage
+
+* Faker::Name.name => "Christophe Bartell"
+
+* Faker::Internet.email => "kirsten.greenholt@corkeryfisher.info"
+
+== Ffaker / Faker ==
+
+This version of the gem was modified by me (Emmanuel Oga) cause I was
+so annoyed on several ineficiencies on the original gem.
+
+And because I coult not find the original author on github (and I
+don't feel like working with the arcane rubyforge+svn tools) I
+just realised this gem using a different name.
== Note on Patches/Pull Requests
-
+
* Fork the project.
* Make your feature addition or bug fix.
* Add tests for it. This is important so I don't break it in a
@@ -14,4 +33,5 @@ Description goes here.
== Copyright
+Copyright (c) 2007 Benjamin Curtis
Copyright (c) 2010 Emmanuel Oga. See LICENSE for details.
View
No changes.
View
@@ -0,0 +1,29 @@
+module Faker
+ require 'faker/utils/module_utils'
+
+ extend ModuleUtils
+
+ LETTERS = k('a'..'z')
+
+ def self.numerify(number_string)
+ number_string.gsub!(/#/) { rand(10).to_s }
+ number_string
+ end
+
+ def self.letterify(letter_string)
+ letter_string.gsub!(/\?/) { LETTERS.rand }
+ letter_string
+ end
+
+ def self.bothify(string)
+ self.letterify(self.numerify(string))
+ end
+
+ autoload :Address, 'faker/address'
+ autoload :Company, 'faker/company'
+ autoload :Internet, 'faker/internet'
+ autoload :Lorem, 'faker/lorem'
+ autoload :Name, 'faker/name'
+ autoload :PhoneNumber, 'faker/phone_number'
+ autoload :VERSION, 'faker/version'
+end
View
@@ -0,0 +1,143 @@
+module Faker
+ module Address
+ extend ModuleUtils
+ extend self
+
+ def zip_code
+ Faker.numerify ZIP_FORMATS.rand
+ end
+
+ def us_state
+ STATE.rand
+ end
+
+ def us_state_abbr
+ STATE_ABBR
+ end
+
+ def city_prefix
+ CITY_PREFIXES.rand
+ end
+
+ def city_suffix
+ CITY_SUFFIXES.rand
+ end
+
+ def city
+ case rand(4)
+ when 0 then '%s %s%s' % [city_prefix, Name.first_name, city_suffix]
+ when 1 then '%s %s' % [city_prefix, Name.first_name]
+ when 2 then '%s%s' % [Name.first_name, city_suffix]
+ when 3 then '%s%s' % [Name.last_name, city_suffix]
+ end
+ end
+
+ def street_suffix
+ STREET_SUFFIX.rand
+ end
+
+ def street_name
+ case rand(2)
+ when 0 then "#{Name.last_name}#{street_suffix}"
+ when 1 then "#{Name.first_name}#{street_suffix}"
+ end
+ end
+
+ def street_address(include_secondary = false)
+ str = case rand(3)
+ when 0 then '##### %s' % street_name
+ when 1 then '#### %s' % street_name
+ when 2 then '### %s' % street_name
+ end
+
+ str << ' ' << secondary_address if include_secondary
+
+ Faker.numerify(str)
+ end
+
+ def secondary_address
+ Faker.numerify(SEC_ADDR.rand)
+ end
+
+ # UK Variants
+ def uk_county
+ UK_COUNTY.rand
+ end
+
+ def uk_country
+ UK_COUNTRY.rand
+ end
+
+ def uk_postcode
+ Faker.bothify(UK_POSTCODE.rand).upcase
+ end
+
+ ZIP_FORMATS = k ['#####', '#####-####']
+
+ STATE = k ['Alabama', 'Alaska', 'Arizona', 'Arkansas',
+ 'California', 'Colorado', 'Connecticut', 'Delaware', 'Florida',
+ 'Georgia', 'Hawaii', 'Idaho', 'Illinois', 'Indiana', 'Iowa', 'Kansas',
+ 'Kentucky', 'Louisiana', 'Maine', 'Maryland', 'Massachusetts',
+ 'Michigan', 'Minnesota', 'Mississippi', 'Missouri', 'Montana',
+ 'Nebraska', 'Nevada', 'New Hampshire', 'New Jersey', 'New Mexico', 'New York',
+ 'North Carolina', 'North Dakota', 'Ohio', 'Oklahoma', 'Oregon',
+ 'Pennsylvania', 'Rhode Island', 'South Carolina', 'South Dakota',
+ 'Tennessee', 'Texas', 'Utah', 'Vermont', 'Virginia', 'Washington',
+ 'West Virginia', 'Wisconsin', 'Wyoming']
+
+ STATE_ABBR = k %w(AL AK AS AZ AR CA CO CT DE DC FM FL GA GU HI ID IL IN IA
+ KS KY LA ME MH MD MA MI MN MS MO MT NE NV NH NJ NM NY NC
+ ND MP OH OK OR PW PA PR RI SC SD TN TX UT VT VI VA WA WV
+ WI WY AE AA AP)
+
+ CITY_PREFIXES = k %w(North East West South New Lake Port)
+
+ CITY_SUFFIXES = k %w(town ton land ville berg burgh borough bury view port
+ mouth stad furt chester mouth fort haven side shire)
+
+ STREET_SUFFIX = k %w(Alley Avenue Branch Bridge Brook Brooks
+ Burg Burgs Bypass Camp Canyon Cape Causeway Center Centers Circle Circles
+ Cliff Cliffs Club Common Corner Corners Course Court Courts Cove Coves
+ Creek Crescent Crest Crossing Crossroad Curve Dale Dam Divide Drive Drive
+ Drives Estate Estates Expressway Extension Extensions Fall Falls Ferry
+ Field Fields Flat Flats Ford Fords Forest Forge Forges Fork Forks Fort
+ Freeway Garden Gardens Gateway Glen Glens Green Greens Grove Groves Harbor
+ Harbors Haven Heights Highway Hill Hills Hollow Inlet Inlet Island Island
+ Islands Islands Isle Isle Junction Junctions Key Keys Knoll Knolls Lake
+ Lakes Land Landing Lane Light Lights Loaf Lock Locks Locks Lodge Lodge Loop
+ Mall Manor Manors Meadow Meadows Mews Mill Mills Mission Mission Motorway
+ Mount Mountain Mountain Mountains Mountains Neck Orchard Oval Overpass Park
+ Parks Parkway Parkways Pass Passage Path Pike Pine Pines Place Plain Plains
+ Plains Plaza Plaza Point Points Port Port Ports Ports Prairie Prairie
+ Radial Ramp Ranch Rapid Rapids Rest Ridge Ridges River Road Road Roads
+ Roads Route Row Rue Run Shoal Shoals Shore Shores Skyway Spring Springs
+ Springs Spur Spurs Square Square Squares Squares Station Station Stravenue
+ Stravenue Stream Stream Street Street Streets Summit Summit Terrace
+ Throughway Trace Track Trafficway Trail Trail Tunnel Tunnel Turnpike
+ Turnpike Underpass Union Unions Valley Valleys Via Viaduct View Views
+ Village Village Villages Ville Vista Vista Walk Walks Wall Way Ways Well
+ Wells)
+
+ SEC_ADDR = k ['Apt. ###', 'Suite ###']
+
+ UK_COUNTY = k ['Avon', 'Bedfordshire', 'Berkshire', 'Borders',
+ 'Buckinghamshire', 'Cambridgeshire', 'Central', 'Cheshire', 'Cleveland',
+ 'Clwyd', 'Cornwall', 'County Antrim', 'County Armagh', 'County Down',
+ 'County Fermanagh', 'County Londonderry', 'County Tyrone', 'Cumbria',
+ 'Derbyshire', 'Devon', 'Dorset', 'Dumfries and Galloway', 'Durham',
+ 'Dyfed', 'East Sussex', 'Essex', 'Fife', 'Gloucestershire', 'Grampian',
+ 'Greater Manchester', 'Gwent', 'Gwynedd County', 'Hampshire',
+ 'Herefordshire', 'Hertfordshire', 'Highlands and Islands', 'Humberside',
+ 'Isle of Wight', 'Kent', 'Lancashire', 'Leicestershire', 'Lincolnshire',
+ 'Lothian', 'Merseyside', 'Mid Glamorgan', 'Norfolk', 'North Yorkshire',
+ 'Northamptonshire', 'Northumberland', 'Nottinghamshire', 'Oxfordshire',
+ 'Powys', 'Rutland', 'Shropshire', 'Somerset', 'South Glamorgan',
+ 'South Yorkshire', 'Staffordshire', 'Strathclyde', 'Suffolk', 'Surrey',
+ 'Tayside', 'Tyne and Wear', 'Warwickshire', 'West Glamorgan', 'West Midlands',
+ 'West Sussex', 'West Yorkshire', 'Wiltshire', 'Worcestershire']
+
+ UK_COUNTRY = k ['England', 'Scotland', 'Wales', 'Northern Ireland']
+
+ UK_POSTCODE = k ['??# #??', '??## #??']
+ end
+end
View
@@ -0,0 +1,140 @@
+module Faker
+ module Company
+ extend ModuleUtils
+ extend self
+
+ def name
+ case rand(3)
+ when 0 then "#{Name.last_name} #{suffix}"
+ when 1 then "#{Name.last_name}-#{Name.last_name}"
+ when 2 then "%s, %s and %s" % [ Name.last_name, Name.last_name, Name.last_name ]
+ end
+ end
+
+ def suffix
+ SUFFIXES.rand
+ end
+
+ # Generate a buzzword-laden catch phrase.
+ # Wordlist from http://www.1728.com/buzzword.htm
+ def catch_phrase
+ "#{CATCH_MID.rand}#{CATCH_MID.rand}#{CATCH_POS.rand}"
+ end
+
+ # When a straight answer won't do, BS to the rescue!
+ # Wordlist from http://dack.com/web/bullshit.html
+ def bs
+ "#{BS_MID.rand}#{BS_MID.rand}#{BS_POS.rand}"
+ end
+
+ SUFFIXES = k %w(Inc and\ Sons LLC Group)
+
+ CATCH_PRE = k ["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-channelled", "Multi-lateral", "Multi-layered", "Multi-tiered",
+ "Networked", "Object-based", "Open-architected", "Open-source",
+ "Operative", "Optimized", "Optional", "Organic", "Organized",
+ "Persevering", "Persistent", "Phased", "Polarised", "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", "Synchronised",
+ "Synergistic", "Synergized", "Team-oriented", "Total", "Triple-buffered",
+ "Universal", "Up-sized", "Upgradable", "User-centric", "User-friendly",
+ "Versatile", "Virtual", "Visionary", "Vision-oriented"]
+
+ CATCH_MID = k ["24 hour", "24/7", "3rd generation", "4th generation",
+ "5th generation", "6th generation", "actuating", "analyzing", "assymetric",
+ "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",
+ "leading edge", "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"]
+
+ CATCH_POS = k ["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",
+ "knowledge base", "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", "utilisation", "website",
+ "workforce"]
+
+ BS_PRE = k ["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",
+ "reintermediate", "whiteboard", "visualize", "repurpose", "innovate",
+ "scale", "unleash", "drive", "extend", "engineer", "revolutionize",
+ "generate", "exploit", "transition", "e-enable", "iterate",
+ "cultivate", "matrix", "productize", "redefine", "recontextualize"]
+
+ BS_MID = k ["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"]
+
+ BS_POS = k ["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", "infomediaries", "models", "mindshare", "deliverables",
+ "users", "schemas", "networks", "applications", "metrics",
+ "e-business", "functionalities", "experiences", "web services",
+ "methodologies"]
+ end
+end
Oops, something went wrong.

0 comments on commit d5d01a2

Please sign in to comment.