Skip to content
This repository
Browse code

Merge pull request #50 from brainopia/master

Support for rake tasks in rails 2.x
  • Loading branch information...
commit b2dae9fb42d991a255b56e0b6cacb5e3ebb9baba 2 parents 930db88 + 0d85a19
Darcy Laycock authored September 03, 2011
12  README.md
Source Rendered
@@ -36,11 +36,17 @@ Much like on Rails 3, Barista supports deep integration into Rails 2. The only t
36 36
 
37 37
     gem "json" # Only needed if on Ruby 1.8 / a platform that ships without JSON
38 38
     gem "barista"
39  
-    
  39
+
40 40
 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.
41 41
 
42 42
 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.
43 43
 
  44
+If you wish to use barista tasks with rails 2 project, add
  45
+
  46
+    require "barista/tasks"
  47
+
  48
+To your `Rakefile`.
  49
+
44 50
 ### Sinatra
45 51
 
46 52
 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:
62 68
     use Barista::Filter if Barista.add_filter?
63 69
     use Barista::Server::Proxy
64 70
     run MyRackApplication
65  
-    
  71
+
66 72
 Next, you need to configure barista anywhere before your the above code is run. e.g by adding the following immediatly preceeding it:
67 73
 
68 74
     # Barista (for CoffeeScript Support)
@@ -71,7 +77,7 @@ Next, you need to configure barista anywhere before your the above code is run.
71 77
     Barista.setup_defaults
72 78
     barista_config = root + '/barista_config.rb'
73 79
     require barista_config if File.exist?(barista_config)
74  
-    
  80
+
75 81
 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).
76 82
 
77 83
 ### A Quick Note on the JSON Gem
3  lib/barista/rake_task.rb
... ...
@@ -1,4 +1,3 @@
1  
-require 'barista' unless defined?(Barista)
2 1
 require 'rake'
3 2
 require 'rake/tasklib'
4 3
 
@@ -45,6 +44,8 @@ def method_missing(method, *args, &blk)
45 44
     private
46 45
 
47 46
     def setup_barista
  47
+      require 'barista'
  48
+
48 49
       Barista.env = @environment if @environment
49 50
       if @input_directory
50 51
         Barista.root = File.expand_path(@input_directory, Dir.pwd)
1  lib/barista/tasks.rb
... ...
@@ -0,0 +1 @@
  1
+load 'barista/tasks/barista.rake'

0 notes on commit b2dae9f

Please sign in to comment.
Something went wrong with that request. Please try again.