picky 3.4.3 → 3.5.0
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/aux/picky/cli.rb +1 -1
- data/lib/picky/backends/memory/json.rb +1 -1
- data/lib/picky/backends/memory/text.rb +2 -2
- data/lib/picky/backends/redis/string.rb +6 -0
- data/lib/picky/bundle.rb +0 -1
- data/lib/picky/bundle_indexing.rb +11 -107
- data/lib/picky/bundle_realtime.rb +16 -8
- data/lib/picky/calculations/location.rb +18 -14
- data/lib/picky/categories.rb +1 -1
- data/lib/picky/category.rb +7 -1
- data/lib/picky/category_indexed.rb +1 -0
- data/lib/picky/category_indexing.rb +17 -17
- data/lib/picky/category_realtime.rb +23 -11
- data/lib/picky/deployment.rb +33 -33
- data/lib/picky/generators/partial/substring.rb +0 -2
- data/lib/picky/generators/similarity/double_metaphone.rb +1 -1
- data/lib/picky/generators/similarity/metaphone.rb +1 -1
- data/lib/picky/generators/similarity/soundex.rb +1 -1
- data/lib/picky/index.rb +22 -5
- data/lib/picky/index_indexing.rb +3 -15
- data/lib/picky/indexers/base.rb +7 -3
- data/lib/picky/indexers/parallel.rb +1 -10
- data/lib/picky/indexers/serial.rb +1 -10
- data/lib/picky/indexes.rb +1 -1
- data/lib/picky/loader.rb +2 -6
- data/lib/picky/query/qualifier_category_mapper.rb +2 -2
- data/lib/picky/query/token.rb +1 -2
- data/lib/picky/query/tokens.rb +6 -0
- data/lib/picky/search.rb +1 -0
- data/lib/picky/sources/couch.rb +1 -1
- data/lib/picky/sources/csv.rb +1 -1
- data/lib/picky/sources/mongo.rb +1 -1
- data/lib/picky/wrappers/bundle/calculation.rb +8 -8
- data/lib/picky/wrappers/bundle/delegators.rb +4 -1
- data/lib/picky/wrappers/bundle/exact_partial.rb +1 -1
- data/lib/picky/wrappers/bundle/location.rb +30 -13
- data/lib/picky/wrappers/category/location.rb +14 -9
- data/lib/tasks/try.rb +2 -2
- data/spec/lib/backends/memory/text_spec.rb +6 -6
- data/spec/lib/bundle_spec.rb +4 -4
- data/spec/lib/calculations/location_spec.rb +27 -29
- data/spec/lib/category_indexed_spec.rb +1 -0
- data/spec/lib/category_indexing_spec.rb +23 -36
- data/spec/lib/category_spec.rb +2 -0
- data/spec/lib/extensions/string_spec.rb +1 -1
- data/spec/lib/generators/partial/infix_spec.rb +2 -2
- data/spec/lib/index_indexing_spec.rb +5 -3
- data/spec/lib/indexed/bundle_spec.rb +2 -2
- data/spec/lib/indexers/base_spec.rb +2 -4
- data/spec/lib/indexers/serial_spec.rb +3 -19
- data/spec/lib/indexing/bundle_partial_generation_speed_spec.rb +42 -42
- data/spec/lib/indexing/bundle_spec.rb +4 -133
- data/spec/lib/query/combination_spec.rb +6 -6
- data/spec/lib/query/token_spec.rb +32 -19
- data/spec/lib/query/tokens_spec.rb +23 -10
- metadata +27 -34
- data/lib/picky/no_source_specified_exception.rb +0 -7
- data/lib/picky/wrappers/sources/base.rb +0 -35
- data/lib/picky/wrappers/sources/location.rb +0 -56
- data/spec/lib/sources/wrappers/base_spec.rb +0 -38
- data/spec/lib/sources/wrappers/location_spec.rb +0 -55
data/lib/picky/deployment.rb
CHANGED
@@ -2,14 +2,14 @@ require File.expand_path '../constants', __FILE__
|
|
2
2
|
|
3
3
|
module Picky # :nodoc:
|
4
4
|
module Capistrano # :nodoc:all
|
5
|
-
|
6
|
-
# Include all
|
5
|
+
|
6
|
+
# Include all
|
7
7
|
#
|
8
8
|
module All
|
9
9
|
def self.extended cap_config
|
10
|
-
|
10
|
+
|
11
11
|
cap_config.instance_eval do
|
12
|
-
|
12
|
+
|
13
13
|
# Executes a rake task on the server.
|
14
14
|
#
|
15
15
|
# Options:
|
@@ -21,56 +21,56 @@ module Picky # :nodoc:
|
|
21
21
|
env = env == false ? '' : "PICKY_ENV=#{env || 'production'}"
|
22
22
|
run "cd #{current_path}; rake #{name} #{env}", options, &block
|
23
23
|
end
|
24
|
-
|
24
|
+
|
25
25
|
end
|
26
|
-
|
26
|
+
|
27
27
|
cap_config.extend Standard
|
28
28
|
cap_config.extend Deploy
|
29
29
|
cap_config.extend Caching
|
30
30
|
cap_config.extend Overrides
|
31
|
-
|
31
|
+
|
32
32
|
end
|
33
33
|
end
|
34
|
-
|
34
|
+
|
35
35
|
# Removes unneeded Rails defaults.
|
36
36
|
#
|
37
37
|
module Overrides
|
38
38
|
def self.extended cap_config
|
39
39
|
cap_config.instance_eval do
|
40
|
-
|
40
|
+
|
41
41
|
namespace :deploy do
|
42
42
|
tasks.delete :check
|
43
43
|
tasks.delete :cold
|
44
44
|
tasks.delete :migrations
|
45
45
|
tasks.delete :migrate
|
46
46
|
tasks.delete :upload
|
47
|
-
|
47
|
+
|
48
48
|
namespace :web do
|
49
49
|
tasks.delete :enable
|
50
50
|
tasks.delete :disable
|
51
51
|
end
|
52
52
|
end
|
53
|
-
|
53
|
+
|
54
54
|
end
|
55
55
|
end
|
56
56
|
end
|
57
|
-
|
57
|
+
|
58
58
|
module Standard
|
59
59
|
def self.extended cap_config
|
60
60
|
cap_config.load 'standard'
|
61
61
|
cap_config.load 'deploy'
|
62
62
|
end
|
63
63
|
end
|
64
|
-
|
64
|
+
|
65
65
|
module Deploy
|
66
|
-
|
66
|
+
|
67
67
|
def self.extended cap_config
|
68
68
|
cap_config.instance_eval do
|
69
|
-
|
69
|
+
|
70
70
|
namespace :deploy do
|
71
71
|
%w(start stop).each do |action|
|
72
72
|
desc "#{action} the Servers"
|
73
|
-
task action.
|
73
|
+
task action.intern, :roles => :app do
|
74
74
|
execute_rake_task "server:#{action}"
|
75
75
|
end
|
76
76
|
end
|
@@ -80,13 +80,13 @@ module Picky # :nodoc:
|
|
80
80
|
execute_rake_task "server:restart", :hosts => server.host
|
81
81
|
end
|
82
82
|
end
|
83
|
-
|
83
|
+
|
84
84
|
desc 'Hot deploy the code'
|
85
85
|
task 'hot', :roles => :app do
|
86
86
|
update
|
87
87
|
execute_rake_task 'server:usr1', :env => false # No env needed.
|
88
88
|
end
|
89
|
-
|
89
|
+
|
90
90
|
desc "Setup a GitHub-style deployment."
|
91
91
|
task :setup, :roles => :app do
|
92
92
|
cmd = "git clone #{repository} #{current_path}-clone-cache &&" +
|
@@ -94,13 +94,13 @@ module Picky # :nodoc:
|
|
94
94
|
"mv #{current_path}-clone-cache #{current_path}"
|
95
95
|
run cmd
|
96
96
|
end
|
97
|
-
|
97
|
+
|
98
98
|
desc "Deploy"
|
99
99
|
task :default, :roles => :app do
|
100
100
|
update
|
101
101
|
restart
|
102
102
|
end
|
103
|
-
|
103
|
+
|
104
104
|
desc "Update the deployed code."
|
105
105
|
task :update_code do # code needs to be updated with all servers
|
106
106
|
puts "updating code to branch #{branch}"
|
@@ -112,12 +112,12 @@ module Picky # :nodoc:
|
|
112
112
|
run cmd
|
113
113
|
symlink
|
114
114
|
end
|
115
|
-
|
115
|
+
|
116
116
|
desc "Cleans up the git checkout"
|
117
117
|
task :cleanup, :roles => :app do
|
118
118
|
run "cd #{current_path} && git gc --aggressive"
|
119
119
|
end
|
120
|
-
|
120
|
+
|
121
121
|
desc "create the symlinks to the shared dirs"
|
122
122
|
task :symlink do
|
123
123
|
set :user, 'deploy'
|
@@ -128,7 +128,7 @@ module Picky # :nodoc:
|
|
128
128
|
# link unicorn.ru
|
129
129
|
run "ln -sf #{shared_path}/unicorn.ru #{current_path}/unicorn.ru"
|
130
130
|
end
|
131
|
-
|
131
|
+
|
132
132
|
namespace :rollback do
|
133
133
|
desc "Rollback to last release."
|
134
134
|
task :default, :roles => :app do
|
@@ -136,20 +136,20 @@ module Picky # :nodoc:
|
|
136
136
|
puts "rolling back to branch #{branch}"
|
137
137
|
deploy.update_code
|
138
138
|
end
|
139
|
-
|
139
|
+
|
140
140
|
task :code, :roles => :app do
|
141
141
|
# implicit
|
142
142
|
end
|
143
143
|
end
|
144
144
|
end
|
145
|
-
|
145
|
+
|
146
146
|
end
|
147
147
|
end
|
148
|
-
|
148
|
+
|
149
149
|
end
|
150
|
-
|
150
|
+
|
151
151
|
module Caching
|
152
|
-
|
152
|
+
|
153
153
|
def self.extended cap_config
|
154
154
|
cap_config.instance_eval do
|
155
155
|
namespace :cache do
|
@@ -180,11 +180,11 @@ module Picky # :nodoc:
|
|
180
180
|
end
|
181
181
|
end
|
182
182
|
end
|
183
|
-
|
183
|
+
|
184
184
|
end
|
185
|
-
|
185
|
+
|
186
186
|
module Statistics
|
187
|
-
|
187
|
+
|
188
188
|
def self.extended cap_config
|
189
189
|
namespace :statistics do
|
190
190
|
desc 'Start the statistics server'
|
@@ -204,8 +204,8 @@ module Picky # :nodoc:
|
|
204
204
|
end
|
205
205
|
end
|
206
206
|
end
|
207
|
-
|
207
|
+
|
208
208
|
end
|
209
|
-
|
209
|
+
|
210
210
|
end
|
211
211
|
end
|
@@ -21,12 +21,10 @@ module Picky
|
|
21
21
|
if @from < 0 && @to < 0
|
22
22
|
def each_subtoken token, &block
|
23
23
|
token.each_subtoken @from - @to - 1, (0..@to), &block
|
24
|
-
# token[0..@to].intern.each_subtoken @from - @to - 1, &block # TODO to_sym
|
25
24
|
end
|
26
25
|
else
|
27
26
|
def each_subtoken token, &block
|
28
27
|
token.each_subtoken @from, (0..@to), &block
|
29
|
-
# token[0..@to].intern.each_subtoken @from, &block # TODO to_sym
|
30
28
|
end
|
31
29
|
end
|
32
30
|
end
|
data/lib/picky/index.rb
CHANGED
@@ -115,7 +115,7 @@ module Picky
|
|
115
115
|
# end
|
116
116
|
#
|
117
117
|
def initialize name
|
118
|
-
@name = name.
|
118
|
+
@name = name.intern
|
119
119
|
@categories = Categories.new
|
120
120
|
|
121
121
|
# Centralized registry.
|
@@ -138,6 +138,21 @@ module Picky
|
|
138
138
|
end
|
139
139
|
end
|
140
140
|
|
141
|
+
# TODO Symbols.
|
142
|
+
#
|
143
|
+
# # API method.
|
144
|
+
# #
|
145
|
+
# # Tells Picky to use Symbols internally.
|
146
|
+
# #
|
147
|
+
# def use_symbols
|
148
|
+
# @symbols = true
|
149
|
+
# end
|
150
|
+
# def use_symbols?
|
151
|
+
# @symbols
|
152
|
+
# end
|
153
|
+
|
154
|
+
# API method.
|
155
|
+
#
|
141
156
|
# Defines a searchable category on the index.
|
142
157
|
#
|
143
158
|
# === Parameters
|
@@ -152,7 +167,7 @@ module Picky
|
|
152
167
|
# * from: Take the data from the data category with this name. Example: You have a source Sources::CSV.new(:title, file:'some_file.csv') but you want the category to be called differently. The you use from: define_category(:similar_title, :from => :title).
|
153
168
|
#
|
154
169
|
def category category_name, options = {}
|
155
|
-
new_category = Category.new category_name.
|
170
|
+
new_category = Category.new category_name.intern, self, options
|
156
171
|
categories << new_category
|
157
172
|
|
158
173
|
new_category = yield new_category if block_given?
|
@@ -222,17 +237,19 @@ module Picky
|
|
222
237
|
#
|
223
238
|
# === Options
|
224
239
|
# * precision: Default is 1 (20% error margin, very fast), up to 5 (5% error margin, slower) makes sense.
|
240
|
+
# * anchor: Where to anchor the geo grid.
|
225
241
|
# * ... all options of #define_category.
|
226
242
|
#
|
227
243
|
def ranged_category category_name, range, options = {}
|
228
|
-
precision = options
|
244
|
+
precision = options.delete(:precision) || 1
|
245
|
+
anchor = options.delete(:anchor) || 0.0
|
229
246
|
|
230
247
|
# Note: :key_format => :to_f ?
|
231
248
|
#
|
232
249
|
options = { partial: Partial::None.new }.merge options
|
233
250
|
|
234
251
|
define_category category_name, options do |category|
|
235
|
-
Wrappers::Category::Location.wrap category, range, precision
|
252
|
+
Wrappers::Category::Location.wrap category, range, precision, anchor
|
236
253
|
end
|
237
254
|
end
|
238
255
|
alias define_ranged_category ranged_category
|
@@ -312,7 +329,7 @@ INDEX
|
|
312
329
|
# Identifier used for technical output.
|
313
330
|
#
|
314
331
|
def identifier
|
315
|
-
|
332
|
+
name
|
316
333
|
end
|
317
334
|
|
318
335
|
#
|
data/lib/picky/index_indexing.rb
CHANGED
@@ -93,7 +93,7 @@ module Picky
|
|
93
93
|
#
|
94
94
|
def source some_source = nil, &block
|
95
95
|
some_source ||= block
|
96
|
-
some_source ? define_source(some_source) : (@source && extract_source ||
|
96
|
+
some_source ? define_source(some_source) : (@source && extract_source || warn_no_source)
|
97
97
|
end
|
98
98
|
# Extract the actual source if it is wrapped in a time
|
99
99
|
# capsule, i.e. a block/lambda.
|
@@ -107,20 +107,8 @@ module Picky
|
|
107
107
|
check_source source
|
108
108
|
@source = source
|
109
109
|
end
|
110
|
-
def
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
No source given for index #{name}. An index needs a source.
|
115
|
-
Example:
|
116
|
-
Index.new(:with_source) do
|
117
|
-
source Sources::CSV.new(:title, file: 'data/books.csv')
|
118
|
-
category :title
|
119
|
-
category :author
|
120
|
-
end
|
121
|
-
|
122
|
-
NO_SOURCE
|
123
|
-
)
|
110
|
+
def warn_no_source
|
111
|
+
warn "No source given for index #{name}."
|
124
112
|
end
|
125
113
|
def check_source source # :nodoc:
|
126
114
|
raise ArgumentError.new(<<-SOURCE
|
data/lib/picky/indexers/base.rb
CHANGED
@@ -19,9 +19,13 @@ module Picky
|
|
19
19
|
# Starts the indexing process.
|
20
20
|
#
|
21
21
|
def index categories
|
22
|
-
|
23
|
-
|
24
|
-
|
22
|
+
process categories do |file|
|
23
|
+
notify_finished file
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
def notify_finished file
|
28
|
+
timed_exclaim %Q{"#{@index_or_category.identifier}": Tokenized -> #{file.path.gsub("#{PICKY_ROOT}/", '')}.}
|
25
29
|
end
|
26
30
|
|
27
31
|
end
|
@@ -60,7 +60,7 @@ module Picky
|
|
60
60
|
end
|
61
61
|
flush combined
|
62
62
|
combined.each do |_, _, file, _|
|
63
|
-
|
63
|
+
yield file
|
64
64
|
file.close
|
65
65
|
end
|
66
66
|
end
|
@@ -73,15 +73,6 @@ module Picky
|
|
73
73
|
end
|
74
74
|
end
|
75
75
|
|
76
|
-
#
|
77
|
-
#
|
78
|
-
def start_indexing_message # :nodoc:
|
79
|
-
timed_exclaim %Q{"#{@index_or_category.identifier}": Starting parallel data preparation.}
|
80
|
-
end
|
81
|
-
def finish_indexing_message # :nodoc:
|
82
|
-
timed_exclaim %Q{"#{@index_or_category.identifier}": Finished parallel data preparation.}
|
83
|
-
end
|
84
|
-
|
85
76
|
end
|
86
77
|
|
87
78
|
end
|
@@ -36,7 +36,7 @@ module Picky
|
|
36
36
|
file.write(result.join) && result.clear if result.size > 100_000
|
37
37
|
end
|
38
38
|
|
39
|
-
|
39
|
+
yield file
|
40
40
|
|
41
41
|
file.write result.join
|
42
42
|
end
|
@@ -45,15 +45,6 @@ module Picky
|
|
45
45
|
|
46
46
|
end
|
47
47
|
|
48
|
-
#
|
49
|
-
#
|
50
|
-
def start_indexing_message # :nodoc:
|
51
|
-
timed_exclaim %Q{"#{@index_or_category.identifier}": Starting serial data preparation.}
|
52
|
-
end
|
53
|
-
def finish_indexing_message # :nodoc:
|
54
|
-
timed_exclaim %Q{"#{@index_or_category.identifier}": Finished serial data preparation.}
|
55
|
-
end
|
56
|
-
|
57
48
|
end
|
58
49
|
end
|
59
50
|
|
data/lib/picky/indexes.rb
CHANGED
data/lib/picky/loader.rb
CHANGED
@@ -143,8 +143,8 @@ module Picky
|
|
143
143
|
load_relative 'wrappers/bundle/location'
|
144
144
|
load_relative 'wrappers/bundle/exact_partial'
|
145
145
|
|
146
|
-
load_relative 'wrappers/sources/base'
|
147
|
-
load_relative 'wrappers/sources/location'
|
146
|
+
# load_relative 'wrappers/sources/base'
|
147
|
+
# load_relative 'wrappers/sources/location'
|
148
148
|
|
149
149
|
# Tokens.
|
150
150
|
#
|
@@ -188,10 +188,6 @@ module Picky
|
|
188
188
|
#
|
189
189
|
load_relative 'rack/harakiri'
|
190
190
|
|
191
|
-
# Errors.
|
192
|
-
#
|
193
|
-
load_relative 'no_source_specified_exception'
|
194
|
-
|
195
191
|
# Load analyzer.
|
196
192
|
#
|
197
193
|
load_relative 'analyzer'
|
@@ -20,7 +20,7 @@ module Picky
|
|
20
20
|
#
|
21
21
|
def add category
|
22
22
|
category.qualifiers.each do |qualifier|
|
23
|
-
sym_qualifier = qualifier.
|
23
|
+
sym_qualifier = qualifier.intern
|
24
24
|
warn %Q{Warning: Qualifier "#{qualifier}" already mapped to category #{mapping[sym_qualifier].identifier} (ambiguous qualifier mapping).} if mapping.has_key? sym_qualifier
|
25
25
|
mapping[sym_qualifier] = category
|
26
26
|
end
|
@@ -33,7 +33,7 @@ module Picky
|
|
33
33
|
def map qualifier
|
34
34
|
return nil if qualifier.empty?
|
35
35
|
|
36
|
-
@mapping[qualifier.
|
36
|
+
@mapping[qualifier.intern]
|
37
37
|
end
|
38
38
|
|
39
39
|
end
|
data/lib/picky/query/token.rb
CHANGED
@@ -37,13 +37,12 @@ module Picky
|
|
37
37
|
partialize # TODO Should this operate on the original?
|
38
38
|
similarize # TODO Should this operate on the original?
|
39
39
|
remove_illegals # TODO Remove?
|
40
|
-
symbolize # TODO to_sym
|
41
40
|
self
|
42
41
|
end
|
43
42
|
|
44
43
|
#
|
45
44
|
#
|
46
|
-
def symbolize
|
45
|
+
def symbolize!
|
47
46
|
@text = @text.to_sym
|
48
47
|
end
|
49
48
|
|
data/lib/picky/query/tokens.rb
CHANGED
data/lib/picky/search.rb
CHANGED
@@ -175,6 +175,7 @@ module Picky
|
|
175
175
|
def tokenized text
|
176
176
|
tokens, originals = tokenizer.tokenize text
|
177
177
|
tokens = Query::Tokens.processed tokens, originals || tokens, @ignore_unassigned
|
178
|
+
# tokens.symbolize # TODO Symbols.
|
178
179
|
tokens.partialize_last # Note: In the standard Picky search, the last token is always partial.
|
179
180
|
tokens
|
180
181
|
end
|
data/lib/picky/sources/couch.rb
CHANGED
@@ -32,7 +32,7 @@ module Picky
|
|
32
32
|
@db = RestClient::Resource.new options.delete(:url), options
|
33
33
|
|
34
34
|
key_format = options.delete :key_format
|
35
|
-
@key_format = key_format && key_format.
|
35
|
+
@key_format = key_format && key_format.intern || :to_sym
|
36
36
|
end
|
37
37
|
|
38
38
|
def to_s
|
data/lib/picky/sources/csv.rb
CHANGED
@@ -42,7 +42,7 @@ module Picky
|
|
42
42
|
@file_name = @csv_options.delete(:file) || raise_no_file_given(category_names)
|
43
43
|
|
44
44
|
key_format = options.delete :key_format
|
45
|
-
@key_format = key_format && key_format.
|
45
|
+
@key_format = key_format && key_format.intern || :to_i
|
46
46
|
end
|
47
47
|
|
48
48
|
def to_s
|
data/lib/picky/sources/mongo.rb
CHANGED
@@ -37,7 +37,7 @@ module Picky
|
|
37
37
|
|
38
38
|
@db = RestClient::Resource.new options.delete(:url), options
|
39
39
|
@database = options.delete(:db)
|
40
|
-
@key_format = options[:key_format] && options[:key_format].
|
40
|
+
@key_format = options[:key_format] && options[:key_format].intern || :to_sym
|
41
41
|
end
|
42
42
|
|
43
43
|
# Tries to require the rest_client gem.
|
@@ -18,22 +18,22 @@ module Picky
|
|
18
18
|
# API.
|
19
19
|
#
|
20
20
|
# By default, a calculation does not
|
21
|
-
#
|
21
|
+
# calculate anything.
|
22
22
|
#
|
23
|
-
def
|
23
|
+
def calculate float
|
24
24
|
float
|
25
25
|
end
|
26
26
|
|
27
|
+
# TODO Symbols.
|
27
28
|
#
|
28
|
-
|
29
|
-
|
30
|
-
@bundle.ids recalculate(float_as_sym.to_s.to_f).to_s.to_sym
|
29
|
+
def ids float_str
|
30
|
+
@bundle.ids calculate(float_str.to_f).to_s
|
31
31
|
end
|
32
32
|
|
33
|
+
# TODO Symbols.
|
33
34
|
#
|
34
|
-
|
35
|
-
|
36
|
-
@bundle.weight recalculate(float_as_sym.to_s.to_f).to_s.to_sym
|
35
|
+
def weight float_str
|
36
|
+
@bundle.weight calculate(float_str.to_f).to_s
|
37
37
|
end
|
38
38
|
|
39
39
|
end
|
@@ -11,32 +11,49 @@ module Picky
|
|
11
11
|
def initialize bundle, options = {}
|
12
12
|
super bundle
|
13
13
|
|
14
|
+
user_grid = options[:grid] || raise("Gridsize needs to be given for location #{bundle.identifier}.")
|
15
|
+
anchor = options[:anchor] || 0.0
|
14
16
|
precision = options[:precision] || 1
|
15
|
-
user_grid = options[:grid] || raise("Gridsize needs to be given for location #{bundle.identifier}.")
|
16
17
|
|
17
|
-
@calculation = Calculations::Location.new user_grid, precision
|
18
|
+
@calculation = Calculations::Location.new user_grid, anchor, precision
|
18
19
|
end
|
19
20
|
|
20
21
|
#
|
21
22
|
#
|
22
|
-
def
|
23
|
-
@calculation.
|
23
|
+
def calculate float
|
24
|
+
@calculation.calculate float
|
24
25
|
end
|
25
26
|
|
27
|
+
# Recalculates the added location.
|
26
28
|
#
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
bundle.load
|
32
|
-
minimum = bundle[:location_minimum] && bundle[:location_minimum].to_f || raise("Configuration :location_minimum for #{bundle.identifier} missing. Did you run rake index already?")
|
33
|
-
@calculation.minimum = minimum
|
29
|
+
def add id, location, where = :unshift
|
30
|
+
@calculation.calculated_range(location.to_s.to_f).each do |new_location|
|
31
|
+
bundle.add id, new_location.to_s, where
|
32
|
+
end
|
34
33
|
end
|
35
34
|
|
36
35
|
# Do not generate a partial.
|
37
36
|
#
|
38
|
-
def
|
39
|
-
# Nothing
|
37
|
+
def add_partialized does_not, matter, at_all
|
38
|
+
# Nothing
|
39
|
+
end
|
40
|
+
|
41
|
+
# Save the config, then dump normally.
|
42
|
+
#
|
43
|
+
def dump
|
44
|
+
bundle[:location_anchor] = @calculation.anchor
|
45
|
+
|
46
|
+
bundle.dump
|
47
|
+
end
|
48
|
+
|
49
|
+
# Load first the bundle, then extract the config.
|
50
|
+
#
|
51
|
+
def load
|
52
|
+
bundle.load
|
53
|
+
|
54
|
+
# TODO Symbols (of the location_anchor!!!).
|
55
|
+
#
|
56
|
+
@calculation.anchor = bundle['location_anchor'] && bundle['location_anchor'].to_f || raise("Configuration 'location_anchor' for #{bundle.identifier} missing. Did you run rake index already?")
|
40
57
|
end
|
41
58
|
|
42
59
|
end
|