mindwords 0.7.0 → 0.8.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0d7be53f70e76eda32325d70cce4e3eb690799b1403440eaff8329929dc4082c
4
- data.tar.gz: fa87c01d3bff8ff57506fbb0eb801ff7d881dc2aff607fbc0142e457e658b005
3
+ metadata.gz: 1f5bf74dd560883c0f522b3bf9eb94ba34e1655360347bb25871762e4c592cc1
4
+ data.tar.gz: 8da5c28a10e9086c72f82eb7615af347da8ec80432249f4716f866c6450b8baf
5
5
  SHA512:
6
- metadata.gz: f01791819abc0b4a78b2573c2513b5dc929142a318bf30d0f3c052ea1b654e03d0462c3fddae891be170d23b03d5fa4512dedd5c85b678ac633481d3bdecd798
7
- data.tar.gz: b99eec4aa8a9a47c3e73b690727cbcc7bf16a1c0f43699fb399f309c8a752d94c7eb5128c5df998679ea0fdc1eeca14d005954e5476a75e74b0d59ef8ac1181f
6
+ metadata.gz: 361eee1873d6b3aa00ccfc415485c86723e28f398b19824d2e9f7b42322304579a9d672db7e4f13b5caa6711fee38028c4a0e361bdddf27451417a77a5476d64
7
+ data.tar.gz: 1eb29c350266e6122059017955e2ae615fb8368aec887df5fc6a6ac18aed7d8a3fbfe1ea0cdc6e6fe2050a55d0b7b9cd753e1280d2b101a0a765d9d6d29603fa
checksums.yaml.gz.sig CHANGED
@@ -1,2 +1,4 @@
1
- M:�e5ja8�>���
2
- 6�$zfI�՛ ��
1
+ v�u+x��g���^��hg�a� OYH���Rk����ўƯ��P�y�GC��E�(�/�;c����r9%�sL�v}%�֙I|Z��r�a��`���;���
2
+ ��Z����z���EyKP�"S?���rui}j5-�Y[�����
3
+ z4�=5���3{�kة՚x��16��I�����gįKQg%���T���zm��x'��agv*3���J(�Ta�_�R��
4
+ �<���B�-*�X�&�7>ȺF���ӌÀ�A:M^��y!�6��<{.T`a���֚�Ukڿ��p��)�Ó:"�2 �S/J=�N�͉��
data/lib/mindwords.rb CHANGED
@@ -5,6 +5,8 @@
5
5
  require 'rexle'
6
6
  require 'rxfreadwrite'
7
7
  require 'line-tree'
8
+ require 'polyrex'
9
+
8
10
 
9
11
  module HashCopy
10
12
  refine Hash do
@@ -73,7 +75,7 @@ class MindWords
73
75
 
74
76
  def import(raws)
75
77
 
76
- s, type = RXFHelper.read raws
78
+ s, type = RXFReader.read raws
77
79
 
78
80
  @filepath = raws if type == :file or type == :dfs
79
81
  lines = (s.strip.gsub(/(^\n|\r)/,'') + "\n").lines.uniq
@@ -578,3 +580,99 @@ EOF
578
580
  end
579
581
 
580
582
  end
