picky 3.6.16 → 4.0.0pre1

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 (73) hide show
  1. data/lib/picky/application.rb +1 -1
  2. data/lib/picky/backends/backend.rb +2 -0
  3. data/lib/picky/backends/memory.rb +14 -7
  4. data/lib/picky/backends/{memory → prepared}/text.rb +10 -4
  5. data/lib/picky/backends/redis/directly_manipulable.rb +3 -5
  6. data/lib/picky/backends/redis/list.rb +5 -1
  7. data/lib/picky/backends/sqlite/basic.rb +4 -2
  8. data/lib/picky/bundle.rb +6 -7
  9. data/lib/picky/bundle_indexed.rb +2 -2
  10. data/lib/picky/bundle_realtime.rb +8 -7
  11. data/lib/picky/categories.rb +0 -1
  12. data/lib/picky/categories_indexing.rb +14 -0
  13. data/lib/picky/category.rb +3 -5
  14. data/lib/picky/category_indexed.rb +2 -5
  15. data/lib/picky/category_indexing.rb +28 -16
  16. data/lib/picky/constants.rb +3 -1
  17. data/lib/picky/frontend_adapters/rack.rb +2 -2
  18. data/lib/picky/generators/similarity/phonetic.rb +6 -14
  19. data/lib/picky/generators/strategy.rb +1 -1
  20. data/lib/picky/generators/weights/runtime.rb +2 -2
  21. data/lib/picky/helpers/indexing.rb +20 -0
  22. data/lib/picky/index.rb +7 -10
  23. data/lib/picky/index_indexed.rb +1 -8
  24. data/lib/picky/index_indexing.rb +44 -42
  25. data/lib/picky/indexers/base.rb +5 -6
  26. data/lib/picky/indexers/parallel.rb +35 -32
  27. data/lib/picky/indexers/serial.rb +38 -15
  28. data/lib/picky/indexes_indexed.rb +0 -7
  29. data/lib/picky/indexes_indexing.rb +16 -19
  30. data/lib/picky/loader.rb +6 -4
  31. data/lib/picky/query/allocation.rb +7 -2
  32. data/lib/picky/query/combination.rb +1 -1
  33. data/lib/picky/query/indexes.rb +1 -1
  34. data/lib/picky/query/indexes_check.rb +12 -14
  35. data/lib/picky/query/token.rb +33 -15
  36. data/lib/picky/results/exact_first.rb +53 -0
  37. data/lib/picky/scheduler.rb +43 -0
  38. data/lib/picky/search.rb +0 -2
  39. data/lib/picky/sources/csv.rb +2 -3
  40. data/lib/picky/sources/db.rb +4 -3
  41. data/lib/picky/sources/mongo.rb +1 -1
  42. data/lib/picky/tokenizer.rb +0 -4
  43. data/lib/picky/wrappers/bundle/location.rb +1 -1
  44. data/lib/picky.rb +2 -2
  45. data/lib/tasks/index.rake +13 -14
  46. data/spec/functional/backends/file_spec.rb +2 -4
  47. data/spec/functional/backends/memory_spec.rb +2 -2
  48. data/spec/functional/backends/redis_spec.rb +1 -1
  49. data/spec/functional/exact_first_spec.rb +24 -4
  50. data/spec/functional/realtime_spec.rb +7 -3
  51. data/spec/lib/application_spec.rb +30 -30
  52. data/spec/lib/backends/backend_spec.rb +25 -27
  53. data/spec/lib/backends/{memory → prepared}/text_spec.rb +1 -1
  54. data/spec/lib/category_indexing_spec.rb +1 -1
  55. data/spec/lib/extensions/symbol_spec.rb +1 -1
  56. data/spec/lib/generators/similarity/phonetic_spec.rb +46 -0
  57. data/spec/lib/index_indexed_spec.rb +5 -5
  58. data/spec/lib/index_indexing_spec.rb +13 -12
  59. data/spec/lib/index_spec.rb +8 -8
  60. data/spec/lib/indexers/base_spec.rb +5 -6
  61. data/spec/lib/indexers/parallel_spec.rb +10 -10
  62. data/spec/lib/indexes_indexed_spec.rb +1 -7
  63. data/spec/lib/indexes_indexing_spec.rb +10 -5
  64. data/spec/lib/query/indexes_check_spec.rb +44 -15
  65. data/spec/lib/query/indexes_spec.rb +11 -11
  66. data/spec/lib/query/token_spec.rb +10 -0
  67. data/spec/lib/{indexed/wrappers → results}/exact_first_spec.rb +18 -21
  68. data/spec/lib/scheduler_spec.rb +92 -0
  69. metadata +45 -34
  70. data/lib/picky/cores.rb +0 -127
  71. data/lib/picky/tokenizers/location.rb +0 -53
  72. data/lib/picky/wrappers/category/exact_first.rb +0 -94
  73. data/spec/lib/cores_spec.rb +0 -185
