sectionx 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 9037b655286271e690d6f4761e277fa43a6a81f3
4
+ data.tar.gz: b64509b53c85bb277ceb48ab939ebda1ceae2fc2
5
+ SHA512:
6
+ metadata.gz: 7122c92cc9c7046771a66fd5d58b79b44f7b358cc9174959159a3191b2903b79d08d90615af3603beacc50e7a95bc716c3b98aeda4e920fcb340259ce8e178a9
7
+ data.tar.gz: 51f3111239dff687546d8062b47c2c68065146104e9ca2b2d725f18f34a002c538703b7f88dd11aa132eb6f877c2ded8ecd5f90829453778b7a22368529abe8f
checksums.yaml.gz.sig ADDED
@@ -0,0 +1,2 @@
1
+ �\t�[��ڲV1����=��N����9E�1f�kvR���P�����}�^2M]����ش�ی��Z�"2_�d3͚(�r��Q��� ŏ�h�D,Ϝ� �$@��� �l#�����_~��5�<|"Tym3L�����+�k벊=��S��
2
+ �Й]�G�Kٙ��O�s��#���b�s����q�O�ⅆ������%�˃� �dFP+-Z�����[u�Oa����C�,�<(
data/lib/sectionx.rb ADDED
@@ -0,0 +1,119 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ # file: sectionx.rb
4
+
5
+ require 'line-tree'
6
+ require 'rexle-builder'
7
+
8
+
9
+ class SectionX
10
+
11
+ def initialize()
12
+ end
13
+
14
+ def import(raw_s)
15
+
16
+ lines = raw_s.lines
17
+ header = lines.shift
18
+ id = header[/id=["']([^"']+)/,1] || 'sectionx'
19
+
20
+ body, summary = lines.join.strip.split(/^----*$/).reverse
21
+ nested = indent_heading("# summary\n%s\n# begin\n%s" % [summary,\
22
+ body.strip])
23
+ a = LineTree.new(nested).to_a
24
+
25
+ summary = a.shift.flatten(1)
26
+ summary.shift
27
+
28
+ section1 = a.shift.flatten(1)
29
+ section1.shift
30
+
31
+ xml = RexleBuilder.new
32
+
33
+ a2 = xml.send(id) do
34
+ xml.summary do
35
+ summary.each do |raw_x|
36
+ label, value = raw_x.split(/\s*:\s*/,2)
37
+ xml.send(label.downcase.gsub(/\s+/,'_'), value)
38
+ end
39
+ end
40
+ xml.sections do
41
+ xml.section do
42
+ xml.summary do
43
+ section1.each do |raw_x|
44
+ label, value = raw_x.split(/\s*:\s*/,2)
45
+ xml.send(label.downcase.gsub(/\s+/,'_'), value)
46
+ end
47
+ end
48
+ xml.sections
49
+ end
50
+ a.each do |section_name, raw_rows|
51
+ xml.section({title: section_name}) do
52
+ xml.summary do
53
+ raw_rows.each do |raw_x|
54
+ label, value = raw_x.split(/\s*:\s*/,2)
55
+ xml.send(label.downcase.gsub(/\s+/,'_'), value)
56
+ end
57
+ end
58
+ xml.sections
59
+ end
60
+ end
61
+ end
62
+ end
63
+
64
+ @doc = Rexle.new a2
65
+
66
+ end
67
+
68
+ def to_xml(options)
69
+ @doc.xml(options)
70
+ end
71
+
72
+ private
73
+
74
+
75
+ def indent_heading(s, heading='#')
76
+
77
+ a = s.split(/(?=^\s*#{heading}\s*\w)/).map do |x|
78
+
79
+ heading_title = x[/^\s*#{heading}\s*(.*)/,1]
80
+
81
+ if heading_title then
82
+
83
+ lines = x.lines
84
+ body = lines[1..-1].map{|y| y.prepend ' '}.join
85
+ r = indent_heading(body, heading + '#')
86
+
87
+ heading_title + "\n" + r
88
+ else
89
+ x
90
+ end
91
+ end
92
+
93
+ a.join
94
+ end
95
+
96
+ end
97
+
98
+ if __FILE__ == $0 then
99
+
100
+ s =<<EOF
101
+ <?sectionx id='personal'?>
102
+
103
+ title: My Personal Profile
104
+ tags: profile personal
105
+
106
+ ----------------------------
107
+
108
+ name: John Smith
109
+ age: 68
110
+
111
+ # Employment
112
+ Employer: FQM R&S
113
+ EOF
114
+
115
+ sx = SectionX.new
116
+ sx.import s
117
+ puts sx.to_xml pretty: true
118
+
119
+ end
data.tar.gz.sig ADDED
Binary file
metadata ADDED
@@ -0,0 +1,108 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: sectionx
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - James Robertson
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain:
11
+ - |
12
+ -----BEGIN CERTIFICATE-----
13
+ MIIDljCCAn6gAwIBAgIBATANBgkqhkiG9w0BAQUFADBIMRIwEAYDVQQDDAlnZW1t
14
+ YXN0ZXIxHjAcBgoJkiaJk/IsZAEZFg5qYW1lc3JvYmVydHNvbjESMBAGCgmSJomT
15
+ 8ixkARkWAmV1MB4XDTE1MDIyMzIxMDM1OFoXDTE2MDIyMzIxMDM1OFowSDESMBAG
16
+ A1UEAwwJZ2VtbWFzdGVyMR4wHAYKCZImiZPyLGQBGRYOamFtZXNyb2JlcnRzb24x
17
+ EjAQBgoJkiaJk/IsZAEZFgJldTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoC
18
+ ggEBANUhQ0jRPxKyNshsQpT6KNb7RhQ+YU2bUAL3i0uCQi27EAtd60q/1POpc15N
19
+ W3h0qwbvkiF3QbeVvPiM/hx13o02A3u3cJZjVgnKPe4cvgWBEHEkSevY+FM/u+XC
20
+ RpQUHSIwlE/MrmEK0yZne3g0Uu7uVStNQ7QEdF7df8cbtKy8Hyua3Y1TUlajs34N
21
+ ec9n3mIMelaOrRbv1NaxXBgrmfiww+o9HJDzA1pVrYaXDaw8jrkMd19da/5ahLIv
22
+ nEAWDO5g7XOPAZTaa1vmHOVaAuDNKFRi5QFDOCGbaVe2XrOgvV2vPr/5OQBphCz/
23
+ 5B7bsimn8YtbiGTzknBX6um9DJkCAwEAAaOBijCBhzAJBgNVHRMEAjAAMAsGA1Ud
24
+ DwQEAwIEsDAdBgNVHQ4EFgQUeqwRWJDjmDXJbw8w7IgcrtATy2owJgYDVR0RBB8w
25
+ HYEbZ2VtbWFzdGVyQGphbWVzcm9iZXJ0c29uLmV1MCYGA1UdEgQfMB2BG2dlbW1h
26
+ c3RlckBqYW1lc3JvYmVydHNvbi5ldTANBgkqhkiG9w0BAQUFAAOCAQEADnti0yjP
27
+ zm4yJGzz/4o2LLojg6qAFVb7fuL1W6vVxanMn6lhfnj57rtmMTf6ku+W2zFKCc/7
28
+ E/zOY5qcWN+dVPdKY7hCmRmo1Z0ETxCO+FgObGGLS4LRAjoJbrsVMY56TIIOyoxX
29
+ i5o4EgthPBhgj0faOLDu9N5Ykmu68k2TJjDrTVBiomA+AiuUjgGrgMJj8uEOOWck
30
+ FoeFWuTT19DkSLd1N/Rr+dqpzI+qdNncw6Fl3ILayVX77MOnAZDrNj63PV22SauM
31
+ fF3d7swBn//lagO6DAUK+663TP5+b44Iqo8hPzD1c9+c5WJjVDaCskt69Ue5+dlb
32
+ VamQ/GtAeu1Iyg==
33
+ -----END CERTIFICATE-----
34
+ date: 2015-02-23 00:00:00.000000000 Z
35
+ dependencies:
36
+ - !ruby/object:Gem::Dependency
37
+ name: line-tree
38
+ requirement: !ruby/object:Gem::Requirement
39
+ requirements:
40
+ - - "~>"
41
+ - !ruby/object:Gem::Version
42
+ version: '0.5'
43
+ - - ">="
44
+ - !ruby/object:Gem::Version
45
+ version: 0.5.1
46
+ type: :runtime
47
+ prerelease: false
48
+ version_requirements: !ruby/object:Gem::Requirement
49
+ requirements:
50
+ - - "~>"
51
+ - !ruby/object:Gem::Version
52
+ version: '0.5'
53
+ - - ">="
54
+ - !ruby/object:Gem::Version
55
+ version: 0.5.1
56
+ - !ruby/object:Gem::Dependency
57
+ name: dynarex-daily
58
+ requirement: !ruby/object:Gem::Requirement
59
+ requirements:
60
+ - - "~>"
61
+ - !ruby/object:Gem::Version
62
+ version: '0.2'
63
+ - - ">="
64
+ - !ruby/object:Gem::Version
65
+ version: 0.2.1
66
+ type: :runtime
67
+ prerelease: false
68
+ version_requirements: !ruby/object:Gem::Requirement
69
+ requirements:
70
+ - - "~>"
71
+ - !ruby/object:Gem::Version
72
+ version: '0.2'
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: 0.2.1
76
+ description:
77
+ email: james@r0bertson.co.uk
78
+ executables: []
79
+ extensions: []
80
+ extra_rdoc_files: []
81
+ files:
82
+ - lib/sectionx.rb
83
+ homepage: https://github.com/jrobertson/sectionx
84
+ licenses:
85
+ - MIT
86
+ metadata: {}
87
+ post_install_message:
88
+ rdoc_options: []
89
+ require_paths:
90
+ - lib
91
+ required_ruby_version: !ruby/object:Gem::Requirement
92
+ requirements:
93
+ - - ">="
94
+ - !ruby/object:Gem::Version
95
+ version: '0'
96
+ required_rubygems_version: !ruby/object:Gem::Requirement
97
+ requirements:
98
+ - - ">="
99
+ - !ruby/object:Gem::Version
100
+ version: '0'
101
+ requirements: []
102
+ rubyforge_project:
103
+ rubygems_version: 2.2.2
104
+ signing_key:
105
+ specification_version: 4
106
+ summary: Makes it convenient to store and retrieve hierarchical data in an XML format
107
+ known as SectionX
108
+ test_files: []
metadata.gz.sig ADDED
Binary file