GithubHelp home page GithubHelp logo

barista's Introduction

Barista

Barista is a set of tools to make using CoffeeScript in Rails 3, Rails 2 and Rack applications easier. You can think of it as similar to Compass, but for CoffeeScript instead of Sass.

As an added bonus, Barista also gives:

  • Automatic support for a :coffeescript filter in Haml (when Haml is loaded before Barista) — automatically converting inline CoffeeScript to JavaScript for you.
  • Where possible, support for coffeescript_include_tag and coffeescript_tag.
  • When possible, instead of pre-compiling in development and test modes, Barista will embed CoffeeScript in the page for you.
  • Support for Heroku via therubyracer-heroku and either pre-compiled JS or, optionally, a lightweight Rack app that generates on request.

Getting Started

Out of the box, Barista has semi-automatic support for Rails 3.0, Rails 2 (currently untested) and Sinatra. With a minimal amount of effort, you can also make it work in any Rack-based framework.

Rails 3

Adding Barista to your Rails 3 application should as simple as adding two gems to your Gemfile, and running two commands. To get started, open up your Gemfile and add the following:

gem "json" # Only needed if on Ruby 1.8 / a platform that ships without JSON
gem "barista"

Next, you'll need to run the the following:

bundle install
rails g barista:install

This will install the gem into your application and will generate a file in config/initializers/barista_config.rb that contains a set of options to configure Barista options.

Place your CoffeeScripts in app/coffeescripts and Barista will automatically compile them on change into public/javascripts.

Rails 2

Much like on Rails 3, Barista supports deep integration into Rails 2. The only thing missing (that is currently supported in the Rails 3 version) is built in support for generating a config file. If you're using bundler in your application, all you need to do is add:

gem "json" # Only needed if on Ruby 1.8 / a platform that ships without JSON
gem "barista"

To your Gemfile. If you're not using bundler, doing gem install json barista and requiring barista both in your application should be enough to get you started.

If you wish to change the barista configuration, take a look at the Rails 3 initializer and modify it to suite your application as needed.

If you wish to use barista tasks with rails 2 project, add

load "barista/tasks/barista.rake"

To your Rakefile.

Sinatra

