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 +4 -4
- data/lib/portable/rendering/column.rb +31 -0
- data/lib/portable/rendering/row.rb +10 -13
- data/lib/portable/version.rb +1 -1
- data/lib/portable/writers/csv.rb +1 -1
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e9a80aeca8e54c0e02bf414ee6c79b6e110e126a57fc64a3a9d3f8990481f940
|
4
|
+
data.tar.gz: 7ee0c481c4d15148857726d3644230a76a52f8ae178425c5e1c5defbc485c81b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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 :
|
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
|
-
|
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(
|
39
|
+
self.class.new(model_columns + other.model_columns, resolver: resolver)
|
43
40
|
end
|
44
41
|
end
|
45
42
|
end
|
data/lib/portable/version.rb
CHANGED
data/lib/portable/writers/csv.rb
CHANGED
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.
|
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
|