From daa95b3a4f3eb5131970271be3820ddb45d30022 Mon Sep 17 00:00:00 2001 From: FotoVerite Date: Sat, 17 May 2014 15:24:24 -0400 Subject: [PATCH] Adds female and male name methods. #NOTE they will return a random name and working as intended. --- Faker.js | 12 ++++++++++-- MinFaker.js | 41 +++++++++++++++++++++-------------------- Readme.md | 2 +- examples/js/Faker.js | 12 ++++++++++-- lib/name.js | 9 +++++++++ package.json | 2 +- test/name.unit.js | 22 ++++++++++++++++++++++ 7 files changed, 74 insertions(+), 26 deletions(-) diff --git a/Faker.js b/Faker.js index 1e40393bb..a4afa0d81 100644 --- a/Faker.js +++ b/Faker.js @@ -17,7 +17,7 @@ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -/*************** AUTOGENERATED @ 1400353766053 *************** +/*************** AUTOGENERATED @ 1400354606632 *************** WARNING: THIS FILE WAS AUTOGENERATED BY THE FAKER BUILD SCRIPT MODIFYING THIS FILE IS FINE, BUT YOU REALLY SHOULD BE MODIFYING THE LIBRARY DIRECTLY AND REGENERATING THIS FILE USING BUILD.js!!!! @@ -40,12 +40,20 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 'use strict'; // exported module var Faker = {}; -Faker.version = "0.7.1"; +Faker.version = "0.7.2"; Faker.Name = {}; Faker.Name.firstName = function () { return Faker.random.first_name(); }; +Faker.Name.firstNameFemale = function () { + return Faker.random.first_name(); + }; + +Faker.Name.firstNameMale = function () { + return Faker.random.first_name(); + }; + Faker.Name.lastName = function () { return Faker.random.last_name(); }; diff --git a/MinFaker.js b/MinFaker.js index 52bf2e527..4b7708e99 100644 --- a/MinFaker.js +++ b/MinFaker.js @@ -1,23 +1,24 @@ -!function(){var a={version:"0.7.1",Name:{}};a.Name.firstName=function(){return a.random.first_name()};a.Name.lastName=function(){return a.random.last_name()};a.Name.findName=function(){switch(a.random.number(8)){case 0:return a.random.name_prefix()+" "+this.firstName()+" "+this.lastName();case 1:return this.firstName()+" "+this.lastName()+" "+a.random.name_suffix()}return this.firstName()+" "+this.lastName()};a.Address={};a.Address.zipCode=function(){return g.replaceSymbolWithNumber(a.random.array_element(["#####", -"#####-####"]))};a.Address.zipCodeFormat=function(a){return g.replaceSymbolWithNumber(["#####","#####-####"][a])};a.Address.city=function(){var c;switch(a.random.number(4)){case 0:c=a.random.city_prefix()+" "+a.random.first_name()+a.random.city_suffix();break;case 1:c=a.random.city_prefix()+" "+a.random.first_name();break;case 2:c=a.random.first_name()+a.random.city_suffix();break;case 3:c=a.random.last_name()+a.random.city_suffix()}return c};a.Address.streetName=function(){var c;switch(a.random.number(2)){case 0:c= -a.random.last_name()+" "+a.random.street_suffix();break;case 1:c=a.random.first_name()+" "+a.random.street_suffix()}return c};a.Address.streetAddress=function(c){void 0===c&&(c=!1);var b="";switch(a.random.number(3)){case 0:b=g.replaceSymbolWithNumber("#####")+" "+this.streetName();break;case 1:b=g.replaceSymbolWithNumber("####")+" "+this.streetName();break;case 2:b=g.replaceSymbolWithNumber("###")+" "+this.streetName()}return c?b+" "+this.secondaryAddress():b};a.Address.secondaryAddress=function(){return g.replaceSymbolWithNumber(a.random.array_element(["Apt. ###", -"Suite ###"]))};a.Address.brState=function(c){return c?a.random.br_state_abbr():a.random.br_state()};a.Address.ukCounty=function(){return a.random.uk_county()};a.Address.ukCountry=function(){return a.random.uk_country()};a.Address.usState=function(c){return c?a.random.us_state_abbr():a.random.us_state()};a.Address.latitude=function(){return(a.random.number(18E5)/1E4-90).toFixed(4)};a.Address.longitude=function(){return(a.random.number(36E5)/1E4-180).toFixed(4)};a.PhoneNumber={};a.PhoneNumber.phoneNumber= -function(){return g.replaceSymbolWithNumber(a.random.phone_formats())};a.PhoneNumber.phoneNumberFormat=function(a){return g.replaceSymbolWithNumber(d.phone_formats[a])};a.Internet={};a.Internet.email=function(){return a.Helpers.slugify(this.userName())+"@"+a.Helpers.slugify(this.domainName())};a.Internet.userName=function(){var c;switch(a.random.number(2)){case 0:c=a.random.first_name();break;case 1:c=a.random.first_name()+a.random.array_element([".","_"])+a.random.last_name()}return c};a.Internet.domainName= -function(){return this.domainWord()+"."+a.random.domain_suffix()};a.Internet.domainWord=function(){return a.random.first_name().toLowerCase()};a.Internet.ip=function(){for(var a=[],b=0;4>b;b++)a[b]=(254*Math.random()+1).toFixed(0);return a.join(".")};a.Internet.color=function(c,b,e){b=Math.floor((a.random.number(256)+c)/2);e=Math.floor((a.random.number(256)+c)/2);c=Math.floor((a.random.number(256)+c)/2);return"#"+b.toString(16)+e.toString(16)+c.toString(16)};a.Company={};a.Company.suffixes=function(){return["Inc", -"and Sons","LLC","Group","and Daughters"]};a.Company.companyName=function(c){switch(c?c:a.random.number(3)){case 0:return a.Name.lastName()+" "+this.companySuffix();case 1:return a.Name.lastName()+"-"+a.Name.lastName();case 2:return a.Name.lastName()+", "+a.Name.lastName()+" and "+a.Name.lastName()}};a.Company.companySuffix=function(){return a.random.array_element(this.suffixes())};a.Company.catchPhrase=function(){return a.random.catch_phrase_adjective()+" "+a.random.catch_phrase_descriptor()+" "+ -a.random.catch_phrase_noun()};a.Company.bs=function(){return a.random.bs_adjective()+" "+a.random.bs_buzz()+" "+a.random.bs_noun()};a.Image={};a.Image.avatar=function(){return a.random.avatar_uri()};a.Image.imageUrl=function(a,b,e){a="http://lorempixel.com/"+(a||640)+"/"+(b||480);"undefined"!==typeof e&&(a+="/"+e);return a};a.Image.abstractImage=function(a,b){return this.imageUrl(a,b,"abstract")};a.Image.animals=function(a,b){return this.imageUrl(a,b,"animals")};a.Image.business=function(a,b){return this.imageUrl(a, -b,"business")};a.Image.cats=function(a,b){return this.imageUrl(a,b,"cats")};a.Image.city=function(a,b){return this.imageUrl(a,b,"city")};a.Image.food=function(a,b){return this.imageUrl(a,b,"food")};a.Image.nightlife=function(a,b){return this.imageUrl(a,b,"nightlife")};a.Image.fashion=function(a,b){return this.imageUrl(a,b,"fashion")};a.Image.people=function(a,b){return this.imageUrl(a,b,"people")};a.Image.nature=function(a,b){return this.imageUrl(a,b,"nature")};a.Image.sports=function(a,b){return this.imageUrl(a, -b,"sports")};a.Image.technics=function(a,b){return this.imageUrl(a,b,"technics")};a.Image.transport=function(a,b){return this.imageUrl(a,b,"transport")};a.Lorem={};a.Lorem.words=function(a){"undefined"==typeof a&&(a=3);return g.shuffle(d.lorem).slice(0,a)};a.Lorem.sentence=function(c,b){"undefined"==typeof c&&(c=3);return this.words(c+a.random.number(7)).join(" ")};a.Lorem.sentences=function(a){"undefined"==typeof a&&(a=3);var b=[];for(a;0=b)throw{name:"TreeParamError",message:"width must be greater than zero"};var f=this.clone(e),d;for(d in f)if(f.hasOwnProperty(d)){var g=null;if("__RECURSE__"!== -f[d])g=eval(f[d]);else if(0!==a)for(var g=[],h=1,h="function"==typeof b?b():b,k=0;kb;b++)a[b]=(254*Math.random()+1).toFixed(0);return a.join(".")};a.Internet.color=function(c,b,e){b=Math.floor((a.random.number(256)+ +c)/2);e=Math.floor((a.random.number(256)+c)/2);c=Math.floor((a.random.number(256)+c)/2);return"#"+b.toString(16)+e.toString(16)+c.toString(16)};a.Company={};a.Company.suffixes=function(){return["Inc","and Sons","LLC","Group","and Daughters"]};a.Company.companyName=function(c){switch(c?c:a.random.number(3)){case 0:return a.Name.lastName()+" "+this.companySuffix();case 1:return a.Name.lastName()+"-"+a.Name.lastName();case 2:return a.Name.lastName()+", "+a.Name.lastName()+" and "+a.Name.lastName()}}; +a.Company.companySuffix=function(){return a.random.array_element(this.suffixes())};a.Company.catchPhrase=function(){return a.random.catch_phrase_adjective()+" "+a.random.catch_phrase_descriptor()+" "+a.random.catch_phrase_noun()};a.Company.bs=function(){return a.random.bs_adjective()+" "+a.random.bs_buzz()+" "+a.random.bs_noun()};a.Image={};a.Image.avatar=function(){return a.random.avatar_uri()};a.Image.imageUrl=function(a,b,e){a="http://lorempixel.com/"+(a||640)+"/"+(b||480);"undefined"!==typeof e&& +(a+="/"+e);return a};a.Image.abstractImage=function(a,b){return this.imageUrl(a,b,"abstract")};a.Image.animals=function(a,b){return this.imageUrl(a,b,"animals")};a.Image.business=function(a,b){return this.imageUrl(a,b,"business")};a.Image.cats=function(a,b){return this.imageUrl(a,b,"cats")};a.Image.city=function(a,b){return this.imageUrl(a,b,"city")};a.Image.food=function(a,b){return this.imageUrl(a,b,"food")};a.Image.nightlife=function(a,b){return this.imageUrl(a,b,"nightlife")};a.Image.fashion= +function(a,b){return this.imageUrl(a,b,"fashion")};a.Image.people=function(a,b){return this.imageUrl(a,b,"people")};a.Image.nature=function(a,b){return this.imageUrl(a,b,"nature")};a.Image.sports=function(a,b){return this.imageUrl(a,b,"sports")};a.Image.technics=function(a,b){return this.imageUrl(a,b,"technics")};a.Image.transport=function(a,b){return this.imageUrl(a,b,"transport")};a.Lorem={};a.Lorem.words=function(a){"undefined"==typeof a&&(a=3);return g.shuffle(d.lorem).slice(0,a)};a.Lorem.sentence= +function(c,b){"undefined"==typeof c&&(c=3);return this.words(c+a.random.number(7)).join(" ")};a.Lorem.sentences=function(a){"undefined"==typeof a&&(a=3);var b=[];for(a;0=b)throw{name:"TreeParamError",message:"width must be greater than zero"};var f=this.clone(e),d;for(d in f)if(f.hasOwnProperty(d)){var g=null;if("__RECURSE__"!==f[d])g=eval(f[d]);else if(0!==a)for(var g=[],h=1,h="function"==typeof b?b():b,k=0;k
  • Name
    • firstName
    • lastName
    • findName
  • Address
    • zipCode
    • zipCodeFormat
    • city
    • streetName
    • streetAddress
    • secondaryAddress
    • brState
    • ukCounty
    • ukCountry
    • usState
    • latitude
    • longitude
  • PhoneNumber
    • phoneNumber
    • phoneNumberFormat
  • Internet
    • email
    • userName
    • domainName
    • domainWord
    • ip
    • color
  • Company
    • suffixes
    • companyName
    • companySuffix
    • catchPhrase
    • bs
  • Image
    • avatar
    • imageUrl
    • abstractImage
    • animals
    • business
    • cats
    • city
    • food
    • nightlife
    • fashion
    • people
    • nature
    • sports
    • technics
    • transport
  • Lorem
    • words
    • sentence
    • sentences
    • paragraph
    • paragraphs
  • Helpers
    • randomNumber
    • randomize
    • slugify
    • replaceSymbolWithNumber
    • shuffle
    • createCard
    • userCard
  • Tree
    • clone
    • createTree
  • Date
    • past
    • future
    • between
    • recent
  • random
    • number
    • array_element
    • city_prefix
    • city_suffix
    • street_suffix
    • br_state
    • br_state_abbr
    • us_state
    • us_state_abbr
    • uk_county
    • uk_country
    • first_name
    • last_name
    • name_prefix
    • name_suffix
    • catch_phrase_adjective
    • catch_phrase_descriptor
    • catch_phrase_noun
    • bs_adjective
    • bs_buzz
    • bs_noun
    • phone_formats
    • domain_suffix
    • avatar_uri
  • definitions
    • first_name
    • last_name
    • name_prefix
    • name_suffix
    • br_state
    • br_state_abbr
    • us_state
    • us_state_abbr
    • city_prefix
    • city_suffix
    • street_suffix
    • uk_county
    • uk_country
    • catch_phrase_adjective
    • catch_phrase_descriptor
    • catch_phrase_noun
    • bs_adjective
    • bs_buzz
    • bs_noun
    • domain_suffix
    • lorem
    • phone_formats
    • avatar_uri
  • +
    • Name
      • firstName
      • firstNameFemale
      • firstNameMale
      • lastName
      • findName
    • Address
      • zipCode
      • zipCodeFormat
      • city
      • streetName
      • streetAddress
      • secondaryAddress
      • brState
      • ukCounty
      • ukCountry
      • usState
      • latitude
      • longitude
    • PhoneNumber
      • phoneNumber
      • phoneNumberFormat
    • Internet
      • email
      • userName
      • domainName
      • domainWord
      • ip
      • color
    • Company
      • suffixes
      • companyName
      • companySuffix
      • catchPhrase
      • bs
    • Image
      • avatar
      • imageUrl
      • abstractImage
      • animals
      • business
      • cats
      • city
      • food
      • nightlife
      • fashion
      • people
      • nature
      • sports
      • technics
      • transport
    • Lorem
      • words
      • sentence
      • sentences
      • paragraph
      • paragraphs
    • Helpers
      • randomNumber
      • randomize
      • slugify
      • replaceSymbolWithNumber
      • shuffle
      • createCard
      • userCard
    • Tree
      • clone
      • createTree
    • Date
      • past
      • future
      • between
      • recent
    • random
      • number
      • array_element
      • city_prefix
      • city_suffix
      • street_suffix
      • br_state
      • br_state_abbr
      • us_state
      • us_state_abbr
      • uk_county
      • uk_country
      • first_name
      • last_name
      • name_prefix
      • name_suffix
      • catch_phrase_adjective
      • catch_phrase_descriptor
      • catch_phrase_noun
      • bs_adjective
      • bs_buzz
      • bs_noun
      • phone_formats
      • domain_suffix
      • avatar_uri
    • definitions
      • first_name
      • last_name
      • name_prefix
      • name_suffix
      • br_state
      • br_state_abbr
      • us_state
      • us_state_abbr
      • city_prefix
      • city_suffix
      • street_suffix
      • uk_county
      • uk_country
      • catch_phrase_adjective
      • catch_phrase_descriptor
      • catch_phrase_noun
      • bs_adjective
      • bs_buzz
      • bs_noun
      • domain_suffix
      • lorem
      • phone_formats
      • avatar_uri
    ## Tests npm install . make test diff --git a/examples/js/Faker.js b/examples/js/Faker.js index 1e40393bb..a4afa0d81 100644 --- a/examples/js/Faker.js +++ b/examples/js/Faker.js @@ -17,7 +17,7 @@ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -/*************** AUTOGENERATED @ 1400353766053 *************** +/*************** AUTOGENERATED @ 1400354606632 *************** WARNING: THIS FILE WAS AUTOGENERATED BY THE FAKER BUILD SCRIPT MODIFYING THIS FILE IS FINE, BUT YOU REALLY SHOULD BE MODIFYING THE LIBRARY DIRECTLY AND REGENERATING THIS FILE USING BUILD.js!!!! @@ -40,12 +40,20 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 'use strict'; // exported module var Faker = {}; -Faker.version = "0.7.1"; +Faker.version = "0.7.2"; Faker.Name = {}; Faker.Name.firstName = function () { return Faker.random.first_name(); }; +Faker.Name.firstNameFemale = function () { + return Faker.random.first_name(); + }; + +Faker.Name.firstNameMale = function () { + return Faker.random.first_name(); + }; + Faker.Name.lastName = function () { return Faker.random.last_name(); }; diff --git a/lib/name.js b/lib/name.js index 48759dcf9..d66e13aff 100644 --- a/lib/name.js +++ b/lib/name.js @@ -5,6 +5,15 @@ var _name = { return Faker.random.first_name(); }, + //Working as intended + firstNameFemale: function () { + return Faker.random.first_name(); + }, + //Working as intended + firstNameMale: function () { + return Faker.random.first_name(); + }, + lastName: function () { return Faker.random.last_name(); }, diff --git a/package.json b/package.json index 8c4f5903e..bd914b38d 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "Faker", "description": "Generate massive amounts of fake contextual data", - "version": "0.7.1", + "version": "0.7.2", "contributors": [ "Marak Squires ", "Matthew Bergman " diff --git a/test/name.unit.js b/test/name.unit.js index 8563f0db9..80d8256d5 100644 --- a/test/name.unit.js +++ b/test/name.unit.js @@ -17,6 +17,28 @@ describe("name.js", function () { }); }); + describe("firstNameFemale()", function () { + it("returns a random name", function () { + sinon.stub(Faker.random, 'first_name').returns('foo'); + var first_name = Faker.Name.firstNameFemale(); + + assert.equal(first_name, 'foo'); + + Faker.random.first_name.restore(); + }); + }); + + describe("firstNameMale()", function () { + it("returns a random name", function () { + sinon.stub(Faker.random, 'first_name').returns('foo'); + var first_name = Faker.Name.firstNameMale(); + + assert.equal(first_name, 'foo'); + + Faker.random.first_name.restore(); + }); + }); + describe("lastName()", function () { it("returns a random name", function () {