mindwords 0.5.2 → 0.5.7
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 +0 -0
- data/lib/mindwords.rb +125 -11
- metadata +2 -2
- 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: 4766e91a6c371e9d2e8849bafdd77cea548cf43d76630a9400f0ec3b2b778953
|
4
|
+
data.tar.gz: 3f17f99a76ea226ca636f7c8c3ecf24e0e1b8c79571fd299d5dfa00bc10f9d63
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 55c7625e72007789f37b6968271655a772d3d1696991b05f112a39f2ca4b437da71ce5795375887b0b908074bdbd3d2104f0a602aa37f46b518263e2eb2d07e7
|
7
|
+
data.tar.gz: 4d5174c595015db117857d1e9db0b8d211d541136f83cf27e08d84bd86768f0b34e53692579f6d12a5a0931fcf3cc9939ff4deac689276cbedc8c095c8a3bf55
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data.tar.gz.sig
CHANGED
Binary file
|
data/lib/mindwords.rb
CHANGED
@@ -20,18 +20,24 @@ class MindWords
|
|
20
20
|
using ColouredText
|
21
21
|
using HashCopy
|
22
22
|
|
23
|
-
attr_accessor :lines
|
23
|
+
attr_accessor :lines, :filepath
|
24
24
|
|
25
25
|
def initialize(raws='', parent: nil, debug: false)
|
26
26
|
|
27
27
|
@parent, @debug = parent, debug
|
28
28
|
|
29
|
-
s,
|
29
|
+
s, type = RXFHelper.read raws
|
30
|
+
|
31
|
+
@filepath = raws if type == :file or type == :dfs
|
30
32
|
@lines = s.strip.gsub(/^\n/,'').lines
|
31
33
|
@lines.shift if @lines.first =~ /<\?mindwords\?>/
|
32
34
|
|
33
35
|
end
|
34
36
|
|
37
|
+
def add(line)
|
38
|
+
@lines << line
|
39
|
+
end
|
40
|
+
|
35
41
|
def breadcrumb()
|
36
42
|
@parent.attributes[:breadcrumb].split(/ +\/ +/) if @parent
|
37
43
|
end
|
@@ -49,6 +55,49 @@ class MindWords
|
|
49
55
|
@parent.attributes[:hashtags].split if @parent
|
50
56
|
end
|
51
57
|
|
58
|
+
def save(file=@filepath)
|
59
|
+
|
60
|
+
return if @lines.empty?
|
61
|
+
|
62
|
+
puts 'before save' if @debug
|
63
|
+
File.write file, to_s()
|
64
|
+
|
65
|
+
end
|
66
|
+
|
67
|
+
# Accepts a list of words with the aim of returning a MindWords document
|
68
|
+
# using matched words with hashtags from the existing MindWords document.
|
69
|
+
#
|
70
|
+
def reflect(raws)
|
71
|
+
|
72
|
+
h = to_h
|
73
|
+
|
74
|
+
missing_words = []
|
75
|
+
|
76
|
+
# add the tags from the main list
|
77
|
+
a = raws.strip.lines.map do |x|
|
78
|
+
if h[x.chomp] then
|
79
|
+
[x.chomp, h[x.chomp]]
|
80
|
+
else
|
81
|
+
missing_words << x
|
82
|
+
nil
|
83
|
+
end
|
84
|
+
end.compact
|
85
|
+
|
86
|
+
# add any linkage words from the tags
|
87
|
+
#
|
88
|
+
a.map(&:last).flatten(1).each do |s|
|
89
|
+
|
90
|
+
a << [s, h[s]] if h[s]
|
91
|
+
|
92
|
+
end
|
93
|
+
|
94
|
+
# remove suplicates lines and transform it into a raw mindwords format
|
95
|
+
#
|
96
|
+
raws3 = a.uniq.map {|s,tags| [s, tags.map {|x| '#' + x }.join(' ')].join(' ') }.join("\n")
|
97
|
+
|
98
|
+
[MindWords.new(raws3), missing_words]
|
99
|
+
|
100
|
+
end
|
52
101
|
|
53
102
|
def search(keyword)
|
54
103
|
|
@@ -72,8 +121,28 @@ class MindWords
|
|
72
121
|
e = element(keyword.downcase.gsub(/ +/,'-'))
|
73
122
|
|
74
123
|
return nil if e.nil?
|
124
|
+
|
125
|
+
# find and add any linkage support lines
|
126
|
+
#
|
127
|
+
|
128
|
+
a3 = []
|
129
|
+
|
130
|
+
a2.each do |line|
|
131
|
+
|
132
|
+
line.chomp.scan(/#[^ ]+/).each do |hashtag|
|
133
|
+
|
134
|
+
puts 'hashtag: ' + hashtag.inspect if @debug
|
135
|
+
r2 = @lines.grep(/^#{hashtag[1..-1]} #/)
|
136
|
+
a3 << r2.first if r2
|
137
|
+
|
138
|
+
end
|
139
|
+
end
|
140
|
+
|
141
|
+
puts 'a2: ' + a2.inspect if @debug
|
142
|
+
a2.concat a3
|
75
143
|
|
76
|
-
MindWords.new(a2.join, parent: e, debug: @debug)
|
144
|
+
MindWords.new(a2.uniq.join, parent: e, debug: @debug)
|
145
|
+
#MindWords.new(a2.uniq.join, debug: @debug)
|
77
146
|
|
78
147
|
end
|
79
148
|
|
@@ -115,11 +184,20 @@ class MindWords
|
|
115
184
|
@lines = tag_sort().lines
|
116
185
|
self
|
117
186
|
end
|
187
|
+
|
188
|
+
def to_a()
|
189
|
+
|
190
|
+
@lines.map do |x|
|
191
|
+
s, rawtags = x.split(/(?= #)/,2)
|
192
|
+
[s, rawtags.scan(/(?<=#)\w+/)]
|
193
|
+
end
|
194
|
+
|
195
|
+
end
|
118
196
|
|
119
197
|
def to_h()
|
120
|
-
|
198
|
+
to_a.to_h
|
121
199
|
end
|
122
|
-
|
200
|
+
|
123
201
|
def to_hashtags()
|
124
202
|
@hashtags
|
125
203
|
end
|
@@ -129,10 +207,12 @@ class MindWords
|
|
129
207
|
sort ? a2tree(tree_sort(LineTree.new(@outline).to_a)) : @outline
|
130
208
|
end
|
131
209
|
|
210
|
+
alias to_tree to_outline
|
211
|
+
|
132
212
|
def to_s(colour: false)
|
133
213
|
|
134
214
|
header = "<?mindwords?>\n\n"
|
135
|
-
return header + @lines.join unless colour
|
215
|
+
return header + @lines.map(&:chomp).join("\n") unless colour
|
136
216
|
|
137
217
|
body = @lines.map do |x|
|
138
218
|
title, hashtags = x.split(/(?=#)/,2)
|
@@ -141,11 +221,24 @@ class MindWords
|
|
141
221
|
|
142
222
|
header + body
|
143
223
|
|
144
|
-
end
|
224
|
+
end
|
145
225
|
|
146
226
|
def to_words()
|
147
|
-
|
148
|
-
|
227
|
+
|
228
|
+
h = {}
|
229
|
+
|
230
|
+
Rexle.new(to_xml).root.each_recursive do |e|
|
231
|
+
|
232
|
+
h[e.attributes[:title]] = {
|
233
|
+
breadcrumb: e.attributes[:breadcrumb],
|
234
|
+
hashtags: e.attributes[:hashtags]
|
235
|
+
}
|
236
|
+
|
237
|
+
end
|
238
|
+
|
239
|
+
h
|
240
|
+
|
241
|
+
end
|
149
242
|
|
150
243
|
def to_xml()
|
151
244
|
build() unless @xml
|
@@ -210,10 +303,9 @@ class MindWords
|
|
210
303
|
|
211
304
|
redundants.compact.each {|x| doc.element(x).delete }
|
212
305
|
|
213
|
-
|
214
306
|
node = if @parent then
|
215
307
|
found = doc.root.element('//' + @parent.name)
|
216
|
-
found ? found : doc.root
|
308
|
+
found ? found.parent : doc.root
|
217
309
|
else
|
218
310
|
doc.root
|
219
311
|
end
|
@@ -326,3 +418,25 @@ class MindWords
|
|
326
418
|
|
327
419
|
end
|
328
420
|
|
421
|
+
class MindWordsWidget
|
422
|
+
|
423
|
+
def initialize()
|
424
|
+
|
425
|
+
end
|
426
|
+
|
427
|
+
|
428
|
+
# can be used for main entries or a words list
|
429
|
+
#
|
430
|
+
def input(content: '', action: 'mwupdate', target: 'icontent')
|
431
|
+
|
432
|
+
<<EOF
|
433
|
+
<form action='#{action}' method='post' target='#{target}'>
|
434
|
+
<textarea name='content' cols='30' rows='19'>
|
435
|
+
#{content}
|
436
|
+
</textarea>
|
437
|
+
<input type='submit' value='Submit'/>
|
438
|
+
</form>
|
439
|
+
EOF
|
440
|
+
end
|
441
|
+
|
442
|
+
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.5.
|
4
|
+
version: 0.5.7
|
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-07 00:00:00.000000000 Z
|
39
39
|
dependencies:
|
40
40
|
- !ruby/object:Gem::Dependency
|
41
41
|
name: line-tree
|
metadata.gz.sig
CHANGED
Binary file
|