mindwords 0.5.6 → 0.6.4

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
  SHA256:
3
- metadata.gz: 9278b3fbcf3da1caed6dd21c274bb8b26e12dec525d05ecf322965b083e8c884
4
- data.tar.gz: 8c9b4a404897fd119b64f13e7140daecc8eb55f404595e001508b0b8dd031b7d
3
+ metadata.gz: 57efb3e9e699846f0886274e3d976cbad5707b3c9b5497cc175f15a5a1bfcfe6
4
+ data.tar.gz: 67fd42d36fe854b72c4336ed1ef185925d40fee6ecdb1e54c729fa3ee601869d
5
5
  SHA512:
6
- metadata.gz: 5d4aa5d8a2d6fbc11492518c9be080d98adf122240867baea88d94dfb2b87781bb0e6f94aa5ea7dc632e9be6525c2a3fe02b854b26d86f57accef214b533a904
7
- data.tar.gz: 96d3d52f2c88e2419aee86737469a837c51985fc716277cd97694f5f32905ee349e7bbbb40e63e121555cdb81c5b90d5b06baabc28b7a1011a00c98fbb584a35
6
+ metadata.gz: ee70b813f79e3a41149b583fe5bebde65c6fb7ef47bb0cb3683f060b1e5bc523f69af796391a1a9b3ed79ed18ce52a26c75949144d7ba1995fc96ad332bd9112
7
+ data.tar.gz: 28a891931b0b589c8519fe05286a440a200bbdea028eba0dc629b79349b472491ed8a1a2b46e4ee64444ce177f9c28b42c595f273859bd209b97797a1a445956
checksums.yaml.gz.sig CHANGED
Binary file
data.tar.gz.sig CHANGED
Binary file
data/lib/mindwords.rb CHANGED
@@ -29,18 +29,46 @@ class MindWords
29
29
  s, type = RXFHelper.read raws
30
30
 
31
31
  @filepath = raws if type == :file or type == :dfs
32
- @lines = s.strip.gsub(/^\n/,'').lines
33
- @lines.shift if @lines.first =~ /<\?mindwords\?>/
32
+ lines = s.strip.gsub(/^\n/,'').lines.uniq
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
 
37
- def add(line)
38
- @lines << line
59
+ def add(s)
60
+
61
+ @lines.concat s.strip.lines
62
+
39
63
  end
40
64
 
41
65
  def breadcrumb()
42
66
  @parent.attributes[:breadcrumb].split(/ +\/ +/) if @parent
43
67
  end
68
+
69
+ def headings()
70
+ breadcrumb[0..-2]
71
+ end
44
72
 
45
73
 
46
74
  def element(id)
@@ -54,12 +82,31 @@ class MindWords
54
82
  def hashtags()
55
83
  @parent.attributes[:hashtags].split if @parent
56
84
  end
85
+
86
+ # helpful when searching for a word itself using autosuggest
87
+ #
88
+ def lookup(s)
89
+ self.to_words.keys.sort.grep /^#{s}/i
90
+ end
91
+
92
+ # same as #lines but inludes the breadcrumb path; Helpful to identify
93
+ # which words don't have a breadcrumb path.
94
+ #
95
+ def linesplus()
96
+
97
+ to_a.map do |word, _|
98
+ r = search word
99
+ r ? [word, r.breadcrumb] : [r, nil]
100
+ end
101
+
102
+ end
57
103
 
58
104
  def save(file=@filepath)
59
105
 
60
106
  return if @lines.empty?
61
107
 
62
108
  puts 'before save' if @debug
109
+
63
110
  File.write file, to_s()
64
111
 
65
112
  end
@@ -99,7 +146,7 @@ class MindWords
99
146
 
100
147
  end
101
148
 
102
- def search(keyword)
149
+ def search(keyword, succinct: true)
103
150
 
