lib/barista.rb in barista-0.1.0 vs lib/barista.rb in barista-0.1.1
- old
+ new
@@ -1,11 +1,12 @@
require 'active_support'
require 'pathname'
module Barista
- autoload :Compiler, 'barista/compiler'
+ autoload :Compiler, 'barista/compiler'
+ autoload :AroundFilter, 'barista/around_filter'
class << self
def root
@root ||= Rails.root.join("app", "scripts")
@@ -51,16 +52,27 @@
def compile_all!(force = false)
Dir[root.join("**", "*.coffee")].each {|file| compile_file! file, force }
true
end
+ # By default, only add it in dev / test
+ def add_filter?
+ Rails.env.test? || Rails.env.development?
+ end
+
end
if defined?(Rails::Engine)
class Engine < Rails::Engine
+
rake_tasks do
load File.expand_path('./barista/tasks/barista.rake', File.dirname(__FILE__))
end
+
+ initializer "barista.wrap_filter" do
+ ApplicationController.around_filter(Barista::AroundFilter) if Barista.add_filter?
+ end
+
end
end
end
\ No newline at end of file