Class: DragonflySvg::Plugin

Inherits:
Object
  • Object
show all
Defined in:
lib/dragonfly_svg/plugin.rb

Instance Method Summary collapse

Instance Method Details

#call(app, _opts = {}) ⇒ Object



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
# File 'lib/dragonfly_svg/plugin.rb', line 20

def call(app, _opts = {})
  app.add_analyser :svg_properties, DragonflySvg::Analysers::SvgProperties.new

  DragonflySvg::Analysers::WidthAnalyser.new(app)
  DragonflySvg::Analysers::HeightAnalyser.new(app)
  DragonflySvg::Analysers::AspectRatioAnalyser.new(app)
  DragonflySvg::Analysers::PortraitAnalyser.new(app)
  DragonflySvg::Analysers::LandscapeAnalyser.new(app)

  app.add_analyser :id do |content|
    content.analyse(:svg_properties)[:id]
  end

  # Aliases
  app.define(:portrait?) { portrait }
  app.define(:landscape?) { landscape }

  app.add_processor :extend_ids, DragonflySvg::Processors::ExtendIds.new
  app.add_processor :remove_namespaces, DragonflySvg::Processors::RemoveNamespaces.new
  app.add_processor :set_attribute, DragonflySvg::Processors::SetAttribute.new
  app.add_processor :set_dimensions, DragonflySvg::Processors::SetDimensions.new
  app.add_processor :set_namespace, DragonflySvg::Processors::SetNamespace.new
  app.add_processor :set_preserve_aspect_ratio, DragonflySvg::Processors::SetPreserveAspectRatio.new
  app.add_processor :set_view_box, DragonflySvg::Processors::SetViewBox.new
end