Sha256: 3cce1d210512e69aab797fc7b68eebd5ef6c211d53147c1d5af279ee1593a5bc

Contents?: true

Size: 1.97 KB

Versions: 21

Compression:

Stored size: 1.97 KB

Contents

require 'rake'
require 'rake/sprocketstask'
require 'sprockets'
require 'action_view'
require 'action_view/base'

module Sprockets
  module Rails
    class Task < Rake::SprocketsTask
      attr_accessor :app

      def initialize(app = nil)
        self.app = app
        super()
      end

      def environment
        if app
          app.assets
        else
          super
        end
      end

      def output
        if app
          File.join(app.root, 'public', app.config.assets.prefix)
        else
          super
        end
      end

      def assets
        if app
          app.config.assets.precompile
        else
          super
        end
      end

      def manifest
        if app
          Sprockets::Manifest.new(index, output, app.config.assets.manifest)
        else
          super
        end
      end

      def cache_path
        if app
          "#{app.config.root}/tmp/cache/assets"
        else
          @cache_path
        end
      end
      attr_writer :cache_path

      def define
        namespace :assets do
          # Override this task change the loaded dependencies
          desc "Load asset compile environment"
          task :environment do
            # Load full Rails environment by default
            Rake::Task['environment'].invoke
          end

          desc "Compile all the assets named in config.assets.precompile"
          task :precompile => :environment do
            with_logger do
              manifest.compile(assets)
            end
          end

          desc "Remove old compiled assets"
          task :clean, [:keep] => :environment do |t, args|
            keep = Integer(args.keep || 2)
            with_logger do
              manifest.clean(keep)
            end
          end

          desc "Remove compiled assets"
          task :clobber => :environment do
            with_logger do
              manifest.clobber
              rm_rf cache_path if cache_path
            end
          end
        end
      end
    end
  end
end

Version data entries

21 entries across 20 versions & 6 rubygems

Version Path
ish_lib_manager-0.0.1 test/dummy/vendor/bundle/ruby/2.3.0/gems/sprockets-rails-2.3.3/lib/sprockets/rails/task.rb
angular-rails4-templates-0.4.1 vendor/ruby/2.1.0/gems/sprockets-rails-2.3.2/lib/sprockets/rails/task.rb
angular-rails4-templates-0.4.0 vendor/ruby/2.1.0/gems/sprockets-rails-2.3.2/lib/sprockets/rails/task.rb
angular-rails4-templates-0.3.0 vendor/ruby/2.1.0/gems/sprockets-rails-2.3.2/lib/sprockets/rails/task.rb
sc_core-0.0.7 test/dummy/vendor/bundle/ruby/2.2.0/gems/sprockets-rails-2.3.3/lib/sprockets/rails/task.rb
sprockets-rails-2.3.3 lib/sprockets/rails/task.rb
solidus_backend-1.0.0.pre3 vendor/bundle/gems/sprockets-rails-2.3.2/lib/sprockets/rails/task.rb
solidus_backend-1.0.0.pre2 vendor/bundle/gems/sprockets-rails-2.3.2/lib/sprockets/rails/task.rb
solidus_backend-1.0.0.pre vendor/bundle/gems/sprockets-rails-2.3.1/lib/sprockets/rails/task.rb
solidus_backend-1.0.0.pre vendor/bundle/gems/sprockets-rails-2.3.2/lib/sprockets/rails/task.rb
sprockets-rails-2.3.2 lib/sprockets/rails/task.rb
sprockets-rails-2.3.1 lib/sprockets/rails/task.rb
sprockets-rails-2.3.0 lib/sprockets/rails/task.rb
shoppe-paypal-1.1.0 vendor/bundle/ruby/2.1.0/gems/sprockets-rails-2.2.4/lib/sprockets/rails/task.rb
sprockets-rails-2.2.4 lib/sprockets/rails/task.rb
sprockets-rails-2.2.3 lib/sprockets/rails/task.rb
sprockets-rails-2.2.2 lib/sprockets/rails/task.rb
sprockets-rails-2.2.1 lib/sprockets/rails/task.rb
sprockets-rails-2.2.0 lib/sprockets/rails/task.rb
sprockets-rails-2.1.4 lib/sprockets/rails/task.rb