Class: Middleman::Imageoptim::Manifest

Inherits:
Object
  • Object
show all
Defined in:
lib/middleman-imageoptim/manifest.rb

Constant Summary collapse

MANIFEST_FILENAME =
'imageoptim.manifest.yml'.freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(app) ⇒ Manifest

Returns a new instance of Manifest.



8
9
10
# File 'lib/middleman-imageoptim/manifest.rb', line 8

def initialize(app)
  @app = app
end

Instance Attribute Details

#appObject (readonly)

Returns the value of attribute app.



6
7
8
# File 'lib/middleman-imageoptim/manifest.rb', line 6

def app
  @app
end

Instance Method Details

#build_and_write(new_resources) ⇒ Object



24
25
26
# File 'lib/middleman-imageoptim/manifest.rb', line 24

def build_and_write(new_resources)
  write(dump(build(new_resources)))
end

#build_dirObject



16
17
18
19
20
21
22
# 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

#pathObject



12
13
14
# File 'lib/middleman-imageoptim/manifest.rb', line 12

def path
  File.join(build_dir, MANIFEST_FILENAME)
end

#resource(key) ⇒ Object



28
29
30
# File 'lib/middleman-imageoptim/manifest.rb', line 28

def resource(key)
  resources[key.to_s]
end