Class: Assette::PostProcessor::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/assette/post_processor.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(file, str = nil, args = {}) ⇒ Base

Returns a new instance of Base.



12
13
14
15
# File 'lib/assette/post_processor.rb', line 12

def initialize(file, str=nil, args={})
  @file = file
  @str = str||file.code; @args = args
end

Class Method Details

.inherited(subclass) ⇒ Object



32
33
34
35
36
37
38
# File 'lib/assette/post_processor.rb', line 32

def inherited subclass
  return if subclass == Assette::PostProcessor::Base || subclass.inspect =~ /#<Class/
  
  if outputs
    Assette::PostProcessor::POST_PROCESSORS[outputs] |= [subclass]
  end
end

.outputsObject



40
41
42
# File 'lib/assette/post_processor.rb', line 40

def outputs
  
end

.set_outputs(val) ⇒ Object

Raises:

  • (ArgumentError)


44
45
46
47
48
49
50
51
52
53
# File 'lib/assette/post_processor.rb', line 44

def set_outputs val
  raise ArgumentError, 'must set outputs to a symbol' unless val.is_a?(Symbol)
  
  instance_eval <<-RUBY
  def outputs
    #{val.inspect}
  end
  RUBY
  val
end

Instance Method Details

#processObject



25
26
27
28
29
# File 'lib/assette/post_processor.rb', line 25

def process
  return @str unless should_process?
  
  processor
end

#processorObject

Raises:

  • (Exception)


21
22
23
# File 'lib/assette/post_processor.rb', line 21

def processor
  raise Exception, "You must implement the processor method for #{self.class.inspect} (you can use the @str)"
end

#should_process?Boolean

Returns:

  • (Boolean)


17
18
19
# File 'lib/assette/post_processor.rb', line 17

def should_process?
  true
end