Parent

TinyMCE::JsonManifest

Public Class Methods

new(file) click to toggle source
# File lib/tinymce/rails/asset_manifest.rb, line 65
def initialize(file)
  @file = file
  @manifest = MultiJson.load(File.read(file))
end
try(manifest_path) click to toggle source
# File lib/tinymce/rails/asset_manifest.rb, line 60
def self.try(manifest_path)
  paths = Dir[File.join(manifest_path, "manifest*.json")]
  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 70
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
dump() click to toggle source
# File lib/tinymce/rails/asset_manifest.rb, line 106
def dump
  MultiJson.dump(@manifest)
end
each(pattern) click to toggle source
# File lib/tinymce/rails/asset_manifest.rb, line 96
def each(pattern)
  @manifest["assets"].each_key do |asset|
    yield asset if asset =~ pattern
  end
end
remove(logical_path) click to toggle source
# File lib/tinymce/rails/asset_manifest.rb, line 82
def remove(logical_path)
  if digested = @manifest["assets"].delete(logical_path)
    @manifest["files"].delete(digested)
  end
end
remove_digest(logical_path) click to toggle source
# File lib/tinymce/rails/asset_manifest.rb, line 88
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
to_s() click to toggle source
# File lib/tinymce/rails/asset_manifest.rb, line 102
def to_s
  dump
end
write() click to toggle source
# File lib/tinymce/rails/asset_manifest.rb, line 110
def write
  File.open(@file, "wb") { |f| f.write(dump) }
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.