├── 1 ├── 1.spec.coffee ├── 1.coffee └── 1.js ├── 2 ├── listings │ ├── house_roast.txt │ ├── barista.html │ ├── 2.3.spec.coffee │ ├── 2.2.clean.js │ ├── 2.3.coffee │ ├── 2.4.coffee │ ├── barista.coffee │ ├── 2.1.spec.coffee │ ├── 2.1.coffee │ ├── 2.2.coffee │ └── barista.js └── 2.coffee ├── 3 ├── listings │ ├── friends.txt │ ├── file2.txt │ ├── file1.txt │ ├── partygoers.txt │ ├── 3.2.clean.js │ ├── 3.3.coffee │ ├── 3.1.coffee │ ├── 3.2.coffee │ ├── 3.4.coffee │ ├── 3.6.coffee │ ├── 3.5.coffee │ └── 3.7.coffee └── 3.coffee ├── 4 ├── 4.coffee └── listings │ ├── 4.4.coffee │ ├── 4.6.coffee │ ├── 4.7.coffee │ ├── 4.5.spec │ ├── 4.3.coffee │ ├── 4.7.spec │ ├── 4.8.spec │ ├── 4.5.coffee │ ├── 4.1.coffee │ ├── 4.2.spec │ ├── 4.8.coffee │ ├── 4.9.spec │ ├── 4.9.coffee │ └── 4.2.coffee ├── 5 ├── 5.coffee ├── listings │ ├── news.coffee │ ├── images │ │ ├── camera.png │ │ ├── gallery1.png │ │ ├── gallery2.png │ │ ├── gallery3.png │ │ ├── product.png │ │ └── skateboard.png │ ├── 5.9.json │ ├── 5.1.coffee │ ├── 5.6.coffee │ ├── 5.11.coffee │ ├── 5.7.coffee │ ├── data.coffee │ ├── 5.8.coffee │ ├── 5.2.coffee │ ├── 5.5.coffee │ ├── 5.3.coffee │ └── 5.12.coffee └── 5.spec.coffee ├── 6 ├── 6.spec.coffee └── listings │ ├── stock.json │ ├── users.json │ ├── products.json │ ├── 6.1.coffee │ ├── 6.7.coffee │ ├── 6.3.coffee │ ├── db.spec.coffee │ ├── 6.6.coffee │ ├── db.coffee │ ├── 6.4.coffee │ └── 6.2.coffee ├── 7 └── listings │ ├── 7.6.coffee │ ├── 7.1.coffee │ ├── 7.2.coffee │ ├── 7.3.coffee │ ├── server.coffee │ └── 7.5.coffee ├── 8 ├── 8.spec.coffee ├── .#8.spec.coffee ├── listings │ ├── 8.1.spec.coffee │ ├── elephant.coffee │ ├── 8.6.coffee │ ├── 8.4.coffee │ ├── 8.5.coffee │ ├── 8.2.coffee │ ├── 8.3.coffee │ ├── 8.7.coffee │ ├── 8.1.litcoffee │ ├── 8.9.coffee │ └── 8.8.coffee └── the_wild_swans_at_coole.litcoffee ├── 9 ├── 9.spec.coffee └── listings │ ├── competitors-5.txt │ ├── phone_numbers.csv │ ├── 9.5.css │ ├── 9.5.html │ ├── competitors-16.txt │ ├── 9.2.coffee │ ├── with_events_tests.coffee │ ├── 9.1.coffee │ ├── 9.1.timed.dsd.coffee │ ├── 9.1.timed.coffee │ ├── 9.3.coffee │ └── 9.5.coffee ├── 10 ├── 10.coffee ├── listings │ ├── src │ │ ├── example.coffee │ │ └── sample.coffee │ ├── spec │ │ └── sample.spec.coffee │ ├── sample.spec.coffee │ ├── word_utils.coffee │ ├── 10.7.coffee │ ├── 10.6.coffee │ ├── fact.coffee │ ├── 10.8.coffee │ ├── 10.5.coffee │ ├── 10.9 │ ├── 10.4.coffee │ ├── 10.1.coffee │ ├── 10.2.coffee │ └── 10.3.coffee ├── raw.coffee ├── word_utils_v1.coffee ├── word_utils.coffee ├── dependencies.coffee ├── word_utils.spec.coffee ├── 10.dependencies.coffee ├── word_utils_v1.spec.coffee └── add_class.coffee ├── 11 ├── 11.spec.coffee └── listings │ ├── server.coffee │ ├── 11.1.html │ ├── api-server.coffee │ ├── package.json │ ├── socket-server.coffee │ ├── 11.3.coffee │ ├── 11.6.coffee │ ├── 11.2.coffee │ ├── 11.5.coffee │ ├── 11.4.coffee │ ├── 11.7.coffee │ └── handlers.coffee ├── 12 ├── 12.spec.coffee └── listings │ ├── blog.agtron.co │ ├── VERSION │ ├── .gitignore │ ├── app │ │ ├── models │ │ │ ├── index.coffee │ │ │ ├── model.coffee │ │ │ └── post.coffee │ │ ├── controllers │ │ │ ├── index.coffee │ │ │ ├── static.coffee │ │ │ ├── controller.coffee │ │ │ └── blog.coffee │ │ ├── views │ │ │ ├── index.coffee │ │ │ ├── list.coffee │ │ │ ├── js.coffee │ │ │ ├── view.coffee │ │ │ └── post.coffee │ │ ├── config.coffee │ │ ├── load.coffee │ │ └── server.coffee │ ├── content │ │ ├── post2.txt │ │ └── this-is-my-first-post.txt │ ├── artifact.tar │ ├── artifact.1.tar │ ├── compiled │ │ ├── app │ │ │ ├── models │ │ │ │ ├── index.js │ │ │ │ ├── model.js │ │ │ │ └── post.js │ │ │ ├── controllers │ │ │ │ ├── index.js │ │ │ │ ├── static.js │ │ │ │ └── controller.js │ │ │ ├── views │ │ │ │ ├── index.js │ │ │ │ ├── view.js │ │ │ │ ├── js.js │ │ │ │ ├── post.js │ │ │ │ └── list.js │ │ │ ├── config.js │ │ │ ├── server.js │ │ │ ├── client │ │ │ │ ├── main.js │ │ │ │ └── comments.js │ │ │ └── load.js │ │ └── spec │ │ │ ├── models │ │ │ └── post_spec.js │ │ │ ├── controllers │ │ │ └── blog_spec.js │ │ │ └── client │ │ │ └── comments_spec.js │ ├── package.json │ ├── spec │ │ ├── models │ │ │ └── post_spec.coffee │ │ ├── controllers │ │ │ └── blog_spec.coffee │ │ └── client │ │ │ └── comments_spec.coffee │ ├── lib │ │ └── modules.coffee │ ├── Makefile │ ├── client │ │ ├── main.coffee │ │ └── comments.coffee │ ├── make_client.coffee │ ├── Cakefile │ └── build_utilities.coffee │ ├── 12.1.coffee │ ├── 12.14.coffee │ └── 12.12.coffee ├── 13 ├── 13.spec.coffee └── listings │ ├── 13.6.coffee │ ├── 13.3.coffee │ ├── 13.2.coffee │ ├── 13.1.coffee │ ├── 13.4.coffee │ └── 13.5.coffee ├── .gitignore ├── exercises ├── 5.8.1.coffee ├── attendees ├── 5.8.1 │ ├── news.coffee │ ├── images │ │ ├── camera.png │ │ ├── gallery1.png │ │ ├── gallery2.png │ │ ├── gallery3.png │ │ ├── product.png │ │ └── skateboard.png │ ├── data.coffee │ └── client.coffee ├── 7.5.4.coffee ├── 4.2.3-2.coffee ├── 5.3.3.coffee ├── 2.5.3.coffee ├── 2.8.4.coffee ├── 2.3.3.coffee ├── 4.8.3.coffee ├── 4.7.2.coffee ├── 10.6.4.coffee ├── 3.3.4.coffee ├── 2.4.4.coffee ├── 4.6.3.coffee ├── 2.6.5.coffee ├── 3.1.5.coffee ├── 3.4.4.coffee ├── 4.2.3-1.coffee ├── 4.2.3.coffee ├── 10.4.4.coffee └── 7.2.5.coffee ├── Cakefile ├── README.md └── package.json /10/10.coffee: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /4/4.coffee: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /5/5.coffee: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /1/1.spec.coffee: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /11/11.spec.coffee: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /12/12.spec.coffee: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /13/13.spec.coffee: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /6/6.spec.coffee: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /8/8.spec.coffee: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /9/9.spec.coffee: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /6/listings/stock.json: -------------------------------------------------------------------------------- 1 | {"stock":35} -------------------------------------------------------------------------------- /6/listings/users.json: -------------------------------------------------------------------------------- 1 | {"xs":123} -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | \#*# 3 | *~ -------------------------------------------------------------------------------- /12/listings/blog.agtron.co/VERSION: -------------------------------------------------------------------------------- 1 | 1 -------------------------------------------------------------------------------- /3/listings/friends.txt: -------------------------------------------------------------------------------- 1 | 2,1,2,2,1,2 2 | -------------------------------------------------------------------------------- /2/listings/house_roast.txt: -------------------------------------------------------------------------------- 1 | Yirgacheffe 2 | -------------------------------------------------------------------------------- /8/.#8.spec.coffee: -------------------------------------------------------------------------------- 1 | plee@wraithe.local.36571 -------------------------------------------------------------------------------- /3/3.coffee: -------------------------------------------------------------------------------- 1 | 2 | # Nothing here. See the spec. -------------------------------------------------------------------------------- /3/listings/file2.txt: -------------------------------------------------------------------------------- 1 | file 2 contents here 2 | -------------------------------------------------------------------------------- /12/listings/blog.agtron.co/.gitignore: -------------------------------------------------------------------------------- 1 | compiled 2 | -------------------------------------------------------------------------------- /3/listings/file1.txt: -------------------------------------------------------------------------------- 1 | file 1 contents are here 2 | -------------------------------------------------------------------------------- /exercises/5.8.1.coffee: -------------------------------------------------------------------------------- 1 | 2 | # See folder 5.8.1 for full solution -------------------------------------------------------------------------------- /exercises/attendees: -------------------------------------------------------------------------------- 1 | Bob,Sally,Jenny,Kandice,Rodney,Penelope,Andrew -------------------------------------------------------------------------------- /10/listings/src/example.coffee: -------------------------------------------------------------------------------- 1 | 2 | exports.example = -> 3 | '123' 4 | -------------------------------------------------------------------------------- /10/listings/src/sample.coffee: -------------------------------------------------------------------------------- 1 | 2 | exports.example = -> 3 | '123' 4 | -------------------------------------------------------------------------------- /2/2.coffee: -------------------------------------------------------------------------------- 1 | 2 | # Nothing here for this chapter. See 2.spec.coffee. 3 | -------------------------------------------------------------------------------- /3/listings/partygoers.txt: -------------------------------------------------------------------------------- 1 | alfred,thomas,peter,sally,james,alan,jane,bill 2 | -------------------------------------------------------------------------------- /10/listings/spec/sample.spec.coffee: -------------------------------------------------------------------------------- 1 | fact 'example', -> 2 | assert.equal 'x', 'x' -------------------------------------------------------------------------------- /12/listings/blog.agtron.co/app/models/index.coffee: -------------------------------------------------------------------------------- 1 | 2 | exports.Post = require('./post').Post 3 | -------------------------------------------------------------------------------- /5/listings/news.coffee: -------------------------------------------------------------------------------- 1 | news = 2 | breaking: 'Free shipping today!' 3 | 4 | exports.all = news -------------------------------------------------------------------------------- /6/listings/products.json: -------------------------------------------------------------------------------- 1 | {"x1":{"costPrice":100,"overhead":20},"x2":{"costPrice":40,"overhead":10}} -------------------------------------------------------------------------------- /12/listings/blog.agtron.co/app/controllers/index.coffee: -------------------------------------------------------------------------------- 1 | 2 | exports.Blog = require('./blog').Blog 3 | -------------------------------------------------------------------------------- /exercises/5.8.1/news.coffee: -------------------------------------------------------------------------------- 1 | news = 2 | breaking: 'Free shipping today!' 3 | 4 | exports.all = news -------------------------------------------------------------------------------- /13/listings/13.6.coffee: -------------------------------------------------------------------------------- 1 | 2 | class Formulaic 3 | 4 | constructor: (@root, @selector, @http, @url) -> 5 | -------------------------------------------------------------------------------- /12/listings/blog.agtron.co/content/post2.txt: -------------------------------------------------------------------------------- 1 | Pretty cool 2 | 3 | This was rather simpler than I anticipated. 4 | -------------------------------------------------------------------------------- /12/listings/blog.agtron.co/content/this-is-my-first-post.txt: -------------------------------------------------------------------------------- 1 | The title goes on the first line. 2 | 3 | Hola! 4 | -------------------------------------------------------------------------------- /8/listings/8.1.spec.coffee: -------------------------------------------------------------------------------- 1 | fs = require 'fs' 2 | assert = require 'assert' 3 | 4 | src = fs.readFileSync './8.1.litcoffee' -------------------------------------------------------------------------------- /5/listings/images/camera.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/boundvariable/coffeescript-in-action/HEAD/5/listings/images/camera.png -------------------------------------------------------------------------------- /8/listings/elephant.coffee: -------------------------------------------------------------------------------- 1 | 2 | class Elephant 3 | walk: -> 4 | 'Walking now' 5 | forget: -> 6 | 'I never forget' -------------------------------------------------------------------------------- /5/listings/images/gallery1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/boundvariable/coffeescript-in-action/HEAD/5/listings/images/gallery1.png -------------------------------------------------------------------------------- /5/listings/images/gallery2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/boundvariable/coffeescript-in-action/HEAD/5/listings/images/gallery2.png -------------------------------------------------------------------------------- /5/listings/images/gallery3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/boundvariable/coffeescript-in-action/HEAD/5/listings/images/gallery3.png -------------------------------------------------------------------------------- /5/listings/images/product.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/boundvariable/coffeescript-in-action/HEAD/5/listings/images/product.png -------------------------------------------------------------------------------- /1/1.coffee: -------------------------------------------------------------------------------- 1 | 2 | square = (x) -> 3 | x * x 4 | 5 | ### 6 | var square = function (x) { 7 | return x * x; 8 | }; 9 | ### 10 | -------------------------------------------------------------------------------- /5/listings/images/skateboard.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/boundvariable/coffeescript-in-action/HEAD/5/listings/images/skateboard.png -------------------------------------------------------------------------------- /exercises/5.8.1/images/camera.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/boundvariable/coffeescript-in-action/HEAD/exercises/5.8.1/images/camera.png -------------------------------------------------------------------------------- /exercises/5.8.1/images/gallery1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/boundvariable/coffeescript-in-action/HEAD/exercises/5.8.1/images/gallery1.png -------------------------------------------------------------------------------- /exercises/5.8.1/images/gallery2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/boundvariable/coffeescript-in-action/HEAD/exercises/5.8.1/images/gallery2.png -------------------------------------------------------------------------------- /exercises/5.8.1/images/gallery3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/boundvariable/coffeescript-in-action/HEAD/exercises/5.8.1/images/gallery3.png -------------------------------------------------------------------------------- /exercises/5.8.1/images/product.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/boundvariable/coffeescript-in-action/HEAD/exercises/5.8.1/images/product.png -------------------------------------------------------------------------------- /exercises/5.8.1/images/skateboard.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/boundvariable/coffeescript-in-action/HEAD/exercises/5.8.1/images/skateboard.png -------------------------------------------------------------------------------- /12/listings/blog.agtron.co/artifact.tar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/boundvariable/coffeescript-in-action/HEAD/12/listings/blog.agtron.co/artifact.tar -------------------------------------------------------------------------------- /10/listings/sample.spec.coffee: -------------------------------------------------------------------------------- 1 | {example} = require './src/example' 2 | 3 | fact 'example', -> 4 | assert.equal 'x', 'x' 5 | assert.equal example(), '123' -------------------------------------------------------------------------------- /12/listings/blog.agtron.co/artifact.1.tar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/boundvariable/coffeescript-in-action/HEAD/12/listings/blog.agtron.co/artifact.1.tar -------------------------------------------------------------------------------- /9/listings/competitors-5.txt: -------------------------------------------------------------------------------- 1 | 0212: Turnbill, Geralyn 2 | 0055: Spielvogel, Cierra 3 | 0072: Renyer, Connie 4 | 0011: Engholm, Ciara 5 | 0088: Gitting, Estrella 6 | -------------------------------------------------------------------------------- /12/listings/blog.agtron.co/app/models/model.coffee: -------------------------------------------------------------------------------- 1 | 2 | class Model 3 | dirify: (s) -> s.toLowerCase().replace /[^a-zA-Z0-9-]/gi, '-' 4 | 5 | exports.Model = Model 6 | -------------------------------------------------------------------------------- /12/listings/blog.agtron.co/compiled/app/models/index.js: -------------------------------------------------------------------------------- 1 | // Generated by CoffeeScript 1.6.3 2 | (function() { 3 | exports.Post = require('./post').Post; 4 | 5 | }).call(this); 6 | -------------------------------------------------------------------------------- /4/listings/4.4.coffee: -------------------------------------------------------------------------------- 1 | 2 | properties = (prop for prop of movie) 3 | 4 | ### JavaScript 5 | var properties = []; 6 | for (var prop in movie) { 7 | properties.push(p); 8 | } 9 | ### -------------------------------------------------------------------------------- /11/listings/server.coffee: -------------------------------------------------------------------------------- 1 | 2 | {makeApiServer} = require './api-server' 3 | {attachSocketServer} = require './socket-server' 4 | 5 | attachSocketServer makeApiServer() 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /12/listings/blog.agtron.co/compiled/app/controllers/index.js: -------------------------------------------------------------------------------- 1 | // Generated by CoffeeScript 1.6.3 2 | (function() { 3 | exports.Blog = require('./blog').Blog; 4 | 5 | }).call(this); 6 | -------------------------------------------------------------------------------- /9/listings/phone_numbers.csv: -------------------------------------------------------------------------------- 1 | hannibal,555-5551,friend 2 | darth,555-5552,colleague 3 | hal_9000,disconnected,friend 4 | freddy,555-5554,friend 5 | T-800,555-5555,colleague 6 | dolly,555-3322,associate 7 | -------------------------------------------------------------------------------- /3/listings/3.2.clean.js: -------------------------------------------------------------------------------- 1 | var countWords = function (s, del) { 2 | var words; 3 | if (s) { 4 | words = s.split(del); 5 | return words.length; 6 | } else { 7 | return 0; 8 | } 9 | }; 10 | -------------------------------------------------------------------------------- /1/1.js: -------------------------------------------------------------------------------- 1 | // Generated by CoffeeScript 1.6.3 2 | var square; 3 | 4 | square = function(x) { 5 | return x * x; 6 | }; 7 | 8 | /* 9 | var square = function (x) { 10 | return x * x; 11 | }; 12 | */ 13 | 14 | -------------------------------------------------------------------------------- /9/listings/9.5.css: -------------------------------------------------------------------------------- 1 | html, body { 2 | padding: 0; 3 | margin: 0; 4 | } 5 | 6 | #pong { 7 | width: 100%; 8 | height: 100%; 9 | position: absolute; 10 | top: 0; 11 | left: 0; 12 | } -------------------------------------------------------------------------------- /exercises/7.5.4.coffee: -------------------------------------------------------------------------------- 1 | people = [ 'bill', 'ted' ] 2 | greetings = {} 3 | 4 | for person in people 5 | greetings[person] = -> 6 | "My name is #{person}" 7 | 8 | greetings.bill() 9 | # My name is ted 10 | -------------------------------------------------------------------------------- /10/raw.coffee: -------------------------------------------------------------------------------- 1 | 2 | do add_word_should_add_one_word = -> 3 | input = "ultra mega" 4 | expected_output = "ultra mega ok" 5 | actual_output = add_word input, "ok" 6 | 7 | assert.equal expected_output, actual_output 8 | 9 | -------------------------------------------------------------------------------- /12/listings/blog.agtron.co/app/views/index.coffee: -------------------------------------------------------------------------------- 1 | 2 | views = 3 | post: require('./post').Post 4 | list: require('./list').List 5 | js: require('./js').Js 6 | 7 | exports.views = (name, data) -> 8 | new views[name](data) 9 | -------------------------------------------------------------------------------- /5/listings/5.9.json: -------------------------------------------------------------------------------- 1 | { 2 | "Fuji-X100": { 3 | "description": "a camera", 4 | "stock": 5 5 | }, 6 | "Perall Powalta": { 7 | "description": "a skateboard", 8 | "stock":6, 9 | "special": "two for one" 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /exercises/4.2.3-2.coffee: -------------------------------------------------------------------------------- 1 | css = (element, styles) -> 2 | element.style ?= {} 3 | for key, value of styles 4 | element.style[key] = value 5 | 6 | class Element 7 | div = new Element 8 | css div, width: 10 9 | 10 | div.style.width 11 | # 10 -------------------------------------------------------------------------------- /3/listings/3.3.coffee: -------------------------------------------------------------------------------- 1 | fs = require 'fs' 2 | 3 | file = process.argv[2] 4 | fs.readFile file, 'utf-8', (error, contents) -> #A 5 | if error 6 | console.log error #B 7 | else 8 | console.log contents #C 9 | -------------------------------------------------------------------------------- /exercises/5.3.3.coffee: -------------------------------------------------------------------------------- 1 | class Product 2 | # any implementation of Product 3 | 4 | class Camera extends Product 5 | cameras = [] 6 | @alphabetical = -> 7 | cameras.sort (a, b) -> a.name > b.name 8 | constructor: -> 9 | all.push @ 10 | super 11 | -------------------------------------------------------------------------------- /10/word_utils_v1.coffee: -------------------------------------------------------------------------------- 1 | removeWord = (text, word) -> 2 | replaced = text.replace word, '' #A 3 | replaced.replace(/^\s\s*/, '').replace(/\s\s*$/, '') #B 4 | 5 | addWord = (text, word) -> 6 | "#{text} #{word}" 7 | 8 | exports.addWord = addWord 9 | exports.removeWord = removeWord 10 | -------------------------------------------------------------------------------- /2/listings/barista.html: -------------------------------------------------------------------------------- 1 | 2 |