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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 32da634ac58591d5130ab01ddb7e6953144f663b563fdce844817473db370bde
4
- data.tar.gz: c7b6ded1144b5cdb46ab702a5d23480d4a778b4bfa134c21f4ae884bf1ecc220
3
+ metadata.gz: 79f24ff23c62ae9aa19e46c4f63d7db4a54edd80f4450c8b9042166d5823f3f4
4
+ data.tar.gz: 4eb7d7ad21a4c51af23f2a915e5e7ff893fe7adfa37d320cb99b25f6adc2daf8
5
5
  SHA512:
6
- metadata.gz: b3cbe61597e5ea310d8084cafcaea7cf75476d969e5ad833ee140397d92cfe9d7c2baf2f5d930754f1870dd1f1b757f91562d79bfdee74e870670f21c981712f
7
- data.tar.gz: 3a101c3f5c3467060cfe7b237efec41e51435d0fe0941a753d6e6b03ba776b99f8aad1845d62015e6cf54a6bbd464902414f8bd0128d7c3cbc8682afd4d084bc
6
+ metadata.gz: ae92f80d1b767fd32256061db8efdad5dfe70d706f9b43076cc01b174af0c4a455b5a2101a8f2ed6002caa0353c89a414736b8d13e7973ba2fe767cea0db8689
7
+ data.tar.gz: 9b16676405f572b58e90f1cb551620549a193215076d99f3505d1a1564e4bea68305385d68a5df56f9df782994b09b803ef4d87161713186c6f4dd8fd2b61f7c
@@ -20,7 +20,7 @@ Metrics/MethodLength:
20
20
  Max: 30
21
21
 
22
22
  Metrics/AbcSize:
23
- Max: 17
23
+ Max: 20
24
24
 
25
25
  Metrics/ClassLength:
26
26
  Max: 125
@@ -8,6 +8,7 @@
8
8
  #
9
9
 
10
10
  require 'acts_as_hashable'
11
+ require 'benchmark'
11
12
  require 'csv'
12
13
  require 'fileutils'
13
14
  require 'forwardable'
@@ -8,5 +8,5 @@
8
8
  #
9
9
 
10
10
  module Portable
11
- VERSION = '1.0.0-alpha.3'
11
+ VERSION = '1.0.0-alpha.4'
12
12
  end
@@ -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.each do |sheet|
24
+ document.sheets.map.with_index do |sheet, index|
24
25
  data_source = data_provider.data_source(sheet.name)
25
- sheet_filename = sheet_filenames[sheet.name]
26
+ sheet_filename = sheet_filenames[index]
26
27
 
27
- write_sheet(sheet_filename, sheet, data_source, time)
28
- end
28
+ time_in_seconds = Benchmark.measure do
29
+ write_sheet(sheet_filename, sheet, data_source, time)
30
+ end.real
29
31
 
30
- sheet_filenames.values
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
- document.sheets.each_with_object({}) do |sheet, memo|
80
- memo[sheet.name] =
81
- if index.positive?
82
- File.join(dir, "#{basename}.#{index}#{ext}")
83
- else
84
- filename
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.3
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-07 00:00:00.000000000 Z
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: