Skip to content

Commit

Permalink
Added Canadian provinces to address forgery.
Browse files Browse the repository at this point in the history
  • Loading branch information
rtlechow committed Feb 6, 2009
1 parent ab04eda commit 105c614
Show file tree
Hide file tree
Showing 5 changed files with 59 additions and 1 deletion.
2 changes: 1 addition & 1 deletion forgery.gemspec
Expand Up @@ -9,7 +9,7 @@ Gem::Specification.new do |s|
s.date = %q{2008-11-30}
s.description = %q{TODO}
s.email = %q{nate@sevenwire.com}
s.files = ["README.markdown", "VERSION.yml", "generators/forgery", "generators/forgery/forgery_generator.rb", "generators/forgery/USAGE", "lib/dictionaries", "lib/dictionaries/cities", "lib/dictionaries/colors", "lib/dictionaries/company_names", "lib/dictionaries/countries", "lib/dictionaries/female_first_names", "lib/dictionaries/frequencies", "lib/dictionaries/genders", "lib/dictionaries/languages", "lib/dictionaries/last_names", "lib/dictionaries/lorem_ipsum", "lib/dictionaries/male_first_names", "lib/dictionaries/name_suffixes", "lib/dictionaries/name_titles", "lib/dictionaries/races", "lib/dictionaries/shirt_sizes", "lib/dictionaries/state_abbrevs", "lib/dictionaries/states", "lib/dictionaries/street_suffixes", "lib/dictionaries/streets", "lib/dictionaries/top_level_domains", "lib/dictionaries.rb", "lib/extensions", "lib/extensions/array.rb", "lib/extensions/hash.rb", "lib/extensions/range.rb", "lib/extensions/string.rb", "lib/file_reader.rb", "lib/forgeries", "lib/forgeries/address_forgery.rb", "lib/forgeries/basic_forgery.rb", "lib/forgeries/internet_forgery.rb", "lib/forgeries/lorem_ipsum_forgery.rb", "lib/forgeries/monetary_forgery.rb", "lib/forgeries/name_forgery.rb", "lib/forgeries/personal_forgery.rb", "lib/forgery.rb", "lib/formats", "lib/formats/phone", "lib/formats/street_number", "lib/formats/zip", "lib/formats.rb", "spec/dictionaries_spec.rb", "spec/extensions", "spec/extensions/array_spec.rb", "spec/extensions/range_spec.rb", "spec/extensions/string_spec.rb", "spec/file_reader_spec.rb", "spec/forgeries", "spec/forgeries/address_forgery_spec.rb", "spec/forgeries/basic_forgery_spec.rb", "spec/forgeries/internet_forgery_spec.rb", "spec/forgeries/lorem_ipsum_forgery_spec.rb", "spec/forgeries/monetary_forgery_spec.rb", "spec/forgeries/name_forgery_spec.rb", "spec/forgeries/personal_forgery_spec.rb", "spec/forgery_spec.rb", "spec/formats_spec.rb", "spec/spec_helper.rb"]
s.files = ["README.markdown", "VERSION.yml", "generators/forgery", "generators/forgery/forgery_generator.rb", "generators/forgery/USAGE", "lib/dictionaries", "lib/dictionaries/cities", "lib/dictionaries/colors", "lib/dictionaries/company_names", "lib/dictionaries/countries", "lib/dictionaries/female_first_names", "lib/dictionaries/frequencies", "lib/dictionaries/genders", "lib/dictionaries/languages", "lib/dictionaries/last_names", "lib/dictionaries/lorem_ipsum", "lib/dictionaries/male_first_names", "lib/dictionaries/name_suffixes", "lib/dictionaries/name_titles", "lib/dictionaries/province_abbrevs", "lib/dictionaries/provinces", "lib/dictionaries/races", "lib/dictionaries/shirt_sizes", "lib/dictionaries/state_abbrevs", "lib/dictionaries/states", "lib/dictionaries/street_suffixes", "lib/dictionaries/streets", "lib/dictionaries/top_level_domains", "lib/dictionaries.rb", "lib/extensions", "lib/extensions/array.rb", "lib/extensions/hash.rb", "lib/extensions/range.rb", "lib/extensions/string.rb", "lib/file_reader.rb", "lib/forgeries", "lib/forgeries/address_forgery.rb", "lib/forgeries/basic_forgery.rb", "lib/forgeries/internet_forgery.rb", "lib/forgeries/lorem_ipsum_forgery.rb", "lib/forgeries/monetary_forgery.rb", "lib/forgeries/name_forgery.rb", "lib/forgeries/personal_forgery.rb", "lib/forgery.rb", "lib/formats", "lib/formats/phone", "lib/formats/street_number", "lib/formats/zip", "lib/formats.rb", "spec/dictionaries_spec.rb", "spec/extensions", "spec/extensions/array_spec.rb", "spec/extensions/range_spec.rb", "spec/extensions/string_spec.rb", "spec/file_reader_spec.rb", "spec/forgeries", "spec/forgeries/address_forgery_spec.rb", "spec/forgeries/basic_forgery_spec.rb", "spec/forgeries/internet_forgery_spec.rb", "spec/forgeries/lorem_ipsum_forgery_spec.rb", "spec/forgeries/monetary_forgery_spec.rb", "spec/forgeries/name_forgery_spec.rb", "spec/forgeries/personal_forgery_spec.rb", "spec/forgery_spec.rb", "spec/formats_spec.rb", "spec/spec_helper.rb"]
s.homepage = %q{http://github.com/sevenwire/forgery}
s.require_paths = ["lib"]
s.rubygems_version = %q{1.3.1}
Expand Down
13 changes: 13 additions & 0 deletions lib/dictionaries/province_abbrevs
@@ -0,0 +1,13 @@
ON
QC
NS
NB
MB
BC
PE
SK
AB
NL
NT
YT
NU
13 changes: 13 additions & 0 deletions lib/dictionaries/provinces
@@ -0,0 +1,13 @@
Ontario
Quebec
Nova Scotia
New Brunswick
Manitoba
British Columbia
Prince Edward Island
Saskatchewan
Alberta
Newfoundland and Labrador
Northwest Territories
Yukon
Nunavut
22 changes: 22 additions & 0 deletions lib/forgeries/address_forgery.rb
Expand Up @@ -79,6 +79,28 @@ def self.state_abbrev
dictionaries[:state_abbrevs].random
end

# Gets a random Canadian province or territory out of the 'provinces' dictionary.
#
# AddressForgery.province
# # => "Ontario"
#
# AddressForgery.province
# # => "Northwest Territories"
def self.province
dictionaries[:provinces].random
end

# Gets a random Canadian province or territory abbreviation out of the 'province_abbrev' dictionary.
#
# AddressForgery.province_abbrev
# # => "ON"
#
# AddressForgery.province_abbrev
# # => "NT"
def self.province_abbrev
dictionaries[:province_abbrevs].random
end

# Gets one of the formats from 'zip_formats' and converts it to numbers.
#
# AddressForgery.zip
Expand Down
10 changes: 10 additions & 0 deletions spec/forgeries/address_forgery_spec.rb
Expand Up @@ -52,6 +52,16 @@
Forgery.dictionaries[:state_abbrevs].should include(state_abbrev)
end

it "should return a random Canadian province or territory" do
province = AddressForgery.province
Forgery.dictionaries[:provinces].should include(province)
end

it "should return a random Canadian province or territory abbreviation" do
province_abbrev = AddressForgery.province_abbrev
Forgery.dictionaries[:province_abbrevs].should include(province_abbrev)
end

it "should return a random country" do
country = AddressForgery.country
Forgery.dictionaries[:countries].should include(country)
Expand Down

0 comments on commit 105c614

Please sign in to comment.