Class: Propshaft::Assembly
- Inherits:
-
Object
- Object
- Propshaft::Assembly
- Defined in:
- lib/propshaft/assembly.rb
Instance Attribute Summary collapse
-
#config ⇒ Object
readonly
Returns the value of attribute config.
Instance Method Summary collapse
- #compilers ⇒ Object
-
#initialize(config) ⇒ Assembly
constructor
A new instance of Assembly.
- #load_path ⇒ Object
- #prefix ⇒ Object
- #processor ⇒ Object
- #resolver ⇒ Object
- #reveal(path_type = :logical_path) ⇒ Object
Constructor Details
#initialize(config) ⇒ Assembly
15 16 17 |
# File 'lib/propshaft/assembly.rb', line 15 def initialize(config) @config = config end |
Instance Attribute Details
#config ⇒ Object (readonly)
Returns the value of attribute config.
13 14 15 |
# File 'lib/propshaft/assembly.rb', line 13 def config @config end |
Instance Method Details
#compilers ⇒ Object
49 50 51 52 53 54 55 56 |
# File 'lib/propshaft/assembly.rb', line 49 def compilers @compilers ||= Propshaft::Compilers.new(self).tap do |compilers| Array(config.compilers).each do |(mime_type, klass)| compilers.register mime_type, klass end end end |
#load_path ⇒ Object
19 20 21 22 23 24 25 26 27 |
# File 'lib/propshaft/assembly.rb', line 19 def load_path @load_path ||= Propshaft::LoadPath.new( config.paths, compilers: compilers, version: config.version, file_watcher: config.file_watcher, integrity_hash_algorithm: config.integrity_hash_algorithm ) end |
#prefix ⇒ Object
37 38 39 40 41 42 |
# File 'lib/propshaft/assembly.rb', line 37 def prefix @prefix ||= begin prefix = config.prefix || "/" prefix.end_with?("/") ? prefix : "#{prefix}/" end end |
#processor ⇒ Object
44 45 46 47 |
# File 'lib/propshaft/assembly.rb', line 44 def processor Propshaft::Processor.new \ load_path: load_path, output_path: config.output_path, compilers: compilers, manifest_path: config.manifest_path end |
#resolver ⇒ Object
29 30 31 32 33 34 35 |
# File 'lib/propshaft/assembly.rb', line 29 def resolver @resolver ||= if config.manifest_path.exist? Propshaft::Resolver::Static.new manifest_path: config.manifest_path, prefix: config.prefix else Propshaft::Resolver::Dynamic.new load_path: load_path, prefix: config.prefix end end |
#reveal(path_type = :logical_path) ⇒ Object
58 59 60 61 62 63 64 |
# File 'lib/propshaft/assembly.rb', line 58 def reveal(path_type = :logical_path) path_type = path_type.presence_in(i[ logical_path path ]) || raise(ArgumentError, "Unknown path_type: #{path_type}") load_path.assets.collect do |asset| asset.send(path_type) end end |