mindmapdoc 0.1.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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 888e10fb37ea910866c7a53ee53dc7ef47adc35d
4
+ data.tar.gz: 0217632f2c5fb6af79a3a76396f05e05f9f2d77c
5
+ SHA512:
6
+ metadata.gz: af147ee78bd0bea1adc01c7104ce908db9393a71a6945be54e8228bb7abcbf8cfa84afe36c0c5061fb25774d691216bd934c031f7b01c54b7f6ad4abca919efa
7
+ data.tar.gz: dfdf15930f4fb11a11d17f8140814000d8c81ff13b0c9a0bf3fc177970e9627b929e75d121a8885be1f18e85d5ac2f391972a204a4d79e032ae2857cc5db5503
checksums.yaml.gz.sig ADDED
Binary file
data/lib/mindmapdoc.rb ADDED
@@ -0,0 +1,117 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ # file: mindmapdoc.rb
4
+
5
+ require 'rdiscount'
6
+ require 'mindmapviz'
7
+
8
+
9
+ class MindmapDoc
10
+
11
+ attr_accessor :root
12
+
13
+ def initialize(s=nil, root: 'root')
14
+
15
+ @root, @tree, @txtdoc, @svg = root, '', '', ''
16
+ import(s) if s
17
+
18
+ end
19
+
20
+ def import(s)
21
+
22
+ if s =~ /^# / then
23
+ @txtdoc = s.gsub(/\r/,'')
24
+ @tree, @html = parse_doc s
25
+ else
26
+ @tree, @txtdoc = parse_tree s
27
+ end
28
+
29
+ @svg = build_svg(@tree)
30
+
31
+ end
32
+
33
+ def to_svg()
34
+ @svg
35
+ end
36
+
37
+ def to_tree()
38
+ @tree
39
+ end
40
+
41
+ def to_md()
42
+ @txtdoc
43
+ end
44
+
45
+ alias to_doc to_md
46
+
47
+ private
48
+
49
+ def build_svg(s)
50
+
51
+ src = s.lines.map {|x| "%s # #%s" % [x.chomp, x.downcase.gsub(/\s/,'')]}\
52
+ .join("\n")
53
+
54
+ mmv = Mindmapviz.new src, fields: %w(label url), delimiter: ' # '
55
+ mmv.to_svg.sub(/.*(?=\<svg)/m,'')
56
+
57
+ end
58
+
59
+ # returns a indented string representation of the mindmap and HTML from
60
+ # the rendered Markdown
61
+ #
62
+ def parse_doc(md)
63
+
64
+ s = RDiscount.new(md.gsub(/\r/,'')).to_html.gsub(/(?<=\<h)[^\<]+/) do |x|
65
+ id = x[/(?<=\>).*/].downcase.gsub(/\s/,'')
66
+ "#{ x[/\d/]} id='#{id}'>#{x[/(?<=\>).*/]}"
67
+ end
68
+
69
+ linex = md.scan(/#[^\n]+\n/).map {|x| (' ' * (x.scan(/#/).length - 1)) + x[/(?<=# ).*/]}
70
+ #log.info 'mindmap: linex: ' + linex.inspect
71
+ @root = linex.shift
72
+ linex.map! {|x| x[2..-1]}
73
+ #log.info 'mindmap: root: ' + @root.inspect
74
+ txt = linex.join("\n")
75
+
76
+ #log.info 'mindmap: txt: ' + txt.inspect
77
+
78
+ [txt, s]
79
+ end
80
+
81
+
82
+ # returns a markdown document
83
+ #
84
+ def parse_tree(s)
85
+
86
+ asrc = [@root] + s.gsub(/\r/,'').strip.lines.map {|x| ' ' + x}
87
+
88
+ a2 = asrc.inject([]) do |r,x|
89
+
90
+ if x.strip.length > 0 then
91
+ r << '#' * (x.scan(/ {2}/).length + 1) + ' ' + x.lstrip
92
+ else
93
+ r
94
+ end
95
+
96
+ end
97
+
98
+ #log.info 'mindmap: a2' + a2.inspect
99
+ a = @txtdoc.split(/.*(?=\n#)/).map(&:strip)
100
+
101
+ a3 = []
102
+
103
+ a2.each do |x|
104
+
105
+ r = a.grep /#{x}/
106
+ #log.info 'mindmap: ' + r.inspect
107
+ r2 = r.any? ? r.first : x
108
+ a3 << "\n" + r2.strip.sub(/\w/) {|x| x.upcase} + "\n"
109
+
110
+ end
111
+ #log.info 'mindmap: a3:' + a3.inspect
112
+
113
+ [asrc.join, a3.join]
114
+
115
+ end
116
+
117
+ end
data.tar.gz.sig ADDED
Binary file
metadata ADDED
@@ -0,0 +1,107 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: mindmapdoc
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
+ 8ixkARkWAmV1MB4XDTE3MTIxMzE3MDI1MloXDTE4MTIxMzE3MDI1MlowSDESMBAG
16
+ A1UEAwwJZ2VtbWFzdGVyMR4wHAYKCZImiZPyLGQBGRYOamFtZXNyb2JlcnRzb24x
17
+ EjAQBgoJkiaJk/IsZAEZFgJldTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoC
18
+ ggEBANUSRMsoPwmyyjX7NWbm/7AAjcFhBvoq+DQfba3odafOKaYSRIacI40ih4fz
19
+ Xgq8bLViuSuzrcZQltAaODMtiaoChvx+7Z0cBVOM8lNTsZsIuQpvC3hG1/zSSM+p
20
+ wBKLcEx8dyn9akv01YVCo5Q+gOpd4M5Y8+NaB19tU5RBqfgI7m5APL7lwU0ABkDD
21
+ dWm0fffqTPJsDT5N1kHJmA0gLa8YWnNNfPuPin+kJA5WwNf+gHdZk5Weg/w6hBMY
22
+ b/KKn5TH0BXqq2ltPTRSMw7BMjP3IPSnb9HmUwTQFkOg6uQlVp607LSbgXt/d5Xi
23
+ 5a49uibOKrry3TYNzWeXYqrKC+UCAwEAAaOBijCBhzAJBgNVHRMEAjAAMAsGA1Ud
24
+ DwQEAwIEsDAdBgNVHQ4EFgQUtaS+kGKXIk2/2wy6scOOk+nJ3/QwJgYDVR0RBB8w
25
+ HYEbZ2VtbWFzdGVyQGphbWVzcm9iZXJ0c29uLmV1MCYGA1UdEgQfMB2BG2dlbW1h
26
+ c3RlckBqYW1lc3JvYmVydHNvbi5ldTANBgkqhkiG9w0BAQUFAAOCAQEAUTBcLzPB
27
+ hrrqcUUBhUJc9Z2lV5lfELDkjEAipO5wMFs1Ybuj72LMFx7MAdCbgY0zqk6VkjMK
28
+ ZFCF02AdVdONAFZzvKV5S+iNo2Kob6wfU5Y0HWSTGicigs7DHm5ne2/l+Lrl+1rE
29
+ yLlecx1/TDqpBFD7EP1eA+vpbhQvRsE0J9mWbjrCf7XomTB0f1ohCrsTjLu4NRD/
30
+ nJ3dURkoefkzkacSIx0QUw4uPPEUA0+ds8+reD+XGhid/icCR4p3ef9c63BCDXHa
31
+ MVgPwk1JjHwj6LchFY/zTEamSovovbrRFMSbfw5kdbPk/wmOGRYaEwTk7wm8u0Zm
32
+ RRHYVIirxLY0zg==
33
+ -----END CERTIFICATE-----
34
+ date: 2017-12-13 00:00:00.000000000 Z
35
+ dependencies:
36
+ - !ruby/object:Gem::Dependency
37
+ name: rdiscount
38
+ requirement: !ruby/object:Gem::Requirement
39
+ requirements:
40
+ - - "~>"
41
+ - !ruby/object:Gem::Version
42
+ version: '2.2'
43
+ - - ">="
44
+ - !ruby/object:Gem::Version
45
+ version: 2.2.0.1
46
+ type: :runtime
47
+ prerelease: false
48
+ version_requirements: !ruby/object:Gem::Requirement
49
+ requirements:
50
+ - - "~>"
51
+ - !ruby/object:Gem::Version
52
+ version: '2.2'
53
+ - - ">="
54
+ - !ruby/object:Gem::Version
55
+ version: 2.2.0.1
56
+ - !ruby/object:Gem::Dependency
57
+ name: mindmapviz
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.3
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.3
76
+ description:
77
+ email: james@jamesrobertson.eu
78
+ executables: []
79
+ extensions: []
80
+ extra_rdoc_files: []
81
+ files:
82
+ - lib/mindmapdoc.rb
83
+ homepage: https://github.com/jrobertson/mindmapdoc
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.6.13
104
+ signing_key:
105
+ specification_version: 4
106
+ summary: mindmapdoc
107
+ test_files: []
metadata.gz.sig ADDED
@@ -0,0 +1 @@
1
+ �����*ЙZn��im�� �����:G�D� ��wf� ���oq,