Socket
Socket
Sign inDemoInstall

literapi

Package Overview
Dependencies
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

literapi - npm Package Compare versions

Comparing version 0.1.2 to 0.1.3

.jsl.conf

5

CHANGELOG.md
# Changelog
## 0.1.3
* Add a new 'quiet' mode with -q
* Internal clean-up
## 0.1.2

@@ -4,0 +9,0 @@

10

lib/compilers/vows.js

@@ -6,2 +6,3 @@ var request = require('request')

, captureRE = /\[([A-Za-z_][A-Za-z_0-9]*)\]/g
, console = require('../console')

@@ -54,3 +55,3 @@ function vowsCompiler(options) {

var match;
if (match = captureRE.exec(string)) {
if ((match = captureRE.exec(string))) {
console.log("WARNING: Possible unrecognized capture: " + match[0])

@@ -105,3 +106,3 @@ console.log(" -> " + string)

var pattern, header = self.substitute(headers[key])
if (pattern = self.headerCapture(header)) {
if ((pattern = self.headerCapture(header))) {
assert.ok(result.headers[key], "Header should exist, but doesn't")

@@ -167,3 +168,3 @@ var match = pattern.regex.exec(result.headers[key])

vowsCompiler.prototype.compile = function (results) {
vowsCompiler.prototype.compile = function (results, cb) {
var suite = vows.describe(results.title)

@@ -176,4 +177,5 @@

suite.tokens = results.tokens
suite.filename = results.filename
return suite
return cb(null, suite)
}

@@ -180,0 +182,0 @@

35

lib/index.js

@@ -20,31 +20,28 @@ var fs = require('fs')

LiterAPI.prototype.parse = function(src) {
return this.parser.parse(src)
LiterAPI.prototype.parse = function(src, cb) {
return this.parser.parse(src, cb)
}
LiterAPI.prototype.compile = function(parsed) {
return this.compiler.compile(parsed)
LiterAPI.prototype.compile = function(parsed, cb) {
return this.compiler.compile(parsed, cb)
}
LiterAPI.prototype.callback = function(name, cb) {
var self = this
return function(err, result) {
LiterAPI.prototype.parseFile = function(filename, cb) {
fs.readFile(filename, 'utf8', function(err, src) {
if (err) return cb(err)
this.parse(src, function(err, parsed) {
if (err) return cb(err)
try {
return cb(null, self[name](result))
} catch (e) {
return cb(e)
}
}
parsed.filename = filename
cb(null, parsed)
}.bind(this))
}.bind(this))
}
LiterAPI.prototype.parseFile = function(filename, cb) {
fs.readFile(filename, 'utf8', this.callback('parse', cb))
}
LiterAPI.prototype.compileFile = function(filename, cb) {
this.parseFile(filename, this.callback('compile', cb))
this.parseFile(filename, function(err, parsed) {
if (err) cb(err)
this.compile(parsed, cb)
}.bind(this))
}
module.exports = LiterAPI

@@ -1,6 +0,7 @@

var markdownstream = require('markdownstream')
var Markdownstream = require('markdownstream')
, ParseResult = require('./ParseResult.js')
function parse(markdown) {
var tokens = markdownstream.sync(markdown)
function parse(markdown, cb) {
var tokens = []
, stream = new Markdownstream
, result = new ParseResult()

@@ -10,25 +11,33 @@ , block = ''

for (i = 0; i < tokens.length; i++) {
token = tokens[i]
stream.on('data', function(token) {
if (token.type == 'heading' && !result.title)
result.setTitle(token.content)
tokens.push(token)
if (token.type == 'code_block') {
block += token.content + "\n\n"
last_code = token
} else {
if (block) {
// flush
result.addBlock(block, last_code)
block = ''
}
if (token.type == 'heading')
result.lastText = token.content
if (token.type == 'heading' && !result.title)
result.setTitle(token.content)
if (token.type == 'code_block') {
block += token.content + "\n\n"
last_code = token
} else {
if (block) {
// flush
result.addBlock(block, last_code)
block = ''
}
}
if (block) result.addBlock(block, last_code)
if (token.type == 'heading')
result.lastText = token.content
}
})
result.tokens = tokens
return result
stream.on('end', function() {
if (block) result.addBlock(block, last_code)
result.tokens = tokens
cb(null, result)
})
stream.write(markdown)
stream.end()
}

@@ -41,3 +50,2 @@

module.exports = markdownParser

@@ -56,3 +56,3 @@ function ParseResult() {

resp.token = token
var parts = block.split(/\n\s*\n/)

@@ -63,3 +63,3 @@ , headers = parts.shift().split("\n")

resp.headers = headers
if (!requestRegex.exec(parts[0]))

@@ -82,5 +82,2 @@ resp.body = parts.shift()

if (block.length)
console.log("Skipping something that doesn't look like anything: " + JSON.stringify(block))
return null

@@ -87,0 +84,0 @@ }

{ "name": "literapi"
, "version": "0.1.2"
, "version": "0.1.3"
, "description": "Literate testing for HTTP APIs using markdown"

@@ -17,3 +17,3 @@ , "keywords": ["testing", "test", "api", "rest", "http", "documentation", "docs", "literate"]

, "scripts":
{ "test": "node test/test.js"
{ "test": "node test/example.js"
}

@@ -20,0 +20,0 @@ , "dependencies":

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc