dxtitle_search 0.1.1 → 0.2.0
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/dxtitle_search.rb +48 -20
- metadata +2 -2
- 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: febca2af1d5f671487bb3a374e0ce3a3a1c9d1bc61a365a7e264da32f2865d44
|
4
|
+
data.tar.gz: 8fb8561355abb9b169b789fa9388e6c70f12c92521d4dea14594ab74e8ad69d9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c6705c471563eede40e9dd71aa133dc3e5adf9a2f014864c44312aab6a3235bd335648b2dc9a40f6d3d1a339ea50258cfe2c31f56d61f617f67dba5be4237379
|
7
|
+
data.tar.gz: 9268dc3c81722d2e42824a3e6ac175e7c12e4927254fcdb7f95825f3797b060e2c912ba62af4517841c4f076cd3379ee4be48c44e866796037fb7cb27ad2520c
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data.tar.gz.sig
CHANGED
Binary file
|
data/lib/dxtitle_search.rb
CHANGED
@@ -7,25 +7,29 @@ require 'dynarex'
|
|
7
7
|
|
8
8
|
class DxTitleSearch
|
9
9
|
|
10
|
-
def initialize(obj, debug: false)
|
10
|
+
def initialize(obj=nil, sources: nil, debug: false)
|
11
11
|
|
12
12
|
@debug = debug
|
13
13
|
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
14
|
+
s = if sources then
|
15
|
+
|
16
|
+
dx = Dynarex.new(sources)
|
17
|
+
dx.all.map {|x| read x.uri }.join
|
18
|
+
|
19
|
+
elsif obj then
|
20
|
+
|
21
|
+
# is it a Dynarex file location?
|
22
|
+
if obj.lines.length < 2 then
|
23
|
+
|
24
|
+
read obj
|
25
|
+
|
26
|
+
else
|
27
|
+
|
28
|
+
obj
|
29
|
+
|
30
|
+
end
|
27
31
|
end
|
28
|
-
|
32
|
+
|
29
33
|
@h = h = s.lines.inject({}) do |r,x|
|
30
34
|
key, value = x.split(/\s+(?=[^\s]+$)/,2)
|
31
35
|
r.merge(key.rstrip => value)
|
@@ -36,21 +40,34 @@ class DxTitleSearch
|
|
36
40
|
end
|
37
41
|
|
38
42
|
def search(keywords)
|
43
|
+
|
44
|
+
phrases = @a.grep /#{keywords}/i
|
39
45
|
|
40
46
|
# find out the keywords count for each entry found
|
41
|
-
|
47
|
+
a0 = keywords.split.flat_map do |x|
|
48
|
+
next if @a.length < 2
|
49
|
+
@a.grep /#{x}/i
|
50
|
+
end
|
51
|
+
|
52
|
+
a = a0.uniq.map do |entry|
|
42
53
|
[entry, entry.scan(/#{keywords.split.join('|')}/).uniq.count]
|
43
54
|
end
|
44
55
|
|
45
56
|
# sort by keywords found per entry and then date
|
57
|
+
#a2 = (phrases + a).uniq.sort do |x, x2|
|
46
58
|
a2 = a.sort do |x, x2|
|
47
59
|
-([x.last, x.first[/^\d+/], ] <=> [x2.last, x2.first[/^\d+/]])
|
48
60
|
end
|
49
61
|
|
50
62
|
# format each result as a Hash object
|
51
|
-
a3 = a2.map do |x|
|
52
|
-
|
53
|
-
|
63
|
+
a3 = (phrases + a2).map do |x|
|
64
|
+
|
65
|
+
if x.length > 1 then
|
66
|
+
line, _ = x
|
67
|
+
else
|
68
|
+
line = x
|
69
|
+
end
|
70
|
+
|
54
71
|
puts 'line: ' + line.inspect if @debug
|
55
72
|
|
56
73
|
rawtime, title = line.split(/ +/,2)
|
@@ -65,6 +82,17 @@ class DxTitleSearch
|
|
65
82
|
return a3
|
66
83
|
|
67
84
|
end
|
85
|
+
|
86
|
+
private
|
87
|
+
|
88
|
+
def read(source)
|
68
89
|
|
69
|
-
|
90
|
+
dx = Dynarex.new(source)
|
70
91
|
|
92
|
+
dx.all.map do |x|
|
93
|
+
"%d %s %s" % [Time.parse(x.created).to_i, x.title, x.url]
|
94
|
+
end.join("\n")
|
95
|
+
|
96
|
+
end
|
97
|
+
|
98
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dxtitle_search
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- James Robertson
|
@@ -35,7 +35,7 @@ cert_chain:
|
|
35
35
|
ODgOmcgAsTin0T9l0vWQJnj2OClh1pcC6tFnQXXcYuwTpbtM2v4OmUfUDvJmwQ42
|
36
36
|
POydZUYZg49X9TlTDqPMKed0
|
37
37
|
-----END CERTIFICATE-----
|
38
|
-
date: 2019-07
|
38
|
+
date: 2019-08-07 00:00:00.000000000 Z
|
39
39
|
dependencies:
|
40
40
|
- !ruby/object:Gem::Dependency
|
41
41
|
name: dynarex
|
metadata.gz.sig
CHANGED
Binary file
|