svg_pathify 0.1.0 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +2 -0
- data/lib/svg_pathify.rb +9 -2
- data/test/svg_pathify_test.rb +15 -2
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0a1d571f84ba0e717943ec4e0a197653300b3919
|
4
|
+
data.tar.gz: 4c67c76ee4d84bbbde29fa711279be827cd3a218
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f37738bdeca9ed81f1d3437a58b0e2de69c7434592cf371c5fb95199509060ec545f77d86e14eb6610e5a5fb4efc95dafa1215c4dc0cb36d1da0980bd5d6639a
|
7
|
+
data.tar.gz: da4fe3492c6dd3e43d0c5e88d342ddb2f32de638da0b197f99a27bcb58225d05c2a982fc808b25785ed5978755b733e42a5e9a63a096b9cecadd868ecad2e3d4
|
data/README.md
CHANGED
data/lib/svg_pathify.rb
CHANGED
@@ -43,9 +43,16 @@ module SvgPathify
|
|
43
43
|
return node if node.text?
|
44
44
|
|
45
45
|
type = CONVERTING_MAP[node.name.to_sym]
|
46
|
-
return node if type.nil?
|
47
46
|
|
48
|
-
type
|
47
|
+
if type
|
48
|
+
type.new( node ).to_path_element
|
49
|
+
else
|
50
|
+
node.dup.tap do |node|
|
51
|
+
node.children.each do |child|
|
52
|
+
child.swap convert_node( child )
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
49
56
|
end
|
50
57
|
|
51
58
|
end
|
data/test/svg_pathify_test.rb
CHANGED
@@ -62,10 +62,23 @@ class SvgPathifyTest < Test::Unit::TestCase
|
|
62
62
|
assert_xml_equal output, SvgPathify.convert( input )
|
63
63
|
end
|
64
64
|
|
65
|
+
def test_deep_search
|
66
|
+
input = %Q{<g><ellipse
|
67
|
+
rx="250" ry="100"
|
68
|
+
fill="none" stroke="blue" stroke-width="20" /></g>}
|
69
|
+
output = %Q{<g><path d="M-250 0a250,100,0,1,1,-250,1Z"
|
70
|
+
stroke-width="20"
|
71
|
+
fill="none"
|
72
|
+
stroke="blue" /></g>}
|
73
|
+
|
74
|
+
assert_xml_equal output, SvgPathify.convert( input )
|
75
|
+
|
76
|
+
end
|
77
|
+
|
65
78
|
#-----> helper
|
66
79
|
|
67
80
|
def assert_xml_equal( expect, other, msg=nil )
|
68
|
-
assert_equal Nokogiri
|
81
|
+
assert_equal Nokogiri::XML( expect, &:noblanks ).root, Nokogiri::XML( other, &:noblanks ).root
|
69
82
|
end
|
70
83
|
|
71
84
|
end
|
@@ -89,6 +102,6 @@ class Nokogiri::XML::Node
|
|
89
102
|
sns = namespace; ons = other.namespace
|
90
103
|
return false if !sns ^ !ons
|
91
104
|
return false if sns && (sns.href != ons.href)
|
92
|
-
skids.
|
105
|
+
skids.to_a.uniq.sort == okids.to_a.uniq.sort
|
93
106
|
end
|
94
107
|
end
|