Skip to content
This repository
Newer
Older
100644 102 lines (67 sloc) 4.513 kb
55afa0cc »
2010-05-03 Add framework docs
1 # Barista #
02b7a2dc »
2010-04-24 Add more barista stuff
2
3 Barista is very, very similar to [bistro\_car](http://github.com/jnicklas/bistro_car) (infact, credit where credit is due - it shares similar
4 code / is almost a fork).
5
6 The main difference being, it lets you use coffee as you would javascript. Simply put, Write coffee
64971654 »
2010-04-27 Add Barista.configure, misc doc changes
7 and place it in `app/coffeescripts` and Barista will automatically serve it as if it was placed in `public/javascripts`
02b7a2dc »
2010-04-24 Add more barista stuff
8
64971654 »
2010-04-27 Add Barista.configure, misc doc changes
9 That is, `app/coffeescripts/demo.coffee` will work for `/javascripts/demo.js`. Even better (and more importantly
02b7a2dc »
2010-04-24 Add more barista stuff
10 for me), it provides `Barista.compile_all!` which takes all coffee files and compiles them into `public/javascripts`.
11
12 If you're using Jammit, this means you can simple run a rake task (`rake barista:brew` before running jammit) and
13 your coffeescripts will be automatically provided, ready for bundling.
14
762266fc »
2010-04-24 More docs
15 To add to your project, simply add:
16
8410919f »
2010-05-03 Misc fixes
17 gem 'barista', '>= 0.2.1'
762266fc »
2010-04-24 More docs
18
19 To your Gemfile and run bundle install.
20
21 As you place .coffee files in app/scripts, it will automatically handle them for you.
22
f6d92739 »
2010-04-25 More docs
23 Please note that for Jammit compatibility etc, by default in test and dev mode it will
24 automatically compile all coffeescripts that have changed before rendering the page.
25
64971654 »
2010-04-27 Add Barista.configure, misc doc changes
26 Barista require rails 3+ (but patches for Rails 2 will be accepted.)
27
55afa0cc »
2010-05-03 Add framework docs
28 ## Frameworks ##
29
30 One of the other main features Barista adds (over bistro\_car) is frameworks similar
31 to Compass. The idea being, you add coffeescripts at runtime from gems etc. To do this,
32 in your gem just have a coffeescript directory and then in you gem add the following code:
33
34 Barista::Framework.register 'name', 'full-path-to-directory' if defined?(Barista::Framework)
35
36 For an example of this in practice, check out [bhm-google-maps](http://github.com/YouthTree/bhm-google-maps)
83f23b6f »
2010-05-03 Readme info
37 or, the currently-in-development, [shuriken](http://github.com/Sutto/shuriken). The biggest advantage of this
38 is you can then manage js dependencies using existing tools like bundler.
55afa0cc »
2010-05-03 Add framework docs
39
85060b17 »
2010-05-03 Bump version, allow you to change prefixes for frameworks
40 In your `Barista.configure` block, you can also configure on a per-application basis the output directory
41 for individual frameworks (e.g. put shuriken into vendor/shuriken, bhm-google-maps into vendor/bhm-google-maps):
42
91a269d7 »
2010-07-18 WIP implementation of hooks
43 Barista.configure do |c|
44 c.change_output_prefix! 'shuriken', 'vendor/shuriken'
45 c.change_output_prefix! 'bhm-google-maps', 'vendor/bhm-google-maps'
85060b17 »
2010-05-03 Bump version, allow you to change prefixes for frameworks
46 end
47
48 Alternatively, to prefix all, you can use `Barista.each_framework` (if you pass true, it includes the 'default' framework
49 which is your application root).
50
91a269d7 »
2010-07-18 WIP implementation of hooks
51 Barista.configure do |c|
52 c.each_framework do |framework|
53 c.change_output_prefix! framework.name, "vendor/#{framework.name}"
85060b17 »
2010-05-03 Bump version, allow you to change prefixes for frameworks
54 end
55 end
91a269d7 »
2010-07-18 WIP implementation of hooks
56
57 ## Hooks ##
58
59 Barista lets you hook into the compilation at several stages. Namely:
60
61 * before compilation
62 * after compilation
63 * after compilation fails
64
65 To hook into these hooks, you can use like so:
66
67 * `Barista.before_compilation { |path| puts "Barista: Compiling #{path}" }`
68 * `Barista.on_compilation { |path| puts "Barista: Successfully compiled #{path}" }`
fd82e0f9 »
2010-07-18 Update to support hooks
69 * `Barista.on_compilation_with_warning { |path, output| puts "Barista: Compilation of #{path} had a warning:\n#{output}" }`
91a269d7 »
2010-07-18 WIP implementation of hooks
70 * `Barista.on_compilation_error { |path, output| puts "Barista: Compilation of #{path} failed with:\n#{output}" }`
71
fd82e0f9 »
2010-07-18 Update to support hooks
72
91a269d7 »
2010-07-18 WIP implementation of hooks
73 These allow you to do things such as notify on compilation, automatically
74 perform compression post compilation and a variety of other cool things.
85060b17 »
2010-05-03 Bump version, allow you to change prefixes for frameworks
75
64971654 »
2010-04-27 Add Barista.configure, misc doc changes
76 ## Configuration ##
77
78 Please note that barista lets you configure several options. To do this,
79 it's as simple as setting up an initializer with:
80
3442ea52 »
2010-04-27 Add the generator
81 rails generate barista_install
64971654 »
2010-04-27 Add Barista.configure, misc doc changes
82
83 Then editing `config/initializers/barista_config.rb`.
84
85 Currently available options are:
86
87 * root - the folder path to read coffeescripts from, defaults to app/coffeescripts
88 * output\_root - the folder to write them into, defautls to public/javascripts.
89 * no\_wrap - stop coffee from automatically wrapping JS in a closure.
83f23b6f »
2010-05-03 Readme info
90 * change\_output\_prefix! - method to change the output prefix for a framework.
64971654 »
2010-04-27 Add Barista.configure, misc doc changes
91
870add66 »
2010-05-14 Contributor details for Barista
92 ## Note on Patches/Pull Requests ##
93
94 1. Fork the project.
95 2. Make your feature addition or bug fix.
96 3. Add tests for it. This is important so I don't break it in a future version unintentionally.
97 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)
98 5. Send me a pull request. Bonus points for topic branches.
99
100 ## Copyright ##
101
102 Copyright (c) 2010 Darcy Laycock. See LICENSE for details.
Something went wrong with that request. Please try again.