Class: Browsable::AssetPipeline
- Inherits:
-
Object
- Object
- Browsable::AssetPipeline
- Defined in:
- lib/browsable/asset_pipeline.rb
Overview
Identifies which Rails asset pipeline (Propshaft, Sprockets, both, or neither) is in use for a project. Reported in the audit header so the user sees at a glance which pipeline browsable inferred — and surfaced in the JSON output so editor integrations and CI can branch on it.
Detection prefers a live ‘defined?` check (set when running inside the host Rails process, e.g. via the railtie or a rake task). Standalone CLI runs never load the host app, so the fallback inspects the project’s Gemfile.lock — the canonical record of which asset-pipeline gem the app actually uses.
Constant Summary collapse
- PROPSHAFT =
"propshaft"- SPROCKETS =
"sprockets"- BOTH =
"sprockets+propshaft"- NONE =
"none"
Instance Attribute Summary collapse
-
#root ⇒ Object
readonly
Returns the value of attribute root.
Class Method Summary collapse
-
.detect(root:) ⇒ Object
Build a pipeline descriptor for the project at ‘root`.
Instance Method Summary collapse
-
#initialize(root:) ⇒ AssetPipeline
constructor
A new instance of AssetPipeline.
-
#name ⇒ Object
One of PROPSHAFT, SPROCKETS, BOTH, NONE.
- #none? ⇒ Boolean
-
#prefer_sprockets_layout? ⇒ Boolean
When both pipelines are loaded (typical during a Propshaft migration), prefer Sprockets-style discovery — its source tree is the broader superset, so its globs match everything Propshaft would have found too.
- #propshaft? ⇒ Boolean
- #sprockets? ⇒ Boolean
Constructor Details
#initialize(root:) ⇒ AssetPipeline
Returns a new instance of AssetPipeline.
27 28 29 |
# File 'lib/browsable/asset_pipeline.rb', line 27 def initialize(root:) @root = File.(root) end |
Instance Attribute Details
#root ⇒ Object (readonly)
Returns the value of attribute root.
25 26 27 |
# File 'lib/browsable/asset_pipeline.rb', line 25 def root @root end |
Class Method Details
.detect(root:) ⇒ Object
Build a pipeline descriptor for the project at ‘root`.
21 22 23 |
# File 'lib/browsable/asset_pipeline.rb', line 21 def self.detect(root:) new(root: root) end |
Instance Method Details
#name ⇒ Object
One of PROPSHAFT, SPROCKETS, BOTH, NONE.
32 33 34 |
# File 'lib/browsable/asset_pipeline.rb', line 32 def name @name ||= identify end |
#prefer_sprockets_layout? ⇒ Boolean
When both pipelines are loaded (typical during a Propshaft migration), prefer Sprockets-style discovery — its source tree is the broader superset, so its globs match everything Propshaft would have found too.
43 |
# File 'lib/browsable/asset_pipeline.rb', line 43 def prefer_sprockets_layout? = sprockets? |