picky 0.11.0 → 0.11.1
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.
- data/lib/picky/bundle.rb +2 -0
- data/lib/picky/index/category.rb +0 -2
- data/lib/picky/index/files.rb +0 -2
- data/lib/picky/indexers/base.rb +14 -2
- data/lib/picky/indexers/default.rb +1 -1
- data/lib/picky/indexing/categories.rb +2 -0
- data/lib/picky/indexing/category.rb +10 -21
- data/lib/picky/indexing/types.rb +16 -3
- data/lib/picky/loader.rb +0 -1
- data/lib/picky/sources/couch.rb +1 -1
- data/lib/picky/sources/csv.rb +1 -1
- data/lib/picky/types.rb +3 -1
- data/lib/tasks/index.rake +8 -9
- data/lib/tasks/shortcuts.rake +2 -2
- data/spec/lib/indexing/category_spec.rb +2 -28
- metadata +3 -7
- data/lib/picky/configuration/type.rb +0 -20
- data/lib/picky/indexers/field.rb +0 -9
- data/spec/lib/indexers/field_spec.rb +0 -9
data/lib/picky/bundle.rb
CHANGED
data/lib/picky/index/category.rb
CHANGED
data/lib/picky/index/files.rb
CHANGED
data/lib/picky/indexers/base.rb
CHANGED
@@ -21,6 +21,8 @@ module Indexers
|
|
21
21
|
#
|
22
22
|
# TODO Duplicate code in Index::Files.
|
23
23
|
#
|
24
|
+
# TODO Rename to prepared_index_file_name.
|
25
|
+
#
|
24
26
|
def search_index_file_name
|
25
27
|
@category.search_index_file_name
|
26
28
|
end
|
@@ -37,7 +39,7 @@ module Indexers
|
|
37
39
|
@category.source || raise_no_source
|
38
40
|
end
|
39
41
|
def raise_no_source
|
40
|
-
raise NoSourceSpecifiedException.new
|
42
|
+
raise NoSourceSpecifiedException.new("No source given for index:#{@type.name}, category:#{@category.name}.") # TODO field.identifier
|
41
43
|
end
|
42
44
|
|
43
45
|
# Selects the original id (indexed id) and a column to process. The column data is called "token".
|
@@ -50,7 +52,17 @@ module Indexers
|
|
50
52
|
|
51
53
|
indexing_message
|
52
54
|
|
53
|
-
# TODO Move open to Index::File.
|
55
|
+
# TODO Move open to Index::File.
|
56
|
+
#
|
57
|
+
# @category.prepared_index do |file|
|
58
|
+
# source.harvest(@type, @category) do |indexed_id, text|
|
59
|
+
# tokenizer.tokenize(text).each do |token_text|
|
60
|
+
# next unless token_text
|
61
|
+
# file.buffer indexed_id << comma << token_text << newline
|
62
|
+
# end
|
63
|
+
# file.write_maybe
|
64
|
+
# end
|
65
|
+
# end
|
54
66
|
#
|
55
67
|
File.open(search_index_file_name, 'w:binary') do |file|
|
56
68
|
result = []
|
@@ -26,6 +26,8 @@ module Indexing
|
|
26
26
|
@exact = options[:exact_indexing_bundle] || Bundle.new(:exact, self, type, similarity, Cacher::Partial::None.new, weights)
|
27
27
|
@partial = options[:partial_indexing_bundle] || Bundle.new(:partial, self, type, Cacher::Similarity::None.new, partial, weights)
|
28
28
|
|
29
|
+
# TODO Move to Query.
|
30
|
+
#
|
29
31
|
# @remove = options[:remove] || false
|
30
32
|
# @filter = options[:filter] || true
|
31
33
|
|
@@ -66,27 +68,11 @@ module Indexing
|
|
66
68
|
exact.delete
|
67
69
|
partial.delete
|
68
70
|
end
|
69
|
-
def create_directory_structure
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
end
|
74
|
-
|
75
|
-
# Used for testing.
|
76
|
-
#
|
77
|
-
# TODO Remove?
|
78
|
-
#
|
79
|
-
def generate_indexes_from_exact_index
|
80
|
-
generate_derived_exact
|
81
|
-
generate_partial
|
82
|
-
generate_derived_partial
|
83
|
-
end
|
84
|
-
def generate_derived_exact
|
85
|
-
exact.generate_derived
|
86
|
-
end
|
87
|
-
def generate_derived_partial
|
88
|
-
partial.generate_derived
|
89
|
-
end
|
71
|
+
# def create_directory_structure
|
72
|
+
# timed_exclaim "Creating directory structure for #{identifier}."
|
73
|
+
# exact.create_directory
|
74
|
+
# partial.create_directory
|
75
|
+
# end
|
90
76
|
|
91
77
|
# Generates all caches for this category.
|
92
78
|
#
|
@@ -117,6 +103,8 @@ module Indexing
|
|
117
103
|
|
118
104
|
# TODO Partially move to type. Duplicate Code in indexers/field.rb.
|
119
105
|
#
|
106
|
+
# TODO Use the Files object.
|
107
|
+
#
|
120
108
|
def search_index_root
|
121
109
|
File.join PICKY_ROOT, 'index'
|
122
110
|
end
|
@@ -128,6 +116,7 @@ module Indexing
|
|
128
116
|
end
|
129
117
|
def index
|
130
118
|
prepare_cache_directory
|
119
|
+
# files.create_directory # TODO Make this possible!
|
131
120
|
indexer.index
|
132
121
|
end
|
133
122
|
def prepare_cache_directory
|
data/lib/picky/indexing/types.rb
CHANGED
@@ -46,14 +46,25 @@ module Indexing
|
|
46
46
|
timed_exclaim "INDEXING FINISHED."
|
47
47
|
end
|
48
48
|
|
49
|
+
# For testing.
|
50
|
+
#
|
51
|
+
def index_for_tests
|
52
|
+
take_snapshot
|
53
|
+
|
54
|
+
self.types.each do |type|
|
55
|
+
type.index
|
56
|
+
type.cache
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
49
60
|
# TODO Spec
|
50
61
|
#
|
51
|
-
def generate_index_only type_name,
|
52
|
-
found = find type_name,
|
62
|
+
def generate_index_only type_name, category_name
|
63
|
+
found = find type_name, category_name
|
53
64
|
found.index if found
|
54
65
|
end
|
55
66
|
def generate_cache_only type_name, category_name
|
56
|
-
found = find type_name,
|
67
|
+
found = find type_name, category_name
|
57
68
|
found.generate_caches if found
|
58
69
|
end
|
59
70
|
|
@@ -68,6 +79,8 @@ module Indexing
|
|
68
79
|
found = type.categories.find category_name
|
69
80
|
return found if found
|
70
81
|
end
|
82
|
+
|
83
|
+
raise %Q{Index "#{type_name}" not found. Possible indexes: "#{types.map(&:name).join('", "')}".}
|
71
84
|
end
|
72
85
|
|
73
86
|
end
|
data/lib/picky/loader.rb
CHANGED
data/lib/picky/sources/couch.rb
CHANGED
data/lib/picky/sources/csv.rb
CHANGED
data/lib/picky/types.rb
CHANGED
data/lib/tasks/index.rake
CHANGED
@@ -12,17 +12,16 @@ namespace :index do
|
|
12
12
|
# end
|
13
13
|
# end
|
14
14
|
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
desc "Takes a snapshot, indexes, and caches."
|
20
|
-
task :
|
21
|
-
|
22
|
-
Indexes.index randomly
|
15
|
+
desc "Takes a snapshot, indexes, and caches in random order."
|
16
|
+
task :randomly => :application do
|
17
|
+
Indexes.index true
|
18
|
+
end
|
19
|
+
desc "Takes a snapshot, indexes, and caches in order given."
|
20
|
+
task :ordered => :application do
|
21
|
+
Indexes.index false
|
23
22
|
end
|
24
23
|
|
25
|
-
desc "Generates the index snapshots."
|
24
|
+
# desc "Generates the index snapshots."
|
26
25
|
task :generate_snapshots => :application do
|
27
26
|
Indexes.take_snapshot
|
28
27
|
end
|
data/lib/tasks/shortcuts.rake
CHANGED
@@ -24,41 +24,15 @@ describe Indexing::Category do
|
|
24
24
|
@category.dump_caches
|
25
25
|
end
|
26
26
|
end
|
27
|
-
|
28
|
-
describe 'generate_derived_partial' do
|
29
|
-
it 'should delegate to partial' do
|
30
|
-
@partial.should_receive(:generate_derived).once.with
|
31
|
-
|
32
|
-
@category.generate_derived_partial
|
33
|
-
end
|
34
|
-
end
|
35
|
-
|
36
|
-
describe 'generate_derived_exact' do
|
37
|
-
it 'should delegate to exact' do
|
38
|
-
@exact.should_receive(:generate_derived).once.with
|
39
|
-
|
40
|
-
@category.generate_derived_exact
|
41
|
-
end
|
42
|
-
end
|
43
|
-
|
44
|
-
describe 'generate_indexes_from_exact_index' do
|
45
|
-
it 'should call three method in order' do
|
46
|
-
@category.should_receive(:generate_derived_exact).once.with().ordered
|
47
|
-
@category.should_receive(:generate_partial).once.with().ordered
|
48
|
-
@category.should_receive(:generate_derived_partial).once.with().ordered
|
49
|
-
|
50
|
-
@category.generate_indexes_from_exact_index
|
51
|
-
end
|
52
|
-
end
|
53
27
|
|
54
28
|
describe 'generate_caches_from_memory' do
|
55
29
|
it 'should delegate to partial' do
|
56
30
|
@partial.should_receive(:generate_caches_from_memory).once.with
|
57
|
-
|
31
|
+
|
58
32
|
@category.generate_caches_from_memory
|
59
33
|
end
|
60
34
|
end
|
61
|
-
|
35
|
+
|
62
36
|
describe 'generate_partial' do
|
63
37
|
it 'should return whatever the partial generation returns' do
|
64
38
|
@exact.stub! :index
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 11
|
8
|
-
-
|
9
|
-
version: 0.11.
|
8
|
+
- 1
|
9
|
+
version: 0.11.1
|
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-11-
|
17
|
+
date: 2010-11-09 00:00:00 +01:00
|
18
18
|
default_executable: picky
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
@@ -64,7 +64,6 @@ files:
|
|
64
64
|
- lib/picky/character_substitution/european.rb
|
65
65
|
- lib/picky/configuration/indexes.rb
|
66
66
|
- lib/picky/configuration/queries.rb
|
67
|
-
- lib/picky/configuration/type.rb
|
68
67
|
- lib/picky/cores.rb
|
69
68
|
- lib/picky/ext/maybe_compile.rb
|
70
69
|
- lib/picky/ext/ruby19/extconf.rb
|
@@ -90,7 +89,6 @@ files:
|
|
90
89
|
- lib/picky/index/wrappers/exact_first.rb
|
91
90
|
- lib/picky/indexers/base.rb
|
92
91
|
- lib/picky/indexers/default.rb
|
93
|
-
- lib/picky/indexers/field.rb
|
94
92
|
- lib/picky/indexers/no_source_specified_error.rb
|
95
93
|
- lib/picky/indexers/solr.rb
|
96
94
|
- lib/picky/indexing/bundle.rb
|
@@ -192,7 +190,6 @@ files:
|
|
192
190
|
- spec/lib/index/type_spec.rb
|
193
191
|
- spec/lib/index/wrappers/exact_first_spec.rb
|
194
192
|
- spec/lib/indexers/base_spec.rb
|
195
|
-
- spec/lib/indexers/field_spec.rb
|
196
193
|
- spec/lib/indexing/bundle_partial_generation_speed_spec.rb
|
197
194
|
- spec/lib/indexing/bundle_spec.rb
|
198
195
|
- spec/lib/indexing/categories_spec.rb
|
@@ -294,7 +291,6 @@ test_files:
|
|
294
291
|
- spec/lib/index/type_spec.rb
|
295
292
|
- spec/lib/index/wrappers/exact_first_spec.rb
|
296
293
|
- spec/lib/indexers/base_spec.rb
|
297
|
-
- spec/lib/indexers/field_spec.rb
|
298
294
|
- spec/lib/indexing/bundle_partial_generation_speed_spec.rb
|
299
295
|
- spec/lib/indexing/bundle_spec.rb
|
300
296
|
- spec/lib/indexing/categories_spec.rb
|
@@ -1,20 +0,0 @@
|
|
1
|
-
module Configuration
|
2
|
-
class Type
|
3
|
-
attr_reader :name,
|
4
|
-
:source,
|
5
|
-
:result_type,
|
6
|
-
:after_indexing,
|
7
|
-
:ignore_unassigned_tokens
|
8
|
-
def initialize name, source, options
|
9
|
-
@name = name
|
10
|
-
@source = source
|
11
|
-
|
12
|
-
@result_type = options[:result_type] || name
|
13
|
-
@after_indexing = options[:after_indexing] # Where do I use this?
|
14
|
-
@ignore_unassigned_tokens = options[:ignore_unassigned_tokens] || false # TODO Move to query?
|
15
|
-
end
|
16
|
-
def generate
|
17
|
-
Index::Type.new name, source, result_type, ignore_unassigned_tokens
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
data/lib/picky/indexers/field.rb
DELETED