picky 0.2.2 → 0.2.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -29,7 +29,7 @@ module Cacher
29
29
  codes.first.to_sym unless codes.empty?
30
30
  end
31
31
 
32
- # Generates an index for the given index (in full index style).
32
+ # Generates an index for the given index (in exact index style).
33
33
  #
34
34
  # In the following form:
35
35
  # [:meier, :mueller, :peter, :pater] => { :MR => [:meier], :MLR => [:mueller], :PTR => [:peter, :pater] }
@@ -21,7 +21,7 @@ module Configuration
21
21
  @after_indexing = options[:after_indexing]
22
22
  @result_type = options[:result_type] || name
23
23
  @ignore_unassigned_tokens = options[:ignore_unassigned_tokens] || false # TODO Move to query?
24
- @solr = options[:solr] || nil
24
+ # @solr = options[:solr] || nil
25
25
  end
26
26
  def generate
27
27
  categories = fields.map { |field| field.generate }
@@ -35,16 +35,16 @@ module Configuration
35
35
  field.index
36
36
  end
37
37
  end
38
- def solr_fields
39
- solr ? fields.select { |field| !field.virtual? } : []
40
- end
41
- # TODO Delegate to Solr handler.
42
- #
43
- def index_solr
44
- return unless solr
45
- @indexer = Indexers::Solr.new self
46
- @indexer.index
47
- end
38
+ # def solr_fields
39
+ # solr ? fields.select { |field| !field.virtual? } : []
40
+ # end
41
+ # # TODO Delegate to Solr handler.
42
+ # #
43
+ # def index_solr
44
+ # return unless solr
45
+ # @indexer = Indexers::Solr.new self
46
+ # @indexer.index
47
+ # end
48
48
  # TODO Spec!
49
49
  #
50
50
  def connect_backend
@@ -4,7 +4,7 @@ module Index
4
4
 
5
5
  # This is the ACTUAL index.
6
6
  #
7
- # Handles full index, partial index, weights index, and similarity index.
7
+ # Handles exact index, partial index, weights index, and similarity index.
8
8
  #
9
9
  class Bundle
10
10
 
@@ -269,8 +269,8 @@ module Index
269
269
  generator = Cacher::PartialGenerator.new self.index
270
270
  self.index = generator.generate self.partial_strategy
271
271
  end
272
- def generate_partial_from full_index
273
- self.index = full_index
272
+ def generate_partial_from exact_index
273
+ self.index = exact_index
274
274
  self.generate_partial
275
275
  self
276
276
  end
@@ -1,13 +1,13 @@
1
1
  module Index
2
2
 
3
- # An index category holds a full and a partial index for a given field.
3
+ # An index category holds a exact and a partial index for a given field.
4
4
  #
5
- # For example an index category for names holds a full and
5
+ # For example an index category for names holds a exact and
6
6
  # a partial index bundle for names.
7
7
  #
8
8
  class Category
9
9
 
10
- attr_reader :name, :type, :full, :partial
10
+ attr_reader :name, :type, :exact, :partial
11
11
 
12
12
  #
13
13
  #
@@ -19,17 +19,17 @@ module Index
19
19
  weights = options[:weights] || Cacher::Weights::Default
20
20
  similarity = options[:similarity] || Cacher::Similarity::Default
21
21
 
22
- @full = options[:full_bundle] || Bundle.new(:full, self, type, Cacher::Partial::None.new, weights, similarity)
22
+ @exact = options[:exact_bundle] || Bundle.new(:exact, self, type, Cacher::Partial::None.new, weights, similarity)
23
23
  @partial = options[:partial_bundle] || Bundle.new(:partial, self, type, partial, weights, Cacher::Similarity::None.new)
24
24
 
25
- @full = full_lambda.call(@full, @partial) if full_lambda = options[:full_lambda]
26
- @partial = partial_lambda.call(@full, @partial) if partial_lambda = options[:partial_lambda]
25
+ @exact = exact_lambda.call(@exact, @partial) if exact_lambda = options[:exact_lambda]
26
+ @partial = partial_lambda.call(@exact, @partial) if partial_lambda = options[:partial_lambda]
27
27
  end
28
28
 