@@ -0,0 +1,53 @@
1
+ # encoding: utf-8
2
+ #
3
+ module Picky
4
+
5
+ class Results
6
+
7
+ # This index combines an exact and partial index.
8
+ # It serves to order the results such that exact hits are found first.
9
+ #
10
+ module ExactFirst
11
+
12
+ # Installs the exact first on the given category
13
+ # or on the categories of the index, if an index is given.
14
+ #
15
+ # THINK Can we unextend in the case it is an index?
16
+ #
17
+ def self.extended index_or_category
18
+ if index_or_category.respond_to? :categories
19
+ extend_each_of index_or_category.categories
20
+ index_or_category
21
+ end
22
+ end
23
+ def self.extend_each_of categories
24
+ categories.categories.each { |category| category.extend self }
25
+ end
26
+
27
+ # Overrides the original method.
28
+ #
29
+ def ids token
30
+ text = token.text
31
+ if token.partial?
32
+ exact.ids(text) | partial.ids(text)
33
+ else
34
+ exact.ids text
35
+ end
36
+ end
37
+
38
+ # Overrides the original method.
39
+ #
40
+ def weight token
41
+ text = token.text
42
+ if token.partial?
43
+ [exact.weight(text), partial.weight(text)].compact.max
44
+ else
45
+ exact.weight text
46
+ end
47
+ end
48
+
49
+ end
50
+
51
+ end
52
+
53
+ end
@@ -0,0 +1,43 @@
1
+ module Picky
2
+
3
+ class Scheduler
4
+
5
+ attr_reader :parallel
6
+
7
+ def initialize options = {}
8
+ @parallel = options[:parallel]
9
+
10
+ configure
11
+ end
12
+
13
+ def configure
14
+ if fork?
15
+ def schedule &block
16
+ scheduler.schedule &block
17
+ end
18
+
19
+ def finish
20
+ scheduler.join
21
+ end
22
+
23
+ def scheduler
24
+ @scheduler ||= Procrastinate::Scheduler.start Procrastinate::SpawnStrategy::Default.new(2)
25
+ end
26
+ else
27
+ def schedule
28
+ yield
29
+ end
30
+
31
+ def finish
32
+ # Don't do anything.
33
+ end
34
+ end
35
+ end
36
+
37
+ def fork?
38
+ parallel && Process.respond_to?(:fork)
39
+ end
40
+
41
+ end
42
+
43
+ end
data/lib/picky/search.rb CHANGED
@@ -27,8 +27,6 @@ module Picky
27
27
  # Takes:
28
28
  # * A number of indexes
29
29
  #
30
- # TODO Add reduce_allocations_to_amount (rename).
31
- #
32
30
  # It is also possible to define the tokenizer and weights like so.
33
31
  # Example:
34
32
  # search = Search.new(index1, index2, index3) do
@@ -62,9 +62,8 @@ module Picky
62
62
  #
63
63
  def harvest category
64
64
  index = category_names.index category.from
65
- get_data do |ary|
66
- indexed_id = ary.shift
67
- text = ary[index]
65
+ get_data do |indexed_id, *ary|
66
+ text = ary[index]
68
67
  next unless text
69
68
  text.force_encoding 'utf-8' # TODO Still needed?
