CloudSesame 0.5.4 → 0.5.5

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 613761dd7ba257e52f1cf2db7ec4041bdde9e407
4
- data.tar.gz: 59068ac2327bf2975068be1daea7bbe3a4525834
3
+ metadata.gz: bcedaacb98078285e2bf1d047a041e4d284e0ba9
4
+ data.tar.gz: 9694b8af7cd6f591f02979431d52113f97e4db50
5
5
  SHA512:
6
- metadata.gz: b1b9860864172024274401d981454d1fdd501533dc61d4e5ea992a6eb7fdb92f2f394dcf04991c26b9ffa25cecf88932e5ce9705aacae214d23d09b1234a22d1
7
- data.tar.gz: 331648c6632f1ba080fd6f22e32334b527f8062bcbb925459d3465d8922fdf62888c9f3be4bacf35cc353e08d4d38ecd65a2e935c97ea9eb0c7033f89d9240f9
6
+ metadata.gz: 42f1e5e7bc7d6fe4b1eb7cfc0bfdc86c9ebbda56032ccc92a236e449e6608f5f792be6b1d710c56adffcdf0344f9b6465faabdd3e0aec65a90919fc762f8ca25
7
+ data.tar.gz: 72d113a1d7004a47ced9f0d5e8767aa04a3ce4c9a7b906ffcd8c746717d9be5beeff11766e0f37e162f9ba0e2c2a05de455b14efe02ffb78ba77aee698426f10
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- CloudSesame (0.5.4)
4
+ CloudSesame (0.5.5)
5
5
  aws-sdk (~> 2)
6
6
 
7
7
  GEM
data/cloud_sesame.gemspec CHANGED
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'CloudSesame'
3
- s.version = '0.5.4'
3
+ s.version = '0.5.5'
4
4
  s.date = '2016-02-09'
5
5
  s.summary = "AWS CloudSearch Query DSL"
6
6
  s.description = "AWS CloudSearch Query DSL"
@@ -31,6 +31,10 @@ module CloudSesame
31
31
  # DEFAULT CONTEXT METHODS
32
32
  # =========================================
33
33
 
34
+ def turn_on_cache
35
+
36
+ end
37
+
34
38
  def default_size(value)
35
39
  (context[:page] ||= {})[:size] = value
36
40
  end
@@ -8,7 +8,9 @@ module CloudSesame
8
8
  end
9
9
 
10
10
  def ==(value)
11
- value.to_f == data.to_f || value == compile
11
+ value == data.to_f ||
12
+ value == data ||
13
+ value == compile
12
14
  end
13
15
 
14
16
  end
@@ -44,7 +44,6 @@ module CloudSesame
44
44
 
45
45
  it 'should return true if data equals to the value' do
46
46
  expect(subject == 0.990).to eq true
47
- expect(subject == "0.990").to eq true
48
47
  end
49
48
 
50
49
  it 'should return false when data does not equal to the value' do
@@ -53,6 +52,13 @@ module CloudSesame
53
52
  end
54
53
  end
55
54
 
55
+ context 'when value comparing with a nil value' do
56
+ subject { NumericValue.new(1) }
57
+ it 'should return false' do
58
+ expect(subject == nil).to eq false
59
+ end
60
+ end
61
+
56
62
  end
57
63
 
58
64
  end
