athena 0.0.5.61 → 0.0.6.65

Sign up to get free protection for your applications and to get access to all the features.
data/README CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  == VERSION
4
4
 
5
- This documentation refers to athena version 0.0.5
5
+ This documentation refers to athena version 0.0.6
6
6
 
7
7
 
8
8
  == DESCRIPTION
@@ -57,26 +57,37 @@ class Athena::Formats
57
57
 
58
58
  def parse(source)
59
59
  path = source.path
60
- raise "index not found: #{path}" unless File.readable_real?(File.join(path, 'segments'))
60
+
61
+ # make sure the index can be opened
62
+ begin
63
+ File.open(File.join(path, 'segments')) {}
64
+ rescue Errno::ENOENT, Errno::EACCES => err
65
+ raise "can't open index at #{path} (#{err.to_s.sub(/ - .*/, '')})"
66
+ end
61
67
 
62
68
  index = ::Ferret::Index::IndexReader.new(path)
69
+ first, last = 0, index.max_doc - 1
70
+
71
+ # make sure we can read from the index
72
+ begin
73
+ index[first]
74
+ index[last]
75
+ rescue StandardError # EOFError, "Not available", ...
76
+ raise "possible Ferret version mismatch; try to set the " <<
77
+ "FERRET_VERSION environment variable to something " <<
78
+ "other than #{Ferret::VERSION}"
79
+ end
63
80
 
64
- 0.upto(index.max_doc - 1) { |i|
65
- next if index.deleted?(i)
81
+ first.upto(last) { |i|
82
+ unless index.deleted?(i)
83
+ doc = index[i]
66
84
 
67
- doc = begin
68
- index[i]
69
- rescue StandardError # "Not available"
70
- next
85
+ Athena::Record.new(parser.block, doc[record_element]) { |record|
86
+ config.each { |element, field_config|
87
+ record.update(element, doc[element], field_config)
88
+ }
89
+ }
71
90
  end
72
-
73
- record = Athena::Record.new(parser.block, doc[record_element])
74
-
75
- config.each { |element, field_config|
76
- record.update(element, doc[element], field_config)
77
- }
78
-
79
- record.close
80
91
  }
81
92
 
82
93
  index.num_docs
data/lib/athena/record.rb CHANGED
@@ -56,6 +56,14 @@ class Athena::Record
56
56
  @id = id
57
57
 
58
58
  add_record
59
+
60
+ if block_given?
61
+ begin
62
+ yield self
63
+ ensure
64
+ close
65
+ end
66
+ end
59
67
  end
60
68
 
61
69
  def fill(field, config)
@@ -30,7 +30,7 @@ module Athena::Version
30
30
 
31
31
  MAJOR = 0
32
32
  MINOR = 0
33
- TINY = 5
33
+ TINY = 6
34
34
 
35
35
  class << self
36
36
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: athena
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5.61
4
+ version: 0.0.6.65
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jens Wille
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2008-12-02 00:00:00 +01:00
12
+ date: 2008-12-03 00:00:00 +01:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency