dynarex-blog 0.4.1 → 0.4.2
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/dynarex-blog.rb +12 -5
- metadata +2 -2
data/lib/dynarex-blog.rb
CHANGED
@@ -21,6 +21,7 @@ class DynarexBlog
|
|
21
21
|
|
22
22
|
@hc_result = HashCache.new(size: 10)
|
23
23
|
@hc_entry_file = HashCache.new(size: 10)
|
24
|
+
@hc_lookup_a = HashCache.new(size: 10)
|
24
25
|
super()
|
25
26
|
end
|
26
27
|
|
@@ -124,18 +125,22 @@ class DynarexBlog
|
|
124
125
|
|
125
126
|
def page(number=0)
|
126
127
|
lookup = @current_lookup
|
127
|
-
|
128
|
+
|
128
129
|
result = nil
|
129
130
|
|
130
131
|
result = @hc_result.read(lookup + number.to_s) do
|
131
132
|
|
132
133
|
if (number == 1) and (lookup == '_entry_lookup.xml') and (@index.records.length == 10) then
|
133
|
-
doc = @hc_lookup.read(
|
134
|
+
doc = @hc_lookup.read(lookup)
|
134
135
|
r = Document.new(File.open(@file_path + 'index.xml','r').read)
|
135
136
|
else
|
136
137
|
doc = @hc_lookup.read(lookup) { Document.new File.open(@file_path + lookup,'r').read }
|
137
|
-
r = select_page(doc, number)
|
138
|
-
@
|
138
|
+
r = select_page(doc, number)
|
139
|
+
@current_lookup = '_entry_lookup.xml'
|
140
|
+
|
141
|
+
# refresh to maintain _entry_lookup in the cache
|
142
|
+
@hc_lookup.refresh(@current_lookup)
|
143
|
+
@hc_lookup_a.refresh(@current_lookup)
|
139
144
|
end
|
140
145
|
|
141
146
|
total_records = XPath.first(doc.root, 'count(records/entry)')
|
@@ -191,7 +196,9 @@ class DynarexBlog
|
|
191
196
|
x1 = (number - 1) * 10
|
192
197
|
x2 = x1 + 9
|
193
198
|
|
194
|
-
|
199
|
+
lookup_a = @hc_lookup_a.read(@current_lookup + number) {XPath.match(doc.root,'records/entry')}
|
200
|
+
a = lookup_a.reverse[x1..x2]
|
201
|
+
|
195
202
|
|
196
203
|
xpath_ids = "entry[%s]" % a.map{|x| x.text('id').to_s}.map{|x| "@id='%s'" % x}.join(' or ')
|
197
204
|
|
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.4.
|
4
|
+
version: 0.4.2
|
5
5
|
platform: ruby
|
6
6
|
authors: []
|
7
7
|
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2010-07-
|
12
|
+
date: 2010-07-24 00:00:00 +01:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|