sectionx 0.1.3 → 0.2.0

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: 7b663fc3f9e9ef3ef36ec22e09ecdf5ee7d9363c
4
- data.tar.gz: ab3e30ef178a9a9c08fb09515322b709ae91c9bc
3
+ metadata.gz: 56059ca006757250417838954d2282745e69c6d7
4
+ data.tar.gz: 0990348f8a22b0af53b35a711250757dfbe926fd
5
5
  SHA512:
6
- metadata.gz: 287f2f7ab62a70d3e66fbff4f0fce0d80e3bae6d260f5b9136a1fd846f04fe0177ca4eb4b90047c08baad220bc367d76281fb276d7374e3e5211028d4b236bd1
7
- data.tar.gz: 03b466b0d287d6e0329ee8c815f37d33e59fc1b95ee37fa681ae954cfaf2b42d202b73017dbde53b9c23649616edbb2655163a27c0aa4a95bb037cbe6c5b8ad9
6
+ metadata.gz: 6ea1c7fe047a86d3af9870cdbafe6d4945256f7b1fcdca904b543d48cf87bcae2fc8a9fcca3ba40d02e9c8c8aa0109c4e449f472cb1381ea173a756a60bfb136
7
+ data.tar.gz: 14cf652dc7d55431030937abe612884588f7a4a2bb867b4b3ea0fc7f324efe1f93224bf158240e3f7befa8a1d88f5b9ff8069642a3457ea658984eb941ff6c6e
checksums.yaml.gz.sig CHANGED
Binary file
data/lib/sectionx.rb CHANGED
@@ -5,6 +5,7 @@
5
5
  require 'line-tree'
6
6
  require 'rexle-builder'
7
7
  require 'rxfhelper'
8
+ require 'recordx'
8
9
 
9
10
 
10
11
  class SectionX
@@ -27,8 +28,15 @@ class SectionX
27
28
  body.strip])
28
29
  a = LineTree.new(nested).to_a
29
30
 
30
- summary = a.shift.flatten(1)
31
- summary.shift
31
+ raw_summary = a.shift.flatten(1)
32
+ raw_summary.shift
33
+
34
+ h = raw_summary.inject({}) do |r,raw_x|
35
+ label, value = raw_x.split(/\s*:\s*/,2)
36
+ r.merge(label.downcase.gsub(/\s+/,'_').to_sym => value)
37
+ end
38
+
39
+ @summary = RecordX.new h
32
40
 
33
41
  section1 = a.shift.flatten(1)
34
42
  section1.shift
@@ -37,10 +45,7 @@ class SectionX
37
45
 
38
46
  a2 = xml.send(id) do
39
47
  xml.summary do
40
- summary.each do |raw_x|
41
- label, value = raw_x.split(/\s*:\s*/,2)
42
- xml.send(label.downcase.gsub(/\s+/,'_'), value)
43
- end
48
+ @summary.each {|label, value| xml.send(label, value) }
44
49
  xml.recordx_type 'sectionx'
45
50
  end
46
51
  xml.sections do
@@ -68,8 +73,6 @@ class SectionX
68
73
  end
69
74
 
70
75
  @doc = doc = Rexle.new a2
71
- @summary = doc.root.xpath('summary/*')\
72
- .inject({}) {|r,x| r.merge(x.name.to_sym => x.text)}
73
76
 
74
77
  summary_methods = (@summary.keys - self.public_methods)
75
78
 
@@ -93,6 +96,10 @@ class SectionX
93
96
  def recordx_type()
94
97
  @summary[:recordx_type]
95
98
  end
99
+
100
+ def save(filepath)
101
+ File.write filepath, @doc.xml(pretty: true)
102
+ end
96
103
 
97
104
  def to_xml(options={})
98
105
  @doc.xml(options)
@@ -101,6 +108,12 @@ class SectionX
101
108
  def xpath(x)
102
109
  @doc.root.xpath(x)
103
110
  end
111
+
112
+ def xslt=(value)
113
+
114
+ self.summary.merge!({xslt: value})
115
+ @xslt = value
116
+ end
104
117
 
105
118
  private
106
119
 
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.3
4
+ version: 0.2.0
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-24 00:00:00.000000000 Z
34
+ date: 2015-02-25 00:00:00.000000000 Z
35
35
  dependencies:
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: line-tree
@@ -93,6 +93,26 @@ dependencies:
93
93
  - - ">="
94
94
  - !ruby/object:Gem::Version
95
95
  version: 0.1.14
96
+ - !ruby/object:Gem::Dependency
97
+ name: recordx
98
+ requirement: !ruby/object:Gem::Requirement
99
+ requirements:
100
+ - - "~>"
101
+ - !ruby/object:Gem::Version
102
+ version: '0.1'
103
+ - - ">="
104
+ - !ruby/object:Gem::Version
105
+ version: 0.1.1r54
106
+ type: :runtime
107
+ prerelease: false
108
+ version_requirements: !ruby/object:Gem::Requirement
109
+ requirements:
110
+ - - "~>"
111
+ - !ruby/object:Gem::Version
112
+ version: '0.1'
113
+ - - ">="
114
+ - !ruby/object:Gem::Version
115
+ version: 0.1.1r54
96
116
  description:
97
117
  email: james@r0bertson.co.uk
98
118
  executables: []
metadata.gz.sig CHANGED
Binary file