mindwords 0.5.3 → 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +3 -4
- data/lib/mindwords.rb +165 -14
- metadata +4 -4
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: aa290828ca8b921917460e6f8958c8b21d461c269a060e63c6079f57090d7d3e
|
4
|
+
data.tar.gz: e719d8986ece5f93bc994682a02b8f9826f1b5554349b40402d2a699920ba40b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 407b282223460ffb5585e15c5acaa1b377cefb17350b7626680cafd6d4f742a2ab1a0b19223385f74ca332f2830f5cc618e22fff93d6a704a0a3921b18dfb65c
|
7
|
+
data.tar.gz: 1f4c83f14c4e5c2ad51925445edb600a9e60a14482f7b4e057703b8ea980d8e631d5c901ebe49b034db3ce73e7ce0515ef936214e18ba138a93b0aee472f1b93
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data.tar.gz.sig
CHANGED
@@ -1,4 +1,3 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
f6R1��)�����w��:�O�0�K5�����IQ�����c��v�@���Z��d:�_`��Q|QN*���kn�]%ڧ1+������4D-���ZH/1�K�'T��3e�ٯ���$��
|
1
|
+
p2ua�/&���8�ħ��5 �~m���-��N�r�%fj�O�Q���)
|
2
|
+
��m�\���^ݹhd�^����L�2�H�nX�C�]�.��F1ڒ����^rV���]S]fw�K�X���,{��luٲ� 8���hLT�����*���갑��u�5�*��.���} "mM��4��0���5>&5B�|"�w&�s��@_"�#cw�ؗ~����5*W��������Z���M����9���>%OH%�h��YM/jf\ D�/�#����/�G��Y)��@��2F5�4l��뮇�\� wM\}9b4�~y���t�|�}���
|
3
|
+
i*�Г���H��^3𓌗�T)'{�UM>
|
data/lib/mindwords.rb
CHANGED
@@ -29,14 +29,44 @@ class MindWords
|
|
29
29
|
s, type = RXFHelper.read raws
|
30
30
|
|
31
31
|
@filepath = raws if type == :file or type == :dfs
|
32
|
-
|
33
|
-
|
32
|
+
lines = s.strip.gsub(/^\n/,'').lines
|
33
|
+
lines.shift if lines.first =~ /<\?mindwords\?>/
|
34
|
+
|
35
|
+
@lines = lines.inject([]) do |r,line|
|
36
|
+
|
37
|
+
# the following does 2 things:
|
38
|
+
# 1. splits words separated by a bar (|) onto their own line
|
39
|
+
# 2. prefixes a word with an underscore if the word is the
|
40
|
+
# same as the hashtag. That way it's not removed by the
|
41
|
+
# redundancy checker
|
42
|
+
|
43
|
+
raw_words, raw_hashtags = line.split(/(?= #)/,2)
|
44
|
+
words = raw_words.split(/ *\| */)
|
45
|
+
hashtags = raw_hashtags.scan(/(?<=#)\w+/)
|
46
|
+
|
47
|
+
words.each do |word|
|
48
|
+
|
49
|
+
linex = (word + ' ' + raw_hashtags)
|
50
|
+
r << (hashtags.include?(word) ? linex.sub!(/\b#{word}\b/, '_\0') \
|
51
|
+
: linex)
|
52
|
+
end
|
53
|
+
|
54
|
+
r
|
55
|
+
end
|
34
56
|
|
35
57
|
end
|
36
58
|
|
59
|
+
def add(line)
|
60
|
+
@lines << line
|
61
|
+
end
|
62
|
+
|
37
63
|
def breadcrumb()
|
38
64
|
@parent.attributes[:breadcrumb].split(/ +\/ +/) if @parent
|
39
65
|
end
|
66
|
+
|
67
|
+
def headings()
|
68
|
+
breadcrumb[0..-2]
|
69
|
+
end
|
40
70
|
|
41
71
|
|
42
72
|
def element(id)
|
@@ -53,12 +83,49 @@ class MindWords
|
|
53
83
|
|
54
84
|
def save(file=@filepath)
|
55
85
|
|
86
|
+
return if @lines.empty?
|
87
|
+
|
56
88
|
puts 'before save' if @debug
|
57
89
|
File.write file, to_s()
|
58
90
|
|
59
91
|
end
|
92
|
+
|
93
|
+
# Accepts a list of words with the aim of returning a MindWords document
|
94
|
+
# using matched words with hashtags from the existing MindWords document.
|
95
|
+
#
|
96
|
+
def reflect(raws)
|
97
|
+
|
98
|
+
h = to_h
|
99
|
+
|
100
|
+
missing_words = []
|
101
|
+
|
102
|
+
# add the tags from the main list
|
103
|
+
a = raws.strip.lines.map do |x|
|
104
|
+
if h[x.chomp] then
|
105
|
+
[x.chomp, h[x.chomp]]
|
106
|
+
else
|
107
|
+
missing_words << x
|
108
|
+
nil
|
109
|
+
end
|
110
|
+
end.compact
|
111
|
+
|
112
|
+
# add any linkage words from the tags
|
113
|
+
#
|
114
|
+
a.map(&:last).flatten(1).each do |s|
|
115
|
+
|
116
|
+
a << [s, h[s]] if h[s]
|
117
|
+
|
118
|
+
end
|
119
|
+
|
120
|
+
# remove suplicates lines and transform it into a raw mindwords format
|
121
|
+
#
|
122
|
+
raws3 = a.uniq.map {|s,tags| [s, tags.map {|x| '#' + x }.join(' ')].join(' ') }.join("\n")
|
123
|
+
|
124
|
+
[MindWords.new(raws3), missing_words]
|
125
|
+
|
126
|
+
end
|
60
127
|
|
61
|
-
def search(keyword)
|
128
|
+
def search(keyword, succinct: true)
|
62
129
|
|
63
130
|
a = @lines.grep(/#{keyword}/i).map do |line|
|
64
131
|
|
@@ -79,9 +146,32 @@ class MindWords
|
|
79
146
|
puts 'a2: ' + a2.inspect if @debug
|
80
147
|
e = element(keyword.downcase.gsub(/ +/,'-'))
|
81
148
|
|
82
|
-
return
|
149
|
+
return MindWords.new(a2.uniq.join, debug: @debug) if e.nil?
|
150
|
+
|
151
|
+
# find and add any linkage support lines
|
152
|
+
#
|
83
153
|
|
84
|
-
|
154
|
+
a3 = []
|
155
|
+
|
156
|
+
a2.each do |line|
|
157
|
+
|
158
|
+
line.chomp.scan(/#[^ ]+/).each do |hashtag|
|
159
|
+
|
160
|
+
puts 'hashtag: ' + hashtag.inspect if @debug
|
161
|
+
r2 = @lines.grep(/^#{hashtag[1..-1]} #/)
|
162
|
+
a3 << r2.first if r2
|
163
|
+
|
164
|
+
end
|
165
|
+
end
|
166
|
+
|
167
|
+
puts 'a2: ' + a2.inspect if @debug
|
168
|
+
a2.concat a3
|
169
|
+
|
170
|
+
if succinct then
|
171
|
+
MindWords.new(a2.uniq.join, parent: e, debug: @debug)
|
172
|
+
else
|
173
|
+
MindWords.new(a2.uniq.join, debug: @debug)
|
174
|
+
end
|
85
175
|
|
86
176
|
end
|
87
177
|
|
@@ -123,11 +213,20 @@ class MindWords
|
|
123
213
|
@lines = tag_sort().lines
|
124
214
|
self
|
125
215
|
end
|
216
|
+
|
217
|
+
def to_a()
|
218
|
+
|
219
|
+
@lines.map do |x|
|
220
|
+
s, rawtags = x.split(/(?= #)/,2)
|
221
|
+
[s, rawtags.scan(/(?<=#)\w+/)]
|
222
|
+
end
|
223
|
+
|
224
|
+
end
|
126
225
|
|
127
226
|
def to_h()
|
128
|
-
|
227
|
+
to_a.to_h
|
129
228
|
end
|
130
|
-
|
229
|
+
|
131
230
|
def to_hashtags()
|
132
231
|
@hashtags
|
133
232
|
end
|
@@ -137,10 +236,12 @@ class MindWords
|
|
137
236
|
sort ? a2tree(tree_sort(LineTree.new(@outline).to_a)) : @outline
|
138
237
|
end
|
139
238
|
|
239
|
+
alias to_tree to_outline
|
240
|
+
|
140
241
|
def to_s(colour: false)
|
141
242
|
|
142
243
|
header = "<?mindwords?>\n\n"
|
143
|
-
return header + @lines.join unless colour
|
244
|
+
return header + @lines.map(&:chomp).join("\n") unless colour
|
144
245
|
|
145
246
|
body = @lines.map do |x|
|
146
247
|
title, hashtags = x.split(/(?=#)/,2)
|
@@ -149,11 +250,24 @@ class MindWords
|
|
149
250
|
|
150
251
|
header + body
|
151
252
|
|
152
|
-
end
|
253
|
+
end
|
153
254
|
|
154
255
|
def to_words()
|
155
|
-
|
156
|
-
|
256
|
+
|
257
|
+
h = {}
|
258
|
+
|
259
|
+
Rexle.new(to_xml).root.each_recursive do |e|
|
260
|
+
|
261
|
+
h[e.attributes[:title]] = {
|
262
|
+
breadcrumb: e.attributes[:breadcrumb],
|
263
|
+
hashtags: e.attributes[:hashtags]
|
264
|
+
}
|
265
|
+
|
266
|
+
end
|
267
|
+
|
268
|
+
h
|
269
|
+
|
270
|
+
end
|
157
271
|
|
158
272
|
def to_xml()
|
159
273
|
build() unless @xml
|
@@ -218,14 +332,29 @@ class MindWords
|
|
218
332
|
|
219
333
|
redundants.compact.each {|x| doc.element(x).delete }
|
220
334
|
|
221
|
-
|
222
335
|
node = if @parent then
|
223
336
|
found = doc.root.element('//' + @parent.name)
|
224
|
-
found ? found : doc.root
|
337
|
+
found ? found.parent : doc.root
|
225
338
|
else
|
226
339
|
doc.root
|
227
340
|
end
|
228
341
|
|
342
|
+
# the following removes any undescore prefix from words which were the
|
343
|
+
# same as the hashtag
|
344
|
+
|
345
|
+
node.root.each_recursive do |e|
|
346
|
+
|
347
|
+
next unless e
|
348
|
+
puts 'e: ' + e.inspect if @debug
|
349
|
+
|
350
|
+
e.attributes[:id] = e.attributes[:id].sub(/^_/,'') if e.attributes[:id]
|
351
|
+
e.attributes[:title] = e.attributes[:title].sub(/^_/,'') if e.attributes[:title]
|
352
|
+
e.value = e.value.sub(/^_/,'')
|
353
|
+
|
354
|
+
end
|
355
|
+
|
356
|
+
# ----
|
357
|
+
|
229
358
|
@outline = treeize node
|
230
359
|
|
231
360
|
node.root.each_recursive do |e|
|
@@ -288,7 +417,7 @@ class MindWords
|
|
288
417
|
|
289
418
|
duplicates.each do |path|
|
290
419
|
|
291
|
-
puts '
|
420
|
+
puts 'pathx: ' + path.inspect if @debug
|
292
421
|
e = doc.element(path)
|
293
422
|
e.delete if e
|
294
423
|
|
@@ -334,3 +463,25 @@ class MindWords
|
|
334
463
|
|
335
464
|
end
|
336
465
|
|
466
|
+
class MindWordsWidget
|
467
|
+
|
468
|
+
def initialize()
|
469
|
+
|
470
|
+
end
|
471
|
+
|
472
|
+
|
473
|
+
# can be used for main entries or a words list
|
474
|
+
#
|
475
|
+
def input(content: '', action: 'mwupdate', target: 'icontent')
|
476
|
+
|
477
|
+
<<EOF
|
478
|
+
<form action='#{action}' method='post' target='#{target}'>
|
479
|
+
<textarea name='content' cols='30' rows='19'>
|
480
|
+
#{content}
|
481
|
+
</textarea>
|
482
|
+
<input type='submit' value='Submit'/>
|
483
|
+
</form>
|
484
|
+
EOF
|
485
|
+
end
|
486
|
+
|
487
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mindwords
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- James Robertson
|
@@ -35,7 +35,7 @@ cert_chain:
|
|
35
35
|
aWH7D2AmhOpqNwWnPHzWR/yzpigAVTrvpHfRxZleQj6Z/090nIH2KR0RdioMmPFq
|
36
36
|
3+574KQzs/gR9Y5a+iMcvHRN
|
37
37
|
-----END CERTIFICATE-----
|
38
|
-
date: 2021-
|
38
|
+
date: 2021-04-09 00:00:00.000000000 Z
|
39
39
|
dependencies:
|
40
40
|
- !ruby/object:Gem::Dependency
|
41
41
|
name: line-tree
|
@@ -46,7 +46,7 @@ dependencies:
|
|
46
46
|
version: '0.9'
|
47
47
|
- - ">="
|
48
48
|
- !ruby/object:Gem::Version
|
49
|
-
version: 0.9.
|
49
|
+
version: 0.9.2
|
50
50
|
type: :runtime
|
51
51
|
prerelease: false
|
52
52
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -56,7 +56,7 @@ dependencies:
|
|
56
56
|
version: '0.9'
|
57
57
|
- - ">="
|
58
58
|
- !ruby/object:Gem::Version
|
59
|
-
version: 0.9.
|
59
|
+
version: 0.9.2
|
60
60
|
- !ruby/object:Gem::Dependency
|
61
61
|
name: rxfhelper
|
62
62
|
requirement: !ruby/object:Gem::Requirement
|
metadata.gz.sig
CHANGED
Binary file
|