aquel 0.0.2 → 0.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 5cab421bf60cbe9a1db710ef05330cdb68efc011
4
- data.tar.gz: 61ac189a192ef2199e02953b734c9104035e152e
3
+ metadata.gz: feb46cbd8f0d7f2f1f69b1621c633f4e8a5dec9a
4
+ data.tar.gz: 363185ab282a158a3c7cb8e33ace18562d28a24a
5
5
  SHA512:
6
- metadata.gz: 48cacbfc062b88aa76ad03796d44d1d00ff1ef78be30c4ff31640a3f951ce8b90b063b002b9e337699f2f17e3b9f6699d30d5d58e9dff3fa477627b25860a484
7
- data.tar.gz: 101ffd59ef8bdb6b772993b6ce3dd02d6e87bffb3f3fca752d316d2c7e39b4a2ca85ed59c6b6816bd8ac34b42a8a1a024bdf47147c439bc5b371e5b7536ede38
6
+ metadata.gz: cd0b27fe23bdfb2b6301b37bdbb9375253fea21c2d15ccecff4a486b8902096d99ecd4e9d2901aefa50dedc33f2dcb41f2cba663d5479713222dde5a3d53da08
7
+ data.tar.gz: 04213723470351bbff63269c721fc194cfff1eee00510dd9ee08920196e6c79cc93d6cedc7ec9e2a70d37e1e08c98c2fcb2625e0e4114fff8538767d2916e9bf
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # aquel
2
2
 
3
- a(nything) que(ry) l(anguage)
3
+ **a**(nything) **que**(ry) **l**(anguage)
4
4
 
5
5
  ## Installation
6
6
 
@@ -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{A(nything) Q(uery) L(anguage)}
11
+ spec.summary = %q{a(nything) que(ry) l(anguage)}
12
12
  spec.homepage = ""
13
13
  spec.license = "MIT"
14
14
 
@@ -1,3 +1,4 @@
1
+ require "aquel/attributes"
1
2
  require "aquel/context"
2
3
  require "aquel/executor"
3
4
  require "aquel/version"
@@ -0,0 +1,13 @@
1
+ module Aquel
2
+ class Attributes < Hash
3
+ def equal_values
4
+ self.class[
5
+ *(self.find_all do |k, v|
6
+ v[:name] == '='
7
+ end.map do |k, v|
8
+ [k, v[:value]]
9
+ end.flatten)
10
+ ]
11
+ end
12
+ end
13
+ end
@@ -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
- item[k-1] == v
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(aexpr, attributes)
84
- if aexpr['AEXPR']
85
- k = expr_value(aexpr['AEXPR']['lexpr'])
86
- v = expr_value(aexpr['AEXPR']['rexpr'])
87
- attributes[k] = v
88
- elsif aexpr['AEXPR AND']
89
- walk(aexpr['AEXPR AND']['lexpr'], attributes)
90
- walk(aexpr['AEXPR AND']['rexpr'], attributes)
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
@@ -1,3 +1,3 @@
1
1
  module Aquel
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
@@ -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.2
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: A(nything) Q(uery) L(anguage)
115
+ summary: a(nything) que(ry) l(anguage)
115
116
  test_files:
116
117
  - spec/aquel_spec.rb
117
118
  - spec/spec_helper.rb