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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: aec4e3689d2f6830ee142beb89ef38d8c7e03d65
4
- data.tar.gz: 491f28cd6d7b8335362d77699f0f0c214824b893
3
+ metadata.gz: 384b003981408ccd6f8f1f87d12e7d8e0a7b08fa
4
+ data.tar.gz: d4b1decccb8a2c9244988bcac72ba58d98f04683
5
5
  SHA512:
6
- metadata.gz: 9d009ad21e0578929aa49c050210096c6f3d747c9b6aed1ede3ab26d4e4255d7695a0d22ec896b657167cca300642158ecf040cac48f0d3a2c7e8d374aec603f
7
- data.tar.gz: '08ad570e01461f620e959923cc8cbc8083efe08296982f5517ab1e99df22dad1d3b6bb73fe9eba1c68205bacdffb782ab8b4df92538eb568d015d70c3c412ae5'
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: :symbol
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: :integer,
228
- some_other_param: {
229
- hash: {
230
- some_field: :string
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', '~> 1'
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
- 0.1.0
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 10:49:05 2017 by
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>
@@ -105,7 +105,7 @@
105
105
  </div>
106
106
 
107
107
  <div id="footer">
108
- Generated on Tue May 16 10:49:05 2017 by
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 10:49:05 2017 by
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 10:49:05 2017 by
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 10:49:05 2017 by
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>
@@ -107,7 +107,7 @@
107
107
  </div>
108
108
 
109
109
  <div id="footer">
110
- Generated on Tue May 16 10:49:05 2017 by
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='lbrace'>{</span>
114
- <span class='label'>hash:</span> <span class='lbrace'>{</span>
115
- <span class='label'>class:</span> <span class='lbrace'>{</span> <span class='label'>type:</span> <span class='const'>String</span><span class='comma'>,</span> <span class='label'>null:</span> <span class='kw'>true</span><span class='comma'>,</span> <span class='label'>required:</span> <span class='kw'>false</span> <span class='rbrace'>}</span><span class='comma'>,</span>
116
- <span class='label'>fields:</span> <span class='lbrace'>{</span> <span class='label'>type:</span> <span class='symbol'>:integer</span><span class='comma'>,</span> <span class='label'>null:</span> <span class='kw'>true</span><span class='comma'>,</span> <span class='label'>required:</span> <span class='kw'>false</span> <span class='rbrace'>}</span><span class='comma'>,</span>
117
- <span class='label'>default_select:</span> <span class='lbrace'>{</span> <span class='label'>type:</span> <span class='symbol'>:symbol</span><span class='comma'>,</span> <span class='label'>null:</span> <span class='kw'>true</span><span class='comma'>,</span> <span class='label'>required:</span> <span class='kw'>false</span> <span class='rbrace'>}</span><span class='comma'>,</span>
118
- <span class='label'>default:</span> <span class='lbrace'>{</span> <span class='label'>type:</span> <span class='lbracket'>[</span><span class='const'>Proc</span><span class='comma'>,</span> <span class='const'>FalseClass</span><span class='rbracket'>]</span><span class='comma'>,</span> <span class='label'>null:</span> <span class='kw'>true</span><span class='comma'>,</span> <span class='label'>required:</span> <span class='kw'>false</span> <span class='rbrace'>}</span>
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 56</span>
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 10:49:05 2017 by
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 48</span>
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'>Schemacop</span><span class='period'>.</span><span class='id identifier rubyid_validate!'>validate!</span><span class='lparen'>(</span><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='comma'>,</span> <span class='id identifier rubyid_options'>options</span><span class='rparen'>)</span>
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 10:49:05 2017 by
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 10:49:05 2017 by
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>(schema) &#x21d2; Object </a>
104
+ <a href="#schema-instance_method" title="#schema (instance method)">#<strong>schema</strong>(*args, &amp;block) &#x21d2; 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>(schema) &#x21d2; <tt>Object</tt>
135
+ #<strong>schema</strong>(*args, &amp;block) &#x21d2; <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 rubyid_schema'>schema</span><span class='rparen'>)</span>
164
- <span class='id identifier rubyid_fail'>fail</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>Schema must be a hash.</span><span class='tstring_end'>&#39;</span></span> <span class='kw'>unless</span> <span class='id identifier rubyid_schema'>schema</span><span class='period'>.</span><span class='id identifier rubyid_is_a?'>is_a?</span><span class='lparen'>(</span><span class='const'>Hash</span><span class='rparen'>)</span>
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'>&amp;</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'>&amp;</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 10:49:05 2017 by
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>
@@ -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='const'>Schemacop</span><span class='period'>.</span><span class='id identifier rubyid_validate!'>validate!</span><span class='lparen'>(</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><span class='comma'>,</span> <span class='ivar'>@params</span><span class='rparen'>)</span>
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 10:49:05 2017 by
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 10:49:05 2017 by
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 10:49:05 2017 by
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'>&lt;</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><span class='lparen'>(</span>
84
- <span class='label'>color:</span> <span class='symbol'>:symbol</span>
85
- <span class='rparen'>)</span>
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'>&lt;</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><span class='lparen'>(</span>
273
- <span class='label'>some_param:</span> <span class='symbol'>:integer</span><span class='comma'>,</span>
274
- <span class='label'>some_other_param:</span> <span class='lbrace'>{</span>
275
- <span class='label'>hash:</span> <span class='lbrace'>{</span>
276
- <span class='label'>some_field:</span> <span class='symbol'>:string</span>
277
- <span class='rbrace'>}</span>
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 10:49:05 2017 by
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'>&lt;</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><span class='lparen'>(</span>
84
- <span class='label'>color:</span> <span class='symbol'>:symbol</span>
85
- <span class='rparen'>)</span>
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'>&lt;</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><span class='lparen'>(</span>
273
- <span class='label'>some_param:</span> <span class='symbol'>:integer</span><span class='comma'>,</span>
274
- <span class='label'>some_other_param:</span> <span class='lbrace'>{</span>
275
- <span class='label'>hash:</span> <span class='lbrace'>{</span>
276
- <span class='label'>some_field:</span> <span class='symbol'>:string</span>
277
- <span class='rbrace'>}</span>
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 10:49:05 2017 by
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 10:49:05 2017 by
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 0.1.0 ruby lib
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 = "0.1.0"
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, ["~> 1"])
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, ["~> 1"])
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, ["~> 1"])
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
- hash: {
8
- class: { type: String, null: true, required: false },
9
- fields: { type: :integer, null: true, required: false },
10
- default_select: { type: :symbol, null: true, required: false },
11
- default: { type: [Proc, FalseClass], null: true, required: false }
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
- Schemacop.validate!(OPTIONS_SCHEMA, options)
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(schema)
13
- fail 'Schema must be a hash.' unless schema.is_a?(Hash)
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
@@ -22,7 +22,7 @@ module Inquery
22
22
  @params = params
23
23
 
24
24
  if self.class._schema
25
- Schemacop.validate!(self.class._schema, @params)
25
+ self.class._schema.validate!(@params)
26
26
  end
27
27
  end
28
28
 
@@ -5,7 +5,7 @@ require 'queries/group/filter_with_color'
5
5
 
6
6
  module Inquery
7
7
  class Query
8
- class ChainableTest < Minitest::Unit::TestCase
8
+ class ChainableTest < Minitest::Test
9
9
  include TestHelper
10
10
 
11
11
  def setup
@@ -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::Unit::TestCase
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::Validation do
32
+ assert_raises Schemacop::Exceptions::ValidationError do
33
33
  Queries::User::FetchInGroup.run
34
34
  end
35
35
  end
@@ -2,7 +2,9 @@ module Queries
2
2
  module Group
3
3
  class FilterWithColor < Inquery::Query::Chainable
4
4
  relation class: 'Group'
5
- schema color: :string
5
+ schema do
6
+ req :color, :string
7
+ end
6
8
 
7
9
  def call
8
10
  relation.where(color: osparams.color)
@@ -1,9 +1,9 @@
1
1
  module Queries
2
2
  module User
3
3
  class FetchInGroup < Inquery::Query
4
- schema(
5
- group_id: :integer
6
- )
4
+ schema do
5
+ req :group_id, :integer
6
+ end
7
7
 
8
8
  def call
9
9
  ::Group.find(osparams.group_id).users
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: 0.1.0
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: '1'
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: '1'
166
+ version: '2'
167
167
  description:
168
168
  email:
169
169
  executables: []