portable-writers-spreadsheet 1.0.0.pre.alpha

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 2140b1eb7619ec9c3a073c36b8a48cf3685f49e401eae47672c8b99bec3ad6ac
4
+ data.tar.gz: a8119842484821bd55c9bcc174ec21280f1235c99c33185872b7c418463b3482
5
+ SHA512:
6
+ metadata.gz: 05d0b5d8c3f5b833ce3b07577d20bd3cf9dca4b559047eb3d18848e7265e2eba2d7861f42973b36357249b77a16fa5fc6ed415c1c973d301fcfad6e92ad78ba5
7
+ data.tar.gz: 6374384f2f31ec4851d36dc0e3c011ede1364d073362d311b77b147ef0c4fade0d888ac29527b7b84f636ebb44e87b1fbd907a589d09549a05d8fa1a5a50aa28
@@ -0,0 +1,8 @@
1
+ # See http://editorconfig.org/
2
+
3
+ [*]
4
+ trim_trailing_whitespace = true
5
+ indent_style = space
6
+ indent_size = 2
7
+ insert_final_newline = true
8
+ end_of_line = lf
@@ -0,0 +1,6 @@
1
+ .DS_Store
2
+ *.gem
3
+ /tmp
4
+ /coverage
5
+ Gemfile.lock
6
+ /pkg
@@ -0,0 +1,32 @@
1
+ AllCops:
2
+ TargetRubyVersion: 2.5
3
+ NewCops: enable
4
+
5
+ Layout/LineLength:
6
+ Max: 100
7
+ Exclude:
8
+ - '*.gemspec'
9
+
10
+ Metrics/BlockLength:
11
+ ExcludedMethods:
12
+ - let
13
+ - it
14
+ - describe
15
+ - context
16
+ - specify
17
+ - define
18
+
19
+ Metrics/MethodLength:
20
+ Max: 30
21
+
22
+ Metrics/AbcSize:
23
+ Max: 20
24
+
25
+ Metrics/ClassLength:
26
+ Max: 125
27
+
28
+ Style/TrailingCommaInHashLiteral:
29
+ Enabled: false
30
+
31
+ Style/TrailingCommaInArrayLiteral:
32
+ Enabled: false
@@ -0,0 +1 @@
1
+ 2.6.6
@@ -0,0 +1,24 @@
1
+ env:
2
+ global:
3
+ - CC_TEST_REPORTER_ID=55ab3825e20978c06f86c9a5aaaa414ad9cedc95f5ed1f11b84695e52e20b059
4
+ language: ruby
5
+ rvm:
6
+ # Build on the latest stable of all supported Rubies (https://www.ruby-lang.org/en/downloads/):
7
+ - 2.5.8
8
+ - 2.6.6
9
+ - 2.7.1
10
+ cache: bundler
11
+ before_script:
12
+ - curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
13
+ - chmod +x ./cc-test-reporter
14
+ - ./cc-test-reporter before-build
15
+ script:
16
+ - bundle exec rubocop
17
+ - bundle exec rspec spec --format documentation
18
+ after_script:
19
+ - ./cc-test-reporter after-build --exit-code $TRAVIS_TEST_RESULT
20
+ addons:
21
+ # https://docs.travis-ci.com/user/uploading-artifacts/
22
+ artifacts:
23
+ paths:
24
+ - Gemfile.lock
@@ -0,0 +1,3 @@
1
+ # 1.0.0 (TBD)
2
+
3
+ Initial implementation.
data/Gemfile ADDED
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ source 'https://rubygems.org'
4
+
5
+ gemspec
@@ -0,0 +1,16 @@
1
+ # frozen_string_literal: true
2
+
3
+ guard :rspec, cmd: 'DISABLE_SIMPLECOV=true bundle exec rspec --format=documentation' do
4
+ require 'guard/rspec/dsl'
5
+ dsl = Guard::RSpec::Dsl.new(self)
6
+
7
+ # RSpec files
8
+ rspec = dsl.rspec
9
+ watch(rspec.spec_helper) { rspec.spec_dir }
10
+ watch(rspec.spec_support) { rspec.spec_dir }
11
+ watch(rspec.spec_files)
12
+
13
+ # Ruby files
14
+ ruby = dsl.ruby
15
+ dsl.watch_spec_files_for(ruby.lib_files)
16
+ end
data/LICENSE ADDED
@@ -0,0 +1,7 @@
1
+ Copyright 2020 Blue Marble Payroll, LLC
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
4
+
5
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
6
+
7
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,76 @@
1
+ # Portable Spreadsheet Writer
2
+
3
+ [![Gem Version](https://badge.fury.io/rb/portable-writers-spreadsheet.svg)](https://badge.fury.io/rb/portable-writers-spreadsheet) [![Build Status](https://travis-ci.org/bluemarblepayroll/portable-writers-spreadsheet.svg?branch=master)](https://travis-ci.org/bluemarblepayroll/portable-writers-spreadsheet) [![Maintainability](https://api.codeclimate.com/v1/badges/3984ca34a23267b3ea0a/maintainability)](https://codeclimate.com/github/bluemarblepayroll/portable-writers-spreadsheet/maintainability) [![Test Coverage](https://api.codeclimate.com/v1/badges/3984ca34a23267b3ea0a/test_coverage)](https://codeclimate.com/github/bluemarblepayroll/portable-writers-spreadsheet/test_coverage) [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
4
+
5
+ This library is a plugin for [Portable](https://github.com/bluemarblepayroll/portable) and provides a new document writer for rendering spreadsheets. It currently is limited to Microsoft Excel Open XML Spreadsheets (.xlsx) and uses the library [fast_excel](https://github.com/Paxa/fast_excel) under the hood.
6
+
7
+ ## Installation
8
+
9
+ To install through Rubygems:
10
+
11
+ ````
12
+ gem install install portable-writers-spreadsheet
13
+ ````
14
+
15
+ You can also add this to your Gemfile:
16
+
17
+ ````
18
+ bundle add portable-writers-spreadsheet
19
+ ````
20
+
21
+ ## Examples
22
+
23
+ See the main [Portable](https://github.com/bluemarblepayroll/portable) repository for examples. The only difference is if you wish to use this library then render documents with Portable::Writers::Spreadsheet (instead of Portable::Writers::Csv).
24
+
25
+ ## Contributing
26
+
27
+ ### Development Environment Configuration
28
+
29
+ Basic steps to take to get this repository compiling:
30
+
31
+ 1. Install [Ruby](https://www.ruby-lang.org/en/documentation/installation/) (check portable-writers-spreadsheet.gemspec for versions supported)
32
+ 2. Install bundler (gem install bundler)
33
+ 3. Clone the repository (git clone git@github.com:bluemarblepayroll/portable-writers-spreadsheet.git)
34
+ 4. Navigate to the root folder (cd portable-writers-spreadsheet)
35
+ 5. Install dependencies (bundle)
36
+
37
+ ### Running Tests
38
+
39
+ To execute the test suite run:
40
+
41
+ ````bash
42
+ bundle exec rspec spec --format documentation
43
+ ````
44
+
45
+ Alternatively, you can have Guard watch for changes:
46
+
47
+ ````bash
48
+ bundle exec guard
49
+ ````
50
+
51
+ Also, do not forget to run Rubocop:
52
+
53
+ ````bash
54
+ bundle exec rubocop
55
+ ````
56
+
57
+ ### Publishing
58
+
59
+ Note: ensure you have proper authorization before trying to publish new versions.
60
+
61
+ After code changes have successfully gone through the Pull Request review process then the following steps should be followed for publishing new versions:
62
+
63
+ 1. Merge Pull Request into master
64
+ 2. Update `lib/portable-writers-spreadsheet/version.rb` using [semantic versioning](https://semver.org/)
65
+ 3. Install dependencies: `bundle`
66
+ 4. Update `CHANGELOG.md` with release notes
67
+ 5. Commit & push master to remote and ensure CI builds master successfully
68
+ 6. Run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
69
+
70
+ ## Code of Conduct
71
+
72
+ Everyone interacting in this codebase, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/bluemarblepayroll/portable-writers-spreadsheet/blob/master/CODE_OF_CONDUCT.md).
73
+
74
+ ## License
75
+
76
+ This project is MIT Licensed.
@@ -0,0 +1,17 @@
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
+ require 'bundler/gem_tasks'
11
+ require 'rspec/core/rake_task'
12
+ require 'rubocop/rake_task'
13
+
14
+ RSpec::Core::RakeTask.new(:spec)
15
+ RuboCop::RakeTask.new
16
+
17
+ task default: %i[rubocop spec]
@@ -0,0 +1,18 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ #
5
+ # Copyright (c) 2020-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
+
11
+ require 'bundler/setup'
12
+ require 'portable/writers/spreadsheet'
13
+
14
+ # You can add fixtures and/or initialization code here to make experimenting
15
+ # with your gem easier. You can also use a different console, if you like.
16
+
17
+ require 'pry'
18
+ Pry.start
File without changes
@@ -0,0 +1,66 @@
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
+ require 'fast_excel'
11
+ require 'portable'
12
+
13
+ module Portable
14
+ module Writers
15
+ # Can write documents to an Excel file.
16
+ class Spreadsheet < Base
17
+ def write!(filename:, data_provider: Data::Provider.new, time: Time.now.utc)
18
+ raise ArgumentError, 'filename is required' if filename.to_s.empty?
19
+
20
+ ensure_directory_exists(filename)
21
+
22
+ workbook = FastExcel.open(filename, constant_memory: true)
23
+
24
+ document.sheets.map do |sheet|
25
+ data_source = data_provider.data_source(sheet.name)
26
+
27
+ worksheet = workbook.add_worksheet(sheet.name)
28
+
29
+ write_head(worksheet, sheet, data_source)
30
+ write_data_table(worksheet, sheet, data_source, time)
31
+ write_foot(worksheet, sheet, data_source)
32
+ end
33
+
34
+ workbook.close
35
+
36
+ time_in_seconds = 1.0
37
+
38
+ [Result.new(filename, time_in_seconds)]
39
+ end
40
+
41
+ private
42
+
43
+ def write_head(worksheet, sheet, data_source)
44
+ sheet.header_rows.each { |row| worksheet.append_row(row) }
45
+
46
+ data_source.header_rows.each { |row| worksheet.append_row(row) }
47
+ end
48
+
49
+ def write_data_table(worksheet, sheet, data_source, time)
50
+ row_renderer = sheet_renderer.row_renderer(sheet.name, data_source.fields)
51
+
52
+ worksheet.append_row(row_renderer.headers) if sheet.include_headers?
53
+
54
+ data_source.data_rows.each do |row|
55
+ worksheet.append_row(row_renderer.render(row, time).values)
56
+ end
57
+ end
58
+
59
+ def write_foot(worksheet, sheet, data_source)
60
+ data_source.footer_rows.each { |row| worksheet.append_row(row) }
61
+
62
+ sheet.footer_rows.each { |row| worksheet.append_row(row) }
63
+ end
64
+ end
65
+ end
66
+ end
@@ -0,0 +1,18 @@
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
+ require 'portable'
11
+
12
+ module Portable
13
+ module Writers
14
+ class Spreadsheet < Base
15
+ VERSION = '1.0.0-alpha'
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,42 @@
1
+ # frozen_string_literal: true
2
+
3
+ require './lib/portable/writers/spreadsheet/version'
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = 'portable-writers-spreadsheet'
7
+ s.version = Portable::Writers::Spreadsheet::VERSION
8
+ s.summary = 'Plugs in a spreadsheet writer for the Portable library'
9
+
10
+ s.description = <<-DESCRIPTION
11
+ Portable is a virtual document object modeling library that only contains basic writers by default. This library extends Portable and adds a Spreadsheet Writer implementation.
12
+ DESCRIPTION
13
+
14
+ s.authors = ['Matthew Ruggio']
15
+ s.email = ['mruggio@bluemarblepayroll.com']
16
+ s.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
17
+ s.bindir = 'exe'
18
+ s.executables = []
19
+ s.homepage = 'https://github.com/bluemarblepayroll/portable-writers-spreadsheet'
20
+ s.license = 'MIT'
21
+ s.metadata = {
22
+ 'bug_tracker_uri' => 'https://github.com/bluemarblepayroll/portable-writers-spreadsheet/issues',
23
+ 'changelog_uri' => 'https://github.com/bluemarblepayroll/portable-writers-spreadsheet/blob/master/CHANGELOG.md',
24
+ 'documentation_uri' => 'https://www.rubydoc.info/gems/portable-writers-spreadsheet',
25
+ 'homepage_uri' => s.homepage,
26
+ 'source_code_uri' => s.homepage
27
+ }
28
+
29
+ s.required_ruby_version = '>= 2.5'
30
+
31
+ s.add_dependency('fast_excel', '~>0.3')
32
+ s.add_dependency('portable', '=1.0.0-alpha.5')
33
+
34
+ s.add_development_dependency('guard-rspec', '~>4.7')
35
+ s.add_development_dependency('pry', '~>0')
36
+ s.add_development_dependency('rake', '~> 13')
37
+ s.add_development_dependency('roo', '~> 2.8')
38
+ s.add_development_dependency('rspec', '~> 3.8')
39
+ s.add_development_dependency('rubocop', '~>0.88.0')
40
+ s.add_development_dependency('simplecov', '~>0.18.5')
41
+ s.add_development_dependency('simplecov-console', '~>0.7.0')
42
+ end
metadata ADDED
@@ -0,0 +1,206 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: portable-writers-spreadsheet
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0.pre.alpha
5
+ platform: ruby
6
+ authors:
7
+ - Matthew Ruggio
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2020-08-08 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: fast_excel
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '0.3'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '0.3'
27
+ - !ruby/object:Gem::Dependency
28
+ name: portable
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - '='
32
+ - !ruby/object:Gem::Version
33
+ version: 1.0.0.pre.alpha.5
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - '='
39
+ - !ruby/object:Gem::Version
40
+ version: 1.0.0.pre.alpha.5
41
+ - !ruby/object:Gem::Dependency
42
+ name: guard-rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '4.7'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '4.7'
55
+ - !ruby/object:Gem::Dependency
56
+ name: pry
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rake
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '13'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '13'
83
+ - !ruby/object:Gem::Dependency
84
+ name: roo
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '2.8'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: '2.8'
97
+ - !ruby/object:Gem::Dependency
98
+ name: rspec
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - "~>"
102
+ - !ruby/object:Gem::Version
103
+ version: '3.8'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - "~>"
109
+ - !ruby/object:Gem::Version
110
+ version: '3.8'
111
+ - !ruby/object:Gem::Dependency
112
+ name: rubocop
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - "~>"
116
+ - !ruby/object:Gem::Version
117
+ version: 0.88.0
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - "~>"
123
+ - !ruby/object:Gem::Version
124
+ version: 0.88.0
125
+ - !ruby/object:Gem::Dependency
126
+ name: simplecov
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - "~>"
130
+ - !ruby/object:Gem::Version
131
+ version: 0.18.5
132
+ type: :development
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - "~>"
137
+ - !ruby/object:Gem::Version
138
+ version: 0.18.5
139
+ - !ruby/object:Gem::Dependency
140
+ name: simplecov-console
141
+ requirement: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - "~>"
144
+ - !ruby/object:Gem::Version
145
+ version: 0.7.0
146
+ type: :development
147
+ prerelease: false
148
+ version_requirements: !ruby/object:Gem::Requirement
149
+ requirements:
150
+ - - "~>"
151
+ - !ruby/object:Gem::Version
152
+ version: 0.7.0
153
+ description: " Portable is a virtual document object modeling library that only
154
+ contains basic writers by default. This library extends Portable and adds a Spreadsheet
155
+ Writer implementation.\n"
156
+ email:
157
+ - mruggio@bluemarblepayroll.com
158
+ executables: []
159
+ extensions: []
160
+ extra_rdoc_files: []
161
+ files:
162
+ - ".editorconfig"
163
+ - ".gitignore"
164
+ - ".rubocop.yml"
165
+ - ".ruby-version"
166
+ - ".travis.yml"
167
+ - CHANGELOG.md
168
+ - Gemfile
169
+ - Guardfile
170
+ - LICENSE
171
+ - README.md
172
+ - Rakefile
173
+ - bin/console
174
+ - exe/.gitkeep
175
+ - lib/portable/writers/spreadsheet.rb
176
+ - lib/portable/writers/spreadsheet/version.rb
177
+ - portable-writers-spreadsheet.gemspec
178
+ homepage: https://github.com/bluemarblepayroll/portable-writers-spreadsheet
179
+ licenses:
180
+ - MIT
181
+ metadata:
182
+ bug_tracker_uri: https://github.com/bluemarblepayroll/portable-writers-spreadsheet/issues
183
+ changelog_uri: https://github.com/bluemarblepayroll/portable-writers-spreadsheet/blob/master/CHANGELOG.md
184
+ documentation_uri: https://www.rubydoc.info/gems/portable-writers-spreadsheet
185
+ homepage_uri: https://github.com/bluemarblepayroll/portable-writers-spreadsheet
186
+ source_code_uri: https://github.com/bluemarblepayroll/portable-writers-spreadsheet
187
+ post_install_message:
188
+ rdoc_options: []
189
+ require_paths:
190
+ - lib
191
+ required_ruby_version: !ruby/object:Gem::Requirement
192
+ requirements:
193
+ - - ">="
194
+ - !ruby/object:Gem::Version
195
+ version: '2.5'
196
+ required_rubygems_version: !ruby/object:Gem::Requirement
197
+ requirements:
198
+ - - ">"
199
+ - !ruby/object:Gem::Version
200
+ version: 1.3.1
201
+ requirements: []
202
+ rubygems_version: 3.0.3
203
+ signing_key:
204
+ specification_version: 4
205
+ summary: Plugs in a spreadsheet writer for the Portable library
206
+ test_files: []