polyrex-headings 0.2.0 → 0.3.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
  SHA256:
3
- metadata.gz: 9ef8d622cae6b8fecd69ecf653ac5ab0682c178e94808d37749ed2a263f3f534
4
- data.tar.gz: 8927856088316195c6c83a36ad0011dda78472cd91ee8c9020fcd8804eecbbdc
3
+ metadata.gz: b19b6d302db47697429ca0cce0d833607cda023c91d905c2f36944af7c1a70c8
4
+ data.tar.gz: 38fafec9887fea9379231e6a239f0136bf30b3607d317d28d7c08ff4bcc01dff
5
5
  SHA512:
6
- metadata.gz: 3492407b37ea880d038fdb4f1bfae0de1c80b221b532d8058678f309b773f241ab697dd2ad92c4f6e31567a8a25889dad0b9e78032015de9268288fab7f616f1
7
- data.tar.gz: 2cb84eace798bb211c5a7bb1350c5292f9a694ff5db352a4169fa1116a6451493e38d896ac2c7762ccbe3f0b840eda562f371c31a76c96f0b0f04eb703d71967
6
+ metadata.gz: 88848e4885eb86a400514d608737af46954b4d0cd5ae99f8e7d2d8db2f266887d7063d74b26d7d2f62e0152706ae868986a1c8bd8eaced17d48df3855a6f10f0
7
+ data.tar.gz: 129558f0ccdade801991f35b1ac2e9664a59435bfa0e42abd1eaddce08faaadf01021a0e470cbe62d326fff6a05a02f9d72781f3f34e345a87d882fb46ceff65
checksums.yaml.gz.sig CHANGED
Binary file
@@ -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 = RXFHelper.read(raw_s)
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
@@ -1,2 +1,4 @@
1
- f���Q�����J����78�]*S��
2
- /t�jϦ�C5��;O-64*U{`]��>���)ofu��������^E�
1
+ 0�<�vsc������֌��`A�^�“����^�(#�@wA��b
2
+ �%t���D��>�X:�2�{w��yf��lg^��Z2<�P2�ޣ(����yq
3
+ �SKG�d���Kg���gW�$��9��X��0����^�<��0r2 �i$"����@`
4
+
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.2.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
  MIIEXjCCAsagAwIBAgIB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xi6FrKa9M2qRewKMDNyHzxZS1N1fwL//+yShXDj
32
- IugkkDXAckDU9LRxtGvWs/fodIj+pSO1GmfM+vtWo21bXf3oXLPi3eAGxhCTaS+A
33
- uFMwJXcd/3uGvIyAGjSIFaTVD0J9HtRv445DJDN/00fzvObt2L7U0Fu1XPE3fonF
34
- uzY8t3bjEky2p6KPiXZoFK8fBaQFK9xGSkEQKBOmCldaVNACqXCbL8tT43voC3Xb
35
- 7q9m2HtS5F1VPGfES14HGW+RIHF+0IMR3k71aKfUEh0UzApGI6C8+ekwjI+Itciy
36
- K8EgeCN0vTCVx/759i3K6q22
28
+ BgkqhkiG9w0BAQsFAAOCAYEAb/tpZ8gB0rtPqduJ98xrWtZENXXVqQYu18KWFXDI
29
+ opOdPd3XE2L/bStWUf04nFofK0djd8RPHzfRZRrIJCrVFgnfNDpQPT9+lirJFohd
30
+ 3sNmYxtnrj7MCEX3sN607XV6fs/8KI/pHNu441umNgKNRFNjN1hV9WDvZMUBVFmi
31
+ K2KfeUd/LIYR5veqZP1FV5YI3o+QGtUVBYpjVWMCXI3PVlncilHhropytJsgTmK+
32
+ m7GRkTcw9bDzTOKLy+9DB5hIfDuy2/p4ghZea5tUsKV47kc6001UsRW/iwV2qwRk
33
+ 3QlMWrvZDcIasPm1AuQygEBiY7UvJK40iH6VU2BkY6k4FWoHnGriWFQJajp1Lrg9
34
+ r4ZBHWMeKglKwXs7dQqJNhc040MV8LIsMNyQmVoovjT0G6BhUgLPI5rPXz1brNim
35
+ EbJCIfBUoHq2SbAPW+rN8OQU0GFKS5VwWo2ksouLe/cwhhYR9h/wfkNMkm464sGh
36
+ E7KxhwTztsgd8aBc/itJzLOs
37
37
  -----END CERTIFICATE-----
38
- date: 2020-01-01 00:00:00.000000000 Z
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.3'
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.3'
56
+ version: '1.4'
57
+ - - ">="
58
+ - !ruby/object:Gem::Version
59
+ version: 1.4.0
60
60
  description:
61
- email: james@jamesrobertson.eu
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.0.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 style headings
89
+ summary: Parses a raw Polyrex document containing Markdown style headings
90
90
  test_files: []
metadata.gz.sig CHANGED
@@ -1 +1,4 @@
1
- �!'eWʑ8�h�V����e R����l,Ee"?ߞ�İ�a��*���qG=Jo��:���"�\��S�YS:%�� �g�� Ss�\�Ro��n6 M�AZ"Y���d�dn<�ܻ ���9��n���D�j[l�ZE��0��p����N�-hFJ����JIw��O��w�{G�' ����F;��J���Ί[���?�����
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