Adding Barista to a Sinatra application is a relatively straight forward affair. Like in Rails 2 and Rails 3, you first need to add and require the barista gem and (optionally, the json gem). Unlike Rails 2 and 3 (which set it up automatically), you must also register the extension in your application. So, in the scope of your app (either the top level scope or the Sinatra::Application subclass you're using), you then need to simple add:

register Barista::Integration::Sinatra

Which will automatically set up the Barista environment and other similar details (e.g. the automatic compilation filter). Since you don't have initializers like you do in Rails, you can then simply run your Barista.configure call and block anywhere before your application starts serving requests.

Other Rack-based Frameworks

Lastly, even though it is built out of the box to support Rails and Sinatra, Barista can also be used with any Rack-based framework. For proper integration, several things must be done. Namely, wherever you declare your middleware (e.g. in a config.ru file), you should register the two pieces of middleware barista uses. Barista::Filter should only be registered when Barista performs compilation (e.g. in development mode) and Barista::Server::Proxy should be registered if you want it to support automatic serving of a coffeescript.js file and / or on the fly (versus pre-request compilation) of CoffeeScripts.

For example, your config.ru may look like:

# Setup goes here...
use Barista::Filter if Barista.add_filter?
use Barista::Server::Proxy
run MyRackApplication

Next, you need to configure barista anywhere before your the above code is run. e.g by adding the following immediatly preceeding it:

# Barista (for CoffeeScript Support)
Barista.app_root = root
Barista.root     = File.join(root, 'coffeescripts')
Barista.setup_defaults
barista_config = root + '/barista_config.rb'
require barista_config if File.exist?(barista_config)

Hence, if you'e using, for example, serve users should have a config.ru that looks similar to this example.

A Quick Note on the JSON Gem

Barista indirectly requires the json gem via the coffee-script gem, but it isn't listed as a dependency for very good reasons. If you encounter errors relating to require 'json', Then you'll need to add either gem 'json' or gem 'json_pure' to your Gemfile.

If you're already running Ruby 1.9, this will be unnecessary as JSON is shipped as part of the standard library.

General Information

Barista transparently compiles CoffeeScript to JavaScript. When a .coffee file is changed and the page is refreshed, Barista first regenerates all .js files whose .coffee sources have been recently changed. This way, you can refresh immediately after saving the .coffee file and not worry about an old .js file being sent to the browser (as often happens when using coffee --watch).

Barista supports using therubyracer when installed or, by default, using either the node executable or jsc (on OS X) to compile your scripts. There is no need for you to install the coffee-script executable in Node as having Node itself, or any of the alternatives available, is enough.

When you want to deploy, you can simple run rake barista:brew to force the compilation of all JavaScripts for the current application.

In Practice

Barista not only supports compiling all JavaScripts on demand (via rake barista:brew as above, or Barista.compile_all!) but it also ships with a simple Rack server app that will compile on demand for platforms such as Heroku, meaning you don't need write access (although it is helpful).

If you're using Jammit, the precompilation phase (e.g. rake barista:brew before running Jammit) will make it possible for your application to automatically bundle not only normal JavaScripts but also your CoffeeScripts.

To add Barista to your project, simply add gem 'barista', '~> 1.0' to your Gemfile and run bundle install.

Please note that for Jammit compatibility, in test and development mode (by default) it will automatically compile all CoffeeScripts that have changed before rendering the page.

Barista works out of the box with Rails 3 (and theoretically, Rails 2) — with support for Rack if you're willing to set it up manually. More docs on how to set it up for other platforms will be posted in the near future.

Sinatra

To use Barista with Sinatra, you'll need to first require the Barista gem in your application and then add the following to your application scope (e.g. if you're using a custom class, there):

register Barista::Integration::Sinatra

This will automatically setup the filter as needed, setup a server proxy for the coffee-script.js file and setup the defaults based on your applications environment

Configuration

Please note that Barista lets you configure several options. To do this, it's as simple as setting up an initializer with:

rails generate barista:install

Then editing config/initializers/barista_config.rb. The options available are:

Boolean Options

All of these come in the form of #option? (to check its status), #option=(value) (to set it) and #option! (to set the value to true):

  • verbose – Output debugging error messages. (Defaults to true in test / dev)
  • bare – Don't wrap the compiled JS in a Closure.
  • add_filter – Automatically add an around filter for processing changes. (Defaults to true in test / dev)
  • add_preamble – Add a time + path preamble to compiled JS. (Defaults to true in test / dev)
  • exception_on_error – Raise an exception on compilation errors (defaults to true)
  • embedded_interpreter – Embeds coffeescript + link to coffee file instead of compiling for include tags and haml filters. (Defaults to true in test / dev)
  • auto_compile – Automatically compile CoffeeScript to JS when CoffeeScript is newer than the generated JS file. After you turn it off, your server will use the generated JS file directly and won't depend on any CoffeeScript compilers. (Defaults is true)

Path options

  • root – The folder path to read CoffeeScripts from. (Defaults to app/coffeescripts.)
  • output_root – The folder to write compiled JS files to. (Defaults to public/javascripts.)
  • change_output_prefix! – Method to change the output prefix for a framework.
  • change_output_root! - Method to change the output root for a given framework.
  • verbose – Whether or not Barista will add a preamble to files.
  • js_path – Path to the pure-JavaScript compiler.
  • env – The application environment. (Defaults to Rails.env.)
  • app_root – The application's root path.
  • bin_path – The path to the node executable if non-standard and not using therubyracer.
  • All of the hook methods mentioned below.

Custom Preamble

