Skip to content

Commit e3da121

Browse files
committed
Remove support for symbol and yaml.
1 parent b1b1658 commit e3da121

File tree

2 files changed

+11
-20
lines changed

2 files changed

+11
-20
lines changed

lib/crack/xml.rb

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,7 @@ def self.available_typecasts=(obj)
4040
self.typecasts["decimal"] = lambda{|v| v.nil? ? nil : BigDecimal(v.to_s)}
4141
self.typecasts["double"] = lambda{|v| v.nil? ? nil : v.to_f}
4242
self.typecasts["float"] = lambda{|v| v.nil? ? nil : v.to_f}
43-
self.typecasts["symbol"] = lambda{|v| v.nil? ? nil : v.to_sym}
4443
self.typecasts["string"] = lambda{|v| v.to_s}
45-
self.typecasts["yaml"] = lambda{|v| v.nil? ? nil : YAML.load(v)}
4644
self.typecasts["base64Binary"] = lambda{|v| v.unpack('m').first }
4745

4846
self.available_typecasts = self.typecasts.keys

test/xml_test.rb

Lines changed: 11 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -65,10 +65,10 @@ class XmlTest < Test::Unit::TestCase
6565
}
6666
}
6767
}
68-
68+
6969
Crack::XML.parse(xml).should == hash
7070
end
71-
71+
7272
context "Parsing xml with text and attributes" do
7373
setup do
7474
xml =<<-XML
@@ -90,20 +90,20 @@ class XmlTest < Test::Unit::TestCase
9090
}
9191
}
9292
end
93-
93+
9494
should "be parse attributes for text node if present" do
9595
@data['opt']['user'][0].attributes.should == {'login' => 'grep'}
9696
end
97-
97+
9898
should "default attributes to empty hash if not present" do
9999
@data['opt']['user'][1].attributes.should == {}
100100
end
101-
101+
102102
should "add 'attributes' accessor methods to parsed instances of String" do
103103
@data['opt']['user'][0].respond_to?(:attributes).should be(true)
104104
@data['opt']['user'][0].respond_to?(:attributes=).should be(true)
105105
end
106-
106+
107107
should "not add 'attributes' accessor methods to all instances of String" do
108108
"some-string".respond_to?(:attributes).should be(false)
109109
"some-string".respond_to?(:attributes=).should be(false)
@@ -149,7 +149,7 @@ class XmlTest < Test::Unit::TestCase
149149
Crack::XML.parse(xml)['tag'].should =~ Regexp.new(k)
150150
end
151151
end
152-
152+
153153
should "should unescape XML entities in attributes" do
154154
xml_entities.each do |k,v|
155155
xml = "<tag attr='Some content #{v}'></tag>"
@@ -226,7 +226,6 @@ class XmlTest < Test::Unit::TestCase
226226
<approved type="boolean"></approved>
227227
<written-on type="date"></written-on>
228228
<viewed-at type="datetime"></viewed-at>
229-
<content type="yaml"></content>
230229
<parent-id></parent-id>
231230
</topic>
232231
EOT
@@ -237,7 +236,6 @@ class XmlTest < Test::Unit::TestCase
237236
'approved' => nil,
238237
'written_on' => nil,
239238
'viewed_at' => nil,
240-
'content' => nil,
241239
'parent_id' => nil
242240
}
243241
Crack::XML.parse(topic_xml)["topic"].should == expected_topic_hash
@@ -254,7 +252,6 @@ class XmlTest < Test::Unit::TestCase
254252
<replies-close-in type="integer">2592000000</replies-close-in>
255253
<written-on type="date">2003-07-16</written-on>
256254
<viewed-at type="datetime">2003-07-16T09:28:00+0000</viewed-at>
257-
<content type="yaml">--- \n1: should be an integer\n:message: Have a nice day\narray: \n- should-have-dashes: true\n should_have_underscores: true\n</content>
258255
<author-email-address>david@loudthinking.com</author-email-address>
259256
<parent-id></parent-id>
260257
<ad-revenue type="decimal">1.5</ad-revenue>
@@ -272,15 +269,11 @@ class XmlTest < Test::Unit::TestCase
272269
'replies_close_in' => 2592000000,
273270
'written_on' => Date.new(2003, 7, 16),
274271
'viewed_at' => Time.utc(2003, 7, 16, 9, 28),
275-
# Changed this line where the key is :message. The yaml specifies this as a symbol, and who am I to change what you specify
276-
# The line in ActiveSupport is
277-
# 'content' => { 'message' => "Have a nice day", 1 => "should be an integer", "array" => [{ "should-have-dashes" => true, "should_have_underscores" => true }] },
278-
'content' => { :message => "Have a nice day", 1 => "should be an integer", "array" => [{ "should-have-dashes" => true, "should_have_underscores" => true }] },
279272
'author_email_address' => "david@loudthinking.com",
280273
'parent_id' => nil,
281274
'ad_revenue' => BigDecimal("1.50"),
282275
'optimum_viewing_angle' => 135.0,
283-
'resident' => :yes
276+
'resident' => 'yes',
284277
}
285278

286279
Crack::XML.parse(topic_xml)["topic"].each do |k,v|
@@ -487,13 +480,13 @@ class XmlTest < Test::Unit::TestCase
487480

488481
Crack::XML.parse(xml_string)['person'].should == expected_hash
489482
end
490-
483+
491484
should "handle an empty xml string" do
492485
Crack::XML.parse('').should == {}
493486
end
494-
487+
495488
# As returned in the response body by the unfuddle XML API when creating objects
496489
should "handle an xml string containing a single space" do
497490
Crack::XML.parse(' ').should == {}
498491
end
499-
end
492+
end

0 commit comments

Comments
 (0)