excel_utils 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.coveralls.yml +2 -0
- data/.gitignore +9 -0
- data/.ruby-gemset +1 -0
- data/.ruby-version +1 -0
- data/.travis.yml +21 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +21 -0
- data/README.md +68 -0
- data/Rakefile +25 -0
- data/excel_utils.gemspec +33 -0
- data/lib/excel_utils.rb +23 -0
- data/lib/excel_utils/sheet.rb +50 -0
- data/lib/excel_utils/version.rb +3 -0
- data/lib/excel_utils/workbook.rb +33 -0
- data/lib/excel_utils/writer.rb +63 -0
- data/spec/coverage_helper.rb +5 -0
- data/spec/minitest_helper.rb +6 -0
- data/spec/read_spec.rb +105 -0
- data/spec/sample.xls +0 -0
- data/spec/sample.xlsx +0 -0
- data/spec/write_spec.rb +33 -0
- metadata +230 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 13a477a8679749794ff54f4bb0a76c653b354be459d50ed1d7c89a6de8a32509
|
4
|
+
data.tar.gz: 920a86b0b1fb587105d7fc78609cf5bdd98a231aa6bee22726ebdfc090b3daca
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: cfb43adfda51aa543e1dd13e00f952b9eb0d2c9cec9dd7b41119eea1b2e0b2db433e47040c224dda7069f0ff0ec0b6d17f43f215f50e60a66db4545ecc740f5a
|
7
|
+
data.tar.gz: c1f424a05025b504b92cd5bf5b67f53c60129ad1973045daf263acf837301e61cc2681a9ce87a3ad90ba20e82a8ac1ef51891e9b2f6d387f4c3756fa6145a74f
|
data/.coveralls.yml
ADDED
data/.gitignore
ADDED
data/.ruby-gemset
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
excel_utils
|
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
ruby-2.7.0
|
data/.travis.yml
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
language: ruby
|
2
|
+
|
3
|
+
rvm:
|
4
|
+
- 2.0
|
5
|
+
- 2.1
|
6
|
+
- 2.2
|
7
|
+
- 2.3
|
8
|
+
- 2.4
|
9
|
+
- 2.5
|
10
|
+
- 2.6
|
11
|
+
- 2.7
|
12
|
+
- jruby-9.1.16.0
|
13
|
+
- jruby-9.2.9.0
|
14
|
+
- ruby-head
|
15
|
+
- jruby-head
|
16
|
+
|
17
|
+
matrix:
|
18
|
+
fast_finish: true
|
19
|
+
allow_failures:
|
20
|
+
- rvm: ruby-head
|
21
|
+
- rvm: jruby-head
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2020 Gabriel Naiman
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,68 @@
|
|
1
|
+
# ExcelUtils
|
2
|
+
|
3
|
+
[![Gem Version](https://badge.fury.io/rb/excel_utils.svg)](https://rubygems.org/gems/excel_utils)
|
4
|
+
[![Build Status](https://travis-ci.org/gabynaiman/excel_utils.svg?branch=master)](https://travis-ci.org/gabynaiman/excel_utils)
|
5
|
+
[![Coverage Status](https://coveralls.io/repos/github/gabynaiman/excel_utils/badge.svg?branch=master)](https://coveralls.io/github/gabynaiman/excel_utils?branch=master)
|
6
|
+
[![Code Climate](https://codeclimate.com/github/gabynaiman/excel_utils.svg)](https://codeclimate.com/github/gabynaiman/excel_utils)
|
7
|
+
|
8
|
+
Excel utils for easy read and write
|
9
|
+
|
10
|
+
## Installation
|
11
|
+
|
12
|
+
Add this line to your application's Gemfile:
|
13
|
+
|
14
|
+
```ruby
|
15
|
+
gem 'excel_utils'
|
16
|
+
```
|
17
|
+
|
18
|
+
And then execute:
|
19
|
+
|
20
|
+
$ bundle
|
21
|
+
|
22
|
+
Or install it yourself as:
|
23
|
+
|
24
|
+
$ gem install excel_utils
|
25
|
+
|
26
|
+
## Usage
|
27
|
+
|
28
|
+
### Write
|
29
|
+
```ruby
|
30
|
+
data = {
|
31
|
+
'Sheet1' => [
|
32
|
+
{column_a: 1.0, column_b: 'some text'},
|
33
|
+
{column_a: 2.0, column_b: 1.35},
|
34
|
+
{column_a: 3.0, column_b: Date.parse('2019-08-17')},
|
35
|
+
{column_a: 4.0, column_b: nil}
|
36
|
+
],
|
37
|
+
'Sheet2' => [
|
38
|
+
{'Column 1' => 123.0, 'Column 2' => 'Text 1'},
|
39
|
+
{'Column 1' => 456.0, 'Column 2' => 'Text 2'}
|
40
|
+
],
|
41
|
+
'Sheet3' => []
|
42
|
+
}
|
43
|
+
|
44
|
+
ExcelUtils.write '/path/to/file.xlsx', data
|
45
|
+
```
|
46
|
+
|
47
|
+
### Read
|
48
|
+
```ruby
|
49
|
+
workbook = ExcelUtils.read '/path/to/file.xlsx'
|
50
|
+
workbook.to_h => # {'Sheet1' => [{'Column A' => 1, ...}, ...], ...}
|
51
|
+
sheet = workbook['Sheet1']
|
52
|
+
sheet.name => # 'Sheet1'
|
53
|
+
sheet.column_names => # ['Column A', ...]
|
54
|
+
sheet.each # Implements enumerable module (map, to_a, ...)
|
55
|
+
|
56
|
+
workbook = ExcelUtils.read '/path/to/file.xlsx', normalize_column_names: true
|
57
|
+
workbook.to_h => # {'Sheet1' => [{column_a: 1, ...}, ...], ...}
|
58
|
+
sheet = workbook.sheets.first
|
59
|
+
sheet.column_names => # [:column_a, ...]
|
60
|
+
```
|
61
|
+
|
62
|
+
## Contributing
|
63
|
+
|
64
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/gabynaiman/excel_utils.
|
65
|
+
|
66
|
+
## License
|
67
|
+
|
68
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
data/Rakefile
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
require 'bundler/gem_tasks'
|
2
|
+
require 'rake/testtask'
|
3
|
+
|
4
|
+
Rake::TestTask.new(:spec) do |t|
|
5
|
+
t.libs << 'spec'
|
6
|
+
t.libs << 'lib'
|
7
|
+
t.pattern = ENV['DIR'] ? File.join(ENV['DIR'], '**', '*_spec.rb') : 'spec/**/*_spec.rb'
|
8
|
+
t.verbose = false
|
9
|
+
t.warning = false
|
10
|
+
t.loader = nil if ENV['TEST']
|
11
|
+
ENV['TEST'], ENV['LINE'] = ENV['TEST'].split(':') if ENV['TEST'] && !ENV['LINE']
|
12
|
+
t.options = ''
|
13
|
+
t.options << "--name=/#{ENV['NAME']}/ " if ENV['NAME']
|
14
|
+
t.options << "-l #{ENV['LINE']} " if ENV['LINE'] && ENV['TEST']
|
15
|
+
end
|
16
|
+
|
17
|
+
task default: :spec
|
18
|
+
|
19
|
+
desc 'Pry console'
|
20
|
+
task :console do
|
21
|
+
require 'excel_utils'
|
22
|
+
require 'pry'
|
23
|
+
ARGV.clear
|
24
|
+
Pry.start
|
25
|
+
end
|
data/excel_utils.gemspec
ADDED
@@ -0,0 +1,33 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require_relative 'lib/excel_utils/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = 'excel_utils'
|
8
|
+
spec.version = ExcelUtils::VERSION
|
9
|
+
spec.authors = ['Gabriel Naiman']
|
10
|
+
spec.email = ['gabynaiman@gmail.com']
|
11
|
+
spec.summary = 'Excel utils for easy read and write'
|
12
|
+
spec.description = 'Excel utils for easy read and write'
|
13
|
+
spec.homepage = 'https://github.com/gabynaiman/excel_utils'
|
14
|
+
spec.license = 'MIT'
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0")
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ['lib']
|
20
|
+
|
21
|
+
spec.add_runtime_dependency 'inflecto', '~> 0.0'
|
22
|
+
spec.add_runtime_dependency 'roo', '~> 2.7'
|
23
|
+
spec.add_runtime_dependency 'roo-xls', '~> 1.1'
|
24
|
+
spec.add_runtime_dependency 'write_xlsx', '~> 0.85'
|
25
|
+
|
26
|
+
spec.add_development_dependency 'rake', '~> 12.0'
|
27
|
+
spec.add_development_dependency 'minitest', '~> 5.0', '< 5.11'
|
28
|
+
spec.add_development_dependency 'minitest-colorin', '~> 0.1'
|
29
|
+
spec.add_development_dependency 'minitest-line', '~> 0.6'
|
30
|
+
spec.add_development_dependency 'simplecov', '~> 0.12'
|
31
|
+
spec.add_development_dependency 'coveralls', '~> 0.8'
|
32
|
+
spec.add_development_dependency 'pry-nav', '~> 0.2'
|
33
|
+
end
|
data/lib/excel_utils.rb
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
require 'date'
|
2
|
+
require 'time'
|
3
|
+
require 'roo'
|
4
|
+
require 'roo-xls'
|
5
|
+
require 'write_xlsx'
|
6
|
+
require 'inflecto'
|
7
|
+
|
8
|
+
require_relative 'excel_utils/version'
|
9
|
+
require_relative 'excel_utils/workbook'
|
10
|
+
require_relative 'excel_utils/sheet'
|
11
|
+
require_relative 'excel_utils/writer'
|
12
|
+
|
13
|
+
module ExcelUtils
|
14
|
+
|
15
|
+
def self.read(filename, **options)
|
16
|
+
Workbook.new filename, **options
|
17
|
+
end
|
18
|
+
|
19
|
+
def self.write(filename, data)
|
20
|
+
Writer.write filename, data
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
module ExcelUtils
|
2
|
+
class Sheet
|
3
|
+
|
4
|
+
include Enumerable
|
5
|
+
|
6
|
+
attr_reader :name, :normalize_column_names
|
7
|
+
|
8
|
+
def initialize(name, spreadsheet, normalize_column_names: false)
|
9
|
+
@name = name
|
10
|
+
@spreadsheet = spreadsheet
|
11
|
+
@normalize_column_names = normalize_column_names
|
12
|
+
end
|
13
|
+
|
14
|
+
def column_names
|
15
|
+
@column_names ||= begin
|
16
|
+
if sheet.first_row
|
17
|
+
first_row = sheet.row sheet.first_row
|
18
|
+
normalize_column_names ? first_row.map { |n| Inflecto.underscore(n.strip.gsub(' ', '_')).to_sym } : first_row
|
19
|
+
else
|
20
|
+
[]
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
def each(&block)
|
26
|
+
rows.each(&block)
|
27
|
+
end
|
28
|
+
|
29
|
+
private
|
30
|
+
|
31
|
+
attr_reader :spreadsheet
|
32
|
+
|
33
|
+
def sheet
|
34
|
+
spreadsheet.sheet name
|
35
|
+
end
|
36
|
+
|
37
|
+
def rows
|
38
|
+
@rows ||= begin
|
39
|
+
if sheet.first_row
|
40
|
+
sheet.to_a[1..-1].map do |row|
|
41
|
+
Hash[column_names.zip(row)]
|
42
|
+
end
|
43
|
+
else
|
44
|
+
[]
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
end
|
50
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
module ExcelUtils
|
2
|
+
class Workbook
|
3
|
+
|
4
|
+
attr_reader :filename, :normalize_column_names
|
5
|
+
|
6
|
+
def initialize(filename, normalize_column_names: false)
|
7
|
+
@filename = filename
|
8
|
+
@normalize_column_names = normalize_column_names
|
9
|
+
@spreadsheet = Roo::Spreadsheet.open filename
|
10
|
+
end
|
11
|
+
|
12
|
+
def sheets
|
13
|
+
@sheets ||= spreadsheet.sheets.map do |name|
|
14
|
+
Sheet.new name, spreadsheet, normalize_column_names: normalize_column_names
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
def [](sheet_name)
|
19
|
+
sheets.detect { |sheet| sheet.name == sheet_name }
|
20
|
+
end
|
21
|
+
|
22
|
+
def to_h
|
23
|
+
sheets.each_with_object({}) do |sheet, hash|
|
24
|
+
hash[sheet.name] = sheet.to_a
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
private
|
29
|
+
|
30
|
+
attr_reader :spreadsheet
|
31
|
+
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,63 @@
|
|
1
|
+
module ExcelUtils
|
2
|
+
class Writer
|
3
|
+
|
4
|
+
TIME_FORMAT = '%Y-%m-%dT%H:%M:%S'
|
5
|
+
|
6
|
+
EXCEL_FORMATS = {
|
7
|
+
date: 'yyyy-mm-dd',
|
8
|
+
date_time: 'yyyy-mm-dd hh:mm:ss'
|
9
|
+
}
|
10
|
+
|
11
|
+
class << self
|
12
|
+
|
13
|
+
def write(filename, data)
|
14
|
+
workbook = WriteXLSX.new filename, strings_to_urls: false
|
15
|
+
|
16
|
+
formats = add_formats workbook
|
17
|
+
|
18
|
+
data.each do |sheet_name, sheet_data|
|
19
|
+
add_sheet workbook, sheet_name, sheet_data, formats
|
20
|
+
end
|
21
|
+
|
22
|
+
workbook.close
|
23
|
+
end
|
24
|
+
|
25
|
+
private
|
26
|
+
|
27
|
+
def add_formats(workbook)
|
28
|
+
EXCEL_FORMATS.each_with_object({}) do |(type, value), formats|
|
29
|
+
formats[type] = workbook.add_format num_format: value
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
def add_sheet(workbook, sheet_name, sheet_data, formats)
|
34
|
+
sheet = workbook.add_worksheet sheet_name
|
35
|
+
|
36
|
+
if sheet_data.any?
|
37
|
+
header = sheet_data.first.keys
|
38
|
+
sheet.write_row 0, 0, header.map(&:to_s)
|
39
|
+
|
40
|
+
sheet_data.each_with_index do |row, r|
|
41
|
+
header.each_with_index do |column, c|
|
42
|
+
if row[column]
|
43
|
+
if row[column].respond_to? :to_time
|
44
|
+
time = row[column].to_time
|
45
|
+
type = date?(time) ? :date : :date_time
|
46
|
+
sheet.write_date_time r + 1, c, time.to_time.strftime(TIME_FORMAT), formats[type]
|
47
|
+
else
|
48
|
+
sheet.write r + 1, c, row[column]
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
def date?(time)
|
57
|
+
time.hour + time.min + time.sec == 0
|
58
|
+
end
|
59
|
+
|
60
|
+
end
|
61
|
+
|
62
|
+
end
|
63
|
+
end
|
data/spec/read_spec.rb
ADDED
@@ -0,0 +1,105 @@
|
|
1
|
+
require 'minitest_helper'
|
2
|
+
|
3
|
+
describe ExcelUtils, 'Read' do
|
4
|
+
|
5
|
+
def expected_rows(sheet)
|
6
|
+
rows_by_sheet[sheet.name].map { |r| Hash[columns_by_sheet[sheet.name].zip(r)] }
|
7
|
+
end
|
8
|
+
|
9
|
+
let :rows_by_sheet do
|
10
|
+
{
|
11
|
+
'Sheet1' => [
|
12
|
+
[1.0, 'some text'],
|
13
|
+
[2.0, 1.35],
|
14
|
+
[3.0, Date.parse('2019-08-17')],
|
15
|
+
[4.0, nil]
|
16
|
+
],
|
17
|
+
'Sheet2' => [
|
18
|
+
[123.0, 'Text 1'],
|
19
|
+
[456.0, 'Text 2']
|
20
|
+
],
|
21
|
+
'Sheet3' => []
|
22
|
+
}
|
23
|
+
end
|
24
|
+
|
25
|
+
['xls', 'xlsx'].each do |extension|
|
26
|
+
|
27
|
+
describe extension do
|
28
|
+
|
29
|
+
let(:filename) { File.expand_path "../sample.#{extension}", __FILE__ }
|
30
|
+
|
31
|
+
describe 'Original column names' do
|
32
|
+
|
33
|
+
let(:workbook) { ExcelUtils.read filename }
|
34
|
+
|
35
|
+
let :columns_by_sheet do
|
36
|
+
{
|
37
|
+
'Sheet1' => ['Column A', 'Column B'],
|
38
|
+
'Sheet2' => ['ID', 'Value'],
|
39
|
+
'Sheet3' => []
|
40
|
+
}
|
41
|
+
end
|
42
|
+
|
43
|
+
it 'to_h' do
|
44
|
+
workbook.to_h.must_equal 'Sheet1' => expected_rows(workbook['Sheet1']),
|
45
|
+
'Sheet2' => expected_rows(workbook['Sheet2']),
|
46
|
+
'Sheet3' => []
|
47
|
+
end
|
48
|
+
|
49
|
+
['Sheet1', 'Sheet2', 'Sheet3'].each do |sheet_name|
|
50
|
+
|
51
|
+
describe sheet_name do
|
52
|
+
|
53
|
+
let(:sheet) { workbook[sheet_name] }
|
54
|
+
|
55
|
+
it 'Column names' do
|
56
|
+
sheet.column_names.must_equal columns_by_sheet[sheet_name]
|
57
|
+
end
|
58
|
+
|
59
|
+
it 'Rows' do
|
60
|
+
sheet.to_a.must_equal expected_rows(sheet)
|
61
|
+
end
|
62
|
+
|
63
|
+
end
|
64
|
+
|
65
|
+
end
|
66
|
+
|
67
|
+
end
|
68
|
+
|
69
|
+
describe 'Normalized column names' do
|
70
|
+
|
71
|
+
let(:workbook) { ExcelUtils.read filename, normalize_column_names: true }
|
72
|
+
|
73
|
+
let :columns_by_sheet do
|
74
|
+
{
|
75
|
+
'Sheet1' => [:column_a, :column_b],
|
76
|
+
'Sheet2' => [:id, :value],
|
77
|
+
'Sheet3' => []
|
78
|
+
}
|
79
|
+
end
|
80
|
+
|
81
|
+
['Sheet1', 'Sheet2', 'Sheet3'].each do |sheet_name|
|
82
|
+
|
83
|
+
describe sheet_name do
|
84
|
+
|
85
|
+
let(:sheet) { workbook[sheet_name] }
|
86
|
+
|
87
|
+
it 'Column names' do
|
88
|
+
sheet.column_names.must_equal columns_by_sheet[sheet_name]
|
89
|
+
end
|
90
|
+
|
91
|
+
it 'Rows' do
|
92
|
+
sheet.to_a.must_equal expected_rows(sheet)
|
93
|
+
end
|
94
|
+
|
95
|
+
end
|
96
|
+
|
97
|
+
end
|
98
|
+
|
99
|
+
end
|
100
|
+
|
101
|
+
end
|
102
|
+
|
103
|
+
end
|
104
|
+
|
105
|
+
end
|
data/spec/sample.xls
ADDED
Binary file
|
data/spec/sample.xlsx
ADDED
Binary file
|
data/spec/write_spec.rb
ADDED
@@ -0,0 +1,33 @@
|
|
1
|
+
require 'minitest_helper'
|
2
|
+
|
3
|
+
describe ExcelUtils do
|
4
|
+
|
5
|
+
let(:tmp_path) { File.expand_path '../../tmp', __FILE__ }
|
6
|
+
|
7
|
+
let(:filename) { File.join tmp_path, "#{SecureRandom.uuid}.xlsx" }
|
8
|
+
|
9
|
+
before do
|
10
|
+
FileUtils.rm_rf tmp_path
|
11
|
+
FileUtils.mkpath tmp_path
|
12
|
+
end
|
13
|
+
|
14
|
+
it 'Write' do
|
15
|
+
data = {
|
16
|
+
'Sheet 1' => [
|
17
|
+
{'column_a' => 1.5, 'column_b' => 'text 1', 'column_c' => DateTime.parse('2019-05-25T16:30:00')},
|
18
|
+
{'column_b' => 'text 2', 'column_c' => Date.parse('2019-07-09'), 'column_a' => 2},
|
19
|
+
],
|
20
|
+
'Sheet 2' => [
|
21
|
+
{'Column A' => 'Text A', 'Column B' => 'Text B'}
|
22
|
+
],
|
23
|
+
'Sheet 3' => []
|
24
|
+
}
|
25
|
+
|
26
|
+
ExcelUtils.write filename, data
|
27
|
+
|
28
|
+
workbook = ExcelUtils.read filename
|
29
|
+
|
30
|
+
workbook.to_h.must_equal data
|
31
|
+
end
|
32
|
+
|
33
|
+
end
|
metadata
ADDED
@@ -0,0 +1,230 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: excel_utils
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Gabriel Naiman
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2020-03-03 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: inflecto
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0.0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0.0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: roo
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '2.7'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '2.7'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: roo-xls
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '1.1'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '1.1'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: write_xlsx
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0.85'
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0.85'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rake
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '12.0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '12.0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: minitest
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '5.0'
|
90
|
+
- - "<"
|
91
|
+
- !ruby/object:Gem::Version
|
92
|
+
version: '5.11'
|
93
|
+
type: :development
|
94
|
+
prerelease: false
|
95
|
+
version_requirements: !ruby/object:Gem::Requirement
|
96
|
+
requirements:
|
97
|
+
- - "~>"
|
98
|
+
- !ruby/object:Gem::Version
|
99
|
+
version: '5.0'
|
100
|
+
- - "<"
|
101
|
+
- !ruby/object:Gem::Version
|
102
|
+
version: '5.11'
|
103
|
+
- !ruby/object:Gem::Dependency
|
104
|
+
name: minitest-colorin
|
105
|
+
requirement: !ruby/object:Gem::Requirement
|
106
|
+
requirements:
|
107
|
+
- - "~>"
|
108
|
+
- !ruby/object:Gem::Version
|
109
|
+
version: '0.1'
|
110
|
+
type: :development
|
111
|
+
prerelease: false
|
112
|
+
version_requirements: !ruby/object:Gem::Requirement
|
113
|
+
requirements:
|
114
|
+
- - "~>"
|
115
|
+
- !ruby/object:Gem::Version
|
116
|
+
version: '0.1'
|
117
|
+
- !ruby/object:Gem::Dependency
|
118
|
+
name: minitest-line
|
119
|
+
requirement: !ruby/object:Gem::Requirement
|
120
|
+
requirements:
|
121
|
+
- - "~>"
|
122
|
+
- !ruby/object:Gem::Version
|
123
|
+
version: '0.6'
|
124
|
+
type: :development
|
125
|
+
prerelease: false
|
126
|
+
version_requirements: !ruby/object:Gem::Requirement
|
127
|
+
requirements:
|
128
|
+
- - "~>"
|
129
|
+
- !ruby/object:Gem::Version
|
130
|
+
version: '0.6'
|
131
|
+
- !ruby/object:Gem::Dependency
|
132
|
+
name: simplecov
|
133
|
+
requirement: !ruby/object:Gem::Requirement
|
134
|
+
requirements:
|
135
|
+
- - "~>"
|
136
|
+
- !ruby/object:Gem::Version
|
137
|
+
version: '0.12'
|
138
|
+
type: :development
|
139
|
+
prerelease: false
|
140
|
+
version_requirements: !ruby/object:Gem::Requirement
|
141
|
+
requirements:
|
142
|
+
- - "~>"
|
143
|
+
- !ruby/object:Gem::Version
|
144
|
+
version: '0.12'
|
145
|
+
- !ruby/object:Gem::Dependency
|
146
|
+
name: coveralls
|
147
|
+
requirement: !ruby/object:Gem::Requirement
|
148
|
+
requirements:
|
149
|
+
- - "~>"
|
150
|
+
- !ruby/object:Gem::Version
|
151
|
+
version: '0.8'
|
152
|
+
type: :development
|
153
|
+
prerelease: false
|
154
|
+
version_requirements: !ruby/object:Gem::Requirement
|
155
|
+
requirements:
|
156
|
+
- - "~>"
|
157
|
+
- !ruby/object:Gem::Version
|
158
|
+
version: '0.8'
|
159
|
+
- !ruby/object:Gem::Dependency
|
160
|
+
name: pry-nav
|
161
|
+
requirement: !ruby/object:Gem::Requirement
|
162
|
+
requirements:
|
163
|
+
- - "~>"
|
164
|
+
- !ruby/object:Gem::Version
|
165
|
+
version: '0.2'
|
166
|
+
type: :development
|
167
|
+
prerelease: false
|
168
|
+
version_requirements: !ruby/object:Gem::Requirement
|
169
|
+
requirements:
|
170
|
+
- - "~>"
|
171
|
+
- !ruby/object:Gem::Version
|
172
|
+
version: '0.2'
|
173
|
+
description: Excel utils for easy read and write
|
174
|
+
email:
|
175
|
+
- gabynaiman@gmail.com
|
176
|
+
executables: []
|
177
|
+
extensions: []
|
178
|
+
extra_rdoc_files: []
|
179
|
+
files:
|
180
|
+
- ".coveralls.yml"
|
181
|
+
- ".gitignore"
|
182
|
+
- ".ruby-gemset"
|
183
|
+
- ".ruby-version"
|
184
|
+
- ".travis.yml"
|
185
|
+
- Gemfile
|
186
|
+
- LICENSE.txt
|
187
|
+
- README.md
|
188
|
+
- Rakefile
|
189
|
+
- excel_utils.gemspec
|
190
|
+
- lib/excel_utils.rb
|
191
|
+
- lib/excel_utils/sheet.rb
|
192
|
+
- lib/excel_utils/version.rb
|
193
|
+
- lib/excel_utils/workbook.rb
|
194
|
+
- lib/excel_utils/writer.rb
|
195
|
+
- spec/coverage_helper.rb
|
196
|
+
- spec/minitest_helper.rb
|
197
|
+
- spec/read_spec.rb
|
198
|
+
- spec/sample.xls
|
199
|
+
- spec/sample.xlsx
|
200
|
+
- spec/write_spec.rb
|
201
|
+
homepage: https://github.com/gabynaiman/excel_utils
|
202
|
+
licenses:
|
203
|
+
- MIT
|
204
|
+
metadata: {}
|
205
|
+
post_install_message:
|
206
|
+
rdoc_options: []
|
207
|
+
require_paths:
|
208
|
+
- lib
|
209
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
210
|
+
requirements:
|
211
|
+
- - ">="
|
212
|
+
- !ruby/object:Gem::Version
|
213
|
+
version: '0'
|
214
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
215
|
+
requirements:
|
216
|
+
- - ">="
|
217
|
+
- !ruby/object:Gem::Version
|
218
|
+
version: '0'
|
219
|
+
requirements: []
|
220
|
+
rubygems_version: 3.1.2
|
221
|
+
signing_key:
|
222
|
+
specification_version: 4
|
223
|
+
summary: Excel utils for easy read and write
|
224
|
+
test_files:
|
225
|
+
- spec/coverage_helper.rb
|
226
|
+
- spec/minitest_helper.rb
|
227
|
+
- spec/read_spec.rb
|
228
|
+
- spec/sample.xls
|
229
|
+
- spec/sample.xlsx
|
230
|
+
- spec/write_spec.rb
|