proforma 1.0.0.pre.alpha → 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 +6 -2
- data/Gemfile.lock +1 -1
- data/README.md +25 -23
- data/bin/console +7 -0
- data/bin/render +8 -3
- data/lib/proforma.rb +2 -5
- data/lib/proforma/compiling/aggregation.rb +3 -1
- data/lib/proforma/compiling/counter.rb +2 -0
- data/lib/proforma/hash_evaluator.rb +4 -8
- data/lib/proforma/hash_refinements.rb +20 -0
- data/lib/proforma/model_factory.rb +2 -0
- data/lib/proforma/modeling.rb +1 -0
- data/lib/proforma/modeling/data_table.rb +1 -1
- data/lib/proforma/modeling/generic_container.rb +1 -3
- data/lib/proforma/type_factory.rb +2 -0
- data/lib/proforma/version.rb +1 -1
- data/spec/fixtures/bringing_it_all_together.txt +42 -0
- data/spec/fixtures/snapshots/custom_table.yml +4 -4
- data/spec/fixtures/snapshots/user_details.yml +5 -5
- data/spec/fixtures/snapshots/user_list.yml +12 -12
- data/spec/proforma/compiling/counter_spec.rb +16 -0
- data/spec/proforma_spec.rb +15 -26
- data/spec/spec_helper.rb +5 -3
- metadata +9 -5
- data/lib/proforma/core_ext/hash.rb +0 -21
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 817f85bba720714f1805a67d79a890f4c54348c5960b2bbe5ada6cf580dd9895
|
4
|
+
data.tar.gz: 40a77e4fe0c8db140eedaa3a1632abcb43a5e5f94fb366126dd9eda6b7324eb6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ee6d3dc842c7c75a43df463508d61228adc55683b439f846f35adbf487be59cd45bb517773609f45f58ae7a4441707a02dd64fc6a468d1e945ac66a38575f206
|
7
|
+
data.tar.gz: ff63785b94954ab0e21a725d98279d384d3d39912cdaf2c2184116d45ded4d85cc888191947f3f15ad4d7ce9a0023fd487c5998879121bdedb45c527d86c47b6
|
data/CHANGELOG.md
CHANGED
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -8,25 +8,25 @@ Proforma is a Ruby-based document rendering framework with a focus on being:
|
|
8
8
|
2. Simple: basic set of controls that limit flexibility but increase simplicity and standardization
|
9
9
|
3. Extendable: different value resolvers and document rendering engines can be plugged in
|
10
10
|
|
11
|
-
The basic premise is you input a dataset and a template and Proforma:
|
11
|
+
The basic premise is you input a dataset and a template and Proforma will:
|
12
12
|
|
13
|
-
1. Evaluate and data-bind each component
|
14
|
-
2. Render as a file
|
13
|
+
1. Evaluate and data-bind each component.
|
14
|
+
2. Render given data and template as a file.
|
15
15
|
|
16
16
|
When a component is in the process of being data-bound it will be evaluated against the current data being read. The evaluator serves two purposes:
|
17
17
|
|
18
|
-
1. Given a record and an expression, find me a raw value (resolving)
|
19
|
-
2. Given a record and an expression, return me a formatted string-based value (text templating)
|
18
|
+
1. Given a record and an expression, find me a raw value (resolving.)
|
19
|
+
2. Given a record and an expression, return me a formatted string-based value (text templating.)
|
20
20
|
|
21
21
|
The basic evaluator that comes with this library is Proforma::HashEvaluator. It is limited to:
|
22
22
|
|
23
|
-
1.
|
24
|
-
2.
|
23
|
+
1. Only resolving values for hash objects and cannot handle nesting / recursion / dot notation.
|
24
|
+
2. Only text templating simple expressions: if the expression starts with a `$` then it is noted as being a data-bound value. The value proceeding the `$` will be resolved and returned. If it does not begin with this special string then the value following the $ will be resolved and returned.
|
25
25
|
|
26
26
|
Other libraries that can be plugged in, such as:
|
27
27
|
|
28
|
-
1. [
|
29
|
-
2. [
|
28
|
+
1. [proforma-extended-evaluator](https://github.com/bluemarblepayroll/proforma-extended-evaluator): adds nested dot-notation object value resolution and rich text templating.
|
29
|
+
2. [proforma-prawn-renderer](https://github.com/bluemarblepayroll/proforma-prawn-renderer): adds PDF rendering.
|
30
30
|
|
31
31
|
See the libraries respective README files for more information.
|
32
32
|
|
@@ -80,9 +80,9 @@ template = {
|
|
80
80
|
{
|
81
81
|
type: 'DataTable',
|
82
82
|
columns: [
|
83
|
-
{ header: 'ID Number', body: '
|
84
|
-
{ header: 'First Name', body: '
|
85
|
-
{ header: 'Last Name', body: '
|
83
|
+
{ header: 'ID Number', body: '$id' },
|
84
|
+
{ header: 'First Name', body: '$first' },
|
85
|
+
{ header: 'Last Name', body: '$last' }
|
86
86
|
]
|
87
87
|
}
|
88
88
|
]
|
@@ -125,13 +125,13 @@ template = {
|
|
125
125
|
columns: [
|
126
126
|
{
|
127
127
|
lines: [
|
128
|
-
{ label: 'ID Number', value: '
|
129
|
-
{ label: 'First Name', value: '
|
128
|
+
{ label: 'ID Number', value: '$id' },
|
129
|
+
{ label: 'First Name', value: '$first' }
|
130
130
|
]
|
131
131
|
},
|
132
132
|
{
|
133
133
|
lines: [
|
134
|
-
{ label: 'Last Name', value: '
|
134
|
+
{ label: 'Last Name', value: '$last' }
|
135
135
|
]
|
136
136
|
}
|
137
137
|
]
|
@@ -211,9 +211,9 @@ template = {
|
|
211
211
|
{
|
212
212
|
type: 'DataTable',
|
213
213
|
columns: [
|
214
|
-
{ header: 'ID Number', body: '
|
215
|
-
{ header: 'First Name', body: '
|
216
|
-
{ header: 'Last Name', body: '
|
214
|
+
{ header: 'ID Number', body: '$id' },
|
215
|
+
{ header: 'First Name', body: '$first' },
|
216
|
+
{ header: 'Last Name', body: '$last' }
|
217
217
|
]
|
218
218
|
},
|
219
219
|
{ type: 'Spacer' },
|
@@ -228,13 +228,13 @@ template = {
|
|
228
228
|
columns: [
|
229
229
|
{
|
230
230
|
lines: [
|
231
|
-
{ label: 'ID Number', value: '
|
232
|
-
{ label: 'First Name', value: '
|
231
|
+
{ label: 'ID Number', value: '$id' },
|
232
|
+
{ label: 'First Name', value: '$first' }
|
233
233
|
]
|
234
234
|
},
|
235
235
|
{
|
236
236
|
lines: [
|
237
|
-
{ label: 'Last Name', value: '
|
237
|
+
{ label: 'Last Name', value: '$last' }
|
238
238
|
]
|
239
239
|
}
|
240
240
|
]
|
@@ -243,8 +243,8 @@ template = {
|
|
243
243
|
type: 'DataTable',
|
244
244
|
property: 'phone_numbers',
|
245
245
|
columns: [
|
246
|
-
{ header: 'Type', body: '
|
247
|
-
{ header: 'Number', body: '
|
246
|
+
{ header: 'Type', body: '$type' },
|
247
|
+
{ header: 'Number', body: '$number' }
|
248
248
|
]
|
249
249
|
},
|
250
250
|
{ type: 'Spacer' }
|
@@ -275,6 +275,8 @@ The `contents` attribute will now contain:
|
|
275
275
|
* user details pane (one per user)
|
276
276
|
* user phone numbers table (one per user)
|
277
277
|
|
278
|
+
The full contents can be seen in [this fixture file](https://github.com/bluemarblepayroll/proforma/blob/master/spec/fixtures/bringing_it_all_together.txt).
|
279
|
+
|
278
280
|
## Contributing
|
279
281
|
|
280
282
|
### Development Environment Configuration
|
data/bin/console
CHANGED
@@ -1,6 +1,13 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
# frozen_string_literal: true
|
3
3
|
|
4
|
+
#
|
5
|
+
# Copyright (c) 2018-present, Blue Marble Payroll, LLC
|
6
|
+
#
|
7
|
+
# This source code is licensed under the MIT license found in the
|
8
|
+
# LICENSE file in the root directory of this source tree.
|
9
|
+
#
|
10
|
+
|
4
11
|
require 'bundler/setup'
|
5
12
|
require 'proforma'
|
6
13
|
|
data/bin/render
CHANGED
@@ -1,6 +1,13 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
# frozen_string_literal: true
|
3
3
|
|
4
|
+
#
|
5
|
+
# Copyright (c) 2018-present, Blue Marble Payroll, LLC
|
6
|
+
#
|
7
|
+
# This source code is licensed under the MIT license found in the
|
8
|
+
# LICENSE file in the root directory of this source tree.
|
9
|
+
#
|
10
|
+
|
4
11
|
require 'bundler/setup'
|
5
12
|
require 'proforma'
|
6
13
|
require 'fileutils'
|
@@ -8,9 +15,7 @@ require 'yaml'
|
|
8
15
|
require 'pry'
|
9
16
|
|
10
17
|
def read_yaml(filename)
|
11
|
-
|
12
|
-
YAML.load(read(filename))
|
13
|
-
# rubocop:enable Security/YAMLLoad
|
18
|
+
YAML.safe_load(read(filename))
|
14
19
|
end
|
15
20
|
|
16
21
|
def read(filename)
|
data/lib/proforma.rb
CHANGED
@@ -12,19 +12,16 @@ require 'bigdecimal'
|
|
12
12
|
require 'forwardable'
|
13
13
|
require 'stringio'
|
14
14
|
|
15
|
-
# Monkey-patching core libaries
|
16
|
-
require_relative 'proforma/core_ext/hash'
|
17
|
-
Hash.include ::Proforma::CoreExt::Hash
|
18
|
-
|
19
15
|
require_relative 'proforma/compiling'
|
20
16
|
require_relative 'proforma/document'
|
21
17
|
require_relative 'proforma/hash_evaluator'
|
18
|
+
require_relative 'proforma/hash_refinements'
|
19
|
+
require_relative 'proforma/model_factory'
|
22
20
|
require_relative 'proforma/modeling'
|
23
21
|
require_relative 'proforma/plain_text_renderer'
|
24
22
|
require_relative 'proforma/prototype'
|
25
23
|
require_relative 'proforma/template'
|
26
24
|
require_relative 'proforma/type_factory'
|
27
|
-
require_relative 'proforma/model_factory'
|
28
25
|
|
29
26
|
# The top-level API that should be seen as the main entry point into this library.
|
30
27
|
module Proforma
|
@@ -19,6 +19,8 @@ module Proforma
|
|
19
19
|
@aggregators = Array(aggregators)
|
20
20
|
@counters = {}
|
21
21
|
@evaluator = evaluator
|
22
|
+
|
23
|
+
freeze
|
22
24
|
end
|
23
25
|
|
24
26
|
def add(records)
|
@@ -35,7 +37,7 @@ module Proforma
|
|
35
37
|
self
|
36
38
|
end
|
37
39
|
|
38
|
-
def
|
40
|
+
def to_h
|
39
41
|
aggregators.map { |aggregator| execute(aggregator) }.to_h
|
40
42
|
end
|
41
43
|
|
@@ -14,24 +14,20 @@ module Proforma
|
|
14
14
|
# This, being a prototype for customizable evaluators, just provides basic evaluation:
|
15
15
|
# - it can only handle hashes for value extraction
|
16
16
|
# - if text is prefixed with a dollar sign and colon then it means it will be dynamically
|
17
|
-
# evaluated against the record. For example:
|
17
|
+
# evaluated against the record. For example: $id
|
18
18
|
class HashEvaluator
|
19
|
-
PROPERTY_PREFIX = '
|
19
|
+
PROPERTY_PREFIX = '$'
|
20
20
|
|
21
21
|
def value(object, expression)
|
22
22
|
return object if expression.to_s.empty?
|
23
23
|
return nil unless object.is_a?(Hash)
|
24
24
|
|
25
|
-
|
26
|
-
object[expression.to_s]
|
27
|
-
elsif object.key?(expression.to_s.to_sym)
|
28
|
-
object[expression.to_s.to_sym]
|
29
|
-
end
|
25
|
+
object[expression.to_s] || object[expression.to_s.to_sym]
|
30
26
|
end
|
31
27
|
|
32
28
|
def text(object, expression)
|
33
29
|
if expression.to_s.start_with?(PROPERTY_PREFIX)
|
34
|
-
value(object, expression.to_s[
|
30
|
+
value(object, expression.to_s[PROPERTY_PREFIX.length..-1])
|
35
31
|
else
|
36
32
|
expression
|
37
33
|
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
#
|
4
|
+
# Copyright (c) 2019-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 Proforma
|
11
|
+
# Let's provide a refinenment instead of monkey-patching Hash. That way we can stop
|
12
|
+
# polluting other libraries and internalize our specific needs.
|
13
|
+
module HashRefinements
|
14
|
+
refine Hash do
|
15
|
+
def symbolize_keys
|
16
|
+
map { |k, v| [k.to_sym, v] }.to_h
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
data/lib/proforma/modeling.rb
CHANGED
@@ -40,9 +40,7 @@ module Proforma
|
|
40
40
|
def compile(data, evaluator)
|
41
41
|
compiled_children = children.map { |child| child.compile(data, evaluator) }
|
42
42
|
|
43
|
-
|
44
|
-
|
45
|
-
self.class.new(args)
|
43
|
+
self.class.new(child_key => compiled_children)
|
46
44
|
end
|
47
45
|
|
48
46
|
private
|
data/lib/proforma/version.rb
CHANGED
@@ -0,0 +1,42 @@
|
|
1
|
+
========================================
|
2
|
+
System A
|
3
|
+
========================================
|
4
|
+
555 N. Michigan Ave.
|
5
|
+
Chicago, IL 55555
|
6
|
+
555-555-5555 ext. 5132
|
7
|
+
========================================
|
8
|
+
USER LIST
|
9
|
+
----------------------------------------
|
10
|
+
|
11
|
+
ID Number, First Name, Last Name
|
12
|
+
1, Matt, Smith
|
13
|
+
2, Katie, Rizzo
|
14
|
+
3, Nathan, Nathanson
|
15
|
+
|
16
|
+
USER DETAILS
|
17
|
+
----------------------------------------
|
18
|
+
|
19
|
+
ID Number: 1
|
20
|
+
First Name: Matt
|
21
|
+
Last Name: Smith
|
22
|
+
Type, Number
|
23
|
+
Mobile, 444-333-2222
|
24
|
+
Home, 444-333-2222
|
25
|
+
|
26
|
+
USER DETAILS
|
27
|
+
----------------------------------------
|
28
|
+
|
29
|
+
ID Number: 2
|
30
|
+
First Name: Katie
|
31
|
+
Last Name: Rizzo
|
32
|
+
Type, Number
|
33
|
+
Fax, 888-777-6666
|
34
|
+
|
35
|
+
USER DETAILS
|
36
|
+
----------------------------------------
|
37
|
+
|
38
|
+
ID Number: 3
|
39
|
+
First Name: Nathan
|
40
|
+
Last Name: Nathanson
|
41
|
+
Type, Number
|
42
|
+
|
@@ -34,14 +34,14 @@ template:
|
|
34
34
|
rows:
|
35
35
|
- cells:
|
36
36
|
- text: ID Number
|
37
|
-
- text:
|
37
|
+
- text: $id
|
38
38
|
- text: Username
|
39
|
-
- text:
|
39
|
+
- text: $username
|
40
40
|
- cells:
|
41
41
|
- text: First Name
|
42
|
-
- text:
|
42
|
+
- text: $first
|
43
43
|
- text: Last Name
|
44
|
-
- text:
|
44
|
+
- text: $last
|
45
45
|
|
46
46
|
documents:
|
47
47
|
- title: Custom Table
|
@@ -38,11 +38,11 @@ template:
|
|
38
38
|
- label_width: 25.0
|
39
39
|
lines:
|
40
40
|
- label: ID Number
|
41
|
-
value:
|
41
|
+
value: $id
|
42
42
|
- label: First Name
|
43
|
-
value:
|
43
|
+
value: $first
|
44
44
|
- label: Last Name
|
45
|
-
value:
|
45
|
+
value: $last
|
46
46
|
- type: Spacer
|
47
47
|
- type: Header
|
48
48
|
value: Phone Numbers
|
@@ -51,9 +51,9 @@ template:
|
|
51
51
|
empty_message: No phone numbers.
|
52
52
|
columns:
|
53
53
|
- header: Type
|
54
|
-
body:
|
54
|
+
body: $type
|
55
55
|
- header: Number
|
56
|
-
body:
|
56
|
+
body: $number
|
57
57
|
- type: Spacer
|
58
58
|
|
59
59
|
documents:
|
@@ -47,19 +47,19 @@ template:
|
|
47
47
|
name: login_count_ave
|
48
48
|
columns:
|
49
49
|
- header: ID Number
|
50
|
-
body:
|
50
|
+
body: $id
|
51
51
|
footer: Login Count Ave.
|
52
52
|
- header: First Name
|
53
|
-
body:
|
54
|
-
footer:
|
53
|
+
body: $first
|
54
|
+
footer: $login_count_ave
|
55
55
|
- header: Last Name
|
56
|
-
body:
|
56
|
+
body: $last
|
57
57
|
- header: Username
|
58
|
-
body:
|
58
|
+
body: $username
|
59
59
|
footer: Login Count Sum
|
60
60
|
- header: Login Count
|
61
|
-
footer:
|
62
|
-
body:
|
61
|
+
footer: $login_count_sum
|
62
|
+
body: $login_count
|
63
63
|
- type: Spacer
|
64
64
|
- type: Grouping
|
65
65
|
children:
|
@@ -71,11 +71,11 @@ template:
|
|
71
71
|
- label_width: 25.0
|
72
72
|
lines:
|
73
73
|
- label: ID Number
|
74
|
-
value:
|
74
|
+
value: $id
|
75
75
|
- label: First Name
|
76
|
-
value:
|
76
|
+
value: $first
|
77
77
|
- label: Last Name
|
78
|
-
value:
|
78
|
+
value: $last
|
79
79
|
- type: Spacer
|
80
80
|
- type: Header
|
81
81
|
value: Phone Numbers
|
@@ -84,9 +84,9 @@ template:
|
|
84
84
|
empty_message: No phone numbers.
|
85
85
|
columns:
|
86
86
|
- header: Type
|
87
|
-
body:
|
87
|
+
body: $type
|
88
88
|
- header: Number
|
89
|
-
body:
|
89
|
+
body: $number
|
90
90
|
- type: Spacer
|
91
91
|
|
92
92
|
documents:
|
@@ -0,0 +1,16 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
#
|
4
|
+
# Copyright (c) 2018-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
|
+
require 'spec_helper'
|
11
|
+
|
12
|
+
describe ::Proforma::Compiling::Counter do
|
13
|
+
specify '#ave returns 0 if count is 0' do
|
14
|
+
expect(subject.ave).to eq(0)
|
15
|
+
end
|
16
|
+
end
|
data/spec/proforma_spec.rb
CHANGED
@@ -45,9 +45,9 @@ describe ::Proforma do
|
|
45
45
|
{
|
46
46
|
type: 'DataTable',
|
47
47
|
columns: [
|
48
|
-
{ header: 'ID Number', body: '
|
49
|
-
{ header: 'First Name', body: '
|
50
|
-
{ header: 'Last Name', body: '
|
48
|
+
{ header: 'ID Number', body: '$id' },
|
49
|
+
{ header: 'First Name', body: '$first' },
|
50
|
+
{ header: 'Last Name', body: '$last' }
|
51
51
|
]
|
52
52
|
}
|
53
53
|
]
|
@@ -83,13 +83,13 @@ describe ::Proforma do
|
|
83
83
|
columns: [
|
84
84
|
{
|
85
85
|
lines: [
|
86
|
-
{ label: 'ID Number', value: '
|
87
|
-
{ label: 'First Name', value: '
|
86
|
+
{ label: 'ID Number', value: '$id' },
|
87
|
+
{ label: 'First Name', value: '$first' }
|
88
88
|
]
|
89
89
|
},
|
90
90
|
{
|
91
91
|
lines: [
|
92
|
-
{ label: 'Last Name', value: '
|
92
|
+
{ label: 'Last Name', value: '$last' }
|
93
93
|
]
|
94
94
|
}
|
95
95
|
]
|
@@ -161,9 +161,9 @@ describe ::Proforma do
|
|
161
161
|
{
|
162
162
|
type: 'DataTable',
|
163
163
|
columns: [
|
164
|
-
{ header: 'ID Number', body: '
|
165
|
-
{ header: 'First Name', body: '
|
166
|
-
{ header: 'Last Name', body: '
|
164
|
+
{ header: 'ID Number', body: '$id' },
|
165
|
+
{ header: 'First Name', body: '$first' },
|
166
|
+
{ header: 'Last Name', body: '$last' }
|
167
167
|
]
|
168
168
|
},
|
169
169
|
{ type: 'Spacer' },
|
@@ -178,13 +178,13 @@ describe ::Proforma do
|
|
178
178
|
columns: [
|
179
179
|
{
|
180
180
|
lines: [
|
181
|
-
{ label: 'ID Number', value: '
|
182
|
-
{ label: 'First Name', value: '
|
181
|
+
{ label: 'ID Number', value: '$id' },
|
182
|
+
{ label: 'First Name', value: '$first' }
|
183
183
|
]
|
184
184
|
},
|
185
185
|
{
|
186
186
|
lines: [
|
187
|
-
{ label: 'Last Name', value: '
|
187
|
+
{ label: 'Last Name', value: '$last' }
|
188
188
|
]
|
189
189
|
}
|
190
190
|
]
|
@@ -193,8 +193,8 @@ describe ::Proforma do
|
|
193
193
|
type: 'DataTable',
|
194
194
|
property: 'phone_numbers',
|
195
195
|
columns: [
|
196
|
-
{ header: 'Type', body: '
|
197
|
-
{ header: 'Number', body: '
|
196
|
+
{ header: 'Type', body: '$type' },
|
197
|
+
{ header: 'Number', body: '$number' }
|
198
198
|
]
|
199
199
|
},
|
200
200
|
{ type: 'Spacer' }
|
@@ -207,18 +207,7 @@ describe ::Proforma do
|
|
207
207
|
|
208
208
|
expected_documents = [
|
209
209
|
Proforma::Document.new(
|
210
|
-
contents:
|
211
|
-
"======================\n555 N. Michigan Ave.\nChicago, IL 55555\n"\
|
212
|
-
"555-555-5555 ext. 5132\n========================================\nUSER"\
|
213
|
-
" LIST\n----------------------------------------\n\nID Number, First Name,"\
|
214
|
-
" Last Name\n1, Matt, Smith\n2, Katie, Rizzo\n3, Nathan, Nathanson\n\nUSER"\
|
215
|
-
" DETAILS\n----------------------------------------\n\nID Number: "\
|
216
|
-
"1\nFirst Name: Matt\nLast Name: Smith\nType, Number\nMobile, 444-333-2222"\
|
217
|
-
"\nHome, 444-333-2222\n\nUSER DETAILS\n-----------------------------------"\
|
218
|
-
"-----\n\nID Number: 2\nFirst Name: Katie\nLast Name: Rizzo\nType, Number\n"\
|
219
|
-
"Fax, 888-777-6666\n\nUSER DETAILS\n----------------------------------"\
|
220
|
-
"------\n\nID Number: 3\nFirst Name: Nathan\nLast Name: "\
|
221
|
-
"Nathanson\nType, Number\n\n",
|
210
|
+
contents: fixture('bringing_it_all_together.txt'),
|
222
211
|
extension: '.txt',
|
223
212
|
title: 'User Report'
|
224
213
|
)
|
data/spec/spec_helper.rb
CHANGED
@@ -19,7 +19,9 @@ SimpleCov.start
|
|
19
19
|
require './lib/proforma'
|
20
20
|
|
21
21
|
def yaml_read(file)
|
22
|
-
|
23
|
-
|
24
|
-
|
22
|
+
YAML.safe_load(File.open(file))
|
23
|
+
end
|
24
|
+
|
25
|
+
def fixture(file)
|
26
|
+
File.open(File.join('spec', 'fixtures', file)).read
|
25
27
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: proforma
|
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: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-04-
|
11
|
+
date: 2019-04-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: acts_as_hashable
|
@@ -138,9 +138,9 @@ files:
|
|
138
138
|
- lib/proforma/compiling/aggregation.rb
|
139
139
|
- lib/proforma/compiling/compilable.rb
|
140
140
|
- lib/proforma/compiling/counter.rb
|
141
|
-
- lib/proforma/core_ext/hash.rb
|
142
141
|
- lib/proforma/document.rb
|
143
142
|
- lib/proforma/hash_evaluator.rb
|
143
|
+
- lib/proforma/hash_refinements.rb
|
144
144
|
- lib/proforma/model_factory.rb
|
145
145
|
- lib/proforma/modeling.rb
|
146
146
|
- lib/proforma/modeling/banner.rb
|
@@ -169,9 +169,11 @@ files:
|
|
169
169
|
- lib/proforma/type_factory.rb
|
170
170
|
- lib/proforma/version.rb
|
171
171
|
- proforma.gemspec
|
172
|
+
- spec/fixtures/bringing_it_all_together.txt
|
172
173
|
- spec/fixtures/snapshots/custom_table.yml
|
173
174
|
- spec/fixtures/snapshots/user_details.yml
|
174
175
|
- spec/fixtures/snapshots/user_list.yml
|
176
|
+
- spec/proforma/compiling/counter_spec.rb
|
175
177
|
- spec/proforma/hash_evaluator_spec.rb
|
176
178
|
- spec/proforma/modeling/table/cell_spec.rb
|
177
179
|
- spec/proforma/modeling/table/row_spec.rb
|
@@ -192,18 +194,20 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
192
194
|
version: 2.3.8
|
193
195
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
194
196
|
requirements:
|
195
|
-
- - "
|
197
|
+
- - ">="
|
196
198
|
- !ruby/object:Gem::Version
|
197
|
-
version:
|
199
|
+
version: '0'
|
198
200
|
requirements: []
|
199
201
|
rubygems_version: 3.0.1
|
200
202
|
signing_key:
|
201
203
|
specification_version: 4
|
202
204
|
summary: Configurable and extendable document rendering engine for datasets
|
203
205
|
test_files:
|
206
|
+
- spec/fixtures/bringing_it_all_together.txt
|
204
207
|
- spec/fixtures/snapshots/custom_table.yml
|
205
208
|
- spec/fixtures/snapshots/user_details.yml
|
206
209
|
- spec/fixtures/snapshots/user_list.yml
|
210
|
+
- spec/proforma/compiling/counter_spec.rb
|
207
211
|
- spec/proforma/hash_evaluator_spec.rb
|
208
212
|
- spec/proforma/modeling/table/cell_spec.rb
|
209
213
|
- spec/proforma/modeling/table/row_spec.rb
|
@@ -1,21 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
#
|
4
|
-
# Copyright (c) 2019-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 Proforma
|
11
|
-
module CoreExt
|
12
|
-
# Monkey-patches for the core Hash class. These will be manually mixed in separately.
|
13
|
-
module Hash
|
14
|
-
unless method_defined?(:symbolize_keys)
|
15
|
-
def symbolize_keys
|
16
|
-
map { |k, v| [k.to_sym, v] }.to_h
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|