mindwords 0.5.1 → 0.5.2

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: cecbfa6443266445084268c94ccedf12ca1f1c4a8e601a510ad49d375c54e910
4
- data.tar.gz: 184f031666fbc23c62ca1fb7b61bbfbce99a1bd88c75072fc9645153f4e1f502
3
+ metadata.gz: 9674ba7b1779b50888b7e917d46b77baf61fdf06de749e0f74ca924f7be3bd09
4
+ data.tar.gz: 8e4ecfbf1a91e80515c5095bd9e998a28fbf7d556350ff8e241a4782e17a3652
5
5
  SHA512:
6
- metadata.gz: 5fd523b6544be615a5a1112deca758af2cc5f6053f03e48c4382acecd413f32db9ed440d572171be342fd64141c0f34debd18f7bd6ebc615cf125029e86ce3f4
7
- data.tar.gz: 047f68b8746aa20cda1bff2e9c09472fee21f70d4f36cee1599576b71f6243b5107e45f632eedf2ab2e953e9df00867dda4b9a94ec13f896f6d38a136cda9ed9
6
+ metadata.gz: 94e2e23bce6a84e5fb5679581271451a6a393cd69655f22f0760cdcecd73f6d93e334d0bb5b3e582090cb970c1b406677da808cc47a6bfa6215bffa6607ba6fc
7
+ data.tar.gz: 2cee5838d869dc197d63f5db05db62604b72f540c108bdacaf41b07ff2aabd4f96531277ce3694ddfaa926cf3bb881d05b424d89840e9ec955b802e30b3992be
Binary file
data.tar.gz.sig CHANGED
Binary file
@@ -22,23 +22,32 @@ class MindWords
22
22
 
23
23
  attr_accessor :lines
24
24
 
25
- def initialize(raws, parent: nil, debug: false)
25
+ def initialize(raws='', parent: nil, debug: false)
26
26
 
27
27
  @parent, @debug = parent, debug
28
-
28
+
29
29
  s, _ = RXFHelper.read raws
30
30
  @lines = s.strip.gsub(/^\n/,'').lines
31
31
  @lines.shift if @lines.first =~ /<\?mindwords\?>/
32
32
 
33
33
  end
34
34
 
35
+ def breadcrumb()
36
+ @parent.attributes[:breadcrumb].split(/ +\/ +/) if @parent
37
+ end
38
+
39
+
35
40
  def element(id)
36
41
 
37
- doc = Rexle.new(@xml)
42
+ doc = Rexle.new(to_xml())
38
43
  e = doc.root.element("//*[@id='#{id}']")
39
44
  #e.attributes[:breadcrumb].to_s if e
40
45
 
41
46
  end
47
+
48
+ def hashtags()
49
+ @parent.attributes[:hashtags].split if @parent
50
+ end
42
51
 
43
52
 
44
53
  def search(keyword)
@@ -60,7 +69,11 @@ class MindWords
60
69
 
61
70
  a2 = a.sort_by(&:last).map(&:first)
62
71
  puts 'a2: ' + a2.inspect if @debug
63
- MindWords.new(a2.join, parent: keyword, debug: @debug)
72
+ e = element(keyword.downcase.gsub(/ +/,'-'))
73
+
74
+ return nil if e.nil?
75
+
76
+ MindWords.new(a2.join, parent: e, debug: @debug)
64
77
 
65
78
  end
66
79
 
@@ -135,6 +148,7 @@ class MindWords
135
148
  end
136
149
 
137
150
  def to_xml()
151
+ build() unless @xml
138
152
  @xml
139
153
  end
140
154
 
@@ -198,7 +212,7 @@ class MindWords
198
212
 
199
213
 
200
214
  node = if @parent then
201
- found = doc.root.element('//' + @parent)
215
+ found = doc.root.element('//' + @parent.name)
202
216
  found ? found : doc.root
203
217
  else
204
218
  doc.root
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.1
4
+ version: 0.5.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Robertson
metadata.gz.sig CHANGED
Binary file