From 16de1b7e1100c6c1d351ce54bc52ad51ee9c313b Mon Sep 17 00:00:00 2001 From: portse Date: Wed, 8 Jul 2015 21:52:23 -0400 Subject: When the locales were split out (commit: 760e50ff2d04a95c990aff98ab84a6c17fb3854c), the en_CA locale lost its zipFormat definition added in PR #173. * Reverted back to simply using the postcode definition. * Updated zipCode function to use that definition for the locale. * Ensure en_CA locale has a postcode definition file. --- lib/address.js | 22 +++++++++++----------- lib/index.js | 2 +- lib/locales/en_CA/address/index.js | 1 + lib/locales/en_CA/address/postcode.js | 3 +++ 4 files changed, 16 insertions(+), 12 deletions(-) create mode 100644 lib/locales/en_CA/address/postcode.js (limited to 'lib') diff --git a/lib/address.js b/lib/address.js index d53e0ef8..a921903f 100644 --- a/lib/address.js +++ b/lib/address.js @@ -2,17 +2,17 @@ function Address (faker) { var f = faker.fake, Helpers = faker.helpers; - this.zipCode = function (format) { - // if zip format is not specified, use the zip format defined for the locale - if (typeof format === 'undefined') { - var localeFormat = faker.definitions.address.zipFormat; - if (typeof localeFormat === 'string') { - format = localeFormat; - } else { - format = faker.random.array_element(localeFormat); - } - } - return Helpers.replaceSymbols(format); + this.zipCode = function(format) { + // if zip format is not specified, use the zip format defined for the locale + if (typeof format === 'undefined') { + var localeFormat = faker.definitions.address.postcode; + if (typeof localeFormat === 'string') { + format = localeFormat; + } else { + format = faker.random.array_element(localeFormat); + } + } + return Helpers.replaceSymbols(format); } this.city = function (format) { diff --git a/lib/index.js b/lib/index.js index 281befed..260f1e4d 100644 --- a/lib/index.js +++ b/lib/index.js @@ -80,7 +80,7 @@ function Faker (opts) { var _definitions = { "name": ["first_name", "last_name", "prefix", "suffix", "title", "male_first_name", "female_first_name", "male_middle_name", "female_middle_name", "male_last_name", "female_last_name"], - "address": ["city_prefix", "city_suffix", "street_suffix", "county", "country", "country_code", "state", "state_abbr", "street_prefix", "zipFormat"], + "address": ["city_prefix", "city_suffix", "street_suffix", "county", "country", "country_code", "state", "state_abbr", "street_prefix", "postcode"], "company": ["adjective", "noun", "descriptor", "bs_adjective", "bs_noun", "bs_verb", "suffix"], "lorem": ["words"], "hacker": ["abbreviation", "adjective", "noun", "verb", "ingverb"], diff --git a/lib/locales/en_CA/address/index.js b/lib/locales/en_CA/address/index.js index 8eaaa997..5b43a214 100644 --- a/lib/locales/en_CA/address/index.js +++ b/lib/locales/en_CA/address/index.js @@ -3,3 +3,4 @@ module['exports'] = address; address.state = require("./state"); address.state_abbr = require("./state_abbr"); address.default_country = require("./default_country"); +address.postcode = require('./postcode.js'); diff --git a/lib/locales/en_CA/address/postcode.js b/lib/locales/en_CA/address/postcode.js new file mode 100644 index 00000000..cd73ce97 --- /dev/null +++ b/lib/locales/en_CA/address/postcode.js @@ -0,0 +1,3 @@ +module["exports"] = [ + "?#? #?#" +]; -- cgit v1.2.3 From e91642b0cf6d93cbd8bf5e51b95642828a3acd62 Mon Sep 17 00:00:00 2001 From: portse Date: Wed, 8 Jul 2015 21:53:39 -0400 Subject: * Removed unused zipFormat definition from the 'en' locale. --- lib/locales/en/address/zipFormat.js | 4 ---- 1 file changed, 4 deletions(-) delete mode 100644 lib/locales/en/address/zipFormat.js (limited to 'lib') diff --git a/lib/locales/en/address/zipFormat.js b/lib/locales/en/address/zipFormat.js deleted file mode 100644 index f233d46c..00000000 --- a/lib/locales/en/address/zipFormat.js +++ /dev/null @@ -1,4 +0,0 @@ -module["exports"] = [ - "#####", - "#####-####" -]; -- cgit v1.2.3 From 7261c18a434f3d4f9663dd4f78f5132a5a40681c Mon Sep 17 00:00:00 2001 From: portse Date: Wed, 8 Jul 2015 22:09:44 -0400 Subject: * Removed import of the zipFormat module. --- lib/locales/en/address/index.js | 1 - 1 file changed, 1 deletion(-) (limited to 'lib') diff --git a/lib/locales/en/address/index.js b/lib/locales/en/address/index.js index a71a498e..575f1d46 100644 --- a/lib/locales/en/address/index.js +++ b/lib/locales/en/address/index.js @@ -1,6 +1,5 @@ var address = {}; module['exports'] = address; -address.zipFormat = require("./zipFormat"); address.city_prefix = require("./city_prefix"); address.city_suffix = require("./city_suffix"); address.county = require("./county"); -- cgit v1.2.3