portable 1.0.0.pre.alpha.6 → 1.0.0.pre.alpha.7

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
  SHA256:
3
- metadata.gz: ab583e6beab687062935129db41650e353f23ec7ca2af9c610f49d8ac60a4811
4
- data.tar.gz: 5999aab0a2a8bb37337d0923a2c06bffe9876dd8e8b4b879b799112090b4f393
3
+ metadata.gz: e9a80aeca8e54c0e02bf414ee6c79b6e110e126a57fc64a3a9d3f8990481f940
4
+ data.tar.gz: 7ee0c481c4d15148857726d3644230a76a52f8ae178425c5e1c5defbc485c81b
5
5
  SHA512:
6
- metadata.gz: b485fead56c787bc169135b0c084289fcc690c49a9bface4f5d394c5494ed1139096ea5da5916001a2a845a1817c057f40d8d498d005288958e1792ebfa96b72
7
- data.tar.gz: 93a3912588240c7c3172e06f47d8226627e50016ab9444a43c4d60aa536919542e8cbf35cb6e7369a226e15796b1b25e9af77e168dcb16a3c1a8a6193a8b481b
6
+ metadata.gz: 2e45f20154ff8471104bcdbd5fbbc32d8cf3c892606c077f418b3d29456c8221c080bc7ae2719f63920e54a8f139ad62b2104ecfee1a39699d54467134f6a9be
7
+ data.tar.gz: d11bdfc431b996f82b8f6b14f53862ff98236ad08f6c7e79d87fdd3153137c42bc71687506bf2bfa544a9c1a62e745ba9658a8e1ded37eba3e9e705cb173ed49
@@ -0,0 +1,31 @@
1
+ # frozen_string_literal: true
2
+
3
+ #
4
+ # Copyright (c) 2020-present, Blue Marble Payroll, LLC
5
+ #
6
+ # This source code is licensed under the MIT license found in the
7
+ # LICENSE file in the root directory of this source tree.
8
+ #
9
+
10
+ module Portable
11
+ module Rendering
12
+ class Column # :nodoc: all
13
+ extend Forwardable
14
+
15
+ attr_reader :column, :pipeline
16
+
17
+ def_delegators :column, :header
18
+
19
+ def_delegators :pipeline, :transform
20
+
21
+ def initialize(column, resolver: Objectable.resolver)
22
+ raise ArgumentError, 'column is required' unless column
23
+
24
+ @column = column
25
+ @pipeline = Realize::Pipeline.new(column.transformers, resolver: resolver)
26
+
27
+ freeze
28
+ end
29
+ end
30
+ end
31
+ end
@@ -7,39 +7,36 @@
7
7
  # LICENSE file in the root directory of this source tree.
8
8
  #
9
9
 
10
+ require_relative 'column'
11
+
10
12
  module Portable
11
13
  module Rendering
12
14
  # Internal intermediary class that knows how to combine columns specification
13
15
  # instances with their respective Realize pipelines.
14
16
  class Row # :nodoc: all
15
- attr_reader :column_pipelines, :resolver
17
+ attr_reader :columns, :resolver
16
18
 
17
19
  def initialize(columns, resolver: Objectable.resolver)
18
20
  @resolver = resolver
19
-
20
- @column_pipelines = columns.each_with_object({}) do |column, memo|
21
- memo[column] = Realize::Pipeline.new(column.transformers, resolver: resolver)
22
- end
21
+ @columns = columns.map { |column| Column.new(column, resolver: resolver) }
23
22
 
24
23
  freeze
25
24
  end
26
25
 
27
26
  def render(object, time)
28
- column_pipelines.each_with_object({}) do |(column, pipeline), memo|
29
- memo[column.header] = pipeline.transform(object, time)
30
- end
31
- end
32
-
33
- def columns
34
- column_pipelines.keys
27
+ columns.map { |column| column.transform(object, time) }
35
28
  end
36
29
 
37
30
  def headers
38
31
  columns.map(&:header)
39
32
  end
40
33
 
34
+ def model_columns
35
+ columns.map(&:column)
36
+ end
37
+
41
38
  def merge(other)
42
- self.class.new(columns + other.columns, resolver: resolver)
39
+ self.class.new(model_columns + other.model_columns, resolver: resolver)
43
40
  end
44
41
  end
45
42
  end
@@ -8,5 +8,5 @@
8
8
  #
9
9
 
10
10
  module Portable
11
- VERSION = '1.0.0-alpha.6'
11
+ VERSION = '1.0.0-alpha.7'
12
12
  end
@@ -57,7 +57,7 @@ module Portable
57
57
  csv << row_renderer.headers if sheet.include_headers?
58
58
 
59
59
  data_source.data_rows.each do |row|
60
- csv << row_renderer.render(row, time).values
60
+ csv << row_renderer.render(row, time)
61
61
  end
62
62
  end
63
63
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: portable
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0.pre.alpha.6
4
+ version: 1.0.0.pre.alpha.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matthew Ruggio
@@ -183,6 +183,7 @@ files:
183
183
  - lib/portable/modeling/options.rb
184
184
  - lib/portable/modeling/sheet.rb
185
185
  - lib/portable/rendering.rb
186
+ - lib/portable/rendering/column.rb
186
187
  - lib/portable/rendering/row.rb
187
188
  - lib/portable/rendering/sheet.rb
188
189
  - lib/portable/util.rb