picky 4.12.1 → 4.12.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (72) hide show
  1. data/lib/picky/backends/backend.rb +5 -3
  2. data/lib/picky/backends/file/basic.rb +1 -1
  3. data/lib/picky/backends/file/json.rb +1 -1
  4. data/lib/picky/backends/file.rb +5 -4
  5. data/lib/picky/backends/memory.rb +4 -4
  6. data/lib/picky/backends/prepared/text.rb +2 -0
  7. data/lib/picky/backends/redis.rb +1 -1
  8. data/lib/picky/bundle.rb +3 -3
  9. data/lib/picky/categories.rb +24 -14
  10. data/lib/picky/categories_convenience.rb +1 -2
  11. data/lib/picky/categories_indexed.rb +2 -4
  12. data/lib/picky/categories_indexing.rb +4 -4
  13. data/lib/picky/categories_realtime.rb +7 -7
  14. data/lib/picky/character_substituters/west_european.rb +1 -1
  15. data/lib/picky/extensions/class.rb +4 -4
  16. data/lib/picky/extensions/module.rb +29 -7
  17. data/lib/picky/index.rb +26 -25
  18. data/lib/picky/index_convenience.rb +1 -3
  19. data/lib/picky/index_indexed.rb +5 -5
  20. data/lib/picky/index_indexing.rb +2 -6
  21. data/lib/picky/index_realtime.rb +7 -7
  22. data/lib/picky/indexers/base.rb +2 -2
  23. data/lib/picky/indexes.rb +12 -17
  24. data/lib/picky/indexes_convenience.rb +1 -3
  25. data/lib/picky/indexes_indexed.rb +2 -5
  26. data/lib/picky/indexes_indexing.rb +2 -6
  27. data/lib/picky/loader.rb +1 -0
  28. data/lib/picky/query/allocation.rb +1 -1
  29. data/lib/picky/query/allocations.rb +7 -7
  30. data/lib/picky/query/boosts.rb +1 -2
  31. data/lib/picky/query/combinations.rb +3 -3
  32. data/lib/picky/query/indexes.rb +18 -18
  33. data/lib/picky/query/token.rb +1 -1
  34. data/lib/picky/query/tokens.rb +2 -2
  35. data/lib/picky/rack/harakiri.rb +1 -1
  36. data/lib/picky/results.rb +2 -2
  37. data/lib/picky/search.rb +5 -5
  38. data/lib/picky/search_facets.rb +3 -3
  39. data/lib/picky/sinatra.rb +1 -1
  40. data/lib/picky/tokenizer/regexp_wrapper.rb +19 -0
  41. data/lib/picky/tokenizer.rb +2 -13
  42. data/lib/picky/wrappers/bundle/delegators.rb +44 -44
  43. data/lib/picky/wrappers/bundle/wrapper.rb +1 -1
  44. data/lib/picky.rb +0 -2
  45. data/lib/tasks/server.rake +2 -1
  46. data/spec/functional/backends/redis_bundle_realtime_spec.rb +1 -1
  47. data/spec/functional/backends/sqlite_bundle_realtime_spec.rb +1 -1
  48. data/spec/functional/custom_delimiters_spec.rb +0 -2
  49. data/spec/functional/facets_spec.rb +1 -1
  50. data/spec/lib/backends/backend_spec.rb +1 -1
  51. data/spec/lib/backends/file/basic_spec.rb +1 -1
  52. data/spec/lib/backends/file_spec.rb +1 -1
  53. data/spec/lib/backends/memory/json_spec.rb +1 -1
  54. data/spec/lib/backends/memory/marshal_spec.rb +1 -1
  55. data/spec/lib/backends/redis/float_spec.rb +1 -1
  56. data/spec/lib/backends/redis/string_spec.rb +1 -1
  57. data/spec/lib/backends/sqlite/array_spec.rb +2 -2
  58. data/spec/lib/backends/sqlite/value_spec.rb +1 -1
  59. data/spec/lib/category_indexing_spec.rb +1 -1
  60. data/spec/lib/extensions/module_spec.rb +43 -6
  61. data/spec/lib/index_indexed_spec.rb +2 -2
  62. data/spec/lib/index_spec.rb +22 -1
  63. data/spec/lib/indexers/base_spec.rb +1 -1
  64. data/spec/lib/indexes_indexing_spec.rb +2 -2
  65. data/spec/lib/query/allocation_spec.rb +3 -3
  66. data/spec/lib/query/allocations_spec.rb +6 -6
  67. data/spec/lib/query/combinations_spec.rb +1 -1
  68. data/spec/lib/query/tokens_spec.rb +13 -13
  69. data/spec/lib/results_spec.rb +2 -2
  70. data/spec/lib/search_spec.rb +4 -4
  71. data/spec/lib/sinatra_spec.rb +2 -2
  72. metadata +5 -4
