Class: Sinatra::AssetPipeline::Task

Inherits:
Rake::SprocketsTask
  • Object
show all
Defined in:
lib/sinatra/asset_pipeline/task.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(app = nil) ⇒ Task

Returns a new instance of Task.


10
11
12
13
# File 'lib/sinatra/asset_pipeline/task.rb', line 10

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

Instance Attribute Details

#appObject

Returns the value of attribute app


8
9
10
# File 'lib/sinatra/asset_pipeline/task.rb', line 8

def app
  @app
end

Class Method Details

.define!(app) ⇒ Object


54
55
56
# File 'lib/sinatra/asset_pipeline/task.rb', line 54

def self.define!(app)
  self.new(app)
end

Instance Method Details

#assetsObject


19
20
21
# File 'lib/sinatra/asset_pipeline/task.rb', line 19

def assets
  app ? app.assets_precompile : super
end

#defineObject


27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/sinatra/asset_pipeline/task.rb', line 27

def define
  namespace :assets do
    %w( precompile clean clobber ).each { |task| Rake::Task[task].clear if Rake::Task.task_defined?(task) }

    desc "Compile all assets"
    task :precompile do
      with_logger do
        manifest.compile(assets)
      end
    end

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

    desc "Remove compiled assets"
    task :clobber do
      with_logger do
        manifest.clobber
      end
    end
  end
end

#environmentObject


15
16
17
# File 'lib/sinatra/asset_pipeline/task.rb', line 15

def environment
  app ? app.sprockets : super
end

#manifestObject


23
24
25
# File 'lib/sinatra/asset_pipeline/task.rb', line 23

def manifest
  app ? ::Sprockets::Manifest.new(environment.index, app.assets_public_path) : super
end