kernow-faker 0.3.2

Sign up to get free protection for your applications and to get access to all the features.
data/History.txt ADDED
@@ -0,0 +1,23 @@
1
+ == 0.3.1 2008-04-03
2
+ * 1 minor enhancement:
3
+ * Added city to Address
4
+
5
+ == 0.3.0 2008-01-01
6
+ * 3 major enhancements:
7
+ * Added Lorem to generate fake Latin
8
+ * Added secondary_address to Address, and made inclusion of
9
+ secondary address in street_address optional (false by
10
+ default).
11
+ * Added UK address methods [Caius Durling]
12
+
13
+ == 0.2.1 2007-12-05
14
+ * 1 major enhancement:
15
+ * Dropped facets to avoid conflict with ActiveSupport
16
+ * 2 minor enhancements:
17
+ * Changed the output of user_name to randomly separate with a . or _
18
+ * Added a few tests
19
+
20
+ == 0.1.0 2007-11-22
21
+
22
+ * 1 major enhancement:
23
+ * Initial release
data/License.txt ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2007 Benjamin Curtis
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/Manifest.txt ADDED
@@ -0,0 +1,29 @@
1
+ History.txt
2
+ License.txt
3
+ Manifest.txt
4
+ README.txt
5
+ Rakefile
6
+ config/hoe.rb
7
+ config/requirements.rb
8
+ faker.tmproj
9
+ lib/extensions/array.rb
10
+ lib/extensions/object.rb
11
+ lib/faker.rb
12
+ lib/faker/address.rb
13
+ lib/faker/company.rb
14
+ lib/faker/internet.rb
15
+ lib/faker/lorem.rb
16
+ lib/faker/name.rb
17
+ lib/faker/phone_number.rb
18
+ lib/faker/version.rb
19
+ script/destroy
20
+ script/generate
21
+ script/txt2html
22
+ setup.rb
23
+ tasks/deployment.rake
24
+ tasks/environment.rake
25
+ tasks/website.rake
26
+ test/test_faker.rb
27
+ test/test_faker_internet.rb
28
+ test/test_faker_name.rb
29
+ test/test_helper.rb
data/README.txt ADDED
@@ -0,0 +1,8 @@
1
+ = Faker
2
+
3
+ A port of Perl's Data::Faker library that generates fake data.
4
+
5
+ == Usage
6
+ * Faker::Name.name => "Christophe Bartell"
7
+
8
+ * Faker::Internet.email => "kirsten.greenholt@corkeryfisher.info"
data/Rakefile ADDED
@@ -0,0 +1,4 @@
1
+ require 'config/requirements'
2
+ require 'config/hoe' # setup Hoe + all gem configuration
3
+
4
+ Dir['tasks/**/*.rake'].each { |rake| load rake }
data/config/hoe.rb ADDED
@@ -0,0 +1,71 @@
1
+ require 'faker/version'
2
+
3
+ AUTHOR = ['Benjamin Curtis', 'Jamie Dyer'] # can also be an array of Authors
4
+ EMAIL = "benjamin.curtis@gmail.com"
5
+ DESCRIPTION = "A port of Perl's Data::Faker - Generates fake names, phone numbers, etc."
6
+ GEM_NAME = 'faker' # what ppl will type to install your gem
7
+ RUBYFORGE_PROJECT = 'faker' # The unix name for your project
8
+ HOMEPATH = "http://#{RUBYFORGE_PROJECT}.rubyforge.org"
9
+ DOWNLOAD_PATH = "http://rubyforge.org/projects/#{RUBYFORGE_PROJECT}"
10
+
11
+ @config_file = "~/.rubyforge/user-config.yml"
12
+ @config = nil
13
+ RUBYFORGE_USERNAME = "unknown"
14
+ def rubyforge_username
15
+ unless @config
16
+ begin
17
+ @config = YAML.load(File.read(File.expand_path(@config_file)))
18
+ rescue
19
+ puts <<-EOS
20
+ ERROR: No rubyforge config file found: #{@config_file}
21
+ Run 'rubyforge setup' to prepare your env for access to Rubyforge
22
+ - See http://newgem.rubyforge.org/rubyforge.html for more details
23
+ EOS
24
+ exit
25
+ end
26
+ end
27
+ RUBYFORGE_USERNAME.replace @config["username"]
28
+ end
29
+
30
+
31
+ REV = nil
32
+ # UNCOMMENT IF REQUIRED:
33
+ # REV = `svn info`.each {|line| if line =~ /^Revision:/ then k,v = line.split(': '); break v.chomp; else next; end} rescue nil
34
+ VERS = Faker::VERSION::STRING + (REV ? ".#{REV}" : "")
35
+ RDOC_OPTS = ['--quiet', '--title', 'faker documentation',
36
+ "--opname", "index.html",
37
+ "--line-numbers",
38
+ "--main", "README",
39
+ "--inline-source"]
40
+
41
+ class Hoe
42
+ def extra_deps
43
+ @extra_deps.reject! { |x| Array(x).first == 'hoe' }
44
+ @extra_deps
45
+ end
46
+ end
47
+
48
+ # Generate all the Rake tasks
49
+ # Run 'rake -T' to see list of generated tasks (from gem root directory)
50
+ hoe = Hoe.new(GEM_NAME, VERS) do |p|
51
+ p.author = AUTHOR
52
+ p.description = DESCRIPTION
53
+ p.email = EMAIL
54
+ p.summary = DESCRIPTION
55
+ p.url = HOMEPATH
56
+ p.rubyforge_name = RUBYFORGE_PROJECT if RUBYFORGE_PROJECT
57
+ p.test_globs = ["test/**/test_*.rb"]
58
+ p.clean_globs |= ['**/.*.sw?', '*.gem', '.config', '**/.DS_Store'] #An array of file patterns to delete on clean.
59
+
60
+ # == Optional
61
+ p.changes = p.paragraphs_of("History.txt", 0..1).join("\n\n")
62
+ #p.extra_deps = [] # An array of rubygem dependencies [name, version], e.g. [ ['active_support', '>= 1.3.1'] ]
63
+
64
+ #p.spec_extras = {} # A hash of extra values to set in the gemspec.
65
+
66
+ end
67
+
68
+ CHANGES = hoe.paragraphs_of('History.txt', 0..1).join("\\n\\n")
69
+ PATH = (RUBYFORGE_PROJECT == GEM_NAME) ? RUBYFORGE_PROJECT : "#{RUBYFORGE_PROJECT}/#{GEM_NAME}"
70
+ hoe.remote_rdoc_dir = File.join(PATH.gsub(/^#{RUBYFORGE_PROJECT}\/?/,''), 'rdoc')
71
+ hoe.rsync_args = '-av --delete --ignore-errors'
@@ -0,0 +1,17 @@
1
+ require 'fileutils'
2
+ include FileUtils
3
+
4
+ require 'rubygems'
5
+ %w[rake hoe newgem rubigen].each do |req_gem|
6
+ begin
7
+ require req_gem
8
+ rescue LoadError
9
+ puts "This Rakefile requires the '#{req_gem}' RubyGem."
10
+ puts "Installation: gem install #{req_gem} -y"
11
+ exit
12
+ end
13
+ end
14
+
15
+ $:.unshift(File.join(File.dirname(__FILE__), %w[.. lib]))
16
+
17
+ require 'faker'
@@ -0,0 +1,9 @@
1
+ class Array
2
+ def rand
3
+ self[Kernel.rand(length)]
4
+ end
5
+
6
+ def shuffle
7
+ self.sort_by{Kernel.rand}
8
+ end
9
+ end
@@ -0,0 +1,6 @@
1
+ class Object
2
+ def returning(value)
3
+ yield(value)
4
+ value
5
+ end
6
+ end
@@ -0,0 +1,76 @@
1
+ module Faker
2
+ class Address
3
+ class << self
4
+ def zip_code
5
+ Faker.numerify(['#####', '#####-####'].rand)
6
+ end
7
+
8
+ def us_state
9
+ ['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'].rand
10
+ end
11
+
12
+ def us_state_abbr
13
+ %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).rand
14
+ end
15
+
16
+ def city_prefix
17
+ %w(North East West South New Lake Port).rand
18
+ end
19
+
20
+ def city_suffix
21
+ %w(town ton land ville berg burgh borough bury view port mouth stad furt chester mouth fort haven side shire).rand
22
+ end
23
+
24
+ def city
25
+ [
26
+ '%s %s%s' % [city_prefix, Name.first_name, city_suffix],
27
+ '%s %s' % [city_prefix, Name.first_name],
28
+ '%s%s' % [Name.first_name, city_suffix],
29
+ '%s%s' % [Name.last_name, city_suffix],
30
+ ].rand
31
+ end
32
+
33
+ def street_suffix
34
+ %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).rand
35
+ end
36
+
37
+ def street_name
38
+ [
39
+ Proc.new { [Name.last_name, street_suffix].join(' ') },
40
+ Proc.new { [Name.first_name, street_suffix].join(' ') }
41
+ ].rand.call
42
+ end
43
+
44
+ def street_address(include_secondary = false)
45
+ Faker.numerify([
46
+ '##### %s' % street_name,
47
+ '#### %s' % street_name,
48
+ '### %s' % street_name
49
+ ].rand + (include_secondary ? ' ' + secondary_address : ''))
50
+ end
51
+
52
+ def secondary_address
53
+ Faker.numerify([
54
+ 'Apt. ###',
55
+ 'Suite ###'
56
+ ].rand)
57
+ end
58
+
59
+ # UK Variants
60
+ def uk_county
61
+ ['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'].rand
62
+ end
63
+
64
+ def uk_country
65
+ ['England', 'Scotland', 'Wales', 'Northern Ireland'].rand
66
+ end
67
+
68
+ def uk_postcode
69
+ Faker.bothify([
70
+ '??# #??',
71
+ '??## #??'
72
+ ].rand).upcase
73
+ end
74
+ end
75
+ end
76
+ end
@@ -0,0 +1,39 @@
1
+ module Faker
2
+ class Company
3
+ class << self
4
+ def name
5
+ Formats.rand.call
6
+ end
7
+
8
+ def suffix
9
+ %w(Inc and\ Sons LLC Group).rand
10
+ end
11
+
12
+ # Generate a buzzword-laden catch phrase.
13
+ # Wordlist from http://www.1728.com/buzzword.htm
14
+ def catch_phrase
15
+ [
16
+ ["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"].rand,
17
+ ["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"].rand,
18
+ ["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"].rand
19
+ ].join(' ')
20
+ end
21
+
22
+ # When a straight answer won't do, BS to the rescue!
23
+ # Wordlist from http://dack.com/web/bullshit.html
24
+ def bs
25
+ [
26
+ ["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"].rand,
27
+ ["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"].rand,
28
+ ["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"].rand
29
+ ].join(' ')
30
+ end
31
+ end
32
+
33
+ Formats = [
34
+ Proc.new { [ Name.last_name, suffix ].join(' ') },
35
+ Proc.new { [ Name.last_name, Name.last_name ].join('-') },
36
+ Proc.new { "%s, %s and %s" % [ Name.last_name, Name.last_name, Name.last_name ] }
37
+ ]
38
+ end
39
+ end
@@ -0,0 +1,52 @@
1
+ module Faker
2
+ class Internet
3
+ class << self
4
+ def email(name = nil)
5
+ [ user_name(name), domain_name ].join('@')
6
+ end
7
+
8
+ def free_email(name = nil)
9
+ [ user_name(name), %w(gmail.com yahoo.com hotmail.com).rand ].join('@')
10
+ end
11
+
12
+ def user_name(name = nil, options = {})
13
+ default_options = {:join => %w(. _), :format => :rand, :data_source => RegularNames}
14
+ options = default_options.merge(options)
15
+ Name.data_source = options[:data_source]
16
+
17
+ return name.scan(/\w+/).shuffle.join(options[:join].rand).downcase if name
18
+
19
+ names = {
20
+ :first => Proc.new { clean_and_downcase Name.first_name },
21
+ :first_last => Proc.new {
22
+ [ Name.first_name, Name.last_name ].map {|n|
23
+ clean_and_downcase n
24
+ }.join(options[:join].rand) }
25
+ }
26
+
27
+ if options[:format] == :rand
28
+ names.rand.call
29
+ else
30
+ names[options[:format]].call
31
+ end
32
+ end
33
+
34
+ def domain_name
35
+ [ domain_word, domain_suffix ].join('.')
36
+ end
37
+
38
+ def domain_word
39
+ clean_and_downcase Company.name.split(' ').first
40
+ end
41
+
42
+ def domain_suffix
43
+ %w(co.uk com us uk ca biz info name).rand
44
+ end
45
+
46
+ protected
47
+ def clean_and_downcase(str)
48
+ str.gsub(/\W/, '').downcase
49
+ end
50
+ end
51
+ end
52
+ end
@@ -0,0 +1,34 @@
1
+ module Faker
2
+ # Based on Perl's Text::Lorem
3
+ class Lorem
4
+ Words = %w(alias consequatur aut perferendis sit voluptatem accusantium doloremque aperiam eaque ipsa quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt explicabo aspernatur aut odit aut fugit sed quia consequuntur magni dolores eos qui ratione voluptatem sequi nesciunt neque dolorem ipsum quia dolor sit amet consectetur adipisci velit sed quia non numquam eius modi tempora incidunt ut labore et dolore magnam aliquam quaerat voluptatem ut enim ad minima veniam quis nostrum exercitationem ullam corporis nemo enim ipsam voluptatem quia voluptas sit suscipit laboriosam nisi ut aliquid ex ea commodi consequatur quis autem vel eum iure reprehenderit qui in ea voluptate velit esse quam nihil molestiae et iusto odio dignissimos ducimus qui blanditiis praesentium laudantium totam rem voluptatum deleniti atque corrupti quos dolores et quas molestias excepturi sint occaecati cupiditate non provident sed ut perspiciatis unde omnis iste natus error similique sunt in culpa qui officia deserunt mollitia animi id est laborum et dolorum fuga et harum quidem rerum facilis est et expedita distinctio nam libero tempore cum soluta nobis est eligendi optio cumque nihil impedit quo porro quisquam est qui minus id quod maxime placeat facere possimus omnis voluptas assumenda est omnis dolor repellendus temporibus autem quibusdam et aut consequatur vel illum qui dolorem eum fugiat quo voluptas nulla pariatur at vero eos et accusamus officiis debitis aut rerum necessitatibus saepe eveniet ut et voluptates repudiandae sint et molestiae non recusandae itaque earum rerum hic tenetur a sapiente delectus ut aut reiciendis voluptatibus maiores doloribus asperiores repellat)
5
+
6
+ def self.words(num = 3)
7
+ Words.shuffle[0, num]
8
+ end
9
+
10
+ def self.sentence(word_count = 4)
11
+ words(word_count + rand(6)).join(' ').capitalize + '.'
12
+ end
13
+
14
+ def self.sentences(sentence_count = 3)
15
+ returning([]) do |sentences|
16
+ 1.upto(sentence_count) do
17
+ sentences << sentence
18
+ end
19
+ end
20
+ end
21
+
22
+ def self.paragraph(sentence_count = 3)
23
+ sentences(sentence_count + rand(3)).join(' ')
24
+ end
25
+
26
+ def self.paragraphs(paragraph_count = 3)
27
+ returning([]) do |paragraphs|
28
+ 1.upto(paragraph_count) do
29
+ paragraphs << paragraph
30
+ end
31
+ end
32
+ end
33
+ end
34
+ end
data/lib/faker/name.rb ADDED
@@ -0,0 +1,46 @@
1
+ module Faker
2
+ class Name
3
+ class << self
4
+ def name
5
+ Formats.rand.call.join(' ')
6
+ end
7
+
8
+ def first_name
9
+ data_source.first_names.rand
10
+ end
11
+
12
+ def last_name
13
+ data_source.last_names.rand
14
+ end
15
+
16
+ def prefix
17
+ data_source.prefixes.rand
18
+ end
19
+
20
+ def suffix
21
+ data_source.suffixes.rand
22
+ end
23
+
24
+ def data_source
25
+ @data_source || RegularNames
26
+ end
27
+
28
+ def data_source=(source)
29
+ @data_source = source
30
+ end
31
+ end
32
+
33
+ Formats = [
34
+ Proc.new { [ prefix, first_name, last_name ] },
35
+ Proc.new { [ first_name, last_name, suffix ] },
36
+ Proc.new { [ first_name, last_name ] },
37
+ Proc.new { [ first_name, last_name ] },
38
+ Proc.new { [ first_name, last_name ] },
39
+ Proc.new { [ first_name, last_name ] },
40
+ Proc.new { [ first_name, last_name ] },
41
+ Proc.new { [ first_name, last_name ] },
42
+ Proc.new { [ first_name, last_name ] },
43
+ Proc.new { [ first_name, last_name ] }
44
+ ]
45
+ end
46
+ end
@@ -0,0 +1,33 @@
1
+ module Faker
2
+ class PhoneNumber
3
+ class << self
4
+ def phone_number
5
+ Faker.numerify(Formats.rand)
6
+ end
7
+ end
8
+
9
+
10
+ Formats = [
11
+ '###-###-####',
12
+ '(###)###-####',
13
+ '1-###-###-####',
14
+ '###.###.####',
15
+ '###-###-####',
16
+ '(###)###-####',
17
+ '1-###-###-####',
18
+ '###.###.####',
19
+ '###-###-#### x###',
20
+ '(###)###-#### x###',
21
+ '1-###-###-#### x###',
22
+ '###.###.#### x###',
23
+ '###-###-#### x####',
24
+ '(###)###-#### x####',
25
+ '1-###-###-#### x####',
26
+ '###.###.#### x####',
27
+ '###-###-#### x#####',
28
+ '(###)###-#### x#####',
29
+ '1-###-###-#### x#####',
30
+ '###.###.#### x#####'
31
+ ]
32
+ end
33
+ end
@@ -0,0 +1,9 @@
1
+ module Faker #:nodoc:
2
+ module VERSION #:nodoc:
3
+ MAJOR = 0
4
+ MINOR = 3
5
+ TINY = 2
6
+
7
+ STRING = [MAJOR, MINOR, TINY].join('.')
8
+ end
9
+ end
data/lib/faker.rb ADDED
@@ -0,0 +1,30 @@
1
+ $:.unshift File.dirname(__FILE__)
2
+
3
+ require 'faker/address'
4
+ require 'faker/company'
5
+ require 'faker/internet'
6
+ require 'faker/lorem'
7
+ require 'faker/name'
8
+ require 'faker/phone_number'
9
+ require 'faker/version'
10
+
11
+ require 'extensions/array'
12
+ require 'extensions/hash'
13
+ require 'extensions/object'
14
+
15
+ require 'data/regular_names'
16
+ require 'data/super_hero_villain_names'
17
+
18
+ module Faker
19
+ def self.numerify(number_string)
20
+ number_string.gsub(/#/) { rand(10).to_s }
21
+ end
22
+
23
+ def self.letterify(letter_string)
24
+ letter_string.gsub(/\?/) { ('a'..'z').to_a.rand }
25
+ end
26
+
27
+ def self.bothify(string)
28
+ self.letterify(self.numerify(string))
29
+ end
30
+ end
data/script/destroy ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+ APP_ROOT = File.join(File.dirname(__FILE__), '..')
3
+
4
+ begin
5
+ require 'rubigen'
6
+ rescue LoadError
7
+ require 'rubygems'
8
+ require 'rubigen'
9
+ end
10
+ require 'rubigen/scripts/destroy'
11
+
12
+ ARGV.shift if ['--help', '-h'].include?(ARGV[0])
13
+ RubiGen::Base.use_component_sources! [:rubygems, :newgem, :newgem_theme, :test_unit]
14
+ RubiGen::Scripts::Destroy.new.run(ARGV)
data/script/generate ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+ APP_ROOT = File.join(File.dirname(__FILE__), '..')
3
+
4
+ begin
5
+ require 'rubigen'
6
+ rescue LoadError
7
+ require 'rubygems'
8
+ require 'rubigen'
9
+ end
10
+ require 'rubigen/scripts/generate'
11
+
12
+ ARGV.shift if ['--help', '-h'].include?(ARGV[0])
13
+ RubiGen::Base.use_component_sources! [:rubygems, :newgem, :newgem_theme, :test_unit]
14
+ RubiGen::Scripts::Generate.new.run(ARGV)
data/script/txt2html ADDED
@@ -0,0 +1,74 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'rubygems'
4
+ begin
5
+ require 'newgem'
6
+ rescue LoadError
7
+ puts "\n\nGenerating the website requires the newgem RubyGem"
8
+ puts "Install: gem install newgem\n\n"
9
+ exit(1)
10
+ end
11
+ require 'redcloth'
12
+ require 'syntax/convertors/html'
13
+ require 'erb'
14
+ require File.dirname(__FILE__) + '/../lib/faker/version.rb'
15
+
16
+ version = Faker::VERSION::STRING
17
+ download = 'http://rubyforge.org/projects/faker'
18
+
19
+ class Fixnum
20
+ def ordinal
21
+ # teens
22
+ return 'th' if (10..19).include?(self % 100)
23
+ # others
24
+ case self % 10
25
+ when 1: return 'st'
26
+ when 2: return 'nd'
27
+ when 3: return 'rd'
28
+ else return 'th'
29
+ end
30
+ end
31
+ end
32
+
33
+ class Time
34
+ def pretty
35
+ return "#{mday}#{mday.ordinal} #{strftime('%B')} #{year}"
36
+ end
37
+ end
38
+
39
+ def convert_syntax(syntax, source)
40
+ return Syntax::Convertors::HTML.for_syntax(syntax).convert(source).gsub(%r!^<pre>|</pre>$!,'')
41
+ end
42
+
43
+ if ARGV.length >= 1
44
+ src, template = ARGV
45
+ template ||= File.join(File.dirname(__FILE__), '/../website/template.rhtml')
46
+
47
+ else
48
+ puts("Usage: #{File.split($0).last} source.txt [template.rhtml] > output.html")
49
+ exit!
50
+ end
51
+
52
+ template = ERB.new(File.open(template).read)
53
+
54
+ title = nil
55
+ body = nil
56
+ File.open(src) do |fsrc|
57
+ title_text = fsrc.readline
58
+ body_text = fsrc.read
59
+ syntax_items = []
60
+ body_text.gsub!(%r!<(pre|code)[^>]*?syntax=['"]([^'"]+)[^>]*>(.*?)</\1>!m){
61
+ ident = syntax_items.length
62
+ element, syntax, source = $1, $2, $3
63
+ syntax_items << "<#{element} class='syntax'>#{convert_syntax(syntax, source)}</#{element}>"
64
+ "syntax-temp-#{ident}"
65
+ }
66
+ title = RedCloth.new(title_text).to_html.gsub(%r!<.*?>!,'').strip
67
+ body = RedCloth.new(body_text).to_html
68
+ body.gsub!(%r!(?:<pre><code>)?syntax-temp-(\d+)(?:</code></pre>)?!){ syntax_items[$1.to_i] }
69
+ end
70
+ stat = File.stat(src)
71
+ created = stat.ctime
72
+ modified = stat.mtime
73
+
74
+ $stdout << template.result(binding)