flowchartviz 0.1.4 → 0.1.5

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 4a447009d44b072f2db1aefa37a20924cb253f92
4
- data.tar.gz: 1de7bbb2ab85661120067c81beadc17b6320e24d
3
+ metadata.gz: 2353e8d44c2a29a3e14c4eca24161487767ed020
4
+ data.tar.gz: 0d043aff373c8f3bfd2ba3d97dcfc1b51cd41ccc
5
5
  SHA512:
6
- metadata.gz: 8cf3cfb6db11ae72a9f2d0151c1ec09253cf7ce11605898991086ca5e17784a2643f38250830d22fcaca4e2b89a9c055f1ee0ef6eb8474ed8a1b2818b5fd553f
7
- data.tar.gz: 9138d794950fb87cf285da5b96b589978b04edfbdcd2d31b98caff29e3c7013577411e43af78f567dd22a3812eaca3c667d99188b0d0a783d2855bca232edacf
6
+ metadata.gz: bf786337451167b5a576b9690d0884bdd4f948c30908cbb47fe44b7954dddc3808d8d4ba2429a0292cdcaee7d7e5c2d228798bb3fa51acfc77fcae39d512bd20
7
+ data.tar.gz: 0af17fb2d849546a256463f04d71c37ca7d1e943bf0f44d840eb544cfa269a24cb4139a5b661d020aef356d114d34d4ab94a96f08d88cf78470f98660c1a82d2
checksums.yaml.gz.sig CHANGED
Binary file
data.tar.gz.sig CHANGED
Binary file
data/lib/flowchartviz.rb CHANGED
@@ -10,14 +10,38 @@ class Flowchartviz
10
10
 
11
11
  attr_reader :raw_doc, :pxg
12
12
 
13
- def initialize(s,truthlabels: %i(yes no), style: default_stylesheet())
13
+ def initialize(s,truthlabels: %i(yes no), style: default_stylesheet(),
14
+ delimiter: ' # ')
14
15
 
15
16
  @true, @false = truthlabels
16
17
 
18
+ if s =~ /<?flowchartviz / then
19
+
20
+ raw_fc = s.clone
21
+ s2 = raw_fc.slice!(/<\?flowchartviz [^>]*\?>/)
22
+
23
+ if s2 then
24
+
25
+ attributes = %w(delimiter id).inject({}) do |r, keyword|
26
+ found = s2[/(?<=#{keyword}=['"])[^'"]+/]
27
+ found ? r.merge(keyword.to_sym => found) : r
28
+ end
29
+
30
+ end
31
+
32
+ h = {delimiter: delimiter }.merge attributes || {}
33
+ s = raw_fc
34
+
35
+ delimiter = h[:delimiter]
36
+
37
+ end
38
+
17
39
  plaintext = scan(LineTree.new(s).to_a).flatten.compact.join("\n")
40
+
41
+ schema = 'items[direction]/item[label, url, connection, shape]'
18
42
 
19
43
  @raw_doc=<<EOF
20
- <?polyrex schema='items[direction]/item[label, connection, shape]' delimiter =' # '?>
44
+ <?polyrex schema='#{schema}' delimiter='#{delimiter}'?>
21
45
  direction: TB
22
46
  #{plaintext}
23
47
  EOF
@@ -56,12 +80,15 @@ EOF
56
80
  k = 0
57
81
 
58
82
  a.map.with_index do |x,j|
83
+
84
+ end_fields = ''
59
85
 
60
86
  case x[0]
61
87
  when /^if */
62
88
  k+=1
63
89
  b = true
64
- x[0].gsub!(/(?:^if | then$)/,'') << ' # # diamond'
90
+ x[0].gsub!(/(?:^if | then$)/,'')
91
+ end_fields = ' # # diamond'
65
92
  when /^else */
66
93
  x[0] = nil
67
94
  k -= 1
@@ -70,10 +97,15 @@ EOF
70
97
  x[0] = nil
71
98
  else
72
99
  k = 1
73
- x[0] << ' # ' + (b ? @true : @false).to_s unless b.nil?
100
+ end_fields = ' # ' + (b ? @true : @false).to_s unless b.nil?
74
101
  b = nil
75
102
  end
76
103
 
104
+ if x[0] then
105
+ x[0] << ' # ' unless x[0] =~ /#/ or end_fields.empty?
106
+ x[0] << end_fields
107
+ end
108
+
77
109
  scan x[1..-1],j+k, b if x.length > 1
78
110
  x[0].prepend ' ' * (j + i) if x[0]
79
111
  x
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: flowchartviz
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
4
+ version: 0.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Robertson
metadata.gz.sig CHANGED
@@ -1,3 +1 @@
1
- Q���`�W)p�NG[�>Y9���ؑ�����˭���f$�Lg�O��0n^^a@� ���ɩ�R��>|���V�?��oׅ����a�-�C2I��M^�Ahj]�楽���x�?�_Ar��?o������x~��?E��=�۸c
2
- 5�:�{u
3
- ��\F���m�6����=�*F���������l� Ƽ�, ��S�GF�ZY!+��W7*�e���S=� �n[4��^����4�L�dE7>��7�%��?(}qi[�
1
+ 9Խ �Q?xBL4��#M̨G$��� o�{<YK�ên=��r\Uz/;A2J��qUÖw "N5Pp9�{��L`���Q�Q��6���"�oc�Fg���^!�ps\d^���"�p��̾crE���[F%�R�T�T�66j�<Ne��