@@ -1,163 +1,163 @@
1
- # require 'spec_helper'
2
- # require 'ruby-prof'
3
- # require 'benchmark'
4
-
5
- # describe CloudSesame do
6
-
7
- # # AWS initializer
8
- # # =======================================================
9
- # require 'yaml'
10
- # YAML.load_file('aws.yml').each do |key, value|
11
- # ENV["AWS_#{ key }"] = value
12
- # end
13
-
14
- # # Domain Initializer /config/initializers/cloudsearch.rb
15
- # # =======================================================
16
- # require 'cloud_sesame'
17
-
18
- # CloudSesame::Domain::Client.configure do |config|
19
- # config.access_key = ENV['AWS_ACCESS_KEY_ID']
20
- # config.secret_key = ENV['AWS_SECRET_ACCESS_KEY']
21
- # end
22
-
23
- # # Usage Example
24
- # # =======================================================
25
- # class Product
26
- # include CloudSesame
27
-
28
- # def self.greeting
29
- # "hello world!"
30
- # end
31
-
32
- # define_cloudsearch do
33
- # # Product CloudSesame Config
34
- # config.endpoint = ENV['AWS_ENDPOINT']
35
- # config.region = ENV['AWS_REGION']
36
-
37
- # default_size 100
38
-
39
- # define_sloppiness 3
40
-
41
- # define_fuzziness do
42
- # max_fuzziness 3
43
- # min_char_size 6
44
- # fuzzy_percent 0.17
45
- # end
46
-
47
- # field :searchable_text, query: { weight: 2 }
48
- # field :description, query: true
49
- # field :tags , as: :text1, default: -> { "men" }
50
-
51
- # field :affiliate_advertiser_ext_id, facet: { size: 50 }
52
- # field :currency, facet: true
53
- # field :discount_percentage, facet: { buckets: %w([10,100] [25,100] [50,100] [70,100]), method: 'interval' }
54
- # field :manufacturer_name, facet: { size: 50 }
55
- # field :price, facet: { buckets: %w([0,25] [25,50] [50,100] [100,200] [200,}), method: 'interval' }
56
- # field :category_string, facet: { sort: 'bucket', size: 10_000 }
57
- # field :created_at, default: -> { Time.now }
58
-
59
- # end
60
-
61
- # end
62
-
63
-
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
139
-
140
- # binding.pry
141
-
142
- # # class ProductController
143
-
144
- # # def load_userq
145
- # # @name = "scott"
146
- # # end
147
-
148
- # # def greeting
149
- # # "hello world!"
150
- # # end
151
-
152
- # # def search
153
- # # load_user
154
- # # q = Product.cloudsearch.and {
155
- # # binding.pry
156
- # # }
157
- # # end
158
-
159
- # # end
160
-
161
- # # test = ProductController.new
162
- # # test.search
163
- # end
1
+ require 'spec_helper'
2
+ require 'ruby-prof'
3
+ require 'benchmark'
4
+
5
+ describe CloudSesame do
6
+
7
+ # AWS initializer
8
+ # =======================================================
9
+ require 'yaml'
10
+ YAML.load_file('aws.yml').each do |key, value|
11
+ ENV["AWS_#{ key }"] = value
12
+ end
13
+
14
+ # Domain Initializer /config/initializers/cloudsearch.rb
15
+ # =======================================================
16
+ require 'cloud_sesame'
17
+
18
+ CloudSesame::Domain::Client.configure do |config|
19
+ config.access_key = ENV['AWS_ACCESS_KEY_ID']
20
+ config.secret_key = ENV['AWS_SECRET_ACCESS_KEY']
21
+ end
22
+
23
+ # Usage Example
24
+ # =======================================================
25
+ class Product
26
+ include CloudSesame
27
+
28
+ def self.greeting
29
+ "hello world!"
30
+ end
31
+
32
+ define_cloudsearch do
33
+ # Product CloudSesame Config
34
+ config.endpoint = ENV['AWS_ENDPOINT']
35
+ config.region = ENV['AWS_REGION']
36
+
37
+ default_size 100
38
+
39
+ define_sloppiness 3
40
+
41
+ define_fuzziness do
42
+ max_fuzziness 3
43
+ min_char_size 6
44
+ fuzzy_percent 0.17
45
+ end
46
+
47
+ field :searchable_text, query: { weight: 2 }
48
+ field :description, query: true
49
+ field :tags , as: :text1, default: -> { "men" }
50
+
51
+ field :affiliate_advertiser_ext_id, facet: { size: 50 }
52
+ field :currency, facet: true
53
+ field :discount_percentage, facet: { buckets: %w([10,100] [25,100] [50,100] [70,100]), method: 'interval' }
54
+ field :manufacturer_name, facet: { size: 50 }
55
+ field :price, facet: { buckets: %w([0,25] [25,50] [50,100] [100,200] [200,}), method: 'interval' }
56
+ field :category_string, facet: { sort: 'bucket', size: 10_000 }
57
+ field :created_at, default: -> { Time.now }
58
+
59
+ end
60
+
61
+ end
62
+
63
+
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
139
+
140
+ binding.pry
141
+
142
+ # class ProductController
143
+
144
+ # def load_userq
145
+ # @name = "scott"
146
+ # end
147
+
148
+ # def greeting
149
+ # "hello world!"
150
+ # end
151
+
152
+ # def search
153
+ # load_user
154
+ # q = Product.cloudsearch.and {
155
+ # binding.pry
156
+ # }
157
+ # end
158
+
159
+ # end
160
+
161
+ # test = ProductController.new
162
+ # test.search
163
+ end
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
4
+ version: 0.5.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Scott Chu