class TinyMCE::Rails::JsonManifest
Public Class Methods
new(file)
click to toggle source
# File lib/tinymce/rails/asset_manifest.rb, line 83 def initialize(file) @file = file @manifest = JSON.parse(File.read(file)) end
try(manifest_path, pattern)
click to toggle source
# File lib/tinymce/rails/asset_manifest.rb, line 78 def self.try(manifest_path, pattern) paths = Dir[File.join(manifest_path, pattern)] new(paths.first) if paths.any? end
Public Instance Methods
append(logical_path, file)
click to toggle source
# File lib/tinymce/rails/asset_manifest.rb, line 88 def append(logical_path, file) stat = File.stat(file) assets[logical_path] = logical_path files[logical_path] = { "logical_path" => logical_path, "mtime" => stat.mtime.iso8601, "size" => stat.size, "digest" => nil } end
assets()
click to toggle source
# File lib/tinymce/rails/asset_manifest.rb, line 115 def assets @manifest["assets"] end
dump()
click to toggle source
# File lib/tinymce/rails/asset_manifest.rb, line 123 def dump JSON.generate(@manifest) end
files()
click to toggle source
# File lib/tinymce/rails/asset_manifest.rb, line 119 def files @manifest["files"] end
remove(logical_path)
click to toggle source
# File lib/tinymce/rails/asset_manifest.rb, line 100 def remove(logical_path) if digested = assets.delete(logical_path) files.delete(digested) end end
remove_digest(logical_path) { |digested, logical_path| ... }
click to toggle source
# File lib/tinymce/rails/asset_manifest.rb, line 106 def remove_digest(logical_path) asset_path(logical_path) do |digested, logical_path| assets[logical_path] = logical_path files[logical_path] = files.delete(digested).tap { |f| f["digest"] = nil } yield digested, logical_path if block_given? end end
write()
click to toggle source
# File lib/tinymce/rails/asset_manifest.rb, line 127 def write File.open(@file, "wb") { |f| f.write(dump) } end