Class: Super::Assets
- Inherits:
-
Object
- Object
- Super::Assets
- Defined in:
- lib/super/assets.rb
Class Method Summary collapse
- .auto ⇒ Object
- .dist(gem_name, package_name) ⇒ Object
- .none ⇒ Object
- .sprockets ⇒ Object
- .sprockets_available? ⇒ Boolean
- .webpacker ⇒ Object
Instance Method Summary collapse
-
#initialize(asset_handler) ⇒ Assets
constructor
A new instance of Assets.
- #none? ⇒ Boolean
- #sprockets? ⇒ Boolean
- #webpacker? ⇒ Boolean
Constructor Details
#initialize(asset_handler) ⇒ Assets
Returns a new instance of Assets.
46 47 48 |
# File 'lib/super/assets.rb', line 46 def initialize(asset_handler) @asset_handler = asset_handler end |
Class Method Details
.auto ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/super/assets.rb', line 17 def self.auto @auto ||= if Gem::Dependency.new("sprockets", "~> 4.0").matching_specs.any? sprockets elsif Gem::Dependency.new("sprockets", "~> 3.0").matching_specs.any? sprockets elsif Gem::Dependency.new("sprockets", "~> 2.0").matching_specs.any? sprockets elsif Gem::Dependency.new("webpacker", "~> 4.0").matching_specs.any? webpacker elsif Gem::Dependency.new("webpacker", "~> 3.0").matching_specs.any? webpacker else none end end |
.dist(gem_name, package_name) ⇒ Object
7 8 9 10 11 12 13 14 15 |
# File 'lib/super/assets.rb', line 7 def self.dist(gem_name, package_name) gem_name = gem_name.to_s @gem_paths ||= {} @gem_paths[gem_name] ||= Pathname.new(Gem.loaded_specs[gem_name].full_gem_path). gem_path = @gem_paths[gem_name] gem_path.join("frontend", package_name, "dist") end |
.none ⇒ Object
42 43 44 |
# File 'lib/super/assets.rb', line 42 def self.none new(:none) end |
.sprockets ⇒ Object
34 35 36 |
# File 'lib/super/assets.rb', line 34 def self.sprockets new(:sprockets) end |
.sprockets_available? ⇒ Boolean
3 4 5 |
# File 'lib/super/assets.rb', line 3 def self.sprockets_available? Gem::Dependency.new("sprockets").matching_specs.any? end |
.webpacker ⇒ Object
38 39 40 |
# File 'lib/super/assets.rb', line 38 def self.webpacker new(:webpacker) end |
Instance Method Details
#none? ⇒ Boolean
58 59 60 |
# File 'lib/super/assets.rb', line 58 def none? @asset_handler == :none end |
#sprockets? ⇒ Boolean
50 51 52 |
# File 'lib/super/assets.rb', line 50 def sprockets? @asset_handler == :sprockets end |
#webpacker? ⇒ Boolean
54 55 56 |
# File 'lib/super/assets.rb', line 54 def webpacker? @asset_handler == :webpacker end |