portable 1.0.0.pre.alpha.3 → 1.0.0.pre.alpha.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +1 -1
- data/lib/portable.rb +1 -0
- data/lib/portable/version.rb +1 -1
- data/lib/portable/writers/csv.rb +16 -17
- data/lib/portable/writers/result.rb +24 -0
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 79f24ff23c62ae9aa19e46c4f63d7db4a54edd80f4450c8b9042166d5823f3f4
|
4
|
+
data.tar.gz: 4eb7d7ad21a4c51af23f2a915e5e7ff893fe7adfa37d320cb99b25f6adc2daf8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ae92f80d1b767fd32256061db8efdad5dfe70d706f9b43076cc01b174af0c4a455b5a2101a8f2ed6002caa0353c89a414736b8d13e7973ba2fe767cea0db8689
|
7
|
+
data.tar.gz: 9b16676405f572b58e90f1cb551620549a193215076d99f3505d1a1564e4bea68305385d68a5df56f9df782994b09b803ef4d87161713186c6f4dd8fd2b61f7c
|
data/.rubocop.yml
CHANGED
data/lib/portable.rb
CHANGED
data/lib/portable/version.rb
CHANGED
data/lib/portable/writers/csv.rb
CHANGED
@@ -8,6 +8,7 @@
|
|
8
8
|
#
|
9
9
|
|
10
10
|
require_relative 'base'
|
11
|
+
require_relative 'result'
|
11
12
|
|
12
13
|
module Portable
|
13
14
|
module Writers
|
@@ -18,16 +19,18 @@ module Portable
|
|
18
19
|
|
19
20
|
ensure_directory_exists(filename)
|
20
21
|
|
21
|
-
sheet_filenames = extrapolate_filenames(filename)
|
22
|
+
sheet_filenames = extrapolate_filenames(filename, document.sheets.length)
|
22
23
|
|
23
|
-
document.sheets.
|
24
|
+
document.sheets.map.with_index do |sheet, index|
|
24
25
|
data_source = data_provider.data_source(sheet.name)
|
25
|
-
sheet_filename = sheet_filenames[
|
26
|
+
sheet_filename = sheet_filenames[index]
|
26
27
|
|
27
|
-
|
28
|
-
|
28
|
+
time_in_seconds = Benchmark.measure do
|
29
|
+
write_sheet(sheet_filename, sheet, data_source, time)
|
30
|
+
end.real
|
29
31
|
|
30
|
-
|
32
|
+
Result.new(sheet_filename, time_in_seconds)
|
33
|
+
end
|
31
34
|
end
|
32
35
|
|
33
36
|
private
|
@@ -70,21 +73,17 @@ module Portable
|
|
70
73
|
FileUtils.mkdir_p(path) unless File.exist?(path)
|
71
74
|
end
|
72
75
|
|
73
|
-
def extrapolate_filenames(filename)
|
74
|
-
index = 0
|
76
|
+
def extrapolate_filenames(filename, count)
|
75
77
|
dir = File.dirname(filename)
|
76
78
|
ext = File.extname(filename)
|
77
79
|
basename = File.basename(filename, ext)
|
78
80
|
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
end
|
86
|
-
|
87
|
-
index += 1
|
81
|
+
(0..count).map do |index|
|
82
|
+
if index.positive?
|
83
|
+
File.join(dir, "#{basename}.#{index}#{ext}")
|
84
|
+
else
|
85
|
+
filename
|
86
|
+
end
|
88
87
|
end
|
89
88
|
end
|
90
89
|
end
|
@@ -0,0 +1,24 @@
|
|
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
|
+
module Portable
|
11
|
+
module Writers
|
12
|
+
# Result return object from a Writer#write! call.
|
13
|
+
class Result
|
14
|
+
attr_reader :filename, :time_in_seconds
|
15
|
+
|
16
|
+
def initialize(filename, time_in_seconds)
|
17
|
+
@filename = filename
|
18
|
+
@time_in_seconds = time_in_seconds
|
19
|
+
|
20
|
+
freeze
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
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.pre.alpha.
|
4
|
+
version: 1.0.0.pre.alpha.4
|
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-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: acts_as_hashable
|
@@ -190,6 +190,7 @@ files:
|
|
190
190
|
- lib/portable/writers.rb
|
191
191
|
- lib/portable/writers/base.rb
|
192
192
|
- lib/portable/writers/csv.rb
|
193
|
+
- lib/portable/writers/result.rb
|
193
194
|
- portable.gemspec
|
194
195
|
homepage: https://github.com/bluemarblepayroll/portable
|
195
196
|
licenses:
|