29
29
  # Loads the index from cache.
30
30
  #
31
31
  def load_from_cache
32
- full.load
32
+ exact.load
33
33
  partial.load
34
34
  end
35
35
 
@@ -50,16 +50,16 @@ module Index
50
50
  dump_caches
51
51
  end
52
52
  def generate_caches_from_db
53
- full.generate_caches_from_db
53
+ exact.generate_caches_from_db
54
54
  end
55
55
  def generate_partial
56
- partial.generate_partial_from full.index
56
+ partial.generate_partial_from exact.index
57
57
  end
58
58
  def generate_caches_from_memory
59
59
  partial.generate_caches_from_memory
60
60
  end
61
61
  def dump_caches
62
- full.dump
62
+ exact.dump
63
63
  partial.dump
64
64
  end
65
65
  # TODO move to Kernel?
@@ -75,13 +75,13 @@ module Index
75
75
 
76
76
  # Used for testing.
77
77
  #
78
- def generate_indexes_from_full_index
79
- generate_derived_full
78
+ def generate_indexes_from_exact_index
79
+ generate_derived_exact
80
80
  generate_partial
81
81
  generate_derived_partial
82
82
  end
83
- def generate_derived_full
84
- full.generate_derived
83
+ def generate_derived_exact
84
+ exact.generate_derived
85
85
  end
86
86
  def generate_derived_partial
87
87
  partial.generate_derived
@@ -102,7 +102,7 @@ module Index
102
102
  # Returns the right index bundle for this token.
103
103
  #
104
104
  def bundle_for token
105
- token.partial? ? partial : full
105
+ token.partial? ? partial : exact
106
106
  end
107
107
 
108
108
  #
@@ -2,10 +2,8 @@
2
2
  #
3
3
  module Index
4
4
 
5
- # This index combines a full and partial index.
6
- # It serves to order the results such that exact (full) hits are found first.
7
- #
8
- # TODO Rename full -> exact. exact/partial?
5
+ # This index combines an exact and partial index.
6
+ # It serves to order the results such that exact hits are found first.
9
7
  #
10
8
  # TODO Need to use the right subtokens. Bake in?
11
9
  #
@@ -16,7 +14,7 @@ module Index
16
14
  delegate :similar,
17
15
  :identifier,
18
16
  :name,
19
- :to => :@full
17
+ :to => :@exact
20
18
  delegate :type,
21
19
  :category,
22
20
  :weight,
@@ -27,19 +25,19 @@ module Index
27
25
  :load,
28
26
  :to => :@partial
29
27
 
30
- # TODO initialize type_or_category # => installs itself on all full and partial
28
+ # TODO initialize type_or_category # => installs itself on all exact and partial
31
29
  #
32
- def initialize full, partial
33
- @full = full
30
+ def initialize exact, partial
31
+ @exact = exact
34
32
  @partial = partial
35
33
  end
36
34
 
37
35
  def ids text
38
- @full.ids(text) + @partial.ids(text)
36
+ @exact.ids(text) + @partial.ids(text)
39
37
  end
40
38
 
41
39
  def weight text
42
- [@full.weight(text) || 0, @partial.weight(text) || 0].max
40
+ [@exact.weight(text) || 0, @partial.weight(text) || 0].max
43
41
  end
44
42
 
45
43
  end
@@ -35,11 +35,13 @@ module Indexers
35
35
  @field.source || raise_no_source
36
36
  end
37
37
  def raise_no_source
38
- raise NoSourceSpecifiedException.new "No source given for #{@type.name}:#{@field.name}."
38
+ raise NoSourceSpecifiedException.new "No source given for #{@type.name}:#{@field.name}." # TODO field.identifier
39
39
  end
40
40
 
41
41
  # Selects the original id (indexed id) and a column to process. The column data is called "token".
42
42
  #
43
+ # Note: Puts together the parts first in an array, then releasing the array from time to time by joining.
44
+ #
43
45
  def process
44
46
  comma = ?,
45
47
  newline = ?\n
@@ -47,19 +49,19 @@ module Indexers
47
49
  indexing_message
48
50
 
49
51
  File.open(search_index_file_name, 'w:binary') do |file|
