liveblog-indexer 0.2.1 → 0.2.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/liveblog-indexer.rb +17 -14
- 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: bdf1e31d0bd7d2da43b214f60ecd77eaa740426e
|
4
|
+
data.tar.gz: 264c5343aae6597ee1fab84227b3185c54481cbe
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7be5a06fb8e059c47d7f96ce9aa96c81367c4c686d25603de97106958ab02d32a7c76a72a163d679caa43b20a31a5a90e8041ef9486d61a344cc6143e560a9a5
|
7
|
+
data.tar.gz: 114e0fad758ea18acad85c169f0be6244a7d9c8f809a9200cd865c44c606eaee1831477d50449e5da4b237a0487baf58d6d3dd70d9dd47cfe8eb7c60ba66e20d
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data.tar.gz.sig
CHANGED
Binary file
|
data/lib/liveblog-indexer.rb
CHANGED
@@ -9,19 +9,22 @@ require 'rxfhelper'
|
|
9
9
|
|
10
10
|
class LiveBlogIndexer
|
11
11
|
|
12
|
-
def initialize(filepath
|
12
|
+
def initialize(filepath: '.', word_index: 'wordindex.json', \
|
13
|
+
url_index: 'url_index.json')
|
13
14
|
|
14
|
-
@wordindex_filepath, @urls_index_filepath = filepath,
|
15
|
-
|
16
|
-
|
15
|
+
@filepath, @wordindex_filepath, @urls_index_filepath = filepath, \
|
16
|
+
word_index, url_index
|
17
|
+
@master = if word_index and File.exists? File.join(filepath,word_index) then
|
18
|
+
JSON.parse(File.read(File.join(filepath, word_index)))
|
17
19
|
else
|
18
20
|
{}
|
19
21
|
end
|
20
22
|
|
21
23
|
@xws = XWS.new
|
22
24
|
|
23
|
-
@url_index = if
|
24
|
-
|
25
|
+
@url_index = if url_index and \
|
26
|
+
File.exists? File.join(filepath, url_index) then
|
27
|
+
JSON.parse(File.read(File.join(filepath, url_index)))
|
25
28
|
else
|
26
29
|
{}
|
27
30
|
end
|
@@ -73,21 +76,21 @@ class LiveBlogIndexer
|
|
73
76
|
|
74
77
|
index_file location
|
75
78
|
save @wordindex_filepath
|
76
|
-
File.write @urls_index_filepath, @url_index.to_json
|
79
|
+
File.write File.join(@filepath, @urls_index_filepath), @url_index.to_json
|
77
80
|
|
78
81
|
end
|
79
82
|
|
80
|
-
def save(
|
83
|
+
def save(filename='wordindex.json')
|
81
84
|
|
82
|
-
File.write filepath, @master.to_json
|
83
|
-
puts 'saved ' +
|
85
|
+
File.write File.join(@filepath, filename), @master.to_json
|
86
|
+
puts 'saved ' + filename
|
84
87
|
|
85
88
|
end
|
86
89
|
|
87
90
|
private
|
88
91
|
|
89
92
|
def index_file(location)
|
90
|
-
|
93
|
+
|
91
94
|
return if @url_index.has_key? location
|
92
95
|
|
93
96
|
puts 'indexing : ' + location.inspect
|
@@ -96,16 +99,16 @@ class LiveBlogIndexer
|
|
96
99
|
return unless summary
|
97
100
|
|
98
101
|
result = add_index doc
|
102
|
+
|
99
103
|
return unless result
|
104
|
+
@url_index[location] = {last_indexed: Time.now}
|
100
105
|
|
101
106
|
prev_day = summary.text 'prev_day'
|
102
107
|
|
103
108
|
if prev_day then
|
104
109
|
url = prev_day + 'formatted.xml'
|
105
|
-
|
106
|
-
index_file(url)
|
110
|
+
index_file(url)
|
107
111
|
end
|
108
112
|
end
|
109
113
|
|
110
|
-
|
111
114
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: liveblog-indexer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- James Robertson
|
@@ -31,7 +31,7 @@ cert_chain:
|
|
31
31
|
mOnsi2V1CXpq2biJtSgD7mBx4cO9FXgbK3Xnsv45ygAPo6jj4Eb34udqz+0v88Ys
|
32
32
|
KoTqNQOniHAW2w==
|
33
33
|
-----END CERTIFICATE-----
|
34
|
-
date: 2015-11-
|
34
|
+
date: 2015-11-15 00:00:00.000000000 Z
|
35
35
|
dependencies:
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: xws
|
metadata.gz.sig
CHANGED
Binary file
|