lorem-ipsum
Advanced tools
Comparing version 0.0.9 to 0.1.0
#!/usr/bin/env node | ||
var g = require('./../lib/generator') | ||
, options = { count: 5, units: 'sentences' } | ||
, copy = false | ||
, args = process.argv.slice(2); | ||
for (var i = 0; i < args.length; i++) { | ||
if (args[i].indexOf('-') < 0) { | ||
options.count = args[i]; | ||
} else { | ||
switch (args[i]) { | ||
case "--words": | ||
case "--word": | ||
case "-w": | ||
options.units = "words"; | ||
break; | ||
case "--sentences": | ||
case "--sentence": | ||
case "-s": | ||
options.units = "sentences"; | ||
break; | ||
case "--paragraphs": | ||
case "--paragraph": | ||
case "-p": | ||
options.units = "paragraphs"; | ||
break; | ||
case "--copy": | ||
case "-cp": | ||
copy = true; | ||
break; | ||
} | ||
} | ||
} | ||
var optimist = require('optimist') | ||
, generator = require('./../lib/generator') | ||
, clipper = require('./../lib/clipper'); | ||
value = g(options); | ||
var options = {} | ||
, arguments = optimist.argv | ||
, loremIpsum = ''; | ||
console.log(value); | ||
options.units = arguments.units || 'sentences'; | ||
options.count = arguments.count || 1; | ||
options.copy = arguments.copy ? true : false; | ||
options.format = arguments.format || 'plain'; | ||
if (copy) { | ||
var exec = require('child_process').exec; | ||
var stat = ''; | ||
switch(process.platform) { | ||
case 'darwin': | ||
stat = 'echo "' + value + '" | pbcopy'; | ||
break; | ||
case 'win32': | ||
stat = 'echo "' + value + '" | clip'; | ||
break; | ||
case 'linux': | ||
stat = 'echo "' + value + '" | xclip -selection clipboard'; | ||
break; | ||
} | ||
exec(stat, function(err, stdout, stderr) { | ||
if (err) { | ||
console.log('FAILED TO COPY DATA TO CLIPBOARD!'); | ||
} | ||
}); | ||
} | ||
// Generate the lorem ipsum text and print it out. | ||
loremIpsum = generator(options); | ||
console.log(loremIpsum); | ||
// Copy the lorem ipsum text to the clipboard. | ||
if (options.copy) { | ||
clipper(loremIpsum, function(err) { err ? process.exit(1) : process.exit() }); | ||
} else { | ||
process.exit(); // Successful exit. | ||
} |
var generator = function() { | ||
var options = (arguments.length) ? arguments[0] : {} | ||
, count = options.count || 250 | ||
, units = options.units || 'words' | ||
, count = options.count || 1 | ||
, units = options.units || 'sentences' | ||
, sentenceLowerBound = options.sentenceLowerBound || 5 | ||
, sentenceUpperBound = options.sentenceUpperBound || 15 | ||
, paragraphLowerBound = options.paragraphLowerBound || 3 | ||
, paragraphUpperBound = options.paragraphUpperBound || 7 | ||
, paragraphPrefix = options.paragraphPrefix || '<p>' | ||
, paragraphSuffix = options.paragraphSuffix || '</p>' | ||
, paragraphLowerBound = options.paragraphLowerBound || 3 | ||
, paragraphUpperBound = options.paragraphUpperBound || 7 | ||
, format = options.format || 'plain' | ||
, words = require('./dictionary').words; | ||
@@ -57,3 +56,10 @@ | ||
, bounds = {min: 0, max: count} | ||
, string = ''; | ||
, string = '' | ||
, prefix = '' | ||
, suffix = "\r\n"; | ||
if (format == 'html') { | ||
prefix = '<p>'; | ||
suffix = '</p>'; | ||
} | ||
@@ -69,3 +75,3 @@ while (bounds.min < bounds.max) { | ||
case 'paragraphs': | ||
string = string + paragraphPrefix + randomParagraph(words, paragraphLowerBound, paragraphUpperBound, sentenceLowerBound, sentenceUpperBound) + paragraphSuffix; | ||
string = string + prefix + randomParagraph(words, paragraphLowerBound, paragraphUpperBound, sentenceLowerBound, sentenceUpperBound) + suffix; | ||
break; | ||
@@ -72,0 +78,0 @@ } |
{ | ||
"name": "lorem-ipsum", | ||
"version": "0.1.0", | ||
"description": "Generates passages of lorem ipsum text suitable for use a placeholder in web pages, graphics, and more.", | ||
"author": "Nickolas Kenyeres <nkenyeres@gmail.com> (http://knicklabs.github.com)", | ||
"name": "lorem-ipsum", | ||
"description": "Generate placeholder text using lorem ipsum.", | ||
"version": "0.0.9", | ||
"repository": { | ||
"type": "git", | ||
"url": "git://github.com/knicklabs/node-lorem-ipsum.git" | ||
"license": "MIT/X11", | ||
"main": "./lib/generator", | ||
"dependencies": { | ||
"optimist": "~0.3.5" | ||
}, | ||
"engines": { | ||
"node": "*" | ||
}, | ||
"dependencies": {}, | ||
"devDependencies": {}, | ||
"main": "./lib/generator", | ||
"optionalDependencies": {}, | ||
"bin": { | ||
"lorem-ipsum": "bin/lorem-ipsum.bin.js" | ||
}, | ||
"optionalDependencies": {} | ||
"repository": { | ||
"type": "git", | ||
"url": "git://github.com/knicklabs/node-lorem-ipsum.git" | ||
}, | ||
"keywords": [ | ||
"lorem", | ||
"ipsum", | ||
"placeholder", | ||
"text", | ||
"dummy", | ||
"filler" | ||
], | ||
"engine": { | ||
"node": ">=0.4" | ||
} | ||
} |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Misc. License Issues
License(Experimental) A package's licensing information has fine-grained problems.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Non-existent author
Supply chain riskThe package was published by an npm account that no longer exists.
Found 1 instance in 1 package
9159
7
90
0
1
1
188
+ Addedoptimist@~0.3.5
+ Addedoptimist@0.3.7(transitive)
+ Addedwordwrap@0.0.3(transitive)