dredd 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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2fb5d14d2d9c51079d0a5065fd6fd1424cc9cec4
4
- data.tar.gz: 8c6dc32e9f73c93825a0706ca22496d464105db9
3
+ metadata.gz: b0d4e39388a55b8ef0bf7410e33abcb3c544a577
4
+ data.tar.gz: e1582407cd7fa935bb50e825a790fa75192475cd
5
5
  SHA512:
6
- metadata.gz: a4a3dbc085dbc59e01095511af4297258bae5b75d0d5828b21263daf2e3a0a3b6c59b6b768f78ed233126fa881b87bbbe18cc126254f23e6965334ac6d95ac72
7
- data.tar.gz: 8ce222adaa4fb32bb418b15d3d7c232d8a46ffd06b85903b229fabbf4c60ccca9b76126ed89867276a0559363c84c00d28df1919ec4a771070a75ce1126cff6a
6
+ metadata.gz: 3ee9456d383cefee40908ea2e3b347c63023f2e38610295f95abc9b30ba9ebb47ffd64de2b9ab55a8dcd15f44c43bc028f47c7f16be76b6cb7ff02408ad4e760
7
+ data.tar.gz: 561771d6d4081f68fa0342f800fdca04d244872a9a9901aebd141861e53de348d3482140fd74c94d0b9e2fc3080742ff87666467d576f3295ebba711113c2b91
@@ -1,5 +1,6 @@
1
1
  require 'hashie/mash'
2
2
  require 'statsample'
3
+ require 'dredd/dsl/predicate'
3
4
 
4
5
 
5
6
  module Dredd
@@ -15,7 +16,7 @@ module Dredd
15
16
  (0...collection.size).to_a
16
17
  end
17
18
 
18
- arr.to_scale.send(@func)
19
+ @predicate.execute(arr.to_scale.send(@func))
19
20
  end
20
21
 
21
22
 
@@ -23,6 +24,8 @@ module Dredd
23
24
  if [:sum, :mean, :min, :max, :size].include?(meth)
24
25
  @func = meth
25
26
  @projection = block
27
+ @predicate = Predicate.new
28
+ return @predicate
26
29
  else
27
30
  super
28
31
  end
@@ -0,0 +1,25 @@
1
+ module Dredd
2
+ module Dsl
3
+ class Predicate
4
+ MAP = {
5
+ :is => :==,
6
+ :lt => :<,
7
+ :gt => :>
8
+ }
9
+ def execute(val)
10
+ return val unless @func
11
+ return val.send(*@func)
12
+ end
13
+
14
+
15
+ def method_missing(meth, *args, &block)
16
+ if [:is, :lt, :gt].include?(meth)
17
+ @func = [MAP[meth], *args]
18
+ else
19
+ super
20
+ end
21
+ end
22
+ end
23
+ end
24
+ end
25
+
data/lib/dredd/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Dredd
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
@@ -25,6 +25,9 @@ describe Dredd::Query do
25
25
  it "should run aggregations without projection" do
26
26
  q = Dredd::Query.new("all{ foo > 10 }.size")
27
27
  q.execute([{:foo => 1},{:foo => 2}, {:foo => 60}]).must_equal(1)
28
+
29
+ q = Dredd::Query.new("(all{ foo > 10 }.size.is 0)")
30
+ q.execute([{:foo => 1},{:foo => 2}, {:foo => 60}]).must_equal(false)
28
31
  end
29
32
 
30
33
  it "should run aggregations on queries" do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dredd
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
  - jondot
@@ -110,6 +110,7 @@ files:
110
110
  - dredd.gemspec
111
111
  - lib/dredd.rb
112
112
  - lib/dredd/dsl/aggregate.rb
113
+ - lib/dredd/dsl/predicate.rb
113
114
  - lib/dredd/query.rb
114
115
  - lib/dredd/version.rb
115
116
  - spec/dredd/query_spec.rb