@@ -13,9 +13,7 @@ module Picky
13
13
  #
14
14
  class Indexes
15
15
 
16
- delegate :size,
17
- :first,
18
- :to => :@indexes
16
+ forward :size, :first, :to => :@indexes
19
17
 
20
18
  attr_reader :indexes,
21
19
  :ignored_categories
@@ -30,21 +28,23 @@ module Picky
30
28
 
31
29
  @indexes = indexes
32
30
  end
33
-
34
- # Ignore the categories with these qualifiers.
35
- #
36
- # Example:
37
- # search = Search.new(index1, index2, index3) do
38
- # ignore :name, :first_name
39
- # end
40
- #
41
- # Note: Cleans up / optimizes after being called.
42
- #
43
- def ignore *qualifiers
44
- @ignored_categories ||= []
45
- @ignored_categories += qualifiers.map { |qualifier| @mapper.map qualifier }.compact
46
- @ignored_categories.uniq!
47
- end
31
+
32
+ # TODO Reinstate.
33
+ #
34
+ # # Ignore the categories with these qualifiers.
35
+ # #
36
+ # # Example:
37
+ # # search = Search.new(index1, index2, index3) do
38
+ # # ignore :name, :first_name
39
+ # # end
40
+ # #
41
+ # # Note: Cleans up / optimizes after being called.
42
+ # #
43
+ # def ignore *qualifiers
44
+ # @ignored_categories ||= []
45
+ # @ignored_categories += qualifiers.map { |qualifier| @qualifier_mapper.map qualifier }.compact
46
+ # @ignored_categories.uniq!
47
+ # end
48
48
 
49
49
  # Returns a number of prepared (sorted, reduced etc.) allocations for the given tokens.
50
50
  #
@@ -15,7 +15,7 @@ module Picky
15
15
  attr_writer :similar
16
16
  attr_writer :predefined_categories
17
17
 
18
- delegate :blank?, :to => :@text
18
+ forward :blank?, :to => :@text
19
19
 
20
20
  # Normal initializer.
21
21
  #
@@ -10,9 +10,9 @@ module Picky
10
10
 
11
11
  attr_reader :tokens, :ignore_unassigned
12
12
 
13
- # Basically delegates to its internal tokens array.
13
+ # Basically forwards to its internal tokens array.
14
14
  #
15
- self.delegate *[Enumerable.instance_methods, :slice!, :[], :uniq!, :last, :reject!, :length, :size, :empty?, :each, :exit, { :to => :@tokens }].flatten
15
+ forward *[Enumerable.instance_methods, :slice!, :[], :uniq!, :last, :reject!, :length, :size, :empty?, :each, :exit, :to => :@tokens].flatten
16
16
 
17
17
  # Create a new Tokens object with the array of tokens passed in.
18
18
  #
@@ -28,7 +28,7 @@ module Rack
28
28
 
29
29
  # #call interface method.
30
30
  #
31
- # Harakiri is a middleware, so it delegates the the app or
31
+ # Harakiri is a middleware, so it forwards the the app or
32
32
  # the next middleware after checking if it is time to honorably retire.
33
33
  #
34
34
  def call env
