excel_templating 0.3.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (59) hide show
  1. checksums.yaml +7 -0
  2. data/.document +3 -0
  3. data/.gitignore +4 -0
  4. data/.rspec +1 -0
  5. data/.rubocop.hound.yml +261 -0
  6. data/.rubocop.ph.yml +44 -0
  7. data/.rubocop.yml +3 -0
  8. data/.yardopts +1 -0
  9. data/ChangeLog.md +8 -0
  10. data/Gemfile +10 -0
  11. data/LICENSE.txt +3 -0
  12. data/README.md +133 -0
  13. data/Rakefile +43 -0
  14. data/excel_templating.gemspec +32 -0
  15. data/lib/excel_templating/document/data_source_registry/registry_list.rb +48 -0
  16. data/lib/excel_templating/document/data_source_registry/registry_renderer.rb +74 -0
  17. data/lib/excel_templating/document/data_source_registry.rb +64 -0
  18. data/lib/excel_templating/document/sheet/repeated_row.rb +39 -0
  19. data/lib/excel_templating/document/sheet.rb +133 -0
  20. data/lib/excel_templating/document.rb +71 -0
  21. data/lib/excel_templating/document_dsl.rb +85 -0
  22. data/lib/excel_templating/excel_abstraction/active_cell_reference.rb +59 -0
  23. data/lib/excel_templating/excel_abstraction/cell.rb +23 -0
  24. data/lib/excel_templating/excel_abstraction/cell_range.rb +26 -0
  25. data/lib/excel_templating/excel_abstraction/cell_reference.rb +39 -0
  26. data/lib/excel_templating/excel_abstraction/date.rb +36 -0
  27. data/lib/excel_templating/excel_abstraction/row.rb +29 -0
  28. data/lib/excel_templating/excel_abstraction/sheet.rb +102 -0
  29. data/lib/excel_templating/excel_abstraction/spread_sheet.rb +28 -0
  30. data/lib/excel_templating/excel_abstraction/time.rb +42 -0
  31. data/lib/excel_templating/excel_abstraction/work_book.rb +47 -0
  32. data/lib/excel_templating/excel_abstraction.rb +16 -0
  33. data/lib/excel_templating/render_helper.rb +14 -0
  34. data/lib/excel_templating/renderer.rb +251 -0
  35. data/lib/excel_templating/rspec_excel_matcher.rb +129 -0
  36. data/lib/excel_templating/version.rb +4 -0
  37. data/lib/excel_templating.rb +4 -0
  38. data/spec/assets/alphalist_7_4.mustache.xlsx +0 -0
  39. data/spec/assets/alphalist_seven_four_expected.xlsx +0 -0
  40. data/spec/assets/valid_cell.mustache.xlsx +0 -0
  41. data/spec/assets/valid_cell_expected.xlsx +0 -0
  42. data/spec/assets/valid_cell_expected_inline.xlsx +0 -0
  43. data/spec/assets/valid_column_expected.xlsx +0 -0
  44. data/spec/cell_validation_spec.rb +114 -0
  45. data/spec/column_validation_spec.rb +47 -0
  46. data/spec/excel_abstraction/active_cell_reference_spec.rb +73 -0
  47. data/spec/excel_abstraction/cell_range_spec.rb +36 -0
  48. data/spec/excel_abstraction/cell_reference_spec.rb +69 -0
  49. data/spec/excel_abstraction/cell_spec.rb +54 -0
  50. data/spec/excel_abstraction/date_spec.rb +27 -0
  51. data/spec/excel_abstraction/row_spec.rb +42 -0
  52. data/spec/excel_abstraction/sheet_spec.rb +83 -0
  53. data/spec/excel_abstraction/spread_sheet_spec.rb +35 -0
  54. data/spec/excel_abstraction/time_spec.rb +27 -0
  55. data/spec/excel_abstraction/work_book_spec.rb +22 -0
  56. data/spec/excel_helper.rb +16 -0
  57. data/spec/excel_templating_spec.rb +141 -0
  58. data/spec/spec_helper.rb +13 -0
  59. metadata +281 -0
@@ -0,0 +1,141 @@
1
+ require 'spec_helper'
2
+
3
+ describe ExcelTemplating do
4
+ context "alphalist 7.4 document" do
5
+ class AlphalistClass < ExcelTemplating::Document
6
+ template "spec/assets/alphalist_7_4.mustache.xlsx"
7
+ title "7.4 Alphalist of Employees as of Dec 31 with previous employer within the year"
8
+ organization "{{organization_name}}"
9
+ default_styling(
10
+ text_wrap: 0,
11
+ font: "Calibri",
12
+ size: 10,
13
+ align: :left,
14
+ locked: 0
15
+ )
16
+ sheet 1 do
17
+ repeat_row 17, with: :employee_data
18
+
19
+ style_columns(
20
+ default: {
21
+ width: inches(1.98)
22
+ },
23
+ columns: {
24
+ 1 => { format: { locked: 1 } },
25
+ 3 => { width: inches(1.98) },
26
+ 4 => { width: inches(1.98) },
27
+ 5 => { width: inches(0.39) }
28
+ }
29
+ )
30
+
31
+ style_rows(
32
+ default: {},
33
+ rows: {
34
+ 1 => { format: { locked: 1 } },
35
+ }
36
+ )
37
+ end
38
+
39
+ protect_document
40
+ end
41
+
42
+ subject { AlphalistClass.new(data) }
43
+ let(:organization_name) { "The Coffee Bean and Tea Leaf" }
44
+ let(:year) { 1971 }
45
+
46
+ let(:data) {
47
+ {
48
+ all_sheets:
49
+ {
50
+ organization_name: organization_name,
51
+ company_tin: '220406705-0000',
52
+ full_company_name: 'THE COFFEE BEAN AND TEA LEAF PHILIPPINES INC.',
53
+ year: year
54
+ },
55
+ 1 => {
56
+ employee_data: [
57
+ {
58
+ tin_number: 12345,
59
+ first_name: "JOHNSON JOHNSONVILLE",
60
+ middle_initial: "Q",
61
+ last_name: "JACKSON",
62
+ enrollment_start_date: "1/1/2013",
63
+ enrollment_end_date: "4/24/2013",
64
+ gross_compensation_income: 123.45,
65
+ non_taxable_13th_and_other: 124.56,
66
+ non_taxable_de_minimis: 234.56,
67
+ non_taxable_government_deductions: 345.67,
68
+ non_taxable_other_compensation: 456.78,
69
+ non_taxable_total: 567.89,
70
+ taxable_basic_salary: 678.90,
71
+ taxable_13th_month_and_other: 789.01,
72
+ taxable_other_compensation: 890.12,
73
+ taxable_total: 901.23,
74
+ exemption_code: 'S',
75
+ exemption_amount: 12.34,
76
+ health_premium: 123.45,
77
+ net_taxable_compensation_income: 234.56,
78
+ tax_due: 345.67,
79
+ tax_withheld: 456.78,
80
+ tax_withheld_in_december: 567.89,
81
+ tax_over_withheld: 678.90,
82
+ tax_withheld_adjusted: 789.01,
83
+ substituted_filing: 'Y',
84
+
85
+ previous_non_taxable_13th_and_other: 0,
86
+ previous_non_taxable_de_minimis: 0,
87
+ previous_non_taxable_government_deductions: 0,
88
+ previous_non_taxable_other_compensation: 0,
89
+ previous_non_taxable_total: 0,
90
+ previous_taxable_basic_salary: 0,
91
+ previous_taxable_13th_month_and_other: 0,
92
+ previous_taxable_other_compensation: 0,
93
+ previous_taxable_total: 0,
94
+ combined_taxable_total: 901.23,
95
+ }
96
+ ],
97
+ total_comp_income: 8000,
98
+ total_non_tax_13th_other: 9000,
99
+ total_non_tax_de_minimis: 9000,
100
+ total_non_tax_gov_deduct: 9000,
101
+ total_non_tax_other: 9000,
102
+ total_non_tax_total: 15000,
103
+ total_tax_basic: 10000,
104
+ total_tax_13th_other: 120000,
105
+ total_tax_other: 999,
106
+ total_tax_total: 99999,
107
+ total_exempt: 999,
108
+ total_premium: 4567.8,
109
+ total_net_tax_comp: 987.98,
110
+ total_tax_due: 123.56,
111
+ total_tax_withheld: 234.56,
112
+ total_tax_withheld_in_december: 975246.78,
113
+ total_tax_over_withheld: 987987.88,
114
+ total_tax_withheld_adjusted: 98787.89,
115
+
116
+ previous_total_non_tax_13th_other: 0,
117
+ previous_total_non_tax_de_minimis: 0,
118
+ previous_total_non_tax_gov_deduct: 0,
119
+ previous_total_non_tax_other: 0,
120
+ previous_total_non_tax_total: 0,
121
+ previous_total_tax_basic: 0,
122
+ previous_total_tax_13th_other: 0,
123
+ previous_total_tax_other: 0,
124
+ previous_total_tax_total: 0,
125
+ combined_total_tax_total: 99998,
126
+
127
+ }
128
+ }
129
+ }
130
+
131
+ describe "#render" do
132
+ it do
133
+ expect do
134
+ subject.render do |path|
135
+ expect(path).to match_excel_content('spec/assets/alphalist_seven_four_expected.xlsx')
136
+ end
137
+ end.not_to raise_error
138
+ end
139
+ end
140
+ end
141
+ end
@@ -0,0 +1,13 @@
1
+ require 'bundler'
2
+ Bundler.setup
3
+ require 'rspec'
4
+ require 'excel_templating/version'
5
+ require 'excel_templating'
6
+ require 'excel_helper'
7
+ require 'excel_templating/rspec_excel_matcher'
8
+ require 'rspec/its'
9
+ require 'byebug'
10
+
11
+ RSpec.configure do |config|
12
+ config.include ExcelHelper
13
+ end
metadata ADDED
@@ -0,0 +1,281 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: excel_templating
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.3.2
5
+ platform: ruby
6
+ authors:
7
+ - bramski
8
+ - Mykola Kyryk
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2020-04-21 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: mustache
16
+ requirement: !ruby/object:Gem::Requirement
17
+ requirements:
18
+ - - ">="
19
+ - !ruby/object:Gem::Version
20
+ version: '0'
21
+ type: :runtime
22
+ prerelease: false
23
+ version_requirements: !ruby/object:Gem::Requirement
24
+ requirements:
25
+ - - ">="
26
+ - !ruby/object:Gem::Version
27
+ version: '0'
28
+ - !ruby/object:Gem::Dependency
29
+ name: roo
30
+ requirement: !ruby/object:Gem::Requirement
31
+ requirements:
32
+ - - ">="
33
+ - !ruby/object:Gem::Version
34
+ version: 2.0.0beta1
35
+ - - "<"
36
+ - !ruby/object:Gem::Version
37
+ version: '3'
38
+ type: :runtime
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ requirements:
42
+ - - ">="
43
+ - !ruby/object:Gem::Version
44
+ version: 2.0.0beta1
45
+ - - "<"
46
+ - !ruby/object:Gem::Version
47
+ version: '3'
48
+ - !ruby/object:Gem::Dependency
49
+ name: roo-xls
50
+ requirement: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ type: :runtime
56
+ prerelease: false
57
+ version_requirements: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ - !ruby/object:Gem::Dependency
63
+ name: write_xlsx
64
+ requirement: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ type: :runtime
70
+ prerelease: false
71
+ version_requirements: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ - !ruby/object:Gem::Dependency
77
+ name: writeexcel
78
+ requirement: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ type: :runtime
84
+ prerelease: false
85
+ version_requirements: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ - !ruby/object:Gem::Dependency
91
+ name: bundler
92
+ requirement: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: '1.0'
97
+ type: :development
98
+ prerelease: false
99
+ version_requirements: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - "~>"
102
+ - !ruby/object:Gem::Version
103
+ version: '1.0'
104
+ - !ruby/object:Gem::Dependency
105
+ name: rake
106
+ requirement: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - "~>"
109
+ - !ruby/object:Gem::Version
110
+ version: '0.8'
111
+ type: :development
112
+ prerelease: false
113
+ version_requirements: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - "~>"
116
+ - !ruby/object:Gem::Version
117
+ version: '0.8'
118
+ - !ruby/object:Gem::Dependency
119
+ name: rspec
120
+ requirement: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - "~>"
123
+ - !ruby/object:Gem::Version
124
+ version: '3.3'
125
+ type: :development
126
+ prerelease: false
127
+ version_requirements: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - "~>"
130
+ - !ruby/object:Gem::Version
131
+ version: '3.3'
132
+ - !ruby/object:Gem::Dependency
133
+ name: rubygems-tasks
134
+ requirement: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - "~>"
137
+ - !ruby/object:Gem::Version
138
+ version: '0.2'
139
+ type: :development
140
+ prerelease: false
141
+ version_requirements: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - "~>"
144
+ - !ruby/object:Gem::Version
145
+ version: '0.2'
146
+ - !ruby/object:Gem::Dependency
147
+ name: yard
148
+ requirement: !ruby/object:Gem::Requirement
149
+ requirements:
150
+ - - "~>"
151
+ - !ruby/object:Gem::Version
152
+ version: '0.8'
153
+ type: :development
154
+ prerelease: false
155
+ version_requirements: !ruby/object:Gem::Requirement
156
+ requirements:
157
+ - - "~>"
158
+ - !ruby/object:Gem::Version
159
+ version: '0.8'
160
+ - !ruby/object:Gem::Dependency
161
+ name: rspec-its
162
+ requirement: !ruby/object:Gem::Requirement
163
+ requirements:
164
+ - - ">="
165
+ - !ruby/object:Gem::Version
166
+ version: '0'
167
+ type: :development
168
+ prerelease: false
169
+ version_requirements: !ruby/object:Gem::Requirement
170
+ requirements:
171
+ - - ">="
172
+ - !ruby/object:Gem::Version
173
+ version: '0'
174
+ description: "."
175
+ email: bramski@gmail.com
176
+ executables: []
177
+ extensions: []
178
+ extra_rdoc_files: []
179
+ files:
180
+ - ".document"
181
+ - ".gitignore"
182
+ - ".rspec"
183
+ - ".rubocop.hound.yml"
184
+ - ".rubocop.ph.yml"
185
+ - ".rubocop.yml"
186
+ - ".yardopts"
187
+ - ChangeLog.md
188
+ - Gemfile
189
+ - LICENSE.txt
190
+ - README.md
191
+ - Rakefile
192
+ - excel_templating.gemspec
193
+ - lib/excel_templating.rb
194
+ - lib/excel_templating/document.rb
195
+ - lib/excel_templating/document/data_source_registry.rb
196
+ - lib/excel_templating/document/data_source_registry/registry_list.rb
197
+ - lib/excel_templating/document/data_source_registry/registry_renderer.rb
198
+ - lib/excel_templating/document/sheet.rb
199
+ - lib/excel_templating/document/sheet/repeated_row.rb
200
+ - lib/excel_templating/document_dsl.rb
201
+ - lib/excel_templating/excel_abstraction.rb
202
+ - lib/excel_templating/excel_abstraction/active_cell_reference.rb
203
+ - lib/excel_templating/excel_abstraction/cell.rb
204
+ - lib/excel_templating/excel_abstraction/cell_range.rb
205
+ - lib/excel_templating/excel_abstraction/cell_reference.rb
206
+ - lib/excel_templating/excel_abstraction/date.rb
207
+ - lib/excel_templating/excel_abstraction/row.rb
208
+ - lib/excel_templating/excel_abstraction/sheet.rb
209
+ - lib/excel_templating/excel_abstraction/spread_sheet.rb
210
+ - lib/excel_templating/excel_abstraction/time.rb
211
+ - lib/excel_templating/excel_abstraction/work_book.rb
212
+ - lib/excel_templating/render_helper.rb
213
+ - lib/excel_templating/renderer.rb
214
+ - lib/excel_templating/rspec_excel_matcher.rb
215
+ - lib/excel_templating/version.rb
216
+ - spec/assets/alphalist_7_4.mustache.xlsx
217
+ - spec/assets/alphalist_seven_four_expected.xlsx
218
+ - spec/assets/valid_cell.mustache.xlsx
219
+ - spec/assets/valid_cell_expected.xlsx
220
+ - spec/assets/valid_cell_expected_inline.xlsx
221
+ - spec/assets/valid_column_expected.xlsx
222
+ - spec/cell_validation_spec.rb
223
+ - spec/column_validation_spec.rb
224
+ - spec/excel_abstraction/active_cell_reference_spec.rb
225
+ - spec/excel_abstraction/cell_range_spec.rb
226
+ - spec/excel_abstraction/cell_reference_spec.rb
227
+ - spec/excel_abstraction/cell_spec.rb
228
+ - spec/excel_abstraction/date_spec.rb
229
+ - spec/excel_abstraction/row_spec.rb
230
+ - spec/excel_abstraction/sheet_spec.rb
231
+ - spec/excel_abstraction/spread_sheet_spec.rb
232
+ - spec/excel_abstraction/time_spec.rb
233
+ - spec/excel_abstraction/work_book_spec.rb
234
+ - spec/excel_helper.rb
235
+ - spec/excel_templating_spec.rb
236
+ - spec/spec_helper.rb
237
+ homepage: https://github.com/payrollhero/excel_templating
238
+ licenses:
239
+ - MIT
240
+ metadata: {}
241
+ post_install_message:
242
+ rdoc_options: []
243
+ require_paths:
244
+ - lib
245
+ required_ruby_version: !ruby/object:Gem::Requirement
246
+ requirements:
247
+ - - ">="
248
+ - !ruby/object:Gem::Version
249
+ version: '0'
250
+ required_rubygems_version: !ruby/object:Gem::Requirement
251
+ requirements:
252
+ - - ">="
253
+ - !ruby/object:Gem::Version
254
+ version: '0'
255
+ requirements: []
256
+ rubygems_version: 3.0.8
257
+ signing_key:
258
+ specification_version: 4
259
+ summary: A library which allows you to slam data into excel files using mustaching.
260
+ test_files:
261
+ - spec/assets/alphalist_7_4.mustache.xlsx
262
+ - spec/assets/alphalist_seven_four_expected.xlsx
263
+ - spec/assets/valid_cell.mustache.xlsx
264
+ - spec/assets/valid_cell_expected.xlsx
265
+ - spec/assets/valid_cell_expected_inline.xlsx
266
+ - spec/assets/valid_column_expected.xlsx
267
+ - spec/cell_validation_spec.rb
268
+ - spec/column_validation_spec.rb
269
+ - spec/excel_abstraction/active_cell_reference_spec.rb
270
+ - spec/excel_abstraction/cell_range_spec.rb
271
+ - spec/excel_abstraction/cell_reference_spec.rb
272
+ - spec/excel_abstraction/cell_spec.rb
273
+ - spec/excel_abstraction/date_spec.rb
274
+ - spec/excel_abstraction/row_spec.rb
275
+ - spec/excel_abstraction/sheet_spec.rb
276
+ - spec/excel_abstraction/spread_sheet_spec.rb
277
+ - spec/excel_abstraction/time_spec.rb
278
+ - spec/excel_abstraction/work_book_spec.rb
279
+ - spec/excel_helper.rb
280
+ - spec/excel_templating_spec.rb
281
+ - spec/spec_helper.rb