Class: Rake::CondenserTask
- Inherits:
-
TaskLib
- Object
- TaskLib
- Rake::CondenserTask
- Defined in:
- lib/rake/condensertask.rb
Overview
Instance Attribute Summary collapse
-
#assets ⇒ Object
Array of asset logical paths to compile.
-
#environment ⇒ Object
‘Environment` instance used for finding assets.
-
#keep ⇒ Object
Number of old assets to keep.
-
#logger ⇒ Object
Logger to use during rake tasks.
-
#manifest ⇒ Object
‘Manifest` instance used for already compiled assets.
-
#name ⇒ Object
Name of the task.
-
#output ⇒ Object
Directory to write compiled assets too.
Instance Method Summary collapse
-
#define ⇒ Object
Define tasks.
-
#initialize(name = :assets) {|_self| ... } ⇒ CondenserTask
constructor
A new instance of CondenserTask.
Constructor Details
#initialize(name = :assets) {|_self| ... } ⇒ CondenserTask
Returns a new instance of CondenserTask.
74 75 76 77 78 79 80 81 82 83 84 |
# File 'lib/rake/condensertask.rb', line 74 def initialize(name = :assets) @name = name @environment = lambda { Condenser.new(Dir.pwd) } @manifest = lambda { Condenser::Manifest.new(environment, output) } @logger = Logger.new($stdout, level: :info) @keep = 2 yield self if block_given? define end |
Instance Attribute Details
#assets ⇒ Object
Array of asset logical paths to compile.
t.assets = %w( application.js jquery.js application.css )
63 64 65 |
# File 'lib/rake/condensertask.rb', line 63 def assets @assets end |
#environment ⇒ Object
‘Environment` instance used for finding assets.
You’ll most likely want to reassign ‘environment` to your own.
Rake::CondenserTask.new do |t|
t.environment = Foo::Assets
end
31 32 33 34 35 36 37 |
# File 'lib/rake/condensertask.rb', line 31 def environment if !@environment.is_a?(Condenser) && @environment.respond_to?(:call) @environment = @environment.call else @environment end end |
#keep ⇒ Object
Number of old assets to keep.
66 67 68 |
# File 'lib/rake/condensertask.rb', line 66 def keep @keep end |
#logger ⇒ Object
Logger to use during rake tasks. Defaults to using stderr.
t.logger = Logger.new($stdout)
72 73 74 |
# File 'lib/rake/condensertask.rb', line 72 def logger @logger end |
#manifest ⇒ Object
‘Manifest` instance used for already compiled assets.
Will be created by default if an environment and output directory are given
44 45 46 47 48 49 50 |
# File 'lib/rake/condensertask.rb', line 44 def manifest if !@manifest.is_a?(Condenser::Manifest) && @manifest.respond_to?(:call) @manifest = @manifest.call else @manifest end end |
#name ⇒ Object
Name of the task. Defaults to “assets”.
The name will also be used to suffix the clean and clobber tasks, “clean_assets” and “clobber_assets”.
21 22 23 |
# File 'lib/rake/condensertask.rb', line 21 def name @name end |
#output ⇒ Object
Directory to write compiled assets too. As well as the manifest file.
t.output = "./public/assets"
57 58 59 |
# File 'lib/rake/condensertask.rb', line 57 def output @output end |
Instance Method Details
#define ⇒ Object
Define tasks
87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 |
# File 'lib/rake/condensertask.rb', line 87 def define desc name == :assets ? "Compile assets" : "Compile #{name} assets" task name do with_logger do manifest.compile(assets) end end desc name == :assets ? "Remove all assets" : "Remove all #{name} assets" task "clobber_#{name}" do with_logger do manifest.clobber end end task :clobber => ["clobber_#{name}"] desc name == :assets ? "Clean old assets" : "Clean old #{name} assets" task "clean_#{name}" do with_logger do manifest.clean(keep) end end task :clean => ["clean_#{name}"] end |