polyrex-headings 0.2.0 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data/lib/polyrex-headings.rb +29 -27
- data.tar.gz.sig +4 -2
- metadata +35 -35
- metadata.gz.sig +4 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b19b6d302db47697429ca0cce0d833607cda023c91d905c2f36944af7c1a70c8
|
4
|
+
data.tar.gz: 38fafec9887fea9379231e6a239f0136bf30b3607d317d28d7c08ff4bcc01dff
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 88848e4885eb86a400514d608737af46954b4d0cd5ae99f8e7d2d8db2f266887d7063d74b26d7d2f62e0152706ae868986a1c8bd8eaced17d48df3855a6f10f0
|
7
|
+
data.tar.gz: 129558f0ccdade801991f35b1ac2e9664a59435bfa0e42abd1eaddce08faaadf01021a0e470cbe62d326fff6a05a02f9d72781f3f34e345a87d882fb46ceff65
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data/lib/polyrex-headings.rb
CHANGED
@@ -3,6 +3,8 @@
|
|
3
3
|
# file: polyrex-headings.rb
|
4
4
|
|
5
5
|
require 'polyrex'
|
6
|
+
require 'rxfreader'
|
7
|
+
|
6
8
|
|
7
9
|
class PolyrexHeadingsException < Exception
|
8
10
|
end
|
@@ -12,28 +14,28 @@ class PolyrexHeadings
|
|
12
14
|
attr_reader :to_polyrex, :to_px, :to_s
|
13
15
|
|
14
16
|
def initialize(raw_s, debug: false)
|
15
|
-
|
17
|
+
|
16
18
|
@debug = debug
|
17
|
-
buffer, type =
|
18
|
-
|
19
|
+
buffer, type = RXFReader.read(raw_s)
|
20
|
+
|
19
21
|
if type == :unknown and buffer.lines.length <= 1 then
|
20
|
-
raise PolyrexHeadingsException, 'File not found'
|
21
|
-
end
|
22
|
+
raise PolyrexHeadingsException, 'File not found'
|
23
|
+
end
|
22
24
|
|
23
|
-
# add an empty space to the blank line where there is no
|
25
|
+
# add an empty space to the blank line where there is no
|
24
26
|
# raw record between headings
|
25
|
-
|
27
|
+
|
26
28
|
buffer.gsub!(/(#+[^\n]+\n+)(?=\n#)/m,'\1 ')
|
27
29
|
summary, *s = buffer.split(/(?=(?:^#|[\n]+\n-+))/,2)
|
28
30
|
type = nil
|
29
31
|
|
30
|
-
a = if raw_s =~ /----/ then
|
31
|
-
|
32
|
-
# this was the original code which used dashes to make an underline
|
32
|
+
a = if raw_s =~ /----/ then
|
33
|
+
|
34
|
+
# this was the original code which used dashes to make an underline
|
33
35
|
# of a heading. Typically the heading is now prefixed with a hash (#)
|
34
36
|
# which means this block is unlikely to be executed.
|
35
37
|
|
36
|
-
s.join.lines.chunk{|x| x != "\n" }.map do |record, x|
|
38
|
+
s.join.lines.chunk{|x| x != "\n" }.map do |record, x|
|
37
39
|
|
38
40
|
if record then
|
39
41
|
|
@@ -44,25 +46,25 @@ class PolyrexHeadings
|
|
44
46
|
end
|
45
47
|
|
46
48
|
else
|
47
|
-
|
49
|
+
|
48
50
|
a2 = summary.gsub(/\n{2,}/,"\n").lines
|
49
51
|
|
50
52
|
if a2.last =~ /^--+/ then
|
51
53
|
a2.pop
|
52
54
|
summary = a2.join
|
53
|
-
type = :rowx
|
55
|
+
type = :rowx
|
54
56
|
end
|
55
|
-
|
56
|
-
s.join.split(/^\n*#/)[1..-1].map do |x|
|
57
|
-
|
57
|
+
|
58
|
+
s.join.split(/^\n*#/)[1..-1].map do |x|
|
59
|
+
|
58
60
|
lines = x.lines
|
59
|
-
raw_heading = lines.shift.rstrip
|
60
|
-
|
61
|
+
raw_heading = lines.shift.rstrip
|
62
|
+
|
61
63
|
body = lines.join.strip
|
62
64
|
|
63
65
|
if type == :rowx and body.length > 0
|
64
66
|
|
65
|
-
lines2 = ["\n"] +
|
67
|
+
lines2 = ["\n"] +
|
66
68
|
RowX.new(body, level: 0).to_lines(delimiter: ' # ') << "\n"
|
67
69
|
else
|
68
70
|
|
@@ -72,28 +74,28 @@ class PolyrexHeadings
|
|
72
74
|
raw_indent = raw_heading.slice!(/#*/)
|
73
75
|
n, heading = raw_indent.length, raw_heading.lstrip
|
74
76
|
|
75
|
-
([indent(n) + heading] + lines2.map{|x| indent(n+1) + x}).join
|
77
|
+
([indent(n) + heading] + lines2.map{|x| indent(n+1) + x}).join
|
76
78
|
end
|
77
79
|
|
78
80
|
end
|
79
81
|
|
80
82
|
summary.sub!(/^(<\?)(ph|polyrex-headings)/,'\1polyrex')
|
81
83
|
@to_s = string = summary + a.join
|
82
|
-
|
84
|
+
|
83
85
|
px = Polyrex.new
|
84
86
|
|
85
87
|
px.parse(string, delimiter: ' # ')
|
86
|
-
|
88
|
+
|
87
89
|
@to_polyrex = @to_px = @px = px
|
88
90
|
|
89
91
|
end
|
90
|
-
|
92
|
+
|
91
93
|
def to_h(symbolise: true)
|
92
94
|
build(@px.records, symbolise)
|
93
95
|
end
|
94
|
-
|
96
|
+
|
95
97
|
private
|
96
|
-
|
98
|
+
|
97
99
|
def build(records, symbolise)
|
98
100
|
|
99
101
|
a = records.map do |record|
|
@@ -102,7 +104,7 @@ class PolyrexHeadings
|
|
102
104
|
puts 'record.records: ' + record.records.inspect
|
103
105
|
puts 'record.x: ' + record.x.inspect
|
104
106
|
end
|
105
|
-
|
107
|
+
|
106
108
|
if record.records.any? then
|
107
109
|
|
108
110
|
key = symbolise ? record.x.downcase.to_sym : record.x
|
@@ -124,7 +126,7 @@ class PolyrexHeadings
|
|
124
126
|
puts 'a.first: ' + a.first.inspect if @debug
|
125
127
|
return a.inject({}) {|r,x| r.merge!(x)} if a.first.is_a? Hash
|
126
128
|
|
127
|
-
a
|
129
|
+
a
|
128
130
|
|
129
131
|
end
|
130
132
|
|
data.tar.gz.sig
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: polyrex-headings
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- James Robertson
|
@@ -11,54 +11,54 @@ cert_chain:
|
|
11
11
|
- |
|
12
12
|
-----BEGIN CERTIFICATE-----
|
13
13
|
MIIEXjCCAsagAwIBAgIBATANBgkqhkiG9w0BAQsFADAsMSowKAYDVQQDDCFnZW1t
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
14
|
+
YXN0ZXIvREM9amFtZXNyb2JlcnRzb24vREM9ZXUwHhcNMjIwMjIzMTUxNjQwWhcN
|
15
|
+
MjMwMjIzMTUxNjQwWjAsMSowKAYDVQQDDCFnZW1tYXN0ZXIvREM9amFtZXNyb2Jl
|
16
|
+
cnRzb24vREM9ZXUwggGiMA0GCSqGSIb3DQEBAQUAA4IBjwAwggGKAoIBgQCrSpt5
|
17
|
+
22rqLDPcNhcdVoKgWSPcZBqO24CMYmodBjqer+eWOCUAi98qDilRYs2vcF9L5vHT
|
18
|
+
DFEb6WFR+mkZ7xJcIK4EiRSI1IU6meDjFpJDLrvYc643JrEfk+wc3tsJJnf5BglP
|
19
|
+
B9GHnCeQjNagwAFBpeZe2Ndrb4huNKeoiR9yFKhO/Gpx96bh74Q9Xb23+jQu+brz
|
20
|
+
JbhGO9LXoaTAOd+iSr4D0GkFMK2XhlXY8Yu123vejTWE7ooOrx1GLeGnpz1dxQSq
|
21
|
+
RKtYsaYIKf1qJBRhnuDFdX9BOx4YZz5EJnMa2mJ9NWa0pxX3f2RUj+fZwkYt4kPC
|
22
|
+
mxBAUCBKLGuDx5IWxaCzSKWHc7xfwEtUGExOG4bexeHBAe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37
37
|
-----END CERTIFICATE-----
|
38
|
-
date:
|
38
|
+
date: 2022-02-23 00:00:00.000000000 Z
|
39
39
|
dependencies:
|
40
40
|
- !ruby/object:Gem::Dependency
|
41
41
|
name: polyrex
|
42
42
|
requirement: !ruby/object:Gem::Requirement
|
43
43
|
requirements:
|
44
|
-
- - ">="
|
45
|
-
- !ruby/object:Gem::Version
|
46
|
-
version: 1.3.0
|
47
44
|
- - "~>"
|
48
45
|
- !ruby/object:Gem::Version
|
49
|
-
version: '1.
|
46
|
+
version: '1.4'
|
47
|
+
- - ">="
|
48
|
+
- !ruby/object:Gem::Version
|
49
|
+
version: 1.4.0
|
50
50
|
type: :runtime
|
51
51
|
prerelease: false
|
52
52
|
version_requirements: !ruby/object:Gem::Requirement
|
53
53
|
requirements:
|
54
|
-
- - ">="
|
55
|
-
- !ruby/object:Gem::Version
|
56
|
-
version: 1.3.0
|
57
54
|
- - "~>"
|
58
55
|
- !ruby/object:Gem::Version
|
59
|
-
version: '1.
|
56
|
+
version: '1.4'
|
57
|
+
- - ">="
|
58
|
+
- !ruby/object:Gem::Version
|
59
|
+
version: 1.4.0
|
60
60
|
description:
|
61
|
-
email:
|
61
|
+
email: digital.robertson@gmail.com
|
62
62
|
executables: []
|
63
63
|
extensions: []
|
64
64
|
extra_rdoc_files: []
|
@@ -83,8 +83,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
83
83
|
- !ruby/object:Gem::Version
|
84
84
|
version: '0'
|
85
85
|
requirements: []
|
86
|
-
rubygems_version: 3.
|
86
|
+
rubygems_version: 3.2.22
|
87
87
|
signing_key:
|
88
88
|
specification_version: 4
|
89
|
-
summary: Parses a raw Polyrex document containing Markdown
|
89
|
+
summary: Parses a raw Polyrex document containing Markdown style headings
|
90
90
|
test_files: []
|
metadata.gz.sig
CHANGED
@@ -1 +1,4 @@
|
|
1
|
-
|
1
|
+
YQ��w�<����u�<���*�!�
|
2
|
+
��1���}�i�Ҡ�s�_����fq�@��"x�Sʀ��k��r�pF��G�r�IV�-a(� �ϐ�����V��9k�tx����(o�չ#I2�b�Yg4imM��X�#��4�lk�ʂ�C��_Q4h|vse����1Om4�7@��Q8XG+��O��������%�yw{�� P�D���k��G9��x��h�!�j�G�S/rl����Hu���戤���Y�Nf��.��,��$S[N���d��CH���y��m#P/犪���4N��f,�q��
|
3
|
+
D����lU���<?d�Ա����^�>r(,Fr��l���d������Z�
|
4
|
+
�˾GM������u��v�l�
|