polyrex 0.2.0 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (2) hide show
  1. data/lib/polyrex.rb +24 -4
  2. metadata +1 -1
data/lib/polyrex.rb CHANGED
@@ -10,17 +10,37 @@ class Polyrex
10
10
  include REXML
11
11
 
12
12
  def initialize(schema)
13
+
14
+ # -- required for the parsing feature
15
+ doc = Document.new(PolyrexSchema.new(schema).to_s)
16
+ @format_masks = XPath.match(doc.root, '//format_mask/text()').map &:to_s
17
+ schema_rpath = schema.gsub(/\[[^\]]+\]/,'')
18
+ @recordx = schema_rpath.split('/')
19
+
20
+ root_format_mask = @format_masks.shift
21
+ field_names = root_format_mask.to_s.scan(/\[!(\w+)\]/).flatten.map(&:to_sym)
22
+ @root_name = @recordx.shift
23
+
24
+ build_tree(a, new_a, 0, history)
25
+ out = scan_link(new_a)
26
+
27
+ summary = field_names.map {|x| "<%s/>" % x}.join
28
+ @doc = Document.new("<%s><summary>%s</summary></%s>" % [root_name, summary, root_name])
13
29
 
30
+ #----
31
+
14
32
  @schema = schema
15
33
 
16
34
  @id = '1'
17
- a = @schema.split('/')
18
- @root_name = a[0]
35
+ #a = @schema.split('/')
36
+ a = @recordx.clone
37
+ #@root_name = a[0]
19
38
 
20
- @doc = Document.new "<%s><summary/><records/></%s>" % ([@root_name] * 2)
39
+ #@doc = Document.new "<%s><summary/><records/></%s>" % ([@root_name] * 2)
21
40
  @parent_node = XPath.first(@doc.root,'records')
22
41
 
23
- @rpaths = (a.length).times.inject({}) {|r| r.merge ({a.join('/').gsub(/\[[^\]]+\]/,'') => a.pop}) }
42
+ #@rpaths = (a.length).times.inject({}) {|r| r.merge ({a.join('/').gsub(/\[[^\]]+\]/,'') => a.pop}) }
43
+ @rpaths = (@recordx.length).times.inject({}) {|r| r.merge ({a.join('/') => a.pop}) }
24
44
 
25
45
  names = @rpaths.to_a[0..-2].map {|k,v| [v[/.[^\[]+/], k]}
26
46
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: polyrex
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors: []
7
7