104
151
  a = @lines.grep(/#{keyword}/i).map do |line|
105
152
 
@@ -120,9 +167,32 @@ class MindWords
120
167
  puts 'a2: ' + a2.inspect if @debug
121
168
  e = element(keyword.downcase.gsub(/ +/,'-'))
122
169
 
123
- return nil if e.nil?
170
+ return MindWords.new(a2.uniq.join, debug: @debug) if e.nil?
171
+
172
+ # find and add any linkage support lines
173
+ #
174
+
175
+ a3 = []
176
+
177
+ a2.each do |line|
178
+
179
+ line.chomp.scan(/#[^ ]+/).each do |hashtag|
180
+
181
+ puts 'hashtag: ' + hashtag.inspect if @debug
182
+ r2 = @lines.grep(/^#{hashtag[1..-1]} #/)
183
+ a3 << r2.first if r2
184
+
185
+ end
186
+ end
187
+
188
+ puts 'a2: ' + a2.inspect if @debug
189
+ a2.concat a3
124
190
 
125
- MindWords.new(a2.join, parent: e, debug: @debug)
191
+ if succinct then
192
+ MindWords.new(a2.uniq.join, parent: e, debug: @debug)
193
+ else
194
+ MindWords.new(a2.uniq.join, debug: @debug)
195
+ end
126
196
 
127
197
  end
128
198
 
@@ -183,8 +253,17 @@ class MindWords
183
253
  end
184
254
 
185
255
  def to_outline(sort: true)
256
+
186
257
  build()
187
- sort ? a2tree(tree_sort(LineTree.new(@outline).to_a)) : @outline
258
+
259
+ if sort then
260
+ a = LineTree.new(@outline).to_a
261
+ puts ('a: ' + a.inspect).debug if @debug
262
+ a2tree(tree_sort(a))
263
+ else
264
+ @outline
265
+ end
266
+
188
267
  end
189
268
 
190
269
  alias to_tree to_outline
@@ -233,12 +312,12 @@ class MindWords
233
312
 
234
313
  @lines.each do |line|
235
314
 
236
- title, rawtags = line.split(/ (?=#)/,2)
315
+ title, rawtags = line.split(/(?= #)/,2)
237
316
 
238
317
  rawtags.scan(/#(\w+)/).flatten(1).each do |rawtag|
239
318
  tag = rawtag.gsub(/ +/, '_')
240
319
  h[tag] ||= []
241
- h[tag] << title
320
+ h[tag] << title.strip
242
321
  end
243
322
 
244
323
  end
@@ -280,17 +359,35 @@ class MindWords
280
359
  e.backtrack.to_s if dups
281
360
 
282
361
  end
362
+
363
+ puts 'redundants: ' + redundants.inspect if @debug
283
364
 
284
365
  redundants.compact.each {|x| doc.element(x).delete }
285
366
 
286
-
287
367
  node = if @parent then
288
368
  found = doc.root.element('//' + @parent.name)
289
- found ? found : doc.root
369
+ found ? found.parent : doc.root
290
370
  else
291
371
  doc.root
292
372
  end
293
373
 
374
+ # the following removes any undescore prefix from words which were the
375
+ # same as the hashtag
376
+
377
+ node.root.each_recursive do |e|
378
+
379
+ next unless e
380
+ puts 'e: ' + e.inspect if @debug
381
+
382
+ e.attributes[:id] = e.attributes[:id].sub(/^_/,'') if e.attributes[:id]
383
+ e.attributes[:title] = e.attributes[:title].sub(/^_/,'') if e.attributes[:title]
384
+ e.value = e.value.sub(/^_/,'')
385
+ e.name = e.name.sub(/^_/,'')
386
+
387
+ end
388
+
389
+ # ----
390
+
294
391
  @outline = treeize node
295
392
 
296
393
  node.root.each_recursive do |e|
@@ -353,7 +450,7 @@ class MindWords
353
450
 
354
451
  duplicates.each do |path|
355
452
 
356
- puts 'path: ' + path.inspect if @debug
453
+ puts 'pathx: ' + path.inspect if @debug
357
454
  e = doc.element(path)
358
455
  e.delete if e
359
456
 
@@ -399,3 +496,25 @@ class MindWords
399
496
 
400
497
  end
401
498
 
499
+ class MindWordsWidget
500
+
501
+ def initialize()
502
+
503
+ end
504
+
505
+
506
+ # can be used for main entries or a words list
507
+ #
508
+ def input(content: '', action: 'mwupdate', target: 'icontent')
509
+
510
+ <<EOF
511
+ <form action='#{action}' method='post' target='#{target}'>
512
+ <textarea name='content' cols='30' rows='19'>
513
+ #{content}
514
+ </textarea>
515
+ <input type='submit' value='Submit'/>
516
+ </form>
517
+ EOF
518
+ end
519
+
520
+ 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.6
4
+ version: 0.6.4
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-02-25 00:00:00.000000000 Z
38
+ date: 2021-06-30 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.1
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.1
59
+ version: 0.9.2
60
60
  - !ruby/object:Gem::Dependency
61
61
  name: rxfhelper
62
62
  requirement: !ruby/object:Gem::Requirement
@@ -103,8 +103,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
103
103
  - !ruby/object:Gem::Version
104
104
  version: '0'
105
105
  requirements: []
106
- rubyforge_project:
107
- rubygems_version: 2.7.10
106
+ rubygems_version: 3.1.2
108
107
  signing_key:
109
108
  specification_version: 4
110
109
  summary: Helps get what's in your mind into a structure using words and hashtags.
metadata.gz.sig CHANGED
Binary file