polyrex-parser 0.2.5 → 0.2.6
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/polyrex-parser.rb +10 -2
- metadata +2 -2
data/lib/polyrex-parser.rb
CHANGED
@@ -31,7 +31,8 @@ class PolyrexParser
|
|
31
31
|
end
|
32
32
|
}
|
33
33
|
|
34
|
-
root_name = s
|
34
|
+
root_name, raw_attributes = s.match(/<(\w+)(\s[^\/>]+)?/).captures
|
35
|
+
attributes = get_attributes(raw_attributes) if raw_attributes
|
35
36
|
|
36
37
|
summary = RexleParser.new("<summary>#{s.fetch_summary}</summary>").to_a
|
37
38
|
|
@@ -46,7 +47,14 @@ class PolyrexParser
|
|
46
47
|
records = record_threads.map{|x| x.join; x[:record]}
|
47
48
|
end
|
48
49
|
|
49
|
-
[root_name, "",
|
50
|
+
[root_name, "", attributes, [*summary], ['records', "",{}, *records]]
|
50
51
|
end
|
51
52
|
|
53
|
+
def get_attributes(raw_attributes)
|
54
|
+
raw_attributes.scan(/(\w+\='[^']+')|(\w+\="[^"]+")/).map(&:compact).flatten.inject({}) do |r, x|
|
55
|
+
attr_name, val = x.split(/=/)
|
56
|
+
r.merge(attr_name => val[1..-2])
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
52
60
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: polyrex-parser
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.6
|
5
5
|
platform: ruby
|
6
6
|
authors: []
|
7
7
|
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2010-11-
|
12
|
+
date: 2010-11-21 00:00:00 +00:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|