picky 4.0.9 → 4.1.0

Sign up to get free protection for your applications and to get access to all the features.
data/lib/picky/results.rb CHANGED
@@ -41,8 +41,15 @@ module Picky
41
41
 
42
42
  # Delegates to allocations.
43
43
  #
44
- def ids amount = 20
45
- allocations.ids amount
44
+ # TODO Remove parameter in 5.0 and just call
45
+ # the method with amount.
46
+ #
47
+ # Note that this is an expensive call and
48
+ # should not be done repeatedly. Just keep
49
+ # a reference to the result.
50
+ #
51
+ def ids only = nil
52
+ allocations.ids only || amount
46
53
  end
47
54
 
48
55
  # The total results. Delegates to the allocations.
@@ -0,0 +1,28 @@
1
+ # encoding: utf-8
2
+ #
3
+ require 'spec_helper'
4
+
5
+ describe 'Location search with live updates' do
6
+
7
+ it 'works with ids larger than 20 on non-specific search' do
8
+ data = Picky::Index.new :test do
9
+ category :titel
10
+ category :text
11
+ end
12
+
13
+ 50.times do |i|
14
+ data.replace_from id: i, titel: 'japan', text: 'some text on japan'
15
+ end
16
+
17
+ stuff = Picky::Search.new data
18
+
19
+ result = stuff.search 'titel:japan', 10000
20
+ result.total.should == 50
21
+ result.ids.size.should == 50
22
+
23
+ result = stuff.search 'japan', 10000
24
+ result.total.should == 100
25
+ result.ids.size.should == 100
26
+ end
27
+
28
+ end
@@ -14,6 +14,7 @@ describe 'Sinatra Index Actions' do
14
14
  category :name
15
15
  category :surname
16
16
  end
17
+
17
18
  people = Picky::Search.new data
18
19
 
19
20
  get '/people' do
@@ -25,7 +25,7 @@ describe Object do
25
25
 
26
26
  describe 'warn_gem_missing' do
27
27
  it 'should warn right' do
28
- object.should_receive(:warn).once.with "gnorf gem missing!\nTo use gnarble gnarf, you need to:\n 1. Add the following line to Gemfile:\n gem 'gnorf'\n or\n require 'gnorf'\n for example at the top of your app.rb file.\n 2. Then, run:\n bundle update\n"
28
+ object.should_receive(:warn).once.with "gnorf gem missing!\nTo use gnarble gnarf, you need to:\n 1. Add the following line to Gemfile:\n gem 'gnorf'\n 2. Then, run:\n bundle update\n"
29
29
 
30
30
  object.warn_gem_missing 'gnorf', 'gnarble gnarf'
31
31
  end
@@ -15,7 +15,7 @@ describe Picky::Generators::Similarity::Phonetic do
15
15
 
16
16
  instance.should_receive(:require).any_number_of_times.and_raise LoadError
17
17
 
18
- instance.should_receive(:warn).once.with "text gem missing!\nTo use a phonetic Similarity, you need to:\n 1. Add the following line to Gemfile:\n gem 'text'\n or\n require 'text'\n for example at the top of your app.rb file.\n 2. Then, run:\n bundle update\n"
18
+ instance.should_receive(:warn).once.with "text gem missing!\nTo use a phonetic Similarity, you need to:\n 1. Add the following line to Gemfile:\n gem 'text'\n 2. Then, run:\n bundle update\n"
19
19
  instance.should_receive(:exit).once.with 1
20
20
 
21
21
  instance.send :initialize
@@ -17,13 +17,19 @@ describe Picky::Results do
17
17
  describe "ids" do
18
18
  before(:each) do
19
19
  @allocations = stub :allocations
20
- @results = described_class.new :unimportant, :unimportant, :unimportant, @allocations
20
+ @results = described_class.new :unimportant, :amount, :unimportant, @allocations
21
21
  end
22
22
  it "delegates" do
23
23
  @allocations.should_receive(:ids).once.with :anything
24
24
 
25
25
  @results.ids :anything
26
26
  end
27
+ it "delegates and uses amount if nothing given" do
28
+ @allocations.should_receive(:ids).once.with :amount
29
+
30
+ @results.ids
31
+ end
32
+
27
33
  end
