inquery 0.1.0 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +9 -11
- data/Rakefile +1 -1
- data/VERSION +1 -1
- data/doc/Inquery.html +1 -1
- data/doc/Inquery/Exceptions.html +1 -1
- data/doc/Inquery/Exceptions/Base.html +1 -1
- data/doc/Inquery/Exceptions/InvalidRelation.html +1 -1
- data/doc/Inquery/Exceptions/UnknownCallSignature.html +1 -1
- data/doc/Inquery/Mixins.html +1 -1
- data/doc/Inquery/Mixins/RelationValidation.html +11 -13
- data/doc/Inquery/Mixins/RelationValidation/ClassMethods.html +6 -6
- data/doc/Inquery/Mixins/SchemaValidation.html +1 -1
- data/doc/Inquery/Mixins/SchemaValidation/ClassMethods.html +6 -20
- data/doc/Inquery/Query.html +2 -2
- data/doc/Inquery/Query/Chainable.html +1 -1
- data/doc/_index.html +1 -1
- data/doc/file.README.html +10 -12
- data/doc/index.html +10 -12
- data/doc/top-level-namespace.html +1 -1
- data/inquery.gemspec +5 -5
- data/lib/inquery/mixins/relation_validation.rb +7 -9
- data/lib/inquery/mixins/schema_validation.rb +2 -9
- data/lib/inquery/query.rb +1 -1
- data/test/inquery/query/chainable_test.rb +1 -1
- data/test/inquery/query_test.rb +2 -2
- data/test/queries/group/filter_with_color.rb +3 -1
- data/test/queries/user/fetch_in_group.rb +3 -3
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 384b003981408ccd6f8f1f87d12e7d8e0a7b08fa
|
4
|
+
data.tar.gz: d4b1decccb8a2c9244988bcac72ba58d98f04683
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a23c59f39af04e1792414d61fb9ed522c4279a35e57ade91f70bc2bdc1afb9d3b1775a978f3d96fd1b90b471769213277abd0e0ee3e0b3fb2ec31a1ba20184f6
|
7
|
+
data.tar.gz: ca4b8f8c2c14966d2a8741c020cf1e575da31de43bb5796313f72ea89c0d00344626a588db20a48e7046c3649d0e6678abd11e85e42c133baf3bf51d58c1ae36
|
data/README.md
CHANGED
@@ -24,9 +24,9 @@ gem 'inquery'
|
|
24
24
|
|
25
25
|
```ruby
|
26
26
|
class FetchUsersWithACar < Inquery::Query
|
27
|
-
schema
|
28
|
-
color
|
29
|
-
|
27
|
+
schema do
|
28
|
+
req :color, :symbol
|
29
|
+
end
|
30
30
|
|
31
31
|
def call
|
32
32
|
User.joins(:cars).where(cars: { color: osparams.color })
|
@@ -223,14 +223,12 @@ purpose, Inquery provides the `schema` method witch integrates the
|
|
223
223
|
|
224
224
|
```ruby
|
225
225
|
class SomeQueryClass < Inquery::Query
|
226
|
-
schema
|
227
|
-
some_param
|
228
|
-
some_other_param:
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
}
|
233
|
-
)
|
226
|
+
schema do
|
227
|
+
req :some_param, :integer
|
228
|
+
opt :some_other_param, :hash do
|
229
|
+
req :some_field, :string
|
230
|
+
end
|
231
|
+
end
|
234
232
|
|
235
233
|
# ...
|
236
234
|
end
|
data/Rakefile
CHANGED
@@ -21,7 +21,7 @@ task :gemspec do
|
|
21
21
|
spec.add_dependency 'minitest'
|
22
22
|
spec.add_dependency 'activesupport'
|
23
23
|
spec.add_dependency 'activerecord'
|
24
|
-
spec.add_dependency 'schemacop', '~>
|
24
|
+
spec.add_dependency 'schemacop', '~> 2'
|
25
25
|
end
|
26
26
|
|
27
27
|
File.open('inquery.gemspec', 'w') { |f| f.write(gemspec.to_ruby.strip) }
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
1.0.0
|
data/doc/Inquery.html
CHANGED
@@ -109,7 +109,7 @@
|
|
109
109
|
</div>
|
110
110
|
|
111
111
|
<div id="footer">
|
112
|
-
Generated on Tue May 16
|
112
|
+
Generated on Tue May 16 13:42:30 2017 by
|
113
113
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
114
114
|
0.9.9 (ruby-2.3.1).
|
115
115
|
</div>
|
data/doc/Inquery/Exceptions.html
CHANGED
@@ -105,7 +105,7 @@
|
|
105
105
|
</div>
|
106
106
|
|
107
107
|
<div id="footer">
|
108
|
-
Generated on Tue May 16
|
108
|
+
Generated on Tue May 16 13:42:30 2017 by
|
109
109
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
110
110
|
0.9.9 (ruby-2.3.1).
|
111
111
|
</div>
|
@@ -118,7 +118,7 @@
|
|
118
118
|
</div>
|
119
119
|
|
120
120
|
<div id="footer">
|
121
|
-
Generated on Tue May 16
|
121
|
+
Generated on Tue May 16 13:42:30 2017 by
|
122
122
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
123
123
|
0.9.9 (ruby-2.3.1).
|
124
124
|
</div>
|
@@ -122,7 +122,7 @@
|
|
122
122
|
</div>
|
123
123
|
|
124
124
|
<div id="footer">
|
125
|
-
Generated on Tue May 16
|
125
|
+
Generated on Tue May 16 13:42:30 2017 by
|
126
126
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
127
127
|
0.9.9 (ruby-2.3.1).
|
128
128
|
</div>
|
@@ -122,7 +122,7 @@
|
|
122
122
|
</div>
|
123
123
|
|
124
124
|
<div id="footer">
|
125
|
-
Generated on Tue May 16
|
125
|
+
Generated on Tue May 16 13:42:30 2017 by
|
126
126
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
127
127
|
0.9.9 (ruby-2.3.1).
|
128
128
|
</div>
|
data/doc/Inquery/Mixins.html
CHANGED
@@ -107,7 +107,7 @@
|
|
107
107
|
</div>
|
108
108
|
|
109
109
|
<div id="footer">
|
110
|
-
Generated on Tue May 16
|
110
|
+
Generated on Tue May 16 13:42:30 2017 by
|
111
111
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
112
112
|
0.9.9 (ruby-2.3.1).
|
113
113
|
</div>
|
@@ -110,14 +110,12 @@
|
|
110
110
|
<dt id="OPTIONS_SCHEMA-constant" class="">OPTIONS_SCHEMA =
|
111
111
|
|
112
112
|
</dt>
|
113
|
-
<dd><pre class="code"><span class='
|
114
|
-
<span class='
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
<span class='rbrace'>}</span>
|
120
|
-
<span class='rbrace'>}</span></pre></dd>
|
113
|
+
<dd><pre class="code"><span class='const'>Schemacop</span><span class='op'>::</span><span class='const'>Schema</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span> <span class='kw'>do</span>
|
114
|
+
<span class='id identifier rubyid_opt'>opt</span> <span class='symbol'>:class</span><span class='comma'>,</span> <span class='symbol'>:string</span>
|
115
|
+
<span class='id identifier rubyid_opt'>opt</span> <span class='symbol'>:fields</span><span class='comma'>,</span> <span class='symbol'>:integer</span>
|
116
|
+
<span class='id identifier rubyid_opt'>opt</span> <span class='symbol'>:default_select</span><span class='comma'>,</span> <span class='symbol'>:symbol</span>
|
117
|
+
<span class='id identifier rubyid_opt'>opt</span> <span class='symbol'>:default</span><span class='comma'>,</span> <span class='symbol'>:object</span><span class='comma'>,</span> <span class='label'>classes:</span> <span class='lbracket'>[</span><span class='const'>Proc</span><span class='comma'>,</span> <span class='const'>FalseClass</span><span class='rbracket'>]</span>
|
118
|
+
<span class='kw'>end</span></pre></dd>
|
121
119
|
|
122
120
|
<dt id="DEFAULT_OPTIONS-constant" class="">DEFAULT_OPTIONS =
|
123
121
|
|
@@ -223,6 +221,8 @@ options specified at class level using the <code>relation</code> method.</p>
|
|
223
221
|
<pre class="lines">
|
224
222
|
|
225
223
|
|
224
|
+
54
|
225
|
+
55
|
226
226
|
56
|
227
227
|
57
|
228
228
|
58
|
@@ -262,12 +262,10 @@ options specified at class level using the <code>relation</code> method.</p>
|
|
262
262
|
92
|
263
263
|
93
|
264
264
|
94
|
265
|
-
95
|
266
|
-
96
|
267
|
-
97</pre>
|
265
|
+
95</pre>
|
268
266
|
</td>
|
269
267
|
<td>
|
270
|
-
<pre class="code"><span class="info file"># File 'lib/inquery/mixins/relation_validation.rb', line
|
268
|
+
<pre class="code"><span class="info file"># File 'lib/inquery/mixins/relation_validation.rb', line 54</span>
|
271
269
|
|
272
270
|
<span class='kw'>def</span> <span class='id identifier rubyid_validate_relation!'>validate_relation!</span><span class='lparen'>(</span><span class='id identifier rubyid_relation'>relation</span><span class='rparen'>)</span>
|
273
271
|
<span class='id identifier rubyid_options'>options</span> <span class='op'>=</span> <span class='const'><span class='object_link'><a href="#DEFAULT_OPTIONS-constant" title="Inquery::Mixins::RelationValidation::DEFAULT_OPTIONS (constant)">DEFAULT_OPTIONS</a></span></span><span class='period'>.</span><span class='id identifier rubyid_dup'>dup</span>
|
@@ -321,7 +319,7 @@ options specified at class level using the <code>relation</code> method.</p>
|
|
321
319
|
</div>
|
322
320
|
|
323
321
|
<div id="footer">
|
324
|
-
Generated on Tue May 16
|
322
|
+
Generated on Tue May 16 13:42:30 2017 by
|
325
323
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
326
324
|
0.9.9 (ruby-2.3.1).
|
327
325
|
</div>
|
@@ -156,16 +156,16 @@ on. See <span class='object_link'><a href="../RelationValidation.html#OPTIONS_SC
|
|
156
156
|
<pre class="lines">
|
157
157
|
|
158
158
|
|
159
|
+
46
|
160
|
+
47
|
159
161
|
48
|
160
|
-
49
|
161
|
-
50
|
162
|
-
51</pre>
|
162
|
+
49</pre>
|
163
163
|
</td>
|
164
164
|
<td>
|
165
|
-
<pre class="code"><span class="info file"># File 'lib/inquery/mixins/relation_validation.rb', line
|
165
|
+
<pre class="code"><span class="info file"># File 'lib/inquery/mixins/relation_validation.rb', line 46</span>
|
166
166
|
|
167
167
|
<span class='kw'>def</span> <span class='id identifier rubyid_relation'>relation</span><span class='lparen'>(</span><span class='id identifier rubyid_options'>options</span> <span class='op'>=</span> <span class='lbrace'>{</span><span class='rbrace'>}</span><span class='rparen'>)</span>
|
168
|
-
<span class='const'
|
168
|
+
<span class='const'><span class='object_link'><a href="../RelationValidation.html#OPTIONS_SCHEMA-constant" title="Inquery::Mixins::RelationValidation::OPTIONS_SCHEMA (constant)">OPTIONS_SCHEMA</a></span></span><span class='period'>.</span><span class='id identifier rubyid_validate!'>validate!</span><span class='lparen'>(</span><span class='id identifier rubyid_options'>options</span><span class='rparen'>)</span>
|
169
169
|
<span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid__relation_options'>_relation_options</span> <span class='op'>=</span> <span class='id identifier rubyid_options'>options</span>
|
170
170
|
<span class='kw'>end</span></pre>
|
171
171
|
</td>
|
@@ -178,7 +178,7 @@ on. See <span class='object_link'><a href="../RelationValidation.html#OPTIONS_SC
|
|
178
178
|
</div>
|
179
179
|
|
180
180
|
<div id="footer">
|
181
|
-
Generated on Tue May 16
|
181
|
+
Generated on Tue May 16 13:42:30 2017 by
|
182
182
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
183
183
|
0.9.9 (ruby-2.3.1).
|
184
184
|
</div>
|
@@ -116,7 +116,7 @@
|
|
116
116
|
</div>
|
117
117
|
|
118
118
|
<div id="footer">
|
119
|
-
Generated on Tue May 16
|
119
|
+
Generated on Tue May 16 13:42:30 2017 by
|
120
120
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
121
121
|
0.9.9 (ruby-2.3.1).
|
122
122
|
</div>
|
@@ -101,7 +101,7 @@
|
|
101
101
|
<li class="public ">
|
102
102
|
<span class="summary_signature">
|
103
103
|
|
104
|
-
<a href="#schema-instance_method" title="#schema (instance method)">#<strong>schema</strong>(
|
104
|
+
<a href="#schema-instance_method" title="#schema (instance method)">#<strong>schema</strong>(*args, &block) ⇒ Object </a>
|
105
105
|
|
106
106
|
|
107
107
|
|
@@ -132,7 +132,7 @@
|
|
132
132
|
<div class="method_details first">
|
133
133
|
<h3 class="signature first" id="schema-instance_method">
|
134
134
|
|
135
|
-
#<strong>schema</strong>(
|
135
|
+
#<strong>schema</strong>(*args, &block) ⇒ <tt>Object</tt>
|
136
136
|
|
137
137
|
|
138
138
|
|
@@ -148,27 +148,13 @@
|
|
148
148
|
13
|
149
149
|
14
|
150
150
|
15
|
151
|
-
16
|
152
|
-
17
|
153
|
-
18
|
154
|
-
19
|
155
|
-
20
|
156
|
-
21
|
157
|
-
22
|
158
|
-
23</pre>
|
151
|
+
16</pre>
|
159
152
|
</td>
|
160
153
|
<td>
|
161
154
|
<pre class="code"><span class="info file"># File 'lib/inquery/mixins/schema_validation.rb', line 12</span>
|
162
155
|
|
163
|
-
<span class='kw'>def</span> <span class='id identifier rubyid_schema'>schema</span><span class='lparen'>(</span><span class='id identifier
|
164
|
-
<span class='id identifier
|
165
|
-
|
166
|
-
<span class='kw'>unless</span> <span class='id identifier rubyid_schema'>schema</span><span class='lbracket'>[</span><span class='symbol'>:type</span><span class='rbracket'>]</span>
|
167
|
-
<span class='id identifier rubyid_schema'>schema</span> <span class='op'>=</span> <span class='lbrace'>{</span>
|
168
|
-
<span class='label'>type:</span> <span class='symbol'>:hash</span><span class='comma'>,</span>
|
169
|
-
<span class='label'>hash:</span> <span class='id identifier rubyid_schema'>schema</span>
|
170
|
-
<span class='rbrace'>}</span>
|
171
|
-
<span class='kw'>end</span>
|
156
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_schema'>schema</span><span class='lparen'>(</span><span class='op'>*</span><span class='id identifier rubyid_args'>args</span><span class='comma'>,</span> <span class='op'>&</span><span class='id identifier rubyid_block'>block</span><span class='rparen'>)</span>
|
157
|
+
<span class='id identifier rubyid_schema'>schema</span> <span class='op'>=</span> <span class='const'>Schemacop</span><span class='op'>::</span><span class='const'>Schema</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='op'>*</span><span class='id identifier rubyid_args'>args</span><span class='comma'>,</span> <span class='op'>&</span><span class='id identifier rubyid_block'>block</span><span class='rparen'>)</span>
|
172
158
|
|
173
159
|
<span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid__schema'>_schema</span> <span class='op'>=</span> <span class='id identifier rubyid_schema'>schema</span>
|
174
160
|
<span class='kw'>end</span></pre>
|
@@ -182,7 +168,7 @@
|
|
182
168
|
</div>
|
183
169
|
|
184
170
|
<div id="footer">
|
185
|
-
Generated on Tue May 16
|
171
|
+
Generated on Tue May 16 13:42:30 2017 by
|
186
172
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
187
173
|
0.9.9 (ruby-2.3.1).
|
188
174
|
</div>
|
data/doc/Inquery/Query.html
CHANGED
@@ -392,7 +392,7 @@ was a validation schema specified).</p>
|
|
392
392
|
<span class='ivar'>@params</span> <span class='op'>=</span> <span class='id identifier rubyid_params'>params</span>
|
393
393
|
|
394
394
|
<span class='kw'>if</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_class'>class</span><span class='period'>.</span><span class='id identifier rubyid__schema'>_schema</span>
|
395
|
-
<span class='
|
395
|
+
<span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_class'>class</span><span class='period'>.</span><span class='id identifier rubyid__schema'>_schema</span><span class='period'>.</span><span class='id identifier rubyid_validate!'>validate!</span><span class='lparen'>(</span><span class='ivar'>@params</span><span class='rparen'>)</span>
|
396
396
|
<span class='kw'>end</span>
|
397
397
|
<span class='kw'>end</span></pre>
|
398
398
|
</td>
|
@@ -708,7 +708,7 @@ easyer access.</p>
|
|
708
708
|
</div>
|
709
709
|
|
710
710
|
<div id="footer">
|
711
|
-
Generated on Tue May 16
|
711
|
+
Generated on Tue May 16 13:42:30 2017 by
|
712
712
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
713
713
|
0.9.9 (ruby-2.3.1).
|
714
714
|
</div>
|
@@ -459,7 +459,7 @@
|
|
459
459
|
</div>
|
460
460
|
|
461
461
|
<div id="footer">
|
462
|
-
Generated on Tue May 16
|
462
|
+
Generated on Tue May 16 13:42:30 2017 by
|
463
463
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
464
464
|
0.9.9 (ruby-2.3.1).
|
465
465
|
</div>
|
data/doc/_index.html
CHANGED
@@ -241,7 +241,7 @@
|
|
241
241
|
</div>
|
242
242
|
|
243
243
|
<div id="footer">
|
244
|
-
Generated on Tue May 16
|
244
|
+
Generated on Tue May 16 13:42:29 2017 by
|
245
245
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
246
246
|
0.9.9 (ruby-2.3.1).
|
247
247
|
</div>
|
data/doc/file.README.html
CHANGED
@@ -80,9 +80,9 @@ to your <code>Gemfile</code>:</p>
|
|
80
80
|
<h2>Basic usage</h2>
|
81
81
|
|
82
82
|
<pre class="code ruby"><code class="ruby"><span class='kw'>class</span> <span class='const'>FetchUsersWithACar</span> <span class='op'><</span> <span class='const'><span class='object_link'><a href="Inquery.html" title="Inquery (module)">Inquery</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="Inquery/Query.html" title="Inquery::Query (class)">Query</a></span></span>
|
83
|
-
<span class='id identifier rubyid_schema'>schema</span
|
84
|
-
<span class='
|
85
|
-
<span class='
|
83
|
+
<span class='id identifier rubyid_schema'>schema</span> <span class='kw'>do</span>
|
84
|
+
<span class='id identifier rubyid_req'>req</span> <span class='symbol'>:color</span><span class='comma'>,</span> <span class='symbol'>:symbol</span>
|
85
|
+
<span class='kw'>end</span>
|
86
86
|
|
87
87
|
<span class='kw'>def</span> <span class='id identifier rubyid_call'>call</span>
|
88
88
|
<span class='const'>User</span><span class='period'>.</span><span class='id identifier rubyid_joins'>joins</span><span class='lparen'>(</span><span class='symbol'>:cars</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_where'>where</span><span class='lparen'>(</span><span class='label'>cars:</span> <span class='lbrace'>{</span> <span class='label'>color:</span> <span class='id identifier rubyid_osparams'>osparams</span><span class='period'>.</span><span class='id identifier rubyid_color'>color</span> <span class='rbrace'>}</span><span class='rparen'>)</span>
|
@@ -269,14 +269,12 @@ purpose, Inquery provides the <code>schema</code> method witch integrates the
|
|
269
269
|
<a href="https://github.com/sitrox/schemacop">Schemacop</a> validation Gem:</p>
|
270
270
|
|
271
271
|
<pre class="code ruby"><code class="ruby"><span class='kw'>class</span> <span class='const'>SomeQueryClass</span> <span class='op'><</span> <span class='const'><span class='object_link'><a href="Inquery.html" title="Inquery (module)">Inquery</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="Inquery/Query.html" title="Inquery::Query (class)">Query</a></span></span>
|
272
|
-
<span class='id identifier rubyid_schema'>schema</span
|
273
|
-
<span class='
|
274
|
-
<span class='
|
275
|
-
<span class='
|
276
|
-
|
277
|
-
|
278
|
-
<span class='rbrace'>}</span>
|
279
|
-
<span class='rparen'>)</span>
|
272
|
+
<span class='id identifier rubyid_schema'>schema</span> <span class='kw'>do</span>
|
273
|
+
<span class='id identifier rubyid_req'>req</span> <span class='symbol'>:some_param</span><span class='comma'>,</span> <span class='symbol'>:integer</span>
|
274
|
+
<span class='id identifier rubyid_opt'>opt</span> <span class='symbol'>:some_other_param</span><span class='comma'>,</span> <span class='symbol'>:hash</span> <span class='kw'>do</span>
|
275
|
+
<span class='id identifier rubyid_req'>req</span> <span class='symbol'>:some_field</span><span class='comma'>,</span> <span class='symbol'>:string</span>
|
276
|
+
<span class='kw'>end</span>
|
277
|
+
<span class='kw'>end</span>
|
280
278
|
|
281
279
|
<span class='comment'># ...
|
282
280
|
</span><span class='kw'>end</span>
|
@@ -347,7 +345,7 @@ And special thanks to <a href="http://www.subgit.com/">SubGit</a> for their grea
|
|
347
345
|
</div></div>
|
348
346
|
|
349
347
|
<div id="footer">
|
350
|
-
Generated on Tue May 16
|
348
|
+
Generated on Tue May 16 13:42:29 2017 by
|
351
349
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
352
350
|
0.9.9 (ruby-2.3.1).
|
353
351
|
</div>
|
data/doc/index.html
CHANGED
@@ -80,9 +80,9 @@ to your <code>Gemfile</code>:</p>
|
|
80
80
|
<h2>Basic usage</h2>
|
81
81
|
|
82
82
|
<pre class="code ruby"><code class="ruby"><span class='kw'>class</span> <span class='const'>FetchUsersWithACar</span> <span class='op'><</span> <span class='const'><span class='object_link'><a href="Inquery.html" title="Inquery (module)">Inquery</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="Inquery/Query.html" title="Inquery::Query (class)">Query</a></span></span>
|
83
|
-
<span class='id identifier rubyid_schema'>schema</span
|
84
|
-
<span class='
|
85
|
-
<span class='
|
83
|
+
<span class='id identifier rubyid_schema'>schema</span> <span class='kw'>do</span>
|
84
|
+
<span class='id identifier rubyid_req'>req</span> <span class='symbol'>:color</span><span class='comma'>,</span> <span class='symbol'>:symbol</span>
|
85
|
+
<span class='kw'>end</span>
|
86
86
|
|
87
87
|
<span class='kw'>def</span> <span class='id identifier rubyid_call'>call</span>
|
88
88
|
<span class='const'>User</span><span class='period'>.</span><span class='id identifier rubyid_joins'>joins</span><span class='lparen'>(</span><span class='symbol'>:cars</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_where'>where</span><span class='lparen'>(</span><span class='label'>cars:</span> <span class='lbrace'>{</span> <span class='label'>color:</span> <span class='id identifier rubyid_osparams'>osparams</span><span class='period'>.</span><span class='id identifier rubyid_color'>color</span> <span class='rbrace'>}</span><span class='rparen'>)</span>
|
@@ -269,14 +269,12 @@ purpose, Inquery provides the <code>schema</code> method witch integrates the
|
|
269
269
|
<a href="https://github.com/sitrox/schemacop">Schemacop</a> validation Gem:</p>
|
270
270
|
|
271
271
|
<pre class="code ruby"><code class="ruby"><span class='kw'>class</span> <span class='const'>SomeQueryClass</span> <span class='op'><</span> <span class='const'><span class='object_link'><a href="Inquery.html" title="Inquery (module)">Inquery</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="Inquery/Query.html" title="Inquery::Query (class)">Query</a></span></span>
|
272
|
-
<span class='id identifier rubyid_schema'>schema</span
|
273
|
-
<span class='
|
274
|
-
<span class='
|
275
|
-
<span class='
|
276
|
-
|
277
|
-
|
278
|
-
<span class='rbrace'>}</span>
|
279
|
-
<span class='rparen'>)</span>
|
272
|
+
<span class='id identifier rubyid_schema'>schema</span> <span class='kw'>do</span>
|
273
|
+
<span class='id identifier rubyid_req'>req</span> <span class='symbol'>:some_param</span><span class='comma'>,</span> <span class='symbol'>:integer</span>
|
274
|
+
<span class='id identifier rubyid_opt'>opt</span> <span class='symbol'>:some_other_param</span><span class='comma'>,</span> <span class='symbol'>:hash</span> <span class='kw'>do</span>
|
275
|
+
<span class='id identifier rubyid_req'>req</span> <span class='symbol'>:some_field</span><span class='comma'>,</span> <span class='symbol'>:string</span>
|
276
|
+
<span class='kw'>end</span>
|
277
|
+
<span class='kw'>end</span>
|
280
278
|
|
281
279
|
<span class='comment'># ...
|
282
280
|
</span><span class='kw'>end</span>
|
@@ -347,7 +345,7 @@ And special thanks to <a href="http://www.subgit.com/">SubGit</a> for their grea
|
|
347
345
|
</div></div>
|
348
346
|
|
349
347
|
<div id="footer">
|
350
|
-
Generated on Tue May 16
|
348
|
+
Generated on Tue May 16 13:42:29 2017 by
|
351
349
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
352
350
|
0.9.9 (ruby-2.3.1).
|
353
351
|
</div>
|
@@ -100,7 +100,7 @@
|
|
100
100
|
</div>
|
101
101
|
|
102
102
|
<div id="footer">
|
103
|
-
Generated on Tue May 16
|
103
|
+
Generated on Tue May 16 13:42:30 2017 by
|
104
104
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
105
105
|
0.9.9 (ruby-2.3.1).
|
106
106
|
</div>
|
data/inquery.gemspec
CHANGED
@@ -1,9 +1,9 @@
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
2
|
-
# stub: inquery
|
2
|
+
# stub: inquery 1.0.0 ruby lib
|
3
3
|
|
4
4
|
Gem::Specification.new do |s|
|
5
5
|
s.name = "inquery".freeze
|
6
|
-
s.version = "
|
6
|
+
s.version = "1.0.0"
|
7
7
|
|
8
8
|
s.required_rubygems_version = Gem::Requirement.new(">= 0".freeze) if s.respond_to? :required_rubygems_version=
|
9
9
|
s.require_paths = ["lib".freeze]
|
@@ -28,7 +28,7 @@ Gem::Specification.new do |s|
|
|
28
28
|
s.add_runtime_dependency(%q<minitest>.freeze, [">= 0"])
|
29
29
|
s.add_runtime_dependency(%q<activesupport>.freeze, [">= 0"])
|
30
30
|
s.add_runtime_dependency(%q<activerecord>.freeze, [">= 0"])
|
31
|
-
s.add_runtime_dependency(%q<schemacop>.freeze, ["~>
|
31
|
+
s.add_runtime_dependency(%q<schemacop>.freeze, ["~> 2"])
|
32
32
|
else
|
33
33
|
s.add_dependency(%q<bundler>.freeze, ["~> 1.3"])
|
34
34
|
s.add_dependency(%q<rake>.freeze, [">= 0"])
|
@@ -40,7 +40,7 @@ Gem::Specification.new do |s|
|
|
40
40
|
s.add_dependency(%q<minitest>.freeze, [">= 0"])
|
41
41
|
s.add_dependency(%q<activesupport>.freeze, [">= 0"])
|
42
42
|
s.add_dependency(%q<activerecord>.freeze, [">= 0"])
|
43
|
-
s.add_dependency(%q<schemacop>.freeze, ["~>
|
43
|
+
s.add_dependency(%q<schemacop>.freeze, ["~> 2"])
|
44
44
|
end
|
45
45
|
else
|
46
46
|
s.add_dependency(%q<bundler>.freeze, ["~> 1.3"])
|
@@ -53,6 +53,6 @@ Gem::Specification.new do |s|
|
|
53
53
|
s.add_dependency(%q<minitest>.freeze, [">= 0"])
|
54
54
|
s.add_dependency(%q<activesupport>.freeze, [">= 0"])
|
55
55
|
s.add_dependency(%q<activerecord>.freeze, [">= 0"])
|
56
|
-
s.add_dependency(%q<schemacop>.freeze, ["~>
|
56
|
+
s.add_dependency(%q<schemacop>.freeze, ["~> 2"])
|
57
57
|
end
|
58
58
|
end
|
@@ -3,14 +3,12 @@ module Inquery
|
|
3
3
|
module RelationValidation
|
4
4
|
extend ActiveSupport::Concern
|
5
5
|
|
6
|
-
OPTIONS_SCHEMA =
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
}
|
13
|
-
}
|
6
|
+
OPTIONS_SCHEMA = Schemacop::Schema.new do
|
7
|
+
opt :class, :string
|
8
|
+
opt :fields, :integer
|
9
|
+
opt :default_select, :symbol
|
10
|
+
opt :default, :object, classes: [Proc, FalseClass]
|
11
|
+
end
|
14
12
|
|
15
13
|
DEFAULT_OPTIONS = {
|
16
14
|
# Allows to restrict the class (attribute `klass`) of the relation. Use
|
@@ -46,7 +44,7 @@ module Inquery
|
|
46
44
|
# Allows to configure the parameters of the relation this query operates
|
47
45
|
# on. See {OPTIONS_SCHEMA} for documentation of the options hash.
|
48
46
|
def relation(options = {})
|
49
|
-
|
47
|
+
OPTIONS_SCHEMA.validate!(options)
|
50
48
|
self._relation_options = options
|
51
49
|
end
|
52
50
|
end
|
@@ -9,15 +9,8 @@ module Inquery
|
|
9
9
|
end
|
10
10
|
|
11
11
|
module ClassMethods
|
12
|
-
def schema(
|
13
|
-
|
14
|
-
|
15
|
-
unless schema[:type]
|
16
|
-
schema = {
|
17
|
-
type: :hash,
|
18
|
-
hash: schema
|
19
|
-
}
|
20
|
-
end
|
12
|
+
def schema(*args, &block)
|
13
|
+
schema = Schemacop::Schema.new(*args, &block)
|
21
14
|
|
22
15
|
self._schema = schema
|
23
16
|
end
|
data/lib/inquery/query.rb
CHANGED
data/test/inquery/query_test.rb
CHANGED
@@ -4,7 +4,7 @@ require 'queries/user/fetch_in_group'
|
|
4
4
|
require 'queries/group/fetch_as_json'
|
5
5
|
|
6
6
|
module Inquery
|
7
|
-
class QueryTest < Minitest::
|
7
|
+
class QueryTest < Minitest::Test
|
8
8
|
include TestHelper
|
9
9
|
|
10
10
|
def setup
|
@@ -29,7 +29,7 @@ module Inquery
|
|
29
29
|
end
|
30
30
|
|
31
31
|
def test_fetch_users_in_group_with_invalid_schema
|
32
|
-
assert_raises Schemacop::Exceptions::
|
32
|
+
assert_raises Schemacop::Exceptions::ValidationError do
|
33
33
|
Queries::User::FetchInGroup.run
|
34
34
|
end
|
35
35
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: inquery
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sitrox
|
@@ -156,14 +156,14 @@ dependencies:
|
|
156
156
|
requirements:
|
157
157
|
- - "~>"
|
158
158
|
- !ruby/object:Gem::Version
|
159
|
-
version: '
|
159
|
+
version: '2'
|
160
160
|
type: :runtime
|
161
161
|
prerelease: false
|
162
162
|
version_requirements: !ruby/object:Gem::Requirement
|
163
163
|
requirements:
|
164
164
|
- - "~>"
|
165
165
|
- !ruby/object:Gem::Version
|
166
|
-
version: '
|
166
|
+
version: '2'
|
167
167
|
description:
|
168
168
|
email:
|
169
169
|
executables: []
|