CloudSesame 0.5.0 → 0.5.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e496630f0f95249813a64396a44c5afb138ac417
4
- data.tar.gz: 8b1ea78470d4452d2328fc3f64b7966064028e3e
3
+ metadata.gz: 0fd4bf461eb1ac6ec180ec34cd4a9cdd9a2589c1
4
+ data.tar.gz: 75c0a8253a052232ed8b0416ba5f9081462a7894
5
5
  SHA512:
6
- metadata.gz: a9fda75e99cc51ab852b0b08603d661c6ae9b554af033c6dbd1ecace4768a9f3d2067ff5ad31d138be426095d4222b697d2436c6e998fb31879932d97c3b5f3a
7
- data.tar.gz: 398c9345b3d76df8114c2d83077749ed8923f22f4a8f21112b58fed691ca3a8b58d1e430923481e08632434ac3711723a5ae1437ecf77e2630e52e5b1e6da34c
6
+ metadata.gz: 83a2fc53241e5dd037f1b88738ad8128f43fa88161f6f2207ed64e29c01cb90220d01bf67519d1b4c1e873dc3404bb198960c7011f864121934e8c607209f97e
7
+ data.tar.gz: 48b0b4138dd446f4c59f2de92eaca2660938f23f30774c36147d675cc8956041ac64e356f488502c4bb585ff58a455af9bd10c94cc8dc7b59aee97ef6a520d66
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- CloudSesame (0.5.0)
4
+ CloudSesame (0.5.1)
5
5
  activesupport (~> 3.2)
6
6
  aws-sdk (~> 2)
7
7
 
@@ -82,6 +82,3 @@ DEPENDENCIES
82
82
  pry (~> 0)
83
83
  rspec (~> 3)
84
84
  ruby-prof
85
-
86
- BUNDLED WITH
87
- 1.11.2
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.0'
3
+ s.version = '0.5.1'
4
4
  s.date = '2016-02-01'
5
5
  s.summary = "AWS CloudSearch Query DSL"
6
6
  s.description = "AWS CloudSearch Query DSL"
data/lib/cloud_sesame.rb CHANGED
@@ -18,17 +18,21 @@ require 'cloud_sesame/query/error/scope_not_defined'
18
18
 
19
19
  # Query DSL Methods
20
20
  # ===============================================
21
- require 'cloud_sesame/query/dsl/block_methods'
22
- require 'cloud_sesame/query/dsl/field_array_methods'
21
+ require 'cloud_sesame/query/dsl/applied_filter_query'
22
+ require 'cloud_sesame/query/dsl/bind_caller'
23
+ require 'cloud_sesame/query/dsl/block_styled_operators'
23
24
  require 'cloud_sesame/query/dsl/field_accessors'
24
- require 'cloud_sesame/query/dsl/filter_query_methods'
25
- require 'cloud_sesame/query/dsl/operator_methods'
25
+ require 'cloud_sesame/query/dsl/scope_accessors'
26
+ require 'cloud_sesame/query/dsl/operators'
27
+ require 'cloud_sesame/query/dsl/field_array_methods'
28
+
29
+ require 'cloud_sesame/query/dsl/range_helper'
26
30
  require 'cloud_sesame/query/dsl/page_methods'
27
31
  require 'cloud_sesame/query/dsl/query_methods'
28
- require 'cloud_sesame/query/dsl/range_methods'
32
+
29
33
  require 'cloud_sesame/query/dsl/response_methods'
30
34
  require 'cloud_sesame/query/dsl/return_methods'
31
- require 'cloud_sesame/query/dsl/scope_accessors'
35
+
32
36
  require 'cloud_sesame/query/dsl/sort_methods'
33
37
 
34
38
  # Query Query Domain Objects
@@ -3,15 +3,15 @@ module CloudSesame
3
3
  class Builder
4
4
  include DSL::QueryMethods
5
5
  include DSL::ResponseMethods
6
- include DSL::BlockMethods
6
+ include DSL::BlockStyledOperators
7
7
  include DSL::FieldAccessors
8
- include DSL::FilterQueryMethods
9
8
  include DSL::ScopeAccessors
9
+ include DSL::AppliedFilterQuery
10
10
  include DSL::PageMethods
11
11
  include DSL::SortMethods
12
12
  include DSL::ReturnMethods
13
13
 
14
- attr_reader :context
14
+ attr_reader :context, :searchable
15
15
 
16
16
  def initialize(context, searchable)
17
17
  @context = Context.new.duplicate context
@@ -2,12 +2,13 @@ module CloudSesame
2
2
  module Query
3
3
  module Domain
4
4
  class Block
5
- include DSL::BlockMethods
5
+ include DSL::AppliedFilterQuery
6
+ include DSL::BlockStyledOperators
6
7
  include DSL::FieldAccessors
