berkeley_library-holdings 1.0.1 → 1.0.3

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: 3eb22100a823f3b72627e1298176ff71d2f03a1a73262018b2739d43fcceded1
4
- data.tar.gz: 128191b7233193db6135bb5d9229f71ffe017c945261047203d6a1f9734c9cb5
3
+ metadata.gz: e63c750942749c07b981b702ef360b3c554f3e63107d47821dd0872ed6676c28
4
+ data.tar.gz: e9a80f67dff1895124ff50813bd594a109ab8e84a7e8d0825248917dcf1b3501
5
5
  SHA512:
6
- metadata.gz: e7ee7b5b3178c507f6e7e937d56d9b0fe48cfbe6116ce12a29343e3ed4d9155803b14fdca813e5a0a967856033e45e7051687915c90f3ea371e5d36ca817719e
7
- data.tar.gz: 2bfe0f25c2f0375f4b95f78a49440a56688473ac5cd68ddea3c3e492df72662955762749ffa87b0ee0e53c13dc1b214525645a4bf5bd18241681c0455b61f701
6
+ metadata.gz: db655747b51ef598e41b6bc4411452e912558af91d81a1c7067c1204f5a0eb3113dfeb8cec8d1f31454251914280c58ec08cfe9c1ebe3c9f5ec0a8d4ee9c906b
7
+ data.tar.gz: 9f573016a2ef9bd89411513c6007dd14ab4dbf701ce7a81cf14bbad4a8cd3db5fba0494575c8980bcc53a498c10c3364c9b2c385472968246f78fdc3cba2f0b8
data/CHANGES.md ADDED
@@ -0,0 +1,19 @@
1
+ # 1.0.3 (2023-04-27)
2
+
3
+ - Fix issue requiring RubyXL extensions to be explicitly required
4
+
5
+ # 1.0.2 (2023-04-27)
6
+
7
+ - Overwrite existing blank columns when writing results to spreadsheet
8
+
9
+ # 1.0.1 (2023-04-26)
10
+
11
+ - First working RubyGems release
12
+
13
+ # 1.0.0 (2023-04-25)
14
+
15
+ - Initial (broken) RubyGems release
16
+
17
+ # 0.1.0 (2023-02-24)
18
+
19
+ - Initial release
@@ -7,7 +7,7 @@ module BerkeleyLibrary
7
7
  SUMMARY = 'Holdings-related utilities for the UC Berkeley Library'.freeze
8
8
  DESCRIPTION = 'A collection of holdings-related utilities for the UC Berkeley Library'.freeze
9
9
  LICENSE = 'MIT'.freeze
10
- VERSION = '1.0.1'.freeze
10
+ VERSION = '1.0.3'.freeze
11
11
  HOMEPAGE = 'https://github.com/BerkeleyLibrary/holdings'.freeze
12
12
  end
13
13
  end
@@ -0,0 +1,31 @@
1
+ require 'rubyXL'
2
+
3
+ module BerkeleyLibrary
4
+ module Util
5
+ module XLSX
6
+ module RubyXLCellExtensions
7
+ # Workaround for https://github.com/weshatheleopard/rubyXL/issues/441
8
+ def initialize(params = nil)
9
+ super
10
+
11
+ return unless params.respond_to?(:[])
12
+
13
+ @worksheet ||= params[:worksheet]
14
+ self.row ||= params[:row] # NOTE: not an instance variable
15
+ end
16
+
17
+ def blank?
18
+ return true if value.nil?
19
+
20
+ value.respond_to?(:strip) && value.strip.empty?
21
+ end
22
+ end
23
+ end
24
+ end
25
+ end
26
+
27
+ module RubyXL
28
+ class Cell
29
+ prepend BerkeleyLibrary::Util::XLSX::RubyXLCellExtensions
30
+ end
31
+ end
@@ -0,0 +1,24 @@
1
+ require 'rubyXL'
2
+ require 'berkeley_library/util/xlsx/rubyxl_cell_extensions'
3
+
4
+ module BerkeleyLibrary
5
+ module Util
6
+ module XLSX
7
+ module RubyXLWorksheetExtensions
8
+ def first_blank_column_index
9
+ sheet_data.rows.inject(0) do |first_blank_c_index, row|
10
+ trailing_blank_cells = row.cells.reverse.take_while(&:blank?)
11
+ row_first_blank_c_index = row.size - trailing_blank_cells.size
12
+ [first_blank_c_index, row_first_blank_c_index].max
13
+ end
14
+ end
15
+ end
16
+ end
17
+ end
18
+ end
19
+
20
+ module RubyXL
21
+ class Worksheet
22
+ prepend BerkeleyLibrary::Util::XLSX::RubyXLWorksheetExtensions
23
+ end
24
+ end
@@ -3,6 +3,7 @@ require 'rubyXL'
3
3
  require 'rubyXL/convenience_methods/cell'
4
4
  require 'rubyXL/convenience_methods/worksheet'
5
5
  require 'zip'
6
+ require 'berkeley_library/util/xlsx'
6
7
 
7
8
  module BerkeleyLibrary
8
9
  module Util
@@ -113,7 +114,8 @@ module BerkeleyLibrary
113
114
  c_index_existing = find_column_index_by_header(header)
114
115
  return c_index_existing if c_index_existing
115
116
 
116
- column_count.tap { |cc| worksheet.insert_cell(0, cc, header) }
117
+ c_index_next = worksheet.first_blank_column_index
118
+ c_index_next.tap { |cc| worksheet.add_cell(0, cc, header) }
117
119
  end
118
120
 
119
121
  private
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: berkeley_library-holdings
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Moles
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-04-26 00:00:00.000000000 Z
11
+ date: 2023-04-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: berkeley_library-logging
@@ -260,7 +260,7 @@ executables: []
260
260
  extensions: []
261
261
  extra_rdoc_files: []
262
262
  files:
263
- - CHANGELOG.md
263
+ - CHANGES.md
264
264
  - LICENSE.md
265
265
  - README.md
266
266
  - lib/berkeley_library/holdings.rb
@@ -280,6 +280,8 @@ files:
280
280
  - lib/berkeley_library/holdings/xlsx_reader.rb
281
281
  - lib/berkeley_library/holdings/xlsx_writer.rb
282
282
  - lib/berkeley_library/util/xlsx.rb
283
+ - lib/berkeley_library/util/xlsx/rubyxl_cell_extensions.rb
284
+ - lib/berkeley_library/util/xlsx/rubyxl_worksheet_extensions.rb
283
285
  - lib/berkeley_library/util/xlsx/spreadsheet.rb
284
286
  homepage: https://github.com/BerkeleyLibrary/holdings
285
287
  licenses:
data/CHANGELOG.md DELETED
@@ -1,5 +0,0 @@
1
- ## [Unreleased]
2
-
3
- ## [0.1.0] - 2023-02-24
4
-
5
- - Initial release