mindwords 0.5.1 → 0.5.2
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 +19 -5
- metadata +1 -1
- 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: 9674ba7b1779b50888b7e917d46b77baf61fdf06de749e0f74ca924f7be3bd09
|
4
|
+
data.tar.gz: 8e4ecfbf1a91e80515c5095bd9e998a28fbf7d556350ff8e241a4782e17a3652
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 94e2e23bce6a84e5fb5679581271451a6a393cd69655f22f0760cdcecd73f6d93e334d0bb5b3e582090cb970c1b406677da808cc47a6bfa6215bffa6607ba6fc
|
7
|
+
data.tar.gz: 2cee5838d869dc197d63f5db05db62604b72f540c108bdacaf41b07ff2aabd4f96531277ce3694ddfaa926cf3bb881d05b424d89840e9ec955b802e30b3992be
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data.tar.gz.sig
CHANGED
Binary file
|
data/lib/mindwords.rb
CHANGED
@@ -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(
|
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
|
-
|
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
metadata.gz.sig
CHANGED
Binary file
|