🚨 This repository is no longer maintained. 🚨
A compilation of CoffeeScript structure, components, and classes.
compendium/application.coffee
is the compendium file, which is what you would load in your application. It shows you the order in which you would include the individual setup files, as well as each individual Component. This obviously changes if you're not in a Rails environment with Sprockets.
compendium/spellbook.coffee
sets up the namespaces for the application. Be sure to change this file (and the namespaces) to the name of your application.
If you need any global variables set across the entire namespace, add them to Spellbook.Globals
in the compendium/spellbook.coffee
file.
A "component" is either a Function or Class.
A Function is either classified as a Helper or a Service.
A helper is a one-off utility function that performs a single action. Some examples:
Spellbook.Helpers.sanitize()
Spellbook.Helpers.slugify()
You can find a template file in components/templates/helper.coffee
.
A service is a function that can perform multiple actions, but a single service, and it is not a class. For example:
Spellbook.Services.autoSubmit()
Spellbook.Services.scrollTo()
You can find a template file in components/templates/service.coffee
.
A class is, as you'd expect, a CoffeeScript class.
You can find a template file in components/templates/class.coffee
.
compendium/domready.coffee
is for all of your JavaScript that is run when the document is ready. You will put your calls to the Components that are used across the application, not just on a single page.
This is a good place to put JavaScript that you aren't ready to organize and sort; or, simply as a testing environment.
Note: You can also use the Spellbook.Inbox
namespace to write in if you aren't sure where to place it temporarily.
There is a jQuery dependency in Spellbook, but you could easily swap out the underlying jQuery with vanilla JavaScript or another similar library.
Install Gulp:
npm install -g gulp
You have two options:
- Run
gulp coffee
to compile thecomponents/*.coffee
files. - Run
gulp
and have it watch and automatically compilecomponents/*.coffee
files.
gulp lint
- Create the
componentName.spec.coffee
file atspec/
- Run the
gulp
command in a separate tab to compile your CoffeeScript - Follow the Running Tests section below
Install/Run Bundler
gem install bundler
bundle
Run Jasmine Server
bundle exec rake jasmine
Now you can go to http://localhost:1234/
to see the tests.
Run Tests via Command Line
bundle exec rake jasmine:ci