28
34
 
29
35
  describe 'to_s time format' do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: picky
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.0.9
4
+ version: 4.1.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-01-07 00:00:00.000000000 Z
12
+ date: 2012-01-24 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rspec
16
- requirement: &70141079682140 !ruby/object:Gem::Requirement
16
+ requirement: &70259240903180 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,21 +21,21 @@ dependencies:
21
21
  version: '0'
22
22
  type: :development
23
23
  prerelease: false
24
- version_requirements: *70141079682140
24
+ version_requirements: *70259240903180
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: picky-client
27
- requirement: &70141079681320 !ruby/object:Gem::Requirement
27
+ requirement: &70259240902680 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ~>
31
31
  - !ruby/object:Gem::Version
32
- version: 4.0.9
32
+ version: 4.1.0
33
33
  type: :development
34
34
  prerelease: false
35
- version_requirements: *70141079681320
35
+ version_requirements: *70259240902680
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: text
38
- requirement: &70141079680580 !ruby/object:Gem::Requirement
38
+ requirement: &70259240902260 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ! '>='
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: '0'
44
44
  type: :runtime
45
45
  prerelease: false
46
- version_requirements: *70141079680580
46
+ version_requirements: *70259240902260
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: yajl-ruby
49
- requirement: &70141079679600 !ruby/object:Gem::Requirement
49
+ requirement: &70259240901800 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ! '>='
@@ -54,10 +54,10 @@ dependencies:
54
54
  version: '0'
55
55
  type: :runtime
56
56
  prerelease: false
57
- version_requirements: *70141079679600
57
+ version_requirements: *70259240901800
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: activesupport
60
- requirement: &70141079694860 !ruby/object:Gem::Requirement
60
+ requirement: &70259240901300 !ruby/object:Gem::Requirement
61
61
  none: false
62
62
  requirements:
63
63
  - - ~>
@@ -65,10 +65,10 @@ dependencies:
65
65
  version: '3.0'
66
66
  type: :runtime
67
67
  prerelease: false
68
- version_requirements: *70141079694860
68
+ version_requirements: *70259240901300
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: procrastinate
71
- requirement: &70141079691460 !ruby/object:Gem::Requirement
71
+ requirement: &70259240900800 !ruby/object:Gem::Requirement
72
72
  none: false
73
73
  requirements:
74
74
  - - ~>
@@ -76,10 +76,10 @@ dependencies:
76
76
  version: '0.4'
77
77
  type: :runtime
78
78
  prerelease: false
79
- version_requirements: *70141079691460
79
+ version_requirements: *70259240900800
80
80
  - !ruby/object:Gem::Dependency
81
81
  name: rack_fast_escape
82
- requirement: &70141079689280 !ruby/object:Gem::Requirement
82
+ requirement: &70259240900420 !ruby/object:Gem::Requirement
83
83
  none: false
84
84
  requirements:
85
85
  - - ! '>='
@@ -87,7 +87,7 @@ dependencies:
87
87
  version: '0'
88
88
  type: :runtime
89
89
  prerelease: false
90
- version_requirements: *70141079689280
90
+ version_requirements: *70259240900420
91
91
  description: Fast Ruby semantic text search engine with comfortable single field interface.
92
92
  email: florian.hanke+picky@gmail.com
93
93
  executables:
@@ -248,6 +248,7 @@ files:
248
248
  - spec/functional/dynamic_weights_spec.rb
249
249
  - spec/functional/exact_first_spec.rb
250
250
  - spec/functional/max_allocations_spec.rb
251
+ - spec/functional/non_specific_ids_larger_than_20_spec.rb
251
252
  - spec/functional/only_spec.rb
252
253
  - spec/functional/realtime_spec.rb
253
254
  - spec/functional/regression_spec.rb
@@ -393,6 +394,7 @@ test_files:
393
394
  - spec/functional/dynamic_weights_spec.rb
394
395
  - spec/functional/exact_first_spec.rb
395
396
  - spec/functional/max_allocations_spec.rb
397
+ - spec/functional/non_specific_ids_larger_than_20_spec.rb
396
398
  - spec/functional/only_spec.rb
397
399
  - spec/functional/realtime_spec.rb
398
400
  - spec/functional/regression_spec.rb