mindwords 0.6.1 → 0.6.3

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: 1513378395921df0332fa183e9f1bbbb4de0effebaa125ac9cbdaaf5c2043a53
4
- data.tar.gz: 0fdbe75ed727876a2ba3e62c4d67cf9f21bcd64b61cb252cb795b5ae260d0859
3
+ metadata.gz: 18ab26d7ab5ff288172a06294982093e97db2b22998cb627ce5f7201dac62a6f
4
+ data.tar.gz: b717eb9f9b9c99d88ed27b33913834f361ceb5715fd9e4e7bdff3bcf7abf9089
5
5
  SHA512:
6
- metadata.gz: 85b57f0e300b6859f4c98a2263920eb5a65014c74711e021f1c52144d6c32c224df4691d8bef4b90b9a69e7f6a95d67e043ccc1100255ac96c6dfe746a592adb
7
- data.tar.gz: dd2ea283e94912e221dfcc463c1f5270ad751b0e7fc968abb6bb19b7dedfe91d29b93fbe3312c96d3726b6d3067b5a7a4d73ee469bf74fc0311423668755edef
6
+ metadata.gz: ab92bd3423e50ad635cfd986d817a874db78b2fb7d57db01300400ce4dd5d267d706e1e642442c6bf4d9b5a84448d8be0fe0c13684cf3cfb160523e67da251d0
7
+ data.tar.gz: b7b6e3e7971d76f3cd42989a2b69fb6e1d5a933c80f5bcfa61fc65542819ecc2d9b711f7d4af8d77ad8a9d3f4cf7e8a310cd1ce68574d511fbfa2e73af020c13
checksums.yaml.gz.sig CHANGED
Binary file
data.tar.gz.sig CHANGED
Binary file
data/lib/mindwords.rb CHANGED
@@ -29,7 +29,7 @@ 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
32
+ lines = s.strip.gsub(/^\n/,'').lines.uniq
33
33
  lines.shift if lines.first =~ /<\?mindwords\?>/
34
34
 
35
35
  @lines = lines.inject([]) do |r,line|
@@ -56,8 +56,10 @@ class MindWords
56
56
 
57
57
  end
58
58
 
59
- def add(line)
60
- @lines << line
59
+ def add(s)
60
+
61
+ @lines.concat s.strip.lines
62
+
61
63
  end
62
64
 
63
65
  def breadcrumb()
@@ -80,13 +82,36 @@ class MindWords
80
82
  def hashtags()
81
83
  @parent.attributes[:hashtags].split if @parent
82
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
83
103
 
84
104
  def save(file=@filepath)
85
105
 
86
106
  return if @lines.empty?
87
107
 
88
108
  puts 'before save' if @debug
89
- File.write file, to_s()
109
+
110
+ if File.exists? file then
111
+ File.write file, to_s()
112
+ else
113
+ raise 'Filepath not given'
114
+ end
90
115
 
91
116
  end
92
117
 
@@ -232,8 +257,17 @@ class MindWords
232
257
  end
233
258
 
234
259
  def to_outline(sort: true)
260
+
235
261
  build()
236
- sort ? a2tree(tree_sort(LineTree.new(@outline).to_a)) : @outline
262
+
263
+ if sort then
264
+ a = LineTree.new(@outline).to_a
265
+ puts ('a: ' + a.inspect).debug if @debug
266
+ a2tree(tree_sort(a))
267
+ else
268
+ @outline
269
+ end
270
+
237
271
  end
238
272
 
239
273
  alias to_tree to_outline
@@ -329,6 +363,8 @@ class MindWords
329
363
  e.backtrack.to_s if dups
330
364
 
331
365
  end
366
+
367
+ puts 'redundants: ' + redundants.inspect if @debug
332
368
 
333
369
  redundants.compact.each {|x| doc.element(x).delete }
334
370
 
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.6.1
4
+ version: 0.6.3
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-04-09 00:00:00.000000000 Z
38
+ date: 2021-05-24 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