data/lib/picky/results.rb CHANGED
@@ -41,7 +41,7 @@ module Picky
41
41
  allocations.process!(amount, offset, extra_allocations)
42
42
  end
43
43
 
44
- # Delegates to allocations.
44
+ # Forwards to allocations.
45
45
  #
46
46
  # Note that this is an expensive call and
47
47
  # should not be done repeatedly. Just keep
@@ -51,7 +51,7 @@ module Picky
51
51
  allocations.ids only
52
52
  end
53
53
 
54
- # The total results. Delegates to the allocations.
54
+ # The total results. Forwards to the allocations.
55
55
  #
56
56
  def total
57
57
  @total ||= allocations.total || 0
data/lib/picky/search.rb CHANGED
@@ -23,10 +23,10 @@ module Picky
23
23
  attr_accessor :tokenizer,
24
24
  :boosts
25
25
 
26
- delegate :ignore,
27
- :only,
28
- :remap_qualifiers,
29
- :to => :indexes
26
+ forward :ignore,
27
+ :only,
28
+ :remap_qualifiers,
29
+ :to => :indexes
30
30
 
31
31
  # Takes:
32
32
  # * A number of indexes
@@ -213,7 +213,7 @@ module Picky
213
213
  unique
214
214
  end
215
215
 
216
- # Delegates the tokenizing to the query tokenizer.
216
+ # Forwards the tokenizing to the query tokenizer.
217
217
  #
218
218
  # Parameters:
219
219
  # * text: The string to tokenize.
@@ -8,12 +8,12 @@ module Picky
8
8
  # category: The category whose facets to return.
9
9
  #
10
10
  # Options
11
- # counts: Whether you want counts (returns a Hash) or not (returns an Array).
12
- # at_least: A minimum count a facet needs to have (inclusive).
11
+ # counts: Whether you want counts (returns a Hash) or not (returns an Array). (Default true)
12
+ # at_least: A minimum count a facet needs to have (inclusive). (Default 1)
13
13
  # filter: A query to filter the facets with.
14
14
  #
15
15
  # Usage:
16
- # search.facets :name, filter: 'surname:peter', more_than: 0
16
+ # search.facets :name, filter: 'surname:peter', at_least: 2
17
17
  #
18
18
  def facets category_identifier, options = {}
19
19
  # TODO Make it work. How should it work with multiple indexes?
data/lib/picky/sinatra.rb CHANGED
@@ -2,7 +2,7 @@
2
2
  #
3
3
  require_relative 'sinatra/index_actions'
4
4
 
5
- # TODO Remove for 5.0.
5
+ # TODO Remove for 5.0 (or rename to Tokenizer.indexing, ...).
6
6
  #
7
7
  module Picky
8
8
 
@@ -0,0 +1,19 @@
1
+ class RegexpWrapper
2
+
3
+ def initialize regexp
4
+ @regexp = regexp
5
+ end
6
+
7
+ def split text
8
+ text.split @regexp
9
+ end
10
+
11
+ def source
12
+ @regexp.source
13
+ end
14
+
15
+ def method_missing name, *args, &block
16
+ @regexp.send name, *args, &block
17
+ end
18
+
19
+ end
@@ -105,17 +105,6 @@ Case sensitive? #{@case_sensitive ? "Yes." : "-"}
105
105
  RegexpWrapper.new thing
106
106
  end
107
107
  end
108
- class RegexpWrapper
109
- def initialize regexp
110
- @regexp = regexp
111
- end
112
- def split text
113
- text.split @regexp
114
- end
115
- def source
116
- @regexp.source
117
- end
118
- end
119
108
  def split text
120
109
  @splits_text_on.split text
121
110
  end
@@ -124,8 +113,8 @@ Case sensitive? #{@case_sensitive ? "Yes." : "-"}
124
113
  #
125
114
  # We only allow arrays.
126
115
  #
127
- # TODO 5.0 Rename to normalizes(config)
128
- # TODO 5.0 Rename to normalize(text)
116
+ # TODO 5.0 Rename to normalizes(config) or normalizes_words
117
+ # TODO 5.0 Rename to normalize(text) or normalize_words
129
118
  #
