Skip to content
This repository has been archived by the owner on May 1, 2023. It is now read-only.

Commit

Permalink
rename to project-name-generator
Browse files Browse the repository at this point in the history
  • Loading branch information
aceakash committed Nov 17, 2014
1 parent 09d0053 commit 2ef3ffc
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 45 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -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'
Expand Down
9 changes: 6 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,17 +1,20 @@
{
"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": {
"test": "gulp test"
},
"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",
Expand Down
62 changes: 31 additions & 31 deletions spec/generator.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
});
});
Expand Down
16 changes: 8 additions & 8 deletions src/generator.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

0 comments on commit 2ef3ffc

Please sign in to comment.