Class: Middleman::FaviconMaker::FaviconMakerExtension

Inherits:
Extension
  • Object
show all
Defined in:
lib/middleman-favicon-maker/extension.rb

Instance Method Summary collapse

Instance Method Details

#after_build(builder) ⇒ Object



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/middleman-favicon-maker/extension.rb', line 17

def after_build(builder)

  template_files = []
  ::FaviconMaker.generate do
    setup do
      template_dir  options[:template_dir]
      output_dir    options[:output_dir]
    end

    options[:icons].each do |input_filename, icon_configs|
      from input_filename do
        icon_configs.each do |icon_config|
          icon icon_config[:icon], icon_config
        end
      end
    end

    each_icon do |filepath, template_filepath|
      pathname = Pathname.new(filepath)
      rel_path =
        if pathname.absolute?
          pathname.relative_path_from(Pathname.new(app.root)).to_s
        else
          filepath
        end
      builder.trigger(:created, rel_path)
    end
  end

end

#after_configurationObject



12
13
14
15
# File 'lib/middleman-favicon-maker/extension.rb', line 12

def after_configuration
  options[:template_dir] ||= source_path
  options[:output_dir]   ||= build_path
end