130
119
  def normalizes_words regexp_replaces
131
120
  raise ArgumentError.new "#{__method__} takes an Array of replaces as argument, not a #{regexp_replaces.class}." unless regexp_replaces.respond_to?(:to_ary) || regexp_replaces.respond_to?(:normalize_with_patterns)
@@ -6,66 +6,66 @@ module Picky
6
6
 
7
7
  module Delegator
8
8
 
9
- delegate :add,
9
+ forward :add,
10
10
 
11
- :inverted,
12
- :weights,
13
- :similarity,
14
- :configuration,
11
+ :inverted,
12
+ :weights,
13
+ :similarity,
14
+ :configuration,
15
15
 
16
- :backup,
17
- :restore,
18
- :delete,
16
+ :backup,
17
+ :restore,
18
+ :delete,
19
19
 
20
- :reset_backend,
20
+ :reset_backend,
21
21
 
22
- :raise_unless_cache_exists,
23
- :raise_unless_index_exists,
24
- :raise_unless_similarity_exists,
22
+ :raise_unless_cache_exists,
23
+ :raise_unless_index_exists,
24
+ :raise_unless_similarity_exists,
25
25
 
26
- :similar,
26
+ :similar,
27
27
 
28
- :to => :bundle
28
+ :to => :bundle
29
29
 
30
30
  end
31
31
 
32
32
  module IndexingDelegator
33
33
 
34
- delegate :[]=,
35
- :analyze,
36
- :dump,
37
- :empty,
38
- :empty_configuration,
39
- :generate_caches_from_memory,
40
- :generate_caches_from_source,
41
- :generate_partial_from,
42
- :retrieve,
43
- :size,
44
- :to => :bundle
34
+ forward :[]=,
35
+ :analyze,
36
+ :dump,
37
+ :empty,
38
+ :empty_configuration,
39
+ :generate_caches_from_memory,
40
+ :generate_caches_from_source,
41
+ :generate_partial_from,
42
+ :retrieve,
43
+ :size,
44
+ :to => :bundle
45
45
 
46
46
  end
47
47
 
48
48
  module IndexedDelegator
49
49
 
50
- delegate :[],
51
- :add_partialized,
52
- :clear,
53
- :clear_inverted,
54
- :clear_weights,
55
- :clear_similarity,
56
- :clear_configuration,
57
- :clear_realtime,
58
- :identifier,
59
- :ids,
60
- :load,
61
- :load_inverted,
62
- :load_weights,
63
- :load_similarity,
64
- :load_configuration,
65
- :name,
66
- :remove,
67
- :weight,
68
- :to => :bundle
50
+ forward :[],
51
+ :add_partialized,
52
+ :clear,
53
+ :clear_inverted,
54
+ :clear_weights,
55
+ :clear_similarity,
56
+ :clear_configuration,
57
+ :clear_realtime,
58
+ :identifier,
59
+ :ids,
60
+ :load,
61
+ :load_inverted,
62
+ :load_weights,
63
+ :load_similarity,
64
+ :load_configuration,
65
+ :name,
66
+ :remove,
67
+ :weight,
68
+ :to => :bundle
69
69
 
70
70
  end
71
71
 
@@ -6,7 +6,7 @@ module Picky
6
6
  #
7
7
  module Bundle
8
8
 
9
- # Base wrapper. Just delegates all methods to the bundle.
9
+ # Base wrapper. Just forwards all methods to the bundle.
10
10
  #
11
11
  class Wrapper
12
12
 
data/lib/picky.rb CHANGED
@@ -20,10 +20,8 @@ module Picky
20
20
  #
21
21
  # TODO Remove active support.
22
22
  #
23
- require 'active_support/core_ext/module/delegation'
24
23
  require 'active_support/core_ext/logger'
25
24
  require 'active_support/core_ext/object/blank'
26
- require 'active_support/core_ext/enumerable'
27
25
  require 'active_support/multibyte'
