From 2ef3ffcacc991003607ba8b56b3d7e00dc13ab0b Mon Sep 17 00:00:00 2001 From: Akash Date: Mon, 17 Nov 2014 11:24:02 +0000 Subject: [PATCH] rename to project-name-generator --- README.md | 6 ++-- package.json | 9 ++++-- spec/generator.spec.js | 62 +++++++++++++++++++++--------------------- src/generator.js | 16 +++++------ 4 files changed, 48 insertions(+), 45 deletions(-) diff --git a/README.md b/README.md index 4d708d2..c51f20d 100644 --- a/README.md +++ b/README.md @@ -1,13 +1,13 @@ -# App Name Generator +# Project Name Generator Generate quirky names like "spiffy-waterfall", "sassy-bread", "mature-dew-8239" to use wherever you need a random but memorable name. ###Install -`npm install app-name-generator --save` +`npm install project-name-generator --save` ###Quick Start ``` -var generate = require('app-name-generator').generate; +var generate = require('project-name-generator').generate; generate().dashed; // 'sassy-bread' diff --git a/package.json b/package.json index 275c9fa..98b0b9f 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { - "name": "app-name-generator", - "version": "1.0.1", + "name": "project-name-generator", + "version": "1.0.0", "description": "Generate a random, unique, heroku-like name for your app/project/server etc. e.g. \"resonant-silence\"", "main": "src/generator.js", "scripts": { @@ -8,10 +8,13 @@ }, "repository": { "type": "git", - "url": "git://github.com/aceakash/app-name-generator.git" + "url": "git://github.com/aceakash/project-name-generator.git" }, "keywords": [ "heroku", + "project", + "server", + "app", "name", "generate", "unique", diff --git a/spec/generator.spec.js b/spec/generator.spec.js index 62698c9..d6e11e2 100644 --- a/spec/generator.spec.js +++ b/spec/generator.spec.js @@ -14,98 +14,98 @@ describe('generator', function () { describe('when called with no argument', function () { - var appName; + var projName; beforeEach(function () { - appName = generate(); + projName = generate(); }); it('returns an object with keys: dashed, spaced, raw', function () { - expect(appName).toBeDefined(); - expect(appName.dashed).toBeDefined(); - expect(appName.spaced).toBeDefined(); - expect(appName.raw).toBeDefined(); + expect(projName).toBeDefined(); + expect(projName.dashed).toBeDefined(); + expect(projName.spaced).toBeDefined(); + expect(projName.raw).toBeDefined(); }); it('has a property raw which is an array of two strings', function () { - expect(appName.raw.length).toBe(2); - expect(typeof appName.raw[0]).toBe('string'); - expect(typeof appName.raw[1]).toBe('string'); + expect(projName.raw.length).toBe(2); + expect(typeof projName.raw[0]).toBe('string'); + expect(typeof projName.raw[1]).toBe('string'); }); it('has an array raw, the first item of which is from the adjectives array', function () { - expect(_.contains(adjectives, appName.raw[0])).toBe(true); + expect(_.contains(adjectives, projName.raw[0])).toBe(true); }); it('has an array raw, the second item of which is from the nouns array', function () { - expect(_.contains(nouns, appName.raw[1])).toBe(true); + expect(_.contains(nouns, projName.raw[1])).toBe(true); }); it("has a property dashed, which is a string of raw's items joined with a dash", function () { - expect(appName.dashed).toBe(appName.raw.join('-')); + expect(projName.dashed).toBe(projName.raw.join('-')); }); it("has a property spaced, which is a string of raw's items joined with a space", function () { - expect(appName.spaced).toBe(appName.raw.join(' ')); + expect(projName.spaced).toBe(projName.raw.join(' ')); }); }); describe('when called with a truthy value as the sole argument', function () { - var appName; + var projName; beforeEach(function () { - appName = generate(true); + projName = generate(true); }); it('has a property raw which is an array of two strings and a number', function () { - expect(appName.raw.length).toBe(3); - expect(typeof appName.raw[0]).toBe('string'); - expect(typeof appName.raw[1]).toBe('string'); - expect(typeof appName.raw[2]).toBe('number'); + expect(projName.raw.length).toBe(3); + expect(typeof projName.raw[0]).toBe('string'); + expect(typeof projName.raw[1]).toBe('string'); + expect(typeof projName.raw[2]).toBe('number'); }); it('has an array raw, the third item of which is a number from 1 to 9999', function () { - var num = appName.raw[2]; + var num = projName.raw[2]; expect(num).toBeDefined(); expect(num).toBeLessThan(10000); expect(num).toBeGreaterThan(0); }); it("has a property dashed, which is a string of raw's items joined with a dash", function () { - expect(appName.dashed).toBe(appName.raw.join('-')); + expect(projName.dashed).toBe(projName.raw.join('-')); }); it("has a property spaced, which is a string of raw's items joined with a space", function () { - expect(appName.spaced).toBe(appName.raw.join(' ')); + expect(projName.spaced).toBe(projName.raw.join(' ')); }); it('has the third item in "raw", when called with other truthy values', function () { _.each([generate(1), generate('something'), generate({one: 1})], - function (appName) { - expect(typeof appName.raw[2]).toBe('number'); + function (projName) { + expect(typeof projName.raw[2]).toBe('number'); }); }); }); describe('when called with a falsey value as the sole argument', function () { - var appName; + var projName; beforeEach(function () { - appName = generate(false); + projName = generate(false); }); it('has a property raw with only two string items', function () { - expect(appName.raw.length).toBe(2); - expect(typeof appName.raw[0]).toBe('string'); - expect(typeof appName.raw[1]).toBe('string'); + expect(projName.raw.length).toBe(2); + expect(typeof projName.raw[0]).toBe('string'); + expect(typeof projName.raw[1]).toBe('string'); }); it('has only two items in "raw", when called with other falsey values', function () { _.each([generate(0), generate(''), generate(null)], - function (appName) { - expect(appName.raw.length).toBe(2); + function (projName) { + expect(projName.raw.length).toBe(2); }); }); }); diff --git a/src/generator.js b/src/generator.js index 0c788e5..2bde2ff 100644 --- a/src/generator.js +++ b/src/generator.js @@ -3,23 +3,23 @@ var _ = require('lodash'), adjectives = require('../src/adjectives'); module.exports.generate = function (addNumberSuffix) { - var rawAppName = getRawAppName(!!addNumberSuffix); + var rawProjName = getRawProjName(!!addNumberSuffix); return { - spaced: rawAppName.join(' '), - dashed: rawAppName.join('-'), - raw: rawAppName + spaced: rawProjName.join(' '), + dashed: rawProjName.join('-'), + raw: rawProjName }; }; -function getRawAppName(addNumberSuffix) { - var rawAppName = [ +function getRawProjName(addNumberSuffix) { + var rawProjName = [ _.sample(adjectives).toLowerCase(), _.sample(nouns).toLowerCase() ]; if (addNumberSuffix) { - rawAppName.push( _.random(1, 9999) ); + rawProjName.push( _.random(1, 9999) ); } - return rawAppName; + return rawProjName; }