sutto / barista Goto Github PK
View Code? Open in Web Editor NEWSimple, transparent CoffeeScript support for Rails and Rack apps.
License: MIT License
Simple, transparent CoffeeScript support for Rails and Rack apps.
License: MIT License
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?
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.
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
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?
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
I think the title says it all. Has anyone else ran into this issue?
EDIT:
rails 3.0.9, using with Jammit
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.
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?
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.
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?
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.
Hello,
I would like Barista to compile app/coffeescripts/foo/bar/baz.coffee
into public/javascripts/foo/bar/baz.js
.
Thanks for your consideration.
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?
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 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.
Thanks!
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?
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?
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
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).
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.
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.
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.
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?
https://github.com/Sutto/barista/blob/master/lib/barista/compiler.rb#L26
CoffeeScript.engine will either be nil or an engine. The actual CoffeeScript#engine would have to have returned true
for #supported? to not be nil. Therefore, this should be sufficient: not CoffeeScript.engine.nil?
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.
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.
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)
i was wondering if we can add a minify step, using uglifier gem, to the compilation process.
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?
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?
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.
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.
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.
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
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?
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.
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.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.