class Middleman::Imageoptim::Manifest
Constants
- MANIFEST_FILENAME
Attributes
app[R]
Public Class Methods
new(app)
click to toggle source
# File lib/middleman-imageoptim/manifest.rb, line 8 def initialize(app) @app = app end
Public Instance Methods
build_and_write(new_resources)
click to toggle source
# File lib/middleman-imageoptim/manifest.rb, line 24 def build_and_write(new_resources) write(dump(build(new_resources))) end
build_dir()
click to toggle source
# File lib/middleman-imageoptim/manifest.rb, line 16 def build_dir if Gem::Version.new(Middleman::VERSION) >= Gem::Version.new('4.0.0') app.config[:build_dir] else app.build_dir end end
path()
click to toggle source
# File lib/middleman-imageoptim/manifest.rb, line 12 def path File.join(build_dir, MANIFEST_FILENAME) end
resource(key)
click to toggle source
# File lib/middleman-imageoptim/manifest.rb, line 28 def resource(key) resources[key.to_s] end
Private Instance Methods
build(resources)
click to toggle source
# File lib/middleman-imageoptim/manifest.rb, line 46 def build(resources) resources.inject({}) do |new_manifest, resource| new_manifest[resource.to_s] = File.mtime(resource) new_manifest end end
dump(source)
click to toggle source
# File lib/middleman-imageoptim/manifest.rb, line 38 def dump(source) YAML.dump(source) end
load(path)
click to toggle source
# File lib/middleman-imageoptim/manifest.rb, line 42 def load(path) YAML.load(File.read(path)) end
resources()
click to toggle source
# File lib/middleman-imageoptim/manifest.rb, line 34 def resources @resources ||= load(path) end
write(manifest)
click to toggle source
# File lib/middleman-imageoptim/manifest.rb, line 53 def write(manifest) File.open(path, 'w') do |manifest_file| manifest_file.write(manifest) end end