12
13
14
15
16
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
|
# File 'lib/dragonfly_svg/plugin.rb', line 12
def call app, opts={}
app.add_analyser :svg_properties, DragonflySvg::Analysers::SvgProperties.new
app.add_analyser :width do |content|
content.analyse(:svg_properties)[:width]
end
app.add_analyser :height do |content|
content.analyse(:svg_properties)[:height]
end
app.add_analyser :aspect_ratio do |content|
attrs = content.analyse(:svg_properties)
attrs[:width].to_f / attrs[:height].to_f
end
app.add_analyser :portrait do |content|
attrs = content.analyse(:svg_properties)
attrs[:width] <= attrs[:height]
end
app.add_analyser :landscape do |content|
!content.analyse(:portrait)
end
app.add_analyser :id do |content|
content.analyse(:svg_properties)[:id]
end
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_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
|