picky 1.5.2 → 1.5.3

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 (69) hide show
  1. data/lib/picky/analyzer.rb +154 -0
  2. data/lib/picky/application.rb +53 -33
  3. data/lib/picky/character_substituters/west_european.rb +10 -6
  4. data/lib/picky/cli.rb +18 -18
  5. data/lib/picky/index/base.rb +44 -13
  6. data/lib/picky/index_bundle.rb +13 -4
  7. data/lib/picky/indexed/indexes.rb +26 -10
  8. data/lib/picky/indexing/indexes.rb +26 -24
  9. data/lib/picky/interfaces/live_parameters.rb +23 -16
  10. data/lib/picky/internals/extensions/object.rb +13 -6
  11. data/lib/picky/internals/frontend_adapters/rack.rb +30 -34
  12. data/lib/picky/internals/index/backend.rb +1 -2
  13. data/lib/picky/internals/index/file/basic.rb +18 -14
  14. data/lib/picky/internals/index/files.rb +16 -6
  15. data/lib/picky/internals/index/redis/basic.rb +12 -5
  16. data/lib/picky/internals/index/redis.rb +2 -2
  17. data/lib/picky/internals/indexed/bundle/base.rb +58 -14
  18. data/lib/picky/internals/indexed/bundle/memory.rb +40 -14
  19. data/lib/picky/internals/indexed/bundle/redis.rb +9 -30
  20. data/lib/picky/internals/indexed/categories.rb +19 -14
  21. data/lib/picky/internals/indexed/category.rb +44 -20
  22. data/lib/picky/internals/indexed/index.rb +23 -13
  23. data/lib/picky/internals/indexed/wrappers/bundle/wrapper.rb +27 -9
  24. data/lib/picky/internals/indexers/serial.rb +1 -1
  25. data/lib/picky/internals/indexing/bundle/base.rb +28 -28
  26. data/lib/picky/internals/indexing/bundle/memory.rb +14 -7
  27. data/lib/picky/internals/indexing/categories.rb +15 -11
  28. data/lib/picky/internals/indexing/category.rb +30 -20
  29. data/lib/picky/internals/indexing/index.rb +22 -14
  30. data/lib/picky/internals/query/allocations.rb +0 -15
  31. data/lib/picky/internals/query/combinations/base.rb +0 -4
  32. data/lib/picky/internals/query/combinations/redis.rb +19 -8
  33. data/lib/picky/internals/query/indexes.rb +3 -6
  34. data/lib/picky/internals/query/token.rb +0 -4
  35. data/lib/picky/internals/query/weights.rb +2 -11
  36. data/lib/picky/internals/results/base.rb +3 -10
  37. data/lib/picky/internals/tokenizers/base.rb +64 -28
  38. data/lib/picky/internals/tokenizers/index.rb +8 -8
  39. data/lib/picky/loader.rb +59 -53
  40. data/lib/picky/query/base.rb +23 -29
  41. data/lib/picky/sources/base.rb +10 -10
  42. data/lib/picky/sources/couch.rb +14 -10
  43. data/lib/picky/sources/csv.rb +21 -14
  44. data/lib/picky/sources/db.rb +37 -31
  45. data/lib/picky/sources/delicious.rb +11 -8
  46. data/lib/picky/sources/wrappers/base.rb +3 -1
  47. data/lib/picky/statistics.rb +66 -0
  48. data/lib/tasks/application.rake +3 -0
  49. data/lib/tasks/checks.rake +11 -0
  50. data/lib/tasks/framework.rake +3 -0
  51. data/lib/tasks/index.rake +9 -11
  52. data/lib/tasks/routes.rake +3 -2
  53. data/lib/tasks/shortcuts.rake +17 -5
  54. data/lib/tasks/statistics.rake +20 -12
  55. data/lib/tasks/try.rake +14 -14
  56. data/spec/lib/application_spec.rb +3 -3
  57. data/spec/lib/index/base_spec.rb +25 -3
  58. data/spec/lib/internals/extensions/object_spec.rb +46 -20
  59. data/spec/lib/internals/frontend_adapters/rack_spec.rb +3 -3
  60. data/spec/lib/internals/index/redis/basic_spec.rb +67 -0
  61. data/spec/lib/internals/indexers/serial_spec.rb +1 -1
  62. data/spec/lib/internals/results/base_spec.rb +0 -12
  63. data/spec/lib/internals/tokenizers/base_spec.rb +49 -1
  64. data/spec/lib/query/allocations_spec.rb +0 -56
  65. data/spec/lib/query/base_spec.rb +25 -21
  66. data/spec/lib/query/combinations/redis_spec.rb +6 -1
  67. data/spec/lib/sources/delicious_spec.rb +2 -2
  68. data/spec/lib/statistics_spec.rb +31 -0
  69. metadata +9 -2
