barista 1.2.1 → 1.3.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.rspec +1 -2
- data/Gemfile +10 -4
- data/Gemfile.lock +97 -2
- data/README.md +24 -3
- data/Rakefile +34 -17
- data/barista.gemspec +31 -17
- data/lib/barista.rb +16 -6
- data/lib/barista/compiler.rb +6 -2
- data/lib/barista/hooks.rb +5 -1
- data/lib/barista/rake_task.rb +3 -1
- data/lib/barista/tasks.rb +1 -0
- data/lib/barista/version.rb +2 -2
- data/spec/assets/alert.coffee +3 -0
- data/spec/barista_spec.rb +69 -4
- data/spec/spec_helper.rb +16 -5
- metadata +181 -90
data/.rspec
CHANGED
@@ -1,2 +1 @@
|
|
1
|
-
--colour
|
2
|
-
--debug
|
1
|
+
--colour
|
data/Gemfile
CHANGED
@@ -3,7 +3,13 @@ source "http://rubygems.org"
|
|
3
3
|
gem 'coffee-script', '~> 2.2'
|
4
4
|
|
5
5
|
group :development, :test do
|
6
|
-
gem '
|
7
|
-
gem '
|
8
|
-
gem '
|
9
|
-
|
6
|
+
gem 'rails', '~> 3.0'
|
7
|
+
gem 'jeweler', '~> 1.0'
|
8
|
+
gem 'rspec', '~> 2.6'
|
9
|
+
gem 'rspec-rails', '~> 2.6'
|
10
|
+
gem 'rspec-core', '~> 2.6'
|
11
|
+
gem 'rdoc', '~> 2.4'
|
12
|
+
gem 'rr', '~> 1.0'
|
13
|
+
gem 'ruby-debug', :platform => :ruby_18
|
14
|
+
gem 'ruby-debug19', '~> 0.11', :platform => :ruby_19
|
15
|
+
end
|
data/Gemfile.lock
CHANGED
@@ -1,20 +1,85 @@
|
|
1
1
|
GEM
|
2
2
|
remote: http://rubygems.org/
|
3
3
|
specs:
|
4
|
+
abstract (1.0.0)
|
5
|
+
actionmailer (3.0.8)
|
6
|
+
actionpack (= 3.0.8)
|
7
|
+
mail (~> 2.2.19)
|
8
|
+
actionpack (3.0.8)
|
9
|
+
activemodel (= 3.0.8)
|
10
|
+
activesupport (= 3.0.8)
|
11
|
+
builder (~> 2.1.2)
|
12
|
+
erubis (~> 2.6.6)
|
13
|
+
i18n (~> 0.5.0)
|
14
|
+
rack (~> 1.2.1)
|
15
|
+
rack-mount (~> 0.6.14)
|
16
|
+
rack-test (~> 0.5.7)
|
17
|
+
tzinfo (~> 0.3.23)
|
18
|
+
activemodel (3.0.8)
|
19
|
+
activesupport (= 3.0.8)
|
20
|
+
builder (~> 2.1.2)
|
21
|
+
i18n (~> 0.5.0)
|
22
|
+
activerecord (3.0.8)
|
23
|
+
activemodel (= 3.0.8)
|
24
|
+
activesupport (= 3.0.8)
|
25
|
+
arel (~> 2.0.10)
|
26
|
+
tzinfo (~> 0.3.23)
|
27
|
+
activeresource (3.0.8)
|
28
|
+
activemodel (= 3.0.8)
|
29
|
+
activesupport (= 3.0.8)
|
30
|
+
activesupport (3.0.8)
|
31
|
+
archive-tar-minitar (0.5.2)
|
32
|
+
arel (2.0.10)
|
33
|
+
builder (2.1.2)
|
4
34
|
coffee-script (2.2.0)
|
5
35
|
coffee-script-source
|
6
36
|
execjs
|
7
37
|
coffee-script-source (1.1.1)
|
38
|
+
columnize (0.3.4)
|
8
39
|
diff-lcs (1.1.2)
|
40
|
+
erubis (2.6.6)
|
41
|
+
abstract (>= 1.0.0)
|
9
42
|
execjs (1.1.0)
|
10
43
|
multi_json (~> 1.0)
|
11
44
|
git (1.2.5)
|
45
|
+
i18n (0.5.0)
|
12
46
|
jeweler (1.6.2)
|
13
47
|
bundler (~> 1.0)
|
14
48
|
git (>= 1.2.5)
|
15
49
|
rake
|
50
|
+
linecache (0.46)
|
51
|
+
rbx-require-relative (> 0.0.4)
|
52
|
+
linecache19 (0.5.12)
|
53
|
+
ruby_core_source (>= 0.1.4)
|
54
|
+
mail (2.2.19)
|
55
|
+
activesupport (>= 2.3.6)
|
56
|
+
i18n (>= 0.4.0)
|
57
|
+
mime-types (~> 1.16)
|
58
|
+
treetop (~> 1.4.8)
|
59
|
+
mime-types (1.16)
|
16
60
|
multi_json (1.0.3)
|
17
|
-
|
61
|
+
polyglot (0.3.1)
|
62
|
+
rack (1.2.3)
|
63
|
+
rack-mount (0.6.14)
|
64
|
+
rack (>= 1.0.0)
|
65
|
+
rack-test (0.5.7)
|
66
|
+
rack (>= 1.0)
|
67
|
+
rails (3.0.8)
|
68
|
+
actionmailer (= 3.0.8)
|
69
|
+
actionpack (= 3.0.8)
|
70
|
+
activerecord (= 3.0.8)
|
71
|
+
activeresource (= 3.0.8)
|
72
|
+
activesupport (= 3.0.8)
|
73
|
+
bundler (~> 1.0)
|
74
|
+
railties (= 3.0.8)
|
75
|
+
railties (3.0.8)
|
76
|
+
actionpack (= 3.0.8)
|
77
|
+
activesupport (= 3.0.8)
|
78
|
+
rake (>= 0.8.7)
|
79
|
+
thor (~> 0.14.4)
|
80
|
+
rake (0.9.2)
|
81
|
+
rbx-require-relative (0.0.5)
|
82
|
+
rdoc (2.5.11)
|
18
83
|
rr (1.0.2)
|
19
84
|
rspec (2.6.0)
|
20
85
|
rspec-core (~> 2.6.0)
|
@@ -24,6 +89,30 @@ GEM
|
|
24
89
|
rspec-expectations (2.6.0)
|
25
90
|
diff-lcs (~> 1.1.2)
|
26
91
|
rspec-mocks (2.6.0)
|
92
|
+
rspec-rails (2.6.1)
|
93
|
+
actionpack (~> 3.0)
|
94
|
+
activesupport (~> 3.0)
|
95
|
+
railties (~> 3.0)
|
96
|
+
rspec (~> 2.6.0)
|
97
|
+
ruby-debug (0.10.4)
|
98
|
+
columnize (>= 0.1)
|
99
|
+
ruby-debug-base (~> 0.10.4.0)
|
100
|
+
ruby-debug-base (0.10.4)
|
101
|
+
linecache (>= 0.3)
|
102
|
+
ruby-debug-base19 (0.11.25)
|
103
|
+
columnize (>= 0.3.1)
|
104
|
+
linecache19 (>= 0.5.11)
|
105
|
+
ruby_core_source (>= 0.1.4)
|
106
|
+
ruby-debug19 (0.11.6)
|
107
|
+
columnize (>= 0.3.1)
|
108
|
+
linecache19 (>= 0.5.11)
|
109
|
+
ruby-debug-base19 (>= 0.11.19)
|
110
|
+
ruby_core_source (0.1.5)
|
111
|
+
archive-tar-minitar (>= 0.5.2)
|
112
|
+
thor (0.14.6)
|
113
|
+
treetop (1.4.9)
|
114
|
+
polyglot (>= 0.3.1)
|
115
|
+
tzinfo (0.3.29)
|
27
116
|
|
28
117
|
PLATFORMS
|
29
118
|
ruby
|
@@ -31,5 +120,11 @@ PLATFORMS
|
|
31
120
|
DEPENDENCIES
|
32
121
|
coffee-script (~> 2.2)
|
33
122
|
jeweler (~> 1.0)
|
123
|
+
rails (~> 3.0)
|
124
|
+
rdoc (~> 2.4)
|
34
125
|
rr (~> 1.0)
|
35
|
-
rspec (~> 2.
|
126
|
+
rspec (~> 2.6)
|
127
|
+
rspec-core (~> 2.6)
|
128
|
+
rspec-rails (~> 2.6)
|
129
|
+
ruby-debug
|
130
|
+
ruby-debug19 (~> 0.11)
|
data/README.md
CHANGED
@@ -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
|
+
load "barista/tasks/barista.rake"
|
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
|
@@ -154,6 +160,14 @@ and `#option!` (to set the value to true):
|
|
154
160
|
* `bin_path` – The path to the `node` executable if non-standard and not using `therubyracer`.
|
155
161
|
* All of the hook methods mentioned below.
|
156
162
|
|
163
|
+
### Custom Preamble
|
164
|
+
|
165
|
+
You can generate a custom preamble using a code block. For example, you can replace the location of the original `.coffee` file by a relative one to `Rails.root`.
|
166
|
+
|
167
|
+
Barista.add_preamble do |location|
|
168
|
+
"/* : DO NOT MODIFY - compiled from #{Pathname.new(location).relative_path_from(Rails.root).to_s}\n\n"
|
169
|
+
end
|
170
|
+
|
157
171
|
## Frameworks
|
158
172
|
|
159
173
|
One of the other main features Barista adds (over other tools) is frameworks similar
|
@@ -219,6 +233,10 @@ The following people have all contributed to Barista:
|
|
219
233
|
* [Ben Atkin](https://github.com/benatkin) – Docs work.
|
220
234
|
* [Ben Hoskings](https://github.com/benhoskings) – Misc. fixes, added preamble support.
|
221
235
|
* [Kim Joar Bekkelund](https://github.com/kjbekkelund) – Docs work.
|
236
|
+
* [Jeffrey ODell](https://github.com/jodell) - Fixed an issue with messages during autocompile.
|
237
|
+
* [Paul McMahon](https://github.com/pwim) - Fixed a typo.
|
238
|
+
* [Ravil Bayramgalin](https://github.com/brainopia) - Fixes for Rakefiles on Rails 2.
|
239
|
+
* [Daniel Doubrovkine](https://github.com/dblock) - Dynamic Preambles, Making it easier to spec the application.
|
222
240
|
|
223
241
|
Barista was originally heavily inspired by [Bistro Car](https://github.com/jnicklas/bistro_car), but has taken a few fundamentally
|
224
242
|
different approach in a few areas.
|
@@ -227,6 +245,9 @@ Barista builds upon the awesome [coffee-script](https://github.com/josh/ruby-cof
|
|
227
245
|
|
228
246
|
It's all possible thanks to [CoffeeScript](https://github.com/jashkenas/coffee-script) by Jeremy Ashkenas.
|
229
247
|
|
248
|
+
If I've missed you're name and you've contributed to Barista, please let me know and I'll add you to the list (or
|
249
|
+
fork this document and send a pull request).
|
250
|
+
|
230
251
|
## Note on Patches/Pull Requests ##
|
231
252
|
|
232
253
|
1. Fork the project.
|
data/Rakefile
CHANGED
@@ -1,29 +1,46 @@
|
|
1
1
|
require 'rubygems'
|
2
|
+
require 'bundler'
|
3
|
+
|
4
|
+
begin
|
5
|
+
Bundler.setup(:default, :development)
|
6
|
+
rescue Bundler::BundlerError => e
|
7
|
+
$stderr.puts e.message
|
8
|
+
$stderr.puts "Run `bundle install` to install missing gems."
|
9
|
+
exit e.status_code
|
10
|
+
end
|
11
|
+
|
2
12
|
require 'rake'
|
13
|
+
require 'rspec/core/rake_task'
|
3
14
|
|
4
|
-
require '
|
15
|
+
require 'barista/version'
|
5
16
|
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
gem.authors = ["Darcy Laycock"]
|
16
|
-
end
|
17
|
-
Jeweler::GemcutterTasks.new
|
18
|
-
rescue LoadError
|
19
|
-
puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
|
17
|
+
require 'jeweler'
|
18
|
+
Jeweler::Tasks.new do |gem|
|
19
|
+
gem.name = "barista"
|
20
|
+
gem.summary = %Q{Simple, transparent coffeescript integration for Rails and Rack applications.}
|
21
|
+
gem.description = File.read(File.expand_path('DESCRIPTION', File.dirname(__FILE__)))
|
22
|
+
gem.email = "sutto@sutto.net"
|
23
|
+
gem.homepage = "http://github.com/Sutto/barista"
|
24
|
+
gem.version = Barista::Version::STRING
|
25
|
+
gem.authors = ["Darcy Laycock"]
|
20
26
|
end
|
27
|
+
Jeweler::GemcutterTasks.new
|
21
28
|
|
22
|
-
|
23
|
-
|
29
|
+
RSpec::Core::RakeTask.new(:spec) do |spec|
|
30
|
+
spec.pattern = "spec/**/*_spec.rb"
|
31
|
+
end
|
32
|
+
|
33
|
+
require 'rdoc/task'
|
34
|
+
RDoc::Task.new do |rdoc|
|
24
35
|
version = Barista::Version::STRING
|
25
36
|
rdoc.rdoc_dir = 'rdoc'
|
26
37
|
rdoc.title = "barista #{version}"
|
27
38
|
rdoc.rdoc_files.include('README*')
|
28
39
|
rdoc.rdoc_files.include('lib/**/*.rb')
|
29
40
|
end
|
41
|
+
|
42
|
+
task :default => :spec
|
43
|
+
|
44
|
+
require 'barista'
|
45
|
+
|
46
|
+
|
data/barista.gemspec
CHANGED
@@ -4,20 +4,14 @@
|
|
4
4
|
# -*- encoding: utf-8 -*-
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
|
-
s.name =
|
8
|
-
s.version = "1.
|
7
|
+
s.name = "barista"
|
8
|
+
s.version = "1.3.0"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Darcy Laycock"]
|
12
|
-
s.date =
|
13
|
-
s.description =
|
14
|
-
|
15
|
-
Much like Compass does for Sass, It also provides Frameworks (bundleable code which can be shared via Gems).
|
16
|
-
|
17
|
-
Lastly, it also provides a Rack Application (which can be used to server compiled code), a around_filter-style precompiler (as Rack middleware) and simple helpers for rails and Haml.
|
18
|
-
|
19
|
-
For more details, please see the the README file bundled with it.}
|
20
|
-
s.email = %q{sutto@sutto.net}
|
12
|
+
s.date = "2012-07-23"
|
13
|
+
s.description = "Barista provides simple, integrated support for CoffeeScript in Rack and Rails applications.\n\nMuch like Compass does for Sass, It also provides Frameworks (bundleable code which can be shared via Gems).\n\nLastly, it also provides a Rack Application (which can be used to server compiled code), a around_filter-style precompiler (as Rack middleware) and simple helpers for rails and Haml.\n\nFor more details, please see the the README file bundled with it."
|
14
|
+
s.email = "sutto@sutto.net"
|
21
15
|
s.extra_rdoc_files = [
|
22
16
|
"LICENSE",
|
23
17
|
"README.md"
|
@@ -47,39 +41,59 @@ For more details, please see the the README file bundled with it.}
|
|
47
41
|
"lib/barista/integration/sinatra.rb",
|
48
42
|
"lib/barista/rake_task.rb",
|
49
43
|
"lib/barista/server.rb",
|
44
|
+
"lib/barista/tasks.rb",
|
50
45
|
"lib/barista/tasks/barista.rake",
|
51
46
|
"lib/barista/version.rb",
|
52
47
|
"lib/generators/barista/install/USAGE",
|
53
48
|
"lib/generators/barista/install/install_generator.rb",
|
54
49
|
"lib/generators/barista/install/templates/initializer.rb",
|
55
50
|
"lib/generators/barista_install_generator.rb",
|
51
|
+
"spec/assets/alert.coffee",
|
56
52
|
"spec/barista_spec.rb",
|
57
53
|
"spec/spec_helper.rb"
|
58
54
|
]
|
59
|
-
s.homepage =
|
55
|
+
s.homepage = "http://github.com/Sutto/barista"
|
60
56
|
s.require_paths = ["lib"]
|
61
|
-
s.rubygems_version =
|
62
|
-
s.summary =
|
57
|
+
s.rubygems_version = "1.8.24"
|
58
|
+
s.summary = "Simple, transparent coffeescript integration for Rails and Rack applications."
|
63
59
|
|
64
60
|
if s.respond_to? :specification_version then
|
65
61
|
s.specification_version = 3
|
66
62
|
|
67
63
|
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
68
64
|
s.add_runtime_dependency(%q<coffee-script>, ["~> 2.2"])
|
65
|
+
s.add_development_dependency(%q<rails>, ["~> 3.0"])
|
69
66
|
s.add_development_dependency(%q<jeweler>, ["~> 1.0"])
|
70
|
-
s.add_development_dependency(%q<rspec>, ["~> 2.
|
67
|
+
s.add_development_dependency(%q<rspec>, ["~> 2.6"])
|
68
|
+
s.add_development_dependency(%q<rspec-rails>, ["~> 2.6"])
|
69
|
+
s.add_development_dependency(%q<rspec-core>, ["~> 2.6"])
|
70
|
+
s.add_development_dependency(%q<rdoc>, ["~> 2.4"])
|
71
71
|
s.add_development_dependency(%q<rr>, ["~> 1.0"])
|
72
|
+
s.add_development_dependency(%q<ruby-debug>, [">= 0"])
|
73
|
+
s.add_development_dependency(%q<ruby-debug19>, ["~> 0.11"])
|
72
74
|
else
|
73
75
|
s.add_dependency(%q<coffee-script>, ["~> 2.2"])
|
76
|
+
s.add_dependency(%q<rails>, ["~> 3.0"])
|
74
77
|
s.add_dependency(%q<jeweler>, ["~> 1.0"])
|
75
|
-
s.add_dependency(%q<rspec>, ["~> 2.
|
78
|
+
s.add_dependency(%q<rspec>, ["~> 2.6"])
|
79
|
+
s.add_dependency(%q<rspec-rails>, ["~> 2.6"])
|
80
|
+
s.add_dependency(%q<rspec-core>, ["~> 2.6"])
|
81
|
+
s.add_dependency(%q<rdoc>, ["~> 2.4"])
|
76
82
|
s.add_dependency(%q<rr>, ["~> 1.0"])
|
83
|
+
s.add_dependency(%q<ruby-debug>, [">= 0"])
|
84
|
+
s.add_dependency(%q<ruby-debug19>, ["~> 0.11"])
|
77
85
|
end
|
78
86
|
else
|
79
87
|
s.add_dependency(%q<coffee-script>, ["~> 2.2"])
|
88
|
+
s.add_dependency(%q<rails>, ["~> 3.0"])
|
80
89
|
s.add_dependency(%q<jeweler>, ["~> 1.0"])
|
81
|
-
s.add_dependency(%q<rspec>, ["~> 2.
|
90
|
+
s.add_dependency(%q<rspec>, ["~> 2.6"])
|
91
|
+
s.add_dependency(%q<rspec-rails>, ["~> 2.6"])
|
92
|
+
s.add_dependency(%q<rspec-core>, ["~> 2.6"])
|
93
|
+
s.add_dependency(%q<rdoc>, ["~> 2.4"])
|
82
94
|
s.add_dependency(%q<rr>, ["~> 1.0"])
|
95
|
+
s.add_dependency(%q<ruby-debug>, [">= 0"])
|
96
|
+
s.add_dependency(%q<ruby-debug19>, ["~> 0.11"])
|
83
97
|
end
|
84
98
|
end
|
85
99
|
|
data/lib/barista.rb
CHANGED
@@ -46,6 +46,10 @@ module Barista
|
|
46
46
|
def invoke_hook(name, *args)
|
47
47
|
hooks.invoke(name, *args)
|
48
48
|
end
|
49
|
+
|
50
|
+
def has_hook?(name)
|
51
|
+
hooks.has_hook?(name)
|
52
|
+
end
|
49
53
|
|
50
54
|
has_hook_method :on_compilation_error => :compilation_failed,
|
51
55
|
:on_compilation => :compiled,
|
@@ -54,7 +58,6 @@ module Barista
|
|
54
58
|
:before_full_compilation => :before_full_compilation,
|
55
59
|
:before_compilation => :before_compilation
|
56
60
|
|
57
|
-
|
58
61
|
# Configuration - Tweak how you use Barista.
|
59
62
|
|
60
63
|
has_boolean_options :verbose, :bare, :add_filter, :add_preamble, :exception_on_error, :embedded_interpreter, :auto_compile
|
@@ -62,6 +65,17 @@ module Barista
|
|
62
65
|
has_delegate_methods Framework, :register
|
63
66
|
has_deprecated_methods :compiler, :compiler=, :compiler_klass, :compiler_klass=
|
64
67
|
|
68
|
+
def add_preamble(&blk)
|
69
|
+
self.add_preamble = true
|
70
|
+
if block_given?
|
71
|
+
@preamble = blk
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
def preamble
|
76
|
+
@preamble
|
77
|
+
end
|
78
|
+
|
65
79
|
def configure
|
66
80
|
yield self if block_given?
|
67
81
|
end
|
@@ -159,10 +173,6 @@ module Barista
|
|
159
173
|
local_env?
|
160
174
|
end
|
161
175
|
|
162
|
-
def default_for_add_preamble
|
163
|
-
local_env?
|
164
|
-
end
|
165
|
-
|
166
176
|
def default_for_exception_on_error
|
167
177
|
true
|
168
178
|
end
|
@@ -215,7 +225,7 @@ module Barista
|
|
215
225
|
end
|
216
226
|
|
217
227
|
def debug(message)
|
218
|
-
logger.debug "[Barista] #{message}" if logger
|
228
|
+
logger.debug "[Barista] #{message}" if logger && verbose?
|
219
229
|
end
|
220
230
|
|
221
231
|
def setup_defaults
|
data/lib/barista/compiler.rb
CHANGED
@@ -114,7 +114,7 @@ module Barista
|
|
114
114
|
@compiled_content = preamble(location) + @compiled_content if location != 'inline' && Barista.add_preamble?
|
115
115
|
@compiled = true
|
116
116
|
end
|
117
|
-
|
117
|
+
|
118
118
|
def to_js
|
119
119
|
compile! unless defined?(@compiled) && @compiled
|
120
120
|
@compiled_content
|
@@ -159,7 +159,11 @@ module Barista
|
|
159
159
|
|
160
160
|
def preamble(location)
|
161
161
|
inner_message = copyable?(location) ? "copied" : "compiled"
|
162
|
-
|
162
|
+
if Barista.preamble
|
163
|
+
Barista.preamble.call(location)
|
164
|
+
else
|
165
|
+
"/* DO NOT MODIFY. This file was #{inner_message} #{Time.now.httpdate} from\n * #{location.strip}\n */\n\n"
|
166
|
+
end
|
163
167
|
end
|
164
168
|
|
165
169
|
def compilation_error_for(location, message)
|
data/lib/barista/hooks.rb
CHANGED
data/lib/barista/rake_task.rb
CHANGED
@@ -1,9 +1,9 @@
|
|
1
|
-
require 'barista' unless defined?(Barista)
|
2
1
|
require 'rake'
|
3
2
|
require 'rake/tasklib'
|
4
3
|
|
5
4
|
module Barista
|
6
5
|
class RakeTask < ::Rake::TaskLib
|
6
|
+
include Rake::DSL
|
7
7
|
|
8
8
|
attr_writer :namespace, :task_name
|
9
9
|
attr_writer :environment, :input_directory, :output_directory, :rails
|
@@ -45,6 +45,8 @@ module Barista
|
|
45
45
|
private
|
46
46
|
|
47
47
|
def setup_barista
|
48
|
+
require 'barista'
|
49
|
+
|
48
50
|
Barista.env = @environment if @environment
|
49
51
|
if @input_directory
|
50
52
|
Barista.root = File.expand_path(@input_directory, Dir.pwd)
|
@@ -0,0 +1 @@
|
|
1
|
+
load 'barista/tasks/barista.rake'
|
data/lib/barista/version.rb
CHANGED
data/spec/barista_spec.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
require '
|
1
|
+
require 'spec_helper'
|
2
2
|
|
3
3
|
describe Barista do
|
4
4
|
|
@@ -6,10 +6,75 @@ describe Barista do
|
|
6
6
|
|
7
7
|
context 'configuration'
|
8
8
|
|
9
|
-
context 'setting
|
9
|
+
context 'setting app_root' do
|
10
|
+
it "defaults to Rails.root" do
|
11
|
+
Barista::app_root.should == Rails.root
|
12
|
+
end
|
13
|
+
it "can be set to another directory" do
|
14
|
+
new_path = File.expand_path("../../public/javascripts", __FILE__)
|
15
|
+
Barista.configure do |c|
|
16
|
+
c.app_root = new_path
|
17
|
+
end
|
18
|
+
Barista::app_root.to_s.should == new_path
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
context 'preamble' do
|
23
|
+
before(:each) do
|
24
|
+
@assets_path = File.expand_path("../assets", __FILE__)
|
25
|
+
@public_path = File.expand_path("../public", __FILE__)
|
26
|
+
Barista.configure do |c|
|
27
|
+
c.root = @assets_path
|
28
|
+
c.output_root = @public_path
|
29
|
+
end
|
30
|
+
FileUtils.rm_rf @public_path if File.directory?(@public_path)
|
31
|
+
end
|
32
|
+
it "is written by default" do
|
33
|
+
Barista.add_preamble = true
|
34
|
+
Barista::compile_all!
|
35
|
+
alert_js = IO.read(File.join(@public_path, "alert.js"))
|
36
|
+
alert_js.should include "DO NOT MODIFY"
|
37
|
+
end
|
38
|
+
it "can be disabled" do
|
39
|
+
Barista.add_preamble = false
|
40
|
+
Barista::compile_all!
|
41
|
+
alert_js = IO.read(File.join(@public_path, "alert.js"))
|
42
|
+
alert_js.should_not include "DO NOT MODIFY"
|
43
|
+
end
|
44
|
+
end
|
10
45
|
|
11
46
|
context 'compiling files'
|
12
47
|
|
13
|
-
context 'compiling all'
|
48
|
+
context 'compiling all' do
|
49
|
+
before(:each) do
|
50
|
+
@assets_path = File.expand_path("../assets", __FILE__)
|
51
|
+
@public_path = File.expand_path("../public", __FILE__)
|
52
|
+
Barista.configure do |c|
|
53
|
+
c.root = @assets_path
|
54
|
+
c.output_root = @public_path
|
55
|
+
end
|
56
|
+
FileUtils.rm_rf @public_path if File.directory?(@public_path)
|
57
|
+
end
|
58
|
+
it "compiles nothing" do
|
59
|
+
lambda { Barista::compile_all! false, false }.should_not raise_error
|
60
|
+
end
|
61
|
+
it "produces alert.js" do
|
62
|
+
Barista::compile_all!
|
63
|
+
File.exist?(File.join(@public_path, "alert.js")).should be_true
|
64
|
+
end
|
65
|
+
it "logs when verbose is true" do
|
66
|
+
log = StringIO.new
|
67
|
+
Barista.logger = Logger.new(log)
|
68
|
+
Barista.compile_all!
|
69
|
+
log.string.should =~ /\[Barista\].+/
|
70
|
+
end
|
71
|
+
it "does not log when verbose is false" do
|
72
|
+
log = StringIO.new
|
73
|
+
Barista.logger = Logger.new(log)
|
74
|
+
Barista.verbose = false
|
75
|
+
Barista.compile_all!
|
76
|
+
log.string.should be_empty
|
77
|
+
end
|
78
|
+
end
|
14
79
|
|
15
|
-
end
|
80
|
+
end
|
data/spec/spec_helper.rb
CHANGED
@@ -1,11 +1,22 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
|
1
3
|
ENV['RAILS_ENV'] ||= 'test'
|
4
|
+
ENV['RAILS_ROOT'] ||= File.expand_path("..", __FILE__)
|
5
|
+
|
6
|
+
require "action_controller/railtie"
|
7
|
+
require "action_mailer/railtie"
|
8
|
+
require "active_resource/railtie"
|
2
9
|
|
3
|
-
require '
|
10
|
+
require 'rspec/rails'
|
4
11
|
|
5
|
-
|
12
|
+
Bundler.require(:default, Rails.env) if defined?(Bundler)
|
6
13
|
|
7
|
-
|
14
|
+
class Application < Rails::Application; end
|
15
|
+
|
16
|
+
require 'barista'
|
8
17
|
|
9
18
|
RSpec.configure do |config|
|
10
|
-
config.mock_with :
|
11
|
-
|
19
|
+
config.mock_with :rspec
|
20
|
+
config.expect_with :rspec
|
21
|
+
end
|
22
|
+
|
metadata
CHANGED
@@ -1,100 +1,197 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: barista
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.3.0
|
5
5
|
prerelease:
|
6
|
-
segments:
|
7
|
-
- 1
|
8
|
-
- 2
|
9
|
-
- 1
|
10
|
-
version: 1.2.1
|
11
6
|
platform: ruby
|
12
|
-
authors:
|
7
|
+
authors:
|
13
8
|
- Darcy Laycock
|
14
9
|
autorequire:
|
15
10
|
bindir: bin
|
16
11
|
cert_chain: []
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
type: :runtime
|
23
|
-
requirement: &id001 !ruby/object:Gem::Requirement
|
12
|
+
date: 2012-07-23 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: coffee-script
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
24
17
|
none: false
|
25
|
-
requirements:
|
18
|
+
requirements:
|
26
19
|
- - ~>
|
27
|
-
- !ruby/object:Gem::Version
|
28
|
-
|
29
|
-
|
30
|
-
- 2
|
31
|
-
- 2
|
32
|
-
version: "2.2"
|
33
|
-
version_requirements: *id001
|
34
|
-
name: coffee-script
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '2.2'
|
22
|
+
type: :runtime
|
35
23
|
prerelease: false
|
36
|
-
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ~>
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '2.2'
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: rails
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ~>
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '3.0'
|
37
38
|
type: :development
|
38
|
-
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
39
41
|
none: false
|
40
|
-
requirements:
|
42
|
+
requirements:
|
41
43
|
- - ~>
|
42
|
-
- !ruby/object:Gem::Version
|
43
|
-
|
44
|
-
|
45
|
-
- 1
|
46
|
-
- 0
|
47
|
-
version: "1.0"
|
48
|
-
version_requirements: *id002
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '3.0'
|
46
|
+
- !ruby/object:Gem::Dependency
|
49
47
|
name: jeweler
|
50
|
-
|
51
|
-
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
50
|
+
requirements:
|
51
|
+
- - ~>
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '1.0'
|
52
54
|
type: :development
|
53
|
-
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
54
57
|
none: false
|
55
|
-
requirements:
|
58
|
+
requirements:
|
56
59
|
- - ~>
|
57
|
-
- !ruby/object:Gem::Version
|
58
|
-
|
59
|
-
|
60
|
-
- 2
|
61
|
-
- 1
|
62
|
-
version: "2.1"
|
63
|
-
version_requirements: *id003
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '1.0'
|
62
|
+
- !ruby/object:Gem::Dependency
|
64
63
|
name: rspec
|
64
|
+
requirement: !ruby/object:Gem::Requirement
|
65
|
+
none: false
|
66
|
+
requirements:
|
67
|
+
- - ~>
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '2.6'
|
70
|
+
type: :development
|
71
|
+
prerelease: false
|
72
|
+
version_requirements: !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
74
|
+
requirements:
|
75
|
+
- - ~>
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: '2.6'
|
78
|
+
- !ruby/object:Gem::Dependency
|
79
|
+
name: rspec-rails
|
80
|
+
requirement: !ruby/object:Gem::Requirement
|
81
|
+
none: false
|
82
|
+
requirements:
|
83
|
+
- - ~>
|
84
|
+
- !ruby/object:Gem::Version
|
85
|
+
version: '2.6'
|
86
|
+
type: :development
|
65
87
|
prerelease: false
|
66
|
-
|
88
|
+
version_requirements: !ruby/object:Gem::Requirement
|
89
|
+
none: false
|
90
|
+
requirements:
|
91
|
+
- - ~>
|
92
|
+
- !ruby/object:Gem::Version
|
93
|
+
version: '2.6'
|
94
|
+
- !ruby/object:Gem::Dependency
|
95
|
+
name: rspec-core
|
96
|
+
requirement: !ruby/object:Gem::Requirement
|
97
|
+
none: false
|
98
|
+
requirements:
|
99
|
+
- - ~>
|
100
|
+
- !ruby/object:Gem::Version
|
101
|
+
version: '2.6'
|
102
|
+
type: :development
|
103
|
+
prerelease: false
|
104
|
+
version_requirements: !ruby/object:Gem::Requirement
|
105
|
+
none: false
|
106
|
+
requirements:
|
107
|
+
- - ~>
|
108
|
+
- !ruby/object:Gem::Version
|
109
|
+
version: '2.6'
|
110
|
+
- !ruby/object:Gem::Dependency
|
111
|
+
name: rdoc
|
112
|
+
requirement: !ruby/object:Gem::Requirement
|
113
|
+
none: false
|
114
|
+
requirements:
|
115
|
+
- - ~>
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '2.4'
|
67
118
|
type: :development
|
68
|
-
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
69
121
|
none: false
|
70
|
-
requirements:
|
122
|
+
requirements:
|
71
123
|
- - ~>
|
72
|
-
- !ruby/object:Gem::Version
|
73
|
-
|
74
|
-
|
75
|
-
- 1
|
76
|
-
- 0
|
77
|
-
version: "1.0"
|
78
|
-
version_requirements: *id004
|
124
|
+
- !ruby/object:Gem::Version
|
125
|
+
version: '2.4'
|
126
|
+
- !ruby/object:Gem::Dependency
|
79
127
|
name: rr
|
128
|
+
requirement: !ruby/object:Gem::Requirement
|
129
|
+
none: false
|
130
|
+
requirements:
|
131
|
+
- - ~>
|
132
|
+
- !ruby/object:Gem::Version
|
133
|
+
version: '1.0'
|
134
|
+
type: :development
|
135
|
+
prerelease: false
|
136
|
+
version_requirements: !ruby/object:Gem::Requirement
|
137
|
+
none: false
|
138
|
+
requirements:
|
139
|
+
- - ~>
|
140
|
+
- !ruby/object:Gem::Version
|
141
|
+
version: '1.0'
|
142
|
+
- !ruby/object:Gem::Dependency
|
143
|
+
name: ruby-debug
|
144
|
+
requirement: !ruby/object:Gem::Requirement
|
145
|
+
none: false
|
146
|
+
requirements:
|
147
|
+
- - ! '>='
|
148
|
+
- !ruby/object:Gem::Version
|
149
|
+
version: '0'
|
150
|
+
type: :development
|
151
|
+
prerelease: false
|
152
|
+
version_requirements: !ruby/object:Gem::Requirement
|
153
|
+
none: false
|
154
|
+
requirements:
|
155
|
+
- - ! '>='
|
156
|
+
- !ruby/object:Gem::Version
|
157
|
+
version: '0'
|
158
|
+
- !ruby/object:Gem::Dependency
|
159
|
+
name: ruby-debug19
|
160
|
+
requirement: !ruby/object:Gem::Requirement
|
161
|
+
none: false
|
162
|
+
requirements:
|
163
|
+
- - ~>
|
164
|
+
- !ruby/object:Gem::Version
|
165
|
+
version: '0.11'
|
166
|
+
type: :development
|
80
167
|
prerelease: false
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
168
|
+
version_requirements: !ruby/object:Gem::Requirement
|
169
|
+
none: false
|
170
|
+
requirements:
|
171
|
+
- - ~>
|
172
|
+
- !ruby/object:Gem::Version
|
173
|
+
version: '0.11'
|
174
|
+
description: ! 'Barista provides simple, integrated support for CoffeeScript in Rack
|
175
|
+
and Rails applications.
|
176
|
+
|
177
|
+
|
178
|
+
Much like Compass does for Sass, It also provides Frameworks (bundleable code which
|
179
|
+
can be shared via Gems).
|
180
|
+
|
181
|
+
|
182
|
+
Lastly, it also provides a Rack Application (which can be used to server compiled
|
183
|
+
code), a around_filter-style precompiler (as Rack middleware) and simple helpers
|
184
|
+
for rails and Haml.
|
185
|
+
|
186
|
+
|
187
|
+
For more details, please see the the README file bundled with it.'
|
89
188
|
email: sutto@sutto.net
|
90
189
|
executables: []
|
91
|
-
|
92
190
|
extensions: []
|
93
|
-
|
94
|
-
extra_rdoc_files:
|
191
|
+
extra_rdoc_files:
|
95
192
|
- LICENSE
|
96
193
|
- README.md
|
97
|
-
files:
|
194
|
+
files:
|
98
195
|
- .document
|
99
196
|
- .rspec
|
100
197
|
- .rvmrc.example
|
@@ -119,47 +216,41 @@ files:
|
|
119
216
|
- lib/barista/integration/sinatra.rb
|
120
217
|
- lib/barista/rake_task.rb
|
121
218
|
- lib/barista/server.rb
|
219
|
+
- lib/barista/tasks.rb
|
122
220
|
- lib/barista/tasks/barista.rake
|
123
221
|
- lib/barista/version.rb
|
124
222
|
- lib/generators/barista/install/USAGE
|
125
223
|
- lib/generators/barista/install/install_generator.rb
|
126
224
|
- lib/generators/barista/install/templates/initializer.rb
|
127
225
|
- lib/generators/barista_install_generator.rb
|
226
|
+
- spec/assets/alert.coffee
|
128
227
|
- spec/barista_spec.rb
|
129
228
|
- spec/spec_helper.rb
|
130
|
-
has_rdoc: true
|
131
229
|
homepage: http://github.com/Sutto/barista
|
132
230
|
licenses: []
|
133
|
-
|
134
231
|
post_install_message:
|
135
232
|
rdoc_options: []
|
136
|
-
|
137
|
-
require_paths:
|
233
|
+
require_paths:
|
138
234
|
- lib
|
139
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
235
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
140
236
|
none: false
|
141
|
-
requirements:
|
142
|
-
- -
|
143
|
-
- !ruby/object:Gem::Version
|
144
|
-
|
145
|
-
segments:
|
237
|
+
requirements:
|
238
|
+
- - ! '>='
|
239
|
+
- !ruby/object:Gem::Version
|
240
|
+
version: '0'
|
241
|
+
segments:
|
146
242
|
- 0
|
147
|
-
|
148
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
243
|
+
hash: -3534914020684204189
|
244
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
149
245
|
none: false
|
150
|
-
requirements:
|
151
|
-
- -
|
152
|
-
- !ruby/object:Gem::Version
|
153
|
-
|
154
|
-
segments:
|
155
|
-
- 0
|
156
|
-
version: "0"
|
246
|
+
requirements:
|
247
|
+
- - ! '>='
|
248
|
+
- !ruby/object:Gem::Version
|
249
|
+
version: '0'
|
157
250
|
requirements: []
|
158
|
-
|
159
251
|
rubyforge_project:
|
160
|
-
rubygems_version: 1.
|
252
|
+
rubygems_version: 1.8.24
|
161
253
|
signing_key:
|
162
254
|
specification_version: 3
|
163
255
|
summary: Simple, transparent coffeescript integration for Rails and Rack applications.
|
164
256
|
test_files: []
|
165
|
-
|