52
+ result = []
50
53
  source.harvest(@type, @field) do |indexed_id, text|
51
54
  tokenizer.tokenize(text).each do |token_text|
52
- file.write indexed_id
53
- file.write comma
54
- file.write token_text
55
- file.write newline
55
+ result << indexed_id << comma << token_text << newline
56
56
  end
57
+ file.write(result.join) && result.clear if result.size > 100_000
57
58
  end
59
+ file.write result.join
58
60
  end
59
61
  end
60
62
 
61
63
  def indexing_message
62
- puts "#{Time.now}: Indexing #{@type.name}:#{@field.name}:#{@field.indexed_name}."
64
+ puts "#{Time.now}: Indexing #{@type.name}:#{@field.name}:#{@field.indexed_name}." # TODO field.identifier
63
65
  end
64
66
 
65
67
  end
data/lib/picky/indexes.rb CHANGED
@@ -71,13 +71,13 @@ module Indexes
71
71
  #
72
72
  def self.backup_caches
73
73
  each_category do |category|
74
- category.full.backup
74
+ category.exact.backup
75
75
  category.partial.backup
76
76
  end
77
77
  end
78
78
  def self.restore_caches
79
79
  each_category do |category|
80
- category.full.restore
80
+ category.exact.restore
81
81
  category.partial.restore
82
82
  end
83
83
  end
@@ -122,7 +122,7 @@ module Indexes
122
122
  def self.check_caches
123
123
  each do |type|
124
124
  type.categories.each do |category|
125
- category.full.raise_unless_cache_exists
125
+ category.exact.raise_unless_cache_exists
126
126
  category.partial.raise_unless_cache_exists
127
127
  end
128
128
  end
@@ -133,7 +133,7 @@ module Indexes
133
133
  def self.clear_caches
134
134
  each do |type|
135
135
  type.categories.each do |category|
136
- category.full.delete_all
136
+ category.exact.delete_all
137
137
  category.partial.delete_all
138
138
  end
139
139
  end
@@ -144,8 +144,8 @@ module Indexes
144
144
  # TODO Should be on type?
145
145
  #
146
146
  def self.create_directory_structure
147
- each_bundle do |full, partial|
148
- full.create_directory
147
+ each_bundle do |exact, partial|
148
+ exact.create_directory
149
149
  partial.create_directory
150
150
  end
151
151
  end
@@ -167,7 +167,7 @@ module Indexes
167
167
  end
168
168
  def self.each_bundle
169
169
  each_category do |category|
170
- yield category.full, category.partial
170
+ yield category.exact, category.partial
171
171
  end
172
172
  end
173
173
 
data/lib/picky/loader.rb CHANGED
@@ -121,7 +121,7 @@ module Loader
121
121
  load_relative 'indexers/field'
122
122
  load_relative 'indexers/default'
123
123
  #
124
- load_relative 'indexers/solr'
124
+ # load_relative 'indexers/solr'
125
125
 
126
126
  # Partial index generation strategies.
127
127
  #
@@ -194,7 +194,7 @@ module Loader
194
194
  load_relative 'query/live'
195
195
  load_relative 'query/full'
196
196
  #
197
- load_relative 'query/solr' # TODO
197
+ # load_relative 'query/solr'
198
198
 
199
199
  # Results.
200
200
  #
@@ -229,7 +229,7 @@ module Loader
229
229
 
230
230
  # Load tools.
231
231
  #
232
- load_relative 'solr/schema_generator'
232
+ # load_relative 'solr/schema_generator'
233
233
  load_relative 'cores'
234
234
 
235
235
  # Load generation.
@@ -58,7 +58,7 @@ module Query
58
58
  [identifier, *@token.to_result]
59
59
  end
60
60
 
61
- # full/title:Flarbl:flarbl
61
+ # exact/title:Flarbl:flarbl
62
62
  #
63
63
  def to_s
64
64
  "#{bundle.name}/#{to_result.join(':')}"
@@ -21,6 +21,8 @@ module Sources
21
21
  # Or
22
22
  # * The configuration as a hash.
23
23
  #
24
+ # TODO Do not use ActiveRecord directly.
25
+ #
24
26
  def create_database_adapter
