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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3b85d9b461f4ce5d4cd3653458bee1c601ee1791
4
- data.tar.gz: 05ec30b4bbb13c0546b9e13e2375db1c5fc96b15
3
+ metadata.gz: 0a1d571f84ba0e717943ec4e0a197653300b3919
4
+ data.tar.gz: 4c67c76ee4d84bbbde29fa711279be827cd3a218
5
5
  SHA512:
6
- metadata.gz: 4c58f24294519ad59fcbf51e72cf2a86913d5e330349163dc4dbcd087082330462f12343256697f888cd368d97dbbbd15a0199b2026a83e30dee485c33f2e233
7
- data.tar.gz: 367deaf9db8dc2cec4d183d54f199d1631264324f91c483d88472fa34a63cffb0d77aa8fd0e0e93d6b458acad1e1991efecd9f033fdc907b56690ec9ea122dd4
6
+ metadata.gz: f37738bdeca9ed81f1d3437a58b0e2de69c7434592cf371c5fb95199509060ec545f77d86e14eb6610e5a5fb4efc95dafa1215c4dc0cb36d1da0980bd5d6639a
7
+ data.tar.gz: da4fe3492c6dd3e43d0c5e88d342ddb2f32de638da0b197f99a27bcb58225d05c2a982fc808b25785ed5978755b733e42a5e9a63a096b9cecadd868ecad2e3d4
data/README.md CHANGED
@@ -16,6 +16,8 @@ gem 'svg_pathify'
16
16
 
17
17
 
18
18
  ~~~ruby
19
+ require 'svg_pathify'
20
+
19
21
  input = %Q{<polyline points="350,75 379,161 469,161 397,215
20
22
  423,301 350,250 277,301 303,215
21
23
  231,161 321,161" />}
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.new( node ).to_path_element
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
@@ -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.parse( expect ).root, Nokogiri.parse( other ).root
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.to_enum.with_index.all?{ |ski,i| ski =~ okids[i] }
105
+ skids.to_a.uniq.sort == okids.to_a.uniq.sort
93
106
  end
94
107
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: svg_pathify
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - qhwa