dynarex-blog 0.2.13 → 0.3.0
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.
- data/lib/dynarex-blog.rb +19 -20
- metadata +2 -2
data/lib/dynarex-blog.rb
CHANGED
@@ -18,6 +18,7 @@ class DynarexBlog
|
|
18
18
|
@current_lookup = '_entry_lookup.xml'
|
19
19
|
@hc_lookup = HashCache.new(size: 5)
|
20
20
|
@hc_result = HashCache.new(size: 5)
|
21
|
+
@hc_entry_file = HashCache.new(size: 5)
|
21
22
|
super()
|
22
23
|
end
|
23
24
|
|
@@ -115,7 +116,7 @@ class DynarexBlog
|
|
115
116
|
def page(number=1)
|
116
117
|
current_lookup = @current_lookup
|
117
118
|
@current_lookup = '_entry_lookup.xml'
|
118
|
-
select_page(current_lookup, number)
|
119
|
+
@hc_result.read(current_lookup + number.to_s) { select_page(current_lookup, number) }
|
119
120
|
end
|
120
121
|
|
121
122
|
def tag(tag)
|
@@ -146,30 +147,28 @@ class DynarexBlog
|
|
146
147
|
#doc = Document.new File.open(@file_path + lookup,'r').read
|
147
148
|
doc = @hc_lookup.read(lookup) { Document.new File.open(@file_path + lookup,'r').read }
|
148
149
|
|
149
|
-
|
150
|
-
|
151
|
-
x2 = x1 + 9
|
150
|
+
x1 = (number - 1) * 10
|
151
|
+
x2 = x1 + 9
|
152
152
|
|
153
|
-
|
153
|
+
a = XPath.match(doc.root,'records/entry').reverse[x1..x2]
|
154
154
|
|
155
|
-
|
155
|
+
xpath_ids = "entry[%s]" % a.map{|x| x.text('id').to_s}.map{|x| "@id='%s'" % x}.join(' or ')
|
156
156
|
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
end
|
157
|
+
temp_doc = Document.new '<root/>'
|
158
|
+
a.map{|x| x.text('file').to_s}.uniq.each do |file|
|
159
|
+
doc_entryx = Document.new( @@hc_entry_file.read(file) {File.open(@file_path + file,'r').read})
|
160
|
+
XPath.each(doc_entryx.root,'records/entry') do |entry|
|
161
|
+
temp_doc.root.add entry
|
163
162
|
end
|
163
|
+
end
|
164
|
+
|
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
|
+
result
|
164
171
|
|
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
|
-
result
|
171
|
-
}
|
172
|
-
r
|
173
172
|
|
174
173
|
end
|
175
174
|
|
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
|
+
version: 0.3.0
|
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-18 00:00:00 +01:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|