portable 1.0.0.pre.alpha.7 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +1 -1
- data/CODE_OF_CONDUCT.md +74 -0
- data/README.md +32 -8
- data/lib/portable/data/source.rb +3 -3
- data/lib/portable/modeling/sheet.rb +2 -0
- data/lib/portable/rendering/sheet.rb +7 -7
- data/lib/portable/util/uniqueness.rb +1 -1
- data/lib/portable/version.rb +1 -1
- data/lib/portable/writers/csv.rb +1 -1
- metadata +5 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 563f9b0e89cfa8fecd2346faa4448a88919ee8188c08ddfbcb0dfe0033acf0b6
|
4
|
+
data.tar.gz: 3f3d82c6a9539e93028cf781b72bdd42d3bd753ccb0a6a2018286a3afc71e20f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 511a1e5ccea009b86e5c4f8838945c6d6cadf150709f5f31e6d6163b59431d05a0a2604ecc4686529f8aa505857f55607de4a74510348b20d52c71ec23b559af
|
7
|
+
data.tar.gz: 93c0c1a1480d961fedfe4c46a909b0ecb25958bfcfb55c8dd0575d7318c7575176b0347588c543d1830b22938a22a473283ce78a109378d9926f423a0848c41b
|
data/CHANGELOG.md
CHANGED
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,74 @@
|
|
1
|
+
# Contributor Covenant Code of Conduct
|
2
|
+
|
3
|
+
## Our Pledge
|
4
|
+
|
5
|
+
In the interest of fostering an open and welcoming environment, we as
|
6
|
+
contributors and maintainers pledge to making participation in our project and
|
7
|
+
our community a harassment-free experience for everyone, regardless of age, body
|
8
|
+
size, disability, ethnicity, gender identity and expression, level of experience,
|
9
|
+
nationality, personal appearance, race, religion, or sexual identity and
|
10
|
+
orientation.
|
11
|
+
|
12
|
+
## Our Standards
|
13
|
+
|
14
|
+
Examples of behavior that contributes to creating a positive environment
|
15
|
+
include:
|
16
|
+
|
17
|
+
* Using welcoming and inclusive language
|
18
|
+
* Being respectful of differing viewpoints and experiences
|
19
|
+
* Gracefully accepting constructive criticism
|
20
|
+
* Focusing on what is best for the community
|
21
|
+
* Showing empathy towards other community members
|
22
|
+
|
23
|
+
Examples of unacceptable behavior by participants include:
|
24
|
+
|
25
|
+
* The use of sexualized language or imagery and unwelcome sexual attention or
|
26
|
+
advances
|
27
|
+
* Trolling, insulting/derogatory comments, and personal or political attacks
|
28
|
+
* Public or private harassment
|
29
|
+
* Publishing others' private information, such as a physical or electronic
|
30
|
+
address, without explicit permission
|
31
|
+
* Other conduct which could reasonably be considered inappropriate in a
|
32
|
+
professional setting
|
33
|
+
|
34
|
+
## Our Responsibilities
|
35
|
+
|
36
|
+
Project maintainers are responsible for clarifying the standards of acceptable
|
37
|
+
behavior and are expected to take appropriate and fair corrective action in
|
38
|
+
response to any instances of unacceptable behavior.
|
39
|
+
|
40
|
+
Project maintainers have the right and responsibility to remove, edit, or
|
41
|
+
reject comments, commits, code, wiki edits, issues, and other contributions
|
42
|
+
that are not aligned to this Code of Conduct, or to ban temporarily or
|
43
|
+
permanently any contributor for other behaviors that they deem inappropriate,
|
44
|
+
threatening, offensive, or harmful.
|
45
|
+
|
46
|
+
## Scope
|
47
|
+
|
48
|
+
This Code of Conduct applies both within project spaces and in public spaces
|
49
|
+
when an individual is representing the project or its community. Examples of
|
50
|
+
representing a project or community include using an official project e-mail
|
51
|
+
address, posting via an official social media account, or acting as an appointed
|
52
|
+
representative at an online or offline event. Representation of a project may be
|
53
|
+
further defined and clarified by project maintainers.
|
54
|
+
|
55
|
+
## Enforcement
|
56
|
+
|
57
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
58
|
+
reported by contacting the project team at oss@bluemarblepayroll.com. All
|
59
|
+
complaints will be reviewed and investigated and will result in a response that
|
60
|
+
is deemed necessary and appropriate to the circumstances. The project team is
|
61
|
+
obligated to maintain confidentiality with regard to the reporter of an incident.
|
62
|
+
Further details of specific enforcement policies may be posted separately.
|
63
|
+
|
64
|
+
Project maintainers who do not follow or enforce the Code of Conduct in good
|
65
|
+
faith may face temporary or permanent repercussions as determined by other
|
66
|
+
members of the project's leadership.
|
67
|
+
|
68
|
+
## Attribution
|
69
|
+
|
70
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
|
71
|
+
available at [http://contributor-covenant.org/version/1/4][version]
|
72
|
+
|
73
|
+
[homepage]: http://contributor-covenant.org
|
74
|
+
[version]: http://contributor-covenant.org/version/1/4/
|
data/README.md
CHANGED
@@ -35,7 +35,7 @@ patients = [
|
|
35
35
|
data_provider = Portable::Data::Provider.new(
|
36
36
|
data_sources: {
|
37
37
|
data_rows: patients,
|
38
|
-
|
38
|
+
keys: %i[first last dob]
|
39
39
|
}
|
40
40
|
)
|
41
41
|
````
|
@@ -50,7 +50,7 @@ document = nil # or {} or Portable::Document.new
|
|
50
50
|
|
51
51
|
The above document says I would like a document with one sheet, and since I did not provide a data_table specification, I would like all the fields emitted from the data source.
|
52
52
|
|
53
|
-
Combining a document + writer + data provider yields a set of documents
|
53
|
+
Combining a document + writer + data provider yields a set of documents. It may emit more than one file if the writer does not know how to write intra-file sheets (i.e. CSV files).
|
54
54
|
|
55
55
|
````ruby
|
56
56
|
writer = Portable::Writers::Csv.new(document)
|
@@ -72,6 +72,18 @@ This library uses Realize under the hood, so you have the option of configuring
|
|
72
72
|
Let's expand our CSV example above with different headers and date formatting:
|
73
73
|
|
74
74
|
````ruby
|
75
|
+
patients = [
|
76
|
+
{ first: 'Marky', last: 'Mark', dob: '2000-04-05' },
|
77
|
+
{ first: 'Frank', last: 'Rizzo', dob: '1930-09-22' }
|
78
|
+
]
|
79
|
+
|
80
|
+
data_provider = Portable::Data::Provider.new(
|
81
|
+
data_sources: {
|
82
|
+
data_rows: patients,
|
83
|
+
keys: %i[first last dob]
|
84
|
+
}
|
85
|
+
)
|
86
|
+
|
75
87
|
document = {
|
76
88
|
sheets: [
|
77
89
|
{
|
@@ -101,14 +113,20 @@ document = {
|
|
101
113
|
}
|
102
114
|
]
|
103
115
|
}
|
116
|
+
|
117
|
+
writer = Portable::Writers::Csv.new(document)
|
118
|
+
name = File.join('tmp', 'patients.csv')
|
119
|
+
written = writer.write!(filename: name, data_provider: data_provider)
|
104
120
|
````
|
105
121
|
|
106
122
|
Executing it the same way would now yield a different CSV file:
|
107
123
|
|
124
|
+
````
|
108
125
|
First Name | Last Name | Date of Birth
|
109
126
|
---------- | --------- | -------------
|
110
127
|
Marky | Mark | 04/05/2000
|
111
128
|
Frank | Rizzo | 09/22/1930
|
129
|
+
````
|
112
130
|
|
113
131
|
Realize is also [pluggable](https://github.com/bluemarblepayroll/realize#plugging-in-transformers), so you are able to create your own and plug them directly into Realize.
|
114
132
|
|
@@ -120,7 +138,7 @@ Each writer can choose how and which options to support.
|
|
120
138
|
|
121
139
|
The following options are available for customizing CSV documents:
|
122
140
|
|
123
|
-
* byte_order_mark: (optional, default is nothing): This option will write out a byte order mark identifying the
|
141
|
+
* byte_order_mark: (optional, default is nothing): This option will write out a [byte order mark](https://en.wikipedia.org/wiki/Byte_order_mark) identifying the endianess for the file. This is useful for ensuring applications like Microsoft Excel open CSV files properly. See Portable::Modeling::ByteOrderMark constants for acceptable values.
|
124
142
|
|
125
143
|
### Static Header/Footer Rows
|
126
144
|
|
@@ -135,7 +153,7 @@ patients = [
|
|
135
153
|
data_provider = Portable::Data::Provider.new(
|
136
154
|
data_sources: {
|
137
155
|
data_rows: patients,
|
138
|
-
|
156
|
+
keys: %i[first last dob],
|
139
157
|
header_rows: [
|
140
158
|
%w[FIRST_START LAST_START DOB_START]
|
141
159
|
],
|
@@ -160,6 +178,10 @@ document = {
|
|
160
178
|
}
|
161
179
|
]
|
162
180
|
}
|
181
|
+
|
182
|
+
writer = Portable::Writers::Csv.new(document)
|
183
|
+
name = File.join('tmp', 'patients.csv')
|
184
|
+
written = writer.write!(filename: name, data_provider: data_provider)
|
163
185
|
````
|
164
186
|
|
165
187
|
Using this document configuration would yield a CSV with four "header rows" at the top, one "data table header row", two data rows, and one "footer row". This is not easily illustrated in Markdown, but this would be the result:
|
@@ -169,10 +191,12 @@ Run Date | 04/05/2000
|
|
169
191
|
Run By | Hops the Bunny
|
170
192
|
|
171
193
|
BEGIN
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
194
|
+
FIRST_START | LAST_START | DOB_START
|
195
|
+
first | last | dob
|
196
|
+
----------- | ---------- | -------------
|
197
|
+
Marky | Mark | 2000-04-05
|
198
|
+
Frank | Rizzo | 1930-09-22
|
199
|
+
FIRST_END | LAST_END | DOB_END
|
176
200
|
END
|
177
201
|
````
|
178
202
|
|
data/lib/portable/data/source.rb
CHANGED
@@ -19,17 +19,17 @@ module Portable
|
|
19
19
|
attr_reader :header_rows,
|
20
20
|
:footer_rows,
|
21
21
|
:data_rows,
|
22
|
-
:
|
22
|
+
:keys,
|
23
23
|
:name
|
24
24
|
|
25
25
|
# Individial header and footer rows are arrays, while individual data_rows is an object
|
26
26
|
# like a hash, Struct, OpenStruct, or really any PORO.
|
27
|
-
def initialize(name: '', header_rows: [], footer_rows: [], data_rows: [],
|
27
|
+
def initialize(name: '', header_rows: [], footer_rows: [], data_rows: [], keys: [])
|
28
28
|
@name = name.to_s
|
29
29
|
@header_rows = header_rows || []
|
30
30
|
@footer_rows = footer_rows || []
|
31
31
|
@data_rows = data_rows || []
|
32
|
-
@
|
32
|
+
@keys = keys || []
|
33
33
|
|
34
34
|
freeze
|
35
35
|
end
|
@@ -27,26 +27,26 @@ module Portable
|
|
27
27
|
freeze
|
28
28
|
end
|
29
29
|
|
30
|
-
def row_renderer(sheet_name,
|
30
|
+
def row_renderer(sheet_name, keys)
|
31
31
|
sheet = document.sheet(sheet_name)
|
32
32
|
row_renderer = row_renderers.fetch(sheet_name.to_s)
|
33
33
|
|
34
34
|
return row_renderer unless sheet.auto?
|
35
35
|
|
36
|
-
dynamic_row_renderer(
|
36
|
+
dynamic_row_renderer(keys).merge(row_renderer)
|
37
37
|
end
|
38
38
|
|
39
39
|
private
|
40
40
|
|
41
41
|
attr_reader :row_renderers
|
42
42
|
|
43
|
-
def fields_to_columns(
|
44
|
-
|
45
|
-
Modeling::Column.array(
|
43
|
+
def fields_to_columns(keys)
|
44
|
+
key_objects = (keys || []).map { |f| { header: f.to_s } }
|
45
|
+
Modeling::Column.array(key_objects)
|
46
46
|
end
|
47
47
|
|
48
|
-
def dynamic_row_renderer(
|
49
|
-
Row.new(fields_to_columns(
|
48
|
+
def dynamic_row_renderer(keys)
|
49
|
+
Row.new(fields_to_columns(keys), resolver: resolver)
|
50
50
|
end
|
51
51
|
end
|
52
52
|
end
|
data/lib/portable/version.rb
CHANGED
data/lib/portable/writers/csv.rb
CHANGED
@@ -52,7 +52,7 @@ module Portable
|
|
52
52
|
end
|
53
53
|
|
54
54
|
def write_data_table(csv, sheet, data_source, time)
|
55
|
-
row_renderer = sheet_renderer.row_renderer(sheet.name, data_source.
|
55
|
+
row_renderer = sheet_renderer.row_renderer(sheet.name, data_source.keys)
|
56
56
|
|
57
57
|
csv << row_renderer.headers if sheet.include_headers?
|
58
58
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: portable
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.0
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Matthew Ruggio
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-08-
|
11
|
+
date: 2020-08-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: acts_as_hashable
|
@@ -165,6 +165,7 @@ files:
|
|
165
165
|
- ".ruby-version"
|
166
166
|
- ".travis.yml"
|
167
167
|
- CHANGELOG.md
|
168
|
+
- CODE_OF_CONDUCT.md
|
168
169
|
- Gemfile
|
169
170
|
- Guardfile
|
170
171
|
- LICENSE
|
@@ -215,9 +216,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
215
216
|
version: '2.5'
|
216
217
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
217
218
|
requirements:
|
218
|
-
- - "
|
219
|
+
- - ">="
|
219
220
|
- !ruby/object:Gem::Version
|
220
|
-
version:
|
221
|
+
version: '0'
|
221
222
|
requirements: []
|
222
223
|
rubygems_version: 3.0.3
|
223
224
|
signing_key:
|