70
69
  yield indexed_id, text
@@ -56,8 +56,9 @@ module Picky
56
56
  end
57
57
 
58
58
  # Creates a database adapter for use with this source.
59
+ #
59
60
  def create_database_adapter # :nodoc:
60
- # TODO Do not use ActiveRecord directly. Use set_table_name etc.
61
+ # THINK Do not use ActiveRecord directly? Use set_table_name etc?
61
62
  #
62
63
  adapter_class = Class.new ActiveRecord::Base
63
64
  adapter_class.abstract_class = true
@@ -96,7 +97,7 @@ module Picky
96
97
  # Uses CREATE TABLE AS with the given SELECT statement to create a snapshot of the data.
97
98
  #
98
99
  def take_snapshot index
99
- timed_exclaim %Q{"#{index.identifier}": Taking snapshot of database data.}
100
+ timed_exclaim %Q{ "#{index.identifier}": Taking snapshot of database data.}
100
101
 
101
102
  origin = snapshot_table_name index.name
102
103
  on_database = database.connection
@@ -143,7 +144,7 @@ module Picky
143
144
  def get_data category, offset, &block # :nodoc:
144
145
  select_statement = harvest_statement_with_offset category, offset
145
146
 
146
- # TODO Rewrite ASAP.
147
+ # THINK Not really nice like this. Rewrite if possible.
147
148
  #
148
149
  if database.connection.adapter_name == "PostgreSQL"
149
150
  id_key = 'id'
@@ -61,7 +61,7 @@ module Picky
61
61
  JSON.parse(resp)['rows'].each do |row|
62
62
  text = row[collection].to_s
63
63
  next unless text
64
- index_key = row.delete(@@id_key) # TODO Still works, I removed .values
64
+ index_key = row.delete @@id_key # Note: I removed .values
65
65
  yield index_key, text
66
66
  end
67
67
  end
@@ -20,10 +20,6 @@ module Picky
20
20
  @query_default ||= new
21
21
  end
22
22
 
23
- # TODO Move EMPTY_STRING top level.
24
- #
25
- EMPTY_STRING = ''.freeze
26
-
27
23
  def to_s
28
24
  reject_condition_location = @reject_condition.to_s[/:(\d+) \(lambda\)/, 1]
29
25
  <<-TOKENIZER
@@ -52,7 +52,7 @@ module Picky
52
52
  bundle.load
53
53
 
54
54
  # TODO Symbols (of the location_anchor!!!).
55
- # It should always be a Symbol.
55
+ # It should always be a Symbol.
56
56
  #
57
57
  @calculation.anchor = bundle['location_anchor'] && bundle['location_anchor'].to_f || raise("Configuration 'location_anchor' for #{bundle.identifier} missing. Did you run rake index already?")
58
58
  end
data/lib/picky.rb CHANGED
@@ -4,9 +4,10 @@ module Picky
4
4
  #
5
5
  require 'active_support/core_ext'
6
6
  require 'text'
7
- require 'yajl' # TODO Maybe replace by multi_json.
7
+ require 'yajl' # THINK Maybe replace by multi_json?
8
8
  require 'rack' # TODO Remove.
9
9
  require 'rack_fast_escape' # TODO Remove.
10
+ require 'procrastinate'
10
11
 
11
12
  # Require the constants.
12
13
  #
@@ -19,7 +20,6 @@ module Picky
19
20
  # Load the framework
20
21
  #
21
22
  Loader.load_framework
22
- puts "Loaded picky with environment '#{PICKY_ENVIRONMENT}' in #{PICKY_ROOT} on Ruby #{RUBY_VERSION}."
23
23
 
24
24
  # Check if delegators need to be installed.
25
25
  #
data/lib/tasks/index.rake CHANGED
@@ -1,22 +1,21 @@
1
1
  # Indexing tasks.
2
2
  #