@@ -7,7 +7,8 @@ describe Query::Base do
7
7
  describe 'combinations_type_for' do
8
8
  let(:query) { described_class.new }
9
9
  it 'returns a specific Combination for a specific input' do
10
- query.combinations_type_for([Index::Memory.new(:gu, :ga)]).should == Internals::Query::Combinations::Memory
10
+ some_source = stub(:source, :harvest => nil)
11
+ query.combinations_type_for([Index::Memory.new(:gu, some_source)]).should == Internals::Query::Combinations::Memory
11
12
  end
12
13
  it 'just works on the same types' do
13
14
  query.combinations_type_for([:blorf, :blarf]).should == Internals::Query::Combinations::Memory
@@ -45,24 +46,24 @@ describe Query::Base do
45
46
  end
46
47
  end
47
48
 
48
- describe "empty_results" do
49
- before(:each) do
50
- @query = Query::Full.new
51
-
52
- @result_type = stub :result_type
53
- @query.stub! :result_type => @result_type
54
- end
55
- it "returns a new result type" do
56
- @result_type.should_receive(:new).once.with :some_offset
57
-
58
- @query.empty_results :some_offset
59
- end
60
- it "returns a new result type with default offset" do
61
- @result_type.should_receive(:new).once.with 0
62
-
63
- @query.empty_results
64
- end
65
- end
49
+ # describe "empty_results" do
50
+ # before(:each) do
51
+ # @query = Query::Full.new
52
+ #
53
+ # @result_type = stub :result_type
54
+ # @query.stub! :result_type => @result_type
55
+ # end
56
+ # it "returns a new result type" do
57
+ # @result_type.should_receive(:new).once.with :some_offset
58
+ #
59
+ # @query.empty_results :some_offset
60
+ # end
61
+ # it "returns a new result type with default offset" do
62
+ # @result_type.should_receive(:new).once.with 0
63
+ #
64
+ # @query.empty_results
65
+ # end
66
+ # end
66
67
 
67
68
  describe "search_with_text" do
68
69
  before(:each) do
@@ -149,12 +150,15 @@ describe Query::Base do
149
150
  end
150
151
 
151
152
  describe 'to_s' do
153
+ before(:each) do
154
+ @type.stub! :name => :some_index
155
+ end
152
156
  context 'with weights' do
153
157
  before(:each) do
154
158
  @query = Query::Full.new @index, weights: :some_weights
155
159
  end
156
160
  it 'works correctly' do
157
- @query.to_s.should == 'Query::Full, weights: some_weights'
161
+ @query.to_s.should == 'Query::Full(some_index, weights: some_weights)'
158
162
  end
159
163
  end
160
164
  context 'without weights' do
@@ -162,7 +166,7 @@ describe Query::Base do
162
166
  @query = Query::Full.new @index
163
167
  end
164
168
  it 'works correctly' do
165
- @query.to_s.should == 'Query::Full'
169
+ @query.to_s.should == 'Query::Full(some_index)'
166
170
  end
167
171
  end
168
172
  end
@@ -114,7 +114,12 @@ describe Internals::Query::Combinations::Redis do
114
114
  end
115
115
 
116
116
  describe 'generate_intermediate_result_id' do
117
- # TODO
117
+ it 'returns the correct result id' do
118
+ @combinations.stub! :host => 'some_hostname'
119
+ Process.stub! :pid => 12345
120
+
121
+ @combinations.generate_intermediate_result_id.should == :'some_hostname:12345:picky:result'
122
+ end
118
123
  end
119
124
 
120
125
  describe "ids" do
@@ -14,8 +14,8 @@ describe Sources::Delicious do
14
14
  before(:each) do
15
15
  @source.should_receive(:require).any_number_of_times.and_raise LoadError
16
16
  end
17
- it "puts & exits" do
18
- @source.should_receive(:puts).once.with "www-delicious gem missing!\nTo use the delicious source, you need to:\n 1. Add the following line to Gemfile:\n gem 'www-delicious'\n 2. Then, run:\n bundle update\n"
17
+ it "warns & exits" do
18
+ @source.should_receive(:warn).once.with "www-delicious gem missing!\nTo use the delicious source, you need to:\n 1. Add the following line to Gemfile:\n gem 'www-delicious'\n 2. Then, run:\n bundle update\n"
19
19
  @source.should_receive(:exit).once.with 1
