class JsonManifest
Public Class Methods
new(file)
click to toggle source
# File lib/neditor_rails/asset_manifest.rb, line 64 def initialize(file) @file = file @manifest = MultiJson.load(File.read(file)) end
try(manifest_path)
click to toggle source
# File lib/neditor_rails/asset_manifest.rb, line 59 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/neditor_rails/asset_manifest.rb, line 69 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/neditor_rails/asset_manifest.rb, line 105 def dump MultiJson.dump(@manifest) end
each(pattern) { |asset| ... }
click to toggle source
# File lib/neditor_rails/asset_manifest.rb, line 95 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/neditor_rails/asset_manifest.rb, line 81 def remove(logical_path) if digested = @manifest["assets"].delete(logical_path) @manifest["files"].delete(digested) end end
remove_digest(logical_path) { |digested, logical_path| ... }
click to toggle source
# File lib/neditor_rails/asset_manifest.rb, line 87 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/neditor_rails/asset_manifest.rb, line 101 def to_s dump end
write()
click to toggle source
# File lib/neditor_rails/asset_manifest.rb, line 109 def write File.open(@file, "wb") { |f| f.write(dump) } end