class TinyMCE::JsonManifest
def self.try(manifest_path)
def self.try(manifest_path) paths = Dir[File.join(manifest_path, "manifest*.json")] new(paths.first) if paths.any? end
def append(logical_path, file)
def append(logical_path, file) stat = File.stat(file) @manifest["assets"][logical_path] = logical_path @manifest["files"][logical_path] = { "logical_path" => logical_path, "mtime" => stat.mtime.iso8601, "size" => stat.size, "digest" => nil } end
def dump
def dump MultiJson.dump(@manifest) end
def each(pattern)
def each(pattern) @manifest["assets"].each_key do |asset| yield asset if asset =~ pattern end end
def initialize(file)
def initialize(file) @file = file @manifest = MultiJson.load(File.read(file)) end
def remove(logical_path)
def remove(logical_path) if digested = @manifest["assets"].delete(logical_path) @manifest["files"].delete(digested) end end
def remove_digest(logical_path)
def remove_digest(logical_path) if digested = @manifest["assets"][logical_path] @manifest["assets"][logical_path] = logical_path @manifest["files"][logical_path] = @manifest["files"].delete(digested).tap { |f| f["digest"] = nil } yield digested, logical_path if block_given? end end
def to_s
def to_s dump end
def write
def write File.open(@file, "wb") { |f| f.write(dump) } end