Module: Condenser::Environment
- Included in:
- Condenser
- Defined in:
- lib/condenser/environment.rb
Instance Attribute Summary collapse
-
#cache ⇒ Object
Returns the value of attribute cache.
-
#context_class ⇒ Object
readonly
This class maybe mutated and mixed in with custom helpers.
-
#npm_path ⇒ Object
Returns the value of attribute npm_path.
-
#path ⇒ Object
readonly
Returns the value of attribute path.
Instance Method Summary collapse
- #append_npm_path(*paths) ⇒ Object
- #append_path(*paths) ⇒ Object
- #clear_path ⇒ Object
- #initialize(*args, **kws, &block) ⇒ Object
- #load_processors(*processors) ⇒ Object
- #new_context_class ⇒ Object
- #prepend_path(*paths) ⇒ Object
Instance Attribute Details
#cache ⇒ Object
Returns the value of attribute cache.
14 15 16 |
# File 'lib/condenser/environment.rb', line 14 def cache @cache end |
#context_class ⇒ Object (readonly)
This class maybe mutated and mixed in with custom helpers.
environment.context_class.instance_eval do
include MyHelpers
def asset_url; end
end
77 78 79 |
# File 'lib/condenser/environment.rb', line 77 def context_class @context_class end |
#npm_path ⇒ Object
Returns the value of attribute npm_path.
13 14 15 |
# File 'lib/condenser/environment.rb', line 13 def npm_path @npm_path end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
13 14 15 |
# File 'lib/condenser/environment.rb', line 13 def path @path end |
Instance Method Details
#append_npm_path(*paths) ⇒ Object
56 57 58 59 60 |
# File 'lib/condenser/environment.rb', line 56 def append_npm_path(*paths) paths.flatten.each do |path| self.npm_path = path end end |
#append_path(*paths) ⇒ Object
38 39 40 41 42 43 44 |
# File 'lib/condenser/environment.rb', line 38 def append_path(*paths) paths.flatten.each do |path| path = File.(path) raise ArgumentError, "Path \"#{path}\" does not exists" if !File.directory?(path) @path.push(path) end end |
#clear_path ⇒ Object
62 63 64 |
# File 'lib/condenser/environment.rb', line 62 def clear_path @path.clear end |
#initialize(*args, **kws, &block) ⇒ Object
16 17 18 19 20 |
# File 'lib/condenser/environment.rb', line 16 def initialize(*args, **kws, &block) @loaded_processors = Set.new @context_class = Class.new(Condenser::Context) super end |
#load_processors(*processors) ⇒ Object
22 23 24 25 26 27 28 |
# File 'lib/condenser/environment.rb', line 22 def load_processors(*processors) processors.flatten! (Set.new(processors) - @loaded_processors).each do |processor| processor.setup(self) @loaded_processors << processor end end |
#new_context_class ⇒ Object
66 67 68 |
# File 'lib/condenser/environment.rb', line 66 def new_context_class context_class.new(self) end |
#prepend_path(*paths) ⇒ Object
30 31 32 33 34 35 36 |
# File 'lib/condenser/environment.rb', line 30 def prepend_path(*paths) paths.flatten.each do |path| path = File.(path) raise ArgumentError, "Path \"#{path}\" does not exists" if !File.directory?(path) @path.unshift(path) end end |