Skip to content

Commit

Permalink
lorem partial working
Browse files Browse the repository at this point in the history
  • Loading branch information
FotoVerite committed May 15, 2010
1 parent 1b195d0 commit c6dbabb
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 23 deletions.
5 changes: 5 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ Faker.Address = require('./lib/address');
Faker.PhoneNumber = require('./lib/phone_number');
Faker.Internet = require('./lib/internet');
Faker.Company = require('./lib/company');
Faker.Lorem = require('./lib/lorem');


var Helper = require('helper');;
Expand All @@ -30,6 +31,10 @@ sys.puts(JSON.stringify(Faker.Internet.domainName()));
sys.puts(JSON.stringify(Faker.Company.companyName()));
sys.puts(JSON.stringify(Faker.Company.catchPhrase()));
sys.puts(JSON.stringify(Faker.Company.bs()));
sys.puts(JSON.stringify(Faker.Lorem.words()));
sys.puts(JSON.stringify(Faker.Lorem.sentence()));
sys.puts(JSON.stringify(Faker.Lorem.sentences()));




45 changes: 22 additions & 23 deletions lib/lorem.js
Original file line number Diff line number Diff line change
@@ -1,26 +1,26 @@
var Helper = require('../helper');
var definitions = require('../lib/definitions');

function words(num){
return Helper.shuffle(lorem);
exports.words = function(num){
if( typeof num == 'undefined'){ var num = 3;}
return Helper.shuffle(definitions.lorem).slice(0, num);
//Words.shuffle[0, num]
}
};

function sentence(word_count){
return 'sentences';
exports.sentence = function(wordCount){
if( typeof wordCount == 'undefined'){ var wordCount = 3;}

return this.words(wordCount + Helper.randomNumber(7)).join(' ').capitalize();
//words(word_count + rand(6)).join(' ').capitalize + '.'
}

function sentences(sentence_count){

return 'sentences';
/*
returning([]) do |sentences|
1.upto(sentence_count) do
sentences << sentence
end
*/

};

exports.sentences = function(sentenceCount){
if( typeof sentenceCount == 'undefined'){ var sentenceCount = 3;}
var sentences = "";
for(sentenceCount; sentenceCount >= 0; sentenceCount--){
sentences = sentences + this.sentence();
}
return sentences;
}

function paragraph(sentence_count){
Expand All @@ -37,9 +37,8 @@ function paragraphs(paragraph_count){
*/
}


console.log(paragraph());
console.log(paragraphs());
console.log(sentence());
console.log(sentences());
console.log(words());
String.prototype.capitalize = function(){ //v1.0
return this.replace(/\w+/g, function(a){
return a.charAt(0).toUpperCase() + a.substr(1).toLowerCase();
});
};

0 comments on commit c6dbabb

Please sign in to comment.