Permalink
Browse files

Added UK addresses [Caius Durling]

  • Loading branch information...
1 parent a943c95 commit 741ea0127f4000fb22f41f2a08b6bb2d4100eb7e @stympy stympy committed Jan 2, 2008
Showing with 23 additions and 0 deletions.
  1. +8 −0 lib/faker.rb
  2. +15 −0 lib/faker/address.rb
View
@@ -13,4 +13,12 @@ module Faker
def self.numerify(number_string)
number_string.gsub(/#/) { rand(10).to_s }
end
+
+ def self.letterify(letter_string)
+ letter_string.gsub(/\?/) { ('a'..'z').to_a.rand }
+ end
+
+ def self.bothify(string)
+ self.letterify(self.numerify(string))
+ end
end
View
@@ -35,6 +35,21 @@ def street_address
].rand.call)
end
+ # UK Variants
+ def uk_county
+ ['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
+ end
+
+ def uk_country
+ ['England', 'Scotland', 'Wales', 'Northern Ireland'].rand
+ end
+
+ def uk_postcode
+ Faker.bothify([
+ Proc.new { '??# #??' },
+ Proc.new { '??## #??' }
+ ].rand.call).upcase
+ end
end
end
end

0 comments on commit 741ea01

Please sign in to comment.