# encoding: utf-8 module ClassyAssets class Configuration def self.configure yield self end def self.asset_digest @asset_digest.nil? ? false : @asset_digest end def self.asset_digest=(digest) @asset_digest = digest end def self.asset_host @asset_host end def self.asset_host=(host) @asset_host = host end def self.asset_paths @asset_paths || build_asset_paths end def self.asset_paths=(paths) @asset_paths = paths.to_a end def self.asset_prefix @asset_prefix || 'assets' end def self.asset_prefix=(prefix) @asset_prefix = prefix end def self.debug_mode @debug_mode.nil? ? (ENV['RACK_ENV'] == 'development') : @debug_mode end def self.debug_mode=(debug) @debug_mode = debug end def self.public_path @public_path || File.join(root_path, 'public') end def self.public_path=(path) @public_path = path end def self.root_path @root_path || '.' end def self.root_path=(path) @root_path = path end def self.sprockets new_sprockets_environment end private def self.build_asset_paths Dir.glob(File.join(root_path, asset_prefix, '*')) end def self.new_sprockets_environment @sprockets = ::Sprockets::Environment.new(root_path) asset_paths.each do |asset_path| unless @sprockets.paths.include?(asset_path) @sprockets.append_path asset_path end end @sprockets.context_class.class_eval do def asset_path(path, options = {}) ClassyAssets.asset_url_for(path) end end @sprockets end end end