Class: Proscenium::Resolver
- Inherits:
-
ActiveSupport::CurrentAttributes
- Object
- ActiveSupport::CurrentAttributes
- Proscenium::Resolver
- Defined in:
- lib/proscenium/resolver.rb
Class Method Summary collapse
-
.resolve(path) ⇒ String
Resolve the given ‘path` to a URL path.
Class Method Details
.resolve(path) ⇒ String
Resolve the given ‘path` to a URL path.
rubocop:disable Metrics/*
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/proscenium/resolver.rb', line 16 def self.resolve(path) self.resolved ||= {} self.resolved[path] ||= begin if path.start_with?('./', '../') raise ArgumentError, 'path must be an absolute file system or URL path' end if path.start_with?('@proscenium/') "/#{path}" elsif path.start_with?(Proscenium.ui_path.to_s) path.delete_prefix Proscenium.root.join('lib').to_s elsif (engine = Proscenium.config.engines.find { |e| path.start_with? "#{e.root}/" }) path.sub(/^#{engine.root}/, "/#{engine.engine_name}") elsif path.start_with?("#{Rails.root}/") path.delete_prefix Rails.root.to_s else Builder.resolve path end end end |