diff --git a/node_modules/.bin/docco b/node_modules/.bin/docco deleted file mode 120000 index e146526..0000000 --- a/node_modules/.bin/docco +++ /dev/null @@ -1 +0,0 @@ -../docco/bin/docco \ No newline at end of file diff --git a/node_modules/.bin/vows b/node_modules/.bin/vows deleted file mode 120000 index 0386e59..0000000 --- a/node_modules/.bin/vows +++ /dev/null @@ -1 +0,0 @@ -../vows/bin/vows \ No newline at end of file diff --git a/node_modules/docco/.gitignore b/node_modules/docco/.gitignore deleted file mode 100644 index 80df34f..0000000 --- a/node_modules/docco/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ -.DS_Store -output -docs \ No newline at end of file diff --git a/node_modules/docco/Cakefile b/node_modules/docco/Cakefile deleted file mode 100644 index 55b4904..0000000 --- a/node_modules/docco/Cakefile +++ /dev/null @@ -1,27 +0,0 @@ -{spawn, exec} = require 'child_process' - -option '-p', '--prefix [DIR]', 'set the installation prefix for `cake install`' - -task 'build', 'continually build the docco library with --watch', -> - coffee = spawn 'coffee', ['-cw', '-o', 'lib', 'src'] - coffee.stdout.on 'data', (data) -> console.log data.toString().trim() - -task 'install', 'install the `docco` command into /usr/local (or --prefix)', (options) -> - base = options.prefix or '/usr/local' - lib = base + '/lib/docco' - exec([ - 'mkdir -p ' + lib - 'cp -rf bin README resources vendor lib ' + lib - 'ln -sf ' + lib + '/bin/docco ' + base + '/bin/docco' - ].join(' && '), (err, stdout, stderr) -> - if err then console.error stderr - ) - -task 'doc', 'rebuild the Docco documentation', -> - exec([ - 'bin/docco src/docco.coffee' - 'sed "s/docco.css/resources\\/docco.css/" < docs/docco.html > index.html' - 'rm -r docs' - ].join(' && '), (err) -> - throw err if err - ) diff --git a/node_modules/docco/README b/node_modules/docco/README deleted file mode 100644 index 777bb9d..0000000 --- a/node_modules/docco/README +++ /dev/null @@ -1,13 +0,0 @@ - ____ -/\ _`\ -\ \ \/\ \ ___ ___ ___ ___ - \ \ \ \ \ / __`\ /'___\ /'___\ / __`\ - \ \ \_\ \ /\ \ \ \ /\ \__/ /\ \__/ /\ \ \ \ - \ \____/ \ \____/ \ \____\ \ \____\ \ \____/ - \/___/ \/___/ \/____/ \/____/ \/___/ - - -Docco is a quick-and-dirty, hundred-line-long, literate-programming-style -documentation generator. For more information, see: - -http://jashkenas.github.com/docco/ \ No newline at end of file diff --git a/node_modules/docco/bin/docco b/node_modules/docco/bin/docco deleted file mode 100755 index d9f78a1..0000000 --- a/node_modules/docco/bin/docco +++ /dev/null @@ -1,8 +0,0 @@ -#!/usr/bin/env node - -var path = require('path'); -var fs = require('fs'); -var lib = path.join(path.dirname(fs.realpathSync(__filename)), '../lib'); - -process.ARGV = process.argv = process.argv.slice(2, process.argv.length); -require(lib + '/docco.js'); diff --git a/node_modules/docco/index.html b/node_modules/docco/index.html deleted file mode 100644 index 73ce3c7..0000000 --- a/node_modules/docco/index.html +++ /dev/null @@ -1,143 +0,0 @@ - docco.coffee

docco.coffee

Docco is a quick-and-dirty, hundred-line-long, literate-programming-style -documentation generator. It produces HTML that displays your comments -alongside your code. Comments are passed through -Markdown, and code is -passed through Pygments syntax highlighting. -This page is the result of running Docco against its own source file.

- -

If you install Docco, you can run it from the command-line:

- -
docco src/*.coffee
-
- -

...will generate linked HTML documentation for the named source files, saving -it into a docs folder.

- -

The source for Docco is available on GitHub, -and released under the MIT license.

- -

To install Docco, first make sure you have Node.js, -Pygments (install the latest dev version of Pygments -from its Mercurial repo), and -CoffeeScript. Then, with NPM:

- -
sudo npm install docco
-
- -

If Node.js doesn't run on your platform, or you'd prefer a more convenient -package, get Rocco, the Ruby port that's -available as a gem. If you're writing shell scripts, try -Shocco, a port for the POSIX shell. -Both are by Ryan Tomayko. If Python's more -your speed, take a look at Nick Fitzgerald's -Pycco.

Main Documentation Generation Functions

Generate the documentation for a source file by reading it in, splitting it -up into comment/code sections, highlighting them for the appropriate language, -and merging them into an HTML template.

generate_documentation = (source, callback) ->
-  fs.readFile source, "utf-8", (error, code) ->
-    throw error if error
-    sections = parse source, code
-    highlight source, sections, ->
-      generate_html source, sections
-      callback()

Given a string of source code, parse out each comment and the code that -follows it, and create an individual section for it. -Sections take the form:

- -
{
-  docs_text: ...
-  docs_html: ...
-  code_text: ...
-  code_html: ...
-}
-
parse = (source, code) ->
-  lines    = code.split '\n'
-  sections = []
-  language = get_language source
-  has_code = docs_text = code_text = ''
-
-  save = (docs, code) ->
-    sections.push docs_text: docs, code_text: code
-
-  for line in lines
-    if line.match language.comment_matcher
-      if not (line.match language.comment_filter)
-        if has_code
-          save docs_text, code_text
-          has_code = docs_text = code_text = ''
-        docs_text += line.replace(language.comment_matcher, '') + '\n'
-    else
-      has_code = yes
-      code_text += line + '\n'
-  save docs_text, code_text
-  sections

Highlights a single chunk of CoffeeScript code, using Pygments over stdio, -and runs the text of its corresponding comment through Markdown, using the -Github-flavored-Markdown modification of Showdown.js.

- -

We process the entire file in a single call to Pygments by inserting little -marker comments between each section and then splitting the result string -wherever our markers occur.

highlight = (source, sections, callback) ->
-  language = get_language source
-  pygments = spawn 'pygmentize', ['-l', language.name, '-f', 'html', '-O', 'encoding=utf-8']
-  output   = ''
-  pygments.stderr.addListener 'data',  (error)  ->
-    console.error error if error
-  pygments.stdout.addListener 'data', (result) ->
-    output += result if result
-  pygments.addListener 'exit', ->
-    output = output.replace(highlight_start, '').replace(highlight_end, '')
-    fragments = output.split language.divider_html
-    for section, i in sections
-      section.code_html = highlight_start + fragments[i] + highlight_end
-      section.docs_html = showdown.makeHtml section.docs_text
-    callback()
-  pygments.stdin.write((section.code_text for section in sections).join(language.divider_text))
-  pygments.stdin.end()

Once all of the code is finished highlighting, we can generate the HTML file -and write out the documentation. Pass the completed sections into the template -found in resources/docco.jst

generate_html = (source, sections) ->
-  title = path.basename source
-  dest  = destination source
-  html  = docco_template {
-    title: title, sections: sections, sources: sources, path: path, destination: destination
-  }
-  console.log "docco: #{source} -> #{dest}"
-  fs.writeFile dest, html

Helpers & Setup

Require our external dependencies, including Showdown.js -(the JavaScript implementation of Markdown).

fs       = require 'fs'
-path     = require 'path'
-showdown = require('./../vendor/showdown').Showdown
-{spawn, exec} = require 'child_process'

A list of the languages that Docco supports, mapping the file extension to -the name of the Pygments lexer and the symbol that indicates a comment. To -add another language to Docco's repertoire, add it here.

languages =
-  '.coffee':
-    name: 'coffee-script', symbol: '#'
-  '.js':
-    name: 'javascript', symbol: '//'
-  '.rb':
-    name: 'ruby', symbol: '#'
-  '.py':
-    name: 'python', symbol: '#'

Build out the appropriate matchers and delimiters for each language.

for ext, l of languages

Does the line begin with a comment?

  l.comment_matcher = new RegExp('^\\s*' + l.symbol + '\\s?')

Ignore hashbangs)

  l.comment_filter = new RegExp('^#![/]')

The dividing token we feed into Pygments, to delimit the boundaries between -sections.

  l.divider_text = '\n' + l.symbol + 'DIVIDER\n'

The mirror of divider_text that we expect Pygments to return. We can split -on this to recover the original sections. -Note: the class is "c" for Python and "c1" for the other languages

  l.divider_html = new RegExp('\\n*<span class="c1?">' + l.symbol + 'DIVIDER<\\/span>\\n*')

Get the current language we're documenting, based on the extension.

get_language = (source) -> languages[path.extname(source)]

Compute the destination HTML path for an input source file path. If the source -is lib/example.coffee, the HTML will be at docs/example.html

destination = (filepath) ->
-  'docs/' + path.basename(filepath, path.extname(filepath)) + '.html'

Ensure that the destination directory exists.

ensure_directory = (callback) ->
-  exec 'mkdir -p docs', -> callback()

Micro-templating, originally by John Resig, borrowed by way of -Underscore.js.

template = (str) ->
-  new Function 'obj',
-    'var p=[],print=function(){p.push.apply(p,arguments);};' +
-    'with(obj){p.push(\'' +
-    str.replace(/[\r\t\n]/g, " ")
-       .replace(/'(?=[^<]*%>)/g,"\t")
-       .split("'").join("\\'")
-       .split("\t").join("'")
-       .replace(/<%=(.+?)%>/g, "',$1,'")
-       .split('<%').join("');")
-       .split('%>').join("p.push('") +
-       "');}return p.join('');"

Create the template that we will use to generate the Docco HTML page.

docco_template  = template fs.readFileSync(__dirname + '/../resources/docco.jst').toString()

The CSS styles we'd like to apply to the documentation.

docco_styles    = fs.readFileSync(__dirname + '/../resources/resources/docco.css').toString()

The start of each Pygments highlight block.

highlight_start = '<div class="highlight"><pre>'

The end of each Pygments highlight block.

highlight_end   = '</pre></div>'

Run the script. -For each source file passed in as an argument, generate the documentation.

sources = process.ARGV.sort()
-if sources.length
-  ensure_directory ->
-    fs.writeFile 'docs/resources/docco.css', docco_styles
-    files = sources.slice(0)
-    next_file = -> generate_documentation files.shift(), next_file if files.length
-    next_file()
-
-
diff --git a/node_modules/docco/lib/docco.js b/node_modules/docco/lib/docco.js deleted file mode 100644 index 036af60..0000000 --- a/node_modules/docco/lib/docco.js +++ /dev/null @@ -1,155 +0,0 @@ -(function() { - var destination, docco_styles, docco_template, ensure_directory, exec, ext, fs, generate_documentation, generate_html, get_language, highlight, highlight_end, highlight_start, l, languages, parse, path, showdown, sources, spawn, template, _ref; - generate_documentation = function(source, callback) { - return fs.readFile(source, "utf-8", function(error, code) { - var sections; - if (error) { - throw error; - } - sections = parse(source, code); - return highlight(source, sections, function() { - generate_html(source, sections); - return callback(); - }); - }); - }; - parse = function(source, code) { - var code_text, docs_text, has_code, language, line, lines, save, sections, _i, _len; - lines = code.split('\n'); - sections = []; - language = get_language(source); - has_code = docs_text = code_text = ''; - save = function(docs, code) { - return sections.push({ - docs_text: docs, - code_text: code - }); - }; - for (_i = 0, _len = lines.length; _i < _len; _i++) { - line = lines[_i]; - if (line.match(language.comment_matcher) && !line.match(language.comment_filter)) { - if (has_code) { - save(docs_text, code_text); - has_code = docs_text = code_text = ''; - } - docs_text += line.replace(language.comment_matcher, '') + '\n'; - } else { - has_code = true; - code_text += line + '\n'; - } - } - save(docs_text, code_text); - return sections; - }; - highlight = function(source, sections, callback) { - var language, output, pygments, section, _i, _len, _results; - language = get_language(source); - pygments = spawn('pygmentize', ['-l', language.name, '-f', 'html', '-O', 'encoding=utf-8']); - output = ''; - pygments.stderr.addListener('data', function(error) { - if (error) { - return console.error(error); - } - }); - pygments.stdout.addListener('data', function(result) { - if (result) { - return output += result; - } - }); - pygments.addListener('exit', function() { - var fragments, i, section, _len; - output = output.replace(highlight_start, '').replace(highlight_end, ''); - fragments = output.split(language.divider_html); - for (i = 0, _len = sections.length; i < _len; i++) { - section = sections[i]; - section.code_html = highlight_start + fragments[i] + highlight_end; - section.docs_html = showdown.makeHtml(section.docs_text); - } - return callback(); - }); - pygments.stdin.write((function() { - _results = []; - for (_i = 0, _len = sections.length; _i < _len; _i++) { - section = sections[_i]; - _results.push(section.code_text); - } - return _results; - }()).join(language.divider_text)); - return pygments.stdin.end(); - }; - generate_html = function(source, sections) { - var dest, html, title; - title = path.basename(source); - dest = destination(source); - html = docco_template({ - title: title, - sections: sections, - sources: sources, - path: path, - destination: destination - }); - console.log("docco: " + source + " -> " + dest); - return fs.writeFile(dest, html); - }; - fs = require('fs'); - path = require('path'); - showdown = require('./../vendor/showdown').Showdown; - _ref = require('child_process'), spawn = _ref.spawn, exec = _ref.exec; - languages = { - '.coffee': { - name: 'coffee-script', - symbol: '#' - }, - '.js': { - name: 'javascript', - symbol: '//' - }, - '.rb': { - name: 'ruby', - symbol: '#' - }, - '.py': { - name: 'python', - symbol: '#' - } - }; - for (ext in languages) { - l = languages[ext]; - l.comment_matcher = new RegExp('^\\s*' + l.symbol + '\\s?'); - l.comment_filter = new RegExp('(^#![/]|^\\s*#\\{)'); - l.divider_text = '\n' + l.symbol + 'DIVIDER\n'; - l.divider_html = new RegExp('\\n*' + l.symbol + 'DIVIDER<\\/span>\\n*'); - } - get_language = function(source) { - return languages[path.extname(source)]; - }; - destination = function(filepath) { - return 'docs/' + path.basename(filepath, path.extname(filepath)) + '.html'; - }; - ensure_directory = function(callback) { - return exec('mkdir -p docs', function() { - return callback(); - }); - }; - template = function(str) { - return new Function('obj', 'var p=[],print=function(){p.push.apply(p,arguments);};' + 'with(obj){p.push(\'' + str.replace(/[\r\t\n]/g, " ").replace(/'(?=[^<]*%>)/g, "\t").split("'").join("\\'").split("\t").join("'").replace(/<%=(.+?)%>/g, "',$1,'").split('<%').join("');").split('%>').join("p.push('") + "');}return p.join('');"); - }; - docco_template = template(fs.readFileSync(__dirname + '/../resources/docco.jst').toString()); - docco_styles = fs.readFileSync(__dirname + '/../resources/docco.css').toString(); - highlight_start = '
';
-  highlight_end = '
'; - sources = process.ARGV.sort(); - if (sources.length) { - ensure_directory(function() { - var files, next_file; - fs.writeFile('docs/docco.css', docco_styles); - files = sources.slice(0); - next_file = function() { - if (files.length) { - return generate_documentation(files.shift(), next_file); - } - }; - return next_file(); - }); - } -}).call(this); diff --git a/node_modules/docco/package.json b/node_modules/docco/package.json deleted file mode 100644 index e2224c4..0000000 --- a/node_modules/docco/package.json +++ /dev/null @@ -1,21 +0,0 @@ -{ - "name": "docco", - "description": "The Quick and Dirty Literate Programming Documentation Generator", - "keywords": ["documentation", "docs", "generator", "coffeescript"], - "author": "Jeremy Ashkenas", - "version": "0.3.0", - "licenses": [{ - "type": "MIT", - "url": "http://opensource.org/licenses/mit-license.php" - }], - "engines": { - "node": ">=0.2.0" - }, - "directories": { - "lib" : "./lib" - }, - "main" : "./lib/docco", - "bin": { - "docco": "./bin/docco" - } -} diff --git a/node_modules/docco/resources/docco.css b/node_modules/docco/resources/docco.css deleted file mode 100644 index 5aa0a8d..0000000 --- a/node_modules/docco/resources/docco.css +++ /dev/null @@ -1,186 +0,0 @@ -/*--------------------- Layout and Typography ----------------------------*/ -body { - font-family: 'Palatino Linotype', 'Book Antiqua', Palatino, FreeSerif, serif; - font-size: 15px; - line-height: 22px; - color: #252519; - margin: 0; padding: 0; -} -a { - color: #261a3b; -} - a:visited { - color: #261a3b; - } -p { - margin: 0 0 15px 0; -} -h1, h2, h3, h4, h5, h6 { - margin: 0px 0 15px 0; -} - h1 { - margin-top: 40px; - } -#container { - position: relative; -} -#background { - position: fixed; - top: 0; left: 525px; right: 0; bottom: 0; - background: #f5f5ff; - border-left: 1px solid #e5e5ee; - z-index: -1; -} -#jump_to, #jump_page { - background: white; - -webkit-box-shadow: 0 0 25px #777; -moz-box-shadow: 0 0 25px #777; - -webkit-border-bottom-left-radius: 5px; -moz-border-radius-bottomleft: 5px; - font: 10px Arial; - text-transform: uppercase; - cursor: pointer; - text-align: right; -} -#jump_to, #jump_wrapper { - position: fixed; - right: 0; top: 0; - padding: 5px 10px; -} - #jump_wrapper { - padding: 0; - display: none; - } - #jump_to:hover #jump_wrapper { - display: block; - } - #jump_page { - padding: 5px 0 3px; - margin: 0 0 25px 25px; - } - #jump_page .source { - display: block; - padding: 5px 10px; - text-decoration: none; - border-top: 1px solid #eee; - } - #jump_page .source:hover { - background: #f5f5ff; - } - #jump_page .source:first-child { - } -table td { - border: 0; - outline: 0; -} - td.docs, th.docs { - max-width: 450px; - min-width: 450px; - min-height: 5px; - padding: 10px 25px 1px 50px; - overflow-x: hidden; - vertical-align: top; - text-align: left; - } - .docs pre { - margin: 15px 0 15px; - padding-left: 15px; - } - .docs p tt, .docs p code { - background: #f8f8ff; - border: 1px solid #dedede; - font-size: 12px; - padding: 0 0.2em; - } - .pilwrap { - position: relative; - } - .pilcrow { - font: 12px Arial; - text-decoration: none; - color: #454545; - position: absolute; - top: 3px; left: -20px; - padding: 1px 2px; - opacity: 0; - -webkit-transition: opacity 0.2s linear; - } - td.docs:hover .pilcrow { - opacity: 1; - } - td.code, th.code { - padding: 14px 15px 16px 25px; - width: 100%; - vertical-align: top; - background: #f5f5ff; - border-left: 1px solid #e5e5ee; - } - pre, tt, code { - font-size: 12px; line-height: 18px; - font-family: Monaco, Consolas, "Lucida Console", monospace; - margin: 0; padding: 0; - } - - -/*---------------------- Syntax Highlighting -----------------------------*/ -td.linenos { background-color: #f0f0f0; padding-right: 10px; } -span.lineno { background-color: #f0f0f0; padding: 0 5px 0 5px; } -body .hll { background-color: #ffffcc } -body .c { color: #408080; font-style: italic } /* Comment */ -body .err { border: 1px solid #FF0000 } /* Error */ -body .k { color: #954121 } /* Keyword */ -body .o { color: #666666 } /* Operator */ -body .cm { color: #408080; font-style: italic } /* Comment.Multiline */ -body .cp { color: #BC7A00 } /* Comment.Preproc */ -body .c1 { color: #408080; font-style: italic } /* Comment.Single */ -body .cs { color: #408080; font-style: italic } /* Comment.Special */ -body .gd { color: #A00000 } /* Generic.Deleted */ -body .ge { font-style: italic } /* Generic.Emph */ -body .gr { color: #FF0000 } /* Generic.Error */ -body .gh { color: #000080; font-weight: bold } /* Generic.Heading */ -body .gi { color: #00A000 } /* Generic.Inserted */ -body .go { color: #808080 } /* Generic.Output */ -body .gp { color: #000080; font-weight: bold } /* Generic.Prompt */ -body .gs { font-weight: bold } /* Generic.Strong */ -body .gu { color: #800080; font-weight: bold } /* Generic.Subheading */ -body .gt { color: #0040D0 } /* Generic.Traceback */ -body .kc { color: #954121 } /* Keyword.Constant */ -body .kd { color: #954121; font-weight: bold } /* Keyword.Declaration */ -body .kn { color: #954121; font-weight: bold } /* Keyword.Namespace */ -body .kp { color: #954121 } /* Keyword.Pseudo */ -body .kr { color: #954121; font-weight: bold } /* Keyword.Reserved */ -body .kt { color: #B00040 } /* Keyword.Type */ -body .m { color: #666666 } /* Literal.Number */ -body .s { color: #219161 } /* Literal.String */ -body .na { color: #7D9029 } /* Name.Attribute */ -body .nb { color: #954121 } /* Name.Builtin */ -body .nc { color: #0000FF; font-weight: bold } /* Name.Class */ -body .no { color: #880000 } /* Name.Constant */ -body .nd { color: #AA22FF } /* Name.Decorator */ -body .ni { color: #999999; font-weight: bold } /* Name.Entity */ -body .ne { color: #D2413A; font-weight: bold } /* Name.Exception */ -body .nf { color: #0000FF } /* Name.Function */ -body .nl { color: #A0A000 } /* Name.Label */ -body .nn { color: #0000FF; font-weight: bold } /* Name.Namespace */ -body .nt { color: #954121; font-weight: bold } /* Name.Tag */ -body .nv { color: #19469D } /* Name.Variable */ -body .ow { color: #AA22FF; font-weight: bold } /* Operator.Word */ -body .w { color: #bbbbbb } /* Text.Whitespace */ -body .mf { color: #666666 } /* Literal.Number.Float */ -body .mh { color: #666666 } /* Literal.Number.Hex */ -body .mi { color: #666666 } /* Literal.Number.Integer */ -body .mo { color: #666666 } /* Literal.Number.Oct */ -body .sb { color: #219161 } /* Literal.String.Backtick */ -body .sc { color: #219161 } /* Literal.String.Char */ -body .sd { color: #219161; font-style: italic } /* Literal.String.Doc */ -body .s2 { color: #219161 } /* Literal.String.Double */ -body .se { color: #BB6622; font-weight: bold } /* Literal.String.Escape */ -body .sh { color: #219161 } /* Literal.String.Heredoc */ -body .si { color: #BB6688; font-weight: bold } /* Literal.String.Interpol */ -body .sx { color: #954121 } /* Literal.String.Other */ -body .sr { color: #BB6688 } /* Literal.String.Regex */ -body .s1 { color: #219161 } /* Literal.String.Single */ -body .ss { color: #19469D } /* Literal.String.Symbol */ -body .bp { color: #954121 } /* Name.Builtin.Pseudo */ -body .vc { color: #19469D } /* Name.Variable.Class */ -body .vg { color: #19469D } /* Name.Variable.Global */ -body .vi { color: #19469D } /* Name.Variable.Instance */ -body .il { color: #666666 } /* Literal.Number.Integer.Long */ \ No newline at end of file diff --git a/node_modules/docco/resources/docco.jst b/node_modules/docco/resources/docco.jst deleted file mode 100644 index cfff7c6..0000000 --- a/node_modules/docco/resources/docco.jst +++ /dev/null @@ -1,58 +0,0 @@ - - - - - <%= title %> - - - - -
-
- <% if (sources.length > 1) { %> -
- Jump To … -
-
- <% for (var i=0, l=sources.length; i - <% var source = sources[i]; %> - - <%= path.basename(source) %> - - <% } %> -
-
-
- <% } %> - - - - - - - - - <% for (var i=0, l=sections.length; i - <% var section = sections[i]; %> - - - - - <% } %> - -
-

- <%= title %> -

-
-
-
- -
- <%= section.docs_html %> -
- <%= section.code_html %> -
-
- - diff --git a/node_modules/docco/src/docco.coffee b/node_modules/docco/src/docco.coffee deleted file mode 100644 index 0ca6b00..0000000 --- a/node_modules/docco/src/docco.coffee +++ /dev/null @@ -1,204 +0,0 @@ -# **Docco** is a quick-and-dirty, hundred-line-long, literate-programming-style -# documentation generator. It produces HTML that displays your comments -# alongside your code. Comments are passed through -# [Markdown](http://daringfireball.net/projects/markdown/syntax), and code is -# passed through [Pygments](http://pygments.org/) syntax highlighting. -# This page is the result of running Docco against its own source file. -# -# If you install Docco, you can run it from the command-line: -# -# docco src/*.coffee -# -# ...will generate linked HTML documentation for the named source files, saving -# it into a `docs` folder. -# -# The [source for Docco](http://github.com/jashkenas/docco) is available on GitHub, -# and released under the MIT license. -# -# To install Docco, first make sure you have [Node.js](http://nodejs.org/), -# [Pygments](http://pygments.org/) (install the latest dev version of Pygments -# from [its Mercurial repo](http://dev.pocoo.org/hg/pygments-main)), and -# [CoffeeScript](http://coffeescript.org/). Then, with NPM: -# -# sudo npm install docco -# -# If **Node.js** doesn't run on your platform, or you'd prefer a more convenient -# package, get [Rocco](http://rtomayko.github.com/rocco/), the Ruby port that's -# available as a gem. If you're writing shell scripts, try -# [Shocco](http://rtomayko.github.com/shocco/), a port for the **POSIX shell**. -# Both are by [Ryan Tomayko](http://github.com/rtomayko). If Python's more -# your speed, take a look at [Nick Fitzgerald](http://github.com/fitzgen)'s -# [Pycco](http://fitzgen.github.com/pycco/). - -#### Main Documentation Generation Functions - -# Generate the documentation for a source file by reading it in, splitting it -# up into comment/code sections, highlighting them for the appropriate language, -# and merging them into an HTML template. -generate_documentation = (source, callback) -> - fs.readFile source, "utf-8", (error, code) -> - throw error if error - sections = parse source, code - highlight source, sections, -> - generate_html source, sections - callback() - -# Given a string of source code, parse out each comment and the code that -# follows it, and create an individual **section** for it. -# Sections take the form: -# -# { -# docs_text: ... -# docs_html: ... -# code_text: ... -# code_html: ... -# } -# -parse = (source, code) -> - lines = code.split '\n' - sections = [] - language = get_language source - has_code = docs_text = code_text = '' - - save = (docs, code) -> - sections.push docs_text: docs, code_text: code - - for line in lines - if line.match(language.comment_matcher) and not line.match(language.comment_filter) - if has_code - save docs_text, code_text - has_code = docs_text = code_text = '' - docs_text += line.replace(language.comment_matcher, '') + '\n' - else - has_code = yes - code_text += line + '\n' - save docs_text, code_text - sections - -# Highlights a single chunk of CoffeeScript code, using **Pygments** over stdio, -# and runs the text of its corresponding comment through **Markdown**, using the -# **Github-flavored-Markdown** modification of [Showdown.js](http://attacklab.net/showdown/). -# -# We process the entire file in a single call to Pygments by inserting little -# marker comments between each section and then splitting the result string -# wherever our markers occur. -highlight = (source, sections, callback) -> - language = get_language source - pygments = spawn 'pygmentize', ['-l', language.name, '-f', 'html', '-O', 'encoding=utf-8'] - output = '' - pygments.stderr.addListener 'data', (error) -> - console.error error if error - pygments.stdout.addListener 'data', (result) -> - output += result if result - pygments.addListener 'exit', -> - output = output.replace(highlight_start, '').replace(highlight_end, '') - fragments = output.split language.divider_html - for section, i in sections - section.code_html = highlight_start + fragments[i] + highlight_end - section.docs_html = showdown.makeHtml section.docs_text - callback() - pygments.stdin.write((section.code_text for section in sections).join(language.divider_text)) - pygments.stdin.end() - -# Once all of the code is finished highlighting, we can generate the HTML file -# and write out the documentation. Pass the completed sections into the template -# found in `resources/docco.jst` -generate_html = (source, sections) -> - title = path.basename source - dest = destination source - html = docco_template { - title: title, sections: sections, sources: sources, path: path, destination: destination - } - console.log "docco: #{source} -> #{dest}" - fs.writeFile dest, html - -#### Helpers & Setup - -# Require our external dependencies, including **Showdown.js** -# (the JavaScript implementation of Markdown). -fs = require 'fs' -path = require 'path' -showdown = require('./../vendor/showdown').Showdown -{spawn, exec} = require 'child_process' - -# A list of the languages that Docco supports, mapping the file extension to -# the name of the Pygments lexer and the symbol that indicates a comment. To -# add another language to Docco's repertoire, add it here. -languages = - '.coffee': - name: 'coffee-script', symbol: '#' - '.js': - name: 'javascript', symbol: '//' - '.rb': - name: 'ruby', symbol: '#' - '.py': - name: 'python', symbol: '#' - -# Build out the appropriate matchers and delimiters for each language. -for ext, l of languages - - # Does the line begin with a comment? - l.comment_matcher = new RegExp('^\\s*' + l.symbol + '\\s?') - - # Ignore [hashbangs](http://en.wikipedia.org/wiki/Shebang_(Unix)) - # and interpolations... - l.comment_filter = new RegExp('(^#![/]|^\\s*#\\{)') - - # The dividing token we feed into Pygments, to delimit the boundaries between - # sections. - l.divider_text = '\n' + l.symbol + 'DIVIDER\n' - - # The mirror of `divider_text` that we expect Pygments to return. We can split - # on this to recover the original sections. - # Note: the class is "c" for Python and "c1" for the other languages - l.divider_html = new RegExp('\\n*' + l.symbol + 'DIVIDER<\\/span>\\n*') - -# Get the current language we're documenting, based on the extension. -get_language = (source) -> languages[path.extname(source)] - -# Compute the destination HTML path for an input source file path. If the source -# is `lib/example.coffee`, the HTML will be at `docs/example.html` -destination = (filepath) -> - 'docs/' + path.basename(filepath, path.extname(filepath)) + '.html' - -# Ensure that the destination directory exists. -ensure_directory = (callback) -> - exec 'mkdir -p docs', -> callback() - -# Micro-templating, originally by John Resig, borrowed by way of -# [Underscore.js](http://documentcloud.github.com/underscore/). -template = (str) -> - new Function 'obj', - 'var p=[],print=function(){p.push.apply(p,arguments);};' + - 'with(obj){p.push(\'' + - str.replace(/[\r\t\n]/g, " ") - .replace(/'(?=[^<]*%>)/g,"\t") - .split("'").join("\\'") - .split("\t").join("'") - .replace(/<%=(.+?)%>/g, "',$1,'") - .split('<%').join("');") - .split('%>').join("p.push('") + - "');}return p.join('');" - -# Create the template that we will use to generate the Docco HTML page. -docco_template = template fs.readFileSync(__dirname + '/../resources/docco.jst').toString() - -# The CSS styles we'd like to apply to the documentation. -docco_styles = fs.readFileSync(__dirname + '/../resources/docco.css').toString() - -# The start of each Pygments highlight block. -highlight_start = '
'
-
-# The end of each Pygments highlight block.
-highlight_end   = '
' - -# Run the script. -# For each source file passed in as an argument, generate the documentation. -sources = process.ARGV.sort() -if sources.length - ensure_directory -> - fs.writeFile 'docs/docco.css', docco_styles - files = sources.slice(0) - next_file = -> generate_documentation files.shift(), next_file if files.length - next_file() - diff --git a/node_modules/docco/vendor/showdown.js b/node_modules/docco/vendor/showdown.js deleted file mode 100644 index 9dfd87f..0000000 --- a/node_modules/docco/vendor/showdown.js +++ /dev/null @@ -1,1298 +0,0 @@ -// -// showdown.js -- A javascript port of Markdown. -// -// Copyright (c) 2007 John Fraser. -// -// Original Markdown Copyright (c) 2004-2005 John Gruber -// -// -// Redistributable under a BSD-style open source license. -// See license.txt for more information. -// -// The full source distribution is at: -// -// A A L -// T C A -// T K B -// -// -// - -// -// Wherever possible, Showdown is a straight, line-by-line port -// of the Perl version of Markdown. -// -// This is not a normal parser design; it's basically just a -// series of string substitutions. It's hard to read and -// maintain this way, but keeping Showdown close to the original -// design makes it easier to port new features. -// -// More importantly, Showdown behaves like markdown.pl in most -// edge cases. So web applications can do client-side preview -// in Javascript, and then build identical HTML on the server. -// -// This port needs the new RegExp functionality of ECMA 262, -// 3rd Edition (i.e. Javascript 1.5). Most modern web browsers -// should do fine. Even with the new regular expression features, -// We do a lot of work to emulate Perl's regex functionality. -// The tricky changes in this file mostly have the "attacklab:" -// label. Major or self-explanatory changes don't. -// -// Smart diff tools like Araxis Merge will be able to match up -// this file with markdown.pl in a useful way. A little tweaking -// helps: in a copy of markdown.pl, replace "#" with "//" and -// replace "$text" with "text". Be sure to ignore whitespace -// and line endings. -// - - -// -// Showdown usage: -// -// var text = "Markdown *rocks*."; -// -// var converter = new Showdown.converter(); -// var html = converter.makeHtml(text); -// -// alert(html); -// -// Note: move the sample code to the bottom of this -// file before uncommenting it. -// - - -// -// Showdown namespace -// -var Showdown = {}; - -// -// converter -// -// Wraps all "globals" so that the only thing -// exposed is makeHtml(). -// -Showdown.converter = function() { - -// -// Globals: -// - -// Global hashes, used by various utility routines -var g_urls; -var g_titles; -var g_html_blocks; - -// Used to track when we're inside an ordered or unordered list -// (see _ProcessListItems() for details): -var g_list_level = 0; - - -this.makeHtml = function(text) { -// -// Main function. The order in which other subs are called here is -// essential. Link and image substitutions need to happen before -// _EscapeSpecialCharsWithinTagAttributes(), so that any *'s or _'s in the -// and tags get encoded. -// - - // Clear the global hashes. If we don't clear these, you get conflicts - // from other articles when generating a page which contains more than - // one article (e.g. an index page that shows the N most recent - // articles): - g_urls = new Array(); - g_titles = new Array(); - g_html_blocks = new Array(); - - // attacklab: Replace ~ with ~T - // This lets us use tilde as an escape char to avoid md5 hashes - // The choice of character is arbitray; anything that isn't - // magic in Markdown will work. - text = text.replace(/~/g,"~T"); - - // attacklab: Replace $ with ~D - // RegExp interprets $ as a special character - // when it's in a replacement string - text = text.replace(/\$/g,"~D"); - - // Standardize line endings - text = text.replace(/\r\n/g,"\n"); // DOS to Unix - text = text.replace(/\r/g,"\n"); // Mac to Unix - - // Make sure text begins and ends with a couple of newlines: - text = "\n\n" + text + "\n\n"; - - // Convert all tabs to spaces. - text = _Detab(text); - - // Strip any lines consisting only of spaces and tabs. - // This makes subsequent regexen easier to write, because we can - // match consecutive blank lines with /\n+/ instead of something - // contorted like /[ \t]*\n+/ . - text = text.replace(/^[ \t]+$/mg,""); - - // Turn block-level HTML blocks into hash entries - text = _HashHTMLBlocks(text); - - // Strip link definitions, store in hashes. - text = _StripLinkDefinitions(text); - - text = _RunBlockGamut(text); - - text = _UnescapeSpecialChars(text); - - // attacklab: Restore dollar signs - text = text.replace(/~D/g,"$$"); - - // attacklab: Restore tildes - text = text.replace(/~T/g,"~"); - - return text; -} - - -var _StripLinkDefinitions = function(text) { -// -// Strips link definitions from text, stores the URLs and titles in -// hash references. -// - - // Link defs are in the form: ^[id]: url "optional title" - - /* - var text = text.replace(/ - ^[ ]{0,3}\[(.+)\]: // id = $1 attacklab: g_tab_width - 1 - [ \t]* - \n? // maybe *one* newline - [ \t]* - ? // url = $2 - [ \t]* - \n? // maybe one newline - [ \t]* - (?: - (\n*) // any lines skipped = $3 attacklab: lookbehind removed - ["(] - (.+?) // title = $4 - [")] - [ \t]* - )? // title is optional - (?:\n+|$) - /gm, - function(){...}); - */ - var text = text.replace(/^[ ]{0,3}\[(.+)\]:[ \t]*\n?[ \t]*?[ \t]*\n?[ \t]*(?:(\n*)["(](.+?)[")][ \t]*)?(?:\n+|\Z)/gm, - function (wholeMatch,m1,m2,m3,m4) { - m1 = m1.toLowerCase(); - g_urls[m1] = _EncodeAmpsAndAngles(m2); // Link IDs are case-insensitive - if (m3) { - // Oops, found blank lines, so it's not a title. - // Put back the parenthetical statement we stole. - return m3+m4; - } else if (m4) { - g_titles[m1] = m4.replace(/"/g,"""); - } - - // Completely remove the definition from the text - return ""; - } - ); - - return text; -} - - -var _HashHTMLBlocks = function(text) { - // attacklab: Double up blank lines to reduce lookaround - text = text.replace(/\n/g,"\n\n"); - - // Hashify HTML blocks: - // We only want to do this for block-level HTML tags, such as headers, - // lists, and tables. That's because we still want to wrap

s around - // "paragraphs" that are wrapped in non-block-level tags, such as anchors, - // phrase emphasis, and spans. The list of tags we're looking for is - // hard-coded: - var block_tags_a = "p|div|h[1-6]|blockquote|pre|table|dl|ol|ul|script|noscript|form|fieldset|iframe|math|ins|del" - var block_tags_b = "p|div|h[1-6]|blockquote|pre|table|dl|ol|ul|script|noscript|form|fieldset|iframe|math" - - // First, look for nested blocks, e.g.: - //

- //
- // tags for inner block must be indented. - //
- //
- // - // The outermost tags must start at the left margin for this to match, and - // the inner nested divs must be indented. - // We need to do this before the next, more liberal match, because the next - // match will start at the first `
` and stop at the first `
`. - - // attacklab: This regex can be expensive when it fails. - /* - var text = text.replace(/ - ( // save in $1 - ^ // start of line (with /m) - <($block_tags_a) // start tag = $2 - \b // word break - // attacklab: hack around khtml/pcre bug... - [^\r]*?\n // any number of lines, minimally matching - // the matching end tag - [ \t]* // trailing spaces/tabs - (?=\n+) // followed by a newline - ) // attacklab: there are sentinel newlines at end of document - /gm,function(){...}}; - */ - text = text.replace(/^(<(p|div|h[1-6]|blockquote|pre|table|dl|ol|ul|script|noscript|form|fieldset|iframe|math|ins|del)\b[^\r]*?\n<\/\2>[ \t]*(?=\n+))/gm,hashElement); - - // - // Now match more liberally, simply from `\n` to `\n` - // - - /* - var text = text.replace(/ - ( // save in $1 - ^ // start of line (with /m) - <($block_tags_b) // start tag = $2 - \b // word break - // attacklab: hack around khtml/pcre bug... - [^\r]*? // any number of lines, minimally matching - .* // the matching end tag - [ \t]* // trailing spaces/tabs - (?=\n+) // followed by a newline - ) // attacklab: there are sentinel newlines at end of document - /gm,function(){...}}; - */ - text = text.replace(/^(<(p|div|h[1-6]|blockquote|pre|table|dl|ol|ul|script|noscript|form|fieldset|iframe|math)\b[^\r]*?.*<\/\2>[ \t]*(?=\n+)\n)/gm,hashElement); - - // Special case just for
. It was easier to make a special case than - // to make the other regex more complicated. - - /* - text = text.replace(/ - ( // save in $1 - \n\n // Starting after a blank line - [ ]{0,3} - (<(hr) // start tag = $2 - \b // word break - ([^<>])*? // - \/?>) // the matching end tag - [ \t]* - (?=\n{2,}) // followed by a blank line - ) - /g,hashElement); - */ - text = text.replace(/(\n[ ]{0,3}(<(hr)\b([^<>])*?\/?>)[ \t]*(?=\n{2,}))/g,hashElement); - - // Special case for standalone HTML comments: - - /* - text = text.replace(/ - ( // save in $1 - \n\n // Starting after a blank line - [ ]{0,3} // attacklab: g_tab_width - 1 - - [ \t]* - (?=\n{2,}) // followed by a blank line - ) - /g,hashElement); - */ - text = text.replace(/(\n\n[ ]{0,3}[ \t]*(?=\n{2,}))/g,hashElement); - - // PHP and ASP-style processor instructions ( and <%...%>) - - /* - text = text.replace(/ - (?: - \n\n // Starting after a blank line - ) - ( // save in $1 - [ ]{0,3} // attacklab: g_tab_width - 1 - (?: - <([?%]) // $2 - [^\r]*? - \2> - ) - [ \t]* - (?=\n{2,}) // followed by a blank line - ) - /g,hashElement); - */ - text = text.replace(/(?:\n\n)([ ]{0,3}(?:<([?%])[^\r]*?\2>)[ \t]*(?=\n{2,}))/g,hashElement); - - // attacklab: Undo double lines (see comment at top of this function) - text = text.replace(/\n\n/g,"\n"); - return text; -} - -var hashElement = function(wholeMatch,m1) { - var blockText = m1; - - // Undo double lines - blockText = blockText.replace(/\n\n/g,"\n"); - blockText = blockText.replace(/^\n/,""); - - // strip trailing blank lines - blockText = blockText.replace(/\n+$/g,""); - - // Replace the element text with a marker ("~KxK" where x is its key) - blockText = "\n\n~K" + (g_html_blocks.push(blockText)-1) + "K\n\n"; - - return blockText; -}; - -var _RunBlockGamut = function(text) { -// -// These are all the transformations that form block-level -// tags like paragraphs, headers, and list items. -// - text = _DoHeaders(text); - - // Do Horizontal Rules: - var key = hashBlock("
"); - text = text.replace(/^[ ]{0,2}([ ]?\*[ ]?){3,}[ \t]*$/gm,key); - text = text.replace(/^[ ]{0,2}([ ]?\-[ ]?){3,}[ \t]*$/gm,key); - text = text.replace(/^[ ]{0,2}([ ]?\_[ ]?){3,}[ \t]*$/gm,key); - - text = _DoLists(text); - text = _DoCodeBlocks(text); - text = _DoBlockQuotes(text); - - // We already ran _HashHTMLBlocks() before, in Markdown(), but that - // was to escape raw HTML in the original Markdown source. This time, - // we're escaping the markup we've just created, so that we don't wrap - //

tags around block-level tags. - text = _HashHTMLBlocks(text); - text = _FormParagraphs(text); - - return text; -} - - -var _RunSpanGamut = function(text) { -// -// These are all the transformations that occur *within* block-level -// tags like paragraphs, headers, and list items. -// - - text = _DoCodeSpans(text); - text = _EscapeSpecialCharsWithinTagAttributes(text); - text = _EncodeBackslashEscapes(text); - - // Process anchor and image tags. Images must come first, - // because ![foo][f] looks like an anchor. - text = _DoImages(text); - text = _DoAnchors(text); - - // Make links out of things like `` - // Must come after _DoAnchors(), because you can use < and > - // delimiters in inline links like [this](). - text = _DoAutoLinks(text); - text = _EncodeAmpsAndAngles(text); - text = _DoItalicsAndBold(text); - - // Do hard breaks: - text = text.replace(/ +\n/g,"
\n"); - - return text; -} - -var _EscapeSpecialCharsWithinTagAttributes = function(text) { -// -// Within tags -- meaning between < and > -- encode [\ ` * _] so they -// don't conflict with their use in Markdown for code, italics and strong. -// - - // Build a regex to find HTML tags and comments. See Friedl's - // "Mastering Regular Expressions", 2nd Ed., pp. 200-201. - var regex = /(<[a-z\/!$]("[^"]*"|'[^']*'|[^'">])*>|)/gi; - - text = text.replace(regex, function(wholeMatch) { - var tag = wholeMatch.replace(/(.)<\/?code>(?=.)/g,"$1`"); - tag = escapeCharacters(tag,"\\`*_"); - return tag; - }); - - return text; -} - -var _DoAnchors = function(text) { -// -// Turn Markdown link shortcuts into XHTML
tags. -// - // - // First, handle reference-style links: [link text] [id] - // - - /* - text = text.replace(/ - ( // wrap whole match in $1 - \[ - ( - (?: - \[[^\]]*\] // allow brackets nested one level - | - [^\[] // or anything else - )* - ) - \] - - [ ]? // one optional space - (?:\n[ ]*)? // one optional newline followed by spaces - - \[ - (.*?) // id = $3 - \] - )()()()() // pad remaining backreferences - /g,_DoAnchors_callback); - */ - text = text.replace(/(\[((?:\[[^\]]*\]|[^\[\]])*)\][ ]?(?:\n[ ]*)?\[(.*?)\])()()()()/g,writeAnchorTag); - - // - // Next, inline-style links: [link text](url "optional title") - // - - /* - text = text.replace(/ - ( // wrap whole match in $1 - \[ - ( - (?: - \[[^\]]*\] // allow brackets nested one level - | - [^\[\]] // or anything else - ) - ) - \] - \( // literal paren - [ \t]* - () // no id, so leave $3 empty - ? // href = $4 - [ \t]* - ( // $5 - (['"]) // quote char = $6 - (.*?) // Title = $7 - \6 // matching quote - [ \t]* // ignore any spaces/tabs between closing quote and ) - )? // title is optional - \) - ) - /g,writeAnchorTag); - */ - text = text.replace(/(\[((?:\[[^\]]*\]|[^\[\]])*)\]\([ \t]*()?[ \t]*((['"])(.*?)\6[ \t]*)?\))/g,writeAnchorTag); - - // - // Last, handle reference-style shortcuts: [link text] - // These must come last in case you've also got [link test][1] - // or [link test](/foo) - // - - /* - text = text.replace(/ - ( // wrap whole match in $1 - \[ - ([^\[\]]+) // link text = $2; can't contain '[' or ']' - \] - )()()()()() // pad rest of backreferences - /g, writeAnchorTag); - */ - text = text.replace(/(\[([^\[\]]+)\])()()()()()/g, writeAnchorTag); - - return text; -} - -var writeAnchorTag = function(wholeMatch,m1,m2,m3,m4,m5,m6,m7) { - if (m7 == undefined) m7 = ""; - var whole_match = m1; - var link_text = m2; - var link_id = m3.toLowerCase(); - var url = m4; - var title = m7; - - if (url == "") { - if (link_id == "") { - // lower-case and turn embedded newlines into spaces - link_id = link_text.toLowerCase().replace(/ ?\n/g," "); - } - url = "#"+link_id; - - if (g_urls[link_id] != undefined) { - url = g_urls[link_id]; - if (g_titles[link_id] != undefined) { - title = g_titles[link_id]; - } - } - else { - if (whole_match.search(/\(\s*\)$/m)>-1) { - // Special case for explicit empty url - url = ""; - } else { - return whole_match; - } - } - } - - url = escapeCharacters(url,"*_"); - var result = ""; - - return result; -} - - -var _DoImages = function(text) { -// -// Turn Markdown image shortcuts into tags. -// - - // - // First, handle reference-style labeled images: ![alt text][id] - // - - /* - text = text.replace(/ - ( // wrap whole match in $1 - !\[ - (.*?) // alt text = $2 - \] - - [ ]? // one optional space - (?:\n[ ]*)? // one optional newline followed by spaces - - \[ - (.*?) // id = $3 - \] - )()()()() // pad rest of backreferences - /g,writeImageTag); - */ - text = text.replace(/(!\[(.*?)\][ ]?(?:\n[ ]*)?\[(.*?)\])()()()()/g,writeImageTag); - - // - // Next, handle inline images: ![alt text](url "optional title") - // Don't forget: encode * and _ - - /* - text = text.replace(/ - ( // wrap whole match in $1 - !\[ - (.*?) // alt text = $2 - \] - \s? // One optional whitespace character - \( // literal paren - [ \t]* - () // no id, so leave $3 empty - ? // src url = $4 - [ \t]* - ( // $5 - (['"]) // quote char = $6 - (.*?) // title = $7 - \6 // matching quote - [ \t]* - )? // title is optional - \) - ) - /g,writeImageTag); - */ - text = text.replace(/(!\[(.*?)\]\s?\([ \t]*()?[ \t]*((['"])(.*?)\6[ \t]*)?\))/g,writeImageTag); - - return text; -} - -var writeImageTag = function(wholeMatch,m1,m2,m3,m4,m5,m6,m7) { - var whole_match = m1; - var alt_text = m2; - var link_id = m3.toLowerCase(); - var url = m4; - var title = m7; - - if (!title) title = ""; - - if (url == "") { - if (link_id == "") { - // lower-case and turn embedded newlines into spaces - link_id = alt_text.toLowerCase().replace(/ ?\n/g," "); - } - url = "#"+link_id; - - if (g_urls[link_id] != undefined) { - url = g_urls[link_id]; - if (g_titles[link_id] != undefined) { - title = g_titles[link_id]; - } - } - else { - return whole_match; - } - } - - alt_text = alt_text.replace(/"/g,"""); - url = escapeCharacters(url,"*_"); - var result = "\""" + _RunSpanGamut(m1) + "");}); - - text = text.replace(/^(.+)[ \t]*\n-+[ \t]*\n+/gm, - function(matchFound,m1){return hashBlock("

