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
def npm_check if app.root.join(‘package-lock.json’) && npm ls != 0 npm i end end.
- #append_path(*paths) ⇒ Object
- #clear_path ⇒ Object
- #initialize(*args) ⇒ Object
- #load_processors(*processors) ⇒ Object
- #new_context_class ⇒ Object
- #prepend_path(*paths) ⇒ Object
Instance Attribute Details
#cache ⇒ Object
Returns the value of attribute cache.
12 13 14 |
# File 'lib/condenser/environment.rb', line 12 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.
11 12 13 |
# File 'lib/condenser/environment.rb', line 11 def npm_path @npm_path end |
#path ⇒ Object (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
def npm_check
if app.root.join('package-lock.json') && npm ls != 0
npm i
end
end
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
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.(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) ⇒ Object
14 15 16 17 18 |
# File 'lib/condenser/environment.rb', line 14 def initialize(*args) @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_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
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.(path) raise ArgumentError, "Path \"#{path}\" does not exists" if !File.directory?(path) @path.unshift(path) end end |