3
- desc "Generate the index (index, category optional)."
4
- task :index, [:index, :category] => :application do |_, options|
5
- index, category = options.index, options.category
6
-
7
- specific = Picky::Indexes
8
- specific = specific[index] if index
9
- specific = specific[category] if category
10
- specific.index
11
- end
3
+ desc "Generate the index in parallel (index, category optional)."
4
+ task :index, [:index, :category] => :'index:parallel'
12
5
 
13
6
  namespace :index do
14
7
 
15
- task :randomly => :application do
16
- Picky::Indexes.index true
17
- end
18
- task :ordered => :application do
19
- Picky::Indexes.index false
8
+ [:parallel, :serial].each do |kind|
9
+ desc "Generate the index in #{kind} (index, category optional)."
10
+ task kind, [:index, :category] => :application do |_, options|
11
+ index, category = options.index, options.category
12
+
13
+ specific = Picky::Indexes
14
+ specific = specific[index] if index
15
+ specific = specific[category] if category
16
+
17
+ specific.index Picky::Scheduler.new(kind => true)
18
+ end
20
19
  end
21
20
 
22
21
  end
@@ -5,8 +5,6 @@ require 'spec_helper'
5
5
  # Describes a Picky index that uses the File backend
6
6
  # for data storage.
7
7
  #
8
- # TODO Everything should just fail.
9
- #
10
8
  describe Picky::Backends::File do
11
9
 
12
10
  class Book
@@ -49,7 +47,7 @@ describe Picky::Backends::File do
49
47
  it 'handles removing with more than one entry' do
50
48
  data.add Book.new(2, 'title', 'author')
51
49
 
52
- books.search('title').ids.should == ['2', '1'] # TODO Should be ['2', '1']
50
+ books.search('title').ids.should == ['2', '1']
53
51
 
54
52
  data.remove '1'
55
53
 
@@ -59,7 +57,7 @@ describe Picky::Backends::File do
59
57
  data.add Book.new(2, 'title', 'author')
60
58
  data.add Book.new(3, 'title', 'author')
61
59
 
62
- books.search('title').ids.should == ['3', '2', '1'] # TODO Should be ['3', '2', '1']
60
+ books.search('title').ids.should == ['3', '2', '1']
63
61
 
64
62
  data.remove '1'
65
63
 
@@ -47,7 +47,7 @@ describe Picky::Backends::Memory do
47
47
  it 'handles removing with more than one entry' do
48
48
  data.add Book.new(2, 'title', 'author')
49
49
 
50
- books.search('title').ids.should == ['2', '1'] # TODO Should be ['2', '1']
50
+ books.search('title').ids.should == ['2', '1']
51
51
 
52
52
  data.remove '1'
53
53
 
@@ -57,7 +57,7 @@ describe Picky::Backends::Memory do
57
57
  data.add Book.new(2, 'title', 'author')
58
58
  data.add Book.new(3, 'title', 'author')
59
59
 
60
- books.search('title').ids.should == ['3', '2', '1'] # TODO Should be ['3', '2', '1']
60
+ books.search('title').ids.should == ['3', '2', '1']
61
61
 
62
62
  data.remove '1'
63
63
 
@@ -57,7 +57,7 @@ describe Picky::Backends::Redis do
57
57
  data.add Book.new(2, 'title', 'author')
58
58
  data.add Book.new(3, 'title', 'author')
59
59
 
60
- books.search('title').ids.should == ['3', '2', '1'] # TODO Should be ['3', '2', '1']
60
+ books.search('title').ids.should == ['3', '2', '1']
61
61
 
62
62
  data.remove '1'
63
63
 
@@ -23,7 +23,27 @@ describe "exact first" do
23
23
  normal = Picky::Search.new index
24
24
  normal.search("disco").ids.should == [2, 1] # 2 was added later.
25
25
 