28
26
  require 'multi_json'
29
27
  require 'rack_fast_escape' if defined? Rack
@@ -16,7 +16,8 @@ namespace :server do
16
16
  task :start => :framework do
17
17
  chdir_to_root
18
18
  daemonize = PICKY_ENVIRONMENT == 'production' ? '-D' : ''
19
- command = "export PICKY_ENV=#{PICKY_ENVIRONMENT}; unicorn -c unicorn.rb #{daemonize}".strip
19
+ ENV['PICKY_ENV'] = PICKY_ENVIRONMENT
20
+ command = "unicorn -c unicorn.rb #{daemonize}".strip
20
21
  puts "Running \`#{command}\`."
21
22
  exec command
22
23
  end
@@ -125,7 +125,7 @@ describe Picky::Bundle do
125
125
  end
126
126
  end
127
127
 
128
- # TODO Add symbols.
128
+ # SYMBOLS
129
129
  #
130
130
  # context 'symbols' do
131
131
  # describe 'combined' do
@@ -125,7 +125,7 @@ describe Picky::Bundle do
125
125
  end
126
126
  end
127
127
 
128
- # TODO Add symbols.
128
+ # SYMBOLS
129
129
  #
130
130
  # context 'symbols' do
131
131
  # describe 'combined' do
@@ -4,8 +4,6 @@ require 'spec_helper'
4
4
 
5
5
  describe 'custom delimiters' do
6
6
 
7
- # TODO Add range query delimiter.
8
- #
9
7
  after(:each) do
10
8
  Picky::Query::Token.partial_character = '\*'
11
9
  Picky::Query::Token.no_partial_character = '"'
@@ -167,7 +167,7 @@ describe 'facets' do
167
167
  it 'is fast enough' do
168
168
  performance_of {
169
169
  10.times { finder.facets(:age_category, filter: 'surname:meier name:peter', counts: false) }
170
- }.should < 0.003
170
+ }.should < 0.0031
171
171
  end
172
172
  it 'has one filtered facet' do
173
173
  finder.facets(:age_category, filter: 'surname:meier name:peter', counts: false).should == ['45']
@@ -5,7 +5,7 @@ describe Picky::Backends::Backend do
5
5
  let(:backend) { described_class.new }
6
6
 
7
7
  describe 'weight' do
8
- it 'delegates to the parameter' do
8
+ it 'forwards to the parameter' do
9
9
  combinations = stub :combinations
10
10
 
11
11
  combinations.should_receive(:score).once.with()
@@ -19,7 +19,7 @@ describe Picky::Backends::File::Basic do
19
19
 
20
20
  describe 'to_s' do
21
21
  it 'returns the cache path with the default file extension' do
22
- basic.to_s.should == 'Picky::Backends::File::Basic(spec/temp/some/cache/path/to/file.file.index,spec/temp/some/cache/path/to/file.file_mapping.index.memory.json)'
22
+ basic.to_s.should == 'Picky::Backends::File::Basic(spec/temp/some/cache/path/to/file.file.index,spec/temp/some/cache/path/to/file.file_mapping.memory.json)'
23
23
  end
24
24
  end
25
25
  end
@@ -38,7 +38,7 @@ describe Picky::Backends::File do
38
38
  describe 'create_...' do
39
39
  [
40
40
  [:inverted, Picky::Backends::File::JSON],
41
- [:weights, Picky::Backends::File::JSON],
41
+ [:weights, Picky::Backends::Memory::JSON],
42
42
  [:similarity, Picky::Backends::File::JSON],
43
43
  [:configuration, Picky::Backends::File::JSON]
44
44
  ].each do |type, kind|
@@ -18,7 +18,7 @@ describe Picky::Backends::Memory::JSON do
18
18
  end
19
19
 
20
20
  describe "dump" do
21
- it "delegates to the given hash" do
21
+ it "forwards to the given hash" do
22
22
  hash = stub :hash
23
23
 
24
24
  json.should_receive(:dump_json).once.with hash
