sectionx 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: da2ae5c8906f2102271de0439a7dcfc56ff235c6
4
- data.tar.gz: bd62157e807121471bccce203ad400120e9ccddc
3
+ metadata.gz: b4bd92b053d2aeaf1a0a68e3bb97b4c851226843
4
+ data.tar.gz: 59a728bd1f0f65b8a8e7e3111ec131fb350db8d4
5
5
  SHA512:
6
- metadata.gz: 42d1026da11df9e1eeb5a4404bc085d0d3a1a5712fcc8eda446c704be32ad9d2d30eab55ab20214dd965b69ea195d3a5e72367e2327d01388971b1945b6c8756
7
- data.tar.gz: 7f6524a59b743501cf3041e030249b79e596eb0803bd13d3767cb7cfc61634d15d99734b81d718024229026526bc5f14e6da23f9f83524ef0546fd71153cb0e6
6
+ metadata.gz: 760da76cb64b8554f34f64c2287c192f9a1520b320b58fc6ec0a79c8ceb6845a2b1884a03c06042d6ae034123cd3c58ba7c89d507b0288e6f763292a1eb618aa
7
+ data.tar.gz: 01b9a9640026eb6d0ca73e5b255d9bf589ea387b21a7e2c8bf13a477585c0c0cd481298b25bea22be4b72d8130b6029584eb3117605e5c1e57a977b2a09daea8
checksums.yaml.gz.sig CHANGED
Binary file
data/lib/sectionx.rb CHANGED
@@ -4,16 +4,21 @@
4
4
 
5
5
  require 'line-tree'
6
6
  require 'rexle-builder'
7
+ require 'rxfhelper'
7
8
 
8
9
 
9
10
  class SectionX
10
11
 
12
+ attr_reader :summary
13
+
11
14
  def initialize()
12
15
  end
13
16
 
14
17
  def import(raw_s)
18
+
19
+ raw_buffer, type = RXFHelper.read(raw_s)
15
20
 
16
- lines = raw_s.lines
21
+ lines = raw_buffer.lines
17
22
  header = lines.shift
18
23
  id = header[/id=["']([^"']+)/,1] || 'sectionx'
19
24
 
@@ -36,6 +41,7 @@ class SectionX
36
41
  label, value = raw_x.split(/\s*:\s*/,2)
37
42
  xml.send(label.downcase.gsub(/\s+/,'_'), value)
38
43
  end
44
+ xml.recordx_type 'sectionx'
39
45
  end
40
46
  xml.sections do
41
47
  xml.section do
@@ -61,13 +67,40 @@ class SectionX
61
67
  end
62
68
  end
63
69
 
64
- @doc = Rexle.new a2
65
-
70
+ @doc = doc = Rexle.new a2
71
+ @summary = doc.root.xpath('summary/*')\
72
+ .inject({}) {|r,x| r.merge(x.name.to_sym => x.text)}
73
+
74
+ summary_methods = (@summary.keys - self.public_methods)
75
+
76
+ summary_methods.each do |x|
77
+
78
+ instance_eval "
79
+
80
+ def #{x.to_sym}()
81
+ @summary[:#{x}]
82
+ end
83
+
84
+ def #{x.to_s}=(v)
85
+ @summary[:#{x}] = v
86
+ @doc.root.element('summary/#{x.to_s}').text = v
87
+ end
88
+ "
89
+ end
90
+ self
66
91
  end
92
+
93
+ def recordx_type()
94
+ @summary[:recordx_type]
95
+ end
67
96
 
68
- def to_xml(options)
97
+ def to_xml(options={})
69
98
  @doc.xml(options)
70
99
  end
100
+
101
+ def xpath(x)
102
+ @doc.root.xpath(x)
103
+ end
71
104
 
72
105
  private
73
106
 
@@ -112,8 +145,8 @@ age: 68
112
145
  Employer: FQM R&S
113
146
  EOF
114
147
 
115
- sx = SectionX.new
116
- sx.import s
117
- puts sx.to_xml pretty: true
148
+ sx = SectionX.new
149
+ sx.import s
150
+ puts sx.to_xml pretty: true
118
151
 
119
152
  end
data.tar.gz.sig CHANGED
Binary file
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sectionx
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Robertson
@@ -31,7 +31,7 @@ cert_chain:
31
31
  fF3d7swBn//lagO6DAUK+663TP5+b44Iqo8hPzD1c9+c5WJjVDaCskt69Ue5+dlb
32
32
  VamQ/GtAeu1Iyg==
33
33
  -----END CERTIFICATE-----
34
- date: 2015-02-23 00:00:00.000000000 Z
34
+ date: 2015-02-24 00:00:00.000000000 Z
35
35
  dependencies:
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: line-tree
metadata.gz.sig CHANGED
Binary file