Class: ReActionView::AssetManifest

Inherits:
Object
  • Object
show all
Defined in:
lib/reactionview/asset_manifest.rb

Instance Method Summary collapse

Constructor Details

#initialize(assets) ⇒ AssetManifest

Returns a new instance of AssetManifest.



7
8
9
# File 'lib/reactionview/asset_manifest.rb', line 7

def initialize(assets)
  @assets = assets
end

Instance Method Details

#exist?Boolean

Returns:

  • (Boolean)


27
28
29
# File 'lib/reactionview/asset_manifest.rb', line 27

def exist?
  !mtime.nil?
end

#explanationObject



47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
# File 'lib/reactionview/asset_manifest.rb', line 47

def explanation
  <<~MESSAGE
    ReActionView's dev tools assets are missing from your precompiled assets.
    #{status}

    To fix this, delete the precompiled assets:

        bin/rails assets:clobber

    That is safe in development. Without public/assets/, Propshaft serves each asset straight from
    the directory it lives in, including ReActionView's.

        Missing:  #{missing_assets.join(", ")}
        Manifest: #{path}

    public/assets/ was most likely left behind by `RAILS_ENV=production bin/rails assets:precompile`,
    and a production precompile doesn't include ReActionView's dev tools.
  MESSAGE
end

#in_use?Boolean

Returns:

  • (Boolean)


43
44
45
# File 'lib/reactionview/asset_manifest.rb', line 43

def in_use?
  @assets.respond_to?(:resolver) && @assets.resolver.respond_to?(:manifest_path)
end

#missing_assetsObject



31
32
33
34
35
36
37
# File 'lib/reactionview/asset_manifest.rb', line 31

def missing_assets
  precompiled = logical_paths

  return [] if precompiled.empty?

  ReActionView::Railtie::PRECOMPILE_ASSETS - precompiled
end

#mtimeObject



19
20
21
22
23
24
25
# File 'lib/reactionview/asset_manifest.rb', line 19

def mtime
  return if path.nil?

  File.mtime(path)
rescue SystemCallError
  nil
end

#pathObject



11
12
13
14
15
16
17
# File 'lib/reactionview/asset_manifest.rb', line 11

def path
  config = @assets&.config

  return unless config.respond_to?(:manifest_path)

  config.manifest_path
end

#stale?Boolean

Returns:

  • (Boolean)


39
40
41
# File 'lib/reactionview/asset_manifest.rb', line 39

def stale?
  exist? && !missing_assets.empty?
end