@@ -18,7 +18,7 @@ describe Picky::Backends::Memory::Marshal do
18
18
  end
19
19
 
20
20
  describe "dump" do
21
- it "delegates to the given hash" do
21
+ it "forwards to the given hash" do
22
22
  hash = stub :hash
23
23
 
24
24
  marshal.should_receive(:dump_marshal).once.with hash
@@ -17,7 +17,7 @@ describe Picky::Backends::Redis::Float do
17
17
  end
18
18
 
19
19
  describe 'member' do
20
- it 'delegates to the backend' do
20
+ it 'forwards to the backend' do
21
21
  client.should_receive(:hget).once.with 'some_namespace', 'some'
22
22
 
23
23
  backend['some']
@@ -17,7 +17,7 @@ describe Picky::Backends::Redis::String do
17
17
  end
18
18
 
19
19
  describe 'member' do
20
- it 'delegates to the backend' do
20
+ it 'forwards to the backend' do
21
21
  client.should_receive(:hget).once.with :some_namespace, :some_symbol
22
22
 
23
23
  backend[:some_symbol]
@@ -8,7 +8,7 @@ describe Picky::Backends::SQLite::Array do
8
8
  let(:db) { described_class.new 'spec/temp/some/cache/path/to/file' }
9
9
 
10
10
  describe 'dump' do
11
- it 'delegates to the given hash' do
11
+ it 'forwards to the given hash' do
12
12
  hash = stub :hash
13
13
 
14
14
  db.should_receive(:dump_sqlite).once.with hash
@@ -76,7 +76,7 @@ describe Picky::Backends::SQLite::Array do
76
76
  let(:db) { described_class.new 'spec/temp/some/cache/path/to/file', realtime: true }
77
77
 
78
78
  describe 'dump' do
79
- it 'delegates to the given hash' do
79
+ it 'forwards to the given hash' do
80
80
  hash = stub :hash
81
81
 
82
82
  db.should_receive(:dump_sqlite).never
@@ -8,7 +8,7 @@ describe Picky::Backends::SQLite::Value do
8
8
  let(:db) { described_class.new 'spec/temp/some/cache/path/to/file' }
9
9
 
10
10
  describe 'dump' do
11
- it 'delegates to the given hash' do
11
+ it 'forwards to the given hash' do
12
12
  hash = stub :hash
13
13
 
14
14
  db.should_receive(:dump_sqlite).once.with hash
@@ -13,7 +13,7 @@ describe Picky::Category do
13
13
  let(:partial) { category.partial }
14
14
 
15
15
  describe 'clear' do
16
- it 'delegates to both bundles' do
16
+ it 'forwards to both bundles' do
17
17
  exact.should_receive(:clear).once.with()
18
18
  partial.should_receive(:clear).once.with()
19
19
 
@@ -2,12 +2,12 @@ require 'spec_helper'
2
2
 
3
3
  describe Module do
4
4
 
5
- describe 'each_delegate' do
5
+ describe 'each_forward' do
6
6
  context "with correct params" do
7
- before(:each) do
8
- @klass = Class.new do
7
+ let(:klass) do
8
+ Class.new do
9
9
 
10
- each_delegate :bli, :bla, :blu, :to => :@some_enumerable
10
+ each_forward :bli, :bla, :blu, :to => :@some_enumerable
11
11
 
12
12
  def initialize some_enumerable
13
13
  @some_enumerable = some_enumerable
@@ -17,7 +17,7 @@ describe Module do
17
17
  end
18
18
  it 'should send each a bli' do
19
19
  bli = stub :bli
20
- delegating = @klass.new [bli, bli, bli, bli]
20
+ delegating = klass.new [bli, bli, bli, bli]
21
21
 
22
22
  bli.should_receive(:bli).exactly(4).times
23
23
 
@@ -25,10 +25,47 @@ describe Module do
25
25
  end
26
26
  end
27
27
  context "without correct params" do
