portable 1.0.0.pre.alpha.2 → 1.0.0.pre.alpha.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/portable.rb +4 -0
- data/lib/portable/data/provider.rb +5 -1
- data/lib/portable/document.rb +3 -0
- data/lib/portable/uniqueness.rb +23 -0
- data/lib/portable/version.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: 32da634ac58591d5130ab01ddb7e6953144f663b563fdce844817473db370bde
|
4
|
+
data.tar.gz: c7b6ded1144b5cdb46ab702a5d23480d4a778b4bfa134c21f4ae884bf1ecc220
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b3cbe61597e5ea310d8084cafcaea7cf75476d969e5ad833ee140397d92cfe9d7c2baf2f5d930754f1870dd1f1b757f91562d79bfdee74e870670f21c981712f
|
7
|
+
data.tar.gz: 3a101c3f5c3467060cfe7b237efec41e51435d0fe0941a753d6e6b03ba776b99f8aad1845d62015e6cf54a6bbd464902414f8bd0128d7c3cbc8682afd4d084bc
|
data/lib/portable.rb
CHANGED
@@ -15,6 +15,10 @@ require 'objectable'
|
|
15
15
|
require 'realize'
|
16
16
|
require 'time'
|
17
17
|
|
18
|
+
# Shared modules/classes
|
19
|
+
require_relative 'portable/uniqueness'
|
20
|
+
|
21
|
+
# Main implementation points
|
18
22
|
require_relative 'portable/data'
|
19
23
|
require_relative 'portable/document'
|
20
24
|
require_relative 'portable/rendering'
|
@@ -14,10 +14,14 @@ module Portable
|
|
14
14
|
# Container of data sources that is inputted into a writer alongside a document.
|
15
15
|
# It contains all the data sources the writer will use to render a document.
|
16
16
|
class Provider
|
17
|
+
include Uniqueness
|
17
18
|
acts_as_hashable
|
18
19
|
|
19
20
|
def initialize(data_sources: [])
|
20
|
-
|
21
|
+
sources = Source.array(data_sources)
|
22
|
+
@data_sources_by_name = pivot_by_name(sources)
|
23
|
+
|
24
|
+
assert_no_duplicate_names(sources)
|
21
25
|
|
22
26
|
freeze
|
23
27
|
end
|
data/lib/portable/document.rb
CHANGED
@@ -13,6 +13,7 @@ require_relative 'modeling/sheet'
|
|
13
13
|
module Portable
|
14
14
|
# Top-level object model for a renderable document.
|
15
15
|
class Document
|
16
|
+
include Uniqueness
|
16
17
|
acts_as_hashable
|
17
18
|
|
18
19
|
attr_reader :sheets, :options
|
@@ -22,6 +23,8 @@ module Portable
|
|
22
23
|
@sheets << Modeling::Sheet.new if @sheets.empty?
|
23
24
|
@options = Modeling::Options.make(options)
|
24
25
|
|
26
|
+
assert_no_duplicate_names(@sheets)
|
27
|
+
|
25
28
|
freeze
|
26
29
|
end
|
27
30
|
end
|
@@ -0,0 +1,23 @@
|
|
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
|
+
# Mixes in helpers for asserting uniqueness across collections
|
12
|
+
module Uniqueness
|
13
|
+
class DuplicateNameError < StandardError; end
|
14
|
+
|
15
|
+
def assert_no_duplicate_names(array)
|
16
|
+
names = array.map { |a| a.name.downcase }
|
17
|
+
|
18
|
+
return if names.uniq.length == array.length
|
19
|
+
|
20
|
+
raise DuplicateNameError, "cannot contain duplicate names: #{names}"
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
data/lib/portable/version.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.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Matthew Ruggio
|
@@ -185,6 +185,7 @@ files:
|
|
185
185
|
- lib/portable/rendering.rb
|
186
186
|
- lib/portable/rendering/row.rb
|
187
187
|
- lib/portable/rendering/sheet.rb
|
188
|
+
- lib/portable/uniqueness.rb
|
188
189
|
- lib/portable/version.rb
|
189
190
|
- lib/portable/writers.rb
|
190
191
|
- lib/portable/writers/base.rb
|