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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1d570f3f29ad40acd6993c3c732be64c8dc1ccde
4
- data.tar.gz: 437c818aeef70e7bd7388430c00e4b2285d962ae
3
+ metadata.gz: 2fb5d14d2d9c51079d0a5065fd6fd1424cc9cec4
4
+ data.tar.gz: 8c6dc32e9f73c93825a0706ca22496d464105db9
5
5
  SHA512:
6
- metadata.gz: a77dd1859aa1111f34b29fe7f7be2491bee5f08d8f3fe6d9df3817696817c35e202efd878e8e4f5effcc9d595a05930ae034a8a649b4e4eccd647a547d237f0d
7
- data.tar.gz: 8f4053a1ba11c29463c06ba1485101138c2f867686f188ad4565550e512d70d632daad9a88c2a07849bd38f0452c6291cd2758bb64a371fc4daff3708c7f5ace
6
+ metadata.gz: a4a3dbc085dbc59e01095511af4297258bae5b75d0d5828b21263daf2e3a0a3b6c59b6b768f78ed233126fa881b87bbbe18cc126254f23e6965334ac6d95ac72
7
+ data.tar.gz: 8ce222adaa4fb32bb418b15d3d7c232d8a46ffd06b85903b229fabbf4c60ccca9b76126ed89867276a0559363c84c00d28df1919ec4a771070a75ce1126cff6a
@@ -6,12 +6,14 @@ module Dredd
6
6
  module Dsl
7
7
  class Aggregate
8
8
  def execute(collection)
9
- return collection unless @projection
9
+ return collection unless @func
10
10
 
11
- arr = collection.map{|k| Hashie::Mash.new(k) }
12
- .map{|k| k.instance_eval(&@projection) }
13
-
14
- return arr unless @func
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
@@ -1,3 +1,3 @@
1
1
  module Dredd
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
@@ -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)
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.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - jondot