You can generate a custom preamble using a code block. For example, you can replace the location of the original .coffee file by a relative one to Rails.root.

Barista.add_preamble do |location|
    "/* : DO NOT MODIFY - compiled from #{Pathname.new(location).relative_path_from(Rails.root).to_s}\n\n"
end

Frameworks

One of the other main features Barista adds (over other tools) is frameworks similar to Compass. The idea being, you add CoffeeScripts at runtime from gems etc. To do this, in your gem just have a coffeescript directory and then in your gem add the following code:

Barista::Framework.register 'name', 'full-path-to-directory' if defined?(Barista::Framework)

For an example of this in practice, check out bhm-google-maps or, the currently-in-development, shuriken. The biggest advantage of this is you can then manage JS dependencies using existing tools like Bundler.

In your Barista.configure block, you can also configure on a per-application basis the output directory for individual frameworks (e.g. put shuriken into vendor/shuriken, bhm-google-maps into vendor/bhm-google-maps):

Barista.configure do |c|
  c.change_output_prefix! 'shuriken',        'vendor/shuriken'
  c.change_output_prefix! 'bhm-google-maps', 'vendor/bhm-google-maps'
end

Alternatively, to prefix all, you can use Barista.each_framework (if you pass true, it includes the 'default' framework which is your application root).

Barista.configure do |c|
  c.each_framework do |framework|
    c.change_output_prefix! framework.name, "vendor/#{framework.name}"
  end
end

Hooks

Barista lets you hook into the compilation at several stages, namely:

  • before compilation
  • after compilation
  • after compilation fails
  • after compilation complete

To hook into these hooks, you can do the following:

  • Barista.before_compilation { |path| puts "Barista: Compiling #{path}" }
  • Barista.on_compilation { |path| puts "Barista: Successfully compiled #{path}" }
  • Barista.on_compilation_with_warning { |path, output| puts "Barista: Compilation of #{path} had a warning:\n#{output}" }
  • Barista.on_compilation_error { |path, output| puts "Barista: Compilation of #{path} failed with:\n#{output}" }
  • Barista.on_compilation_complete { puts "Barista: Successfully compiled all files" }

These allow you to do things such as notify on compilation, automatically perform compression post compilation and a variety of other cool things.

An excellent example of these hooks in use is barista_growl, by Trevor Burnham — a gem perfect for development purposes that automatically shows Growl messages on compilation.

Deployment

Add require 'barista/capistrano' to your deploy.rb.

Contributors / Credits

The following people have all contributed to Barista:

Barista was originally heavily inspired by Bistro Car, but has taken a few fundamentally different approach in a few areas.

Barista builds upon the awesome coffee-script gem.

It's all possible thanks to CoffeeScript by Jeremy Ashkenas.

If I've missed you're name and you've contributed to Barista, please let me know and I'll add you to the list (or fork this document and send a pull request).

Note on Patches/Pull Requests

  1. Fork the project.
  2. Make your feature addition or bug fix.
  3. Add tests for it. This is important so I don't break it in a future version unintentionally.
  4. Commit, do not mess with rakefile, version, or history. (if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)
  5. Send me a pull request. Bonus points for topic branches.

Copyright

Copyright (c) 2010 Darcy Laycock. See LICENSE for details.

barista's People

Contributors

allenwei avatar benatkin avatar benhoskings avatar dblock avatar einarmagnus avatar jodell avatar kimjoar avatar linjunpop avatar mnoble avatar pwim avatar sutto avatar topfunky avatar xaviershay avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

barista's Issues

Integrate Haml Filter support?

It'd be pretty cool if all I had to do was install barista to get full on coffeescript support for my entire codebase, don't really like having to install an old plugin for that. Any chance you'd port it over to your gem?

therubyracer not being picked up in version 1.1

When I updated to version 1.1 all of a sudden every time I run rake barista:brew I always get the following error message:
CoffeeScript doesn't appear to be installed on this system and you're not using an embedded compiler

However I have therubyracer installed and it works on version 1.0.
running with bundle exec rake barista:brew does not fix the problem

Set output_root for frameworks

Is there a mean to set output_root for a framework? This would be very useful when developing rails 3.1 engines, especially the ones with an isolated namespace. I noticed the option in the code but there doesn't seem to be a way to set it without patching barista.

Would it be possible to add this as an option to Barista::Framework.register or add an attribute writer to the Framework class?

haml filter load issue

I'm not quite sure why my app happens to behave this way (presumably others' don't, since no one else has mentioned this problem), but I get an "uninitialized constant Haml::Filters" NameError when trying to start my app after installing Barista. The Barista code this is coming from is in lib/barista/haml_filter.rb:
def self.setup
if defined?(Haml)
CoffeeScript.module_eval { include Haml::Filters::Base }
end
end

At this point in my app's load process, Haml is indeed defined, but Haml::Filters is not. I can fix the problem by adding "require haml/filters" before the module_eval, but not being particularly familiar with the conventions of using require in gems, I don't know if this is a good idea. Perhaps require 'haml/filters' unless defined?(Haml::Filters)?

I'm using Haml 3.0.25 (currently the most recent) and Rails 3.0.3 (also currently the most recent).

Way of using compiled js

Hello i was trying to use :javascript in haml but does not seems to compile coffeescript in rails 3.0.3.
Is there any other way instead of requiring coffee-script.js and using the :coffeescript filter in haml?

allow subdirs in input root

Hello,

I would like Barista to compile app/coffeescripts/foo/bar/baz.coffee into public/javascripts/foo/bar/baz.js.

Thanks for your consideration.

Feature: joining framework files into a single output file.

Hey.

I was looking for a feature that would join all files in a registered framework into a single javascript file, although with barista this was simply not possible. That's why I'm here, requesting this feature.

Just in case you don't get what I mean, I've provided these examples.

Say I register a framework like this:

Barista::Framework.register "uploader", {
      join: true, # or :bundle.. your choice.
      root: "lib/scripts/uploader", # => app/lib/scripts/uploader/*.coffee
    output: "vendor/uploader" # => /javascripts/vendor/uploader.js
}

Then I want it to compile all .coffee files inside app/lib/scripts/uploader/ (:root) and all it's subdirectories, concatenate it and save it as javascripts/vendor/uploader.js.

Thanks in advance.

Random Node not found messages

I am getting "which: no nodejs in" and "which: no node in" messages all over the place with barista installed. Thought it does manage to work because Node.js is installed. Any idea how to suppress these?

Configuration in for framework integration doen't work

When Barista::Integration setup, configuration actually haven't loaded!! So It will all use default value, user customized setting doesn't work.
So far we only have one configuration add_filter used in Barista::Integration.

I don't have good fix except put Barista::Integration.setup at bottom of barista rails initializer.

Installation and js loading

Barista looks awesome.

I installed it and converted a html :javascript to :coffeescript.

Without any other change (Rails 3.0.4 in development, no fiddling with default javascripts, empty barista config) it doesn't work because the client side coffeescript.js is not loaded (and the source html has the script as "text/coffeescript")

I changed the config with c.embedded_interpreter = false and that bypasses the issue.

  1. Wouldn't it be best to add "coffeescript" to the default javascript sources?
  2. In the meantime, is there a standard way of embedding "coffeescript.js"?
  3. I'd recommend adding the embedded_interpreter option (commented) in the generated config.

Thanks!

Multiple output roots (e.g spec/javascript) would be awesome

I'd like to TDD my coffee script so it would be awesome if maybe frameworks could specify their own output directories so I can have one for jasmine that maps spec/coffeescripts to spec/javascripts. I'll take a look a forking and adding this and send a pull request if I get anywhere.

Fails to compile files with non-ASCII characters under Ruby 1.9

Running barista:brew under Ruby 1.9.2 failed with the following backtrace

** Invoke barista:brew (first_time)
** Invoke environment (first_time)
** Execute environment
** Execute barista:brew
rake aborted!
"\xC3" from ASCII-8BIT to UTF-8
.gems/gems/barista-1.0.0/lib/barista/compiler.rb:123:in `write'
.gems/gems/barista-1.0.0/lib/barista/compiler.rb:123:in `block in save'
.gems/gems/barista-1.0.0/lib/barista/compiler.rb:123:in `open'
.gems/gems/barista-1.0.0/lib/barista/compiler.rb:123:in `save'
.gems/gems/barista-1.0.0/lib/barista/compiler.rb:55:in `autocompile_file'
.gems/gems/barista-1.0.0/lib/barista.rb:178:in `block in compile_all!'
.gems/gems/barista-1.0.0/lib/barista.rb:177:in `each'
.gems/gems/barista-1.0.0/lib/barista.rb:177:in `compile_all!'
.gems/gems/barista-1.0.0/lib/barista/tasks/barista.rake:9:in `block (2 levels) in <top (required)>'

After removing some spanish accented characters from my CoffeeScript files, it worked fine, so I guess it might have something to do with Ruby 1.9 and encoding (works fine under Ruby 1.8).

I don't know if it's relevant, but I'm using therubyracer.

Not sure if it's a bug or I just have to do something I haven't found in the documentation.

Thanks.

Forcing Sinatra middleware

Currently using Barista in a Sinatra app, purely as a rake task

However as soon as I add it to my Gemfile, Barista instantly adds its middleware onto Sinatra::Base. My initializer has to then remove the middleware entries.

According to Sinatra Extension docs, the best practice for this sort of thing is to require the user to opt into middleware. So I would register my middleware manually (or all at once in an initializer). I believe auto wiring up middleware on load is a problem.

I'd highly recommend adding a def self.registered call to the base module of Barista so I can just do a register Barista anywhere in sinatra and have it wire up the middleware then.

RSpec NameError: uninitialized constant CoffeeScript::Engines

Hi, Darcy

I have very simple rails app:
# Gemfile
source 'http://rubygems.org'
gem 'rails', '3.0.5'
gem 'sqlite3'
gem 'therubyracer', :require => false
gem 'barista'
gem 'rspec'
gem 'rspec-rails'
gem 'webrat'
gem 'capybara'

Set up for rspec-rails and barista:
$ rails generate rspec:install
$ rails generate barista:install

Generate User scaffold and migrate db:
$ rails generate scaffold user name:string
$ rake db:migrate

I have app/coffeescripts/application.coffee with just one line:
# app/coffeescripts/application.coffee
echo "hello"

When I'm trying to run
$ rspec spec/requests/users_spec.rb
I get NameError: uninitialized constant CoffeeScript::Engines
F

Failures:

  1) Users GET /users works! (now write some real specs)
     Failure/Error: get users_path
     NameError:
       uninitialized constant CoffeeScript::Engines
     # <internal:prelude>:10:in `synchronize'
     # ./spec/requests/users_spec.rb:7:in `block (3 levels) in <top (required)>'

Finished in 0.31144 seconds
1 example, 1 failure

Could you please suggest what to do to make rpsec work with barista.

Appreciate your help.

The coffeescript compiler at 'coffee' is currently unavailable

Upgraded to 0.6.0, get the following error in my server log, and no compilation:
The coffeescript compiler at 'coffee' is currently unavailable

It is available:
$ which coffee
/usr/local/bin/coffee

the preamble branch on my fork works for me. Won't get a chance to investigate until next week.

Copy .js files "as is" to the public/javascript dir

Hi, would be nice to have an option of just copying all files that have a .js extension to the destination folder. For instance, I may have "app/scripts/lib" dir where I hold js libs such as jQuery. The reason I don't want to put them into the public/javascripts dir is because I believe the whole dir should be added to gitignore. Basically, the behavior I'm talking about is what SASS and LESS used to do for .css files.

Either I couldn't find how or it's currently not possible.

ReferenceError: console is not defined

I get an Barista::CompilationError on my app/coffeescripts/application.coffee file (which is not the culprit because I ran coffee -c on it successfully) with the following trace:

[Barista] Compiling all scripts for barista
[Barista] Compiling all coffeescripts
[Barista] Compiling application.coffee from framework 'default'
[Barista] There was an error compiling coffeescript from app/coffeescripts/application.coffee:

/tmp/coffee.js20110215-13685-14wc4ac:9
var CoffeeScript = this.CoffeeScript, print = console.log;
                 ^
ReferenceError: console is not defined
    at Object.<anonymous> (/tmp/coffee.js20110215-13685-14wc4ac:9:18)
    at Module._compile (module:384:23)
    at Module._loadScriptSync (module:393:16)
    at Module.loadSync (module:296:10)
    at Object.runMain (module:459:22)
    at node.js:196:8

In my app/views/layouts/application.html.haml file, I have:

= coffeescript_include_tag 'application'

What am I missing? Thanks for your consideration.

Option to disable comment being added to compiled output

I'd really prefer not seeing this sort of comment added to the compiled output:

/* DO NOT MODIFY. This file was compiled Tue, 26 Apr 2011 18:25:38 GMT from
 * /possibly/sensitive/path/that/view/source/exposes/app/coffeescripts/hello.coffee
 */

Adding a config option to disable this would be nice. I'll dig a bit deeper to see if it's supported but undocumented and if not, possibly work on a patch to enable the disabling of the comment.

rake assets:precompile not working

When I install Barista and afterwards try to run rake assets:precompile, clean, etc I get the following error...

rake aborted!
uninitialized constant Barista

Tasks: TOP => environment
(See full trace by running task with --trace)
rake aborted!
Command failed with status (1): [/Users/erichrusch/.rvm/rubies/ruby-1.9.3-p...]

Tasks: TOP => assets:clean
(See full trace by running task with --trace)

Any ideas?

Interpolation with CoffeeScript HAML filter

I have a view file written in haml which uses the coffeescript filter and having problem with string interpolation. Since haml uses the #{} syntax for inline ruby and coffeescript uses the same syntax for string interpolation there is a conflict. What happens is that haml will always see the #{} syntax as inline ruby making it basically impossible to use string interpolation in a coffeescript filter. Any idea if this is possible to solve?

Filter "coffeescript" is not defined.

Hello

I have a following problem. I'm using HAML views in my rails app and i wanted to use some coffeescript in them. I added Barista to my gemfile:

gem 'haml'
gem 'therubyracer'
gem 'barista'

and ran bundle install.
But when I try to use :coffeescriptfilter I get:

Haml::Error in carts#index

Showing /home/jesha/ror/prefab/app/views/carts/index.html.haml where line #7 raised:

