streamer 0.1.1 → 0.2.0

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: 90dbc68e3c8adf372f06c4381cc35b74dc080534
4
- data.tar.gz: 71c4278b1e1aac8d7b7f602f4102758207f9cdfe
3
+ metadata.gz: 2ec94108449b6143b468bc841cf65296564d1273
4
+ data.tar.gz: b1dd939f742f67d21ebbff7498f9506244bc254c
5
5
  SHA512:
6
- metadata.gz: bdc5d83f093256515d60679c91d419d3d9c8a26ddf889bd8c47a36ba0dcd200fa7c63d1c82a9a344248dc8605cf2d66208960264ab4bdd538cbd8358dfec448a
7
- data.tar.gz: edcc7555b28a958055e362fcde5dbc27004e94b209ed864eb34ef16ac5e1b1ae8b7fadfb75f5c676a5998ef68d252e31e41ba8bcde7c125638f95be592f2a25e
6
+ metadata.gz: 96a144b31e30015954ae677574b6b65b5dc72610e097af4bdcc094625aab92b4c24d2d727aa07b881c56c1c4d332554a1eeac8f1b6729c86ab2ebc608a0e7448
7
+ data.tar.gz: f70c324ca3ccbaee3e894707b8e9bfb4056efb2ae3a0a7633da85ef6f7754b4f75c8b6838b3a1d75c953bdbfbb2b5d548b523d3453491949df3f7d498f055fee
@@ -3,7 +3,7 @@ module Streamer
3
3
  # Count provides the number of items in a list
4
4
  class Count < Functor
5
5
  def call
6
- payload[options.fetch(:list)].size
6
+ list.size
7
7
  end
8
8
  end
9
9
  end
@@ -85,6 +85,24 @@ module Streamer
85
85
  def property
86
86
  options[:property]
87
87
  end
88
+
89
+ def list_definition
90
+ options.fetch(:list)
91
+ end
92
+
93
+ def list
94
+ return list_from_value unless list_definition[:value].nil?
95
+ return list_from_function unless list_definition[:function].nil?
96
+ fail 'Streamer::Functors - no list given'
97
+ end
98
+
99
+ def list_from_value
100
+ payload[list_definition[:value]]
101
+ end
102
+
103
+ def list_from_function
104
+ functor(list_definition[:function]).call
105
+ end
88
106
  end
89
107
  end
90
108
  end
@@ -7,7 +7,6 @@ module Streamer
7
7
  end
8
8
 
9
9
  def group
10
- list = options.fetch(:list)
11
10
  group_key = options.fetch(:by)
12
11
  operand_key = options.fetch(:operand)
13
12
  operator = options.fetch(:operator).to_sym
@@ -15,7 +14,7 @@ module Streamer
15
14
  end
16
15
 
17
16
  def accumulate(list, group_key, operand_key, operator)
18
- payload[list].each_with_object({}) do |item, val|
17
+ list.each_with_object({}) do |item, val|
19
18
  val[item[group_key]] =
20
19
  (val[item[group_key]] || 0.0).send(
21
20
  operator,
@@ -3,11 +3,7 @@ module Streamer
3
3
  # least determines the least item in a list
4
4
  class Least < Functor
5
5
  def call
6
- least
7
- end
8
-
9
- def least
10
- vals = value(options.fetch(:list).split('.')).map do |item|
6
+ vals = list.map do |item|
11
7
  item[options.fetch(:property)]
12
8
  end
13
9
  vals.sort.shift
@@ -3,14 +3,11 @@ module Streamer
3
3
  # Sum sums the list using the property provided
4
4
  class Sum < Functor
5
5
  def call
6
- sum
7
- end
8
-
9
- def sum
10
- payload[options.fetch(:list)].inject(0.0) do |total, item|
6
+ list.inject(0.0) do |total, item|
11
7
  total + item[options.fetch(:property)]
12
8
  end
13
9
  end
10
+
14
11
  end
15
12
  end
16
13
  end
@@ -1,4 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
  module Streamer
3
- VERSION = '0.1.1'.freeze
3
+ VERSION = '0.2.0'.freeze
4
4
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: streamer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Scott Helm
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-02-09 00:00:00.000000000 Z
11
+ date: 2016-02-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler