Module: Condenser::Environment

Included in:
Condenser
Defined in:
lib/condenser/environment.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#cacheObject

Returns the value of attribute cache.



12
13
14
# File 'lib/condenser/environment.rb', line 12

def cache
  @cache
end

#context_classObject (readonly)

This class maybe mutated and mixed in with custom helpers.

environment.context_class.instance_eval do
  include MyHelpers
  def asset_url; end
end


75
76
77
# File 'lib/condenser/environment.rb', line 75

def context_class
  @context_class
end

#npm_pathObject

Returns the value of attribute npm_path.



11
12
13
# File 'lib/condenser/environment.rb', line 11

def npm_path
  @npm_path
end

#pathObject (readonly)

Returns the value of attribute path.



11
12
13
# File 'lib/condenser/environment.rb', line 11

def path
  @path
end

Instance Method Details

#append_npm_path(*paths) ⇒ Object



54
55
56
57
58
# File 'lib/condenser/environment.rb', line 54

def append_npm_path(*paths)
  paths.flatten.each do |path|
    self.npm_path = path
  end
end

#append_path(*paths) ⇒ Object



36
37
38
39
40
41
42
# File 'lib/condenser/environment.rb', line 36

def append_path(*paths)
  paths.flatten.each do |path|
    path = File.expand_path(path)
    raise ArgumentError, "Path \"#{path}\" does not exists" if !File.directory?(path)
    @path.push(path)
  end
end

#clear_pathObject



60
61
62
# File 'lib/condenser/environment.rb', line 60

def clear_path
  @path.clear
end

#initialize(*args, **kws, &block) ⇒ Object



14
15
16
17
18
# File 'lib/condenser/environment.rb', line 14

def initialize(*args, **kws, &block)
  @loaded_processors = Set.new
  @context_class = Class.new(Condenser::Context)
  super
end

#load_processors(*processors) ⇒ Object



20
21
22
23
24
25
26
# File 'lib/condenser/environment.rb', line 20

def load_processors(*processors)
  processors.flatten!
  (Set.new(processors) - @loaded_processors).each do |processor|
    processor.setup(self)
    @loaded_processors << processor
  end
end

#new_context_classObject



64
65
66
# File 'lib/condenser/environment.rb', line 64

def new_context_class
  context_class.new(self)
end

#prepend_path(*paths) ⇒ Object



28
29
30
31
32
33
34
# File 'lib/condenser/environment.rb', line 28

def prepend_path(*paths)
  paths.flatten.each do |path|
    path = File.expand_path(path)
    raise ArgumentError, "Path \"#{path}\" does not exists" if !File.directory?(path)
    @path.unshift(path)
  end
end