multi_xml 0.4.2 → 0.4.3
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of multi_xml might be problematic. Click here for more details.
- data/.gitignore +0 -1
- data/.travis.yml +2 -2
- data/README.md +0 -2
- data/lib/multi_xml.rb +20 -8
- data/lib/multi_xml/parsers/libxml.rb +2 -2
- data/lib/multi_xml/parsers/nokogiri.rb +2 -2
- data/lib/multi_xml/version.rb +1 -1
- data/multi_xml.gemspec +1 -1
- data/spec/helper.rb +4 -2
- metadata +5 -5
data/.gitignore
CHANGED
data/.travis.yml
CHANGED
data/README.md
CHANGED
@@ -98,10 +98,8 @@ implementations:
|
|
98
98
|
* Ruby 1.9.2
|
99
99
|
* Ruby 1.9.3
|
100
100
|
* [JRuby][]
|
101
|
-
* [Ruby Enterprise Edition][ree]
|
102
101
|
|
103
102
|
[jruby]: http://www.jruby.org/
|
104
|
-
[ree]: http://www.rubyenterpriseedition.com/
|
105
103
|
|
106
104
|
If something doesn't work on one of these interpreters, it should be considered
|
107
105
|
a bug.
|
data/lib/multi_xml.rb
CHANGED
@@ -17,8 +17,6 @@ module MultiXml
|
|
17
17
|
|
18
18
|
CONTENT_ROOT = '__content__'.freeze unless defined?(CONTENT_ROOT)
|
19
19
|
|
20
|
-
# TODO: use Time.xmlschema instead of Time.parse;
|
21
|
-
# use regexp instead of Date.parse
|
22
20
|
unless defined?(PARSING)
|
23
21
|
PARSING = {
|
24
22
|
'symbol' => Proc.new{|symbol| symbol.to_sym},
|
@@ -30,9 +28,9 @@ module MultiXml
|
|
30
28
|
'boolean' => Proc.new{|boolean| !%w(0 false).include?(boolean.strip)},
|
31
29
|
'string' => Proc.new{|string| string.to_s},
|
32
30
|
'yaml' => Proc.new{|yaml| YAML::load(yaml) rescue yaml},
|
33
|
-
'base64Binary' => Proc.new{|binary|
|
31
|
+
'base64Binary' => Proc.new{|binary| ::Base64.decode64(binary)},
|
34
32
|
'binary' => Proc.new{|binary, entity| parse_binary(binary, entity)},
|
35
|
-
'file' => Proc.new{|file, entity| parse_file(file, entity)}
|
33
|
+
'file' => Proc.new{|file, entity| parse_file(file, entity)},
|
36
34
|
}
|
37
35
|
|
38
36
|
PARSING.update(
|
@@ -41,12 +39,26 @@ module MultiXml
|
|
41
39
|
)
|
42
40
|
end
|
43
41
|
|
42
|
+
TYPE_NAMES = {
|
43
|
+
'Symbol' => 'symbol',
|
44
|
+
'Fixnum' => 'integer',
|
45
|
+
'Bignum' => 'integer',
|
46
|
+
'BigDecimal' => 'decimal',
|
47
|
+
'Float' => 'float',
|
48
|
+
'TrueClass' => 'boolean',
|
49
|
+
'FalseClass' => 'boolean',
|
50
|
+
'Date' => 'date',
|
51
|
+
'DateTime' => 'datetime',
|
52
|
+
'Time' => 'datetime',
|
53
|
+
'Array' => 'array',
|
54
|
+
'Hash' => 'hash'
|
55
|
+
} unless defined?(TYPE_NAMES)
|
56
|
+
|
44
57
|
class << self
|
45
58
|
# Get the current parser class.
|
46
59
|
def parser
|
47
|
-
return
|
60
|
+
return @@parser if defined?(@@parser)
|
48
61
|
self.parser = self.default_parser
|
49
|
-
@parser
|
50
62
|
end
|
51
63
|
|
52
64
|
# The default parser based on what you currently
|
@@ -79,9 +91,9 @@ module MultiXml
|
|
79
91
|
case new_parser
|
80
92
|
when String, Symbol
|
81
93
|
require "multi_xml/parsers/#{new_parser.to_s.downcase}"
|
82
|
-
|
94
|
+
@@parser = MultiXml::Parsers.const_get("#{new_parser.to_s.split('_').map{|s| s.capitalize}.join('')}")
|
83
95
|
when Class, Module
|
84
|
-
|
96
|
+
@@parser = new_parser
|
85
97
|
else
|
86
98
|
raise "Did not recognize your parser specification. Please specify either a symbol or a class."
|
87
99
|
end
|
@@ -17,11 +17,11 @@ module MultiXml
|
|
17
17
|
end
|
18
18
|
|
19
19
|
def each_child(node, &block)
|
20
|
-
node.children.each
|
20
|
+
node.children.each(&block)
|
21
21
|
end
|
22
22
|
|
23
23
|
def each_attr(node, &block)
|
24
|
-
node.attribute_nodes.each
|
24
|
+
node.attribute_nodes.each(&block)
|
25
25
|
end
|
26
26
|
|
27
27
|
def node_name(node)
|
data/lib/multi_xml/version.rb
CHANGED
data/multi_xml.gemspec
CHANGED
@@ -2,8 +2,8 @@
|
|
2
2
|
require File.expand_path('../lib/multi_xml/version', __FILE__)
|
3
3
|
|
4
4
|
Gem::Specification.new do |gem|
|
5
|
+
gem.add_development_dependency 'maruku'
|
5
6
|
gem.add_development_dependency 'rake'
|
6
|
-
gem.add_development_dependency 'rdiscount'
|
7
7
|
gem.add_development_dependency 'rspec'
|
8
8
|
gem.add_development_dependency 'simplecov'
|
9
9
|
gem.add_development_dependency 'yard'
|
data/spec/helper.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: multi_xml
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.3
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,10 +9,10 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-04-16 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
|
-
name:
|
15
|
+
name: maruku
|
16
16
|
requirement: !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
@@ -28,7 +28,7 @@ dependencies:
|
|
28
28
|
- !ruby/object:Gem::Version
|
29
29
|
version: '0'
|
30
30
|
- !ruby/object:Gem::Dependency
|
31
|
-
name:
|
31
|
+
name: rake
|
32
32
|
requirement: !ruby/object:Gem::Requirement
|
33
33
|
none: false
|
34
34
|
requirements:
|
@@ -139,7 +139,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
139
139
|
version: '0'
|
140
140
|
requirements: []
|
141
141
|
rubyforge_project:
|
142
|
-
rubygems_version: 1.8.
|
142
|
+
rubygems_version: 1.8.22
|
143
143
|
signing_key:
|
144
144
|
specification_version: 3
|
145
145
|
summary: A generic swappable back-end for XML parsing
|