25
27
  adapter_class = Class.new ActiveRecord::Base
26
28
  adapter_class.abstract_class = true
@@ -2,21 +2,20 @@ source :gemcutter
2
2
 
3
3
  # Gems required by Picky.
4
4
  #
5
- gem 'picky'
6
- gem 'bundler', '>=0.9.26'
7
- gem 'rack', '1.2.1'
8
- gem 'rack-mount', '0.6.9'
9
- gem 'text', '0.2.0'
10
- gem 'yajl-ruby', '0.7.8', :require => 'yajl'
5
+ gem 'picky', '~> 0.2.0'
6
+ gem 'bundler', '>= 0.9.26'
7
+ gem 'rack', '~> 1.2.1'
8
+ gem 'rack-mount', '~> 0.6.9'
9
+ gem 'text', '~> 0.2.0'
10
+ gem 'yajl-ruby', '~> 0.7.8', :require => 'yajl'
11
11
 
12
- # Should be optional.
12
+ # Should be optional, but isn't yet.
13
+ #
14
+ gem 'activerecord', '~> 2.3.8', :require => 'active_record'
15
+
16
+ # Optional.
13
17
  #
14
- gem 'activesupport', '2.3.8', :require => 'active_support'
15
- gem 'activerecord', '2.3.8', :require => 'active_record'
16
- gem 'rsolr', '0.12.1'
17
- gem 'sunspot', '1.1.0'
18
18
  gem 'rack_fast_escape', '2009.06.24'
19
- gem 'rspec'
20
19
 
21
20
  # Required by your project.
22
21
  #
@@ -1,6 +1,6 @@
1
1
  # Just an example, see application.rb on how this file is used.
2
2
  #
3
- # Note: ActiveRecord is used.
3
+ # Note: ActiveRecord is used. Sorry.
4
4
  #
5
5
  adapter: mysql
6
6
  host: localhost
@@ -20,22 +20,22 @@ describe Configuration::Type do
20
20
  :solr => :some_solr_option
21
21
  end
22
22
 
23
- describe 'solr_fields' do
24
- it 'should return all non-virtual fields' do
25
- @type.solr_fields.should == [@field]
26
- end
27
- end
23
+ # describe 'solr_fields' do
24
+ # it 'should return all non-virtual fields' do
25
+ # @type.solr_fields.should == [@field]
26
+ # end
27
+ # end
28
28
 
29
- describe 'index_solr' do
30
- it 'should get a new solr indexer and start it' do
31
- solr = mock :solr
32
- Indexers::Solr.should_receive(:new).once.with(@type).and_return solr
33
-
34
- solr.should_receive(:index).once.with
35
-
36
- @type.index_solr
37
- end
38
- end
29
+ # describe 'index_solr' do
30
+ # it 'should get a new solr indexer and start it' do
31
+ # solr = mock :solr
32
+ # Indexers::Solr.should_receive(:new).once.with(@type).and_return solr
33
+ #
34
+ # solr.should_receive(:index).once.with
35
+ #
36
+ # @type.index_solr
37
+ # end
38
+ # end
39
39
 
40
40
  describe 'index' do
41
41
  it 'should index each of the fields' do
@@ -6,7 +6,7 @@ describe Index::Bundle do
6
6
  @category = stub :category, :name => :some_category
7
7
  @type = stub :type, :name => :some_type
8
8
  @partial_strategy = Cacher::Partial::Subtoken.new :down_to => 1
9
- @full = Index::Bundle.new :some_name, @category, @type, @partial_strategy, nil, nil
9
+ @exact = Index::Bundle.new :some_name, @category, @type, @partial_strategy, nil, nil
10
10
  end
11
11
 
12
12
  def generate_random_keys amount
@@ -28,11 +28,11 @@ describe Index::Bundle do
28
28
  before(:each) do
29
29
  random_keys = generate_random_keys 500
30
30
  random_ids = generate_random_ids 500
31
- @full.index = Hash[random_keys.zip(random_ids)]
31
+ @exact.index = Hash[random_keys.zip(random_ids)]
32
32
  end
33
33
  it 'should be fast' do
34
34
  performance_of do