7
- include DSL::ScopeAccessors
8
- include DSL::OperatorMethods
9
- include DSL::RangeMethods
10
- include DSL::FilterQueryMethods
8
+ include DSL::Operators
9
+ include DSL::RangeHelper
10
+ include DSL::ScopeAccessors
11
+ include DSL::BindCaller
11
12
 
12
13
  attr_reader :_caller, :_context, :_scopes
13
14
 
@@ -16,11 +17,7 @@ module CloudSesame
16
17
  @_context = _context
17
18
  @_scopes = []
18
19
 
19
- @_caller.instance_variables.each do |name|
20
- value = @_caller.instance_variable_get name
21
- instance_variable_set name, value
22
- end
23
-
20
+ _bind_caller_instance_variables
24
21
  end
25
22
 
26
23
  def _eval(node, _scope, _return = _scope, &block)
@@ -49,16 +46,6 @@ module CloudSesame
49
46
  self
50
47
  end
51
48
 
52
- private
53
-
54
- # ACCESS CALLER'S METHODS
55
- # =========================================
56
- def method_missing(name, *args, &block)
57
- _caller.send(name, *args, &block)
58
- rescue NoMethodError
59
- super
60
- end
61
-
62
49
  end
63
50
  end
64
51
  end
@@ -2,7 +2,8 @@ module CloudSesame
2
2
  module Query
3
3
  module Domain
4
4
  class Literal
5
- include DSL::RangeMethods
5
+ include DSL::BindCaller
6
+ include DSL::RangeHelper
6
7
 
7
8
  attr_reader :_name, :_options, :_caller
8
9
 
@@ -11,10 +12,7 @@ module CloudSesame
11
12
  @_options = _options
12
13
  @_caller = _caller
13
14
 
14
- _caller.instance_variables.each do |name|
15
- value = _caller.instance_variable_get name
16
- instance_variable_set name, value
17
- end
15
+ _bind_caller_instance_variables
18
16
  end
19
17
 
20
18
  def _eval(&block)
@@ -23,16 +21,6 @@ module CloudSesame
23
21
  end
24
22
  end
25
23
 
26
- private
27
-
28
- # ACCESS CALLER'S METHODS
29
- # =========================================
30
- def method_missing(name, *args, &block)
31
- _caller.send(name, *args, &block)
32
- rescue NoMethodError
33
- super
34
- end
35
-
36
24
  end
37
25
  end
38
26
  end
@@ -1,7 +1,7 @@
1
1
  module CloudSesame
2
2
  module Query
3
3
  module DSL
4
- module FilterQueryMethods
4
+ module AppliedFilterQuery
5
5
 
6
6
  def included?(field, value = nil)