26
- index = Picky::Wrappers::Category::ExactFirst.wrap index
26
+ index.extend Picky::Results::ExactFirst
27
+
28
+ exact_first = Picky::Search.new index
29
+ exact_first.search("disco").ids.should == [1, 2] # Exact first.
30
+ exact_first.search("disc").ids.should == [2, 1] # Not exact, so not first.
31
+ end
32
+
33
+ it 'handles extending single categories' do
34
+ index = Picky::Index.new :exact_first
35
+ category = index.category :text, partial: Picky::Partial::Substring.new(from: 1)
36
+
37
+ require 'ostruct'
38
+ exact = OpenStruct.new id: 1, text: "disco"
39
+ partial = OpenStruct.new id: 2, text: "discofox"
40
+ index.add exact
41
+ index.add partial
42
+
43
+ normal = Picky::Search.new index
44
+ normal.search("disco").ids.should == [2, 1] # 2 was added later.
45
+
46
+ category.extend Picky::Results::ExactFirst
27
47
 
28
48
  exact_first = Picky::Search.new index
29
49
  exact_first.search("disco").ids.should == [1, 2] # Exact first.
@@ -41,14 +61,14 @@ describe "exact first" do
41
61
  category :text, partial: Picky::Partial::Substring.new(from: 1)
42
62
  end
43
63
  normal = Picky::Search.new data
44
- Picky::Indexes.index_for_tests
64
+ Picky::Indexes.index
45
65
 
46
66
  normal.search("disco").ids.should == [1, 2] # Ordering with which it was added.
47
67
 
48
- data = Picky::Wrappers::Category::ExactFirst.wrap data
68
+ data.extend Picky::Results::ExactFirst
49
69
  exact_first = Picky::Search.new data
50
70
 
51
- Picky::Indexes.index_for_tests
71
+ Picky::Indexes.index
52
72
 
53
73
  exact_first.search("disco").ids.should == [2, 1] # Exact first.
54
74
  exact_first.search("disc").ids.should == [1, 2] # Not exact, so not first.
@@ -26,7 +26,7 @@ describe "Realtime Indexing" do
26
26
  end
27
27
 
28
28
  context 'dumping and loading' do
29
- it "doesn't find books anymore after dumping and reloading and updating" do
29
+ it "doesn't find books anymore after dumping and loading and updating" do
30
30
  index.replace Book.new(2, "Title New", "Author New")
31
31
 
32
32
  books.search("title").ids.should == [2, 1]
@@ -243,7 +243,9 @@ describe "Realtime Indexing" do
243
243
  index.replace Book.new(2, "Title New", "Author New")
244
244
  index.add Book.new(3, "TTL", "AUTHR")
245
245
 
246
- books.search('author:Athr~').ids.should == [2, 1, 3] # TODO Is that what I'd expect?
246
+ # Note: [2, 1] are in one allocation, [3] in the other.
247
+ #
248
+ books.search('author:Athr~').ids.should == [2, 1, 3]
247
249
  end
248
250
  end
249
251
  end
@@ -465,7 +467,9 @@ describe "Realtime Indexing" do
465
467
  index.replace Book.new("two", "Title New", "Author New")
466
468
  index.add Book.new("three", "TTL", "AUTHR")
467
469
 
468
- books.search('author:Athr~').ids.should == [:two, :one, :three] # TODO Is that what I'd expect?
470
+ # Note: Allocations are [:two, :one], then [:three].
471
+ #
472
+ books.search('author:Athr~').ids.should == [:two, :one, :three]
469
473
  end
470
474
  end
471
475
  end
@@ -3,7 +3,7 @@
3
3
  require 'spec_helper'
4
4
 
5
5
  describe Picky::Application do
6
-
6
+
7
7
  describe "integration" do
8
8
  it "should run ok" do
9
9
  lambda {
@@ -14,10 +14,10 @@ describe Picky::Application do
14
14
  :file => 'app/db.yml'
15
15
  )
16
16
  end
17
- books.define_category :title
18
-
17
+ books.category :title
18
+
19
19
  rack_adapter.stub! :exclaim # Stopping it from exclaiming.
20
-
20
+
21
21
  route %r{^/books} => Picky::Search.new(books)
22
22
  end
23
23
  Picky::Tokenizer.index_default.tokenize 'some text'
@@ -35,29 +35,29 @@ describe Picky::Application do
35
35
  removes_characters_after_splitting: /[\.]/,
36
36
  normalizes_words: [[/\$(\w+)/i, '\1 dollars']],
