Module: Proscenium::Manifest

Defined in:
lib/proscenium/manifest.rb

Class Method Summary collapse

Class Method Details

.[](key) ⇒ Object



46
47
48
# File 'lib/proscenium/manifest.rb', line 46

def [](key)
  loaded? ? manifest[key] : nil
end

.load!Object



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/proscenium/manifest.rb', line 14

def load!
  public_path = Rails.configuration.paths['public'].first
  self.manifest = {}
  self.loaded = false

  if Proscenium.config.manifest_path.exist?
    self.loaded = true

    JSON.parse(Proscenium.config.manifest_path.read)['outputs'].each do |outpath, details|
      next if !details.key?('entryPoint')

      outpath = outpath.delete_prefix "#{public_path}/"

      ep = details['entryPoint']
      ep = if (gem = BundledGems.paths.find { |_, v| ep.start_with? "#{v}/" })
             "@rubygems/#{gem[0]}#{ep.delete_prefix(gem[1])}"
           else
             ep.delete_prefix(Rails.root.to_s)
           end

      manifest[ep] = "/#{outpath}"
    end
  end

  manifest
end

.loaded?Boolean

Returns:

  • (Boolean)


10
11
12
# File 'lib/proscenium/manifest.rb', line 10

def loaded?
  loaded
end

.reset!Object



41
42
43
44
# File 'lib/proscenium/manifest.rb', line 41

def reset!
  self.manifest = {}
  self.loaded = false
end