35
- @full.generate_partial
35
+ @exact.generate_partial
36
36
  end.should < 0.2
37
37
  end
38
38
  end
@@ -10,16 +10,16 @@ describe Index::Category do
10
10
  @similarity = stub :similarity
11
11
  @category = Index::Category.new @field, @type, :partial => @partial, :weights => @weights, :similarity => @similarity
12
12
 
13
- @full = stub :full, :dump => nil
14
- @category.stub! :full => @full
13
+ @exact = stub :exact, :dump => nil
14
+ @category.stub! :exact => @exact
15
15
 
16
16
  @partial = stub :partial, :dump => nil
17
17
  @category.stub! :partial => @partial
18
18
  end
19
19
 
20
20
  describe 'dump_caches' do
21
- it 'should dump the full index' do
22
- @full.should_receive(:dump).once.with
21
+ it 'should dump the exact index' do
22
+ @exact.should_receive(:dump).once.with
23
23
 
24
24
  @category.dump_caches
25
25
  end
@@ -38,21 +38,21 @@ describe Index::Category do
38
38
  end
39
39
  end
40
40
 
41
- describe 'generate_derived_full' do
42
- it 'should delegate to full' do
43
- @full.should_receive(:generate_derived).once.with
41
+ describe 'generate_derived_exact' do
42
+ it 'should delegate to exact' do
43
+ @exact.should_receive(:generate_derived).once.with
44
44
 
45
- @category.generate_derived_full
45
+ @category.generate_derived_exact
46
46
  end
47
47
  end
48
48
 
49
- describe 'generate_indexes_from_full_index' do
49
+ describe 'generate_indexes_from_exact_index' do
50
50
  it 'should call three method in order' do
51
- @category.should_receive(:generate_derived_full).once.with().ordered
51
+ @category.should_receive(:generate_derived_exact).once.with().ordered
52
52
  @category.should_receive(:generate_partial).once.with().ordered
53
53
  @category.should_receive(:generate_derived_partial).once.with().ordered
54
54
 
55
- @category.generate_indexes_from_full_index
55
+ @category.generate_indexes_from_exact_index
56
56
  end
57
57
  end
58
58
 
@@ -70,12 +70,12 @@ describe Index::Category do
70
70
  @category.weight @token
71
71
  end
72
72
  end
73
- context 'full bundle' do
73
+ context 'exact bundle' do
74
74
  before(:each) do
75
- @category.stub! :bundle_for => @full
75
+ @category.stub! :bundle_for => @exact
76
76
  end
77
77
  it 'should receive weight with the token text' do
78
- @full.should_receive(:weight).once.with :some_text
78
+ @exact.should_receive(:weight).once.with :some_text
79
79
 
80
80
  @category.weight @token
81
81
  end
@@ -96,12 +96,12 @@ describe Index::Category do
96
96
  @category.ids @token
97
97
  end
98
98
  end
99
- context 'full bundle' do
99
+ context 'exact bundle' do
100
100
  before(:each) do
101
- @category.stub! :bundle_for => @full
101
+ @category.stub! :bundle_for => @exact
102
102
  end
103
103
  it 'should receive ids with the token text' do
104
- @full.should_receive(:ids).once.with :some_text
104
+ @exact.should_receive(:ids).once.with :some_text
105
105
 
106
106
  @category.ids @token
107
107
  end
@@ -137,7 +137,7 @@ describe Index::Category do
137
137
  it 'should return the right bundle' do
138
138
  token = stub :token, :partial? => false
139
139
 
140
- @category.bundle_for(token).should == @full
140
+ @category.bundle_for(token).should == @exact
141
141
  end
142
142
  it 'should return the right bundle' do
143
143
  token = stub :token, :partial? => true
@@ -156,23 +156,23 @@ describe Index::Category do
156
156
 
157
157
  describe 'generate_partial' do
158
158
  it 'should return whatever the partial generation returns' do
159
- @full.stub! :index
159
+ @exact.stub! :index
160
160
  @partial.stub! :generate_partial_from => :generation_returns
161
161
 
162
162
  @category.generate_partial
163
163
  end
