dredd 0.0.1 → 0.0.2
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 +4 -4
- data/lib/dredd/dsl/aggregate.rb +7 -5
- data/lib/dredd/version.rb +1 -1
- data/spec/dredd/query_spec.rb +5 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2fb5d14d2d9c51079d0a5065fd6fd1424cc9cec4
|
4
|
+
data.tar.gz: 8c6dc32e9f73c93825a0706ca22496d464105db9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a4a3dbc085dbc59e01095511af4297258bae5b75d0d5828b21263daf2e3a0a3b6c59b6b768f78ed233126fa881b87bbbe18cc126254f23e6965334ac6d95ac72
|
7
|
+
data.tar.gz: 8ce222adaa4fb32bb418b15d3d7c232d8a46ffd06b85903b229fabbf4c60ccca9b76126ed89867276a0559363c84c00d28df1919ec4a771070a75ce1126cff6a
|
data/lib/dredd/dsl/aggregate.rb
CHANGED
@@ -6,12 +6,14 @@ module Dredd
|
|
6
6
|
module Dsl
|
7
7
|
class Aggregate
|
8
8
|
def execute(collection)
|
9
|
-
return collection unless @
|
9
|
+
return collection unless @func
|
10
10
|
|
11
|
-
arr =
|
12
|
-
|
13
|
-
|
14
|
-
|
11
|
+
arr = if @projection
|
12
|
+
collection.map{|k| Hashie::Mash.new(k) }
|
13
|
+
.map{|k| k.instance_eval(&@projection) }
|
14
|
+
else
|
15
|
+
(0...collection.size).to_a
|
16
|
+
end
|
15
17
|
|
16
18
|
arr.to_scale.send(@func)
|
17
19
|
end
|
data/lib/dredd/version.rb
CHANGED
data/spec/dredd/query_spec.rb
CHANGED
@@ -22,6 +22,11 @@ describe Dredd::Query do
|
|
22
22
|
q.execute([{:foo => 0},{:foo => 0}, {:foo => 60}]).must_equal(20)
|
23
23
|
end
|
24
24
|
|
25
|
+
it "should run aggregations without projection" do
|
26
|
+
q = Dredd::Query.new("all{ foo > 10 }.size")
|
27
|
+
q.execute([{:foo => 1},{:foo => 2}, {:foo => 60}]).must_equal(1)
|
28
|
+
end
|
29
|
+
|
25
30
|
it "should run aggregations on queries" do
|
26
31
|
q = Dredd::Query.new("all{ foo > 10 }.sum{ foo }")
|
27
32
|
q.execute([{:foo => 1},{:foo => 2}, {:foo => 60}]).must_equal(60)
|