From 122b95d8beb97c16eac6f5bf20d346b68d2bc6a0 Mon Sep 17 00:00:00 2001 From: Joshua Peek Date: Mon, 29 Aug 2011 10:31:41 -0500 Subject: [PATCH] Remove deprecated methods Fixes #165 --- lib/sprockets/base.rb | 3 +- lib/sprockets/index.rb | 1 - lib/sprockets/static_compilation.rb | 78 ----------------------------- 3 files changed, 1 insertion(+), 81 deletions(-) delete mode 100644 lib/sprockets/static_compilation.rb diff --git a/lib/sprockets/base.rb b/lib/sprockets/base.rb index f20ccf644..a3f3cff59 100644 --- a/lib/sprockets/base.rb +++ b/lib/sprockets/base.rb @@ -5,7 +5,6 @@ require 'sprockets/processing' require 'sprockets/server' require 'sprockets/static_asset' -require 'sprockets/static_compilation' require 'sprockets/trail' require 'pathname' @@ -13,7 +12,7 @@ module Sprockets # `Base` class for `Environment` and `Index`. class Base include Digest - include Caching, Processing, Server, StaticCompilation, Trail + include Caching, Processing, Server, Trail # Get and set `Logger` instance. attr_accessor :logger diff --git a/lib/sprockets/index.rb b/lib/sprockets/index.rb index 2b374b2d1..bcdd433f3 100644 --- a/lib/sprockets/index.rb +++ b/lib/sprockets/index.rb @@ -17,7 +17,6 @@ def initialize(environment) @context_class = environment.context_class @cache = environment.cache @trail = environment.trail.index - @static_root = environment.static_root @digest = environment.digest @digest_class = environment.digest_class @version = environment.version diff --git a/lib/sprockets/static_compilation.rb b/lib/sprockets/static_compilation.rb deleted file mode 100644 index e61767880..000000000 --- a/lib/sprockets/static_compilation.rb +++ /dev/null @@ -1,78 +0,0 @@ -require 'sprockets/static_asset' - -require 'fileutils' -require 'pathname' - -module Sprockets - # `Caching` is an internal mixin whose public methods are exposed on - # the `Environment` and `Index` classes. - module StaticCompilation - # `static_root` is a special path where compiled assets are served - # from. This is usually set to a `/public` or `/static` directory. - # - # In a production environment, Apache or nginx should be - # configured to serve assets from the directory. - def static_root - @static_root ||= nil - end - - # Assign a static root directory. - def static_root=(root) - expire_index! - logger.warn "Sprockets::Environment#static_root is deprecated\n#{caller[0..2].join("\n")}" - @static_root = root ? Pathname.new(root) : nil - end - - # `precompile` takes a like of paths, globs, or `Regexp`s to - # compile into `static_root`. - # - # precompile "application.js", "*.css", /.+\.(png|jpg)/ - # - # This usually ran via a rake task. - def precompile(*paths) - options = paths.last.is_a?(Hash) ? paths.pop : {} - - logger.warn "Sprockets::Environment#precompile is deprecated\n#{caller[0..2].join("\n")}" - - if options[:to] - target = options[:to] - elsif static_root - warn "Sprockets::Environment#static_root is deprecated" - target = static_root - else - raise ArgumentError, "missing target" - end - - target = Pathname.new(target) - - manifest = {} - paths.each do |path| - each_logical_path do |logical_path| - if path.is_a?(Regexp) - # Match path against `Regexp` - next unless path.match(logical_path) - else - # Otherwise use fnmatch glob syntax - next unless File.fnmatch(path.to_s, logical_path) - end - - if asset = find_asset(logical_path) - manifest[logical_path] = asset.digest_path - - filename = target.join(asset.digest_path) - - # Ensure directory exists - FileUtils.mkdir_p filename.dirname - - # Write file - asset.write_to(filename) - - # Write compressed file if its a bundled asset like .js or .css - asset.write_to("#{filename}.gz") if asset.is_a?(BundledAsset) - end - end - end - manifest - end - end -end