dynarex-blog 0.3.5 → 0.3.6

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 +15 -3
  2. metadata +1 -1
data/lib/dynarex-blog.rb CHANGED
@@ -17,6 +17,8 @@ class DynarexBlog
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
19
  @hc_lookup = HashCache.new(size: 15)
20
+ @hc_lookup.read(@current_lookup) { Document.new File.open(@file_path + @current_lookup,'r').read }
21
+
20
22
  @hc_result = HashCache.new(size: 5)
21
23
  @hc_entry_file = HashCache.new(size: 5)
22
24
  super()
@@ -116,19 +118,29 @@ class DynarexBlog
116
118
  def page(number=0)
117
119
  current_lookup = @current_lookup
118
120
  @current_lookup = '_entry_lookup.xml'
121
+ result = nil
119
122
 
120
123
  if (number == 1) and (current_lookup == '_entry_lookup.xml') and (@index.records.length == 10) then
121
- Document.new(File.open(@file_path + 'index.xml','r').read)
124
+ result = Document.new(File.open(@file_path + 'index.xml','r').read)
122
125
  else
123
- @hc_result.read(current_lookup + number.to_s) { select_page(current_lookup, number) }
126
+ result = @hc_result.read(current_lookup + number.to_s) { select_page(current_lookup, number) }
127
+ @hc_lookup.read(@current_lookup) { Document.new File.open(@file_path + @current_lookup,'r').read }
124
128
  end
129
+
130
+ result
125
131
  end
126
132
 
127
133
  def tag(tag)
128
134
  @current_lookup = tag + '_lookup.xml'
129
135
  self
130
136
  end
131
-
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
132
144
 
133
145
  private
134
146
 
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.5
4
+ version: 0.3.6
5
5
  platform: ruby
6
6
  authors: []
7
7