crack 0.3.0 → 0.3.1
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of crack might be problematic. Click here for more details.
- data/crack.gemspec +3 -2
- data/lib/crack.rb +1 -1
- data/lib/crack/xml.rb +16 -2
- data/test/parser_test.rb +27 -0
- metadata +5 -4
data/crack.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{crack}
|
8
|
-
s.version = "0.3.
|
8
|
+
s.version = "0.3.1"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = [%q{John Nunemaker}, %q{Wynn Netherland}]
|
12
|
-
s.date = %q{2011-09-
|
12
|
+
s.date = %q{2011-09-21}
|
13
13
|
s.email = %q{nunemaker@gmail.com}
|
14
14
|
s.extra_rdoc_files = [
|
15
15
|
"LICENSE",
|
@@ -30,6 +30,7 @@ Gem::Specification.new do |s|
|
|
30
30
|
"test/data/twittersearch-ie.json",
|
31
31
|
"test/hash_test.rb",
|
32
32
|
"test/json_test.rb",
|
33
|
+
"test/parser_test.rb",
|
33
34
|
"test/string_test.rb",
|
34
35
|
"test/test_helper.rb",
|
35
36
|
"test/xml_test.rb"
|
data/lib/crack.rb
CHANGED
data/lib/crack/xml.rb
CHANGED
@@ -189,7 +189,7 @@ class REXMLUtilityNode #:nodoc:
|
|
189
189
|
end
|
190
190
|
|
191
191
|
module Crack
|
192
|
-
|
192
|
+
class REXMLParser
|
193
193
|
def self.parse(xml)
|
194
194
|
stack = []
|
195
195
|
parser = REXML::Parsers::BaseParser.new(xml)
|
@@ -215,4 +215,18 @@ module Crack
|
|
215
215
|
stack.length > 0 ? stack.pop.to_hash : {}
|
216
216
|
end
|
217
217
|
end
|
218
|
-
|
218
|
+
|
219
|
+
class XML
|
220
|
+
def self.parser
|
221
|
+
@@parser ||= REXMLParser
|
222
|
+
end
|
223
|
+
|
224
|
+
def self.parser=(parser)
|
225
|
+
@@parser = parser
|
226
|
+
end
|
227
|
+
|
228
|
+
def self.parse(xml)
|
229
|
+
parser.parse(xml)
|
230
|
+
end
|
231
|
+
end
|
232
|
+
end
|
data/test/parser_test.rb
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class ParserTest < Test::Unit::TestCase
|
4
|
+
should "default to REXMLParser" do
|
5
|
+
Crack::XML.parser.should == Crack::REXMLParser
|
6
|
+
end
|
7
|
+
|
8
|
+
context "with a custom Parser" do
|
9
|
+
class CustomParser
|
10
|
+
def self.parse(xml)
|
11
|
+
xml
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
setup do
|
16
|
+
Crack::XML.parser = CustomParser
|
17
|
+
end
|
18
|
+
|
19
|
+
should "use the custom Parser" do
|
20
|
+
Crack::XML.parse("<xml/>").should == "<xml/>"
|
21
|
+
end
|
22
|
+
|
23
|
+
teardown do
|
24
|
+
Crack::XML.parser = nil
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: crack
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 17
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 3
|
9
|
-
-
|
10
|
-
version: 0.3.
|
9
|
+
- 1
|
10
|
+
version: 0.3.1
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- John Nunemaker
|
@@ -16,7 +16,7 @@ autorequire:
|
|
16
16
|
bindir: bin
|
17
17
|
cert_chain: []
|
18
18
|
|
19
|
-
date: 2011-09-
|
19
|
+
date: 2011-09-21 00:00:00 Z
|
20
20
|
dependencies: []
|
21
21
|
|
22
22
|
description:
|
@@ -43,6 +43,7 @@ files:
|
|
43
43
|
- test/data/twittersearch-ie.json
|
44
44
|
- test/hash_test.rb
|
45
45
|
- test/json_test.rb
|
46
|
+
- test/parser_test.rb
|
46
47
|
- test/string_test.rb
|
47
48
|
- test/test_helper.rb
|
48
49
|
- test/xml_test.rb
|