Filter "coffeescript" is not defined.
Extracted source (around line #7):

4:
5: %br
6:
7: :coffeescript
8:   alert("test")
9:
10: %table

Do you know what am I doing wrong?

undefined method `dirty?' for Barista::Compiler:Class exception

Hi!

Compiler does not have the "dirty?" method ?!

ree-1.8.7-2010.02 > [$]nicolas@nicolas-desktop:[git:master] /home/nicolas/projects/novagolf-> rails c
Loading development environment (Rails 3.0.1)
ree-1.8.7-2010.02 > Barista::Compilers::Node.available?
true
ree-1.8.7-2010.02 > Barista.compile_all!
NoMethodError: undefined method `dirty?' for Barista::Compiler:Class
    from /home/nicolas/.rvm/gems/ree-1.8.7-2010.02@novagolf/gems/barista-0.6.0/lib/barista.rb:94:in `compile_file!'
    from /home/nicolas/.rvm/gems/ree-1.8.7-2010.02@novagolf/gems/barista-0.6.0/lib/barista.rb:115:in `compile_all!'
    from /home/nicolas/.rvm/gems/ree-1.8.7-2010.02@novagolf/gems/barista-0.6.0/lib/barista.rb:114:in `each'
    from /home/nicolas/.rvm/gems/ree-1.8.7-2010.02@novagolf/gems/barista-0.6.0/lib/barista.rb:114:in `compile_all!'
    from (irb):2

Barista::CompilationError when javascript doesn't compile

With latest version of Coffeescript (0.9.4) and Barista 0.5.1, I get this error when I have a syntax error in my coffeescript file :

"coffee -p --no-wrap '/Users/po/code/vendeur/app/coffeescripts/lunch.coffee'" exited with a non-zero status.

It used to tell me where the error was but now I have to manually run the coffee command to get a clue :

Error: In /Users/po/code/vendeur/app/coffeescripts/lunch.coffee, Parse error on line 13: Unexpected '='
at Object.parseError (/usr/local/lib/coffee-script/lib/parser.js:513:11)
...

Is this the normal behavior?

document rails2 install

On a rails2 app with bundler I just added

gem 'barista', :require => 'barista'

and after creating an app/coffeescripts directory it seems to be working. Please add a note on rails2 install in the README

forcing coffee-script 2.1.x?

coffee-script 2.2.0 is out and it looks like there isn't any major compatibility issues

barista won't let me upgrade because it depends on 2.1.3. Mind changing the ruby dependency to use >= instead of ~>

thanks

Changed configuration but old settings remain

In my rails 3 project I setup my barista_config so that js files would get compiled to public/js
c.output_root = Rails.root.join("public", "js")

This works fine but then I changed it to:
c.output_root = Rails.root.join("public", "javascripts", "compiled")

Even though I changed the config it is still compiling my coffeescripts to the old directory.

[Barista] The coffeescript compiler at 'coffee' is currently unavailable.

Hi, I get the following after including barista into the gem file, adding my coffee scripts to app/coffeescripts (Rails 3 app).

[Barista] Compiling all scripts
[Barista] Compiling all coffeescripts
[Barista] The coffeescript compiler at 'coffee' is currently unavailable.

Gemfile: gem 'barista', '>= 0.5.0'

(and no I didn't forget to run bundle install)

Any idea as to whats causing this issue?

Running rake barista:brew (Node Compiler) using Capistrano always fail

hi,

Running rake barista:brew (Node Compiler) using Capistrano always fail with :
"... exited with a non-zero status.".

My cap recipe is just like this :

run "cd #{release_path} && rake RAILS_ENV=#{rails_env} barista:brew"

When I run rake barista:brew directly on my prod box with a shell it works.
So I think that it's the way Barista launches the coffee executable that does not work when it is launched by Capistrano...

Thanks,

Nicolas.

Manual .coffee files compiling

I'm using Jasmine, a javascript test framework and would like to be able to write tests in CoffeeScript. Jasmine puts its files under spec/javascripts, thus I want to be able to put my .coffee files containing tests under spec/coffeescripts and then compile them to spec/javascripts each time I run the testsuite.

One option I was pointed to is to use a guard-coffeescript gem, but I dislike the idea of something being constantly loaded in the background (if I forget to load it, then my compiled js tests won't be up to date with the .coffee tests). So, what I would like to do is to be able to compile those .coffee files each time I run rake jasmine:ci. That would probably mean putting some calls to Barista compiler in spec/javascripts/support/jasmine_runner.rb and I would like to know what that code would actually look like? Thanks.

application error NoMethodError at / undefined method `present?' for CoffeeScript::Engines::Node:Module

I am using barista in my new Sinatra app.
this is my source code.

require 'rubygems'
require 'sinatra'
require 'json'
require 'barista'

Barista.configure do |c|
c.app_root = setting.root
c.root = File.join(settings.root, 'coffeescripts')
end

get '/' do
erb :index
end

When i run my app, then an error occurred.

NoMethodError at /
undefined method `present?' for CoffeeScript::Engines::Node:Module

I don't know what exactly this error is.
any idea??

Barista + Sinatra

I did everything as in README. But when i try to load my app, i get this:

NoMethodError at /
undefined method `debug' for nil:NilClass
file: barista.rb location: debug line: 198

ruby 1.9.2p180 (2011-02-18 revision 30909) [x86_64-darwin10.6.0]
sinatra (1.2.3)
barista (1.0.0)

Require coffee-script >= or ~> 2.2

coffee-script 2.1.3 and below use console.log to print out the results of the compilation. When used with Node.js, console.log uses sprintf()-style interpolation to fill in values in error messages, so format character groups (such as "%d") get replaced with NaN when writing out compiled CoffeeScript. coffee-script 2.2.0 does not use console.log so these characters are correctly passed through. Requiring coffee-script 2.2 (and above) will ensure that people using characters that could be trapped by a console.log call will not be.

coffee-script not found error on new server

I am setting up a new production server and was under the impression that I had everything set up correctly. However, when I do rake RAILS_ENV=production barista:brew I get:

CoffeeScript doesn't appear to be installed on this system and you're not using an embedded compiler.

However, coffee -v returns CoffeeScript version 1.1.1. I installed using node.js and nmp. I also tried manually installing the gem on the server using gem install coffee-script but even after doing that I still get the same error.

The error happens both when using capistrano with a barista command and trying to run the command through ssh. Any idea?

Barista hanging on compilation

I've been using Barista for a few months now, but just recently it's started to hang when run through the Rails 3 development server.

When I run:

rails server

and hit the URL, the page starts loading and just hangs there.
If I exit rails server I get the following stack trace (note the Completed time is how long I waited before killing the server)

Started GET "/" for 127.0.0.1 at Mon Aug 23 13:36:09 +1000 2010
  Processing by IndexController#index as HTML
[Barista] Compiling all scripts
[Barista] Compiling all coffeescripts
[Barista] Compiling quince/Controllers.coffee from framework 'default'
Completed   in 32910ms

Barista::CompilationError ("coffee -p '<long file path>/app/coffeescripts/quince/Controllers.coffee'" exited with a non-zero status.):
/Users/wallisa/.bundle/ruby/1.8/gems/barista-0.5.0/lib/barista/compiler.rb:72:in `invoke_coffee'
  /Users/wallisa/.bundle/ruby/1.8/gems/barista-0.5.0/lib/barista/compiler.rb:34:in `compile!'
  /Users/wallisa/.bundle/ruby/1.8/gems/barista-0.5.0/lib/barista/compiler.rb:39:in `to_js'
  /Users/wallisa/.bundle/ruby/1.8/gems/barista-0.5.0/lib/barista/compiler.rb:23:in `compile'
  /Users/wallisa/.bundle/ruby/1.8/gems/barista-0.5.0/lib/barista.rb:88:in `compile_file!'
  /Users/wallisa/.bundle/ruby/1.8/gems/barista-0.5.0/lib/barista.rb:105:in `compile_all!'
  /Users/wallisa/.bundle/ruby/1.8/gems/barista-0.5.0/lib/barista.rb:104:in `each'
  /Users/wallisa/.bundle/ruby/1.8/gems/barista-0.5.0/lib/barista.rb:104:in `compile_all!'
  /Users/wallisa/.bundle/ruby/1.8/gems/barista-0.5.0/lib/barista/filter.rb:6:in `filter'
  ....

Any ideas?

add minification step

i was wondering if we can add a minify step, using uglifier gem, to the compilation process.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.