28
+ it 'should raise an error' do
29
+ lambda do
30
+ Class.new do
31
+ each_forward :bli, :bla, :blu # :to missing
32
+ end
33
+ end.should raise_error(ArgumentError)
34
+ end
35
+ end
36
+ end
37
+
38
+ describe 'forward' do
39
+ context "with correct params" do
40
+ let(:klass) do
41
+ Class.new do
42
+
43
+ forward :bli, :bla, :blu, :to => :@some_thing
44
+
45
+ def initialize some_thing
46
+ @some_thing = some_thing
47
+ end
48
+
49
+ end
50
+ end
28
51
  it 'should send each a bli' do
52
+ bli = stub :bli
53
+ delegating = klass.new bli
54
+
55
+ bli.should_receive(:bli).exactly(1).times
56
+ bli.should_receive(:bla).exactly(1).times
57
+ bli.should_receive(:blu).exactly(1).times
58
+
59
+ delegating.bli
60
+ delegating.bla
61
+ delegating.blu
62
+ end
63
+ end
64
+ context "without correct params" do
65
+ it 'should raise an error' do
29
66
  lambda do
30
67
  Class.new do
31
- each_delegate :bli, :bla, :blu # :to missing
68
+ forward :bli, :bla, :blu # :to missing
32
69
  end
33
70
  end.should raise_error(ArgumentError)
34
71
  end
@@ -31,14 +31,14 @@ describe Picky::Index do
31
31
  end
32
32
 
33
33
  describe "load" do
34
- it "delegates to each category" do
34
+ it "forwards to each category" do
35
35
  @categories.should_receive(:load).once.with
36
36
 
37
37
  @index.load
38
38
  end
39
39
  end
40
40
  describe "possible_combinations" do
41
- it "delegates to the combinator" do
41
+ it "forwards to the combinator" do
42
42
  @categories.should_receive(:possible_combinations).once.with :some_token
43
43
 
44
44
  @index.possible_combinations :some_token
@@ -63,7 +63,7 @@ describe Picky::Index do
63
63
  end
64
64
 
65
65
  describe 'geo_categories' do
66
- it 'delegates correctly' do
66
+ it 'forwards correctly' do
67
67
  api.should_receive(:ranged_category).once.with :some_lat, 0.00898312, from: :some_lat_from
68
68
  api.should_receive(:ranged_category).once.with :some_lng, 0.01796624, from: :some_lng_from
69
69
 
@@ -103,6 +103,27 @@ describe Picky::Index do
103
103
  end
104
104
  end
105
105
  end
106
+
107
+ describe '#to_stats' do
108
+ let(:index) do
109
+ the_source = some_source
110
+ described_class.new :some_index_name do
111
+ source the_source
112
+ category :text1
113
+ category :text2
114
+ result_identifier :foobar
115
+ end
116
+ end
117
+
118
+ it 'outputs the stats correctly' do
119
+ index.to_stats.should == <<-EXPECTED
120
+ some_index_name (Picky::Index):
121
+ source: some_source
122
+ categories: text1, text2
123
+ result identifier: "foobar"
124
+ EXPECTED
125
+ end
126
+ end
106
127
  end
107
128
 
108
129
  end
@@ -12,7 +12,7 @@ describe Picky::Indexers::Base do
12
12
  end
13
13
 
14
14
  describe 'source' do
15
- it 'delegates it to the index or category' do
15
+ it 'forwards it to the index or category' do
16
16
  some_index_or_category.should_receive(:source).once.with
17
17
 
18
18
  indexer.source
@@ -44,7 +44,7 @@ describe Picky::Indexes do
44
44
  indexes.indexes.should == []
45
45
  end
46
46
  end
47
- def self.it_delegates_each name
47
+ def self.it_forwards_each name
48
48
  describe name do
49
49
  it "calls #{name} on each in order" do
50
50
  @index1.should_receive(name).once.with.ordered
@@ -54,7 +54,7 @@ describe Picky::Indexes do
54
54
  end
55
55
  end
56
56
  end
57
- it_delegates_each :clear
57
+ it_forwards_each :clear
58
58
  end
59
59
 
60
60
  end