" + _RunSpanGamut(m1) + "

");}); - - // atx-style headers: - // # Header 1 - // ## Header 2 - // ## Header 2 with closing hashes ## - // ... - // ###### Header 6 - // - - /* - text = text.replace(/ - ^(\#{1,6}) // $1 = string of #'s - [ \t]* - (.+?) // $2 = Header text - [ \t]* - \#* // optional closing #'s (not counted) - \n+ - /gm, function() {...}); - */ - - text = text.replace(/^(\#{1,6})[ \t]*(.+?)[ \t]*\#*\n+/gm, - function(wholeMatch,m1,m2) { - var h_level = m1.length; - return hashBlock("" + _RunSpanGamut(m2) + ""); - }); - - return text; -} - -// This declaration keeps Dojo compressor from outputting garbage: -var _ProcessListItems; - -var _DoLists = function(text) { -// -// Form HTML ordered (numbered) and unordered (bulleted) lists. -// - - // attacklab: add sentinel to hack around khtml/safari bug: - // http://bugs.webkit.org/show_bug.cgi?id=11231 - text += "~0"; - - // Re-usable pattern to match any entirel ul or ol list: - - /* - var whole_list = / - ( // $1 = whole list - ( // $2 - [ ]{0,3} // attacklab: g_tab_width - 1 - ([*+-]|\d+[.]) // $3 = first list item marker - [ \t]+ - ) - [^\r]+? - ( // $4 - ~0 // sentinel for workaround; should be $ - | - \n{2,} - (?=\S) - (?! // Negative lookahead for another list item marker - [ \t]* - (?:[*+-]|\d+[.])[ \t]+ - ) - ) - )/g - */ - var whole_list = /^(([ ]{0,3}([*+-]|\d+[.])[ \t]+)[^\r]+?(~0|\n{2,}(?=\S)(?![ \t]*(?:[*+-]|\d+[.])[ \t]+)))/gm; - - if (g_list_level) { - text = text.replace(whole_list,function(wholeMatch,m1,m2) { - var list = m1; - var list_type = (m2.search(/[*+-]/g)>-1) ? "ul" : "ol"; - - // Turn double returns into triple returns, so that we can make a - // paragraph for the last item in a list, if necessary: - list = list.replace(/\n{2,}/g,"\n\n\n");; - var result = _ProcessListItems(list); - - // Trim any trailing whitespace, to put the closing `` - // up on the preceding line, to get it past the current stupid - // HTML block parser. This is a hack to work around the terrible - // hack that is the HTML block parser. - result = result.replace(/\s+$/,""); - result = "<"+list_type+">" + result + "\n"; - return result; - }); - } else { - whole_list = /(\n\n|^\n?)(([ ]{0,3}([*+-]|\d+[.])[ \t]+)[^\r]+?(~0|\n{2,}(?=\S)(?![ \t]*(?:[*+-]|\d+[.])[ \t]+)))/g; - text = text.replace(whole_list,function(wholeMatch,m1,m2,m3) { - var runup = m1; - var list = m2; - - var list_type = (m3.search(/[*+-]/g)>-1) ? "ul" : "ol"; - // Turn double returns into triple returns, so that we can make a - // paragraph for the last item in a list, if necessary: - var list = list.replace(/\n{2,}/g,"\n\n\n");; - var result = _ProcessListItems(list); - result = runup + "<"+list_type+">\n" + result + "\n"; - return result; - }); - } - - // attacklab: strip sentinel - text = text.replace(/~0/,""); - - return text; -} - -_ProcessListItems = function(list_str) { -// -// Process the contents of a single ordered or unordered list, splitting it -// into individual list items. -// - // The $g_list_level global keeps track of when we're inside a list. - // Each time we enter a list, we increment it; when we leave a list, - // we decrement. If it's zero, we're not in a list anymore. - // - // We do this because when we're not inside a list, we want to treat - // something like this: - // - // I recommend upgrading to version - // 8. Oops, now this line is treated - // as a sub-list. - // - // As a single paragraph, despite the fact that the second line starts - // with a digit-period-space sequence. - // - // Whereas when we're inside a list (or sub-list), that line will be - // treated as the start of a sub-list. What a kludge, huh? This is - // an aspect of Markdown's syntax that's hard to parse perfectly - // without resorting to mind-reading. Perhaps the solution is to - // change the syntax rules such that sub-lists must start with a - // starting cardinal number; e.g. "1." or "a.". - - g_list_level++; - - // trim trailing blank lines: - list_str = list_str.replace(/\n{2,}$/,"\n"); - - // attacklab: add sentinel to emulate \z - list_str += "~0"; - - /* - list_str = list_str.replace(/ - (\n)? // leading line = $1 - (^[ \t]*) // leading whitespace = $2 - ([*+-]|\d+[.]) [ \t]+ // list marker = $3 - ([^\r]+? // list item text = $4 - (\n{1,2})) - (?= \n* (~0 | \2 ([*+-]|\d+[.]) [ \t]+)) - /gm, function(){...}); - */ - list_str = list_str.replace(/(\n)?(^[ \t]*)([*+-]|\d+[.])[ \t]+([^\r]+?(\n{1,2}))(?=\n*(~0|\2([*+-]|\d+[.])[ \t]+))/gm, - function(wholeMatch,m1,m2,m3,m4){ - var item = m4; - var leading_line = m1; - var leading_space = m2; - - if (leading_line || (item.search(/\n{2,}/)>-1)) { - item = _RunBlockGamut(_Outdent(item)); - } - else { - // Recursion for sub-lists: - item = _DoLists(_Outdent(item)); - item = item.replace(/\n$/,""); // chomp(item) - item = _RunSpanGamut(item); - } - - return "
  • " + item + "
  • \n"; - } - ); - - // attacklab: strip sentinel - list_str = list_str.replace(/~0/g,""); - - g_list_level--; - return list_str; -} - - -var _DoCodeBlocks = function(text) { -// -// Process Markdown `
    ` blocks.
    -//
    -
    -	/*
    -		text = text.replace(text,
    -			/(?:\n\n|^)
    -			(								// $1 = the code block -- one or more lines, starting with a space/tab
    -				(?:
    -					(?:[ ]{4}|\t)			// Lines must start with a tab or a tab-width of spaces - attacklab: g_tab_width
    -					.*\n+
    -				)+
    -			)
    -			(\n*[ ]{0,3}[^ \t\n]|(?=~0))	// attacklab: g_tab_width
    -		/g,function(){...});
    -	*/
    -
    -	// attacklab: sentinel workarounds for lack of \A and \Z, safari\khtml bug
    -	text += "~0";
    -
    -	text = text.replace(/(?:\n\n|^)((?:(?:[ ]{4}|\t).*\n+)+)(\n*[ ]{0,3}[^ \t\n]|(?=~0))/g,
    -		function(wholeMatch,m1,m2) {
    -			var codeblock = m1;
    -			var nextChar = m2;
    -
    -			codeblock = _EncodeCode( _Outdent(codeblock));
    -			codeblock = _Detab(codeblock);
    -			codeblock = codeblock.replace(/^\n+/g,""); // trim leading newlines
    -			codeblock = codeblock.replace(/\n+$/g,""); // trim trailing whitespace
    -
    -			codeblock = "
    " + codeblock + "\n
    "; - - return hashBlock(codeblock) + nextChar; - } - ); - - // attacklab: strip sentinel - text = text.replace(/~0/,""); - - return text; -} - -var hashBlock = function(text) { - text = text.replace(/(^\n+|\n+$)/g,""); - return "\n\n~K" + (g_html_blocks.push(text)-1) + "K\n\n"; -} - - -var _DoCodeSpans = function(text) { -// -// * Backtick quotes are used for spans. -// -// * You can use multiple backticks as the delimiters if you want to -// include literal backticks in the code span. So, this input: -// -// Just type ``foo `bar` baz`` at the prompt. -// -// Will translate to: -// -//

    Just type foo `bar` baz at the prompt.

    -// -// There's no arbitrary limit to the number of backticks you -// can use as delimters. If you need three consecutive backticks -// in your code, use four for delimiters, etc. -// -// * You can use spaces to get literal backticks at the edges: -// -// ... type `` `bar` `` ... -// -// Turns to: -// -// ... type `bar` ... -// - - /* - text = text.replace(/ - (^|[^\\]) // Character before opening ` can't be a backslash - (`+) // $2 = Opening run of ` - ( // $3 = The code block - [^\r]*? - [^`] // attacklab: work around lack of lookbehind - ) - \2 // Matching closer - (?!`) - /gm, function(){...}); - */ - - text = text.replace(/(^|[^\\])(`+)([^\r]*?[^`])\2(?!`)/gm, - function(wholeMatch,m1,m2,m3,m4) { - var c = m3; - c = c.replace(/^([ \t]*)/g,""); // leading whitespace - c = c.replace(/[ \t]*$/g,""); // trailing whitespace - c = _EncodeCode(c); - return m1+""+c+""; - }); - - return text; -} - - -var _EncodeCode = function(text) { -// -// Encode/escape certain characters inside Markdown code runs. -// The point is that in code, these characters are literals, -// and lose their special Markdown meanings. -// - // Encode all ampersands; HTML entities are not - // entities within a Markdown code span. - text = text.replace(/&/g,"&"); - - // Do the angle bracket song and dance: - text = text.replace(//g,">"); - - // Now, escape characters that are magic in Markdown: - text = escapeCharacters(text,"\*_{}[]\\",false); - -// jj the line above breaks this: -//--- - -//* Item - -// 1. Subitem - -// special char: * -//--- - - return text; -} - - -var _DoItalicsAndBold = function(text) { - - // must go first: - text = text.replace(/(\*\*|__)(?=\S)([^\r]*?\S[*_]*)\1/g, - "$2"); - - text = text.replace(/(\*|_)(?=\S)([^\r]*?\S)\1/g, - "$2"); - - return text; -} - - -var _DoBlockQuotes = function(text) { - - /* - text = text.replace(/ - ( // Wrap whole match in $1 - ( - ^[ \t]*>[ \t]? // '>' at the start of a line - .+\n // rest of the first line - (.+\n)* // subsequent consecutive lines - \n* // blanks - )+ - ) - /gm, function(){...}); - */ - - text = text.replace(/((^[ \t]*>[ \t]?.+\n(.+\n)*\n*)+)/gm, - function(wholeMatch,m1) { - var bq = m1; - - // attacklab: hack around Konqueror 3.5.4 bug: - // "----------bug".replace(/^-/g,"") == "bug" - - bq = bq.replace(/^[ \t]*>[ \t]?/gm,"~0"); // trim one level of quoting - - // attacklab: clean up hack - bq = bq.replace(/~0/g,""); - - bq = bq.replace(/^[ \t]+$/gm,""); // trim whitespace-only lines - bq = _RunBlockGamut(bq); // recurse - - bq = bq.replace(/(^|\n)/g,"$1 "); - // These leading spaces screw with
     content, so we need to fix that:
    -			bq = bq.replace(
    -					/(\s*
    [^\r]+?<\/pre>)/gm,
    -				function(wholeMatch,m1) {
    -					var pre = m1;
    -					// attacklab: hack around Konqueror 3.5.4 bug:
    -					pre = pre.replace(/^  /mg,"~0");
    -					pre = pre.replace(/~0/g,"");
    -					return pre;
    -				});
    -
    -			return hashBlock("
    \n" + bq + "\n
    "); - }); - return text; -} - - -var _FormParagraphs = function(text) { -// -// Params: -// $text - string to process with html

    tags -// - - // Strip leading and trailing lines: - text = text.replace(/^\n+/g,""); - text = text.replace(/\n+$/g,""); - - var grafs = text.split(/\n{2,}/g); - var grafsOut = new Array(); - - // - // Wrap

    tags. - // - var end = grafs.length; - for (var i=0; i= 0) { - grafsOut.push(str); - } - else if (str.search(/\S/) >= 0) { - str = _RunSpanGamut(str); - str = str.replace(/^([ \t]*)/g,"

    "); - str += "

    " - grafsOut.push(str); - } - - } - - // - // Unhashify HTML blocks - // - end = grafsOut.length; - for (var i=0; i= 0) { - var blockText = g_html_blocks[RegExp.$1]; - blockText = blockText.replace(/\$/g,"$$$$"); // Escape any dollar signs - grafsOut[i] = grafsOut[i].replace(/~K\d+K/,blockText); - } - } - - return grafsOut.join("\n\n"); -} - - -var _EncodeAmpsAndAngles = function(text) { -// Smart processing for ampersands and angle brackets that need to be encoded. - - // Ampersand-encoding based entirely on Nat Irons's Amputator MT plugin: - // http://bumppo.net/projects/amputator/ - text = text.replace(/&(?!#?[xX]?(?:[0-9a-fA-F]+|\w+);)/g,"&"); - - // Encode naked <'s - text = text.replace(/<(?![a-z\/?\$!])/gi,"<"); - - return text; -} - - -var _EncodeBackslashEscapes = function(text) { -// -// Parameter: String. -// Returns: The string, with after processing the following backslash -// escape sequences. -// - - // attacklab: The polite way to do this is with the new - // escapeCharacters() function: - // - // text = escapeCharacters(text,"\\",true); - // text = escapeCharacters(text,"`*_{}[]()>#+-.!",true); - // - // ...but we're sidestepping its use of the (slow) RegExp constructor - // as an optimization for Firefox. This function gets called a LOT. - - text = text.replace(/\\(\\)/g,escapeCharacters_callback); - text = text.replace(/\\([`*_{}\[\]()>#+-.!])/g,escapeCharacters_callback); - return text; -} - - -var _DoAutoLinks = function(text) { - - text = text.replace(/<((https?|ftp|dict):[^'">\s]+)>/gi,"
    $1"); - - // Email addresses: - - /* - text = text.replace(/ - < - (?:mailto:)? - ( - [-.\w]+ - \@ - [-a-z0-9]+(\.[-a-z0-9]+)*\.[a-z]+ - ) - > - /gi, _DoAutoLinks_callback()); - */ - text = text.replace(/<(?:mailto:)?([-.\w]+\@[-a-z0-9]+(\.[-a-z0-9]+)*\.[a-z]+)>/gi, - function(wholeMatch,m1) { - return _EncodeEmailAddress( _UnescapeSpecialChars(m1) ); - } - ); - - return text; -} - - -var _EncodeEmailAddress = function(addr) { -// -// Input: an email address, e.g. "foo@example.com" -// -// Output: the email address as a mailto link, with each character -// of the address encoded as either a decimal or hex entity, in -// the hopes of foiling most address harvesting spam bots. E.g.: -// -// foo -// @example.com -// -// Based on a filter by Matthew Wickline, posted to the BBEdit-Talk -// mailing list: -// - - // attacklab: why can't javascript speak hex? - function char2hex(ch) { - var hexDigits = '0123456789ABCDEF'; - var dec = ch.charCodeAt(0); - return(hexDigits.charAt(dec>>4) + hexDigits.charAt(dec&15)); - } - - var encode = [ - function(ch){return "&#"+ch.charCodeAt(0)+";";}, - function(ch){return "&#x"+char2hex(ch)+";";}, - function(ch){return ch;} - ]; - - addr = "mailto:" + addr; - - addr = addr.replace(/./g, function(ch) { - if (ch == "@") { - // this *must* be encoded. I insist. - ch = encode[Math.floor(Math.random()*2)](ch); - } else if (ch !=":") { - // leave ':' alone (to spot mailto: later) - var r = Math.random(); - // roughly 10% raw, 45% hex, 45% dec - ch = ( - r > .9 ? encode[2](ch) : - r > .45 ? encode[1](ch) : - encode[0](ch) - ); - } - return ch; - }); - - addr = "" + addr + ""; - addr = addr.replace(/">.+:/g,"\">"); // strip the mailto: from the visible part - - return addr; -} - - -var _UnescapeSpecialChars = function(text) { -// -// Swap back in all the special characters we've hidden. -// - text = text.replace(/~E(\d+)E/g, - function(wholeMatch,m1) { - var charCodeToReplace = parseInt(m1); - return String.fromCharCode(charCodeToReplace); - } - ); - return text; -} - - -var _Outdent = function(text) { -// -// Remove one level of line-leading tabs or spaces -// - - // attacklab: hack around Konqueror 3.5.4 bug: - // "----------bug".replace(/^-/g,"") == "bug" - - text = text.replace(/^(\t|[ ]{1,4})/gm,"~0"); // attacklab: g_tab_width - - // attacklab: clean up hack - text = text.replace(/~0/g,"") - - return text; -} - -var _Detab = function(text) { -// attacklab: Detab's completely rewritten for speed. -// In perl we could fix it by anchoring the regexp with \G. -// In javascript we're less fortunate. - - // expand first n-1 tabs - text = text.replace(/\t(?=\t)/g," "); // attacklab: g_tab_width - - // replace the nth with two sentinels - text = text.replace(/\t/g,"~A~B"); - - // use the sentinel to anchor our regex so it doesn't explode - text = text.replace(/~B(.+?)~A/g, - function(wholeMatch,m1,m2) { - var leadingText = m1; - var numSpaces = 4 - leadingText.length % 4; // attacklab: g_tab_width - - // there *must* be a better way to do this: - for (var i=0; i reporter.js

    reporter.js

    Steal vows console object

    var	consoleObj = require("../lib/console.js");
    -
    -var options = { tail: '\n' };
    -var stylize = consoleObj.stylize,
    -    puts = consoleObj.puts(options);

    Construct a report object

    var report = {

    store contexts

    	"contexts": {},

    When vows fires report we add various data to our internal structure -For a context, just inject a context object into our internal list -For vow we add a vows object to that context -For subject set the subject -For finish, print the structure, then print the report

    	"add": function _add(obj) {
    -		if (obj[0] === "context") {
    -			this.contexts[obj[1]] = { vows: {} };
    -		} else if (obj[0] === "vow") {
    -			var vow = obj[1];
    -			this.contexts[vow.context].vows[vow.title] = vow;
    -		} else if (obj[0] === "subject") {
    -			this.subject = obj[1];
    -		} else if (obj[0] === "finish") {
    -			this.print();
    -			this.printReport(obj[1]);
    -		}
    -	},

    Code horrors :(

    	"print": function _print() {
    -		var self = this;
    -		puts('\n♢ ' + stylize(this.subject, 'bold') + '\n');
    -
    -		var contexts = {};

    Find the parent context based on the name

    		function findParent(contexts, text) {
    -			var obj = false;
    -			var newKey = text;
    -			for (var key in contexts) {
    -				var context = contexts[key];
    -				if (context.oldKey) {
    -					key = context.oldKey;
    -				}
    -				if (context.contexts) {
    -					var arr = findParent(context.contexts, text);
    -					if (arr) {
    -						return arr;
    -					}
    -				} 
    -				if (text.indexOf(key) !== -1) {
    -					newKey = text.replace(key, "");	
    -					obj = context;
    -					break;
    -				}
    -			}
    -			if (obj) {
    -				return [obj, newKey];	
    -			} else {
    -				return false;
    -			}
    -		};

    Create the real contexts object from this.contexts

    		Object.keys(this.contexts).sort().forEach(function(key) {
    -			var arr = findParent(contexts, key);
    -			if (arr) {
    -				var context = arr[0];
    -				var newKey = arr[1];	
    -			}
    -
    -			if (!arr) {
    -				contexts[key] = self.contexts[key];
    -				if (!contexts[key].contexts) {
    -					contexts[key].contexts = {};
    -				}
    -			} else {
    -				context.contexts[newKey] = self.contexts[key];
    -				context.contexts[newKey].oldKey = key;
    -				if (!context.contexts[newKey].contexts) {
    -					context.contexts[newKey].contexts = {};
    -				}
    -			}
    -		});

    print a context recursively

    		function print(context, key, depth) {
    -			var whitespace = (new Array(depth + 1)).join("  ");
    -			puts(whitespace + consoleObj.contextText(key));
    -
    -			Object.keys(context.vows).forEach(function(key2) {
    -				puts(whitespace + " " + consoleObj.vowText(context.vows[key2]));
    -			});
    -			if (context.contexts) {
    -				Object.keys(context.contexts).forEach(function(key) {
    -					print(context.contexts[key], key, depth + 1);
    -				});
    -			}
    -		}

    For each context print it

    		Object.keys(contexts).forEach(function(key) {
    -			print(contexts[key], key, 0);
    -		});
    -	},

    delegate printing of the report to vows console

    	"printReport": function _printReport(report) {
    -		puts(consoleObj.result(report).join('\n'));
    -	}
    -}
    -
    -exports.name = 'prettyprint';

    Might be needed. Who knows o/

    exports.setStream = function _setStream(s) {
    -	options.stream = s;
    -};

    When vows reports ask our report to add the object

    exports.report = function _report(obj) {
    -	report.add(obj);
    -};
    -
    -
    \ No newline at end of file diff --git a/node_modules/vows-is/docs/vows-is.html b/node_modules/vows-is/docs/vows-is.html deleted file mode 100644 index b3ce5f2..0000000 --- a/node_modules/vows-is/docs/vows-is.html +++ /dev/null @@ -1,285 +0,0 @@ - vows-is.js

    vows-is.js

    var fluent = require("vows-fluent"),
    -    request = require("request"),
    -    should = require("should"),
    -    EventEmitter = require("events").EventEmitter.Prototype,
    -    AssertionConstructor = should.Assertion,
    -    Assertion = AssertionConstructor.prototype,
    -    Trait = require("traits").Trait,
    -    Topic = fluent.Topic,
    -    Vow = fluent.Vow,
    -    Context = fluent.Context;

    Remove should from the prototype.

    delete Object.prototype.should;

    Redefine should in a friendly manner.

    Object.defineProperty(Object.prototype, "should", {
    -    get: function() {
    -        return this._should || new AssertionConstructor(this); 
    -    },
    -    set: function(val) {
    -        this._should = val;
    -    },
    -    configurable: true
    -});

    defaults objects overwritten through config.

    var defaults = {},

    test whether an url is an url or has a method in it.

        test_uri = /^(GET|POST|PUT|HEAD|DELETE)(.*)/;

    utility create function

    var create = function _create(trait) {
    -    return Object.create(Object.prototype, trait)
    -};

    factory to get a server instance. Cached internally

    var getServer = function _getServer(cb) {
    -    if (getServer.app) {
    -        cb(getServer.app);
    -    } else {
    -        defaults.server.factory(function(app) {
    -            getServer.app = app;
    -            cb(app);    
    -        });
    -    }
    -}

    Is object used in topic().is

    exports.Is = {

    dummy getter

        get a() {
    -        return this;
    -    },

    dummy getter

        get an() {
    -        return this;
    -    },

    invocation. This will invoke the previous topic with values -and return it

        "invocation": function _invocation() {
    -        var args = arguments;
    -        this._parent.set(wrapTopicInError(function _topic(topic) {
    -            return topic.apply(null, args);
    -        }));
    -        return this.end();
    -    },

    request. This sets the value of the topic to be a request function. -It goes off and asks for a server from the server factory, -Then generates the url to request. It makes a request to your -server then uses this.callback to set the response as the topic

        "request": function _request(url) {
    -        this._parent.set(function _topic() {
    -            var cb = this.callback;
    -            getServer(function _getServer(server) {
    -                var options;
    -                if (typeof url === "string") {
    -                    options = {};
    -                    var match = url && url.match(test_uri);
    -                    if (match) {
    -                        options.method = match[1];
    -                        options.uri = defaults.server.uri + match[2].substr(1);
    -                    } else {
    -                        options.uri = defaults.server.uri + uri 
    -                    }   
    -                } else {
    -                    options = url;
    -                }
    -                request(options, function _handleRequest(err, res, body) {
    -                    cb(err, res);
    -                });
    -            });
    -        });
    -        return this.end()
    -    },

    Set the topic to be a property of the current topic

        "property": function _property(name) {
    -        this._parent.set(function _topic(topic) {
    -            return topic[name];
    -        });
    -        return this.end()
    -    },

    end the is abstraction returning the context owning the topic.

        "end": function _end() {
    -        return this._parent.parent()
    -    }
    -};
    -
    -var wrapTopicInError = function _wrap(val) {
    -    return function() {
    -        try {
    -            return val.apply(this, arguments);
    -        } catch (e) {
    -            var ev = Object.create(EventEmitter);
    -            process.nextTick(function() {
    -                ev.emit('error', e)
    -            });
    -            return ev;
    -        }
    -    };
    -}

    Property descriptor for property is. -Creates a Is, sets the parent and returns it. -Typeof function check supports topic.is and topic().is -The function is used to allow topic.is(value)

    var propertyDescriptorIs = {
    -    "set": function _set() {},
    -    "get": function _get() {
    -        var i = create(Trait(exports.Is));
    -        if (typeof this === "function") {
    -            i._parent = this();
    -        } else {
    -            i._parent = this;
    -        }
    -        var f = (function _is(val) {
    -            if (typeof val === "function") {
    -                var val = wrapTopicInError(val);
    -            }
    -            this._parent.set(val);
    -            return this.end();
    -        }).bind(i);
    -        var keys = Object.getOwnPropertyNames(i);
    -        keys.forEach(function(key) {
    -            var pd = Object.getOwnPropertyDescriptor(i, key);
    -            Object.defineProperty(f, key, pd);
    -        });
    -        return f;
    -    }
    -};

    Add is as a getter to the topic to support topic().is

    Object.defineProperty(Topic, "is", propertyDescriptorIs);

    replace topic method with a getter that returns the function -make sure to bind this and add the is property to the function

    var old_topic = Context.topic;
    -Object.defineProperty(Context, "topic", {
    -    "set": function _set() {},
    -    "get": function _get() {
    -        var f = old_topic.bind(this);
    -        Object.defineProperty(f, "is", propertyDescriptorIs);
    -        return f;
    -    }
    -});

    It object used in vow().it

    exports.It = {

    Creates a should wrapper and returns it. -Also sets the vow value to unwrap the should wrapper.

        get should() {
    -        var s = create(Trait(exports.Should));
    -        s._stack = [];
    -        s._parent = this._parent;
    -        return s;
    -    }
    -}

    Property descriptor for property it. -Creates a It, sets the parent and returns it. -Typeof function check supports vow.it and vow().it

    var propertyDescriptorIt = {
    -    "set": function _set() {},
    -    "get": function _get() {
    -        var i = create(Trait(exports.It));
    -        if (typeof this === "function") {
    -            i._parent = this();
    -        } else {
    -            i._parent = this;   
    -        }
    -        return i;
    -    }
    -};

    Add is as a getter on Vow to support vow().it

    Object.defineProperty(Vow, "it", propertyDescriptorIt);

    Replace vow method with a getter that returns the function -make sure to bind the scope and add it to the vow value

    var old_vow = Context.vow
    -Object.defineProperty(Context, "vow", {
    -    "set": function _set() {},
    -    "get": function _get() {
    -        var f = old_vow.bind(this);
    -        Object.defineProperty(f, "it", propertyDescriptorIt);
    -        return f;
    -    }
    -});

    Extension of the should.js Assertion object

    exports.Assertion = create(Trait.override(Trait({

    header. Assert it has property headers and that the -header name has value val

        "header": function _header(name, val) {
    -        return this.property("headers").with.property(name, val);
    -    },

    error getter. Set's the object to the error and calls ok.

        get error() {
    -        this.obj = this._error
    -        return this.ok;
    -    },
    -}), Trait(Assertion)));

    a Should object which is a wrapper around should.js

    exports.Should = {

    transforms the stack into a nice assertion string

        "prettyPrint": function _prettyPrint() {
    -        var arr = this._stack.map(function _map(val) {
    -            var str = val.key;
    -            if (exports.prettyPrint[val.key]) {
    -                str += " " + exports.prettyPrint[val.key](val.args);
    -            } else if (val.args.length) {
    -                str += " " + val.args.join(" ");
    -            }
    -            return str;
    -        });
    -        arr.unshift("should");
    -        return arr.join(" ");
    -    },

    end the abstraction. This creates a should.js assertion -and unravels the stack running every assertion. -it then returns context that the vow belongs to.

        "end": function _end() {
    -        var s = create(Trait(exports.Assertion));
    -        s.obj = this._obj;
    -        s._error = this._error;
    -        this._stack.forEach(function _each(val) {
    -            if (val.type === 'get') {
    -                s = s[val.key];
    -            } else {
    -                s = s[val.key].apply(s, val.args);
    -            }
    -        });
    -        return this._parent.parent();
    -    }
    -};

    A stack of prettyPrint methods to make the assertions look pretty

    exports.prettyPrint = {
    -    "header": function _property(args) {
    -        return args[0] + " with value " + args[1];
    -    }
    -};

    For each of the methods that can be called on a context add them to should. -This tells the Should wrappers to end itself and return back to the context.

    ["vow", "context", "parent", "batch", "suite", "partial"].forEach(function _each(key) {
    -    exports.Should[key] = function _parent() {
    -        var parent = this._parent.parent();
    -        if (!this._parent._name) {
    -            this._parent.name(this.prettyPrint());
    -        }
    -        var that = this;
    -        this._parent.set(function _set(err, value) {
    -            that._obj = value;
    -            that._error = err;
    -            that.end();
    -        });
    -        return parent[key].apply(parent, arguments);
    -    };
    -});

    Replace the vow method of Should with a getter so chaining doesn't break

    var should_vow = exports.Should.vow
    -Object.defineProperty(exports.Should, "vow", {
    -    "set": function _set() {},
    -    "get": function _get() {
    -        var f = should_vow.bind(this);
    -        Object.defineProperty(f, "it", propertyDescriptorIt);
    -        return f;
    -    }
    -});

    For each of the methods of exports.Assersion add a wrapper -to Should. The wrapper simply saves the command on a stack. -The stack is unravelled when the should wrapper ends.

    Object.keys(exports.Assertion).forEach(function _each(key) {
    -    if (!exports.Should.hasOwnProperty(key)) {
    -        var descriptor = Object.getOwnPropertyDescriptor(exports.Assertion, key);
    -        var name = descriptor.get ? "get" : "value";
    -        descriptor[name] = function _descriptor() {
    -            this._stack.push({
    -                "type": name,
    -                "key": key,
    -                "args": Array.prototype.slice.call(arguments)
    -            });
    -            return this;
    -        }
    -        Object.defineProperty(exports.Should, key, descriptor);
    -    }
    -});

    Config method sets defaults

    exports.config = function _init(obj) {
    -    Object.keys(obj).forEach(function _each(key) {
    -        defaults[key] = obj[key];
    -    });
    -    if (defaults.server.defaults) {
    -        request = request.defaults(defaults.server.defaults);
    -    }
    -    return this;
    -};

    partial method that runs a predefined partial function on the context

    Context.partial = function _partial(name, data) {
    -    var p = exports._partial[name];
    -    return p(this, data);
    -};

    Store hashes of partials

    exports._partial = {};

    Store a partial by name

    exports.partial = function _partial(name, f) {
    -    this._partial[name] = f;
    -    return this;
    -};

    Expose methods of vows-fluent on exports.

    Object.keys(fluent).forEach(function _each(key) {
    -    exports[key] = fluent[key];
    -});

    Expose the custom vows-is reporter

    exports.reporter = require("./reporter.js");

    Expose vows console

    exports.console = require("../lib/console.js");

    End function will various clean up functions -default.server.kill is your clean up function to kill the server

    exports.end = function _end() {
    -    if (defaults.server && 
    -        defaults.server.kill && 
    -        typeof defaults.server.kill === "function"
    -    ) {
    -        getServer(function(server) {
    -            defaults.server.kill(server);   
    -        });
    -    }
    -};

    expose should object from should.js

    exports.should = should;

    Punch vows in the face

    var stylize = exports.console.stylize;
    -var inspect = exports.console.inspect;
    -
    -require('assert').AssertionError.prototype.toString = function () {
    -    var that = this,
    -        source = this.stack && this.stack.match(/([a-zA-Z0-9._-]+\.js)(:\d+):\d+/);
    -
    -    function parse(str) {
    -        return str.replace(/{actual}/g,   inspect(that.actual)).
    -                   replace(/{operator}/g, stylize(that.operator, 'bold')).
    -                   replace(/{expected}/g, (that.expected instanceof Function)
    -                                          ? that.expected.name
    -                                          : inspect(that.expected));
    -    }
    -
    -    if (this.message) {
    -        var msg = stylize(parse(this.message), 'yellow');
    -        if (source) {
    -            msg += stylize(' // ' + source[1] + source[2], 'grey');
    -        }
    -        return msg;
    -    } else {
    -        return stylize([
    -            this.expected,
    -            this.operator,
    -            this.actual
    -        ].join(' '), 'yellow');
    -    }
    -};
    -
    -
    \ No newline at end of file diff --git a/node_modules/vows-is/lib/console.js b/node_modules/vows-is/lib/console.js deleted file mode 100644 index 19895f1..0000000 --- a/node_modules/vows-is/lib/console.js +++ /dev/null @@ -1,132 +0,0 @@ -// copied verbatim from vows/lib/vows/console.js -var eyes = require('eyes').inspector({ stream: null, styles: false }); - -// Stylize a string -exports.stylize = function stylize(str, style) { - var styles = { - 'bold' : [1, 22], - 'italic' : [3, 23], - 'underline' : [4, 24], - 'cyan' : [96, 39], - 'yellow' : [33, 39], - 'green' : [32, 39], - 'red' : [31, 39], - 'grey' : [90, 39], - 'green-hi' : [92, 32], - }; - return '\033[' + styles[style][0] + 'm' + str + - '\033[' + styles[style][1] + 'm'; -}; - -var $ = exports.$ = function (str) { - str = new(String)(str); - - ['bold', 'grey', 'yellow', 'red', 'green', 'white', 'cyan', 'italic'].forEach(function (style) { - Object.defineProperty(str, style, { - get: function () { - return exports.$(exports.stylize(this, style)); - } - }); - }); - return str; -}; - -exports.puts = function (options) { - var stylize = exports.stylize; - options.stream || (options.stream = process.stdout); - options.tail = options.tail || ''; - - return function (args) { - args = Array.prototype.slice.call(arguments); - if (!options.raw) { - args = args.map(function (a) { - return a.replace(/`([^`]+)`/g, function (_, capture) { return stylize(capture, 'italic') }) - .replace(/\*([^*]+)\*/g, function (_, capture) { return stylize(capture, 'bold') }); - }); - } - return options.stream.write(args.join('\n') + options.tail); - }; -}; - -exports.result = function (event) { - var result = [], buffer = [], time = '', header; - var complete = event.honored + event.pending + event.errored + event.broken; - var status = (event.errored && 'errored') || (event.broken && 'broken') || - (event.honored && 'honored') || (event.pending && 'pending'); - - if (event.total === 0) { - return [$("Could not find any tests to run.").bold.red]; - } - - event.honored && result.push($(event.honored).bold + " honored"); - event.broken && result.push($(event.broken).bold + " broken"); - event.errored && result.push($(event.errored).bold + " errored"); - event.pending && result.push($(event.pending).bold + " pending"); - - if (complete < event.total) { - result.push($(event.total - complete).bold + " dropped"); - } - - result = result.join(' ∙ '); - - header = { - honored: '✓ ' + $('OK').bold.green, - broken: '✗ ' + $('Broken').bold.yellow, - errored: '✗ ' + $('Errored').bold.red, - pending: '- ' + $('Pending').bold.cyan - }[status] + ' » '; - - if (typeof(event.time) === 'number') { - time = ' (' + event.time.toFixed(3) + 's)'; - time = this.stylize(time, 'grey'); - } - buffer.push(header + result + time + '\n'); - - return buffer; -}; - -exports.inspect = function inspect(val) { - return '\033[1m' + eyes(val) + '\033[22m'; -}; - -exports.error = function (obj) { - var string = '✗ ' + $('Errored ').red + '» '; - string += $(obj.error).red.bold + '\n'; - string += (obj.context ? ' in ' + $(obj.context).red + '\n': ''); - string += ' in ' + $(obj.suite.subject).red + '\n'; - string += ' in ' + $(obj.suite._filename).red; - - return string; -}; - -exports.contextText = function (event) { - return ' ' + event; -}; - -exports.vowText = function (event) { - var buffer = []; - - buffer.push(' ' + { - honored: ' ✓ ', - broken: ' ✗ ', - errored: ' ✗ ', - pending: ' - ' - }[event.status] + this.stylize(event.title, ({ - honored: 'green', - broken: 'yellow', - errored: 'red', - pending: 'cyan' - })[event.status])); - - if (event.status === 'broken') { - buffer.push(' » ' + event.exception); - } else if (event.status === 'errored') { - if (event.exception.type === 'promise') { - buffer.push(' » ' + this.stylize("An unexpected error was caught: " + - this.stylize(event.exception.error, 'bold'), 'red')); - } else { - buffer.push(' ' + this.stylize(event.exception, 'red')); - } - } - return buffer.join('\n'); -}; diff --git a/node_modules/vows-is/package.json b/node_modules/vows-is/package.json deleted file mode 100644 index 55f9fdb..0000000 --- a/node_modules/vows-is/package.json +++ /dev/null @@ -1,25 +0,0 @@ -{ - "name": "vows-is", - "description": "A vows topic utility", - "version": "0.1.24", - "author": "Raynos ", - "contributors": [ - { "name": "Raynos", "email": "raynos2@gmail.com", "url":"http://raynos.org" } - ], - "dependencies": { - "vows-fluent": "0.1.10", - "request": "2.0.3", - "traits": "0.4.0", - "should": "0.3.1", - "eyes": "0.1.6" - }, - "devDepenencies": { - "docco": "0.3.0", - "express": "2.4.5" - }, - "keywords": ["vows", "vows-fluent", "tdd", "test", "testing"], - "repository": "git://github.com/Raynos/vows-is.git", - "main": "src/vows-is", - "scripts": {}, - "engines": { "node": "0.4.x" } -} \ No newline at end of file diff --git a/node_modules/vows-is/src/reporter.js b/node_modules/vows-is/src/reporter.js deleted file mode 100644 index 72a7cbf..0000000 --- a/node_modules/vows-is/src/reporter.js +++ /dev/null @@ -1,123 +0,0 @@ -// Steal vows console object -var consoleObj = require("../lib/console.js"); - -var options = { tail: '\n' }; -var stylize = consoleObj.stylize, - puts = consoleObj.puts(options); - -// Construct a report object -var report = { - // store contexts - "contexts": {}, - // When vows fires report we add various data to our internal structure - // For a context, just inject a context object into our internal list - // For vow we add a vows object to that context - // For subject set the subject - // For finish, print the structure, then print the report - "add": function _add(obj) { - if (obj[0] === "context") { - this.contexts[obj[1]] = { vows: {} }; - } else if (obj[0] === "vow") { - var vow = obj[1]; - this.contexts[vow.context].vows[vow.title] = vow; - } else if (obj[0] === "subject") { - this.subject = obj[1]; - } else if (obj[0] === "finish") { - this.print(); - this.printReport(obj[1]); - } - }, - // Code horrors :( - "print": function _print() { - var self = this; - puts('\n♢ ' + stylize(this.subject, 'bold') + '\n'); - - var contexts = {}; - - // Find the parent context based on the name - function findParent(contexts, text) { - var obj = false; - var newKey = text; - for (var key in contexts) { - var context = contexts[key]; - if (context.oldKey) { - key = context.oldKey; - } - if (context.contexts) { - var arr = findParent(context.contexts, text); - if (arr) { - return arr; - } - } - if (text.indexOf(key) !== -1) { - newKey = text.replace(key, ""); - obj = context; - break; - } - } - if (obj) { - return [obj, newKey]; - } else { - return false; - } - }; - - // Create the real contexts object from this.contexts - Object.keys(this.contexts).sort().forEach(function(key) { - var arr = findParent(contexts, key); - if (arr) { - var context = arr[0]; - var newKey = arr[1]; - } - - if (!arr) { - contexts[key] = self.contexts[key]; - if (!contexts[key].contexts) { - contexts[key].contexts = {}; - } - } else { - context.contexts[newKey] = self.contexts[key]; - context.contexts[newKey].oldKey = key; - if (!context.contexts[newKey].contexts) { - context.contexts[newKey].contexts = {}; - } - } - }); - - // print a context recursively - function print(context, key, depth) { - var whitespace = (new Array(depth + 1)).join(" "); - puts(whitespace + consoleObj.contextText(key)); - - Object.keys(context.vows).forEach(function(key2) { - puts(whitespace + " " + consoleObj.vowText(context.vows[key2])); - }); - if (context.contexts) { - Object.keys(context.contexts).forEach(function(key) { - print(context.contexts[key], key, depth + 1); - }); - } - } - - // For each context print it - Object.keys(contexts).forEach(function(key) { - print(contexts[key], key, 0); - }); - }, - // delegate printing of the report to vows console - "printReport": function _printReport(report) { - puts(consoleObj.result(report).join('\n')); - } -} - -exports.name = 'prettyprint'; - -// Might be needed. Who knows o/ -exports.setStream = function _setStream(s) { - options.stream = s; -}; - -// When vows reports ask our report to add the object -exports.report = function _report(obj) { - report.add(obj); -}; \ No newline at end of file diff --git a/node_modules/vows-is/src/vows-is.js b/node_modules/vows-is/src/vows-is.js deleted file mode 100644 index d7e2877..0000000 --- a/node_modules/vows-is/src/vows-is.js +++ /dev/null @@ -1,396 +0,0 @@ -var fluent = require("vows-fluent"), - request = require("request"), - should = require("should"), - EventEmitter = require("events").EventEmitter.prototype, - AssertionConstructor = should.Assertion, - Assertion = AssertionConstructor.prototype, - Trait = require("traits").Trait, - Topic = fluent.Topic, - Vow = fluent.Vow, - Context = fluent.Context; - -// Remove should from the prototype. -delete Object.prototype.should; - -// Redefine should in a friendly manner. -Object.defineProperty(Object.prototype, "should", { - get: function() { - return this._should || new AssertionConstructor(this); - }, - set: function(val) { - this._should = val; - }, - configurable: true -}); - -// defaults objects overwritten through config. -var defaults = {}, - // test whether an url is an url or has a method in it. - test_uri = /^(GET|POST|PUT|HEAD|DELETE)(.*)/; - -// utility create function -var create = function _create(trait) { - return Object.create(Object.prototype, trait) -}; - -// factory to get a server instance. Cached internally -var getServer = function _getServer(cb) { - if (getServer.app) { - cb(getServer.app); - } else { - defaults.server.factory(function(app) { - getServer.app = app; - cb(app); - }); - } -} - -// Is object used in topic().is -exports.Is = { - // dummy getter - get a() { - return this; - }, - // dummy getter - get an() { - return this; - }, - // invocation. This will invoke the previous topic with values - // and return it - "invocation": function _invocation() { - var args = arguments; - this._parent.set(wrapTopicInError(function _topic(topic) { - return topic.apply(null, args); - })); - return this.end(); - }, - // request. This sets the value of the topic to be a request function. - // It goes off and asks for a server from the server factory, - // Then generates the url to request. It makes a request to your - // server then uses `this.callback` to set the response as the topic - "request": function _request(url) { - this._parent.set(function _topic() { - var cb = this.callback; - getServer(function _getServer(server) { - var options; - if (typeof url === "string") { - options = {}; - var match = url && url.match(test_uri); - if (match) { - options.method = match[1]; - options.uri = defaults.server.uri + match[2].substr(1); - } else { - options.uri = defaults.server.uri + uri - } - } else { - options = url; - } - request(options, function _handleRequest(err, res, body) { - cb(err, res); - }); - }); - }); - return this.end() - }, - // Set the topic to be a property of the current topic - "property": function _property(name) { - this._parent.set(function _topic(topic) { - return topic[name]; - }); - return this.end() - }, - // end the is abstraction returning the context owning the topic. - "end": function _end() { - return this._parent.parent() - } -}; - -var wrapTopicInError = function _wrap(val) { - return function() { - try { - return val.apply(this, arguments); - } catch (e) { - console.log(EventEmitter); - var ev = Object.create(EventEmitter); - process.nextTick(function() { - ev.emit('error', e) - }); - return ev; - } - }; -} - -// Property descriptor for property is. -// Creates a Is, sets the parent and returns it. -// Typeof function check supports `topic.is` and `topic().is` -// The function is used to allow `topic.is(value)` -var propertyDescriptorIs = { - "set": function _set() {}, - "get": function _get() { - var i = create(Trait(exports.Is)); - if (typeof this === "function") { - i._parent = this(); - } else { - i._parent = this; - } - var f = (function _is(val) { - if (typeof val === "function") { - var val = wrapTopicInError(val); - } - this._parent.set(val); - return this.end(); - }).bind(i); - var keys = Object.getOwnPropertyNames(i); - keys.forEach(function(key) { - var pd = Object.getOwnPropertyDescriptor(i, key); - Object.defineProperty(f, key, pd); - }); - return f; - } -}; - -// Add is as a getter to the topic to support `topic().is` -Object.defineProperty(Topic, "is", propertyDescriptorIs); - -// replace topic method with a getter that returns the function -// make sure to bind this and add the `is` property to the function -var old_topic = Context.topic; -Object.defineProperty(Context, "topic", { - "set": function _set() {}, - "get": function _get() { - var f = old_topic.bind(this); - Object.defineProperty(f, "is", propertyDescriptorIs); - return f; - } -}); - - -// It object used in `vow().it` -exports.It = { - // Creates a should wrapper and returns it. - // Also sets the vow value to unwrap the should wrapper. - get should() { - var s = create(Trait(exports.Should)); - s._stack = []; - s._parent = this._parent; - return s; - } -} - -// Property descriptor for property it. -// Creates a It, sets the parent and returns it. -// Typeof function check supports `vow.it` and `vow().it` -var propertyDescriptorIt = { - "set": function _set() {}, - "get": function _get() { - var i = create(Trait(exports.It)); - if (typeof this === "function") { - i._parent = this(); - } else { - i._parent = this; - } - return i; - } -}; - -// Add is as a getter on Vow to support `vow().it` -Object.defineProperty(Vow, "it", propertyDescriptorIt); - -// Replace vow method with a getter that returns the function -// make sure to bind the scope and add `it` to the `vow` value -var old_vow = Context.vow -Object.defineProperty(Context, "vow", { - "set": function _set() {}, - "get": function _get() { - var f = old_vow.bind(this); - Object.defineProperty(f, "it", propertyDescriptorIt); - return f; - } -}); - -// Extension of the should.js Assertion object -exports.Assertion = create(Trait.override(Trait({ - // header. Assert it has property headers and that the - // header `name` has value `val` - "header": function _header(name, val) { - return this.property("headers").with.property(name, val); - }, - // error getter. Set's the object to the error and calls ok. - get error() { - this.obj = this._error - return this.ok; - }, -}), Trait(Assertion))); - -// a Should object which is a wrapper around should.js -exports.Should = { - // transforms the stack into a nice assertion string - "prettyPrint": function _prettyPrint() { - var arr = this._stack.map(function _map(val) { - var str = val.key; - if (exports.prettyPrint[val.key]) { - str += " " + exports.prettyPrint[val.key](val.args); - } else if (val.args.length) { - str += " " + val.args.join(" "); - } - return str; - }); - arr.unshift("should"); - return arr.join(" "); - }, - // end the abstraction. This creates a should.js assertion - // and unravels the stack running every assertion. - // it then returns context that the vow belongs to. - "end": function _end() { - var s = create(Trait(exports.Assertion)); - s.obj = this._obj; - s._error = this._error; - this._stack.forEach(function _each(val) { - if (val.type === 'get') { - s = s[val.key]; - } else { - s = s[val.key].apply(s, val.args); - } - }); - return this._parent.parent(); - } -}; - -// A stack of prettyPrint methods to make the assertions look pretty -exports.prettyPrint = { - "header": function _property(args) { - return args[0] + " with value " + args[1]; - } -}; - -// For each of the methods that can be called on a context add them to should. -// This tells the Should wrappers to end itself and return back to the context. -["vow", "context", "parent", "batch", "suite", "partial"].forEach(function _each(key) { - exports.Should[key] = function _parent() { - var parent = this._parent.parent(); - if (!this._parent._name) { - this._parent.name(this.prettyPrint()); - } - var that = this; - this._parent.set(function _set(err, value) { - that._obj = value; - that._error = err; - that.end(); - }); - return parent[key].apply(parent, arguments); - }; -}); - -// Replace the vow method of Should with a getter so chaining doesn't break -var should_vow = exports.Should.vow -Object.defineProperty(exports.Should, "vow", { - "set": function _set() {}, - "get": function _get() { - var f = should_vow.bind(this); - Object.defineProperty(f, "it", propertyDescriptorIt); - return f; - } -}); - -// For each of the methods of `exports.Assersion` add a wrapper -// to Should. The wrapper simply saves the command on a stack. -// The stack is unravelled when the should wrapper ends. -Object.keys(exports.Assertion).forEach(function _each(key) { - if (!exports.Should.hasOwnProperty(key)) { - var descriptor = Object.getOwnPropertyDescriptor(exports.Assertion, key); - var name = descriptor.get ? "get" : "value"; - descriptor[name] = function _descriptor() { - this._stack.push({ - "type": name, - "key": key, - "args": Array.prototype.slice.call(arguments) - }); - return this; - } - Object.defineProperty(exports.Should, key, descriptor); - } -}); - -// Config method sets defaults -exports.config = function _init(obj) { - Object.keys(obj).forEach(function _each(key) { - defaults[key] = obj[key]; - }); - if (defaults.server.defaults) { - request = request.defaults(defaults.server.defaults); - } - return this; -}; - -// partial method that runs a predefined partial function on the context -Context.partial = function _partial(name, data) { - var p = exports._partial[name]; - return p(this, data); -}; - -// Store hashes of partials -exports._partial = {}; - -// Store a partial by name -exports.partial = function _partial(name, f) { - this._partial[name] = f; - return this; -}; - -// Expose methods of vows-fluent on exports. -Object.keys(fluent).forEach(function _each(key) { - exports[key] = fluent[key]; -}); - -// Expose the custom vows-is reporter -exports.reporter = require("./reporter.js"); - -// Expose vows console -exports.console = require("../lib/console.js"); - -// End function will various clean up functions -// default.server.kill is your clean up function to kill the server -exports.end = function _end() { - if (defaults.server && - defaults.server.kill && - typeof defaults.server.kill === "function" - ) { - getServer(function(server) { - defaults.server.kill(server); - }); - } -}; - -// expose should object from should.js -exports.should = should; - -// Punch vows in the face -var stylize = exports.console.stylize; -var inspect = exports.console.inspect; - -require('assert').AssertionError.prototype.toString = function () { - var that = this, - source = this.stack && this.stack.match(/([a-zA-Z0-9._-]+\.js)(:\d+):\d+/); - - function parse(str) { - return str.replace(/{actual}/g, inspect(that.actual)). - replace(/{operator}/g, stylize(that.operator, 'bold')). - replace(/{expected}/g, (that.expected instanceof Function) - ? that.expected.name - : inspect(that.expected)); - } - - if (this.message) { - var msg = stylize(parse(this.message), 'yellow'); - if (source) { - msg += stylize(' // ' + source[1] + source[2], 'grey'); - } - return msg; - } else { - return stylize([ - this.expected, - this.operator, - this.actual - ].join(' '), 'yellow'); - } -}; \ No newline at end of file diff --git a/node_modules/vows-is/test/config.js b/node_modules/vows-is/test/config.js deleted file mode 100644 index d4e91e9..0000000 --- a/node_modules/vows-is/test/config.js +++ /dev/null @@ -1,27 +0,0 @@ -var express = require("express"); - -module.exports = { - "server": { - "factory": function _createServer(cb) { - var app = express.createServer(); - - app.use(express.bodyParser()) - app.use(app.router); - - app.get("/", function(req, res) { - res.send("hello world"); - }); - - app.post("/echo", function(req, res) { - res.send(req.body); - }); - - app.listen(4000); - cb(app); - }, - "kill": function _kill(app) { - app.close(); - }, - "uri": "http://localhost:4000" - } -} \ No newline at end of file diff --git a/node_modules/vows-is/test/vows-is-test.js b/node_modules/vows-is/test/vows-is-test.js deleted file mode 100644 index a786d0c..0000000 --- a/node_modules/vows-is/test/vows-is-test.js +++ /dev/null @@ -1,85 +0,0 @@ -var is = require("../src/vows-is.js"); - -is.config(require("./config.js")); - -is.partial("req", function _partial(context, header) { - return context - .vow.it.should.not.error - .vow.it.should.have.status(200) - .vow.it.should.have.header("content-type", header || "text/html; charset=utf-8"); -}); - -is.partial("GET", function _partial(context) { - return context - .partial("req") - .context("contains a body that") - .topic.is.property('body') - .vow.it.should.be.ok - .vow.it.should.include.string("hello world") -}); - -var suite = is.suite("vows-is").batch() - - .context("a request to GET /") - .topic.is.a.request("GET /") - .partial("GET") - .batch() - .context("an echo request to POST /echo") - .topic.is.a.request({ - "uri": "http://localhost:4000/echo", - "method": "POST", - "json": { - "foo": "bar" - } - }) - .partial("req", "application/json; charset=utf-8") - .context("contains a body that") - .topic.is.property("body") - .vow.it.should.be.ok - .vow.it.should.have.property("foo").and.be.equal("bar") - -.batch() - - .context("2 into 6") - .topic.is(function() { return 6 / 2; }) - .vow.it.should.be.a("number") - .vow.it.should.eql(3) - .parent() - - .context("123") - .topic.is(123) - .vow.it.should.be.a("number") - .vow.it.should.eql(123) - .context("divided by 10") - .topic.is(function(topic) { return topic / 10 }) - .vow.it.should.eql(12.3) - .batch() - - .context("1 plus 3") - .topic.is(function() { return 1 + 3; }) - .vow.it.should.be.a("number") - .vow.it.should.eql(4) - .context("subtract 5") - .topic.is(function(topic) { return topic - 5; }) - .vow.it.should.be.a("number") - .vow.it.should.eql(-1) - .context("times 2") - .topic.is(function(topic) { return topic * 2; }) - .vow.it.should.be.a("number") - .vow.it.should.eql(-2) - .parent() - .context("times 0") - .topic.is(function (topic) { return topic * 0; }) - .vow.it.should.eql(0) - -.suite(); - -if (module.parent) { - suite["export"](module); -} else { - suite.run({ - reporter: is.reporter - }, function() { - is.end(); - }); -} \ No newline at end of file diff --git a/node_modules/vows/.gitignore b/node_modules/vows/.gitignore deleted file mode 100644 index 3c3629e..0000000 --- a/node_modules/vows/.gitignore +++ /dev/null @@ -1 +0,0 @@ -node_modules diff --git a/node_modules/vows/LICENSE b/node_modules/vows/LICENSE deleted file mode 100644 index a1edd93..0000000 --- a/node_modules/vows/LICENSE +++ /dev/null @@ -1,20 +0,0 @@ -Copyright (c) 2009 cloudhead - -Permission is hereby granted, free of charge, to any person obtaining -a copy of this software and associated documentation files (the -"Software"), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, sublicense, and/or sell copies of the Software, and to -permit persons to whom the Software is furnished to do so, subject to -the following conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -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. diff --git a/node_modules/vows/Makefile b/node_modules/vows/Makefile deleted file mode 100644 index 6bf8991..0000000 --- a/node_modules/vows/Makefile +++ /dev/null @@ -1,7 +0,0 @@ -# -# Run all tests -# -test: - @@bin/vows test/* - -.PHONY: test install diff --git a/node_modules/vows/README.md b/node_modules/vows/README.md deleted file mode 100644 index 58c8ff5..0000000 --- a/node_modules/vows/README.md +++ /dev/null @@ -1,39 +0,0 @@ -Vows -==== - -> Asynchronous BDD & continuous integration for node.js - -#### # - -introduction ------------- -There are two reasons why we might want asynchronous testing. The first, and obvious reason is that node.js is asynchronous, and therefore our tests need to be. The second reason is to make test suites which target I/O libraries run much faster. - -_Vows_ is an experiment in making this possible, while adding a minimum of overhead. - -synopsis --------- - - var vows = require('vows'), - assert = require('assert'); - - vows.describe('Deep Thought').addBatch({ - 'An instance of DeepThought': { - topic: new DeepThought, - - 'should know the answer to the ultimate question of life': function (deepThought) { - assert.equal (deepThought.question('what is the answer to the universe?'), 42); - } - } - }); - -installation ------------- - - $ npm install vows - -documentation -------------- - -Head over to - diff --git a/node_modules/vows/bin/vows b/node_modules/vows/bin/vows deleted file mode 100755 index 3449709..0000000 --- a/node_modules/vows/bin/vows +++ /dev/null @@ -1,515 +0,0 @@ -#!/usr/bin/env node - -var path = require('path'), - fs = require('fs'), - util = require('util'), - events = require('events'); - -// -// Attempt to load Coffee-Script. If it's not available, continue on our -// merry way, if it is available, set it up so we can include `*.coffee` -// scripts and start searching for them. -// -var fileExt, specFileExt; - -try { - var coffee = require('coffee-script'); - if (require.extensions) { - require.extensions['.coffee'] = function (module, filename) { - var content = coffee.compile(fs.readFileSync(filename, 'utf8')); - return module._compile(content, filename); - }; - } else { - require.registerExtension('.coffee', function (content) { return coffee.compile(content) }); - } - fileExt = /\.(js|coffee)$/; - specFileExt = /[.-](test|spec)\.(js|coffee)$/; -} catch (_) { - fileExt = /\.js$/; - specFileExt = /[.-](test|spec)\.js$/; -} - -var inspect = require('eyes').inspector({ - stream: null, - styles: { string: 'grey', regexp: 'grey' } -}); - -var vows = require('../lib/vows'); -var cutils = require('../lib/vows/console'); -var stylize = require('../lib/vows/console').stylize; -var _reporter = require('../lib/vows/reporters/dot-matrix'), reporter = { - name: _reporter.name -}; -var _coverage; - -var help = [ - "usage: vows [FILE, ...] [options]", - "", - "options:", - " -v, --verbose Enable verbose output", - " -w, --watch Watch mode", - " -s, --silent Don't report", - " -i, --isolate Run each test in it's own vows process", - " -m PATTERN Only run tests matching the PATTERN string", - " -r PATTERN Only run tests matching the PATTERN regexp", - " --json Use JSON reporter", - " --spec Use Spec reporter", - " --dot-matrix Use Dot-Matrix reporter", - " --xunit Use xUnit reporter", - " --cover-plain Print plain coverage map if detected", - " --cover-html Write coverage map to \"coverage.html\"", - " --cover-json Write unified coverage map to \"coverage.json\"", - //" --no-color Don't use terminal colors", - " --version Show version", - " -h, --help You're staring at it" -].join('\n'); - -var options = { - reporter: reporter, - matcher: /.*/, - watch: false, - coverage: false, - isolate: false -}; - -var files = []; - -// Get rid of process runner -// ('node' in most cases) -var arg, args = [], argv = process.argv.slice(2); - -// Current directory index, -// and path of test folder. -var root, testFolder; - -// -// Parse command-line parameters -// -while (arg = argv.shift()) { - if (arg === __filename) { continue } - - if (arg[0] !== '-') { - args.push(arg); - } else { - arg = arg.match(/^--?(.+)/)[1]; - - if (arg[0] === 'r') { - options.matcher = new(RegExp)(argv.shift()); - } else if (arg[0] === 'm') { - options.matcher = (function (str) { // Create an escaped RegExp - var specials = '. * + ? | ( ) [ ] { } \\ ^ ? ! = : $'.split(' ').join('|\\'), - regex = new(RegExp)('(\\' + specials + ')', 'g'); - return new(RegExp)(str.replace(regex, '\\$1')); - })(argv.shift()); - } else if (arg in options) { - options[arg] = true; - } else { - switch (arg) { - case 'json': - _reporter = require('../lib/vows/reporters/json'); - break; - case 'spec': - _reporter = require('../lib/vows/reporters/spec'); - break; - case 'dot-matrix': - _reporter = require('../lib/vows/reporters/dot-matrix'); - break; - case 'silent': - case 's': - _reporter = require('../lib/vows/reporters/silent'); - break; - case 'xunit': - _reporter = require('../lib/vows/reporters/xunit'); - break; - case 'cover-plain': - options.coverage = true; - _coverage = require('../lib/vows/coverage/report-plain'); - break; - case 'cover-html': - options.coverage = true; - _coverage = require('../lib/vows/coverage/report-html'); - break; - case 'cover-json': - options.coverage = true; - _coverage = require('../lib/vows/coverage/report-json'); - break; - case 'verbose': - case 'v': - options.verbose = true; - break; - case 'watch': - case 'w': - options.watch = true; - break; - case 'supress-stdout': - options.supressStdout = true; - break; - case 'isolate': - case 'i': - options.isolate = true; - break; - case 'no-color': - options.nocolor = true; - break; - case 'no-error': - options.error = false; - break; - case 'version': - console.log('vows ' + vows.version); - process.exit(0); - case 'help': - case 'h': - console.log(help); - process.exit(0); - break; - } - } - } -} - -if (options.supressStdout) { - _reporter.setStream && _reporter.setStream(process.stdout); - process.stdout = fs.createWriteStream('/dev/null'); -} - -if (options.watch) { - options.reporter = reporter = require('../lib/vows/reporters/watch'); -} - -msg('bin', 'argv', args); -msg('bin', 'options', { reporter: options.reporter.name, matcher: options.matcher }); - -if (args.length === 0 || options.watch) { - msg('bin', 'discovering', 'folder structure'); - root = fs.readdirSync('.'); - - if (root.indexOf('test') !== -1) { - testFolder = 'test'; - } else if (root.indexOf('spec') !== -1) { - testFolder = 'spec'; - } else { - abort("runner", "couldn't find test folder"); - } - msg('bin', 'discovered', "./" + testFolder); - - if (args.length === 0) { - args = paths(testFolder).filter(function (f) { - return new(RegExp)('-' + testFolder + '.(js|coffee)$').test(f); - }); - - if (options.watch) { - args = args.concat(paths('lib'), - paths('src')); - } - } -} - -if (! options.watch) { - reporter.report = function (data, filename) { - switch (data[0]) { - case 'subject': - case 'vow': - case 'context': - case 'error': - _reporter.report(data, filename); - break; - case 'end': - (options.verbose || _reporter.name === 'json') && - _reporter.report(data); - break; - case 'finish': - options.verbose ? - _reporter.print('\n') - : - _reporter.print(' '); - break; - } - }; - reporter.reset = function () { _reporter.reset && _reporter.reset() }; - reporter.print = _reporter.print; - - files = args.map(function (a) { - return (!a.match(/^\//)) - ? path.join(process.cwd(), a.replace(fileExt, '')) - : a.replace(fileExt, ''); - }); - - runSuites(importSuites(files), function (results) { - var status = results.errored ? 2 : (results.broken ? 1 : 0); - - !options.verbose && _reporter.print('\n'); - msg('runner', 'finish'); - _reporter.report(['finish', results], { - write: function (str) { - util.print(str.replace(/^\n\n/, '\n')); - } - }); - try { - if (options.coverage === true && _$jscoverage !== undefined) { - _coverage.report(_$jscoverage); - } - } catch (err) { - // ignore the undefined jscoverage - } - if (process.stdout.write('')) { // Check if stdout is drained - process.exit(status); - } else { - process.stdout.on('drain', function () { - process.exit(status); - }); - } - }); -} else { - // - // Watch mode - // - (function () { - var pendulum = [ - '. ', '.. ', '... ', ' ...', - ' ..', ' .', ' .', ' ..', - '... ', '.. ', '. ' - ]; - var strobe = ['.', ' ']; - var status, - cue, - current = 0, - running = 0, - lastRun, - colors = ['32m', '33m', '31m'], - timer = setInterval(tick, 100); - - process.on('uncaughtException', cleanup); - process.on('exit', cleanup); - process.on('SIGINT', function () { - process.exit(0); - }); - process.on('SIGQUIT', function () { - changed(); - }); - - cursorHide(); - - // Run every 100ms - function tick() { - if (running && (cue !== strobe)) { - cue = strobe, current = 0; - } else if (!running && (cue !== pendulum)) { - cue = pendulum, current = 0; - } - - eraseLine(); - lastRun && !running && esc(colors[status.errored ? 2 : (status.broken ? 1 : 0)]); - print(cue[current]); - - if (current == cue.length - 1) { current = -1 } - - current ++; - esc('39m'); - cursorRestore(); - } - - // - // Utility functions - // - function print(str) { util.print(str) } - function esc(str) { print("\x1b[" + str) } - function eraseLine() { esc("0K") } - function cursorRestore() { esc("0G") } - function cursorHide() { esc("?25l") } - function cursorShow() { esc("?25h") } - function cleanup() { eraseLine(), cursorShow(), clearInterval(timer), print('\n') } - - // - // Called when a file has been modified. - // Run the matching tests and change the status. - // - function changed(file) { - status = { honored: 0, broken: 0, errored: 0, pending: 0 }; - - msg('watcher', 'detected change in', file); - - file = (specFileExt.test(file) ? path.join(testFolder, file) - : path.join(testFolder, file + '-' + testFolder)); - - try { - fs.statSync(file); - } catch (e) { - msg('watcher', 'no equivalence found, running all tests.'); - file = null; - } - - var files = (specFileExt.test(file) ? [file] : paths(testFolder)).map(function (p) { - return path.join(process.cwd(), p); - }).map(function (p) { - var cache = require.main.moduleCache || require.cache; - if (cache[p]) { delete(cache[p]) } - return p; - }).map(function (p) { - return p.replace(fileExt, ''); - }); - - running ++; - - runSuites(importSuites(files), function (results) { - delete(results.time); - print(cutils.result(results).join('') + '\n\n'); - lastRun = new(Date); - status = results; - running --; - }); - } - - msg('watcher', 'watching', args); - - // - // Watch all relevant files, - // and call `changed()` on change. - // - args.forEach(function (p) { - fs.watchFile(p, function (current, previous) { - if (new(Date)(current.mtime).valueOf() === - new(Date)(previous.mtime).valueOf()) { return } - else { - changed(p); - } - }); - }); - })(); -} - -function runSuites(suites, callback) { - var results = { - honored: 0, - broken: 0, - errored: 0, - pending: 0, - total: 0, - time: 0 - }; - reporter.reset(); - - (function run(suites, callback) { - var suite = suites.shift(); - if (suite) { - msg('runner', "running", suite.subject + ' ', options.watch ? false : true); - suite.run(options, function (result) { - Object.keys(result).forEach(function (k) { - results[k] += result[k]; - }); - run(suites, callback); - }); - } else { - callback(results); - } - })(suites, callback); -} - -function importSuites(files) { - msg(options.watcher ? 'watcher' : 'runner', 'loading', files); - - var spawn = require('child_process').spawn; - - function cwdname(f) { - return f.replace(process.cwd() + '/', '') + '.js'; - } - - function wrapSpawn(f) { - f = cwdname(f); - return function (options, callback) { - var args = [process.argv[1], '--json', '--supress-stdout', f], - p = spawn(process.argv[0], args), - result; - - p.on('exit', function (code) { - callback( - !result ? - {errored: 1, total: 1} - : - result - ); - }); - - var buffer = []; - p.stdout.on('data', function (data) { - data = data.toString().split(/\n/g); - if (data.length == 1) { - buffer.push(data[0]); - } else { - data[0] = buffer.concat(data[0]).join(''); - buffer = [data.pop()]; - - data.forEach(function (data) { - if (data) { - data = JSON.parse(data); - if (data && data[0] === 'finish') { - result = data[1]; - } else { - reporter.report(data); - } - } - }); - } - }); - - p.stderr.pipe(process.stderr); - } - } - - return files.reduce(options.isolate ? function (suites, f) { - return suites.concat({ - run: wrapSpawn(f) - }); - } : function (suites, f) { - var obj = require(f); - return suites.concat(Object.keys(obj).map(function (s) { - obj[s]._filename = cwdname(f); - return obj[s]; - })); - }, []) -} - -// -// Recursively traverse a hierarchy, returning -// a list of all relevant .js files. -// -function paths(dir) { - var paths = []; - - try { fs.statSync(dir) } - catch (e) { return [] } - - (function traverse(dir, stack) { - stack.push(dir); - fs.readdirSync(stack.join('/')).forEach(function (file) { - var path = stack.concat([file]).join('/'), - stat = fs.statSync(path); - - if (file[0] == '.' || file === 'vendor') { - return; - } else if (stat.isFile() && fileExt.test(file)) { - paths.push(path); - } else if (stat.isDirectory()) { - traverse(file, stack); - } - }); - stack.pop(); - })(dir || '.', []); - - return paths; -} - -function msg(cmd, subject, str, p) { - if (options.verbose) { - util[p ? 'print' : 'puts']( stylize('vows ', 'green') - + stylize(cmd, 'bold') - + ' ' + subject + ' ' - + (str ? (typeof(str) === 'string' ? str : inspect(str)) : '') - ); - } -} - -function abort(cmd, str) { - console.log(stylize('vows ', 'red') + stylize(cmd, 'bold') + ' ' + str); - console.log(stylize('vows ', 'red') + stylize(cmd, 'bold') + ' exiting'); - process.exit(-1); -} diff --git a/node_modules/vows/lib/assert/error.js b/node_modules/vows/lib/assert/error.js deleted file mode 100644 index 1284017..0000000 --- a/node_modules/vows/lib/assert/error.js +++ /dev/null @@ -1,27 +0,0 @@ -var stylize = require('../vows/console').stylize; -var inspect = require('../vows/console').inspect; - -require('assert').AssertionError.prototype.toString = function () { - var that = this, - source = this.stack.match(/([a-zA-Z0-9._-]+\.js)(:\d+):\d+/); - - function parse(str) { - return str.replace(/{actual}/g, inspect(that.actual)). - replace(/{operator}/g, stylize(that.operator, 'bold')). - replace(/{expected}/g, (that.expected instanceof Function) - ? that.expected.name - : inspect(that.expected)); - } - - if (this.message) { - return stylize(parse(this.message), 'yellow') + - stylize(' // ' + source[1] + source[2], 'grey'); - } else { - return stylize([ - this.expected, - this.operator, - this.actual - ].join(' '), 'yellow'); - } -}; - diff --git a/node_modules/vows/lib/assert/macros.js b/node_modules/vows/lib/assert/macros.js deleted file mode 100644 index 137028e..0000000 --- a/node_modules/vows/lib/assert/macros.js +++ /dev/null @@ -1,215 +0,0 @@ -var assert = require('assert'), - utils = require('./utils'); - -var messages = { - 'equal' : "expected {expected},\n\tgot\t {actual} ({operator})", - 'notEqual' : "didn't expect {actual} ({operator})" -}; -messages['strictEqual'] = messages['deepEqual'] = messages['equal']; -messages['notStrictEqual'] = messages['notDeepEqual'] = messages['notEqual']; - -for (var key in messages) { - assert[key] = (function (key, callback) { - return function (actual, expected, message) { - callback(actual, expected, message || messages[key]); - }; - })(key, assert[key]); -} - -assert.ok = (function (callback) { - return function (actual, message) { - callback(actual, message || "expected expression to evaluate to {expected}, but was {actual}"); - }; -})(assert.ok); - -assert.match = function (actual, expected, message) { - if (! expected.test(actual)) { - assert.fail(actual, expected, message || "expected {actual} to match {expected}", "match", assert.match); - } -}; -assert.matches = assert.match; - -assert.isTrue = function (actual, message) { - if (actual !== true) { - assert.fail(actual, true, message || "expected {expected}, got {actual}", "===", assert.isTrue); - } -}; -assert.isFalse = function (actual, message) { - if (actual !== false) { - assert.fail(actual, false, message || "expected {expected}, got {actual}", "===", assert.isFalse); - } -}; -assert.isZero = function (actual, message) { - if (actual !== 0) { - assert.fail(actual, 0, message || "expected {expected}, got {actual}", "===", assert.isZero); - } -}; -assert.isNotZero = function (actual, message) { - if (actual === 0) { - assert.fail(actual, 0, message || "expected non-zero value, got {actual}", "===", assert.isNotZero); - } -}; - -assert.greater = function (actual, expected, message) { - if (actual <= expected) { - assert.fail(actual, expected, message || "expected {actual} to be greater than {expected}", ">", assert.greater); - } -}; -assert.lesser = function (actual, expected, message) { - if (actual >= expected) { - assert.fail(actual, expected, message || "expected {actual} to be lesser than {expected}", "<", assert.lesser); - } -}; - -assert.inDelta = function (actual, expected, delta, message) { - var lower = expected - delta; - var upper = expected + delta; - if (actual < lower || actual > upper) { - assert.fail(actual, expected, message || "expected {actual} to be in within *" + delta.toString() + "* of {expected}", null, assert.inDelta); - } -}; - -// -// Inclusion -// -assert.include = function (actual, expected, message) { - if ((function (obj) { - if (isArray(obj) || isString(obj)) { - return obj.indexOf(expected) === -1; - } else if (isObject(actual)) { - return ! obj.hasOwnProperty(expected); - } - return false; - })(actual)) { - assert.fail(actual, expected, message || "expected {actual} to include {expected}", "include", assert.include); - } -}; -assert.includes = assert.include; - -assert.deepInclude = function (actual, expected, message) { - if (!isArray(actual)) { - return assert.include(actual, expected, message); - } - if (!actual.some(function (item) { return utils.deepEqual(item, expected) })) { - assert.fail(actual, expected, message || "expected {actual} to include {expected}", "include", assert.deepInclude); - } -}; -assert.deepIncludes = assert.deepInclude; - -// -// Length -// -assert.isEmpty = function (actual, message) { - if ((isObject(actual) && Object.keys(actual).length > 0) || actual.length > 0) { - assert.fail(actual, 0, message || "expected {actual} to be empty", "length", assert.isEmpty); - } -}; -assert.isNotEmpty = function (actual, message) { - if ((isObject(actual) && Object.keys(actual).length === 0) || actual.length === 0) { - assert.fail(actual, 0, message || "expected {actual} to be not empty", "length", assert.isNotEmpty); - } -}; - -assert.length = function (actual, expected, message) { - if (actual.length !== expected) { - assert.fail(actual, expected, message || "expected {actual} to have {expected} element(s)", "length", assert.length); - } -}; - -// -// Type -// -assert.isArray = function (actual, message) { - assertTypeOf(actual, 'array', message || "expected {actual} to be an Array", assert.isArray); -}; -assert.isObject = function (actual, message) { - assertTypeOf(actual, 'object', message || "expected {actual} to be an Object", assert.isObject); -}; -assert.isNumber = function (actual, message) { - if (isNaN(actual)) { - assert.fail(actual, 'number', message || "expected {actual} to be of type {expected}", "isNaN", assert.isNumber); - } else { - assertTypeOf(actual, 'number', message || "expected {actual} to be a Number", assert.isNumber); - } -}; -assert.isBoolean = function (actual, message) { - if (actual !== true && actual !== false) { - assert.fail(actual, 'boolean', message || "expected {actual} to be a Boolean", "===", assert.isBoolean); - } -}; -assert.isNaN = function (actual, message) { - if (actual === actual) { - assert.fail(actual, 'NaN', message || "expected {actual} to be NaN", "===", assert.isNaN); - } -}; -assert.isNull = function (actual, message) { - if (actual !== null) { - assert.fail(actual, null, message || "expected {expected}, got {actual}", "===", assert.isNull); - } -}; -assert.isNotNull = function (actual, message) { - if (actual === null) { - assert.fail(actual, null, message || "expected non-null value, got {actual}", "===", assert.isNotNull); - } -}; -assert.isUndefined = function (actual, message) { - if (actual !== undefined) { - assert.fail(actual, undefined, message || "expected {actual} to be {expected}", "===", assert.isUndefined); - } -}; -assert.isDefined = function (actual, message) { - if(actual === undefined) { - assert.fail(actual, 0, message || "expected {actual} to be defined", "===", assert.isDefined); - } -}; -assert.isString = function (actual, message) { - assertTypeOf(actual, 'string', message || "expected {actual} to be a String", assert.isString); -}; -assert.isFunction = function (actual, message) { - assertTypeOf(actual, 'function', message || "expected {actual} to be a Function", assert.isFunction); -}; -assert.typeOf = function (actual, expected, message) { - assertTypeOf(actual, expected, message, assert.typeOf); -}; -assert.instanceOf = function (actual, expected, message) { - if (! (actual instanceof expected)) { - assert.fail(actual, expected, message || "expected {actual} to be an instance of {expected}", "instanceof", assert.instanceOf); - } -}; - -// -// Utility functions -// - -function assertTypeOf(actual, expected, message, caller) { - if (typeOf(actual) !== expected) { - assert.fail(actual, expected, message || "expected {actual} to be of type {expected}", "typeOf", caller); - } -}; - -function isArray (obj) { - return Array.isArray(obj); -} - -function isString (obj) { - return typeof(obj) === 'string' || obj instanceof String; -} - -function isObject (obj) { - return typeof(obj) === 'object' && obj && !isArray(obj); -} - -// A better `typeof` -function typeOf(value) { - var s = typeof(value), - types = [Object, Array, String, RegExp, Number, Function, Boolean, Date]; - - if (s === 'object' || s === 'function') { - if (value) { - types.forEach(function (t) { - if (value instanceof t) { s = t.name.toLowerCase() } - }); - } else { s = 'null' } - } - return s; -} diff --git a/node_modules/vows/lib/assert/utils.js b/node_modules/vows/lib/assert/utils.js deleted file mode 100644 index dccd0f6..0000000 --- a/node_modules/vows/lib/assert/utils.js +++ /dev/null @@ -1,77 +0,0 @@ - -// Taken from node/lib/assert.js -exports.deepEqual = function (actual, expected) { - if (actual === expected) { - return true; - - } else if (Buffer.isBuffer(actual) && Buffer.isBuffer(expected)) { - if (actual.length != expected.length) return false; - - for (var i = 0; i < actual.length; i++) { - if (actual[i] !== expected[i]) return false; - } - return true; - - } else if (actual instanceof Date && expected instanceof Date) { - return actual.getTime() === expected.getTime(); - - } else if (typeof actual != 'object' && typeof expected != 'object') { - return actual == expected; - - } else { - return objEquiv(actual, expected); - } -} - -// Taken from node/lib/assert.js -exports.notDeepEqual = function (actual, expected, message) { - if (exports.deepEqual(actual, expected)) { - fail(actual, expected, message, 'notDeepEqual', assert.notDeepEqual); - } -} - -// Taken from node/lib/assert.js -function isUndefinedOrNull(value) { - return value === null || value === undefined; -} - -// Taken from node/lib/assert.js -function isArguments(object) { - return Object.prototype.toString.call(object) == '[object Arguments]'; -} - -// Taken from node/lib/assert.js -function objEquiv(a, b) { - if (isUndefinedOrNull(a) || isUndefinedOrNull(b)) - return false; - if (a.prototype !== b.prototype) return false; - if (isArguments(a)) { - if (!isArguments(b)) { - return false; - } - a = pSlice.call(a); - b = pSlice.call(b); - return exports.deepEqual(a, b); - } - try { - var ka = Object.keys(a), - kb = Object.keys(b), - key, i; - } catch (e) { - return false; - } - if (ka.length != kb.length) - return false; - ka.sort(); - kb.sort(); - for (i = ka.length - 1; i >= 0; i--) { - if (ka[i] != kb[i]) - return false; - } - for (i = ka.length - 1; i >= 0; i--) { - key = ka[i]; - if (!exports.deepEqual(a[key], b[key])) return false; - } - return true; -} - diff --git a/node_modules/vows/lib/vows.js b/node_modules/vows/lib/vows.js deleted file mode 100644 index 44e5cf2..0000000 --- a/node_modules/vows/lib/vows.js +++ /dev/null @@ -1,193 +0,0 @@ -// -// Vows.js - asynchronous event-based BDD for node.js -// -// usage: -// -// var vows = require('vows'); -// -// vows.describe('Deep Thought').addBatch({ -// "An instance of DeepThought": { -// topic: new DeepThought, -// -// "should know the answer to the ultimate question of life": function (deepThought) { -// assert.equal (deepThought.question('what is the answer to the universe?'), 42); -// } -// } -// }).run(); -// -var sys = require('sys'), - path = require('path'), - events = require('events'), - vows = exports; - -// Options -vows.options = { - Emitter: events.EventEmitter, - reporter: require('./vows/reporters/dot-matrix'), - matcher: /.*/, - error: true // Handle "error" event -}; - -vows.__defineGetter__('reporter', function () { - return vows.options.reporter; -}); - -var stylize = require('./vows/console').stylize; -var console = require('./vows/console'); - -vows.inspect = require('./vows/console').inspect; -vows.prepare = require('./vows/extras').prepare; -vows.tryEnd = require('./vows/suite').tryEnd; - -// -// Assertion Macros & Extensions -// -require('./assert/error'); -require('./assert/macros'); - -// -// Suite constructor -// -var Suite = require('./vows/suite').Suite; - -// -// This function gets added to events.EventEmitter.prototype, by default. -// It's essentially a wrapper around `on`, which adds all the specification -// goodness. -// -function addVow(vow) { - var batch = vow.batch; - - batch.total ++; - batch.vows.push(vow); - - return this.on("success", function () { - var args = Array.prototype.slice.call(arguments); - // If the callback is expecting two or more arguments, - // pass the error as the first (null) and the result after. - if (vow.callback.length >= 2 && batch.suite.options.error) { - args.unshift(null); - } - runTest(args, this.ctx); - vows.tryEnd(batch); - - }).on("error", function (err) { - if (vow.callback.length >= 2 || !batch.suite.options.error) { - runTest(arguments, this.ctx); - } else { - output('errored', { type: 'promise', error: err.stack || err.message || JSON.stringify(err) }); - } - vows.tryEnd(batch); - }); - - function runTest(args, ctx) { - var topic, status; - - if (vow.callback instanceof String) { - return output('pending'); - } - - // Run the test, and try to catch `AssertionError`s and other exceptions; - // increment counters accordingly. - try { - vow.callback.apply(ctx === global || !ctx ? vow.binding : ctx, args); - output('honored'); - } catch (e) { - if (e.name && e.name.match(/AssertionError/)) { - output('broken', e.toString()); - } else { - output('errored', e.stack || e.message || e); - } - } - } - - function output(status, exception) { - batch[status] ++; - vow.status = status; - - if (vow.context && batch.lastContext !== vow.context) { - batch.lastContext = vow.context; - batch.suite.report(['context', vow.context]); - } - batch.suite.report(['vow', { - title: vow.description, - context: vow.context, - status: status, - exception: exception || null - }]); - } -}; - -// -// On exit, check that all promises have been fired. -// If not, report an error message. -// -process.on('exit', function () { - var results = { honored: 0, broken: 0, errored: 0, pending: 0, total: 0 }, failure; - - vows.suites.forEach(function (s) { - if ((s.results.total > 0) && (s.results.time === null)) { - s.reporter.print('\n\n'); - s.reporter.report(['error', { error: "Asynchronous Error", suite: s }]); - } - s.batches.forEach(function (b) { - var unFired = []; - - b.vows.forEach(function (vow) { - if (! vow.status) { - if (unFired.indexOf(vow.context) === -1) { - unFired.push(vow.context); - } - } - }); - - if (unFired.length > 0) { sys.print('\n') } - - unFired.forEach(function (title) { - s.reporter.report(['error', { - error: "callback not fired", - context: title, - batch: b, - suite: s - }]); - }); - - if (b.status === 'begin') { - failure = true; - results.errored ++; - results.total ++; - } - Object.keys(results).forEach(function (k) { results[k] += b[k] }); - }); - }); - if (failure) { - sys.puts(console.result(results)); - } -}); - -vows.suites = []; - -// -// Create a new test suite -// -vows.describe = function (subject) { - var suite = new(Suite)(subject); - - this.options.Emitter.prototype.addVow = addVow; - this.suites.push(suite); - - // - // Add any additional arguments as batches if they're present - // - if (arguments.length > 1) { - for (var i = 1, l = arguments.length; i < l; ++i) { - suite.addBatch(arguments[i]); - } - } - - return suite; -}; - - -vows.version = require('fs').readFileSync(path.join(__dirname, '..', 'package.json')) - .toString().match(/"version"\s*:\s*"([\d.]+)"/)[1]; diff --git a/node_modules/vows/lib/vows/console.js b/node_modules/vows/lib/vows/console.js deleted file mode 100644 index cf988dd..0000000 --- a/node_modules/vows/lib/vows/console.js +++ /dev/null @@ -1,131 +0,0 @@ -var eyes = require('eyes').inspector({ stream: null, styles: false }); - -// Stylize a string -this.stylize = function stylize(str, style) { - var styles = { - 'bold' : [1, 22], - 'italic' : [3, 23], - 'underline' : [4, 24], - 'cyan' : [96, 39], - 'yellow' : [33, 39], - 'green' : [32, 39], - 'red' : [31, 39], - 'grey' : [90, 39], - 'green-hi' : [92, 32], - }; - return '\033[' + styles[style][0] + 'm' + str + - '\033[' + styles[style][1] + 'm'; -}; - -var $ = this.$ = function (str) { - str = new(String)(str); - - ['bold', 'grey', 'yellow', 'red', 'green', 'white', 'cyan', 'italic'].forEach(function (style) { - Object.defineProperty(str, style, { - get: function () { - return exports.$(exports.stylize(this, style)); - } - }); - }); - return str; -}; - -this.puts = function (options) { - var stylize = exports.stylize; - options.stream || (options.stream = process.stdout); - options.tail = options.tail || ''; - - return function (args) { - args = Array.prototype.slice.call(arguments); - if (!options.raw) { - args = args.map(function (a) { - return a.replace(/`([^`]+)`/g, function (_, capture) { return stylize(capture, 'italic') }) - .replace(/\*([^*]+)\*/g, function (_, capture) { return stylize(capture, 'bold') }); - }); - } - return options.stream.write(args.join('\n') + options.tail); - }; -}; - -this.result = function (event) { - var result = [], buffer = [], time = '', header; - var complete = event.honored + event.pending + event.errored + event.broken; - var status = (event.errored && 'errored') || (event.broken && 'broken') || - (event.honored && 'honored') || (event.pending && 'pending'); - - if (event.total === 0) { - return [$("Could not find any tests to run.").bold.red]; - } - - event.honored && result.push($(event.honored).bold + " honored"); - event.broken && result.push($(event.broken).bold + " broken"); - event.errored && result.push($(event.errored).bold + " errored"); - event.pending && result.push($(event.pending).bold + " pending"); - - if (complete < event.total) { - result.push($(event.total - complete).bold + " dropped"); - } - - result = result.join(' ∙ '); - - header = { - honored: '✓ ' + $('OK').bold.green, - broken: '✗ ' + $('Broken').bold.yellow, - errored: '✗ ' + $('Errored').bold.red, - pending: '- ' + $('Pending').bold.cyan - }[status] + ' » '; - - if (typeof(event.time) === 'number') { - time = ' (' + event.time.toFixed(3) + 's)'; - time = this.stylize(time, 'grey'); - } - buffer.push(header + result + time + '\n'); - - return buffer; -}; - -this.inspect = function inspect(val) { - return '\033[1m' + eyes(val) + '\033[22m'; -}; - -this.error = function (obj) { - var string = '✗ ' + $('Errored ').red + '» '; - string += $(obj.error).red.bold + '\n'; - string += (obj.context ? ' in ' + $(obj.context).red + '\n': ''); - string += ' in ' + $(obj.suite.subject).red + '\n'; - string += ' in ' + $(obj.suite._filename).red; - - return string; -}; - -this.contextText = function (event) { - return ' ' + event; -}; - -this.vowText = function (event) { - var buffer = []; - - buffer.push(' ' + { - honored: ' ✓ ', - broken: ' ✗ ', - errored: ' ✗ ', - pending: ' - ' - }[event.status] + this.stylize(event.title, ({ - honored: 'green', - broken: 'yellow', - errored: 'red', - pending: 'cyan' - })[event.status])); - - if (event.status === 'broken') { - buffer.push(' » ' + event.exception); - } else if (event.status === 'errored') { - if (event.exception.type === 'promise') { - buffer.push(' » ' + this.stylize("An unexpected error was caught: " + - this.stylize(event.exception.error, 'bold'), 'red')); - } else { - buffer.push(' ' + this.stylize(event.exception, 'red')); - } - } - return buffer.join('\n'); -}; diff --git a/node_modules/vows/lib/vows/context.js b/node_modules/vows/lib/vows/context.js deleted file mode 100644 index 426bc27..0000000 --- a/node_modules/vows/lib/vows/context.js +++ /dev/null @@ -1,55 +0,0 @@ - -this.Context = function (vow, ctx, env) { - var that = this; - - this.tests = vow.callback; - this.topics = (ctx.topics || []).slice(0); - this.emitter = null; - this.env = env || {}; - this.env.context = this; - - this.env.callback = function (/* arguments */) { - var ctx = this; - var args = Array.prototype.slice.call(arguments); - - var emit = (function (args) { - // - // Convert callback-style results into events. - // - if (vow.batch.suite.options.error) { - return function () { - var e = args.shift(); - that.emitter.ctx = ctx; - // We handle a special case, where the first argument is a - // boolean, in which case we treat it as a result, and not - // an error. This is useful for `path.exists` and other - // functions like it, which only pass a single boolean - // parameter instead of the more common (error, result) pair. - if (typeof(e) === 'boolean' && args.length === 0) { - that.emitter.emit.call(that.emitter, 'success', e); - } else { - if (e) { that.emitter.emit.apply(that.emitter, ['error', e].concat(args)) } - else { that.emitter.emit.apply(that.emitter, ['success'].concat(args)) } - } - }; - } else { - return function () { - that.emitter.ctx = ctx; - that.emitter.emit.apply(that.emitter, ['success'].concat(args)); - }; - } - })(args.slice(0)); - // If `this.callback` is called synchronously, - // the emitter will not have been set yet, - // so we defer the emition, that way it'll behave - // asynchronously. - if (that.emitter) { emit() } - else { process.nextTick(emit) } - }; - this.name = vow.description; - this.title = [ - ctx.title || '', - vow.description || '' - ].join(/^[#.:]/.test(vow.description) ? '' : ' ').trim(); -}; - diff --git a/node_modules/vows/lib/vows/coverage/file.js b/node_modules/vows/lib/vows/coverage/file.js deleted file mode 100644 index 5bdef90..0000000 --- a/node_modules/vows/lib/vows/coverage/file.js +++ /dev/null @@ -1,29 +0,0 @@ - -exports.coverage = function (filename, data) { - var ret = { - filename: filename, - coverage: 0, - hits: 0, - misses: 0, - sloc : 0 - }; - - var source = data.source; - ret.source = source.map(function (line, num) { - num++; - - if (data[num] === 0) { - ret.misses++; - ret.sloc++; - } else if (data[num] !== undefined) { - ret.hits++; - ret.sloc++; - } - - return { line: line, coverage: (data[num] === undefined ? '' : data[num]) }; - }); - - ret.coverage = (ret.hits / ret.sloc) * 100; - - return ret; -}; \ No newline at end of file diff --git a/node_modules/vows/lib/vows/coverage/fragments/coverage-foot.html b/node_modules/vows/lib/vows/coverage/fragments/coverage-foot.html deleted file mode 100644 index 691287b..0000000 --- a/node_modules/vows/lib/vows/coverage/fragments/coverage-foot.html +++ /dev/null @@ -1,2 +0,0 @@ - - \ No newline at end of file diff --git a/node_modules/vows/lib/vows/coverage/fragments/coverage-head.html b/node_modules/vows/lib/vows/coverage/fragments/coverage-head.html deleted file mode 100644 index aa2f107..0000000 --- a/node_modules/vows/lib/vows/coverage/fragments/coverage-head.html +++ /dev/null @@ -1,61 +0,0 @@ - - - - - - - diff --git a/node_modules/vows/lib/vows/coverage/report-html.js b/node_modules/vows/lib/vows/coverage/report-html.js deleted file mode 100644 index 8ae15df..0000000 --- a/node_modules/vows/lib/vows/coverage/report-html.js +++ /dev/null @@ -1,54 +0,0 @@ -var sys = require('sys'), - fs = require('fs'), - file = require('./file'); - -this.name = 'coverage-report-html'; - -function getCoverageClass( data ) { - var fullCoverage= (data.coverage == 100); - var okCoverage= (!fullCoverage && data.coverage >=60); - var coverageClass= ''; - if( fullCoverage ) coverageClass= 'fullCoverage'; - else if( okCoverage) coverageClass= 'okCoverage'; - else coverageClass= 'poorCoverage'; - return coverageClass; -} -this.report = function (coverageMap) { - var out, head, foot; - - try { - out = fs.openSync("coverage.html", "w"); - head = fs.readFileSync(__dirname + "/fragments/coverage-head.html", "utf8"); - foot = fs.readFileSync(__dirname + "/fragments/coverage-foot.html", "utf8"); - } catch (error) { - sys.print("Error: Unable to write to file coverage.html\n"); - return; - } - - fs.writeSync(out, head); - - for (var filename in coverageMap) { - if (coverageMap.hasOwnProperty(filename)) { - var data = file.coverage(filename, coverageMap[filename]); - var coverageClass= getCoverageClass( data ); - fs.writeSync(out, "

    " + filename + "

    \n"); - fs.writeSync(out, '' + "[ hits: " + data.hits); - fs.writeSync(out, ", misses: " + data.misses + ", sloc: " + data.sloc); - fs.writeSync(out, ", coverage: " + data.coverage.toFixed(2) + "% ]" + " [+]\n"); - fs.writeSync(out, "\n"); - fs.writeSync(out, "
    \n"); - } - } - - fs.writeSync(out, foot); - fs.close(out); -}; \ No newline at end of file diff --git a/node_modules/vows/lib/vows/coverage/report-json.js b/node_modules/vows/lib/vows/coverage/report-json.js deleted file mode 100644 index 90fea22..0000000 --- a/node_modules/vows/lib/vows/coverage/report-json.js +++ /dev/null @@ -1,54 +0,0 @@ -var sys = require('sys'), - fs = require('fs'), - file = require('./file'); - -this.name = 'coverage-report-json'; - -this.report = function (coverageMap) { - var output = { - meta: { - "generator": "vowsjs", - "generated": new Date().toString(), - "instrumentation": "node-jscoverage", - "file-version": "1.0" - }, - files: [ ], - coverage: [ ] - }; - - - for (var filename in coverageMap) { - if (coverageMap.hasOwnProperty(filename)) { - var data = file.coverage(filename, coverageMap[filename]); - - var coverage = { - file: filename, - coverage: data.coverage.toFixed(2), - hits: data.hits, - misses: data.misses, - sloc: data.sloc, - source: { } - }; - - for (var i = 0; i < data.source.length; i++) { - coverage.source[i + 1] = { - line: data.source[i].line, - coverage: data.source[i].coverage - }; - } - - output.coverage.push(coverage); - - output.files.push(filename); - } - } - - try { - out = fs.openSync("coverage.json", "w"); - fs.writeSync(out, JSON.stringify(output)); - fs.close(out); - } catch (error) { - sys.print("Error: Unable to write to file coverage.json\n"); - return; - } -}; \ No newline at end of file diff --git a/node_modules/vows/lib/vows/coverage/report-plain.js b/node_modules/vows/lib/vows/coverage/report-plain.js deleted file mode 100644 index e82e42f..0000000 --- a/node_modules/vows/lib/vows/coverage/report-plain.js +++ /dev/null @@ -1,38 +0,0 @@ -var sys = require('sys'), - file = require('./file'); - -this.name = 'coverage-report-plain'; - -function lpad(str, width) { - str = String(str); - var n = width - str.length; - - if (n < 1) { - return str; - } - - while (n--) { - str = ' ' + str; - } - - return str; -} - - -this.report = function (coverageMap) { - for (var filename in coverageMap) { - if (coverageMap.hasOwnProperty(filename)) { - var data = file.coverage(filename, coverageMap[filename]); - - sys.print(filename + ":\n"); - sys.print("[ hits: " + data.hits + ", misses: " + data.misses); - sys.print(", sloc: " + data.sloc + ", coverage: " + data.coverage.toFixed(2) + "% ]\n"); - - for (var i = 0; i < data.source.length; i++) { - sys.print(lpad(data.source[i].coverage, 5) + " | " + data.source[i].line + "\n"); - } - - sys.print("\n"); - } - } -}; \ No newline at end of file diff --git a/node_modules/vows/lib/vows/extras.js b/node_modules/vows/lib/vows/extras.js deleted file mode 100644 index a90d7a5..0000000 --- a/node_modules/vows/lib/vows/extras.js +++ /dev/null @@ -1,28 +0,0 @@ -var events = require('events'); -// -// Wrap a Node.js style async function into an EventEmmitter -// -this.prepare = function (obj, targets) { - targets.forEach(function (target) { - if (target in obj) { - obj[target] = (function (fun) { - return function () { - var args = Array.prototype.slice.call(arguments); - var ee = new(events.EventEmitter); - - args.push(function (err /* [, data] */) { - var args = Array.prototype.slice.call(arguments, 1); - - if (err) { ee.emit.apply(ee, ['error', err].concat(args)) } - else { ee.emit.apply(ee, ['success'].concat(args)) } - }); - fun.apply(obj, args); - - return ee; - }; - })(obj[target]); - } - }); - return obj; -}; - diff --git a/node_modules/vows/lib/vows/reporters/dot-matrix.js b/node_modules/vows/lib/vows/reporters/dot-matrix.js deleted file mode 100644 index 0ecf590..0000000 --- a/node_modules/vows/lib/vows/reporters/dot-matrix.js +++ /dev/null @@ -1,67 +0,0 @@ -var options = { tail: '' }, - console = require('../../vows/console'), - stylize = console.stylize, - puts = console.puts(options); -// -// Console reporter -// -var messages = [], lastContext; - -this.name = 'dot-matrix'; -this.setStream = function (s) { - options.stream = s; -}; - -this.reset = function () { - messages = []; - lastContext = null; -}; -this.report = function (data) { - var event = data[1]; - - switch (data[0]) { - case 'subject': - // messages.push(stylize(event, 'underline') + '\n'); - break; - case 'context': - break; - case 'vow': - if (event.status === 'honored') { - puts(stylize('·', 'green')); - } else if (event.status === 'pending') { - puts(stylize('-', 'cyan')); - } else { - if (lastContext !== event.context) { - lastContext = event.context; - messages.push(' ' + event.context); - } - if (event.status === 'broken') { - puts(stylize('✗', 'yellow')); - messages.push(console.vowText(event)); - } else if (event.status === 'errored') { - puts(stylize('✗', 'red')); - messages.push(console.vowText(event)); - } - messages.push(''); - } - break; - case 'end': - puts(' '); - break; - case 'finish': - if (messages.length) { - puts('\n\n' + messages.join('\n')); - } else { - puts(''); - } - puts(console.result(event).join('\n')); - break; - case 'error': - puts(console.error(event)); - break; - } -}; - -this.print = function (str) { - puts(str); -}; diff --git a/node_modules/vows/lib/vows/reporters/json.js b/node_modules/vows/lib/vows/reporters/json.js deleted file mode 100644 index 9f5ac4d..0000000 --- a/node_modules/vows/lib/vows/reporters/json.js +++ /dev/null @@ -1,16 +0,0 @@ -var options = { tail: '\n', raw: true }; -var console = require('../../vows/console'); -var puts = console.puts(options); - -// -// Console JSON reporter -// -this.name = 'json'; -this.setStream = function (s) { - options.stream = s; -}; -this.report = function (obj) { - puts(JSON.stringify(obj)); -}; - -this.print = function (str) {}; diff --git a/node_modules/vows/lib/vows/reporters/silent.js b/node_modules/vows/lib/vows/reporters/silent.js deleted file mode 100644 index fe90a33..0000000 --- a/node_modules/vows/lib/vows/reporters/silent.js +++ /dev/null @@ -1,8 +0,0 @@ -// -// Silent reporter - "Shhh" -// -this.name = 'silent'; -this.reset = function () {}; -this.report = function () {}; -this.print = function () {}; - diff --git a/node_modules/vows/lib/vows/reporters/spec.js b/node_modules/vows/lib/vows/reporters/spec.js deleted file mode 100644 index 0f91146..0000000 --- a/node_modules/vows/lib/vows/reporters/spec.js +++ /dev/null @@ -1,44 +0,0 @@ -var sys = require('sys'); - -var options = { tail: '\n' }; -var console = require('../../vows/console'); -var stylize = console.stylize, - puts = console.puts(options); -// -// Console reporter -// - -this.name = 'spec'; -this.setStream = function (s) { - options.stream = s; -}; -this.report = function (data) { - var event = data[1]; - - buffer = []; - - switch (data[0]) { - case 'subject': - puts('\n♢ ' + stylize(event, 'bold') + '\n'); - break; - case 'context': - puts(console.contextText(event)); - break; - case 'vow': - puts(console.vowText(event)); - break; - case 'end': - sys.print('\n'); - break; - case 'finish': - puts(console.result(event).join('\n')); - break; - case 'error': - puts(console.error(event)); - break; - } -}; - -this.print = function (str) { - sys.print(str); -}; diff --git a/node_modules/vows/lib/vows/reporters/watch.js b/node_modules/vows/lib/vows/reporters/watch.js deleted file mode 100644 index f172481..0000000 --- a/node_modules/vows/lib/vows/reporters/watch.js +++ /dev/null @@ -1,39 +0,0 @@ -var sys = require('sys'); - -var options = {}; -var console = require('../../vows/console'); -var spec = require('../../vows/reporters/spec'); -var stylize = console.stylize, - puts = console.puts(options); -// -// Console reporter -// -var lastContext; - -this.name = 'watch'; -this.setStream = function (s) { - options.stream = s; -}; -this.reset = function () { - lastContext = null; -}; -this.report = function (data) { - var event = data[1]; - - switch (data[0]) { - case 'vow': - if (['honored', 'pending'].indexOf(event.status) === -1) { - if (lastContext !== event.context) { - lastContext = event.context; - puts(console.contextText(event.context)); - } - puts(console.vowText(event)); - puts(''); - } - break; - case 'error': - puts(console.error(event)); - break; - } -}; -this.print = function (str) {}; diff --git a/node_modules/vows/lib/vows/reporters/xunit.js b/node_modules/vows/lib/vows/reporters/xunit.js deleted file mode 100644 index 411a948..0000000 --- a/node_modules/vows/lib/vows/reporters/xunit.js +++ /dev/null @@ -1,90 +0,0 @@ -// xunit outoput for vows, so we can run things under hudson -// -// The translation to xunit is simple. Most likely more tags/attributes can be -// added, see: http://ant.1045680.n5.nabble.com/schema-for-junit-xml-output-td1375274.html -// - -var puts = require('util').puts; - -var buffer = [], - curSubject = null; - -function xmlEnc(value) { - return !value ? value : String(value).replace(/&/g, "&") - .replace(/>/g, ">") - .replace(/'; -} - -function cdata(data) { - return ''; -} - -this.name = 'xunit'; -this.report = function (data) { - var event = data[1]; - - switch (data[0]) { - case 'subject': - curSubject = event; - break; - case 'context': - break; - case 'vow': - switch (event.status) { - case 'honored': - buffer.push(tag('testcase', {classname: curSubject, name: event.context + ': ' + event.title}, true)); - break; - case 'broken': - var err = tag('error', {type: 'vows.event.broken', message: 'Broken test'}, false, cdata(event.exception)); - buffer.push(tag('testcase', {classname: curSubject, name: event.context + ': ' + event.title}, false, err)); - break; - case 'errored': - var skip = tag('skipped', {type: 'vows.event.errored', message: 'Errored test'}, false, cdata(event.exception)); - buffer.push(tag('testcase', {classname: curSubject, name: event.context + ': ' + event.title}, false, skip)); - break; - case 'pending': - // nop - break; - } - break; - case 'end': - buffer.push(end('testcase')); - break; - case 'finish': - buffer.unshift(tag('testsuite', {name: 'Vows test', tests: event.total, timestamp: (new Date()).toUTCString(), errors: event.errored, failures: event.broken, skip: event.pending, time: event.time})); - buffer.push(end('testsuite')); - puts(buffer.join('\n')); - break; - case 'error': - break; - } -}; - -this.print = function (str) { }; diff --git a/node_modules/vows/lib/vows/suite.js b/node_modules/vows/lib/vows/suite.js deleted file mode 100644 index 6665ed3..0000000 --- a/node_modules/vows/lib/vows/suite.js +++ /dev/null @@ -1,319 +0,0 @@ -var events = require('events'), - path = require('path'); - -var vows = require('../vows'); -var Context = require('../vows/context').Context; - -this.Suite = function (subject) { - this.subject = subject; - this.matcher = /.*/; - this.reporter = require('./reporters/dot-matrix'); - this.batches = []; - this.options = { error: true }; - this.reset(); -}; - -this.Suite.prototype = new(function () { - this.reset = function () { - this.results = { - honored: 0, - broken: 0, - errored: 0, - pending: 0, - total: 0, - time: null - }; - this.batches.forEach(function (b) { - b.lastContext = null; - b.remaining = b._remaining; - b.honored = b.broken = b.errored = b.total = b.pending = 0; - b.vows.forEach(function (vow) { vow.status = null }); - b.teardowns = []; - }); - }; - - this.addBatch = function (tests) { - this.batches.push({ - tests: tests, - suite: this, - vows: [], - remaining: 0, - _remaining: 0, - honored: 0, - broken: 0, - errored: 0, - pending: 0, - total: 0, - teardowns: [] - }); - return this; - }; - this.addVows = this.addBatch; - - this.parseBatch = function (batch, matcher) { - var tests = batch.tests; - - if ('topic' in tests) { - throw new(Error)("missing top-level context."); - } - // Count the number of vows/promises expected to fire, - // so we know when the tests are over. - // We match the keys against `matcher`, to decide - // whether or not they should be included in the test. - // Any key, including assertion function keys can be matched. - // If a child matches, then the n parent topics must not be skipped. - (function count(tests, _match) { - var match = false; - - var keys = Object.keys(tests).filter(function (k) { - return k !== 'topic' && k !== 'teardown'; - }); - - for (var i = 0, key; i < keys.length; i++) { - key = keys[i]; - - // If the parent node, or this one matches. - match = _match || matcher.test(key); - - if (typeof(tests[key]) === 'object') { - match = count(tests[key], match); - } else { - if (typeof(tests[key]) === 'string') { - tests[key] = new(String)(tests[key]); - } - if (! match) { - tests[key]._skip = true; - } - } - } - - // If any of the children matched, - // don't skip this node. - for (var i = 0; i < keys.length; i++) { - if (! tests[keys[i]]._skip) { match = true } - } - - if (match) { batch.remaining ++ } - else { tests._skip = true } - - return match; - })(tests, false); - - batch._remaining = batch.remaining; - }; - - this.runBatch = function (batch) { - var topic, - tests = batch.tests, - promise = batch.promise = new(events.EventEmitter); - - var that = this; - - batch.status = 'begin'; - - // The test runner, it calls itself recursively, passing the - // previous context to the inner contexts. This is so the `topic` - // functions have access to all the previous context topics in their - // arguments list. - // It is defined and invoked at the same time. - // If it encounters a `topic` function, it waits for the returned - // promise to emit (the topic), at which point it runs the functions under it, - // passing the topic as an argument. - (function run(ctx, lastTopic) { - var old = false; - topic = ctx.tests.topic; - - if (typeof(topic) === 'function') { - // Run the topic, passing the previous context topics - topic = topic.apply(ctx.env, ctx.topics); - - if (typeof(topic) === 'undefined') { ctx._callback = true } - } - - // If this context has a topic, store it in `lastTopic`, - // if not, use the last topic, passed down by a parent - // context. - if (typeof(topic) !== 'undefined' || ctx._callback) { - lastTopic = topic; - } else { - old = true; - topic = lastTopic; - } - - // If the topic doesn't return an event emitter (such as a promise), - // we create it ourselves, and emit the value on the next tick. - if (! (topic && topic.constructor === events.EventEmitter)) { - ctx.emitter = new(events.EventEmitter); - - if (! ctx._callback) { - process.nextTick(function (val) { - return function () { ctx.emitter.emit("success", val) }; - }(topic)); - } - topic = ctx.emitter; - } - - topic.on('success', function (val) { - // Once the topic fires, add the return value - // to the beginning of the topics list, so it - // becomes the first argument for the next topic. - // If we're using the parent topic, no need to - // prepend it to the topics list, or we'll get - // duplicates. - if (! old) Array.prototype.unshift.apply(ctx.topics, arguments); - }); - if (topic.setMaxListeners) { topic.setMaxListeners(Infinity) } - - // Now run the tests, or sub-contexts - Object.keys(ctx.tests).filter(function (k) { - return ctx.tests[k] && k !== 'topic' && - k !== 'teardown' && !ctx.tests[k]._skip; - }).forEach(function (item) { - // Create a new evaluation context, - // inheriting from the parent one. - var env = Object.create(ctx.env); - env.suite = that; - - // Holds the current test or context - var vow = Object.create({ - callback: ctx.tests[item], - context: ctx.title, - description: item, - binding: ctx.env, - status: null, - batch: batch - }); - - // If we encounter a function, add it to the callbacks - // of the `topic` function, so it'll get called once the - // topic fires. - // If we encounter an object literal, we recurse, sending it - // our current context. - if ((typeof(vow.callback) === 'function') || (vow.callback instanceof String)) { - topic.addVow(vow); - } else if (typeof(vow.callback) === 'object') { - // If there's a setup stage, we have to wait for it to fire, - // before calling the inner context. Else, just run the inner context - // synchronously. - if (topic) { - topic.on("success", function (ctx) { - return function (val) { - return run(new(Context)(vow, ctx, env), lastTopic); - }; - }(ctx)); - } else { - run(new(Context)(vow, ctx, env), lastTopic); - } - } - }); - // Teardown - if (ctx.tests.teardown) { - batch.teardowns.push(ctx); - } - if (! ctx.tests._skip) { - batch.remaining --; - } - // Check if we're done running the tests - exports.tryEnd(batch); - // This is our initial, empty context - })(new(Context)({ callback: tests, context: null, description: null }, {})); - return promise; - }; - - this.report = function () { - return this.reporter.report.apply(this.reporter, arguments); - }; - - this.run = function (options, callback) { - var that = this, start; - - options = options || {}; - - for (var k in options) { this.options[k] = options[k] } - - this.matcher = this.options.matcher || this.matcher; - this.reporter = this.options.reporter || this.reporter; - - this.batches.forEach(function (batch) { - that.parseBatch(batch, that.matcher); - }); - - this.reset(); - - start = new(Date); - - if (this.batches.filter(function (b) { return b.remaining > 0 }).length) { - this.report(['subject', this.subject]); - } - - return (function run(batches) { - var batch = batches.shift(); - - if (batch) { - // If the batch has no vows to run, - // go to the next one. - if (batch.remaining === 0) { - run(batches); - } else { - that.runBatch(batch).on('end', function () { - run(batches); - }); - } - } else { - that.results.time = (new(Date) - start) / 1000; - that.report(['finish', that.results]); - - if (callback) { callback(that.results) } - - if (that.results.honored + that.results.pending === that.results.total) { - return 0; - } else { - return 1; - } - } - })(this.batches.slice(0)); - }; - - this.runParallel = function () {}; - - this.export = function (module, options) { - for (var k in (options || {})) { this.options[k] = options[k] } - - if (require.main === module) { - return this.run(); - } else { - return module.exports[this.subject] = this; - } - }; - this.exportTo = function (module, options) { // Alias, for JSLint - return this.export(module, options); - }; -}); - -// -// Checks if all the tests in the batch have been run, -// and triggers the next batch (if any), by emitting the 'end' event. -// -this.tryEnd = function (batch) { - var result, style, time; - - if (batch.honored + batch.broken + batch.errored + batch.pending === batch.total && - batch.remaining === 0) { - - Object.keys(batch).forEach(function (k) { - (k in batch.suite.results) && (batch.suite.results[k] += batch[k]); - }); - - // Run teardowns - if (batch.teardowns) { - for (var i = batch.teardowns.length - 1, ctx; i >= 0; i--) { - ctx = batch.teardowns[i]; - ctx.tests.teardown.apply(ctx.env, ctx.topics); - } - } - - batch.status = 'end'; - batch.suite.report(['end']); - batch.promise.emit('end', batch.honored, batch.broken, batch.errored, batch.pending); - } -}; diff --git a/node_modules/vows/package.json b/node_modules/vows/package.json deleted file mode 100644 index 154f5cc..0000000 --- a/node_modules/vows/package.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "name" : "vows", - "description" : "Asynchronous BDD & continuous integration for node.js", - "url" : "http://vowsjs.org", - "keywords" : ["testing", "spec", "test", "BDD"], - "author" : "Alexis Sellier ", - "contributors" : [{ "name": "Charlie Robbins", "email": "charlie.robbins@gmail.com" }], - "dependencies" : {"eyes": ">=0.1.6"}, - "main" : "./lib/vows", - "bin" : { "vows": "./bin/vows" }, - "directories" : { "test": "./test", "bin": "./bin" }, - "version" : "0.5.11", - "engines" : {"node": ">=0.2.6"} -} diff --git a/node_modules/vows/test/assert-test.js b/node_modules/vows/test/assert-test.js deleted file mode 100644 index 76e2d32..0000000 --- a/node_modules/vows/test/assert-test.js +++ /dev/null @@ -1,135 +0,0 @@ -var vows = require('../lib/vows'); -var assert = require('assert'); - -vows.describe('vows/assert').addBatch({ - "The Assertion module": { - topic: require('assert'), - - "`equal`": function (assert) { - assert.equal("hello world", "hello world"); - assert.equal(1, true); - }, - "`match`": function (assert) { - assert.match("hello world", /^[a-z]+ [a-z]+$/); - }, - "`length`": function (assert) { - assert.length("hello world", 11); - assert.length([1, 2, 3], 3); - }, - "`isDefined`": function (assert) { - assert.isDefined(null); - assertError(assert.isDefined, undefined); - }, - "`include`": function (assert) { - assert.include("hello world", "world"); - assert.include([0, 42, 0], 42); - assert.include({goo:true}, 'goo'); - }, - "`deepInclude`": function (assert) { - assert.deepInclude([{a:'b'},{c:'d'}], {a:'b'}); - assert.deepInclude("hello world", "world"); - assert.deepInclude({goo:true}, 'goo'); - }, - "`typeOf`": function (assert) { - assert.typeOf('goo', 'string'); - assert.typeOf(42, 'number'); - assert.typeOf([], 'array'); - assert.typeOf({}, 'object'); - assert.typeOf(false, 'boolean'); - }, - "`instanceOf`": function (assert) { - assert.instanceOf([], Array); - assert.instanceOf(function () {}, Function); - }, - "`isArray`": function (assert) { - assert.isArray([]); - assertError(assert.isArray, {}); - }, - "`isString`": function (assert) { - assert.isString(""); - }, - "`isObject`": function (assert) { - assert.isObject({}); - assertError(assert.isObject, []); - }, - "`isNumber`": function (assert) { - assert.isNumber(0); - }, - "`isBoolean`": function (assert){ - assert.isBoolean(true); - assert.isBoolean(false); - assertError(assert.isBoolean, 0); - }, - "`isNan`": function (assert) { - assert.isNaN(0/0); - }, - "`isTrue`": function (assert) { - assert.isTrue(true); - assertError(assert.isTrue, 1); - }, - "`isFalse`": function (assert) { - assert.isFalse(false); - assertError(assert.isFalse, 0); - }, - "`isZero`": function (assert) { - assert.isZero(0); - assertError(assert.isZero, null); - }, - "`isNotZero`": function (assert) { - assert.isNotZero(1); - }, - "`isUndefined`": function (assert) { - assert.isUndefined(undefined); - assertError(assert.isUndefined, null); - }, - "`isDefined`": function (assert) { - assert.isDefined(null); - assertError(assert.isDefined, undefined); - }, - "`isNull`": function (assert) { - assert.isNull(null); - assertError(assert.isNull, 0); - assertError(assert.isNull, undefined); - }, - "`isNotNull`": function (assert) { - assert.isNotNull(0); - }, - "`greater` and `lesser`": function (assert) { - assert.greater(5, 4); - assert.lesser(4, 5); - }, - "`inDelta`": function (assert) { - assert.inDelta(42, 40, 5); - assert.inDelta(42, 40, 2); - assert.inDelta(42, 42, 0); - assert.inDelta(3.1, 3.0, 0.2); - assertError(assert.inDelta, [42, 40, 1]); - }, - "`isEmpty`": function (assert) { - assert.isEmpty({}); - assert.isEmpty([]); - assert.isEmpty(""); - }, - "`isNotEmpty`": function (assert) { - assert.isNotEmpty({goo:true}); - assert.isNotEmpty([1]); - assert.isNotEmpty(" "); - assertError(assert.isNotEmpty, {}); - assertError(assert.isNotEmpty, []); - assertError(assert.isNotEmpty, ""); - } - } -}).export(module); - -function assertError(assertion, args, fail) { - if (!Array.isArray(args)) { args = [args]; } - try { - assertion.apply(null, args); - fail = true; - } catch (e) {/* Success */} - - fail && assert.fail(args.join(' '), assert.AssertionError, - "expected an AssertionError for {actual}", - "assertError", assertError); -} - diff --git a/node_modules/vows/test/fixtures/isolate/failing.js b/node_modules/vows/test/fixtures/isolate/failing.js deleted file mode 100644 index 7a1865e..0000000 --- a/node_modules/vows/test/fixtures/isolate/failing.js +++ /dev/null @@ -1,18 +0,0 @@ -var vows = require('../../../lib/vows'), - assert = require('assert'); - -var obvious; -vows.describe('failing').addBatch({ - 'Obvious test': obvious = { - topic: function () { - this.callback(null, false); - }, - 'should work': function (result) { - assert.ok(result); - } - // but it won't - }, - 'Obvious test #2': obvious, - 'Obvious test #3': obvious, - 'Obvious test #4': obvious -}).export(module); diff --git a/node_modules/vows/test/fixtures/isolate/log.js b/node_modules/vows/test/fixtures/isolate/log.js deleted file mode 100644 index 9828045..0000000 --- a/node_modules/vows/test/fixtures/isolate/log.js +++ /dev/null @@ -1,18 +0,0 @@ -var vows = require('../../../lib/vows'), - assert = require('assert'); - -var obvious; -vows.describe('stderr').addBatch({ - 'Obvious test': obvious = { - topic: function () { - this.callback(null, true); - }, - 'should work': function (result) { - console.log('oh no!'); - assert.ok(result); - } - }, - 'Obvious test #2': obvious, - 'Obvious test #3': obvious, - 'Obvious test #4': obvious -}).export(module); diff --git a/node_modules/vows/test/fixtures/isolate/passing.js b/node_modules/vows/test/fixtures/isolate/passing.js deleted file mode 100644 index 7f95730..0000000 --- a/node_modules/vows/test/fixtures/isolate/passing.js +++ /dev/null @@ -1,17 +0,0 @@ -var vows = require('../../../lib/vows'), - assert = require('assert'); - -var obvious; -vows.describe('passing').addBatch({ - 'Obvious test': obvious = { - topic: function () { - this.callback(null, true); - }, - 'should work': function (result) { - assert.ok(result); - } - }, - 'Obvious test #2': obvious, - 'Obvious test #3': obvious, - 'Obvious test #4': obvious -}).export(module); diff --git a/node_modules/vows/test/fixtures/isolate/stderr.js b/node_modules/vows/test/fixtures/isolate/stderr.js deleted file mode 100644 index 545ad20..0000000 --- a/node_modules/vows/test/fixtures/isolate/stderr.js +++ /dev/null @@ -1,18 +0,0 @@ -var vows = require('../../../lib/vows'), - assert = require('assert'); - -var obvious; -vows.describe('stderr').addBatch({ - 'Obvious test': obvious = { - topic: function () { - this.callback(null, true); - }, - 'should work': function (result) { - console.error('oh no!'); - assert.ok(result); - } - }, - 'Obvious test #2': obvious, - 'Obvious test #3': obvious, - 'Obvious test #4': obvious -}).export(module); diff --git a/node_modules/vows/test/isolate-test.js b/node_modules/vows/test/isolate-test.js deleted file mode 100644 index 40f993b..0000000 --- a/node_modules/vows/test/isolate-test.js +++ /dev/null @@ -1,140 +0,0 @@ -var vows = require('../lib/vows'), - assert = require('assert'), - path = require('path'), - exec = require('child_process').exec; - -function generateTopic(args, file) { - return function () { - var cmd = './bin/vows' + ' -i ' + (args || '') + - ' ./test/fixtures/isolate/' + file, - options = {cwd: path.resolve(__dirname + '/../')}, - callback = this.callback; - - exec(cmd, options, function (err, stdout, stderr) { - callback(null, { - err: err, - stdout: stdout, - stderr: stderr - }); - }); - } -}; - -function assertExecOk(r) { - assert.isNull(r.err); -} - -function assertExecNotOk(r) { - assert.isNotNull(r.err); -} - -function parseResults(stdout) { - return stdout.split(/\n/g).map(function (s) { - if (!s) return; - return JSON.parse(s); - }).filter(function (s) {return s}); -} - -function assertResultTypePresent(results, type) { - assert.ok(results.some(function (result) { - return result[0] == type; - })); -} - -function assertResultsFinish(results, expected) { - var finish = results[results.length - 1]; - assert.equal(finish[0], 'finish'); - - finish = finish[1]; - - Object.keys(expected).forEach(function (key) { - assert.equal(finish[key], expected[key]); - }); -} - -vows.describe('vows/isolate').addBatch({ - 'Running vows with -i flag for test/fixtures/isolate/': { - 'passing.js': { - 'with default reporter': { - topic: generateTopic(null, 'passing.js'), - 'should be ok': assertExecOk - }, - 'with json reporter': { - topic: generateTopic('--json', 'passing.js'), - 'should be ok': assertExecOk, - 'should have correct output': function (r) { - var results = parseResults(r.stdout) - - assertResultTypePresent(results, 'subject'); - assertResultTypePresent(results, 'end'); - - assertResultsFinish(results, { - total: 4, - honored: 4 - }); - } - } - }, - 'failing.js': { - 'with json reporter': { - topic: generateTopic('--json', 'failing.js'), - 'should be not ok': assertExecNotOk, - 'should have correct output though': function (r) { - var results = parseResults(r.stdout); - - assertResultsFinish(results, { - total: 4, - broken: 4 - }); - } - } - }, - 'stderr.js': { - 'with json reporter': { - topic: generateTopic('--json', 'stderr.js'), - 'should be ok': assertExecOk, - 'should have stderr': function (r) { - assert.equal(r.stderr, - ['oh no!', 'oh no!', 'oh no!', 'oh no!', ''].join('\n')); - }, - 'should have correct output': function (r) { - var results= parseResults(r.stdout); - - assertResultsFinish(results, { - total: 4, - honored: 4 - }); - } - } - }, - 'log.js': { - 'with json reporter': { - topic: generateTopic('--json', 'log.js'), - 'should be ok': assertExecOk, - 'should have correct output': function (r) { - var results= parseResults(r.stdout); - - assertResultsFinish(results, { - total: 4, - honored: 4 - }); - } - } - }, - 'all tests (*)': { - 'with json reporter': { - topic: generateTopic('--json', '*'), - 'should be not ok': assertExecNotOk, - 'should have correct output': function (r) { - var results= parseResults(r.stdout); - - assertResultsFinish(results, { - total: 16, - broken: 4, - honored: 12 - }); - } - } - } - } -}).export(module); diff --git a/node_modules/vows/test/testInherit.js b/node_modules/vows/test/testInherit.js deleted file mode 100644 index 25bc4c0..0000000 --- a/node_modules/vows/test/testInherit.js +++ /dev/null @@ -1,133 +0,0 @@ -/* - * instanceof is a more complete check then .constructor === - * - * It works when using node's built-in util.inherits function - * and it also honors a class's entire ancestry - * - * Here I am only testing the change to vows in suite.js at line 147 to change - * the check from .constructor === to instanceof. These tests should demonstrate - * that this change should work both cases. For completness I also check - * the case when EventEmitter is an ancestor, not the parent Class. - * - */ -var EventEmitter = process.EventEmitter, - util = require('util'), - vows = require('vows'), - assert = require('assert'); - -vows.describe('EventEmitters as a return value from a topic').addBatch({ - 'returning an EventEmitter' : { - topic : function () { - //Make an event emitter - var tmp = new EventEmitter(); - //set it to emit success in a bit - setTimeout(function () { - //pass a value to make sure this all works - tmp.emit('success', 'I work'); - }, 10); - - return tmp; - }, - 'will catch what I pass to success' : function (ret) { - assert.strictEqual(ret, 'I work'); - } - }, - 'returning a class that uses util.inherit to inherit from EventEmitter' : { - topic : function () { - //Make a class that will util.inherit from EventEmitter - var Class = function () { - EventEmitter.call(this); - }, - tmp; - - //inherit from EventEmitter - util.inherits(Class, EventEmitter); - //Get a new one - tmp = new Class(); - //set it to emit success in a bit - setTimeout(function () { - //pass a value to make sure this all works - tmp.emit('success', 'I work'); - }, 10); - - return tmp; - }, - 'will catch what I pass to success' : function (ret) { - assert.strictEqual(ret, 'I work'); - } - }, - 'returning a class that uses Class.prototype = new EventEmitter()' : { - topic : function () { - //Make a class that will inherit from EventEmitter - var Class = function () {}, tmp; - //inherit - Class.prototype = new EventEmitter(); - //Get a new one - tmp = new Class(); - //set it to emit success in a bit - setTimeout(function () { - //pass a value to make sure this all works - tmp.emit('success', 'I work'); - }, 10); - - return tmp; - }, - 'will catch what I pass to success' : function (ret) { - assert.strictEqual(ret, 'I work'); - } - }, - 'returning a class that uses util.inherit to inherit from a class that inherits from EventEmitter ' : { - topic : function () { - //Class1 inherits from EventEmitter - var Class1 = function () { - var self = this; - EventEmitter.call(self); - }, - //Class2 inherits from Class1 - Class2 = function () { - Class1.call(this); - }, tmp; - //Inherit - util.inherits(Class1, EventEmitter); - util.inherits(Class2, Class1); - //Get a new one - tmp = new Class2(); - //set it to emit success in a bit - setTimeout(function () { - //pass a value to make sure this all works - tmp.emit('success', 'I work'); - },10); - - return tmp; - }, - 'will catch what I pass to success' : function (ret) { - assert.strictEqual(ret, 'I work'); - } - }, - 'returning a class that uses Class2.prototype = new Class1() and Class1.prototype = new EventEmitter()' : { - topic : function () { - //Class1 will inherit from EventEmitter - var Class1 = function () {}, - //Class2 will inherit from Class1 - Class2 = function () {}, tmp; - //Inherit - Class1.prototype = new EventEmitter(); - Class2.prototype = new Class1(); - //Get a new one - tmp = new Class2(); - //seit it to emit success in a bit - setTimeout(function () { - //pass a value to make sure this all works - tmp.emit('success', 'I work'); - },10); - - return tmp; - }, - 'will catch what I pass to success' : function (ret) { - assert.strictEqual(ret, 'I work'); - } - } -}).export(module); - - - diff --git a/node_modules/vows/test/vows-error-test.js b/node_modules/vows/test/vows-error-test.js deleted file mode 100644 index 79afaba..0000000 --- a/node_modules/vows/test/vows-error-test.js +++ /dev/null @@ -1,51 +0,0 @@ -var path = require('path'), - events = require('events'), - assert = require('assert'), - fs = require('fs'), - vows = require('../lib/vows'); - -function doSomethingAsync(callback) { - var err = null; - var testValue = 'a'; - - process.nextTick(function() { - callback(err, testValue); - }); -} - -function doSomethingAsyncWithError(callback) { - var err = true; - var testValue = 'a'; - - process.nextTick(function() { - callback(err, testValue); - }); -} - - -vows.describe('vows/error').addBatch({ - 'Generate success response to async function': { - topic: function() { - doSomethingAsync(this.callback) - }, - 'Validate success': function(err, testValue) { - assert.ok(!err); - }, - 'Validate testValue': function(err, testValue) { - assert.equal(testValue, 'a'); - } - }, - - 'Generate error response to async function': { - topic: function() { - doSomethingAsyncWithError(this.callback) - }, - 'Validate error': function(err, testValue) { - assert.ok(err); - }, - 'Validate testValue': function(err, testValue) { - // This assertion fails. It shouldn't. - assert.equal(testValue, 'a'); - } - } -}).export(module) \ No newline at end of file diff --git a/node_modules/vows/test/vows-test.js b/node_modules/vows/test/vows-test.js deleted file mode 100644 index 0568236..0000000 --- a/node_modules/vows/test/vows-test.js +++ /dev/null @@ -1,374 +0,0 @@ -var path = require('path'), - events = require('events'), - assert = require('assert'), - fs = require('fs'), - vows = require('../lib/vows'); - -var api = vows.prepare({ - get: function (id, callback) { - process.nextTick(function () { callback(null, id) }); - }, - version: function () { return '1.0' } -}, ['get']); - -var promiser = function (val) { - return function () { - var promise = new(events.EventEmitter); - process.nextTick(function () { promise.emit('success', val) }); - return promise; - } -}; - -vows.describe("Vows").addBatch({ - "A context": { - topic: promiser("hello world"), - - "with a nested context": { - topic: function (parent) { - this.state = 42; - return promiser(parent)(); - }, - "has access to the environment": function () { - assert.equal(this.state, 42); - }, - "and a sub nested context": { - topic: function () { - return this.state; - }, - "has access to the parent environment": function (r) { - assert.equal(r, 42); - assert.equal(this.state, 42); - }, - "has access to the parent context object": function (r) { - assert.ok(Array.isArray(this.context.topics)); - assert.include(this.context.topics, "hello world"); - } - } - } - }, - "A nested context": { - topic: promiser(1), - - ".": { - topic: function (a) { return promiser(2)() }, - - ".": { - topic: function (b, a) { return promiser(3)() }, - - ".": { - topic: function (c, b, a) { return promiser([4, c, b, a])() }, - - "should have access to the parent topics": function (topics) { - assert.equal(topics.join(), [4, 3, 2, 1].join()); - } - }, - - "from": { - topic: function (c, b, a) { return promiser([4, c, b, a])() }, - - "the parent topics": function(topics) { - assert.equal(topics.join(), [4, 3, 2, 1].join()); - } - } - } - } - }, - "Nested contexts with callback-style async": { - topic: function () { - fs.stat(__dirname + '/vows-test.js', this.callback); - }, - 'after a successful `fs.stat`': { - topic: function (stat) { - fs.open(__dirname + '/vows-test.js', "r", stat.mode, this.callback); - }, - 'after a successful `fs.open`': { - topic: function (fd, stat) { - fs.read(fd, stat.size, 0, "utf8", this.callback); - }, - 'after a successful `fs.read`': function (data) { - assert.match (data, /after a successful `fs.read`/); - } - } - } - }, - "A nested context with no topics": { - topic: 45, - ".": { - ".": { - "should pass the value down": function (topic) { - assert.equal(topic, 45); - } - } - } - }, - "A Nested context with topic gaps": { - topic: 45, - ".": { - ".": { - topic: 101, - ".": { - ".": { - topic: function (prev, prev2) { - return this.context.topics.slice(0); - }, - "should pass the topics down": function (topics) { - assert.length(topics, 2); - assert.equal(topics[0], 101); - assert.equal(topics[1], 45); - } - } - } - } - } - }, - "A non-promise return value": { - topic: function () { return 1 }, - "should be converted to a promise": function (val) { - assert.equal(val, 1); - } - }, - "A 'prepared' interface": { - "with a wrapped function": { - topic: function () { return api.get(42) }, - "should work as expected": function (val) { - assert.equal(val, 42); - } - }, - "with a non-wrapped function": { - topic: function () { return api.version() }, - "should work as expected": function (val) { - assert.equal(val, '1.0'); - } - } - }, - "A non-function topic": { - topic: 45, - - "should work as expected": function (topic) { - assert.equal(topic, 45); - } - }, - "A non-function topic with a falsy value": { - topic: 0, - - "should work as expected": function (topic) { - assert.equal(topic, 0); - } - }, - "A topic returning a function": { - topic: function () { - return function () { return 42 }; - }, - - "should work as expected": function (topic) { - assert.isFunction(topic); - assert.equal(topic(), 42); - }, - "in a sub-context": { - "should work as expected": function (topic) { - assert.isFunction(topic); - assert.equal(topic(), 42); - }, - } - }, - "A topic emitting an error": { - topic: function () { - var promise = new(events.EventEmitter); - process.nextTick(function () { - promise.emit("error", 404); - }); - return promise; - }, - "shouldn't raise an exception if the test expects it": function (e, res) { - assert.equal(e, 404); - assert.ok(! res); - } - }, - "A topic not emitting an error": { - topic: function () { - var promise = new(events.EventEmitter); - process.nextTick(function () { - promise.emit("success", true); - }); - return promise; - }, - "should pass `null` as first argument, if the test is expecting an error": function (e, res) { - assert.strictEqual(e, null); - assert.equal(res, true); - }, - "should pass the result as first argument if the test isn't expecting an error": function (res) { - assert.equal(res, true); - } - }, - "A topic with callback-style async": { - "when successful": { - topic: function () { - var that = this; - process.nextTick(function () { - that.callback(null, "OK"); - }); - }, - "should work like an event-emitter": function (res) { - assert.equal(res, "OK"); - }, - "should assign `null` to the error argument": function (e, res) { - assert.strictEqual(e, null); - assert.equal(res, "OK"); - } - }, - "when unsuccessful": { - topic: function () { - function async(callback) { - process.nextTick(function () { - callback("ERROR"); - }); - } - async(this.callback); - }, - "should have a non-null error value": function (e, res) { - assert.equal(e, "ERROR"); - }, - "should work like an event-emitter": function (e, res) { - assert.equal(res, undefined); - } - }, - "using this.callback synchronously": { - topic: function () { - this.callback(null, 'hello'); - }, - "should work the same as returning a value": function (res) { - assert.equal(res, 'hello'); - } - }, - "using this.callback with a user context": { - topic: function () { - this.callback.call({ boo: true }, null, 'hello'); - }, - "should give access to the user context": function (res) { - assert.isTrue(this.boo); - } - }, - "passing this.callback to a function": { - topic: function () { - this.boo = true; - var async = function (callback) { - callback(null); - }; - async(this.callback); - }, - "should give access to the topic context": function () { - assert.isTrue(this.boo); - } - }, - "with multiple arguments": { - topic: function () { - this.callback(null, 1, 2, 3); - }, - "should pass them to the vow": function (e, a, b, c) { - assert.strictEqual(e, null); - assert.strictEqual(a, 1); - assert.strictEqual(b, 2); - assert.strictEqual(c, 3); - }, - "and a sub-topic": { - topic: function (a, b, c) { - return [a, b, c]; - }, - "should receive them too": function (val) { - assert.deepEqual(val, [1, 2, 3]); - } - } - } - } -}).addBatch({ - "A Sibling context": { - "'A', with `this.foo = true`": { - topic: function () { - this.foo = true; - return this; - }, - "should have `this.foo` set to true": function (res) { - assert.equal(res.foo, true); - } - }, - "'B', with nothing set": { - topic: function () { - return this; - }, - "shouldn't have access to `this.foo`": function (e, res) { - assert.isUndefined(res.foo); - } - } - } -}).addBatch({ - "A 2nd batch": { - topic: function () { - var p = new(events.EventEmitter); - setTimeout(function () { - p.emit("success"); - }, 100); - return p; - }, - "should run after the first": function () {} - } -}).addBatch({ - "A 3rd batch": { - topic: true, "should run last": function () {} - } -}).addBatch({}).export(module); - -vows.describe("Vows with a single batch", { - "This is a batch that's added as the optional parameter to describe()": { - topic: true, - "And a vow": function () {} - } -}).export(module); - -vows.describe("Vows with multiple batches added as optional parameters", { - "First batch": { - topic: true, - "should be run first": function () {} - } -}, { - "Second batch": { - topic: true, - "should be run second": function () {} - } -}).export(module); - -vows.describe("Vows with teardowns").addBatch({ - "A context": { - topic: function () { - return { flag: true }; - }, - "And a vow": function (topic) { - assert.isTrue(topic.flag); - }, - "And another vow": function (topic) { - assert.isTrue(topic.flag); - }, - "And a final vow": function (topic) { - assert.isTrue(topic.flag); - }, - 'subcontext': { - 'nested': function (_, topic) { - assert.isTrue(topic.flag); - } - }, - teardown: function (topic) { - topic.flag = false; - }, - "with a subcontext" : { - topic: function (topic) { - var that = this; - process.nextTick(function () { - that.callback(null, topic); - }); - }, - "Waits for the subcontext before teardown" : function(topic) { - assert.isTrue(topic.flag); - } - } - } -}).export(module); -