CloudSesame 0.5.2 → 0.5.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -4
- data/cloud_sesame.gemspec +2 -2
- data/lib/cloud_sesame/query/ast/numeric_value.rb +5 -1
- data/lib/cloud_sesame/query/ast/range_value.rb +5 -1
- data/spec/cloud_sesame/query/ast/numeric_value_spec.rb +61 -0
- data/spec/cloud_sesame_spec.rb +78 -50
- metadata +21 -19
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 572a899b37bb0c8cc0699855cb410739cba4f14c
|
4
|
+
data.tar.gz: e62e85516ba236f8a6eb92ecb9c6cb22740c6f84
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f68c0644208590a0589c047110b0d0ef5b8d733fd81bc183c26350cd14f747ad2ecdca3aebe6824797c1ca639e3a43ff92174a0750d6b446c566495892b1c61c
|
7
|
+
data.tar.gz: f22e6a1e9290d24bf62a42613fe731232cf6e0fbaeea1363a421abe08e789cb0891d80f8b0b2e8543de17626213cc536652242039e392533b76c2137d51b6cad
|
data/Gemfile.lock
CHANGED
data/cloud_sesame.gemspec
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
s.name = 'CloudSesame'
|
3
|
-
s.version = '0.5.
|
4
|
-
s.date = '2016-02-
|
3
|
+
s.version = '0.5.3'
|
4
|
+
s.date = '2016-02-09'
|
5
5
|
s.summary = "AWS CloudSearch Query DSL"
|
6
6
|
s.description = "AWS CloudSearch Query DSL"
|
7
7
|
s.authors = ['Scott Chu', 'Emily Fan', 'Greg Ward', 'David McHoull',
|
@@ -9,7 +9,10 @@ module CloudSesame
|
|
9
9
|
@data = if value.kind_of?(Range)
|
10
10
|
range_to_array(value)
|
11
11
|
elsif value.is_a?(String) && (match = string_format?(value))
|
12
|
-
|
12
|
+
(matches = match.captures)[1, 2] = matches[1, 2].map do |i|
|
13
|
+
Value.parse(i) unless i.nil? || i.empty?
|
14
|
+
end
|
15
|
+
@data = matches
|
13
16
|
else
|
14
17
|
default_range
|
15
18
|
end
|
@@ -40,6 +43,7 @@ module CloudSesame
|
|
40
43
|
end
|
41
44
|
|
42
45
|
def ==(object)
|
46
|
+
binding.pry
|
43
47
|
data == Value.parse(object).data
|
44
48
|
end
|
45
49
|
|
@@ -0,0 +1,61 @@
|
|
1
|
+
module CloudSesame
|
2
|
+
module Query
|
3
|
+
module AST
|
4
|
+
describe NumericValue do
|
5
|
+
|
6
|
+
describe 'compile' do
|
7
|
+
let(:value) { 20 }
|
8
|
+
subject { NumericValue.new(value) }
|
9
|
+
it 'should return the data in string format' do
|
10
|
+
expect(subject.compile).to eq "#{ value }"
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
describe '==' do
|
15
|
+
|
16
|
+
context 'when value comparing with is a integer' do
|
17
|
+
subject { NumericValue.new(20) }
|
18
|
+
|
19
|
+
it 'should return true if data equals to the value' do
|
20
|
+
expect(subject == 20).to eq true
|
21
|
+
end
|
22
|
+
|
23
|
+
it 'should return false when data does not equal to the value' do
|
24
|
+
expect(subject == 21).to eq false
|
25
|
+
end
|
26
|
+
|
27
|
+
end
|
28
|
+
|
29
|
+
context 'when value comparing with is a float' do
|
30
|
+
subject { NumericValue.new(0.99) }
|
31
|
+
|
32
|
+
it 'should return true if data equals to the value' do
|
33
|
+
expect(subject == 0.990).to eq true
|
34
|
+
end
|
35
|
+
|
36
|
+
it 'should return false when data does not equal to the value' do
|
37
|
+
expect(subject == 1.0).to eq false
|
38
|
+
end
|
39
|
+
|
40
|
+
end
|
41
|
+
|
42
|
+
context 'when value comparing with is a string' do
|
43
|
+
subject { NumericValue.new("0.99") }
|
44
|
+
|
45
|
+
it 'should return true if data equals to the value' do
|
46
|
+
expect(subject == 0.990).to eq true
|
47
|
+
expect(subject == "0.990").to eq true
|
48
|
+
end
|
49
|
+
|
50
|
+
it 'should return false when data does not equal to the value' do
|
51
|
+
expect(subject == 1.0).to eq false
|
52
|
+
expect(subject == "1.0").to eq false
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
end
|
57
|
+
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
data/spec/cloud_sesame_spec.rb
CHANGED
@@ -46,7 +46,7 @@
|
|
46
46
|
|
47
47
|
# field :searchable_text, query: { weight: 2 }
|
48
48
|
# field :description, query: true
|
49
|
-
# field :tags,
|
49
|
+
# field :tags , as: :text1, default: -> { "men" }
|
50
50
|
|
51
51
|
# field :affiliate_advertiser_ext_id, facet: { size: 50 }
|
52
52
|
# field :currency, facet: true
|
@@ -54,66 +54,94 @@
|
|
54
54
|
# field :manufacturer_name, facet: { size: 50 }
|
55
55
|
# field :price, facet: { buckets: %w([0,25] [25,50] [50,100] [100,200] [200,}), method: 'interval' }
|
56
56
|
# field :category_string, facet: { sort: 'bucket', size: 10_000 }
|
57
|
-
# field :created_at, default: -> {
|
58
|
-
|
59
|
-
# scope :shoes_by_brand, ->(brand = nil) { query("shoes").and { manufacturer_name brand } if brand }
|
60
|
-
# scope :and_mens do
|
61
|
-
# and! { tags "men"}
|
62
|
-
# end
|
57
|
+
# field :created_at, default: -> { Time.now }
|
63
58
|
|
64
59
|
# end
|
65
60
|
|
66
61
|
# end
|
67
62
|
|
68
63
|
|
69
|
-
# @tags = [1, 2]
|
70
|
-
# n = 10_000
|
71
|
-
#
|
72
|
-
# result = RubyProf.profile do
|
73
|
-
#
|
74
|
-
#
|
75
|
-
#
|
76
|
-
#
|
77
|
-
#
|
78
|
-
#
|
79
|
-
#
|
80
|
-
#
|
81
|
-
#
|
82
|
-
#
|
83
|
-
#
|
84
|
-
#
|
85
|
-
#
|
86
|
-
#
|
87
|
-
#
|
88
|
-
#
|
89
|
-
#
|
90
|
-
#
|
91
|
-
#
|
92
|
-
#
|
93
|
-
#
|
94
|
-
#
|
95
|
-
#
|
96
|
-
#
|
97
|
-
#
|
98
|
-
#
|
99
|
-
#
|
100
|
-
#
|
101
|
-
#
|
102
|
-
#
|
103
|
-
#
|
104
|
-
#
|
105
|
-
#
|
106
|
-
|
107
|
-
#
|
108
|
-
# end
|
109
|
-
# printer = RubyProf::FlatPrinter.new(result)
|
110
|
-
# printer.print(STDOUT, {})
|
64
|
+
# # @tags = [1, 2]
|
65
|
+
# # n = 10_000
|
66
|
+
# # q = nil
|
67
|
+
# # result = RubyProf.profile do
|
68
|
+
# # n.times do
|
69
|
+
# # q = Product.cloudsearch.query("black jacket").sort(price: :asc).page(1).size(1000)
|
70
|
+
# # .price { gt 100 }
|
71
|
+
# # .and {
|
72
|
+
# # or! {
|
73
|
+
# # tags *@tags
|
74
|
+
# # tags
|
75
|
+
# # tags nil
|
76
|
+
# # and! {
|
77
|
+
# # tags.not "3", "4"
|
78
|
+
# # }
|
79
|
+
# # and!.not {
|
80
|
+
# # tags.start_with "5", "6"
|
81
|
+
# # tags.not.start_with("7")
|
82
|
+
# # tags.not.near("8", distance: 7)
|
83
|
+
# # tags start_with("9"), near("10")
|
84
|
+
# # tags term("11", boost: 2)
|
85
|
+
# # tags.not phrase "12"
|
86
|
+
# # }
|
87
|
+
# # or!.not {
|
88
|
+
# # price(25..100)
|
89
|
+
# # price 100...200
|
90
|
+
# # price gte(200).lt(300)
|
91
|
+
# # price gte(300)
|
92
|
+
# # }
|
93
|
+
# # or! {
|
94
|
+
# # created_at Date.today - 7
|
95
|
+
# # created_at gte(Date.today)
|
96
|
+
# # created_at gte(Date.today).lt(Date.today + 3)
|
97
|
+
# # }
|
98
|
+
# # }
|
99
|
+
# # }
|
100
|
+
# # q.applied_filters
|
101
|
+
|
102
|
+
# # end
|
103
|
+
# # end
|
104
|
+
# # printer = RubyProf::FlatPrinter.new(result)
|
105
|
+
# # printer.print(STDOUT, {})
|
106
|
+
|
107
|
+
# class Coupon
|
108
|
+
# include CloudSesame
|
109
|
+
|
110
|
+
# VALID_COUPON_RANK = 20
|
111
|
+
|
112
|
+
# define_cloudsearch do
|
113
|
+
# config.endpoint = ENV['AWS_ENDPOINT']
|
114
|
+
# config.region = ENV['AWS_REGION']
|
115
|
+
|
116
|
+
# default_size 10
|
117
|
+
|
118
|
+
# define_sloppiness 3
|
119
|
+
|
120
|
+
# define_fuzziness do
|
121
|
+
# max_fuzziness 3
|
122
|
+
# min_char_size 6
|
123
|
+
# fuzzy_percent 0.17
|
124
|
+
# end
|
125
|
+
|
126
|
+
# field :end_date, as: :date1
|
127
|
+
# field :rank, as: :num1, default: -> { gte VALID_COUPON_RANK }
|
128
|
+
# field :searchable_text, query: true
|
129
|
+
# field :affiliate_advertiser_search_ext_id, as: :string1, facet: { size: 50 }
|
130
|
+
# field :countries, as: :string_array1
|
131
|
+
# field :deal_types, as: :string_array2, facet: {}
|
132
|
+
# field :tags, as: :string_array3, facet: {}
|
133
|
+
# field :type, default: -> { 'Catalog::CouponSearchable' }
|
134
|
+
# end
|
135
|
+
|
136
|
+
# end
|
137
|
+
|
138
|
+
# q = Coupon.cloudsearch.builder
|
111
139
|
|
112
140
|
# binding.pry
|
113
141
|
|
114
142
|
# # class ProductController
|
115
143
|
|
116
|
-
# # def
|
144
|
+
# # def load_userq
|
117
145
|
# # @name = "scott"
|
118
146
|
# # end
|
119
147
|
|
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.5.
|
4
|
+
version: 0.5.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Scott Chu
|
@@ -15,90 +15,90 @@ authors:
|
|
15
15
|
autorequire:
|
16
16
|
bindir: bin
|
17
17
|
cert_chain: []
|
18
|
-
date: 2016-02-
|
18
|
+
date: 2016-02-09 00:00:00.000000000 Z
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
21
21
|
name: aws-sdk
|
22
22
|
requirement: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- -
|
24
|
+
- - ~>
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '2'
|
27
27
|
type: :runtime
|
28
28
|
prerelease: false
|
29
29
|
version_requirements: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- -
|
31
|
+
- - ~>
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: '2'
|
34
34
|
- !ruby/object:Gem::Dependency
|
35
35
|
name: rspec
|
36
36
|
requirement: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- -
|
38
|
+
- - ~>
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '3'
|
41
41
|
type: :development
|
42
42
|
prerelease: false
|
43
43
|
version_requirements: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- -
|
45
|
+
- - ~>
|
46
46
|
- !ruby/object:Gem::Version
|
47
47
|
version: '3'
|
48
48
|
- !ruby/object:Gem::Dependency
|
49
49
|
name: pry
|
50
50
|
requirement: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- -
|
52
|
+
- - ~>
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '0'
|
55
55
|
type: :development
|
56
56
|
prerelease: false
|
57
57
|
version_requirements: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
|
-
- -
|
59
|
+
- - ~>
|
60
60
|
- !ruby/object:Gem::Version
|
61
61
|
version: '0'
|
62
62
|
- !ruby/object:Gem::Dependency
|
63
63
|
name: guard
|
64
64
|
requirement: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
|
-
- -
|
66
|
+
- - '>='
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '0'
|
69
69
|
type: :development
|
70
70
|
prerelease: false
|
71
71
|
version_requirements: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
|
-
- -
|
73
|
+
- - '>='
|
74
74
|
- !ruby/object:Gem::Version
|
75
75
|
version: '0'
|
76
76
|
- !ruby/object:Gem::Dependency
|
77
77
|
name: guard-rspec
|
78
78
|
requirement: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
|
-
- -
|
80
|
+
- - '>='
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: '0'
|
83
83
|
type: :development
|
84
84
|
prerelease: false
|
85
85
|
version_requirements: !ruby/object:Gem::Requirement
|
86
86
|
requirements:
|
87
|
-
- -
|
87
|
+
- - '>='
|
88
88
|
- !ruby/object:Gem::Version
|
89
89
|
version: '0'
|
90
90
|
- !ruby/object:Gem::Dependency
|
91
91
|
name: ruby-prof
|
92
92
|
requirement: !ruby/object:Gem::Requirement
|
93
93
|
requirements:
|
94
|
-
- -
|
94
|
+
- - '>='
|
95
95
|
- !ruby/object:Gem::Version
|
96
96
|
version: '0'
|
97
97
|
type: :development
|
98
98
|
prerelease: false
|
99
99
|
version_requirements: !ruby/object:Gem::Requirement
|
100
100
|
requirements:
|
101
|
-
- -
|
101
|
+
- - '>='
|
102
102
|
- !ruby/object:Gem::Version
|
103
103
|
version: '0'
|
104
104
|
description: AWS CloudSearch Query DSL
|
@@ -107,8 +107,8 @@ executables: []
|
|
107
107
|
extensions: []
|
108
108
|
extra_rdoc_files: []
|
109
109
|
files:
|
110
|
-
-
|
111
|
-
-
|
110
|
+
- .gitignore
|
111
|
+
- .rspec
|
112
112
|
- Gemfile
|
113
113
|
- Gemfile.lock
|
114
114
|
- Guardfile
|
@@ -180,6 +180,7 @@ files:
|
|
180
180
|
- spec/cloud_sesame/domain/base_spec.rb
|
181
181
|
- spec/cloud_sesame/query/ast/and_spec.rb
|
182
182
|
- spec/cloud_sesame/query/ast/multi_expression_operator_spec.rb
|
183
|
+
- spec/cloud_sesame/query/ast/numeric_value_spec.rb
|
183
184
|
- spec/cloud_sesame/query/ast/operator_spec.rb
|
184
185
|
- spec/cloud_sesame/query/ast/or_spec.rb
|
185
186
|
- spec/cloud_sesame/query/ast/root_spec.rb
|
@@ -212,17 +213,17 @@ require_paths:
|
|
212
213
|
- lib
|
213
214
|
required_ruby_version: !ruby/object:Gem::Requirement
|
214
215
|
requirements:
|
215
|
-
- -
|
216
|
+
- - '>='
|
216
217
|
- !ruby/object:Gem::Version
|
217
218
|
version: '0'
|
218
219
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
219
220
|
requirements:
|
220
|
-
- -
|
221
|
+
- - '>='
|
221
222
|
- !ruby/object:Gem::Version
|
222
223
|
version: '0'
|
223
224
|
requirements: []
|
224
225
|
rubyforge_project:
|
225
|
-
rubygems_version: 2.
|
226
|
+
rubygems_version: 2.4.8
|
226
227
|
signing_key:
|
227
228
|
specification_version: 4
|
228
229
|
summary: AWS CloudSearch Query DSL
|
@@ -231,6 +232,7 @@ test_files:
|
|
231
232
|
- spec/cloud_sesame/domain/base_spec.rb
|
232
233
|
- spec/cloud_sesame/query/ast/and_spec.rb
|
233
234
|
- spec/cloud_sesame/query/ast/multi_expression_operator_spec.rb
|
235
|
+
- spec/cloud_sesame/query/ast/numeric_value_spec.rb
|
234
236
|
- spec/cloud_sesame/query/ast/operator_spec.rb
|
235
237
|
- spec/cloud_sesame/query/ast/or_spec.rb
|
236
238
|
- spec/cloud_sesame/query/ast/root_spec.rb
|