164
- it 'should use the full index to generate the partial index' do
165
- full_index = stub :full_index
166
- @full.stub! :index => full_index
167
- @partial.should_receive(:generate_partial_from).once.with(full_index)
164
+ it 'should use the exact index to generate the partial index' do
165
+ exact_index = stub :exact_index
166
+ @exact.stub! :index => exact_index
167
+ @partial.should_receive(:generate_partial_from).once.with(exact_index)
168
168
 
169
169
  @category.generate_partial
170
170
  end
171
171
  end
172
172
 
173
173
  describe 'generate_caches_from_db' do
174
- it 'should delegate to full' do
175
- @full.should_receive(:generate_caches_from_db).once.with
174
+ it 'should delegate to exact' do
175
+ @exact.should_receive(:generate_caches_from_db).once.with
176
176
 
177
177
  @category.generate_caches_from_db
178
178
  end
@@ -193,7 +193,7 @@ describe Index::Category do
193
193
 
194
194
  describe 'load_from_cache' do
195
195
  it 'should call two methods' do
196
- @full.should_receive(:load).once
196
+ @exact.should_receive(:load).once
197
197
  @partial.should_receive(:load).once
198
198
 
199
199
  @category.load_from_cache
@@ -1,51 +1,51 @@
1
- require 'spec_helper'
2
-
3
- describe Query::Solr do
4
-
5
- describe 'real server' do
6
- before(:each) do
7
- @server = Query::Solr.new
8
- end
9
-
10
- describe 'execute' do
11
- context 'error cases' do
12
- before(:each) do
13
- @tokens = stub :tokens
14
- end
15
- context 'tokens are malformed' do
16
-
17
- end
18
- context 'server returns strange values' do
19
-
20
- end
21
- context 'server raises' do
22
- before(:each) do
23
- @server.stub! :select => lambda { raise Solr::RequestError }
24
- end
25
- it 'should not fail' do
26
- @tokens.stub! :to_solr_query => ''
27
-
28
- lambda { @server.execute(@tokens) }.should_not raise_error
29
- end
30
- end
31
- end
32
- end
33
- end
34
-
35
- context 'with connected Server' do
36
- before(:each) do
37
- @server = stub :server
38
- RSolr.stub! :connect => @server
39
- end
40
- end
41
-
42
- context 'without connected server' do
43
- before(:each) do
44
- RSolr.should_receive(:connect).and_raise RuntimeError
45
- end
46
- it 'should have a nil server' do
47
- Query::Solr.new(:some_index_type).server.should == nil
48
- end
49
- end
50
-
51
- end
1
+ # require 'spec_helper'
2
+ #
3
+ # describe Query::Solr do
4
+ #
5
+ # describe 'real server' do
6
+ # before(:each) do
7
+ # @server = Query::Solr.new
8
+ # end
9
+ #
10
+ # describe 'execute' do
11
+ # context 'error cases' do
12
+ # before(:each) do
13
+ # @tokens = stub :tokens
14
+ # end
15
+ # context 'tokens are malformed' do
16
+ #
17
+ # end
18
+ # context 'server returns strange values' do
19
+ #
20
+ # end
21
+ # context 'server raises' do
22
+ # before(:each) do
23
+ # @server.stub! :select => lambda { raise Solr::RequestError }
24
+ # end
25
+ # it 'should not fail' do
26
+ # @tokens.stub! :to_solr_query => ''
27
+ #
28
+ # lambda { @server.execute(@tokens) }.should_not raise_error
29
+ # end
30
+ # end
31
+ # end
32
+ # end
33
+ # end
34
+ #
35
+ # context 'with connected Server' do
36
+ # before(:each) do
37
+ # @server = stub :server
38
+ # RSolr.stub! :connect => @server
39
+ # end
40
+ # end
41
+ #
42
+ # context 'without connected server' do
43
+ # before(:each) do
44
+ # RSolr.should_receive(:connect).and_raise RuntimeError
45
+ # end
46
+ # it 'should have a nil server' do
47
+ # Query::Solr.new(:some_index_type).server.should == nil
48
+ # end
49
+ # end
50
+ #
51
+ # end
@@ -1,42 +1,42 @@
1
- # encoding: utf-8
2
- require 'spec_helper'
3
-
4
- describe Solr::SchemaGenerator do
5
-
6
- before(:each) do
7
- @types = stub :types
8
- @configuration = stub :configuration, :types => @types
9
- @generator = Solr::SchemaGenerator.new @configuration
10
- end
11
-
12
- describe 'bound_field_names' do
13
- before(:each) do
14
- @generator.stub! :combine_field_names => :some_field_names
15
- end
16
- it 'should bind field_names' do
17
- b = @generator.bound_field_names
18
-
19
- eval('field_names', b).should == :some_field_names
20
- end
21
- end
22
-
23
- describe 'generate' do
24
- before(:each) do
25
- @generator.stub! :bound_field_names
26
- @generator.stub! :generate_schema_for
27
- end
28
- it 'should receive generate_schema_for once with the result of extract_binding' do
29
- @generator.stub! :bound_field_names => :some_binding
30
-
31
- @generator.should_receive(:generate_schema_for).once.with :some_binding
32
-
33
- @generator.generate
34
- end
35
- it 'should extract the binding' do
36
- @generator.should_receive(:bound_field_names).once.with
37
-
38
- @generator.generate
39
- end
40
- end
41
-
42
- end
1
+ # # encoding: utf-8
2
+ # require 'spec_helper'
3
+ #
4
+ # describe Solr::SchemaGenerator do
5
+ #
6
+ # before(:each) do
7
+ # @types = stub :types
8
+ # @configuration = stub :configuration, :types => @types
9
+ # @generator = Solr::SchemaGenerator.new @configuration
10
+ # end
11
+ #
12
+ # describe 'bound_field_names' do
13
+ # before(:each) do
14
+ # @generator.stub! :combine_field_names => :some_field_names
15
+ # end
16
+ # it 'should bind field_names' do
17
+ # b = @generator.bound_field_names
18
+ #
19
+ # eval('field_names', b).should == :some_field_names
20
+ # end
21
+ # end
22
+ #
23
+ # describe 'generate' do
24
+ # before(:each) do
25
+ # @generator.stub! :bound_field_names
26
+ # @generator.stub! :generate_schema_for
27
+ # end
28
+ # it 'should receive generate_schema_for once with the result of extract_binding' do
29
+ # @generator.stub! :bound_field_names => :some_binding
30
+ #
31
+ # @generator.should_receive(:generate_schema_for).once.with :some_binding
32
+ #
33
+ # @generator.generate
34
+ # end
35
+ # it 'should extract the binding' do
36
+ # @generator.should_receive(:bound_field_names).once.with
37
+ #
38
+ # @generator.generate
39
+ # end
40
+ # end
41
+ #
42
+ # end
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 2
8
- - 2
9
- version: 0.2.2
8
+ - 3
9
+ version: 0.2.3
10
10
  platform: ruby
