dynarex-blog 0.3.6 → 0.3.7
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/dynarex-blog.rb +25 -18
- metadata +2 -2
data/lib/dynarex-blog.rb
CHANGED
@@ -116,31 +116,38 @@ class DynarexBlog
|
|
116
116
|
end
|
117
117
|
|
118
118
|
def page(number=0)
|
119
|
-
|
119
|
+
lookup = @current_lookup
|
120
120
|
@current_lookup = '_entry_lookup.xml'
|
121
121
|
result = nil
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
122
|
+
|
123
|
+
result = @hc_result.read(lookup + number.to_s) do
|
124
|
+
|
125
|
+
if (number == 1) and (lookup == '_entry_lookup.xml') and (@index.records.length == 10) then
|
126
|
+
doc = @hc_lookup.read('_entry_lookup.xml')
|
127
|
+
r = Document.new(File.open(@file_path + 'index.xml','r').read)
|
128
|
+
else
|
129
|
+
doc = @hc_lookup.read(lookup) { Document.new File.open(@file_path + lookup,'r').read }
|
130
|
+
r = select_page(doc, number)
|
131
|
+
@hc_lookup.read(@current_lookup) # refresh to maintain @current_lookup in the cache
|
132
|
+
end
|
133
|
+
|
134
|
+
[
|
135
|
+
['total_records', XPath.first(doc.root, 'count(records/entry)')],
|
136
|
+
['page_number', number]
|
137
|
+
].each do |name, text|
|
138
|
+
r.root.elements['summary'].add Element.new(name).add_text(text)
|
139
|
+
end
|
140
|
+
|
141
|
+
r
|
128
142
|
end
|
129
|
-
|
143
|
+
|
130
144
|
result
|
131
145
|
end
|
132
146
|
|
133
147
|
def tag(tag)
|
134
148
|
@current_lookup = tag + '_lookup.xml'
|
135
149
|
self
|
136
|
-
end
|
137
|
-
|
138
|
-
def length
|
139
|
-
doc = @hc_lookup.read('_entry_lookup.xml')
|
140
|
-
XPath.first(doc.root, 'count(records/entry)')
|
141
|
-
end
|
142
|
-
|
143
|
-
alias size length
|
150
|
+
end
|
144
151
|
|
145
152
|
private
|
146
153
|
|
@@ -159,10 +166,9 @@ class DynarexBlog
|
|
159
166
|
[lookup, XPath.first(lookup.root, "records/entry[id='#{id}']")]
|
160
167
|
end
|
161
168
|
|
162
|
-
def select_page(
|
169
|
+
def select_page(doc, number)
|
163
170
|
|
164
171
|
#doc = Document.new File.open(@file_path + lookup,'r').read
|
165
|
-
doc = @hc_lookup.read(lookup) { Document.new File.open(@file_path + lookup,'r').read }
|
166
172
|
|
167
173
|
x1 = (number - 1) * 10
|
168
174
|
x2 = x1 + 9
|
@@ -184,6 +190,7 @@ class DynarexBlog
|
|
184
190
|
XPath.each(temp_doc.root, xpath_ids) do |record|
|
185
191
|
records.add record
|
186
192
|
end
|
193
|
+
|
187
194
|
result
|
188
195
|
|
189
196
|
|
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.3.
|
4
|
+
version: 0.3.7
|
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-19 00:00:00 +01:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|