37
37
  rejects_token_if: lambda { |token| token.blank? || token == :amistad }
38
-
38
+
39
39
  searching removes_characters: /[^a-zA-Z0-9äöü\s\/\-\,\&\"\~\*\:]/,
40
40
  stopwords: /\b(and|the|of|it|in|for)\b/,
41
41
  splits_text_on: /[\s\/\-\,\&]+/,
42
42
  normalizes_words: [[/Deoxyribonucleic Acid/i, 'DNA']],
43
-
43
+
44
44
  substitutes_characters_with: Picky::CharacterSubstituters::WestEuropean.new,
45
45
  maximum_tokens: 5
46
-
46
+
47
47
  books_index = Picky::Index.new :books do
48
48
  source Picky::Sources::DB.new(
49
49
  'SELECT id, title, author, isbn13 as isbn FROM books',
50
50
  :file => 'app/db.yml'
51
51
  )
52
52
  end
53
-
54
- books_index.define_category :title,
55
- similarity: Picky::Similarity::DoubleMetaphone.new(3) # Up to three similar title word indexed.
56
- books_index.define_category :author,
57
- similarity: Picky::Similarity::Soundex.new(2)
58
- books_index.define_category :isbn,
53
+
54
+ books_index.category :title,
55
+ similarity: Picky::Similarity::DoubleMetaphone.new(3) # Up to three similar title word indexed.
56
+ books_index.category :author,
57
+ similarity: Picky::Similarity::Soundex.new(2)
58
+ books_index.category :isbn,
59
59
  partial: Picky::Partial::None.new # Partially searching on an ISBN makes not much sense.
60
-
60
+
61
61
  geo_index = Picky::Index.new :geo do
62
62
  source Picky::Sources::CSV.new(:location, :north, :east, file: 'data/ch.csv', col_sep: ',')
63
63
  indexing removes_characters: /[^a-z]/
@@ -66,11 +66,11 @@ describe Picky::Application do
66
66
  ranged_category :north1, 1, precision: 3, from: :north
67
67
  ranged_category :east1, 1, precision: 3, from: :east
68
68
  end
69
-
69
+
70
70
  rack_adapter.stub! :exclaim # Stopping it from exclaiming.
71
-
71
+
72
72
  route %r{^/books} => Picky::Search.new(books_index)
73
-
73
+
74
74
  buks_search = Picky::Search.new(books_index) do
75
75
  searching removes_characters: /[buks]/
76
76
  ignore :author
@@ -80,39 +80,39 @@ describe Picky::Application do
80
80
  }.should_not raise_error
81
81
  end
82
82
  end
83
-
83
+
84
84
  describe 'finalize' do
85
85
  before(:each) do
86
86
  described_class.stub! :check
87
87
  end
88
88
  it 'checks if all is ok' do
89
89
  described_class.should_receive(:check).once.with
90
-
90
+
91
91
  described_class.finalize
92
92
  end
93
93
  it 'tells the rack adapter to finalize' do
94
94
  described_class.rack_adapter.should_receive(:finalize).once.with
95
-
95
+
96
96
  described_class.finalize
97
97
  end
98
98
  end
99
-
99
+
100
100
  describe 'check' do
101
101
  it 'does something' do
102
102
  described_class.should_receive(:warn).once.with "\nWARNING: No routes defined for application configuration in Class.\n\n"
103
-
103
+
104
104
  described_class.check
105
105
  end
106
106
  end
107
-
107
+
108
108
  describe 'delegation' do
109
109
  it "should delegate route" do
110
110
  described_class.rack_adapter.should_receive(:route).once.with :path => :query
111
-
111
+
112
112
  described_class.route :path => :query
113
113
  end
114
114
  end
115
-
115
+
116
116
  describe 'rack_adapter' do
117
117
  it 'should be there' do
118
118
  lambda { described_class.rack_adapter }.should_not raise_error
@@ -124,11 +124,11 @@ describe Picky::Application do
124
124
  described_class.rack_adapter.should == described_class.rack_adapter
125
125
  end
126
126
  end
