Class: Super::Assets

Inherits:
Object
  • Object
show all
Defined in:
lib/super/assets.rb

Class Method Summary collapse

Instance Method Summary collapse

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

.autoObject



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).expand_path
  gem_path = @gem_paths[gem_name]

  gem_path.join("frontend", package_name, "dist")
end

.noneObject



42
43
44
# File 'lib/super/assets.rb', line 42

def self.none
  new(:none)
end

.sprocketsObject



34
35
36
# File 'lib/super/assets.rb', line 34

def self.sprockets
  new(:sprockets)
end

.sprockets_available?Boolean

Returns:

  • (Boolean)


3
4
5
# File 'lib/super/assets.rb', line 3

def self.sprockets_available?
  Gem::Dependency.new("sprockets").matching_specs.any?
end

.webpackerObject



38
39
40
# File 'lib/super/assets.rb', line 38

def self.webpacker
  new(:webpacker)
end

Instance Method Details

#none?Boolean

Returns:

  • (Boolean)


58
59
60
# File 'lib/super/assets.rb', line 58

def none?
  @asset_handler == :none
end

#sprockets?Boolean

Returns:

  • (Boolean)


50
51
52
# File 'lib/super/assets.rb', line 50

def sprockets?
  @asset_handler == :sprockets
end

#webpacker?Boolean

Returns:

  • (Boolean)


54
55
56
# File 'lib/super/assets.rb', line 54

def webpacker?
  @asset_handler == :webpacker
end