pxindex 0.1.0 → 0.1.1
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/lib/pxindex.rb +31 -25
- data.tar.gz.sig +0 -0
- metadata +2 -2
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: aa8e72a6b88709e91b08b64c3b69a6555d0bde8b
|
4
|
+
data.tar.gz: e7f0839043b1ed3db016c13e298bb7c19b3e9c66
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 377ef810ad44ba95317d470f74bef51f3e40cf4b02ae7e6429f2baaa92e549dad20f4efbe30befa1838c0ae640dee92df67e7f93cc86f46d8ca91f96907b8a2c
|
7
|
+
data.tar.gz: 9c506a295da08a6e25a029dbec93b00889868204ba39f95931af74820ce97f9fb316796c0f7f68240caf48d55b55194e7a4e19add4006ac7e3dce31ce666f7de
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data/lib/pxindex.rb
CHANGED
@@ -13,25 +13,24 @@ class PxIndex
|
|
13
13
|
s, _ = RXFHelper.read raw_s
|
14
14
|
|
15
15
|
@px = PolyrexHeadings.new(s).to_polyrex
|
16
|
-
@
|
16
|
+
@rs = @px.records
|
17
17
|
|
18
18
|
@s = ''
|
19
|
-
@result = nil
|
20
19
|
|
21
20
|
end
|
22
21
|
|
23
22
|
def q?(s)
|
24
23
|
|
25
|
-
if s.length
|
24
|
+
if (s.length - @s.length).abs > 1 or s[0..-2] != @s then
|
26
25
|
|
27
|
-
@
|
26
|
+
@rs = @px.records
|
28
27
|
|
29
28
|
s2 = ''
|
30
29
|
|
31
30
|
a = s.chars.map do |x|
|
32
31
|
|
33
32
|
s2 += x
|
34
|
-
found = search_records(s2, @
|
33
|
+
found = search_records(s2, @rs)
|
35
34
|
|
36
35
|
break if not found
|
37
36
|
found
|
@@ -44,7 +43,7 @@ class PxIndex
|
|
44
43
|
|
45
44
|
i = s.length-1
|
46
45
|
|
47
|
-
records = search_records(s, @
|
46
|
+
records = search_records(s, @rs)
|
48
47
|
|
49
48
|
@s = s
|
50
49
|
|
@@ -57,38 +56,45 @@ class PxIndex
|
|
57
56
|
|
58
57
|
private
|
59
58
|
|
60
|
-
def search_records(raw_s,
|
61
|
-
|
62
|
-
return @result if raw_s[-1] == ' '
|
63
|
-
keywords = raw_s.split(/ /)
|
59
|
+
def search_records(raw_s, rs=@rs)
|
64
60
|
|
65
|
-
|
61
|
+
|
62
|
+
if raw_s[-1] == ' ' then
|
66
63
|
|
67
|
-
|
68
|
-
stack << r if r.any?
|
69
|
-
|
70
|
-
keywords.last
|
64
|
+
child_records = rs.flat_map(&:records)
|
71
65
|
|
72
|
-
|
73
|
-
|
66
|
+
if child_records.length > 0 then
|
67
|
+
@rs = child_records
|
68
|
+
return child_records
|
69
|
+
else
|
70
|
+
return nil
|
71
|
+
end
|
74
72
|
end
|
73
|
+
|
74
|
+
keywords = raw_s.split(/ /)
|
75
|
+
|
76
|
+
s = keywords.length > 1 ? keywords.last : raw_s
|
75
77
|
|
76
|
-
a =
|
78
|
+
a = rs.select {|x| x.title[0..s.length-1] == s}
|
77
79
|
|
78
|
-
if a.any? then
|
80
|
+
if s.length == 1 and a.any? and keywords.length < 2 then
|
81
|
+
a = a.first.records
|
82
|
+
end
|
83
|
+
|
84
|
+
if a.any? then
|
79
85
|
|
80
|
-
|
81
|
-
#@result = a.map(&:title)
|
82
|
-
@result = a
|
86
|
+
@rs = a
|
83
87
|
|
84
88
|
else
|
85
89
|
|
86
|
-
|
90
|
+
return nil unless keywords.length > 1
|
91
|
+
|
92
|
+
r = rs.flat_map(&:records)
|
87
93
|
|
88
94
|
if r.any? then
|
89
95
|
|
90
|
-
|
91
|
-
search_records(s,
|
96
|
+
@rs = r
|
97
|
+
search_records(s, rs)
|
92
98
|
|
93
99
|
else
|
94
100
|
|
data.tar.gz.sig
CHANGED
Binary file
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pxindex
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- James Robertson
|
@@ -31,7 +31,7 @@ cert_chain:
|
|
31
31
|
MrilunBr0ny9pMGbDRKeTfgMh9LinxPgD3BjXqZ78prB3LDxWO8kA/yDt5sLGSiq
|
32
32
|
n8uRSvQvGormuQ==
|
33
33
|
-----END CERTIFICATE-----
|
34
|
-
date: 2016-
|
34
|
+
date: 2016-12-01 00:00:00.000000000 Z
|
35
35
|
dependencies:
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: polyrex-headings
|
metadata.gz.sig
CHANGED
Binary file
|