583
+
584
+ class MindWordsPlus
585
+
586
+ attr_reader :to_px
587
+
588
+ def initialize(s, fields: %w(title content), debug: false)
589
+
590
+ lt = LineTree.new(s)
591
+ h = lt.to_h
592
+
593
+ mw = MindWords.new(h.keys.join("\n"))
594
+ outline = mw.to_outline
595
+
596
+ out = outline.lines.map do |line|
597
+
598
+ word = line[/\w[^$]+/]
599
+
600
+ found = h.keys.find do |key, value|
601
+
602
+ if debug then
603
+ puts 'key2: ' + key[/^[^#]+(?= #)/].inspect
604
+ puts 'word: ' + word.chomp.inspect
605
+ end
606
+
607
+ word.chomp == key[/^[^#]+(?= #)/]
608
+ end
609
+
610
+ puts 'found: ' + found.inspect if debug
611
+
612
+ if found and h[found][:body] then
613
+ puts '***' + h[found][:body].keys.inspect if debug
614
+ line.chomp + ' # ' + h[found][:body].keys.join('<br/>') + "\n"
615
+ else
616
+ line
617
+ end
618
+
619
+ end
620
+
621
+ puts out.join if debug
622
+
623
+ px = Polyrex.new(schema: "entries[title]/entry[#{fields.join(', ')}]",
624
+ delimiter: ' # ')
625
+ px.import out.join
626
+ @px = px
627
+
628
+ end
629
+
630
+ def to_ph()
631
+
632
+ lines = []
633
+
634
+ @px.each_recursive do |x, parent, level|
635
+
636
+ if level.to_i < 3 then
637
+ line = ("\n" + '#' * (level.to_i + 1)) + ' ' + x.title + "\n\n"
638
+ else
639
+ line = '*' + ' ' + x.title + "\n"
640
+ end
641
+
642
+ if x.content.length >= 1 then
643
+ txt = '- ' + x.content.gsub('&lt;','<').gsub('&gt;','>')
644
+ line += "\n" + txt.gsub('<br/>',"\n- ") + "\n"
645
+ end
646
+
647
+ lines << line
648
+
649
+ end
650
+
651
+ lines.join.gsub(/\n\n\n/,"\n\n")
652
+ end
653
+
654
+ def to_px()
655
+ @px
656
+ end
657
+
658
+ def to_tree()
659
+
660
+ lines = []
661
+ @px.each_recursive do |x, parent, level|
662
+
663
+ line = (' ' * level) + x.title
664
+
665
+ if x.content.length >= 1 then
666
+ txt = x.content.gsub('&lt;','<').gsub('&gt;','>')
667
+ indent = ' ' * (level+1) + '* '
668
+ line += "\n" + indent + txt.gsub('<br/>',"\n" + indent)
669
+ end
670
+
671
+ lines << line
672
+ end
673
+
674
+ lines.join("\n")
675
+
676
+ end
677
+
678
+ end
data.tar.gz.sig CHANGED
Binary file
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.7.0
4
+ version: 0.8.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Robertson
@@ -35,48 +35,28 @@ cert_chain:
35
35
  eUqhPOSrxIRLebVebvo/SHN6+ed3Q1tXowsbLGCT9QwqbaZ5MZ7zks92mIWeJvsA
36
36
  JdpabIXfcOANNKd0ha4NO+Yu
37
37
  -----END CERTIFICATE-----
38
- date: 2022-03-15 00:00:00.000000000 Z
38
+ date: 2022-03-16 00:00:00.000000000 Z
39
39
  dependencies:
40
40
  - !ruby/object:Gem::Dependency
41
- name: line-tree
41
+ name: polyrex
42
42
  requirement: !ruby/object:Gem::Requirement
43
43
  requirements:
44
44
  - - "~>"
45
45
  - !ruby/object:Gem::Version
46
- version: '0.9'
46
+ version: '1.4'
47
47
  - - ">="
48
48
  - !ruby/object:Gem::Version
49
- version: 0.9.3
49
+ version: 1.4.1
50
50
  type: :runtime
51
51
  prerelease: false
52
52
  version_requirements: !ruby/object:Gem::Requirement
53
53
  requirements:
54
54
  - - "~>"
55
55
  - !ruby/object:Gem::Version
56
- version: '0.9'
56
+ version: '1.4'
57
57
  - - ">="
58
58
  - !ruby/object:Gem::Version
59
- version: 0.9.3
60
- - !ruby/object:Gem::Dependency
61
- name: rxfreadwrite
62
- requirement: !ruby/object:Gem::Requirement
63
- requirements:
64
- - - "~>"
65
- - !ruby/object:Gem::Version
66
- version: '0.2'
67
- - - ">="
68
- - !ruby/object:Gem::Version
69
- version: 0.2.5
70
- type: :runtime
71
- prerelease: false
72
- version_requirements: !ruby/object:Gem::Requirement
73
- requirements:
74
- - - "~>"
75
- - !ruby/object:Gem::Version
76
- version: '0.2'
77
- - - ">="
78
- - !ruby/object:Gem::Version
79
- version: 0.2.5
59
+ version: 1.4.1
80
60
  description:
81
61
  email: digital.robertson@gmail.com
82
62
  executables: []
metadata.gz.sig CHANGED
Binary file