liveblog-indexer 0.2.1 → 0.2.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
  SHA1:
3
- metadata.gz: f82780521af1cc06c3f824c15200ce00745a99b7
4
- data.tar.gz: 66819da8961da8a60b3e7441318d9f898274893f
3
+ metadata.gz: bdf1e31d0bd7d2da43b214f60ecd77eaa740426e
4
+ data.tar.gz: 264c5343aae6597ee1fab84227b3185c54481cbe
5
5
  SHA512:
6
- metadata.gz: dbea6b4324aaad28c221b24d57b9bb06801d74678dbd0953dc54d3602f39e115b74e12cb66e90c2a86ef769d2432313b533afc3fd19b6eda5f9fcec189e112ac
7
- data.tar.gz: 0b9dbb25e21b8adf798a4bc766ae338821b2b4e79f7e44ad9c76e4311ae868233a407ceb55669c80ae90c688134e7d474fe63cf36b8d173266c5433c74e50bff
6
+ metadata.gz: 7be5a06fb8e059c47d7f96ce9aa96c81367c4c686d25603de97106958ab02d32a7c76a72a163d679caa43b20a31a5a90e8041ef9486d61a344cc6143e560a9a5
7
+ data.tar.gz: 114e0fad758ea18acad85c169f0be6244a7d9c8f809a9200cd865c44c606eaee1831477d50449e5da4b237a0487baf58d6d3dd70d9dd47cfe8eb7c60ba66e20d
checksums.yaml.gz.sig CHANGED
Binary file
data.tar.gz.sig CHANGED
Binary file
@@ -9,19 +9,22 @@ require 'rxfhelper'
9
9
 
10
10
  class LiveBlogIndexer
11
11
 
12
- def initialize(filepath='wordindex.json', urls_indexed: 'urls-indexed.json')
12
+ def initialize(filepath: '.', word_index: 'wordindex.json', \
13
+ url_index: 'url_index.json')
13
14
 
14
- @wordindex_filepath, @urls_index_filepath = filepath, urls_indexed
15
- @master = if filepath and File.exists? filepath then
16
- JSON.parse(File.read(filepath))
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 urls_indexed and File.exists? urls_indexed then
24
- JSON.parse(File.read(urls_indexed))
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(filepath=nil)
83
+ def save(filename='wordindex.json')
81
84
 
82
- File.write filepath, @master.to_json
83
- puts 'saved ' + File.basename(filepath)
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
- @url_index[url] = {last_indexed: Time.now}
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.1
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-13 00:00:00.000000000 Z
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