2012-08-10 15:35:06 +00:00
|
|
|
require 'sprockets'
|
|
|
|
require 'sprockets-vendor_gems/extend_all'
|
|
|
|
require 'pathname'
|
|
|
|
require 'sprockets/assistant/output'
|
2012-08-10 20:09:51 +00:00
|
|
|
require 'sprockets-sass'
|
|
|
|
require 'sprockets/assistant/compass'
|
2012-08-10 15:35:06 +00:00
|
|
|
|
|
|
|
module Sprockets
|
|
|
|
module Assistant
|
|
|
|
class Compiler
|
|
|
|
include Sprockets::Assistant::Output
|
|
|
|
|
|
|
|
DEFAULT_TARGET = "compiled"
|
|
|
|
|
|
|
|
def initialize(settings)
|
|
|
|
@settings = settings
|
|
|
|
@target = DEFAULT_TARGET
|
|
|
|
end
|
|
|
|
|
|
|
|
def compile
|
2012-08-10 20:09:51 +00:00
|
|
|
::Compass.configuration do |c|
|
|
|
|
c.output_style = :compressed
|
|
|
|
end
|
|
|
|
|
2012-08-10 15:35:06 +00:00
|
|
|
@env = Sprockets::Environment.new
|
|
|
|
@env.append_path('assets/javascripts')
|
|
|
|
@env.append_path('assets/stylesheets')
|
|
|
|
|
|
|
|
instance_eval(&@settings)
|
|
|
|
end
|
|
|
|
|
|
|
|
def file(name)
|
|
|
|
file_target = target.join(name)
|
|
|
|
say "#{name} => #{file_target}"
|
|
|
|
|
|
|
|
file_target.parent.mkpath
|
|
|
|
target.join(name).open('w') { |fh| fh.print @env[name].to_s }
|
|
|
|
end
|
|
|
|
|
|
|
|
def target
|
|
|
|
Pathname(@target)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|