127
-
127
+
128
128
  describe 'route' do
129
129
  it 'is delegated' do
130
130
  described_class.rack_adapter.should_receive(:route).once.with :some_options
131
-
131
+
132
132
  described_class.route(:some_options)
133
133
  end
134
134
  it 'raises on block' do
@@ -139,7 +139,7 @@ describe Picky::Application do
139
139
  }.to raise_error("Warning: block passed into #route method, not into Search.new!")
140
140
  end
141
141
  end
142
-
142
+
143
143
  describe 'call' do
144
144
  before(:each) do
145
145
  @routes = stub :routes
@@ -147,9 +147,9 @@ describe Picky::Application do
147
147
  end
148
148
  it 'should delegate' do
149
149
  @routes.should_receive(:call).once.with :env
150
-
150
+
151
151
  described_class.call :env
152
152
  end
153
153
  end
154
-
154
+
155
155
  end
@@ -2,37 +2,35 @@ require 'spec_helper'
2
2
 
3
3
  describe Picky::Backends::Backend do
4
4
 
5
- context 'without options' do
6
- let(:backend) { described_class.new }
5
+ let(:backend) { described_class.new }
7
6
 
8
- describe 'extract_lambda_or' do
9
- it 'returns a given non-lambda' do
10
- backend.extract_lambda_or(:thing).should == :thing
11
- end
12
- it 'calls a given lambda with the given args' do
13
- lam = ->() do
14
- :lam
15
- end
16
-
17
- backend.extract_lambda_or(lam).should == :lam
7
+ describe 'extract_lambda_or' do
8
+ it 'returns a given non-lambda' do
9
+ backend.extract_lambda_or(:thing).should == :thing
10
+ end
11
+ it 'calls a given lambda with the given args' do
12
+ lam = ->() do
13
+ :lam
18
14
  end
19
- it 'calls a given lambda with the given args' do
20
- lam = ->(arg1) do
21
- arg1.should == 1
22
- :lam
23
- end
24
-
25
- backend.extract_lambda_or(lam, 1).should == :lam
15
+
16
+ backend.extract_lambda_or(lam).should == :lam
17
+ end
18
+ it 'calls a given lambda with the given args' do
19
+ lam = ->(arg1) do
20
+ arg1.should == 1
21
+ :lam
26
22
  end
27
- it 'calls a given lambda with the given args' do
28
- lam = ->(arg1, arg2) do
29
- arg1.should == 1
30
- arg2.should == 2
31
- :lam
32
- end
33
-
34
- backend.extract_lambda_or(lam, 1, 2).should == :lam
23
+
24
+ backend.extract_lambda_or(lam, 1).should == :lam
25
+ end
26
+ it 'calls a given lambda with the given args' do
27
+ lam = ->(arg1, arg2) do
28
+ arg1.should == 1
29
+ arg2.should == 2
30
+ :lam
35
31
  end
32
+
33
+ backend.extract_lambda_or(lam, 1, 2).should == :lam
36
34
  end
37
35
  end
38
36
 
@@ -1,6 +1,6 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe Picky::Backends::Memory::Text do
3
+ describe Picky::Backends::Prepared::Text do
4
4
 
5
5
  let(:text) { described_class.new "some_cache_path" }
6
6
 
@@ -127,7 +127,7 @@ describe Picky::Category do
127
127
  category.stub! :indexer => @indexer
128
128
  end
129
129
  it "tells the indexer to index" do
130
- @indexer.should_receive(:index).once
130
+ @indexer.should_receive(:prepare).once
131
131
 
132
132
  category.prepare
133
133
  end
@@ -13,7 +13,7 @@ describe Symbol do
13
13
  performance_of { @token.each_subtoken { |subtoken| } }.should < 0.00065
14
14
  end
15
15
  it 'is fast enough' do
16
- performance_of { @token.each_intoken { |intoken| } }.should < 0.025 # TODO Slow!
16
+ performance_of { @token.each_intoken { |intoken| } }.should < 0.025 # THINK Is this too slow?
17
17
  end
18
18
  end
19
19