elandesign-archer 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/Manifest +8 -0
- data/README.rdoc +3 -0
- data/Rakefile +15 -0
- data/archer.gemspec +31 -0
- data/lib/archer.rb +4 -0
- data/lib/archer/address.rb +173 -0
- data/lib/archer/lipsum.rb +44 -0
- data/lib/archer/name.rb +31 -0
- data/lib/archer/phonenumber.rb +20 -0
- metadata +71 -0
data/Manifest
ADDED
data/README.rdoc
ADDED
data/Rakefile
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
# Rakefile
|
2
|
+
require 'rubygems'
|
3
|
+
require 'rake'
|
4
|
+
require 'echoe'
|
5
|
+
|
6
|
+
Echoe.new('archer', '0.1.0') do |p|
|
7
|
+
p.description = "Dummy data generator, optimised for the UK"
|
8
|
+
p.url = "http://github.com/elandesign/archer"
|
9
|
+
p.author = "Paul Smith"
|
10
|
+
p.email = "paul@elandesign.co.uk"
|
11
|
+
p.ignore_pattern = ["tmp/*", "script/*"]
|
12
|
+
p.development_dependencies = []
|
13
|
+
end
|
14
|
+
|
15
|
+
Dir["#{File.dirname(__FILE__)}/tasks/*.rake"].sort.each { |ext| load ext }
|
data/archer.gemspec
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
|
3
|
+
Gem::Specification.new do |s|
|
4
|
+
s.name = %q{archer}
|
5
|
+
s.version = "0.1.0"
|
6
|
+
|
7
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
|
8
|
+
s.authors = ["Paul Smith"]
|
9
|
+
s.date = %q{2009-01-08}
|
10
|
+
s.description = %q{Dummy data generator, optimised for the UK}
|
11
|
+
s.email = %q{paul@elandesign.co.uk}
|
12
|
+
s.extra_rdoc_files = ["lib/archer/address.rb", "lib/archer/lipsum.rb", "lib/archer/name.rb", "lib/archer/phonenumber.rb", "lib/archer.rb", "README.rdoc"]
|
13
|
+
s.files = ["lib/archer/address.rb", "lib/archer/lipsum.rb", "lib/archer/name.rb", "lib/archer/phonenumber.rb", "lib/archer.rb", "Manifest", "Rakefile", "README.rdoc", "archer.gemspec"]
|
14
|
+
s.has_rdoc = true
|
15
|
+
s.homepage = %q{http://github.com/elandesign/archer}
|
16
|
+
s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "Archer", "--main", "README.rdoc"]
|
17
|
+
s.require_paths = ["lib"]
|
18
|
+
s.rubyforge_project = %q{archer}
|
19
|
+
s.rubygems_version = %q{1.3.1}
|
20
|
+
s.summary = %q{Dummy data generator, optimised for the UK}
|
21
|
+
|
22
|
+
if s.respond_to? :specification_version then
|
23
|
+
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
24
|
+
s.specification_version = 2
|
25
|
+
|
26
|
+
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
|
27
|
+
else
|
28
|
+
end
|
29
|
+
else
|
30
|
+
end
|
31
|
+
end
|
data/lib/archer.rb
ADDED
@@ -0,0 +1,173 @@
|
|
1
|
+
module Archer
|
2
|
+
class Address
|
3
|
+
|
4
|
+
THOROUGHFARES = %w(Albert Ark\ Royal Arncliffe Ashley Belmont Birch Blake Brenda Brierton Brigandine Browning Byron Caledonian Carlton Caroline Charles Charterhouse Chatham Chaucer Chester Claremont Clifton Courageous Dalton Derby Devon Dorset Eamont East Eldon Elm Elwick Eton Glendale Gloucester Grange Grantham Granville Grosvenor Harrow Hart Hazel Helmsley Holt Hutton Intrepid Ivy Jutland Keats Kingsley Lansdowne Larch Lawson Lime Lister Lithgo Marlborough Miller Milton Newlands North Oak Oakley Osborne Park Parkview Pine Queens Queensberry Relton Richmond Ridley Rugby Seaton Serpentine Shaker Shakespeare Shelley Shrewsbury South Southbrooke Stephenson Stockton Tennyson Thornton Tunstall Victoria Wansbeck Warrior Watt Welldeck West Westbrooke Willow Wilton Winterbottom Wooler Wordsworth Yarm York)
|
5
|
+
|
6
|
+
THOROUGHFARE_DESCRIPTORS = %w(Road Crescent Street Avenue Drive Close Grove Oval Gardens)
|
7
|
+
|
8
|
+
TOWNS = [
|
9
|
+
{:name => "Aberdeen", :postcodes => ["AB"], :dialling_code => "01224"},
|
10
|
+
{:name => "Bath", :county => "Somerset", :postcodes => ["BA"], :dialling_code => "01225"},
|
11
|
+
{:name => "Belfast", :postcodes => ["BT"], :dialling_code => "028"},
|
12
|
+
{:name => "Birmingham", :county => "Warwickshire", :postcodes => ["B"], :dialling_code => "0121"},
|
13
|
+
{:name => "Blackburn", :county => "Lancashire", :postcodes => ["BB"], :dialling_code => "01254"},
|
14
|
+
{:name => "Blackpool", :county => "Lancashire", :postcodes => ["FY"], :dialling_code => "01253"},
|
15
|
+
{:name => "Bolton", :county => "Lancashire", :postcodes => ["BL"], :dialling_code => "01204"},
|
16
|
+
{:name => "Bournemouth", :county => "Hampshire", :postcodes => ["BH"], :dialling_code => "01202"},
|
17
|
+
{:name => "Bradford", :county => "Yorkshire", :postcodes => ["BD"], :dialling_code => "01274"},
|
18
|
+
{:name => "Brighton", :county => "Sussex", :postcodes => ["BN"], :dialling_code => "01273"},
|
19
|
+
{:name => "Bristol", :county => "Gloucestershire", :postcodes => ["BS"], :dialling_code => "0117"},
|
20
|
+
{:name => "Bromley", :county => "Kent", :postcodes => ["BR"], :dialling_code => "0208"},
|
21
|
+
{:name => "Cambridge", :postcodes => ["CB"], :dialling_code => "01223"},
|
22
|
+
{:name => "Canterbury", :county => "Kent", :postcodes => ["CT"], :dialling_code => "01227"},
|
23
|
+
{:name => "Cardiff", :county => "Glamorgan", :postcodes => ["CF"], :dialling_code => "029"},
|
24
|
+
{:name => "Carlisle", :county => "Cumbria", :postcodes => ["CA"], :dialling_code => "01228"},
|
25
|
+
{:name => "Chelmsford", :county => "Essex", :postcodes => ["CM"], :dialling_code => "01245"},
|
26
|
+
{:name => "Chester", :county => "Cheshire", :postcodes => ["CH"], :dialling_code => "01244"},
|
27
|
+
{:name => "Middlesbrough", :county => "Cleveland", :postcodes => ["TS"], :dialling_code => "01642"},
|
28
|
+
{:name => "Colchester", :county => "Essex", :postcodes => ["CO"], :dialling_code => "01206"},
|
29
|
+
{:name => "Coventry", :county => "Warwickshire", :postcodes => ["CV"], :dialling_code => "024"},
|
30
|
+
{:name => "Crewe", :county => "Cheshire", :postcodes => ["CW"], :dialling_code => "01270"},
|
31
|
+
{:name => "Croydon", :county => "Surrey", :postcodes => ["CR"], :dialling_code => "0208"},
|
32
|
+
{:name => "Darlington", :county => "County Durham", :postcodes => ["DL"], :dialling_code => "01325"},
|
33
|
+
{:name => "Dartford", :county => "Kent", :postcodes => ["DA"], :dialling_code => "01322"},
|
34
|
+
{:name => "Derby", :county => "Derbyshire", :postcodes => ["DE"], :dialling_code => "01332"},
|
35
|
+
{:name => "Doncaster", :county => "Yorkshire", :postcodes => ["DN"], :dialling_code => "01302"},
|
36
|
+
{:name => "Dorchester", :county => "Dorset", :postcodes => ["DT"], :dialling_code => "01305"},
|
37
|
+
{:name => "Dudley", :county => "Worcestershire", :postcodes => ["DY"], :dialling_code => "01384"},
|
38
|
+
{:name => "Dumfries", :postcodes => ["DG"], :dialling_code => "01387"},
|
39
|
+
{:name => "Dundee", :county => "Angus", :postcodes => ["DD"], :dialling_code => "01382"},
|
40
|
+
{:name => "Durham", :county => "County Durham", :postcodes => ["DH"], :dialling_code => "0191"},
|
41
|
+
{:name => "Edinburgh", :county => "Midlothian", :postcodes => ["EH"], :dialling_code => "0131"},
|
42
|
+
{:name => "Enfield", :county => "Middlesex", :postcodes => ["EN"], :dialling_code => "0208"},
|
43
|
+
{:name => "Exeter", :county => "Devon", :postcodes => ["EX"], :dialling_code => "01392"},
|
44
|
+
{:name => "Falkirk", :county => "Stirling", :postcodes => ["FK"], :dialling_code => "01324"},
|
45
|
+
{:name => "Galashiels", :postcodes => ["TD"], :dialling_code => "01896"},
|
46
|
+
{:name => "Glasgow", :county => "Lanarkshire", :postcodes => ["G"], :dialling_code => "0141"},
|
47
|
+
{:name => "Gloucester", :county => "Gloucestershire", :postcodes => ["GL"], :dialling_code => "01452"},
|
48
|
+
{:name => "Guildford", :county => "Surrey", :postcodes => ["GU"], :dialling_code => "01483"},
|
49
|
+
{:name => "Halifax", :county => "Yorkshire", :postcodes => ["HX"], :dialling_code => "01422"},
|
50
|
+
{:name => "Harrogate", :county => "Yorkshire", :postcodes => ["HG"], :dialling_code => "01423"},
|
51
|
+
{:name => "Harrow", :county => "Middlesex", :postcodes => ["HA"], :dialling_code => "0208"},
|
52
|
+
{:name => "Hemel Hempstead", :county => "Hertfordshire", :postcodes => ["HP"], :dialling_code => "01442"},
|
53
|
+
{:name => "Hereford", :county => "Worcestershire", :postcodes => ["HR"], :dialling_code => "01432"},
|
54
|
+
{:name => "Huddersfield", :county => "Yorkshire", :postcodes => ["HD"], :dialling_code => "01484"},
|
55
|
+
{:name => "Hull", :county => "East Yorkshire", :postcodes => ["HU"], :dialling_code => "01482"},
|
56
|
+
{:name => "Ilford", :county => "Essex", :postcodes => ["IG"], :dialling_code => "0208"},
|
57
|
+
{:name => "Inverness", :postcodes => ["IV"], :dialling_code => "01463"},
|
58
|
+
{:name => "Ipswich", :county => "Suffolk", :postcodes => ["IP"], :dialling_code => "01473"},
|
59
|
+
{:name => "Kilmarnock", :county => "Ayrshire", :postcodes => ["KA"], :dialling_code => "01563"},
|
60
|
+
{:name => "Kingston upon Thames", :county => "Surrey", :postcodes => ["KT"], :dialling_code => "0208"},
|
61
|
+
{:name => "Kirkcaldy", :county => "Fife", :postcodes => ["KY"], :dialling_code => "01592"},
|
62
|
+
{:name => "Kirkwall", :county => "Orkney", :postcodes => ["KW"], :dialling_code => "01856"},
|
63
|
+
{:name => "Lancaster", :county => "Lancashire", :postcodes => ["LA"], :dialling_code => "01524"},
|
64
|
+
{:name => "Leeds", :county => "Yorkshire", :postcodes => ["LS"], :dialling_code => "0113"},
|
65
|
+
{:name => "Leicester", :county => "Leicestershire", :postcodes => ["LE"], :dialling_code => "0116"},
|
66
|
+
{:name => "Lerwick", :county => "Shetland", :postcodes => ["ZE"], :dialling_code => "01806"},
|
67
|
+
{:name => "Lincoln", :county => "Lincolnshire", :postcodes => ["LN"], :dialling_code => "01522"},
|
68
|
+
{:name => "Liverpool", :county => "Lancashire", :postcodes => ["L"], :dialling_code => "0151"},
|
69
|
+
{:name => "Llandudno", :county => "Caernarfonshire", :postcodes => ["LL"], :dialling_code => "01492"},
|
70
|
+
{:name => "London", :postcodes => ["EC", "SW", "E", "N", "NW", "SE", "W", "WC"], :dialling_code => "0207"},
|
71
|
+
{:name => "Luton", :county => "Bedfordshire", :postcodes => ["LU"], :dialling_code => "01582"},
|
72
|
+
{:name => "Manchester", :county => "Lancashire", :postcodes => ["M"], :dialling_code => "0161"},
|
73
|
+
{:name => "Milton Keynes", :county => "Buckinghamshire", :postcodes => ["MK"], :dialling_code => "01908"},
|
74
|
+
{:name => "Motherwell", :county => "Lanarkshire", :postcodes => ["ML"], :dialling_code => "01698"},
|
75
|
+
{:name => "Newcastle upon Tyne", :county => "Tyne & Wear", :postcodes => ["NE"], :dialling_code => "0191"},
|
76
|
+
{:name => "Newport", :county => "Pembrokeshire", :postcodes => ["NP"], :dialling_code => "01633"},
|
77
|
+
{:name => "Northampton", :county => "Northamptonshire", :postcodes => ["NN"], :dialling_code => "01604"},
|
78
|
+
{:name => "Norwich", :county => "Norfolk", :postcodes => ["NR"], :dialling_code => "01603"},
|
79
|
+
{:name => "Nottingham", :county => "Nottinghamshire", :postcodes => ["NG"], :dialling_code => "0115"},
|
80
|
+
{:name => "Oldham", :county => "Lancashire", :postcodes => ["OL"], :dialling_code => "0161"},
|
81
|
+
{:name => "Oxford", :county => "Oxfordshire", :postcodes => ["OX"], :dialling_code => "01865"},
|
82
|
+
{:name => "Paisley", :county => "Renfrewshire", :postcodes => ["PA"], :dialling_code => "0141"},
|
83
|
+
{:name => "Perth", :county => "Perthshire", :postcodes => ["PH"], :dialling_code => "01738"},
|
84
|
+
{:name => "Peterborough", :county => "Cambridgeshire", :postcodes => ["PE"], :dialling_code => "01733"},
|
85
|
+
{:name => "Plymouth", :county => "Devon", :postcodes => ["PL"], :dialling_code => "01752"},
|
86
|
+
{:name => "Portsmouth", :county => "Hampshire", :postcodes => ["PO"], :dialling_code => "023"},
|
87
|
+
{:name => "Preston", :county => "Lancashire", :postcodes => ["PR"], :dialling_code => "01772"},
|
88
|
+
{:name => "Reading", :county => "Berkshire", :postcodes => ["RG"], :dialling_code => "0118"},
|
89
|
+
{:name => "Redhill", :county => "Surrey", :postcodes => ["RH"], :dialling_code => "01737"},
|
90
|
+
{:name => "Rochester", :county => "Kent", :postcodes => ["ME"], :dialling_code => "01634"},
|
91
|
+
{:name => "Romford", :county => "Essex", :postcodes => ["RM"], :dialling_code => "01708"},
|
92
|
+
{:name => "Tunbridge Wells", :county => "Kent", :postcodes => ["TN"], :dialling_code => "01892"},
|
93
|
+
{:name => "Salisbury", :county => "Wiltshire", :postcodes => ["SP"], :dialling_code => "01722"},
|
94
|
+
{:name => "Sheffield", :county => "Yorkshire", :postcodes => ["S"], :dialling_code => "0114"},
|
95
|
+
{:name => "Shrewsbury", :county => "Shropshire", :postcodes => ["SY"], :dialling_code => "01743"},
|
96
|
+
{:name => "Slough", :county => "Buckinghamshire", :postcodes => ["SL"], :dialling_code => "01753"},
|
97
|
+
{:name => "Southampton", :county => "Hampshire", :postcodes => ["SO"], :dialling_code => "023"},
|
98
|
+
{:name => "Southend on Sea", :county => "Essex", :postcodes => ["SS"], :dialling_code => "01702"},
|
99
|
+
{:name => "St Albans", :county => "Hertfordshire", :postcodes => ["AL"], :dialling_code => "01727"},
|
100
|
+
{:name => "Stevenage", :county => "Hertfordshire", :postcodes => ["SG"], :dialling_code => "01438"},
|
101
|
+
{:name => "Stockport", :county => "Cheshire", :postcodes => ["SK"], :dialling_code => "0161"},
|
102
|
+
{:name => "Stoke-on-Trent", :county => "Staffordshire", :postcodes => ["ST"], :dialling_code => "01782"},
|
103
|
+
{:name => "Sunderland", :county => "Tyne & Wear", :postcodes => ["SR"], :dialling_code => "0191"},
|
104
|
+
{:name => "Sutton", :county => "West Sussex", :postcodes => ["SM"], :dialling_code => "01798"},
|
105
|
+
{:name => "Swansea", :county => "Glamorgan", :postcodes => ["SA"], :dialling_code => "01792"},
|
106
|
+
{:name => "Swindon", :county => "Wiltshire", :postcodes => ["SN"], :dialling_code => "01793"},
|
107
|
+
{:name => "Taunton", :county => "Somerset", :postcodes => ["TA"], :dialling_code => "01905"},
|
108
|
+
{:name => "Telford", :county => "Shropshire", :postcodes => ["TF"], :dialling_code => "01952"},
|
109
|
+
{:name => "Torquay", :county => "Devon", :postcodes => ["TQ"], :dialling_code => "01803"},
|
110
|
+
{:name => "Truro", :county => "Cornwall", :postcodes => ["TR"], :dialling_code => "01872"},
|
111
|
+
{:name => "Twickenham", :county => "Middlesex", :postcodes => ["TW"], :dialling_code => "0208"},
|
112
|
+
{:name => "Uxbridge", :county => "Kent", :postcodes => ["UB"], :dialling_code => "01895"},
|
113
|
+
{:name => "Wakefield", :county => "Yorkshire", :postcodes => ["WF"], :dialling_code => "01924"},
|
114
|
+
{:name => "Walsall", :county => "Staffordshire", :postcodes => ["WS"], :dialling_code => "01922"},
|
115
|
+
{:name => "Warrington", :county => "Lancashire", :postcodes => ["WA"], :dialling_code => "01925"},
|
116
|
+
{:name => "Watford", :county => "Hertfordshire", :postcodes => ["WD"], :dialling_code => "01923"},
|
117
|
+
{:name => "Wigan", :county => "Lancashire", :postcodes => ["WN"], :dialling_code => "01942"},
|
118
|
+
{:name => "Wolverhampton", :county => "Staffordshire", :postcodes => ["WV"], :dialling_code => "01902"},
|
119
|
+
{:name => "Worcester", :county => "Worcestershire", :postcodes => ["WR"], :dialling_code => "01905"},
|
120
|
+
{:name => "York", :county => "Yorkshire", :postcodes => ["YO"], :dialling_code => "01904"}
|
121
|
+
]
|
122
|
+
|
123
|
+
DEFAULT_OPTIONS = {
|
124
|
+
:street_length => 120
|
125
|
+
}
|
126
|
+
|
127
|
+
attr_reader :house_number, :street_name, :postcode
|
128
|
+
|
129
|
+
# Generates a random address
|
130
|
+
# options {
|
131
|
+
# :street_length => 120 # The maximum house number on the street
|
132
|
+
# }
|
133
|
+
def initialize(options = {})
|
134
|
+
options = DEFAULT_OPTIONS.merge(options)
|
135
|
+
@house_number = rand(options[:street_length])
|
136
|
+
@street_name = "#{THOROUGHFARES[rand(THOROUGHFARES.length)]} #{THOROUGHFARE_DESCRIPTORS[rand(THOROUGHFARE_DESCRIPTORS.length)]}"
|
137
|
+
@town = TOWNS[rand(TOWNS.length)]
|
138
|
+
@postcode = generate_postcode @town[:postcodes][rand(@town[:postcodes].length)]
|
139
|
+
end
|
140
|
+
|
141
|
+
# The street line of the Address
|
142
|
+
def street
|
143
|
+
"#{@house_number} #{@street_name}"
|
144
|
+
end
|
145
|
+
|
146
|
+
# The name of the town
|
147
|
+
def town
|
148
|
+
@town[:name]
|
149
|
+
end
|
150
|
+
|
151
|
+
# The name of the county (if applicable)
|
152
|
+
def county
|
153
|
+
@town[:county]
|
154
|
+
end
|
155
|
+
|
156
|
+
# Formats the address as a string
|
157
|
+
def to_s(separator = "\n")
|
158
|
+
[street, town, county, @postcode].compact.join(separator)
|
159
|
+
end
|
160
|
+
|
161
|
+
private
|
162
|
+
|
163
|
+
# Valid characters for the inwards part of the postcode
|
164
|
+
INCODES = ('A'..'Z').to_a - %w(C I K M O V)
|
165
|
+
|
166
|
+
# Generate a random postcode for the postal area
|
167
|
+
# Designed to be syntactically correct, but not necessarily a genuine postcode
|
168
|
+
def generate_postcode(area)
|
169
|
+
"#{area}#{rand(50)} #{rand(10)}#{INCODES[rand(INCODES.length)]}#{INCODES[rand(INCODES.length)]}"
|
170
|
+
end
|
171
|
+
|
172
|
+
end
|
173
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
module Archer
|
2
|
+
class Lipsum
|
3
|
+
|
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
|
+
|
7
|
+
def initialize(options = {:words_per_sentence => 10, :sentences_per_paragraph => 7})
|
8
|
+
@words_per_sentence, @sentences_per_paragraph = options[:words_per_sentence].to_i, options[:sentences_per_paragraph].to_i
|
9
|
+
end
|
10
|
+
|
11
|
+
def paragraphs(paragraph_count = 5)
|
12
|
+
p = ''
|
13
|
+
paragraph_count.times do
|
14
|
+
p += paragraph + "\r\n"
|
15
|
+
end
|
16
|
+
p.strip
|
17
|
+
end
|
18
|
+
|
19
|
+
def paragraph(sentence_count = nil)
|
20
|
+
sentences(sentence_count)
|
21
|
+
end
|
22
|
+
|
23
|
+
def sentences(sentence_count = nil)
|
24
|
+
s = ''
|
25
|
+
(sentence_count || @sentences_per_paragraph).times do
|
26
|
+
s += sentence + ' '
|
27
|
+
end
|
28
|
+
s.strip
|
29
|
+
end
|
30
|
+
|
31
|
+
def sentence(word_count = nil)
|
32
|
+
s = words(word_count) + '.'
|
33
|
+
s[0,1] = s[0,1].upcase
|
34
|
+
s
|
35
|
+
end
|
36
|
+
|
37
|
+
private
|
38
|
+
|
39
|
+
def words(count)
|
40
|
+
WORDS.sort_by{ Kernel.rand }[0, (count || @words_per_sentence) + rand(5)].join(' ')
|
41
|
+
end
|
42
|
+
|
43
|
+
end
|
44
|
+
end
|
data/lib/archer/name.rb
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
module Archer
|
2
|
+
class Name
|
3
|
+
|
4
|
+
MALE_TITLES = %w(Mr)
|
5
|
+
MALE_FORENAMES = %w(Aaron Adam Aidan Alex Alexander Alfie Andrew Anthony Archie Ashley Ashton Bailey Ben Benjamin Billy Bradley Brandon Callum Cameron Charles Charlie Christopher Connor Corey Daniel David Declan Dominic Dylan Edward Elliot Ellis Ethan Evan Ewan Finlay Finley Freddie Frederick Gabriel George Harley Harrison Harry Harvey Hayden Henry Isaac Jack Jacob Jake James Jamie Jason Jay Jayden Joe Joel John Jonathan Jordan Joseph Josh Joshua Jude Kai Kian Kieran Kieron Kyle Leo Leon Lewis Liam Logan Louie Louis Luca Lucas Luke Marcus Mark Mason Matthew Max Michael Mohammad Mohammed Morgan Muhammad Nathan Nicholas Noah Oliver Oscar Owen Patrick Peter Reece Reuben Rhys Riley Robert Ryan Sam Samuel Scott Sean Sebastian Spencer Taylor Theo Thomas Toby Tom Tyler William Zachary Zak)
|
6
|
+
|
7
|
+
FEMALE_TITLES = %w(Mrs Miss Ms)
|
8
|
+
FEMALE_FORENAMES = %w(Aaliyah Abbie Abby Abigail Aimee Alexandra Alice Alicia Alisha Amber Amelia Amelie Amy Anna Ava Bethany Brooke Caitlin Cerys Charlie Charlotte Chelsea Chloe Courtney Daisy Danielle Demi Eleanor Elise Elizabeth Ella Elle Ellen Ellie Eloise Emily Emma Erin Eva Eve Evie Faith Francesca Freya Gabrielle Gemma Georgia Georgina Grace Gracie Hannah Harriet Hollie Holly Imogen Isabel Isabella Isabelle Isla Isobel Jade Jasmine Jennifer Jessica Jodie Kate Katherine Katie Kayleigh Keira Kiera Lara Laura Lauren Layla Leah Libby Lilly Lily Lola Louise Lucy Lydia Maddison Madeleine Madison Maisie Martha Matilda Maya Megan Melissa Mia Millie Mollie Molly Morgan Naomi Natasha Niamh Nicole Olivia Paige Phoebe Poppy Rachel Rebecca Rosie Ruby Samantha Sarah Scarlett Shannon Sienna Skye Sofia Sophia Sophie Stephanie Summer Tegan Tia Tilly Victoria Yasmin Zara Zoe)
|
9
|
+
|
10
|
+
SURNAMES = %w(Smith Jones Williams Brown Taylor Davies Wilson Evans Thomas Johnson Roberts Walker Wright Robinson Thompson White Hughes Edwards Green Hall Wood Harris Lewis Martin Jackson Clarke Clark Turner Hill Scott Cooper Morris Ward Moore King Watson Baker Harrison Morgan Patel Young Allen Mitchell James Anderson Phillips Lee Bell Parker Davis)
|
11
|
+
|
12
|
+
attr_accessor :title, :forename, :surname
|
13
|
+
|
14
|
+
# Generates a random name
|
15
|
+
# options = {
|
16
|
+
# :male => boolean
|
17
|
+
# }
|
18
|
+
def initialize(options = {})
|
19
|
+
@male = options[:male] || rand(2) == 1
|
20
|
+
@surname = SURNAMES[rand(SURNAMES.length)]
|
21
|
+
@forename = @male ? MALE_FORENAMES[rand(MALE_FORENAMES.length)] : FEMALE_FORENAMES[rand(FEMALE_FORENAMES.length)]
|
22
|
+
@title = @male ? MALE_TITLES[rand(MALE_TITLES.length)] : FEMALE_TITLES[rand(FEMALE_TITLES.length)]
|
23
|
+
end
|
24
|
+
|
25
|
+
# Returns the full name
|
26
|
+
def to_s
|
27
|
+
"#{@title} #{@forename} #{@surname}"
|
28
|
+
end
|
29
|
+
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module Archer
|
2
|
+
class PhoneNumber
|
3
|
+
|
4
|
+
attr_accessor :area_code, :number
|
5
|
+
|
6
|
+
def initialize(area_code = nil)
|
7
|
+
@area_code = (area_code || "01#{rand(1000)}").to_s
|
8
|
+
@number = rand(10 ** (11 - @area_code.length)).to_s.ljust(11 - @area_code.length, '0')
|
9
|
+
end
|
10
|
+
|
11
|
+
def self.mobile
|
12
|
+
new("07#{rand(1000)}")
|
13
|
+
end
|
14
|
+
|
15
|
+
def to_s
|
16
|
+
"#{@area_code} #{@number}"
|
17
|
+
end
|
18
|
+
|
19
|
+
end
|
20
|
+
end
|
metadata
ADDED
@@ -0,0 +1,71 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: elandesign-archer
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Paul Smith
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2009-01-08 00:00:00 -08:00
|
13
|
+
default_executable:
|
14
|
+
dependencies: []
|
15
|
+
|
16
|
+
description: Dummy data generator, optimised for the UK
|
17
|
+
email: paul@elandesign.co.uk
|
18
|
+
executables: []
|
19
|
+
|
20
|
+
extensions: []
|
21
|
+
|
22
|
+
extra_rdoc_files:
|
23
|
+
- lib/archer/address.rb
|
24
|
+
- lib/archer/lipsum.rb
|
25
|
+
- lib/archer/name.rb
|
26
|
+
- lib/archer/phonenumber.rb
|
27
|
+
- lib/archer.rb
|
28
|
+
- README.rdoc
|
29
|
+
files:
|
30
|
+
- lib/archer/address.rb
|
31
|
+
- lib/archer/lipsum.rb
|
32
|
+
- lib/archer/name.rb
|
33
|
+
- lib/archer/phonenumber.rb
|
34
|
+
- lib/archer.rb
|
35
|
+
- Manifest
|
36
|
+
- Rakefile
|
37
|
+
- README.rdoc
|
38
|
+
- archer.gemspec
|
39
|
+
has_rdoc: true
|
40
|
+
homepage: http://github.com/elandesign/archer
|
41
|
+
post_install_message:
|
42
|
+
rdoc_options:
|
43
|
+
- --line-numbers
|
44
|
+
- --inline-source
|
45
|
+
- --title
|
46
|
+
- Archer
|
47
|
+
- --main
|
48
|
+
- README.rdoc
|
49
|
+
require_paths:
|
50
|
+
- lib
|
51
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
52
|
+
requirements:
|
53
|
+
- - ">="
|
54
|
+
- !ruby/object:Gem::Version
|
55
|
+
version: "0"
|
56
|
+
version:
|
57
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: "1.2"
|
62
|
+
version:
|
63
|
+
requirements: []
|
64
|
+
|
65
|
+
rubyforge_project: archer
|
66
|
+
rubygems_version: 1.2.0
|
67
|
+
signing_key:
|
68
|
+
specification_version: 2
|
69
|
+
summary: Dummy data generator, optimised for the UK
|
70
|
+
test_files: []
|
71
|
+
|