20
20
 
21
21
  @source.check_gem
@@ -0,0 +1,31 @@
1
+ # encoding: utf-8
2
+ #
3
+ require 'spec_helper'
4
+
5
+ # We need to load the Statistics file explicitly as the Statistics
6
+ # are not loaded with the Loader (not needed in the server, only for script runs).
7
+ #
8
+ require File.expand_path '../../../lib/picky/statistics', __FILE__
9
+
10
+ describe Statistics do
11
+
12
+ let(:stats) { described_class.new }
13
+
14
+ describe 'lines_of_code' do
15
+ it 'is correct' do
16
+ stats.lines_of_code(<<-TEXT
17
+ # not a line of code
18
+ class LineOfCode
19
+ # also not a line of code
20
+ def bla
21
+ # not one either
22
+ this is one # this is still one
23
+ end
24
+ end
25
+ # In total, we have 5 LOC.
26
+ TEXT
27
+ ).should == 5
28
+ end
29
+ end
30
+
31
+ end
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: picky
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 1.5.2
5
+ version: 1.5.3
6
6
  platform: ruby
7
7
  authors:
8
8
  - Florian Hanke
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2011-03-04 00:00:00 +01:00
13
+ date: 2011-03-13 00:00:00 +01:00
14
14
  default_executable: picky
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
@@ -37,6 +37,7 @@ files:
37
37
  - lib/constants.rb
38
38
  - lib/deployment.rb
39
39
  - lib/picky/aliases.rb
40
+ - lib/picky/analyzer.rb
40
41
  - lib/picky/application.rb
41
42
  - lib/picky/character_substituters/west_european.rb
42
43
  - lib/picky/cli.rb
@@ -144,9 +145,11 @@ files:
144
145
  - lib/picky/sources/delicious.rb
145
146
  - lib/picky/sources/wrappers/base.rb
146
147
  - lib/picky/sources/wrappers/location.rb
148
+ - lib/picky/statistics.rb
147
149
  - lib/picky-tasks.rb
148
150
  - lib/picky.rb
149
151
  - lib/tasks/application.rake
152
+ - lib/tasks/checks.rake
150
153
  - lib/tasks/framework.rake
151
154
  - lib/tasks/index.rake
152
155
  - lib/tasks/routes.rake
@@ -195,6 +198,7 @@ files:
195
198
  - spec/lib/internals/index/file/marshal_spec.rb
196
199
  - spec/lib/internals/index/file/text_spec.rb
197
200
  - spec/lib/internals/index/files_spec.rb
201
+ - spec/lib/internals/index/redis/basic_spec.rb
198
202
  - spec/lib/internals/index/redis/string_hash_spec.rb
199
203
  - spec/lib/internals/index/redis_spec.rb
200
204
  - spec/lib/internals/indexed/bundle/memory_spec.rb
@@ -243,6 +247,7 @@ files:
243
247
  - spec/lib/sources/delicious_spec.rb
244
248
  - spec/lib/sources/wrappers/base_spec.rb
245
249
  - spec/lib/sources/wrappers/location_spec.rb
250
+ - spec/lib/statistics_spec.rb
246
251
  - spec/specific/speed_spec.rb
247
252
  - bin/picky
248
253
  has_rdoc: true
@@ -312,6 +317,7 @@ test_files:
312
317
  - spec/lib/internals/index/file/marshal_spec.rb
313
318
  - spec/lib/internals/index/file/text_spec.rb
314
319
  - spec/lib/internals/index/files_spec.rb
320
+ - spec/lib/internals/index/redis/basic_spec.rb
315
321
  - spec/lib/internals/index/redis/string_hash_spec.rb
316
322
  - spec/lib/internals/index/redis_spec.rb
317
323
  - spec/lib/internals/indexed/bundle/memory_spec.rb
@@ -360,4 +366,5 @@ test_files:
360
366
  - spec/lib/sources/delicious_spec.rb
361
367
  - spec/lib/sources/wrappers/base_spec.rb
362
368
  - spec/lib/sources/wrappers/location_spec.rb
369
+ - spec/lib/statistics_spec.rb
363
370
  - spec/specific/speed_spec.rb