CloudSesame 0.6.8 → 0.7.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.editorconfig +12 -0
- data/.gitignore +1 -1
- data/Gemfile.lock +13 -13
- data/Guardfile +1 -0
- data/cloud_sesame.gemspec +2 -2
- data/coverage/.last_run.json +1 -1
- data/coverage/.resultset.json +679 -591
- data/lib/cloud_sesame/config/credential.rb +6 -6
- data/lib/cloud_sesame/context.rb +0 -5
- data/lib/cloud_sesame/domain/base.rb +147 -128
- data/lib/cloud_sesame/domain/client.rb +25 -25
- data/lib/cloud_sesame/domain/client_module/caching/base.rb +19 -23
- data/lib/cloud_sesame/domain/client_module/caching/no_cache.rb +11 -11
- data/lib/cloud_sesame/domain/client_module/caching/rails_cache.rb +32 -28
- data/lib/cloud_sesame/domain/client_module/caching.rb +19 -28
- data/lib/cloud_sesame/domain/client_module/retry.rb +6 -6
- data/lib/cloud_sesame/domain/config.rb +6 -6
- data/lib/cloud_sesame/query/ast/abstract/multi_expression_operator.rb +37 -0
- data/lib/cloud_sesame/query/ast/abstract/operator.rb +27 -0
- data/lib/cloud_sesame/query/ast/abstract/single_expression_operator.rb +39 -0
- data/lib/cloud_sesame/query/ast/abstract/value.rb +88 -0
- data/lib/cloud_sesame/query/ast/and.rb +1 -1
- data/lib/cloud_sesame/query/ast/date_value.rb +19 -3
- data/lib/cloud_sesame/query/ast/literal.rb +13 -28
- data/lib/cloud_sesame/query/ast/near.rb +4 -4
- data/lib/cloud_sesame/query/ast/not.rb +6 -7
- data/lib/cloud_sesame/query/ast/numeric_value.rb +20 -12
- data/lib/cloud_sesame/query/ast/or.rb +1 -1
- data/lib/cloud_sesame/query/ast/phrase.rb +1 -1
- data/lib/cloud_sesame/query/ast/prefix.rb +1 -1
- data/lib/cloud_sesame/query/ast/range_value.rb +40 -39
- data/lib/cloud_sesame/query/ast/root.rb +2 -6
- data/lib/cloud_sesame/query/ast/string_value.rb +26 -0
- data/lib/cloud_sesame/query/ast/term.rb +1 -1
- data/lib/cloud_sesame/query/ast/value.rb +25 -54
- data/lib/cloud_sesame/query/builder.rb +83 -54
- data/lib/cloud_sesame/query/domain/block.rb +3 -1
- data/lib/cloud_sesame/query/dsl/applied_filter_query.rb +14 -23
- data/lib/cloud_sesame/query/dsl/field_accessors.rb +25 -22
- data/lib/cloud_sesame/query/dsl/field_array_methods.rb +1 -1
- data/lib/cloud_sesame/query/dsl/inspect_method.rb +31 -0
- data/lib/cloud_sesame/query/dsl/sort_methods.rb +5 -4
- data/lib/cloud_sesame/query/node/abstract.rb +1 -2
- data/lib/cloud_sesame/query/node/facet.rb +1 -5
- data/lib/cloud_sesame/query/node/filter_query.rb +15 -2
- data/lib/cloud_sesame/query/node/fuzziness.rb +4 -3
- data/lib/cloud_sesame/query/node/page.rb +2 -2
- data/lib/cloud_sesame/query/node/query.rb +4 -17
- data/lib/cloud_sesame/query/node/query_options.rb +6 -16
- data/lib/cloud_sesame/query/node/query_options_field.rb +3 -1
- data/lib/cloud_sesame/query/node/query_parser.rb +8 -10
- data/lib/cloud_sesame/query/node/request.rb +57 -31
- data/lib/cloud_sesame/query/node/sort.rb +25 -11
- data/lib/cloud_sesame.rb +15 -12
- data/lib/{abstract_object.rb → services/abstract_object.rb} +0 -0
- data/lib/services/class_specific.rb +44 -0
- data/lib/services/lazy_object.rb +19 -0
- data/spec/cloud_sesame/domain/base_spec.rb +26 -11
- data/spec/cloud_sesame/domain/client_module/caching/base_spec.rb +2 -1
- data/spec/cloud_sesame/domain/client_module/caching/no_cache_spec.rb +2 -3
- data/spec/cloud_sesame/domain/client_module/caching/rails_cache_spec.rb +6 -6
- data/spec/cloud_sesame/domain/client_module/caching_spec.rb +33 -32
- data/spec/cloud_sesame/query/ast/abstract/multi_expression_operator_spec.rb +67 -0
- data/spec/cloud_sesame/query/ast/abstract/operator_spec.rb +29 -0
- data/spec/cloud_sesame/query/ast/abstract/single_expression_operator_spec.rb +70 -0
- data/spec/cloud_sesame/query/ast/abstract/value_spec.rb +118 -0
- data/spec/cloud_sesame/query/ast/and_spec.rb +1 -1
- data/spec/cloud_sesame/query/ast/or_spec.rb +1 -1
- data/spec/cloud_sesame/query/ast/range_value_spec.rb +5 -11
- data/spec/cloud_sesame/query/builder_spec.rb +10 -4
- data/spec/cloud_sesame/query/domain/block_spec.rb +15 -8
- data/spec/cloud_sesame/query/dsl/{block_methods_spec.rb → block_styled_operators_spec.rb} +0 -0
- data/spec/cloud_sesame/query/dsl/field_accessors_spec.rb +88 -50
- data/spec/cloud_sesame/query/dsl/field_array_methods_spec.rb +0 -2
- data/spec/cloud_sesame/query/node/facet_spec.rb +1 -15
- data/spec/cloud_sesame/query/node/filter_query_spec.rb +16 -2
- data/spec/cloud_sesame/query/node/page_spec.rb +3 -2
- data/spec/cloud_sesame/query/node/query_options_spec.rb +1 -1
- data/spec/cloud_sesame/query/node/query_parser_spec.rb +1 -7
- data/spec/cloud_sesame/query/node/query_spec.rb +10 -28
- data/spec/cloud_sesame/query/node/sort_spec.rb +19 -28
- data/spec/cloud_sesame_spec.rb +2 -156
- data/spec/helpers/benchmark_helper.rb +12 -0
- data/spec/integration/filter_query_spec.rb +0 -0
- data/spec/profiling_spec.rb +155 -0
- data/spec/{abstract_object_spec.rb → services/abstract_object_spec.rb} +0 -0
- data/spec/services/class_specific_spec.rb +135 -0
- data/spec/spec_helper.rb +3 -0
- metadata +32 -22
- data/lib/active_support/core_ext/object/deep_dup.rb +0 -53
- data/lib/active_support/core_ext/object/duplicable.rb +0 -98
- data/lib/cloud_sesame/query/ast/multi_expression_operator.rb +0 -35
- data/lib/cloud_sesame/query/ast/operator.rb +0 -25
- data/lib/cloud_sesame/query/ast/single_expression_operator.rb +0 -35
- data/lib/cloud_sesame/query/scope.rb +0 -21
- data/profiler.rb +0 -91
- data/spec/cloud_sesame/query/ast/multi_expression_operator_spec.rb +0 -76
- data/spec/cloud_sesame/query/ast/operator_spec.rb +0 -29
- data/spec/cloud_sesame/query/ast/single_expression_operator_spec.rb +0 -78
- data/spec/context_spec.rb +0 -17
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: CloudSesame
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.7.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Scott Chu
|
@@ -16,7 +16,7 @@ authors:
|
|
16
16
|
autorequire:
|
17
17
|
bindir: bin
|
18
18
|
cert_chain: []
|
19
|
-
date: 2016-
|
19
|
+
date: 2016-03-13 00:00:00.000000000 Z
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
22
22
|
name: aws-sdk
|
@@ -136,6 +136,7 @@ executables: []
|
|
136
136
|
extensions: []
|
137
137
|
extra_rdoc_files: []
|
138
138
|
files:
|
139
|
+
- ".editorconfig"
|
139
140
|
- ".gitignore"
|
140
141
|
- ".rspec"
|
141
142
|
- ".rubocop.yml"
|
@@ -148,9 +149,6 @@ files:
|
|
148
149
|
- coverage/.last_run.json
|
149
150
|
- coverage/.resultset.json
|
150
151
|
- coverage/.resultset.json.lock
|
151
|
-
- lib/abstract_object.rb
|
152
|
-
- lib/active_support/core_ext/object/deep_dup.rb
|
153
|
-
- lib/active_support/core_ext/object/duplicable.rb
|
154
152
|
- lib/cloud_sesame.rb
|
155
153
|
- lib/cloud_sesame/config/credential.rb
|
156
154
|
- lib/cloud_sesame/context.rb
|
@@ -163,21 +161,23 @@ files:
|
|
163
161
|
- lib/cloud_sesame/domain/client_module/retry.rb
|
164
162
|
- lib/cloud_sesame/domain/config.rb
|
165
163
|
- lib/cloud_sesame/domain/error/caching.rb
|
164
|
+
- lib/cloud_sesame/query/ast/abstract/multi_expression_operator.rb
|
165
|
+
- lib/cloud_sesame/query/ast/abstract/operator.rb
|
166
|
+
- lib/cloud_sesame/query/ast/abstract/single_expression_operator.rb
|
167
|
+
- lib/cloud_sesame/query/ast/abstract/value.rb
|
166
168
|
- lib/cloud_sesame/query/ast/and.rb
|
167
169
|
- lib/cloud_sesame/query/ast/date_value.rb
|
168
170
|
- lib/cloud_sesame/query/ast/field_array.rb
|
169
171
|
- lib/cloud_sesame/query/ast/literal.rb
|
170
|
-
- lib/cloud_sesame/query/ast/multi_expression_operator.rb
|
171
172
|
- lib/cloud_sesame/query/ast/near.rb
|
172
173
|
- lib/cloud_sesame/query/ast/not.rb
|
173
174
|
- lib/cloud_sesame/query/ast/numeric_value.rb
|
174
|
-
- lib/cloud_sesame/query/ast/operator.rb
|
175
175
|
- lib/cloud_sesame/query/ast/or.rb
|
176
176
|
- lib/cloud_sesame/query/ast/phrase.rb
|
177
177
|
- lib/cloud_sesame/query/ast/prefix.rb
|
178
178
|
- lib/cloud_sesame/query/ast/range_value.rb
|
179
179
|
- lib/cloud_sesame/query/ast/root.rb
|
180
|
-
- lib/cloud_sesame/query/ast/
|
180
|
+
- lib/cloud_sesame/query/ast/string_value.rb
|
181
181
|
- lib/cloud_sesame/query/ast/term.rb
|
182
182
|
- lib/cloud_sesame/query/ast/value.rb
|
183
183
|
- lib/cloud_sesame/query/builder.rb
|
@@ -189,6 +189,7 @@ files:
|
|
189
189
|
- lib/cloud_sesame/query/dsl/block_styled_operators.rb
|
190
190
|
- lib/cloud_sesame/query/dsl/field_accessors.rb
|
191
191
|
- lib/cloud_sesame/query/dsl/field_array_methods.rb
|
192
|
+
- lib/cloud_sesame/query/dsl/inspect_method.rb
|
192
193
|
- lib/cloud_sesame/query/dsl/operators.rb
|
193
194
|
- lib/cloud_sesame/query/dsl/page_methods.rb
|
194
195
|
- lib/cloud_sesame/query/dsl/query_methods.rb
|
@@ -214,9 +215,9 @@ files:
|
|
214
215
|
- lib/cloud_sesame/query/node/return.rb
|
215
216
|
- lib/cloud_sesame/query/node/sloppiness.rb
|
216
217
|
- lib/cloud_sesame/query/node/sort.rb
|
217
|
-
- lib/
|
218
|
-
-
|
219
|
-
-
|
218
|
+
- lib/services/abstract_object.rb
|
219
|
+
- lib/services/class_specific.rb
|
220
|
+
- lib/services/lazy_object.rb
|
220
221
|
- spec/cloud_sesame/config/credential_spec.rb
|
221
222
|
- spec/cloud_sesame/domain/base_spec.rb
|
222
223
|
- spec/cloud_sesame/domain/client_module/caching/base_spec.rb
|
@@ -224,17 +225,18 @@ files:
|
|
224
225
|
- spec/cloud_sesame/domain/client_module/caching/rails_cache_spec.rb
|
225
226
|
- spec/cloud_sesame/domain/client_module/caching_spec.rb
|
226
227
|
- spec/cloud_sesame/domain/client_spec.rb
|
228
|
+
- spec/cloud_sesame/query/ast/abstract/multi_expression_operator_spec.rb
|
229
|
+
- spec/cloud_sesame/query/ast/abstract/operator_spec.rb
|
230
|
+
- spec/cloud_sesame/query/ast/abstract/single_expression_operator_spec.rb
|
231
|
+
- spec/cloud_sesame/query/ast/abstract/value_spec.rb
|
227
232
|
- spec/cloud_sesame/query/ast/and_spec.rb
|
228
|
-
- spec/cloud_sesame/query/ast/multi_expression_operator_spec.rb
|
229
233
|
- spec/cloud_sesame/query/ast/numeric_value_spec.rb
|
230
|
-
- spec/cloud_sesame/query/ast/operator_spec.rb
|
231
234
|
- spec/cloud_sesame/query/ast/or_spec.rb
|
232
235
|
- spec/cloud_sesame/query/ast/range_value_spec.rb
|
233
236
|
- spec/cloud_sesame/query/ast/root_spec.rb
|
234
|
-
- spec/cloud_sesame/query/ast/single_expression_operator_spec.rb
|
235
237
|
- spec/cloud_sesame/query/builder_spec.rb
|
236
238
|
- spec/cloud_sesame/query/domain/block_spec.rb
|
237
|
-
- spec/cloud_sesame/query/dsl/
|
239
|
+
- spec/cloud_sesame/query/dsl/block_styled_operators_spec.rb
|
238
240
|
- spec/cloud_sesame/query/dsl/field_accessors_spec.rb
|
239
241
|
- spec/cloud_sesame/query/dsl/field_array_methods_spec.rb
|
240
242
|
- spec/cloud_sesame/query/node/abstract_spec.rb
|
@@ -247,7 +249,11 @@ files:
|
|
247
249
|
- spec/cloud_sesame/query/node/query_spec.rb
|
248
250
|
- spec/cloud_sesame/query/node/sort_spec.rb
|
249
251
|
- spec/cloud_sesame_spec.rb
|
250
|
-
- spec/
|
252
|
+
- spec/helpers/benchmark_helper.rb
|
253
|
+
- spec/integration/filter_query_spec.rb
|
254
|
+
- spec/profiling_spec.rb
|
255
|
+
- spec/services/abstract_object_spec.rb
|
256
|
+
- spec/services/class_specific_spec.rb
|
251
257
|
- spec/spec_helper.rb
|
252
258
|
homepage: https://github.com/47colborne/cloud-sesame
|
253
259
|
licenses:
|
@@ -274,7 +280,6 @@ signing_key:
|
|
274
280
|
specification_version: 4
|
275
281
|
summary: AWS CloudSearch Query DSL
|
276
282
|
test_files:
|
277
|
-
- spec/abstract_object_spec.rb
|
278
283
|
- spec/cloud_sesame/config/credential_spec.rb
|
279
284
|
- spec/cloud_sesame/domain/base_spec.rb
|
280
285
|
- spec/cloud_sesame/domain/client_module/caching/base_spec.rb
|
@@ -282,17 +287,18 @@ test_files:
|
|
282
287
|
- spec/cloud_sesame/domain/client_module/caching/rails_cache_spec.rb
|
283
288
|
- spec/cloud_sesame/domain/client_module/caching_spec.rb
|
284
289
|
- spec/cloud_sesame/domain/client_spec.rb
|
290
|
+
- spec/cloud_sesame/query/ast/abstract/multi_expression_operator_spec.rb
|
291
|
+
- spec/cloud_sesame/query/ast/abstract/operator_spec.rb
|
292
|
+
- spec/cloud_sesame/query/ast/abstract/single_expression_operator_spec.rb
|
293
|
+
- spec/cloud_sesame/query/ast/abstract/value_spec.rb
|
285
294
|
- spec/cloud_sesame/query/ast/and_spec.rb
|
286
|
-
- spec/cloud_sesame/query/ast/multi_expression_operator_spec.rb
|
287
295
|
- spec/cloud_sesame/query/ast/numeric_value_spec.rb
|
288
|
-
- spec/cloud_sesame/query/ast/operator_spec.rb
|
289
296
|
- spec/cloud_sesame/query/ast/or_spec.rb
|
290
297
|
- spec/cloud_sesame/query/ast/range_value_spec.rb
|
291
298
|
- spec/cloud_sesame/query/ast/root_spec.rb
|
292
|
-
- spec/cloud_sesame/query/ast/single_expression_operator_spec.rb
|
293
299
|
- spec/cloud_sesame/query/builder_spec.rb
|
294
300
|
- spec/cloud_sesame/query/domain/block_spec.rb
|
295
|
-
- spec/cloud_sesame/query/dsl/
|
301
|
+
- spec/cloud_sesame/query/dsl/block_styled_operators_spec.rb
|
296
302
|
- spec/cloud_sesame/query/dsl/field_accessors_spec.rb
|
297
303
|
- spec/cloud_sesame/query/dsl/field_array_methods_spec.rb
|
298
304
|
- spec/cloud_sesame/query/node/abstract_spec.rb
|
@@ -305,5 +311,9 @@ test_files:
|
|
305
311
|
- spec/cloud_sesame/query/node/query_spec.rb
|
306
312
|
- spec/cloud_sesame/query/node/sort_spec.rb
|
307
313
|
- spec/cloud_sesame_spec.rb
|
308
|
-
- spec/
|
314
|
+
- spec/helpers/benchmark_helper.rb
|
315
|
+
- spec/integration/filter_query_spec.rb
|
316
|
+
- spec/profiling_spec.rb
|
317
|
+
- spec/services/abstract_object_spec.rb
|
318
|
+
- spec/services/class_specific_spec.rb
|
309
319
|
- spec/spec_helper.rb
|
@@ -1,53 +0,0 @@
|
|
1
|
-
require 'active_support/core_ext/object/duplicable'
|
2
|
-
|
3
|
-
class Object
|
4
|
-
# Returns a deep copy of object if it's duplicable. If it's
|
5
|
-
# not duplicable, returns +self+.
|
6
|
-
#
|
7
|
-
# object = Object.new
|
8
|
-
# dup = object.deep_dup
|
9
|
-
# dup.instance_variable_set(:@a, 1)
|
10
|
-
#
|
11
|
-
# object.instance_variable_defined?(:@a) # => false
|
12
|
-
# dup.instance_variable_defined?(:@a) # => true
|
13
|
-
def deep_dup
|
14
|
-
duplicable? ? dup : self
|
15
|
-
end
|
16
|
-
end
|
17
|
-
|
18
|
-
class Array
|
19
|
-
# Returns a deep copy of array.
|
20
|
-
#
|
21
|
-
# array = [1, [2, 3]]
|
22
|
-
# dup = array.deep_dup
|
23
|
-
# dup[1][2] = 4
|
24
|
-
#
|
25
|
-
# array[1][2] # => nil
|
26
|
-
# dup[1][2] # => 4
|
27
|
-
def deep_dup
|
28
|
-
map(&:deep_dup)
|
29
|
-
end
|
30
|
-
end
|
31
|
-
|
32
|
-
class Hash
|
33
|
-
# Returns a deep copy of hash.
|
34
|
-
#
|
35
|
-
# hash = { a: { b: 'b' } }
|
36
|
-
# dup = hash.deep_dup
|
37
|
-
# dup[:a][:c] = 'c'
|
38
|
-
#
|
39
|
-
# hash[:a][:c] # => nil
|
40
|
-
# dup[:a][:c] # => "c"
|
41
|
-
def deep_dup
|
42
|
-
hash = dup
|
43
|
-
each_pair do |key, value|
|
44
|
-
if key.frozen? && ::String === key
|
45
|
-
hash[key] = value.deep_dup
|
46
|
-
else
|
47
|
-
hash.delete(key)
|
48
|
-
hash[key.deep_dup] = value.deep_dup
|
49
|
-
end
|
50
|
-
end
|
51
|
-
hash
|
52
|
-
end
|
53
|
-
end
|
@@ -1,98 +0,0 @@
|
|
1
|
-
#--
|
2
|
-
# Most objects are cloneable, but not all. For example you can't dup +nil+:
|
3
|
-
#
|
4
|
-
# nil.dup # => TypeError: can't dup NilClass
|
5
|
-
#
|
6
|
-
# Classes may signal their instances are not duplicable removing +dup+/+clone+
|
7
|
-
# or raising exceptions from them. So, to dup an arbitrary object you normally
|
8
|
-
# use an optimistic approach and are ready to catch an exception, say:
|
9
|
-
#
|
10
|
-
# arbitrary_object.dup rescue object
|
11
|
-
#
|
12
|
-
# Rails dups objects in a few critical spots where they are not that arbitrary.
|
13
|
-
# That rescue is very expensive (like 40 times slower than a predicate), and it
|
14
|
-
# is often triggered.
|
15
|
-
#
|
16
|
-
# That's why we hardcode the following cases and check duplicable? instead of
|
17
|
-
# using that rescue idiom.
|
18
|
-
#++
|
19
|
-
class Object
|
20
|
-
# Can you safely dup this object?
|
21
|
-
#
|
22
|
-
# False for +nil+, +false+, +true+, symbol, number, method objects;
|
23
|
-
# true otherwise.
|
24
|
-
def duplicable?
|
25
|
-
true
|
26
|
-
end
|
27
|
-
end
|
28
|
-
|
29
|
-
class NilClass
|
30
|
-
# +nil+ is not duplicable:
|
31
|
-
#
|
32
|
-
# nil.duplicable? # => false
|
33
|
-
# nil.dup # => TypeError: can't dup NilClass
|
34
|
-
def duplicable?
|
35
|
-
false
|
36
|
-
end
|
37
|
-
end
|
38
|
-
|
39
|
-
class FalseClass
|
40
|
-
# +false+ is not duplicable:
|
41
|
-
#
|
42
|
-
# false.duplicable? # => false
|
43
|
-
# false.dup # => TypeError: can't dup FalseClass
|
44
|
-
def duplicable?
|
45
|
-
false
|
46
|
-
end
|
47
|
-
end
|
48
|
-
|
49
|
-
class TrueClass
|
50
|
-
# +true+ is not duplicable:
|
51
|
-
#
|
52
|
-
# true.duplicable? # => false
|
53
|
-
# true.dup # => TypeError: can't dup TrueClass
|
54
|
-
def duplicable?
|
55
|
-
false
|
56
|
-
end
|
57
|
-
end
|
58
|
-
|
59
|
-
class Symbol
|
60
|
-
# Symbols are not duplicable:
|
61
|
-
#
|
62
|
-
# :my_symbol.duplicable? # => false
|
63
|
-
# :my_symbol.dup # => TypeError: can't dup Symbol
|
64
|
-
def duplicable?
|
65
|
-
false
|
66
|
-
end
|
67
|
-
end
|
68
|
-
|
69
|
-
class Numeric
|
70
|
-
# Numbers are not duplicable:
|
71
|
-
#
|
72
|
-
# 3.duplicable? # => false
|
73
|
-
# 3.dup # => TypeError: can't dup Fixnum
|
74
|
-
def duplicable?
|
75
|
-
false
|
76
|
-
end
|
77
|
-
end
|
78
|
-
|
79
|
-
require 'bigdecimal'
|
80
|
-
class BigDecimal
|
81
|
-
# BigDecimals are duplicable:
|
82
|
-
#
|
83
|
-
# BigDecimal.new("1.2").duplicable? # => true
|
84
|
-
# BigDecimal.new("1.2").dup # => #<BigDecimal:...,'0.12E1',18(18)>
|
85
|
-
def duplicable?
|
86
|
-
true
|
87
|
-
end
|
88
|
-
end
|
89
|
-
|
90
|
-
class Method
|
91
|
-
# Methods are not duplicable:
|
92
|
-
#
|
93
|
-
# method(:puts).duplicable? # => false
|
94
|
-
# method(:puts).dup # => TypeError: allocator undefined for Method
|
95
|
-
def duplicable?
|
96
|
-
false
|
97
|
-
end
|
98
|
-
end
|
@@ -1,35 +0,0 @@
|
|
1
|
-
module CloudSesame
|
2
|
-
module Query
|
3
|
-
module AST
|
4
|
-
class MultiExpressionOperator < Operator
|
5
|
-
|
6
|
-
def children
|
7
|
-
@children ||= create_children
|
8
|
-
end
|
9
|
-
|
10
|
-
def compile
|
11
|
-
if !children.empty? && (compiled = children.compile) && !compiled.empty?
|
12
|
-
"(#{ symbol }#{ boost } #{ compiled })"
|
13
|
-
end
|
14
|
-
end
|
15
|
-
|
16
|
-
def <<(object)
|
17
|
-
children << object
|
18
|
-
end
|
19
|
-
|
20
|
-
def is_excluded
|
21
|
-
children.map(&:is_excluded)
|
22
|
-
end
|
23
|
-
|
24
|
-
private
|
25
|
-
|
26
|
-
def create_children
|
27
|
-
array = FieldArray.new
|
28
|
-
array._scope = self
|
29
|
-
array
|
30
|
-
end
|
31
|
-
|
32
|
-
end
|
33
|
-
end
|
34
|
-
end
|
35
|
-
end
|
@@ -1,25 +0,0 @@
|
|
1
|
-
module CloudSesame
|
2
|
-
module Query
|
3
|
-
module AST
|
4
|
-
class Operator
|
5
|
-
SYMBOL = nil
|
6
|
-
|
7
|
-
attr_reader :context, :options
|
8
|
-
|
9
|
-
def initialize(context, options = {})
|
10
|
-
@context = context
|
11
|
-
@options = options
|
12
|
-
end
|
13
|
-
|
14
|
-
def boost
|
15
|
-
" boost=#{ options[:boost] }" if options[:boost]
|
16
|
-
end
|
17
|
-
|
18
|
-
def symbol
|
19
|
-
self.class::SYMBOL
|
20
|
-
end
|
21
|
-
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|
@@ -1,35 +0,0 @@
|
|
1
|
-
module CloudSesame
|
2
|
-
module Query
|
3
|
-
module AST
|
4
|
-
class SingleExpressionOperator < Operator
|
5
|
-
|
6
|
-
DETAILED = false
|
7
|
-
|
8
|
-
attr_accessor :child
|
9
|
-
|
10
|
-
def is_for(field, options = {})
|
11
|
-
child.is_for field, options if child
|
12
|
-
end
|
13
|
-
|
14
|
-
def is_excluded
|
15
|
-
child.is_excluded if child
|
16
|
-
end
|
17
|
-
|
18
|
-
def <<(object)
|
19
|
-
self.child = object
|
20
|
-
end
|
21
|
-
|
22
|
-
def compile(_detailed = nil)
|
23
|
-
if child && (compiled = child.compile operator_detailed) && !compiled.empty?
|
24
|
-
"(#{ symbol }#{ boost } #{ compiled })"
|
25
|
-
end
|
26
|
-
end
|
27
|
-
|
28
|
-
def operator_detailed
|
29
|
-
self.class::DETAILED
|
30
|
-
end
|
31
|
-
|
32
|
-
end
|
33
|
-
end
|
34
|
-
end
|
35
|
-
end
|
@@ -1,21 +0,0 @@
|
|
1
|
-
module CloudSesame
|
2
|
-
module Query
|
3
|
-
class Scope
|
4
|
-
|
5
|
-
attr_reader :_scope, :_return
|
6
|
-
|
7
|
-
def initialize(_scope, _return)
|
8
|
-
@_scope, @_return = _scope, _return
|
9
|
-
end
|
10
|
-
|
11
|
-
def _context
|
12
|
-
_scope.context
|
13
|
-
end
|
14
|
-
|
15
|
-
def <<(object)
|
16
|
-
_scope << object
|
17
|
-
end
|
18
|
-
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|
data/profiler.rb
DELETED
@@ -1,91 +0,0 @@
|
|
1
|
-
require 'profile'
|
2
|
-
require 'yaml'
|
3
|
-
require_relative './cloud_sesame.rb'
|
4
|
-
|
5
|
-
# AWS initializer
|
6
|
-
# =======================================================
|
7
|
-
|
8
|
-
YAML.load_file('aws.yml').each do |key, value|
|
9
|
-
ENV["AWS_#{ key }"] = value
|
10
|
-
end
|
11
|
-
|
12
|
-
# Domain Initializer /config/initializers/cloudsearch.rb
|
13
|
-
# =======================================================
|
14
|
-
|
15
|
-
|
16
|
-
CloudSesame::Domain::Client.configure do |config|
|
17
|
-
config.access_key = ENV['AWS_ACCESS_KEY_ID']
|
18
|
-
config.secret_key = ENV['AWS_SECRET_ACCESS_KEY']
|
19
|
-
end
|
20
|
-
|
21
|
-
# Usage Example
|
22
|
-
# =======================================================
|
23
|
-
class Product
|
24
|
-
include CloudSesame
|
25
|
-
|
26
|
-
define_cloudsearch do
|
27
|
-
# Product CloudSesame Config
|
28
|
-
config.endpoint = ENV['AWS_ENDPOINT']
|
29
|
-
config.region = ENV['AWS_REGION']
|
30
|
-
|
31
|
-
default_size 100
|
32
|
-
|
33
|
-
define_sloppiness 3
|
34
|
-
|
35
|
-
define_fuzziness do
|
36
|
-
max_fuzziness 3
|
37
|
-
min_char_size 6
|
38
|
-
fuzzy_percent 0.17
|
39
|
-
end
|
40
|
-
|
41
|
-
field :searchable_text, query: { weight: 2 }
|
42
|
-
field :description, query: true
|
43
|
-
field :tags
|
44
|
-
|
45
|
-
field :affiliate_advertiser_ext_id, facet: { size: 50 }
|
46
|
-
field :currency, facet: true
|
47
|
-
field :discount_percentage, facet: { buckets: %w([10,100] [25,100] [50,100] [70,100]), method: 'interval' }
|
48
|
-
field :manufacturer_name, facet: { size: 50 }
|
49
|
-
field :price, facet: { buckets: %w([0,25] [25,50] [50,100] [100,200] [200,}), method: 'interval' }
|
50
|
-
field :category_string, facet: { sort: 'bucket', size: 10_000 }
|
51
|
-
field :created_at, default: -> { gt Date.today }
|
52
|
-
|
53
|
-
scope :shoes_by_brand, ->(brand = nil) { query("shoes").and { manufacturer_name brand } if brand }
|
54
|
-
scope :and_mens do
|
55
|
-
and! { tags "men"}
|
56
|
-
end
|
57
|
-
|
58
|
-
end
|
59
|
-
|
60
|
-
end
|
61
|
-
|
62
|
-
def query
|
63
|
-
query = Product.cloudsearch
|
64
|
-
.query("black jacket")
|
65
|
-
.sort(price: :asc)
|
66
|
-
.page(1)
|
67
|
-
.size(1000)
|
68
|
-
.or {
|
69
|
-
or! {
|
70
|
-
tags("men", "women")
|
71
|
-
}
|
72
|
-
tags.not start_with("automotive"), "home"
|
73
|
-
and! {
|
74
|
-
price gt(100).lt(500)
|
75
|
-
created_at gt(Date.today - 7)
|
76
|
-
currency "CAD", "USD"
|
77
|
-
}
|
78
|
-
|
79
|
-
}.or {
|
80
|
-
and! {
|
81
|
-
tags "outdoor"
|
82
|
-
price gt(200).lt(1000)
|
83
|
-
created_at gt(Date.today - 7)
|
84
|
-
currency "CAD", "USD"
|
85
|
-
}
|
86
|
-
}
|
87
|
-
|
88
|
-
query.compile
|
89
|
-
end
|
90
|
-
|
91
|
-
query
|
@@ -1,76 +0,0 @@
|
|
1
|
-
module CloudSesame
|
2
|
-
module Query
|
3
|
-
module AST
|
4
|
-
describe MultiExpressionOperator do
|
5
|
-
|
6
|
-
let(:context) { {} }
|
7
|
-
let(:options) { {} }
|
8
|
-
let(:block) { Proc.new {} }
|
9
|
-
|
10
|
-
subject { MultiExpressionOperator.new(context, options, &block) }
|
11
|
-
|
12
|
-
it 'should be a type of operator' do
|
13
|
-
expect(MultiExpressionOperator.ancestors).to include(Operator)
|
14
|
-
end
|
15
|
-
|
16
|
-
describe '#children' do
|
17
|
-
it 'should be empty by default' do
|
18
|
-
expect(subject.children).to be_empty
|
19
|
-
end
|
20
|
-
it 'should be an Field Array' do
|
21
|
-
expect(subject.children).to be_a AST::FieldArray
|
22
|
-
end
|
23
|
-
end
|
24
|
-
|
25
|
-
describe '#compile' do
|
26
|
-
context 'when theres children' do
|
27
|
-
let(:child) { OpenStruct.new(compile: "compiled") }
|
28
|
-
before { subject.children << child }
|
29
|
-
|
30
|
-
it 'should compile to children' do
|
31
|
-
expect(subject.children).to receive(:compile)
|
32
|
-
subject.compile
|
33
|
-
end
|
34
|
-
|
35
|
-
context 'and boost options is given' do
|
36
|
-
before { subject.options[:boost] = 2 }
|
37
|
-
it 'should return compiled string with boost' do
|
38
|
-
expect(subject.compile).to eq "( boost=2 compiled)"
|
39
|
-
end
|
40
|
-
end
|
41
|
-
context 'and boost options is not given' do
|
42
|
-
it 'should return compiled string with boost' do
|
43
|
-
expect(subject.compile).to eq "( compiled)"
|
44
|
-
end
|
45
|
-
end
|
46
|
-
end
|
47
|
-
context 'when theres no children' do
|
48
|
-
it 'should return nothing' do
|
49
|
-
expect(subject.compile).to eq nil
|
50
|
-
end
|
51
|
-
end
|
52
|
-
end
|
53
|
-
|
54
|
-
describe '#<<' do
|
55
|
-
it 'should push object into the children' do
|
56
|
-
object = :hello
|
57
|
-
expect(subject.children).to receive(:<<).with(object)
|
58
|
-
subject << object
|
59
|
-
end
|
60
|
-
end
|
61
|
-
|
62
|
-
describe '#is_excluded' do
|
63
|
-
let(:child) { OpenStruct.new(is_excluded: nil) }
|
64
|
-
before { subject.children << child.dup << child.dup << child.dup }
|
65
|
-
it 'should broadcast down this method to it\'s children' do
|
66
|
-
subject.children.each do |child|
|
67
|
-
expect(child).to receive(:is_excluded)
|
68
|
-
end
|
69
|
-
subject.is_excluded
|
70
|
-
end
|
71
|
-
end
|
72
|
-
|
73
|
-
end
|
74
|
-
end
|
75
|
-
end
|
76
|
-
end
|
@@ -1,29 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
module CloudSesame
|
4
|
-
module Query
|
5
|
-
module AST
|
6
|
-
describe Operator do
|
7
|
-
let(:context) {{}}
|
8
|
-
let(:options) {{}}
|
9
|
-
let(:block) { Proc.new {} }
|
10
|
-
subject { Operator.new(context, options, &block) }
|
11
|
-
|
12
|
-
describe '#boost' do
|
13
|
-
context 'given boost option' do
|
14
|
-
let(:options) {{ boost: 2 }}
|
15
|
-
it 'should return an compiled boost value' do
|
16
|
-
expect(subject.boost).to eq " boost=2"
|
17
|
-
end
|
18
|
-
end
|
19
|
-
context 'given no boost option' do
|
20
|
-
it 'should return nothing' do
|
21
|
-
expect(subject.boost).to eq nil
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
26
|
-
end
|
27
|
-
end
|
28
|
-
end
|
29
|
-
end
|