dragonfly_svg 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 535a838609a37371bc692cd6a18581fb6ee4e7be
|
4
|
+
data.tar.gz: 00c687d365a5b7600ec2ad7a3f0ebc28750e5511
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f313203428612c6bd4a44a47912bfcf236703939124f1305126242e7597729dff33e5e87ca6daf30f2c03903fb2dc99fe738737a099b4dd8b4ca88b9e2a5bd81
|
7
|
+
data.tar.gz: 84dad19fc19dbb7a62af87c4457eb0b91d44b35a86492222b9d2bac48bbfe72b36acea8753830c32a995a33bce75712bd6726f9b77beb0f9f968c9bb7a7c7284
|
data/lib/dragonfly_svg/plugin.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
require 'dragonfly_svg/analysers/svg_properties'
|
2
2
|
require 'dragonfly_svg/processors/extend_ids'
|
3
3
|
require 'dragonfly_svg/processors/remove_namespaces'
|
4
|
+
require 'dragonfly_svg/processors/set_attribute'
|
4
5
|
require 'dragonfly_svg/processors/set_dimensions'
|
5
6
|
require 'dragonfly_svg/processors/set_namespace'
|
6
7
|
require 'dragonfly_svg/processors/set_preserve_aspect_ratio'
|
@@ -38,6 +39,7 @@ module DragonflySvg
|
|
38
39
|
|
39
40
|
app.add_processor :extend_ids, DragonflySvg::Processors::ExtendIds.new
|
40
41
|
app.add_processor :remove_namespaces, DragonflySvg::Processors::RemoveNamespaces.new
|
42
|
+
app.add_processor :set_attribute, DragonflySvg::Processors::SetAttribute.new
|
41
43
|
app.add_processor :set_dimensions, DragonflySvg::Processors::SetDimensions.new
|
42
44
|
app.add_processor :set_namespace, DragonflySvg::Processors::SetNamespace.new
|
43
45
|
app.add_processor :set_preserve_aspect_ratio, DragonflySvg::Processors::SetPreserveAspectRatio.new
|
@@ -47,4 +49,4 @@ module DragonflySvg
|
|
47
49
|
end
|
48
50
|
end
|
49
51
|
|
50
|
-
Dragonfly::App.register_plugin(:svg) { DragonflySvg::Plugin.new }
|
52
|
+
Dragonfly::App.register_plugin(:svg) { DragonflySvg::Plugin.new }
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require 'nokogiri'
|
2
|
+
|
3
|
+
module DragonflySvg
|
4
|
+
module Processors
|
5
|
+
class SetAttribute
|
6
|
+
|
7
|
+
def call content, xpath, attribute_name, value
|
8
|
+
doc = Nokogiri::XML(content.data)
|
9
|
+
|
10
|
+
doc.xpath(xpath).each do |node|
|
11
|
+
node.set_attribute attribute_name, value
|
12
|
+
end
|
13
|
+
|
14
|
+
content.update(doc.to_xml)
|
15
|
+
end
|
16
|
+
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
module DragonflySvg
|
4
|
+
module Processors
|
5
|
+
describe SetAttribute do
|
6
|
+
|
7
|
+
let(:app) { test_app.configure_with(:svg) }
|
8
|
+
let(:processor) { DragonflySvg::Processors::SetAttribute.new }
|
9
|
+
let(:analyser) { DragonflySvg::Analysers::SvgProperties.new }
|
10
|
+
let(:svg) { Dragonfly::Content.new(app, SAMPLES_DIR.join('sample.svg')) }
|
11
|
+
|
12
|
+
let(:xpath) { "./*[name()='svg']" }
|
13
|
+
let(:attribute_name) { 'style' }
|
14
|
+
let(:value) { 'margin: 50px;' }
|
15
|
+
|
16
|
+
before do
|
17
|
+
processor.call(svg, xpath, attribute_name, value)
|
18
|
+
end
|
19
|
+
|
20
|
+
it 'sets attribute' do
|
21
|
+
Nokogiri::XML(svg.data).xpath(xpath).count.must_equal 1
|
22
|
+
Nokogiri::XML(svg.data).xpath(xpath).first.get_attribute('style').must_equal value
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dragonfly_svg
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tomas Celizna
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-10-
|
11
|
+
date: 2015-10-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: dragonfly
|
@@ -129,6 +129,7 @@ files:
|
|
129
129
|
- lib/dragonfly_svg/plugin.rb
|
130
130
|
- lib/dragonfly_svg/processors/extend_ids.rb
|
131
131
|
- lib/dragonfly_svg/processors/remove_namespaces.rb
|
132
|
+
- lib/dragonfly_svg/processors/set_attribute.rb
|
132
133
|
- lib/dragonfly_svg/processors/set_dimensions.rb
|
133
134
|
- lib/dragonfly_svg/processors/set_namespace.rb
|
134
135
|
- lib/dragonfly_svg/processors/set_preserve_aspect_ratio.rb
|
@@ -139,6 +140,7 @@ files:
|
|
139
140
|
- test/dragonfly_svg/plugin_test.rb
|
140
141
|
- test/dragonfly_svg/processors/extend_ids_test.rb
|
141
142
|
- test/dragonfly_svg/processors/remove_namespaces_test.rb
|
143
|
+
- test/dragonfly_svg/processors/set_attribute_test.rb
|
142
144
|
- test/dragonfly_svg/processors/set_dimensions_test.rb
|
143
145
|
- test/dragonfly_svg/processors/set_namespace_test.rb
|
144
146
|
- test/dragonfly_svg/processors/set_preserve_aspect_ratio_test.rb
|
@@ -173,6 +175,7 @@ test_files:
|
|
173
175
|
- test/dragonfly_svg/plugin_test.rb
|
174
176
|
- test/dragonfly_svg/processors/extend_ids_test.rb
|
175
177
|
- test/dragonfly_svg/processors/remove_namespaces_test.rb
|
178
|
+
- test/dragonfly_svg/processors/set_attribute_test.rb
|
176
179
|
- test/dragonfly_svg/processors/set_dimensions_test.rb
|
177
180
|
- test/dragonfly_svg/processors/set_namespace_test.rb
|
178
181
|
- test/dragonfly_svg/processors/set_preserve_aspect_ratio_test.rb
|