11
11
  authors:
12
12
  - Florian Hanke
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-10-14 00:00:00 +02:00
17
+ date: 2010-10-15 00:00:00 +02:00
18
18
  default_executable: picky
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
@@ -84,7 +84,6 @@ files:
84
84
  - lib/picky/indexers/solr.rb
85
85
  - lib/picky/indexes.rb
86
86
  - lib/picky/initializers/ext.rb
87
- - lib/picky/initializers/mysql.rb
88
87
  - lib/picky/loader.rb
89
88
  - lib/picky/loggers/search.rb
90
89
  - lib/picky/query/allocation.rb
@@ -1,22 +0,0 @@
1
- # Wrapper for the mysql adapter method execute
2
- # to handle the 8 hours disconnect problem.
3
- # (http://www.mysql.fr/search/?q=autoreconnect)
4
- #
5
- ActiveRecord::ConnectionAdapters::MysqlAdapter.module_eval do
6
- def execute_with_retry_once(sql, name = nil)
7
- retried = false
8
- begin
9
- execute_without_retry_once(sql, name)
10
- rescue ActiveRecord::StatementInvalid => statement_invalid_exception
11
- # Our database connection has gone away, reconnect and retry this method
12
- #
13
- reconnect!
14
- unless retried
15
- retried = true
16
- retry
17
- end
18
- end
19
- end
20
-
21
- alias_method_chain :execute, :retry_once
22
- end