Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ jobs:
fail-fast: false
matrix:
os: [ ubuntu-latest, macos-latest ]
ruby: [ '3.1', '3.2' ]
ruby: [ '3.3', '3.4' ]
runs-on: ${{ matrix.os }}

steps:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/gem-push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: '3.2'
ruby-version: '3.3'
bundler-cache: true

- name: Publish to RubyGems
Expand Down
3 changes: 3 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ inherit_mode:
- Exclude
- Include

AllCops:
TargetRubyVersion: 3.3

# Allow one line around block body (Layout/EmptyLines will still disallow two or more)
Layout/EmptyLinesAroundBlockBody:
Enabled: false
Expand Down
2 changes: 1 addition & 1 deletion .ruby-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3.1.2
~> 3.3
5 changes: 3 additions & 2 deletions berkeley_library-location.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ Gem::Specification.new do |spec|
spec.version = BerkeleyLibrary::Location::ModuleInfo::VERSION
spec.homepage = BerkeleyLibrary::Location::ModuleInfo::HOMEPAGE

spec.required_ruby_version = '>= 3.1.0'
spec.required_ruby_version = '>= 3.3.0'

spec.metadata['homepage_uri'] = spec.homepage
spec.metadata['source_code_uri'] = spec.homepage
Expand All @@ -31,6 +31,7 @@ Gem::Specification.new do |spec|
spec.add_dependency 'berkeley_library-util', '~> 0.1', '>= 0.1.9'
spec.add_dependency 'jsonpath', '~> 0.5.8'
spec.add_dependency 'marcel', '~> 1.0.2'
spec.add_dependency 'nokogiri', '>= 1.19.1'
spec.add_dependency 'rest-client', '~> 2.1'
spec.add_dependency 'rubyXL', '~> 3.4'

Expand All @@ -40,7 +41,7 @@ Gem::Specification.new do |spec|
spec.add_development_dependency 'dotenv', '~> 2.7'
spec.add_development_dependency 'rake', '~> 13.0'
spec.add_development_dependency 'rspec', '~> 3.10'
spec.add_development_dependency 'rubocop', '= 1.39'
spec.add_development_dependency 'rubocop', '~> 1.75'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we want to ~> 1.75? This will automatically pull in newer versions (and potentially change reports/passes) whenever dependencies are updated. We did ~> 1.84.0 in UCBEARS and ~> 1.77.0 in Framework; should this be ~> 1.75.0 instead?

spec.add_development_dependency 'rubocop-rake', '= 0.6.0'
spec.add_development_dependency 'rubocop-rspec', '= 2.4.0'
spec.add_development_dependency 'ruby-prof', '~> 1.7.1'
Expand Down
2 changes: 2 additions & 0 deletions lib/berkeley_library/location/xlsx_reader.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ def each_oclc_number
return to_enum(:each_oclc_number) unless block_given?

ss.each_value(oclc_col_index, include_header: false) do |v|
# convert to integer if oclc number is a float in the spreadsheet"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
# convert to integer if oclc number is a float in the spreadsheet"
# convert to integer if oclc number is a float in the spreadsheet

v = v.to_i if v.is_a?(Float)
next if (v_str = v.to_s).strip == ''

yield v_str
Expand Down
2 changes: 1 addition & 1 deletion spec/.rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -123,5 +123,5 @@ RSpec/VerifiedDoubles:
RSpec/IdenticalEqualityAssertion: # new in 2.4
Enabled: true

RSpec/Rails/AvoidSetupHook: # new in 2.4
RSpecRails/AvoidSetupHook:
Enabled: true
28 changes: 28 additions & 0 deletions spec/berkeley_library/location/xlsx_reader_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -73,12 +73,40 @@ module Location
.to yield_successive_args(*oclc_numbers_expected)
end

# Added this since oclc floats in oclc-numbers-float.xlsx weren't being read
# in as floats at runtime.
it 'processes OCLC numbers converted to floats from the base spreadsheet' do
source_xlsx_path = 'spec/data/excel/oclc-numbers.xlsx'
source_oclc_numbers = XLSXReader.new(source_xlsx_path).each_oclc_number.to_a

Dir.mktmpdir(File.basename(__FILE__)) do |tmpdir|
xlsx_path = File.join(tmpdir, 'oclc-numbers-from-source-as-floats.xlsx')

ss = BerkeleyLibrary::Util::XLSX::Spreadsheet.new
c_index = ss.ensure_column!(BerkeleyLibrary::Location::Constants::OCLC_COL_HEADER)
source_oclc_numbers.each_with_index do |oclc_num, i|
r_index = 1 + i # skip header row
ss.set_value_at(r_index, c_index, oclc_num.to_f)
end
ss.save_as(xlsx_path)

reader = XLSXReader.new(xlsx_path)
expect(reader.each_oclc_number.to_a).to eq(source_oclc_numbers)
end
end

it 'finds OCLC numbers as strings' do
reader = XLSXReader.new('spec/data/excel/oclc-numbers-text.xlsx')
expect { |b| reader.each_oclc_number(&b) }
.to yield_successive_args(*oclc_numbers_expected)
end

it 'finds OCLC numbers when column is formatted as Excel number' do
reader = XLSXReader.new('spec/data/excel/oclc-numbers-float.xlsx')
expect { |b| reader.each_oclc_number(&b) }
.to yield_successive_args(*oclc_numbers_expected)
end

it 'skips blank cells' do
reader = XLSXReader.new('spec/data/excel/oclc-numbers-sparse.xlsx')
expect { |b| reader.each_oclc_number(&b) }
Expand Down
Binary file added spec/data/excel/oclc-numbers-float.xlsx
Binary file not shown.
Loading