Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge pull request #50 from brainopia/master

Support for rake tasks in rails 2.x
  • Loading branch information...
commit b2dae9fb42d991a255b56e0b6cacb5e3ebb9baba 2 parents 930db88 + 0d85a19
@Sutto authored
Showing with 12 additions and 4 deletions.
  1. +9 −3 README.md
  2. +2 −1  lib/barista/rake_task.rb
  3. +1 −0  lib/barista/tasks.rb
View
12 README.md
@@ -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](https://github.com/Sutto/barista/blob/master/lib/generators/barista/install/templates/initializer.rb) 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 `config.ru` 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.setup_defaults
barista_config = root + '/barista_config.rb'
require barista_config if File.exist?(barista_config)
-
+
Hence, if you'e using, for example, [serve](https://github.com/jlong/serve) users should have a `config.ru` that looks similar to [this example](https://github.com/YouthTree/site-design/blob/master/config.ru).
### A Quick Note on the JSON Gem
View
3  lib/barista/rake_task.rb
@@ -1,4 +1,3 @@
-require 'barista' unless defined?(Barista)
require 'rake'
require 'rake/tasklib'
@@ -45,6 +44,8 @@ def method_missing(method, *args, &blk)
private
def setup_barista
+ require 'barista'
+
Barista.env = @environment if @environment
if @input_directory
Barista.root = File.expand_path(@input_directory, Dir.pwd)
View
1  lib/barista/tasks.rb
@@ -0,0 +1 @@
+load 'barista/tasks/barista.rake'
Please sign in to comment.
Something went wrong with that request. Please try again.