smql 0.0.4.6 → 0.0.4.7
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/lib/smql_to_ar.rb +2 -2
- data/lib/smql_to_ar/condition_types.rb +8 -5
- metadata +3 -16
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.4.
|
1
|
+
0.0.4.7
|
data/lib/smql_to_ar.rb
CHANGED
@@ -152,10 +152,10 @@ class SmqlToAR
|
|
152
152
|
@model = model
|
153
153
|
@last_model = nil
|
154
154
|
*@path, @col = *Array.wrap( col).
|
155
|
-
collect
|
155
|
+
collect {|x| x.to_s.split /[.\/]/ }.
|
156
156
|
flatten.
|
157
157
|
collect( &Col.method( :new)).
|
158
|
-
reject
|
158
|
+
reject {|x| x === :self }
|
159
159
|
end
|
160
160
|
|
161
161
|
def last_model
|
@@ -100,7 +100,7 @@ class SmqlToAR
|
|
100
100
|
# Passt das Object, die Klasse instanzieren.
|
101
101
|
def try_parse model, cols, op, val
|
102
102
|
#p :class => self, :self => name, :try_parse => op, :cols => cols, :with => self::Operator, :value => val, :expected => self::Expected, :model => model.name
|
103
|
-
new model, cols, val if self::Operator === op and self::Expected.any?
|
103
|
+
new model, cols, val if self::Operator === op and self::Expected.any? {|x| x === val}
|
104
104
|
end
|
105
105
|
|
106
106
|
def inspect
|
@@ -225,7 +225,7 @@ class SmqlToAR
|
|
225
225
|
# { 'articles=>' => [ { id: 1 }, { id: 2 } ] }
|
226
226
|
class EqualJoin <Condition
|
227
227
|
Operator = '=>'
|
228
|
-
Expected = [Hash, lambda {|x| x.kind_of?( Array) and x.all?
|
228
|
+
Expected = [Hash, lambda {|x| x.kind_of?( Array) and x.all? {|y| y.kind_of?( Hash) }}]
|
229
229
|
|
230
230
|
def initialize *pars
|
231
231
|
super( *pars)
|
@@ -255,7 +255,10 @@ class SmqlToAR
|
|
255
255
|
col.joins.each {|j, m| builder.joins table+j, m }
|
256
256
|
builder.joins t, model
|
257
257
|
b4 = b3.new( b2)
|
258
|
-
sub.each
|
258
|
+
sub.each do |i|
|
259
|
+
b5 = And.new b4
|
260
|
+
i.collect {|j| j.build b5, t }
|
261
|
+
end
|
259
262
|
end
|
260
263
|
self
|
261
264
|
end
|
@@ -293,7 +296,7 @@ class SmqlToAR
|
|
293
296
|
t = table+col.to_a
|
294
297
|
builder.sub_joins t, col, *sub[0..1]
|
295
298
|
#ap sub: sub[2..-1]
|
296
|
-
sub[2..-1].each
|
299
|
+
sub[2..-1].each {|x| x.build builder, t }
|
297
300
|
end
|
298
301
|
self
|
299
302
|
end
|
@@ -345,7 +348,7 @@ class SmqlToAR
|
|
345
348
|
|
346
349
|
class <<self
|
347
350
|
def try_parse model, func, args
|
348
|
-
self.new model, func, args if self::Name === func and self::Expected.any?
|
351
|
+
self.new model, func, args if self::Name === func and self::Expected.any? {|x| x === args }
|
349
352
|
end
|
350
353
|
|
351
354
|
def inspect
|
metadata
CHANGED
@@ -6,8 +6,8 @@ version: !ruby/object:Gem::Version
|
|
6
6
|
- 0
|
7
7
|
- 0
|
8
8
|
- 4
|
9
|
-
-
|
10
|
-
version: 0.0.4.
|
9
|
+
- 7
|
10
|
+
version: 0.0.4.7
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Denis Knauf
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-11-
|
18
|
+
date: 2011-11-30 00:00:00 +01:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
@@ -57,19 +57,6 @@ dependencies:
|
|
57
57
|
version: "0"
|
58
58
|
type: :runtime
|
59
59
|
version_requirements: *id003
|
60
|
-
- !ruby/object:Gem::Dependency
|
61
|
-
name: methodphitamine
|
62
|
-
prerelease: false
|
63
|
-
requirement: &id004 !ruby/object:Gem::Requirement
|
64
|
-
none: false
|
65
|
-
requirements:
|
66
|
-
- - ">="
|
67
|
-
- !ruby/object:Gem::Version
|
68
|
-
segments:
|
69
|
-
- 0
|
70
|
-
version: "0"
|
71
|
-
type: :runtime
|
72
|
-
version_requirements: *id004
|
73
60
|
description: SMQL is a JSON-based query langauage similar to MQL. This gem convertes these querys to ActiveRecord.
|
74
61
|
email:
|
75
62
|
- Denis.Knauf@gmail.com
|