dynarex-blog 0.2.9 → 0.2.10

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.
Files changed (2) hide show
  1. data/lib/dynarex-blog.rb +21 -17
  2. metadata +1 -1
data/lib/dynarex-blog.rb CHANGED
@@ -16,7 +16,8 @@ class DynarexBlog
16
16
  @file_path = file_path[/\/$/] ? file_path : file_path + '/'
17
17
  if File.exists? (@file_path + 'index.xml') then open(@file_path) else fresh_start() end
18
18
  @current_lookup = '_entry_lookup.xml'
19
- @hashcache = HashCache.new(size: 5)
19
+ @hc_lookup = HashCache.new(size: 5)
20
+ @hc_result = HashCache.new(size: 5)
20
21
  super()
21
22
  end
22
23
 
@@ -143,27 +144,30 @@ class DynarexBlog
143
144
  def select_page(lookup, number)
144
145
 
145
146
  #doc = Document.new File.open(@file_path + lookup,'r').read
146
- doc = @hashcache.read(lookup) { Document.new File.open(@file_path + lookup,'r').read }
147
- x1 = (number - 1) * 10
148
- x2 = x1 + 9
147
+ doc = @hc_lookup.read(lookup) { Document.new File.open(@file_path + lookup,'r').read }
148
+
149
+ result = @hc_result.read(lookup + number.to_s) {
150
+ x1 = (number - 1) * 10
151
+ x2 = x1 + 9
149
152
 
150
- a = XPath.match(doc.root,'records/entry').reverse[x1..x2]
153
+ a = XPath.match(doc.root,'records/entry').reverse[x1..x2]
151
154
 
152
- xpath_ids = "entry[%s]" % a.map{|x| x.text('id').to_s}.map{|x| "@id='%s'" % x}.join(' or ')
155
+ xpath_ids = "entry[%s]" % a.map{|x| x.text('id').to_s}.map{|x| "@id='%s'" % x}.join(' or ')
153
156
 
154
- temp_doc = Document.new '<root/>'
155
- a.map{|x| x.text('file').to_s}.uniq.each do |file|
156
- doc_entryx = Document.new File.open(@file_path + file,'r').read
157
- XPath.each(doc_entryx.root,'records/entry') do |entry|
158
- temp_doc.root.add entry
157
+ temp_doc = Document.new '<root/>'
158
+ a.map{|x| x.text('file').to_s}.uniq.each do |file|
159
+ doc_entryx = Document.new File.open(@file_path + file,'r').read
160
+ XPath.each(doc_entryx.root,'records/entry') do |entry|
161
+ temp_doc.root.add entry
162
+ end
159
163
  end
160
- end
161
164
 
162
- result = Document.new '<result><summary/><records/></result>'
163
- records = XPath.first(result.root, 'records')
164
- XPath.each(temp_doc.root, xpath_ids) do |record|
165
- records.add record
166
- end
165
+ result = Document.new '<result><summary/><records/></result>'
166
+ records = XPath.first(result.root, 'records')
167
+ XPath.each(temp_doc.root, xpath_ids) do |record|
168
+ records.add record
169
+ end
170
+ }
167
171
 
168
172
  result
169
173
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dynarex-blog
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.9
4
+ version: 0.2.10
5
5
  platform: ruby
6
6
  authors: []
7
7