7
7
  !!(
@@ -0,0 +1,26 @@
1
+ module CloudSesame
2
+ module Query
3
+ module DSL
4
+ module BindCaller
5
+
6
+ private
7
+
8
+ def _bind_caller_instance_variables
9
+ _caller.instance_variables.each do |name|
10
+ value = _caller.instance_variable_get name
11
+ instance_variable_set name, value
12
+ end
13
+ end
14
+
15
+ # ACCESS CALLER'S METHODS
16
+ # =========================================
17
+ def method_missing(name, *args, &block)
18
+ _caller.send(name, *args, &block)
19
+ rescue NoMethodError
20
+ super
21
+ end
22
+
23
+ end
24
+ end
25
+ end
26
+ end
@@ -1,7 +1,7 @@
1
1
  module CloudSesame
2
2
  module Query
3
3
  module DSL
4
- module BlockMethods
4
+ module BlockStyledOperators
5
5
 
6
6
  # CLAUSE: AND
7
7
  # =========================================
@@ -1,7 +1,7 @@
1
1
  module CloudSesame
2
2
  module Query
3
3
  module DSL
4
- module OperatorMethods
4
+ module Operators
5
5
 
6
6
  # NEAR: creates a single NEAR node
7
7
  # =======================================
@@ -1,7 +1,7 @@
1
1
  module CloudSesame
2
2
  module Query
3
3
  module DSL
4
- module RangeMethods
4
+ module RangeHelper
5
5
 
6
6
  def gt(input)
7
7
  AST::RangeValue.new.gt input
@@ -4,8 +4,9 @@ module CloudSesame
4
4
  module ScopeAccessors
5
5
 
6
6
  def scopes(name = nil, *args)
7
- defined_scopes = _scope.context[:scopes]
8
7
  return _return if name.nil?
8
+
9
+ defined_scopes = _scope.context[:scopes]
9
10
  if defined_scopes && (block = defined_scopes[name.to_sym])
10
11
  instance_exec *args, &block
11
12
  _return
@@ -0,0 +1,124 @@
1
+ module CloudSesame
2
+ module Query
3
+ module Domain
4
+ describe Block do
5
+
6
+ class Caller
7
+
8
+ def initialize
9
+ @test = "hello"
10
+ end
11
+
12
+ def test_method
13
+ return "test method!!!"
14
+ end
15
+ end
16
+
17
+ subject { Block.new(Caller.new, {}) }
18
+
19
+ # expect modules to be included
20
+ [
21
+ DSL::BlockStyledOperators,
22
+ DSL::FieldAccessors,
23
+ DSL::ScopeAccessors,
24
+ DSL::Operators,
25
+ DSL::BindCaller
26
+ ].each do |included_module|
27
+ it "should include #{ included_module }" do
28
+ expect(Block.included_modules).to include included_module
29
+ end
30
+ end
31
+
32
+ context 'given a caller' do
33
+
34
+ it 'should have access to caller\'s instance variables' do
35
+ expect(subject.instance_variable_get(:@test)).to eq "hello"
36
+ end
37
+
38
+ it 'should have access to caller\'s methods' do
39
+ expect(subject.test_method).to eq "test method!!!"
40
+ end
41
+
42
+ end
43
+
44
+ describe '#_scopes' do
45
+ it 'should be default to an empty array' do
46
+ expect(subject._scopes).to eq []
47
+ end
48
+ it 'should not be able to get overrided' do
49
+ expect{ subject._scopes = [] }.to raise_error(NoMethodError)
50
+ end
51
+ end
52
+
53
+ describe '#_scope' do
54
+ context 'when scopes is not empty' do
55
+ before { subject._scopes << 1 << 2 }
56
+ it 'should return the last item from _scopes' do
57
+ expect(subject._scope).to eq 2
58
+ end
59
+ end
60
+ context 'when scopes is empty' do
61
+ it 'should return nil' do
62
+ expect(subject._scope).to eq nil
63
+ end
64
+ end
65
+ end
66
+
67
+ # def _eval(node, _scope, _return = _scope, &block)
68
+ # _scopes.push node
69
+ # instance_eval &block
70
+ # _scope << node
71
+ # _scopes.pop
72
+ # _scope.is_a?(AST::Root) ? _return : node
73
+ # end
74
+ describe '#_eval' do
75
+
76
+ let(:node) { AST::And.new({}, {}) }
77
+ let(:scope) { AST::And.new({}, {}) }
78
+
79
+ context 'when block is not given' do
80
+ it 'should raise an error ' do
81
+ expect{ subject._eval(node, scope) }.to raise_error(ArgumentError)
82
+ end
83
+ end
84
+
85
+ context 'when a block is given' do
86
+
87
+ subject { Block.new(self, {}) }
88
+
89
+ it 'should use itself to evalute the block' do
90
+ subject._eval(node, scope) { expect(self).to eq subject }
91
+ end
92
+
93
+ it 'should change the _scope in the block to the node passed in' do
94
+ subject._eval(node, scope) { expect(_scope).to eq node }
95
+ end
96
+
97
+ it 'should set the _scope back to previous scope after _eval' do
98
+ subject._scopes << :first_scope
99
+ subject._eval(node, scope) {}
100
+ expect(subject._scope).to eq :first_scope
101
+ end
102
+
103
+ context 'when _scope is not a root node' do
104
+ it 'should return the node it self' do
105
+ expect(subject._eval(node, scope) {}).to eq node
106
+ end
107
+ end
108
+
109
+ context 'when _scope is a root node' do
110
+ it 'should return the _return' do
111
+ scope = AST::Root.new({}, {})
112
+ expect(subject._eval(node, scope, :return_object) { }).to eq :return_object
113
+ end
114
+ end
115
+
116
+ end
117
+
118
+
119
+ end
120
+
121
+ end
122
+ end
123
+ end
124
+ end
@@ -1,9 +1,7 @@
1
- require 'spec_helper'
2
-
3
1
  module CloudSesame
4
2
  module Query
5
3
  module DSL
6
- describe BlockMethods do
4
+ describe BlockStyledOperators do
7
5
 
8
6
  # Setup
9
7
  # =================================================
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.0
4
+ version: 0.5.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Scott Chu
@@ -21,98 +21,98 @@ dependencies:
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: activesupport
36
36
  requirement: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - "~>"
38
+ - - ~>
39
39
  - !ruby/object:Gem::Version
40
40
  version: '3.2'
41
41
  type: :runtime
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.2'
48
48
  - !ruby/object:Gem::Dependency
49
49
  name: rspec
50
50
  requirement: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - "~>"
52
+ - - ~>
53
53
  - !ruby/object:Gem::Version
54
54
  version: '3'
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: '3'
62
62
  - !ruby/object:Gem::Dependency
63
63
  name: pry
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
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: guard-rspec
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
  - !ruby/object:Gem::Dependency
105
105
  name: ruby-prof
106
106
  requirement: !ruby/object:Gem::Requirement
107
107
  requirements:
108
- - - ">="
108
+ - - '>='
109
109
  - !ruby/object:Gem::Version
110
110
  version: '0'
111
111
  type: :development
112
112
  prerelease: false
113
113
  version_requirements: !ruby/object:Gem::Requirement
114
114
  requirements:
115
- - - ">="
115
+ - - '>='
116
116
  - !ruby/object:Gem::Version
117
117
  version: '0'
118
118
  description: AWS CloudSearch Query DSL
@@ -121,8 +121,8 @@ executables: []
121
121
  extensions: []
122
122
  extra_rdoc_files: []
123
123
  files:
124
- - ".gitignore"
125
- - ".rspec"
124
+ - .gitignore
125
+ - .rspec
126
126
  - Gemfile
127
127
  - Gemfile.lock
128
128
  - Guardfile
@@ -157,14 +157,15 @@ files:
157
157
  - lib/cloud_sesame/query/domain/block.rb
158
158
  - lib/cloud_sesame/query/domain/chaining_block.rb
159
159
  - lib/cloud_sesame/query/domain/literal.rb
160
- - lib/cloud_sesame/query/dsl/block_methods.rb
160
+ - lib/cloud_sesame/query/dsl/applied_filter_query.rb
161
+ - lib/cloud_sesame/query/dsl/bind_caller.rb
162
+ - lib/cloud_sesame/query/dsl/block_styled_operators.rb
161
163
  - lib/cloud_sesame/query/dsl/field_accessors.rb
162
164
  - lib/cloud_sesame/query/dsl/field_array_methods.rb
163
- - lib/cloud_sesame/query/dsl/filter_query_methods.rb
164
- - lib/cloud_sesame/query/dsl/operator_methods.rb
165
+ - lib/cloud_sesame/query/dsl/operators.rb
165
166
  - lib/cloud_sesame/query/dsl/page_methods.rb
166
167
  - lib/cloud_sesame/query/dsl/query_methods.rb
167
- - lib/cloud_sesame/query/dsl/range_methods.rb
168
+ - lib/cloud_sesame/query/dsl/range_helper.rb
168
169
  - lib/cloud_sesame/query/dsl/response_methods.rb
169
170
  - lib/cloud_sesame/query/dsl/return_methods.rb
170
171
  - lib/cloud_sesame/query/dsl/scope_accessors.rb
@@ -196,6 +197,7 @@ files:
196
197
  - spec/cloud_sesame/query/ast/root_spec.rb
197
198
  - spec/cloud_sesame/query/ast/single_expression_operator_spec.rb
198
199
  - spec/cloud_sesame/query/builder_spec.rb
200
+ - spec/cloud_sesame/query/domain/block_spec.rb
199
201
  - spec/cloud_sesame/query/dsl/block_methods_spec.rb
200
202
  - spec/cloud_sesame/query/dsl/field_accessors_spec.rb
201
203
  - spec/cloud_sesame/query/dsl/field_array_methods_spec.rb
@@ -222,17 +224,17 @@ require_paths:
222
224
  - lib
223
225
  required_ruby_version: !ruby/object:Gem::Requirement
224
226
  requirements:
225
- - - ">="
227
+ - - '>='
226
228
  - !ruby/object:Gem::Version
227
229
  version: '0'
228
230
  required_rubygems_version: !ruby/object:Gem::Requirement
229
231
  requirements:
230
- - - ">="
232
+ - - '>='
231
233
  - !ruby/object:Gem::Version
232
234
  version: '0'
233
235
  requirements: []
234
236
  rubyforge_project:
235
- rubygems_version: 2.5.1
237
+ rubygems_version: 2.4.8
236
238
  signing_key:
237
239
  specification_version: 4
238
240
  summary: AWS CloudSearch Query DSL
@@ -246,6 +248,7 @@ test_files:
246
248
  - spec/cloud_sesame/query/ast/root_spec.rb
247
249
  - spec/cloud_sesame/query/ast/single_expression_operator_spec.rb
248
250
  - spec/cloud_sesame/query/builder_spec.rb
251
+ - spec/cloud_sesame/query/domain/block_spec.rb
249
252
  - spec/cloud_sesame/query/dsl/block_methods_spec.rb
250
253
  - spec/cloud_sesame/query/dsl/field_accessors_spec.rb
251
254
  - spec/cloud_sesame/query/dsl/field_array_methods_spec.rb