aquel 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/aquel.gemspec +1 -1
- data/lib/aquel.rb +1 -0
- data/lib/aquel/attributes.rb +13 -0
- data/lib/aquel/executor.rb +16 -12
- data/lib/aquel/version.rb +1 -1
- data/spec/aquel_spec.rb +5 -0
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: feb46cbd8f0d7f2f1f69b1621c633f4e8a5dec9a
|
4
|
+
data.tar.gz: 363185ab282a158a3c7cb8e33ace18562d28a24a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cd0b27fe23bdfb2b6301b37bdbb9375253fea21c2d15ccecff4a486b8902096d99ecd4e9d2901aefa50dedc33f2dcb41f2cba663d5479713222dde5a3d53da08
|
7
|
+
data.tar.gz: 04213723470351bbff63269c721fc194cfff1eee00510dd9ee08920196e6c79cc93d6cedc7ec9e2a70d37e1e08c98c2fcb2625e0e4114fff8538767d2916e9bf
|
data/README.md
CHANGED
data/aquel.gemspec
CHANGED
@@ -8,7 +8,7 @@ Gem::Specification.new do |spec|
|
|
8
8
|
spec.version = Aquel::VERSION
|
9
9
|
spec.authors = ["youpy"]
|
10
10
|
spec.email = ["youpy@buycheapviagraonlinenow.com"]
|
11
|
-
spec.summary = %q{
|
11
|
+
spec.summary = %q{a(nything) que(ry) l(anguage)}
|
12
12
|
spec.homepage = ""
|
13
13
|
spec.license = "MIT"
|
14
14
|
|
data/lib/aquel.rb
CHANGED
data/lib/aquel/executor.rb
CHANGED
@@ -22,10 +22,10 @@ module Aquel
|
|
22
22
|
context.execute!
|
23
23
|
|
24
24
|
items = []
|
25
|
-
attributes =
|
25
|
+
attributes = Attributes.new
|
26
26
|
|
27
27
|
walk(ast['SELECT']['whereClause'], attributes)
|
28
|
-
document = context.document_block.call(attributes)
|
28
|
+
document = context.document_block.call(attributes.equal_values)
|
29
29
|
|
30
30
|
if context.items_block
|
31
31
|
context.items_block.call(document).each do |item|
|
@@ -34,7 +34,7 @@ module Aquel
|
|
34
34
|
end
|
35
35
|
elsif context.find_by_block.size > 0
|
36
36
|
context.find_by_block.each do |k, v|
|
37
|
-
v.call(attributes[k], document).each do |item|
|
37
|
+
v.call(attributes.equal_values[k], document).each do |item|
|
38
38
|
value = context.split_block.call(item)
|
39
39
|
items << (value.kind_of?(Array) ? value : [value])
|
40
40
|
end
|
@@ -53,7 +53,11 @@ module Aquel
|
|
53
53
|
attributes.each do |k, v|
|
54
54
|
if k.kind_of?(Fixnum)
|
55
55
|
items = items.find_all do |item|
|
56
|
-
|
56
|
+
if v[:name] == '='
|
57
|
+
item[k-1] == v[:value]
|
58
|
+
elsif v[:name] == '<>'
|
59
|
+
item[k-1] != v[:value]
|
60
|
+
end
|
57
61
|
end
|
58
62
|
end
|
59
63
|
end
|
@@ -80,14 +84,14 @@ module Aquel
|
|
80
84
|
end
|
81
85
|
end
|
82
86
|
|
83
|
-
def walk(
|
84
|
-
if aexpr['AEXPR']
|
85
|
-
k = expr_value(aexpr['
|
86
|
-
v = expr_value(aexpr['
|
87
|
-
attributes[k] = v
|
88
|
-
elsif aexpr['AEXPR AND']
|
89
|
-
walk(aexpr['
|
90
|
-
walk(aexpr['
|
87
|
+
def walk(node, attributes)
|
88
|
+
if aexpr = node['AEXPR']
|
89
|
+
k = expr_value(aexpr['lexpr'])
|
90
|
+
v = expr_value(aexpr['rexpr'])
|
91
|
+
attributes[k] = { :value => v, :name => aexpr['name'][0] }
|
92
|
+
elsif aexpr = node['AEXPR AND']
|
93
|
+
walk(aexpr['lexpr'], attributes)
|
94
|
+
walk(aexpr['rexpr'], attributes)
|
91
95
|
elsif aexpr['AEXPR OR']
|
92
96
|
raise 'OR clauses are not supported yet'
|
93
97
|
end
|
data/lib/aquel/version.rb
CHANGED
data/spec/aquel_spec.rb
CHANGED
@@ -51,6 +51,11 @@ describe Aquel do
|
|
51
51
|
|
52
52
|
expect(items.size).to eql(1)
|
53
53
|
expect(items.first).to eql(%w/foo1 baz1/)
|
54
|
+
|
55
|
+
items = aquel.execute("select 1,3 from tsv where path = '#{tsv_path}' and 1 != 'foo1'")
|
56
|
+
|
57
|
+
expect(items.size).to eql(1)
|
58
|
+
expect(items.first).to eql(%w/foo2 baz2/)
|
54
59
|
end
|
55
60
|
end
|
56
61
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: aquel
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- youpy
|
@@ -81,6 +81,7 @@ files:
|
|
81
81
|
- Rakefile
|
82
82
|
- aquel.gemspec
|
83
83
|
- lib/aquel.rb
|
84
|
+
- lib/aquel/attributes.rb
|
84
85
|
- lib/aquel/context.rb
|
85
86
|
- lib/aquel/executor.rb
|
86
87
|
- lib/aquel/version.rb
|
@@ -111,7 +112,7 @@ rubyforge_project:
|
|
111
112
|
rubygems_version: 2.2.0.rc.1
|
112
113
|
signing_key:
|
113
114
|
specification_version: 4
|
114
|
-
summary:
|
115
|
+
summary: a(nything) que(ry) l(anguage)
|
115
116
|
test_files:
|
116
117
|
- spec/aquel_spec.rb
|
117
118
|
- spec/spec_helper.rb
|