index-tanked 0.4.1 → 0.5.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.
@@ -2,7 +2,7 @@ module IndexTanked
2
2
  class Configuration
3
3
 
4
4
  class << self
5
- attr_accessor :url, :index, :search_availability, :index_availability, :timeout, :activerecord_queue
5
+ attr_accessor :url, :index, :search_availability, :index_availability, :timeout, :search_timeout, :activerecord_queue
6
6
 
7
7
  def self.block_accessor(*fields)
8
8
  fields.each do |field|
@@ -48,7 +48,19 @@ module IndexTanked
48
48
  raise SearchingDisabledError, "index tank search is disabled in configuration" unless IndexTanked::Configuration.search_available?
49
49
  raise IndexTanked::SearchError, "No or invalid index has been provided" unless @index.is_a? IndexTank::Index
50
50
  raise IndexTanked::SearchError, "No query provided" if @query.nil?
51
- @raw_result ||= @index.search(@query, @options.merge(:start => pager.offset, :len => pager.per_page))
51
+ search_timeout = if IndexTanked::Configuration.search_timeout.is_a?(Proc)
52
+ IndexTanked::Configuration.search_timeout.call
53
+ else
54
+ IndexTanked::Configuration.search_timeout
55
+ end
56
+ if search_timeout
57
+ IndexTanked::Timer.timeout(search_timeout, TimeoutExceededError) do
58
+ sleep(search_timeout + 1) if $testing_index_tanked_search_timeout
59
+ @raw_result ||= @index.search(@query, @options.merge(:start => pager.offset, :len => pager.per_page))
60
+ end
61
+ else
62
+ @raw_result ||= @index.search(@query, @options.merge(:start => pager.offset, :len => pager.per_page))
63
+ end
52
64
  rescue StandardError => e
53
65
  raise if e.is_a? IndexTankedError
54
66
  raise IndexTanked::SearchError, "#{e.class}: #{e.message}"
@@ -1,3 +1,3 @@
1
1
  module IndexTanked
2
- GEM_VERSION = '0.4.1'
2
+ GEM_VERSION = '0.5.0'
3
3
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: index-tanked
3
3
  version: !ruby/object:Gem::Version
4
- hash: 13
5
- prerelease: false
4
+ hash: 11
5
+ prerelease:
6
6
  segments:
7
7
  - 0
8
- - 4
9
- - 1
10
- version: 0.4.1
8
+ - 5
9
+ - 0
10
+ version: 0.5.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - Adam Kittelson
@@ -16,8 +16,7 @@ autorequire:
16
16
  bindir: bin
17
17
  cert_chain: []
18
18
 
19
- date: 2011-06-21 00:00:00 -07:00
20
- default_executable:
19
+ date: 2011-10-24 00:00:00 Z
21
20
  dependencies:
22
21
  - !ruby/object:Gem::Dependency
23
22
  name: indextank
@@ -155,7 +154,6 @@ files:
155
154
  - LICENSE
156
155
  - README.markdown
157
156
  - Rakefile
158
- has_rdoc: true
159
157
  homepage: http://github.com/zencoder/index-tanked
160
158
  licenses: []
161
159
 
@@ -185,7 +183,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
185
183
  requirements: []
186
184
 
187
185
  rubyforge_project:
188
- rubygems_version: 1.3.7
186
+ rubygems_version: 1.8.6
189
187
  signing_key:
190
188
  specification_version: 3
191
189
  summary: Index Tank <http://indextank.com> integration library.