Skip to content

Commit

Permalink
Packaging reworked for npm 1.x.
Browse files Browse the repository at this point in the history
  • Loading branch information
mauricemach committed May 6, 2011
1 parent 001eb2a commit fec0a69
Show file tree
Hide file tree
Showing 14 changed files with 56 additions and 51 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
.DS_Store
material/
lib/coffeekup.js
node_modules/
2 changes: 2 additions & 0 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
.git*
material/
4 changes: 2 additions & 2 deletions Cakefile
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
exec = require('child_process').exec

task 'build', ->
exec 'coffee -c lib/coffeekup.coffee', (err) ->
puts err if err
exec 'coffee -o lib -c src/*.coffee', (err) ->
console.log err if err

task 'test', -> require('./test').run()

Expand Down
14 changes: 9 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,8 @@ Just grab [node.js](http://nodejs.org/#download) and [npm](http://github.com/isa

coffeekup = require 'coffeekup'

puts coffeekup.render -> h1 "You can feed me templates as functions."
puts coffeekup.render "h1 'Or strings. I am not too picky.'"
console.log coffeekup.render -> h1 "You can feed me templates as functions."
console.log coffeekup.render "h1 'Or strings. I am not too picky.'"

Defining locals and context variables:

Expand All @@ -94,12 +94,12 @@ Defining locals and context variables:
attrs.name = attrs.id
@input attrs

puts coffeekup.render template, context: {title: 'Log In'}, locals: helpers
console.log coffeekup.render template, context: {title: 'Log In'}, locals: helpers

Precompiling to functions:

standalone_template = coffeekup.compile template
puts standalone_template(context: {foo: 'bar'}, locals: {ping: 'pong'})
console.log standalone_template(context: {foo: 'bar'}, locals: {ping: 'pong'})

With [zappa](http://github.com/mauricemach/zappa):

Expand Down Expand Up @@ -159,6 +159,10 @@ See [/examples](http://github.com/mauricemach/coffeekup/tree/master/examples) fo

## Change Log:

**v0.2.3** (2011-05-06):

- Packaging reworked for npm 1.x.

**v0.2.2** (2011-01-05):

- Updated to CoffeeScript 1.0.0 and node 0.2.6/0.3.3.
Expand All @@ -179,4 +183,4 @@ See [/examples](http://github.com/mauricemach/coffeekup/tree/master/examples) fo

## Compatibility

Latest version tested with node 0.2.6/0.3.3 and CoffeeScript 1.0.0.
Latest version tested with node 0.4.7 and CoffeeScript 1.1.0.
4 changes: 2 additions & 2 deletions benchmark.coffee
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
coffeekup = require 'coffeekup'
coffeekup = require './lib/coffeekup'
jade = require 'jade'
ejs = require 'ejs'
eco = require 'eco'
Expand Down Expand Up @@ -183,7 +183,7 @@ benchmark = (title, code) ->
code()
puts "#{title}: #{new Date - start} ms"

exports.run = ->
@run = ->
benchmark 'CoffeeKup (precompiled)', -> coffeekup_compiled_template context: data
benchmark 'CoffeeKup (code)', -> coffeekup.render coffeekup_template, context: data
benchmark 'CoffeeKup (code, cache off)', -> coffeekup.render coffeekup_template, context: data, cache: off
Expand Down
7 changes: 7 additions & 0 deletions bin/coffeekup
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/usr/bin/env node

var path = require('path')
var fs = require('fs')
var lib = path.join(path.dirname(fs.realpathSync(__filename)), '../lib')

require(lib + '/cli').run()
3 changes: 1 addition & 2 deletions examples/express/app.coffee
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
app = require('express').createServer()
sys = require('sys')

app.register '.coffee', require('coffeekup')
app.set 'view engine', 'coffee'
Expand All @@ -16,4 +15,4 @@ app.get '/inline', (req, res) ->

app.listen 3000

sys.puts "Listening on 3000..."
console.log "Listening on 3000..."
2 changes: 1 addition & 1 deletion examples/meryl/app.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ meryl.run
templateExt: '.coffee'
templateFunc: coffeekup.adapters.meryl

puts 'Listening on 3000...'
console.log 'Listening on 3000...'
1 change: 0 additions & 1 deletion index.js

This file was deleted.

1 change: 1 addition & 0 deletions lib/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.js
12 changes: 5 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,18 +1,16 @@
{
"name": "coffeekup",
"description": "Markup as CoffeeScript.",
"version": "0.2.2",
"version": "0.2.3",
"author": "Maurice Machado <[email protected]>",
"contributors": [
{"name": "Maurice Machado", "email": "[email protected]"},
{"name": "Vladimir Dronnikov", "email": "[email protected]"}
],
"repository": {"type": "git", "url": "http://github.com/mauricemach/coffeekup.git"},
"dependencies": {"coffee-script": ">= 1.0.0"},
"dependencies": {"coffee-script": ">= 1.0.1"},
"keywords": ["template", "view", "coffeescript"],
"bin": {"coffeekup": "./bin/coffeekup.coffee"},
"main": "./index",
"directories": {"lib": "./lib"},
"main": "./lib/index",
"engines": {"node": ">= 0.2.6"}
"bin": "./bin/coffeekup",
"main": "./lib/coffeekup",
"engines": {"node": ">= 0.4.1"}
}
49 changes: 22 additions & 27 deletions bin/coffeekup.coffee → src/cli.coffee
100755 → 100644
Original file line number Diff line number Diff line change
@@ -1,17 +1,11 @@
#!/usr/bin/env coffee

coffeekup = require 'coffeekup'
coffeekup = require './coffeekup'
fs = require 'fs'
path = require 'path'
puts = console.log
{OptionParser} = require 'coffee-script/lib/optparse'

# On [email protected], argv looks like [filename],
# On [email protected], argv looks like ["node", "path/to/coffee", filename]
if process.argv[0] is 'node' and process.argv.length >= 2
argv = process.argv[2..]
else
argv = process.argv[0..]
argv = process.argv[2..]
options = null

render = (input_path, output_directory) ->
fs.readFile input_path, (err, contents) ->
Expand Down Expand Up @@ -47,24 +41,25 @@ switches = [
['-h', '--help', 'display this help message']
]

parser = new OptionParser switches, usage
options = parser.parse argv
args = options.arguments
delete options.arguments
@run = ->
parser = new OptionParser switches, usage
options = parser.parse argv
args = options.arguments
delete options.arguments

puts parser.help() if options.help or argv.length is 0
puts coffeekup.version if options.version
if options.utils
options.locals ?= {}
options.locals.render = (file) ->
contents = fs.readFileSync file
coffeekup.render String(contents), options
puts parser.help() if options.help or argv.length is 0
puts coffeekup.version if options.version
if options.utils
options.locals ?= {}
options.locals.render = (file) ->
contents = fs.readFileSync file
coffeekup.render String(contents), options

if args.length > 0
file = args[0]
if args.length > 0
file = args[0]

if options.watch
fs.watchFile file, {persistent: true, interval: 500}, (curr, prev) ->
return if curr.size is prev.size and curr.mtime.getTime() is prev.mtime.getTime()
render file, options.output
else render file, options.output
if options.watch
fs.watchFile file, {persistent: true, interval: 500}, (curr, prev) ->
return if curr.size is prev.size and curr.mtime.getTime() is prev.mtime.getTime()
render file, options.output
else render file, options.output
2 changes: 1 addition & 1 deletion lib/coffeekup.coffee → src/coffeekup.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ else
coffeekup = exports
coffee = require 'coffee-script'

coffeekup.version = '0.2.2'
coffeekup.version = '0.2.3'

skeleton = (ck_options = {}) ->
ck_options.context ?= {}
Expand Down
4 changes: 2 additions & 2 deletions test.coffee
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
exports.run = ->
@run = ->
test 'Literal text', ->
'Just text' is render ->
text 'Just text'
Expand Down Expand Up @@ -101,7 +101,7 @@ exports.run = ->

puts = console.log
print = require('sys').print
ck = require 'coffeekup'
ck = require './lib/coffeekup'
render = ck.render

[tests, passed, failed, errors] = [[], [], [], []]
Expand Down

0 comments on commit fec0a69

Please sign in to comment.