Browse files

Merge pull request #50 from brainopia/master

Support for rake tasks in rails 2.x
  • Loading branch information...
2 parents 930db88 + 0d85a19 commit b2dae9fb42d991a255b56e0b6cacb5e3ebb9baba @Sutto Sutto committed Sep 3, 2011
Showing with 12 additions and 4 deletions.
  1. +9 −3
  2. +2 −1 lib/barista/rake_task.rb
  3. +1 −0 lib/barista/tasks.rb
@@ -36,11 +36,17 @@ Much like on Rails 3, Barista supports deep integration into Rails 2. The only t
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
+ require "barista/tasks"
+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:
@@ -62,7 +68,7 @@ For example, your `` may look like:
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)
@@ -71,7 +77,7 @@ Next, you need to configure barista anywhere before your the above code is run.
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 `` that looks similar to [this example](
### A Quick Note on the JSON Gem
@@ -1,4 +1,3 @@
-require 'barista' unless defined?(Barista)
require 'rake'
require 'rake/tasklib'
@@ -45,6 +44,8 @@ def method_missing(method, *args, &blk)
def setup_barista
+ require 'barista'
Barista.env = @environment if @environment
if @input_directory
Barista.root = File.expand_path(@input_directory, Dir.pwd)
@@ -0,0 +1 @@
+load 'barista/tasks/barista.rake'

0 comments on commit b2dae9f

Please sign in to comment.