Class: TinyMCE::Rails::NewPropshaftManifest

Inherits:
AssetManifest show all
Defined in:
lib/tinymce/rails/asset_manifest/new_propshaft_manifest.rb

Instance Attribute Summary

Attributes inherited from AssetManifest

#file

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from AssetManifest

#asset_path, #each, load, #to_s

Constructor Details

#initialize(file) ⇒ NewPropshaftManifest

Returns a new instance of NewPropshaftManifest.



10
11
12
13
# File 'lib/tinymce/rails/asset_manifest/new_propshaft_manifest.rb', line 10

def initialize(file)
  @file = file
  @manifest = Propshaft::Manifest.from_path(Pathname.new(file))
end

Class Method Details

.try(manifest_path) ⇒ Object



4
5
6
7
8
# File 'lib/tinymce/rails/asset_manifest/new_propshaft_manifest.rb', line 4

def self.try(manifest_path)
  return unless defined?(Propshaft::Manifest)
  json_file = File.join(manifest_path, ".manifest.json")
  new(json_file) if File.exist?(json_file)
end

Instance Method Details

#append(logical_path, file) ⇒ Object



15
16
17
18
19
20
21
22
# File 'lib/tinymce/rails/asset_manifest/new_propshaft_manifest.rb', line 15

def append(logical_path, file)
  entry = Propshaft::Manifest::ManifestEntry.new(
    logical_path: logical_path,
    digested_path: logical_path,
    integrity: nil
  )
  @manifest.push(entry)
end

#assetsObject



36
37
38
# File 'lib/tinymce/rails/asset_manifest/new_propshaft_manifest.rb', line 36

def assets
  @manifest.transform_values(&:digested_path)
end

#dumpObject



40
41
42
# File 'lib/tinymce/rails/asset_manifest/new_propshaft_manifest.rb', line 40

def dump
  @manifest.to_json
end

#remove(logical_path) ⇒ Object



24
25
26
# File 'lib/tinymce/rails/asset_manifest/new_propshaft_manifest.rb', line 24

def remove(logical_path)
  @manifest.delete(logical_path)
end

#remove_digest(logical_path) ⇒ Object



28
29
30
31
32
33
34
# File 'lib/tinymce/rails/asset_manifest/new_propshaft_manifest.rb', line 28

def remove_digest(logical_path)
  asset_path(logical_path) do |digested, logical_path|
    append(logical_path, nil)

    yield digested, logical_path if block_given?
  end
end

#writeObject



44
45
46
# File 'lib/tinymce/rails/asset_manifest/new_propshaft_manifest.rb', line 44

def write
  File.open(@file, "wb") { |f| f.write(dump) }
end