Skip to content

Commit

Permalink
init
Browse files Browse the repository at this point in the history
  • Loading branch information
codex committed Dec 19, 2011
1 parent f4cde20 commit d929f02
Show file tree
Hide file tree
Showing 6 changed files with 70 additions and 18 deletions.
2 changes: 1 addition & 1 deletion README.md
@@ -1 +1 @@
README
tater parses out annotated codeblocks
31 changes: 31 additions & 0 deletions domain/services/annotate.coffee
@@ -0,0 +1,31 @@
tokenize = require('parsimony').tokenize
getLeadspace = require('parsimony').getLeadspace

annotate = (dsl, annotationDelim, next) ->

annotationDelim ?= "#>>"
parsingDelim = new RegExp( annotationDelim + '(.+)\n' )

tokenize dsl, parsingDelim, (tokens) ->

tokens.shift() # remove first token

# the first and then every other token is an annotation
# immediately following a token is a codeblock

blocks = []

for annotation, index in tokens by 2

# the next token is code
code = tokens[index + 1]

blocks.push
# block:
annotation: annotation.trim()
code: code.trim()
leadspace: getLeadspace code

next blocks

module.exports = annotate
22 changes: 22 additions & 0 deletions domain/services/specs/annotate.spec.coffee
@@ -0,0 +1,22 @@
#>> Setup

should = require 'should'
annotate = require '../annotate'

#>> Given some DSL code

code =
'''
>> Given some dsl code
foo = "foo"
'''

#>> when it is tokenized

annotate code, '>>', (blocks) ->

#>> Then

blocks[0].annotation.should.equal "Given some dsl code"
blocks[0].code.should.equal 'foo = "foo"'
blocks[0].leadspace.should.equal " "
8 changes: 8 additions & 0 deletions domain/tater.agent.coffee
@@ -0,0 +1,8 @@
annotate = require './services/annotate'

tater =

parse: (dsl, delim, next) -> annotate dsl, delim, next


module.exports = tater
8 changes: 0 additions & 8 deletions domain/yourapp.agent.coffee

This file was deleted.

17 changes: 8 additions & 9 deletions package.json
@@ -1,17 +1,16 @@
{
"name":"APPNAME",
"description":"Nothing here yet",
"name":"tater",
"description":"creates annotated codeblocks",
"version":"0.0.1",
"homepage":"http://github.com/wearefractal/APPNAME",
"repository":"git://github.com/wearefractal/APPNAME.git",
"homepage":"http://github.com/wearefractal/tater",
"repository":"git://github.com/wearefractal/tater.git",
"author":"Fractal <contact@wearefractal.com> (http://wearefractal.com/)",
"main":"./domain/yourapp.coffee",
"main":"./domain/tater.agent.coffee",

"dependencies":{
"coffee-script":"*",
"slice":"*",
"modulate":"*"
},
"parsimony":"*"
},

"devDependencies":{
"should":"*",
Expand All @@ -24,7 +23,7 @@
"licenses":[
{
"type":"MIT",
"url":"http://github.com/wearefractal/APPNAME/raw/master/LICENSE"
"url":"http://github.com/wearefractal/tater/raw/master/LICENSE"
}
]
}

0 comments on commit d929f02

Please sign in to comment.