Module: Barista
- Extended by:
- Extensions
- Defined in:
- lib/barista.rb,
lib/barista/hooks.rb,
lib/barista/filter.rb,
lib/barista/server.rb,
lib/barista/helpers.rb,
lib/barista/version.rb,
lib/barista/compiler.rb,
lib/barista/framework.rb,
lib/barista/rake_task.rb,
lib/barista/extensions.rb,
lib/barista/haml_filter.rb,
lib/barista/integration.rb,
lib/barista/integration/rails2.rb,
lib/barista/integration/rails3.rb,
lib/barista/integration/sinatra.rb,
lib/generators/barista/install/install_generator.rb
Defined Under Namespace
Modules: Extensions, Generators, HamlFilter, Helpers, Integration, Version
Classes: Compiler, Filter, Framework, Hooks, RakeTask, Server
Constant Summary
collapse
- Error =
Class.new(StandardError)
- CompilationError =
Class.new(Error)
- CompilerUnavailableError =
Class.new(Error)
Class Method Summary
collapse
Methods included from Extensions
included
Class Method Details
.app_root ⇒ Object
86
87
88
|
# File 'lib/barista.rb', line 86
def app_root
@app_root ||= default_for_app_root
end
|
.app_root=(value) ⇒ Object
90
91
92
|
# File 'lib/barista.rb', line 90
def app_root=(value)
@app_root = value.nil? ? nil : Pathname(value.to_s)
end
|
.change_output_prefix!(framework, prefix = nil) ⇒ Object
199
200
201
202
|
# File 'lib/barista.rb', line 199
def change_output_prefix!(framework, prefix = nil)
framework = Barista::Framework[framework] unless framework.is_a?(Barista::Framework)
framework.output_prefix = prefix if framework
end
|
.change_output_root!(framework, root) ⇒ Object
204
205
206
207
|
# File 'lib/barista.rb', line 204
def change_output_root!(framework, root)
framework = Barista::Framework[framework] unless framework.is_a?(Barista::Framework)
framework.output_root = root if framework
end
|
.compile_all!(force = false, silence_error = true) ⇒ Object
.compile_file!(file, force = false, silence_error = false) ⇒ Object
Actual tasks on the barista module.
181
182
183
|
# File 'lib/barista.rb', line 181
def compile_file!(file, force = false, silence_error = false)
Compiler.autocompile_file file, force, silence_error
end
|
65
66
67
|
# File 'lib/barista.rb', line 65
def configure
yield self if block_given?
end
|
.debug(message) ⇒ Object
217
218
219
|
# File 'lib/barista.rb', line 217
def debug(message)
logger.debug "[Barista] #{message}" if logger
end
|
.default_for_add_filter ⇒ Object
158
159
160
|
# File 'lib/barista.rb', line 158
def default_for_add_filter
local_env?
end
|
.default_for_add_preamble ⇒ Object
162
163
164
|
# File 'lib/barista.rb', line 162
def default_for_add_preamble
local_env?
end
|
.default_for_app_root ⇒ Object
137
138
139
140
141
142
143
|
# File 'lib/barista.rb', line 137
def default_for_app_root
if defined?(Rails.root)
Rails.root
else
Pathname(Dir.pwd)
end
end
|
.default_for_auto_compile ⇒ Object
174
175
176
|
# File 'lib/barista.rb', line 174
def default_for_auto_compile
true
end
|
.default_for_embedded_interpreter ⇒ Object
170
171
172
|
# File 'lib/barista.rb', line 170
def default_for_embedded_interpreter
false
end
|
.default_for_env ⇒ Object
132
133
134
135
|
# File 'lib/barista.rb', line 132
def default_for_env
return Rails.env.to_s if defined?(Rails.env)
ENV['RAILS_ENV'] || ENV['RACK_ENV'] || 'development'
end
|
.default_for_exception_on_error ⇒ Object
166
167
168
|
# File 'lib/barista.rb', line 166
def default_for_exception_on_error
true
end
|
.default_for_logger ⇒ Object
145
146
147
148
149
150
151
152
|
# File 'lib/barista.rb', line 145
def default_for_logger
if defined?(Rails.logger)
Rails.logger
else
require 'logger'
Logger.new(STDOUT)
end
end
|
.default_for_verbose ⇒ Object
154
155
156
|
# File 'lib/barista.rb', line 154
def default_for_verbose
local_env?
end
|
.each_framework(include_default = false, &blk) ⇒ Object
209
210
211
|
# File 'lib/barista.rb', line 209
def each_framework(include_default = false, &blk)
Framework.all(include_default).each(&blk)
end
|
.env ⇒ Object
69
70
71
|
# File 'lib/barista.rb', line 69
def env
@env ||= default_for_env
end
|
.env=(value) ⇒ Object
73
74
75
76
|
# File 'lib/barista.rb', line 73
def env=(value)
@env = value.to_s.strip
@env = nil if @env == ''
end
|
.hooks ⇒ Object
Hook methods
Hooks are a generic way to define blocks that are executed at run time. For a full list of hooks, see the readme.
38
39
40
|
# File 'lib/barista.rb', line 38
def hooks
@hooks ||= Hooks.new
end
|
.invoke_hook(name, *args) ⇒ Object
46
47
48
|
# File 'lib/barista.rb', line 46
def invoke_hook(name, *args)
hooks.invoke(name, *args)
end
|
.library_root ⇒ Object
29
30
31
|
# File 'lib/barista.rb', line 29
def library_root
@library_root ||= Pathname(__FILE__).dirname
end
|
.local_env? ⇒ Boolean
Default configuration options
128
129
130
|
# File 'lib/barista.rb', line 128
def local_env?
%w(test development).include? Barista.env
end
|
.logger ⇒ Object
78
79
80
|
# File 'lib/barista.rb', line 78
def logger
@logger ||= default_for_logger
end
|
.logger=(value) ⇒ Object
82
83
84
|
# File 'lib/barista.rb', line 82
def logger=(value)
@logger = value
end
|
.no_wrap! ⇒ Object
116
117
118
119
|
# File 'lib/barista.rb', line 116
def no_wrap!
deprecate! self, :no_wrap!, 'Please use bare! instead.'
bare!
end
|
.no_wrap=(value) ⇒ Object
121
122
123
124
|
# File 'lib/barista.rb', line 121
def no_wrap=(value)
deprecate! self, :no_wrap=, 'Please use bare= instead.'
self.bare = value
end
|
.no_wrap? ⇒ Boolean
111
112
113
114
|
# File 'lib/barista.rb', line 111
def no_wrap?
deprecate! self, :no_wrap?, 'Please use bare? instead.'
bare?
end
|
.on_hook(name, *args, &blk) ⇒ Object
42
43
44
|
# File 'lib/barista.rb', line 42
def on_hook(name, *args, &blk)
hooks.on(name, *args, &blk)
end
|
.output_path_for(file) ⇒ Object
213
214
215
|
# File 'lib/barista.rb', line 213
def output_path_for(file)
output_root.join(file.to_s.gsub(/^\/+/, '')).to_s.gsub(/\.coffee$/, '.js')
end
|
.output_root ⇒ Object
103
104
105
|
# File 'lib/barista.rb', line 103
def output_root
@output_root ||= app_root.join("public", "javascripts")
end
|
.output_root=(value) ⇒ Object
107
108
109
|
# File 'lib/barista.rb', line 107
def output_root=(value)
@output_root = value.nil? ? nil : Pathname(value.to_s)
end
|
.root ⇒ Object
94
95
96
|
# File 'lib/barista.rb', line 94
def root
@root ||= app_root.join("app", "coffeescripts")
end
|
.root=(value) ⇒ Object
98
99
100
101
|
# File 'lib/barista.rb', line 98
def root=(value)
@root = value.nil? ? nil : Pathname(value.to_s)
Framework.default_framework = nil
end
|