From 90f5aa702a8d02a70827d6454a0eeca26bd7996b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?mar=C3=ADa=20a=2E=20matienzo?= Date: Wed, 23 Jul 2025 10:28:05 -0700 Subject: [PATCH 1/5] Update to ruby 3.3 & latest rubocop gems --- .github/workflows/build.yml | 4 +- .rubocop.yml | 138 ++++++++++++++++++ Dockerfile | 3 +- berkeley_library-alma.gemspec | 6 +- rakelib/.rubocop.yml | 2 +- spec/.rubocop.yml | 12 +- .../alma/sru/xml_reader_spec.rb | 2 +- 7 files changed, 155 insertions(+), 12 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 35997ec..936d76d 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -6,7 +6,7 @@ jobs: fail-fast: false matrix: os: [ ubuntu-latest, macos-latest ] - ruby: [ '2.7', '3.0', '3.1' ] + ruby: [ '3.3', '3.4' ] runs-on: ${{ matrix.os }} steps: @@ -24,7 +24,7 @@ jobs: - name: Upload artifacts if: ${{ always() }} - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: name: artifacts path: artifacts/** diff --git a/.rubocop.yml b/.rubocop.yml index 57e5faf..d5c328e 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -487,3 +487,141 @@ Style/RedundantStringEscape: # (new in 1.37) Style/RedundantEach: # (new in 1.38) Enabled: true +Gemspec/AddRuntimeDependency: # new in 1.65 + Enabled: true +Gemspec/AttributeAssignment: # new in 1.77 + Enabled: true +Gemspec/DevelopmentDependencies: # new in 1.44 + Enabled: false +Lint/ArrayLiteralInRegexp: # new i n 1.71 + Enabled: true +Lint/ConstantReassignment: # new in 1.70 + Enabled: true +Lint/CopDirectiveSyntax: # new in 1.72 + Enabled: true +Lint/DuplicateMatchPattern: # new in 1.50 + Enabled: true +Lint/DuplicateSetElement: # new in 1.67 + Enabled: true +Lint/HashNewWithKeywordArgumentsAsDefault: # new in 1.69 + Enabled: true +Lint/ItWithoutArgumentsInBlock: # new in 1.59 + Enabled: true +Lint/LiteralAssignmentInCondition: # new in 1.58 + Enabled: true +Lint/MixedCaseRange: # new in 1.53 + Enabled: true +Lint/NumericOperationWithConstantResult: # new in 1.69 + Enabled: true +Lint/RedundantRegexpQuantifiers: # new in 1.53 + Enabled: true +Lint/RedundantTypeConversion: # new in 1.72 + Enabled: true +Lint/SharedMutableDefault: # new in 1.70 + Enabled: true +Lint/SuppressedExceptionInNumberConversion: # new in 1.72 + Enabled: true +Lint/UnescapedBracketInRegexp: # new in 1.68 + Enabled: true +Lint/UselessConstantScoping: # new in 1.72 + Enabled: true +Lint/UselessDefaultValueArgument: # new in 1.76 + Enabled: true +Lint/UselessDefined: # new in 1.69 + Enabled: true +Lint/UselessNumericOperation: # new in 1.66 + Enabled: true +Lint/UselessOr: # new in 1.76 + Enabled: true +Lint/UselessRescue: # new in 1.43 + Enabled: true +Metrics/CollectionLiteralLength: # new in 1.47 + Enabled: true +Naming/PredicateMethod: # new in 1.76 + Enabled: true +Style/AmbiguousEndlessMethodDefinition: # new in 1.68 + Enabled: true +Style/ArrayIntersect: # new in 1.40 + Enabled: true +Style/BitwisePredicate: # new in 1.68 + Enabled: true +Style/CollectionQuerying: # new in 1.77 + Enabled: true +Style/CombinableDefined: # new in 1.68 + Enabled: true +Style/ComparableBetween: # new in 1.74 + Enabled: true +Style/ComparableClamp: # new in 1.44 + Enabled: true +Style/ConcatArrayLiterals: # new in 1.41 + Enabled: true +Style/DataInheritance: # new in 1.49 + Enabled: true +Style/DigChain: # new in 1.69 + Enabled: true +Style/DirEmpty: # new in 1.48 + Enabled: true +Style/EmptyStringInsideInterpolation: # new in 1.76 + Enabled: true +Style/ExactRegexpMatch: # new in 1.51 + Enabled: true +Style/FileEmpty: # new in 1.48 + Enabled: true +Style/FileNull: # new in 1.69 + Enabled: true +Style/FileTouch: # new in 1.69 + Enabled: true +Style/HashFetchChain: # new in 1.75 + Enabled: true +Style/HashSlice: # new in 1.71 + Enabled: true +Style/ItAssignment: # new in 1.70 + Enabled: true +Style/ItBlockParameter: # new in 1.75 + Enabled: true +Style/KeywordArgumentsMerging: # new in 1.68 + Enabled: true +Style/MapIntoArray: # new in 1.63 + Enabled: true +Style/MapToSet: # new in 1.42 + Enabled: true +Style/MinMaxComparison: # new in 1.42 + Enabled: true +Style/RedundantArrayConstructor: # new in 1.52 + Enabled: true +Style/RedundantArrayFlatten: # new in 1.76 + Enabled: true +Style/RedundantConstantBase: # new in 1.40 + Enabled: true +Style/RedundantCurrentDirectoryInPath: # new in 1.53 + Enabled: true +Style/RedundantDoubleSplatHashBraces: # new in 1.41 + Enabled: true +Style/RedundantFilterChain: # new in 1.52 + Enabled: true +Style/RedundantFormat: # new in 1.72 + Enabled: true +Style/RedundantHeredocDelimiterQuotes: # new in 1.45 + Enabled: true +Style/RedundantInterpolationUnfreeze: # new in 1.66 + Enabled: true +Style/RedundantLineContinuation: # new in 1.49 + Enabled: true +Style/RedundantRegexpArgument: # new in 1.53 + Enabled: true +Style/RedundantRegexpConstructor: # new in 1.52 + Enabled: true +Style/ReturnNilInPredicateMethodDefinition: # new in 1.53 + Enabled: true +Style/SafeNavigationChainLength: # new in 1.68 + Enabled: true +Style/SendWithLiteralMethodName: # new in 1.64 + Enabled: true +Style/SingleLineDoEndBlock: # new in 1.57 + Enabled: true +Style/SuperArguments: # new in 1.64 + Enabled: true +Style/SuperWithArgsParentheses: # new in 1.58 + Enabled: true +Style/YAMLFileRead: # new in 1.53 + Enabled: true \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index 03d8918..2244681 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,7 +1,7 @@ # ============================================================================= # Target: base -FROM ruby:2.7.5-alpine AS base +FROM ruby:3.3-alpine AS base RUN apk --no-cache --update upgrade && \ apk --no-cache add \ @@ -12,6 +12,7 @@ RUN apk --no-cache --update upgrade && \ openssl \ tzdata \ xz-libs \ + yaml-dev \ && rm -rf /var/cache/apk/* WORKDIR /opt/app diff --git a/berkeley_library-alma.gemspec b/berkeley_library-alma.gemspec index 78c89e5..62b942b 100644 --- a/berkeley_library-alma.gemspec +++ b/berkeley_library-alma.gemspec @@ -31,9 +31,9 @@ Gem::Specification.new do |spec| spec.add_development_dependency 'colorize', '~> 0.8' 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-rake', '= 0.6.0' - spec.add_development_dependency 'rubocop-rspec', '= 2.4.0' + spec.add_development_dependency 'rubocop', '~> 1.78.0' + spec.add_development_dependency 'rubocop-rake', '~> 0.7.0' + spec.add_development_dependency 'rubocop-rspec', '~> 3.6.0' spec.add_development_dependency 'simplecov', '~> 0.21' spec.add_development_dependency 'simplecov-rcov', '~> 0.2' spec.add_development_dependency 'webmock', '~> 3.12' diff --git a/rakelib/.rubocop.yml b/rakelib/.rubocop.yml index 93dfdb7..49c83db 100644 --- a/rakelib/.rubocop.yml +++ b/rakelib/.rubocop.yml @@ -1,4 +1,4 @@ inherit_from: ../.rubocop.yml -require: +plugins: - rubocop-rake diff --git a/spec/.rubocop.yml b/spec/.rubocop.yml index 17792c3..c2a261e 100644 --- a/spec/.rubocop.yml +++ b/spec/.rubocop.yml @@ -1,6 +1,6 @@ inherit_from: ../.rubocop.yml -require: +plugins: - rubocop-rspec AllCops: @@ -74,10 +74,16 @@ RSpec/ExampleLength: RSpec/ExpectInHook: Enabled: false +RSpec/IndexedLet: + Enabled: false + # your naming scheme is not in possession of all the facts -RSpec/FilePath: +RSpec/SpecFilePathFormat: Enabled: false +RSpec/SpecFilePathSuffix: + Enabled: true + # explicit >>> implicit RSpec/InstanceVariable: Enabled: false @@ -122,5 +128,3 @@ RSpec/VerifiedDoubles: RSpec/IdenticalEqualityAssertion: # new in 2.4 Enabled: true -RSpec/Rails/AvoidSetupHook: # new in 2.4 - Enabled: true diff --git a/spec/lib/berkeley_library/alma/sru/xml_reader_spec.rb b/spec/lib/berkeley_library/alma/sru/xml_reader_spec.rb index 380046c..8168f80 100644 --- a/spec/lib/berkeley_library/alma/sru/xml_reader_spec.rb +++ b/spec/lib/berkeley_library/alma/sru/xml_reader_spec.rb @@ -18,7 +18,7 @@ module SRU describe :new do it 'raises an error for unreadable sources' do - not_xml = Object.new + not_xml = 'string' expect { XMLReader.read(not_xml) }.to raise_error(ArgumentError) end end From 45a5cc1b032d86b9f59dbe77e4b71407b380b16f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?mar=C3=ADa=20a=2E=20matienzo?= Date: Wed, 23 Jul 2025 12:31:58 -0700 Subject: [PATCH 2/5] add rubocop style fixes --- bin/alma-mms-lookup | 2 +- bin/alma-oclc-lookup | 2 +- lib/berkeley_library/alma/record_id.rb | 3 ++- lib/berkeley_library/alma/sru/xml_reader.rb | 2 +- spec/lib/berkeley_library/alma/config_spec.rb | 2 +- spec/lib/berkeley_library/alma/sru/sru_spec.rb | 8 ++++---- 6 files changed, 10 insertions(+), 9 deletions(-) diff --git a/bin/alma-mms-lookup b/bin/alma-mms-lookup index 2f356dd..479a0f6 100755 --- a/bin/alma-mms-lookup +++ b/bin/alma-mms-lookup @@ -14,7 +14,7 @@ $stderr.sync = true require 'bundler/setup' # Require lib directory -unless $LOAD_PATH.include?((lib_path = File.expand_path('../lib', __dir__))) +unless $LOAD_PATH.include?(lib_path = File.expand_path('../lib', __dir__)) puts "Adding #{lib_path} to $LOAD_PATH" $LOAD_PATH.unshift(lib_path) end diff --git a/bin/alma-oclc-lookup b/bin/alma-oclc-lookup index b28ef03..b3076a5 100755 --- a/bin/alma-oclc-lookup +++ b/bin/alma-oclc-lookup @@ -14,7 +14,7 @@ $stderr.sync = true require 'bundler/setup' # Require lib directory -unless $LOAD_PATH.include?((lib_path = File.expand_path('../lib', __dir__))) +unless $LOAD_PATH.include?(lib_path = File.expand_path('../lib', __dir__)) puts "Adding #{lib_path} to $LOAD_PATH" $LOAD_PATH.unshift(lib_path) end diff --git a/lib/berkeley_library/alma/record_id.rb b/lib/berkeley_library/alma/record_id.rb index 5152f09..c59d724 100644 --- a/lib/berkeley_library/alma/record_id.rb +++ b/lib/berkeley_library/alma/record_id.rb @@ -36,7 +36,8 @@ def parse(id) return id if id.is_a?(RecordId) return MMSID.new(id) if ALMA_RECORD_RE =~ id - return BibNumber.new(id) if MILLENNIUM_RECORD_RE =~ id + + BibNumber.new(id) if MILLENNIUM_RECORD_RE =~ id end end diff --git a/lib/berkeley_library/alma/sru/xml_reader.rb b/lib/berkeley_library/alma/sru/xml_reader.rb index da2d09d..a6532c8 100644 --- a/lib/berkeley_library/alma/sru/xml_reader.rb +++ b/lib/berkeley_library/alma/sru/xml_reader.rb @@ -110,7 +110,7 @@ def end_element_namespace(name, prefix = nil, uri = nil) # @see Nokogiri::XML::Sax::Document#characters # rubocop:disable Metrics/MethodLength def characters(string) - return super unless NS_SRW == @current_element_ns + return super unless @current_element_ns == NS_SRW return unless (name = @current_element_name) case name diff --git a/spec/lib/berkeley_library/alma/config_spec.rb b/spec/lib/berkeley_library/alma/config_spec.rb index 1b60e83..6f67df5 100644 --- a/spec/lib/berkeley_library/alma/config_spec.rb +++ b/spec/lib/berkeley_library/alma/config_spec.rb @@ -67,7 +67,7 @@ module Alma end after do - Object.send(:remove_const, :Rails) + Object.send(:remove_const, :Rails) # rubocop:disable RSpec/RemoveConst end describe :alma_sru_base_uri do diff --git a/spec/lib/berkeley_library/alma/sru/sru_spec.rb b/spec/lib/berkeley_library/alma/sru/sru_spec.rb index 93bd9f9..33f6d27 100644 --- a/spec/lib/berkeley_library/alma/sru/sru_spec.rb +++ b/spec/lib/berkeley_library/alma/sru/sru_spec.rb @@ -21,7 +21,7 @@ module Alma reader = SRU.get_marc_records(*mms_ids) marc_records = reader.to_a expect(marc_records.size).to eq(mms_ids.size) - expect(marc_records.map(&:record_id)).to contain_exactly(*mms_ids) + expect(marc_records.map(&:record_id)).to match_array(mms_ids) end end @@ -60,7 +60,7 @@ module Alma reader = SRU.get_marc_records(*mms_ids) marc_records = reader.to_a expect(marc_records.size).to eq(mms_ids.size) - expect(marc_records.map(&:record_id)).to contain_exactly(*mms_ids) + expect(marc_records.map(&:record_id)).to match_array(mms_ids) end it 'does not freeze records by default' do @@ -68,7 +68,7 @@ module Alma reader = SRU.get_marc_records(*mms_ids) reader.to_a.each do |record| - expect(record.frozen?).to eq(false) + expect(record.frozen?).to be(false) end end @@ -77,7 +77,7 @@ module Alma reader = SRU.get_marc_records(*mms_ids, freeze: true) reader.to_a.each do |record| - expect(record.frozen?).to eq(true) + expect(record.frozen?).to be(true) end end From 658b62dc64b2dc2fa482cf28828dda7bb28e9c37 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?mar=C3=ADa=20a=2E=20matienzo?= Date: Wed, 23 Jul 2025 12:36:37 -0700 Subject: [PATCH 3/5] Add gem push workflow and fix a Dockerfile style issue --- .github/workflows/gem-push.yml | 33 +++++++++++++++++++++++++++++++++ Dockerfile | 2 +- 2 files changed, 34 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/gem-push.yml diff --git a/.github/workflows/gem-push.yml b/.github/workflows/gem-push.yml new file mode 100644 index 0000000..9e6341e --- /dev/null +++ b/.github/workflows/gem-push.yml @@ -0,0 +1,33 @@ +name: Ruby Gem + +on: + release: + types: [published] + +jobs: + build: + name: Build + Publish + runs-on: ubuntu-latest + permissions: + contents: read + packages: write + + steps: + - uses: actions/checkout@v3 + + - name: Set up Ruby + uses: ruby/setup-ruby@v1 + with: + ruby-version: '3.3' + bundler-cache: true + + - name: Publish to RubyGems + run: | + mkdir -p $HOME/.gem + touch $HOME/.gem/credentials + chmod 0600 $HOME/.gem/credentials + printf -- "---\n:rubygems_api_key: ${GEM_HOST_API_KEY}\n" > $HOME/.gem/credentials + gem build *.gemspec + gem push *.gem + env: + GEM_HOST_API_KEY: "${{secrets.RUBYGEMS_AUTH_TOKEN}}" diff --git a/Dockerfile b/Dockerfile index 2244681..b5ab58e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -52,4 +52,4 @@ COPY --from=development /usr/local/bundle /usr/local/bundle RUN bundle config set deployment 'true' RUN bundle install --local --path=/usr/local/bundle -CMD ['bundle', 'exec', 'rake'] +CMD ["bundle", "exec", "rake"] From 0fa4ebc53be197ca0c9c054b5d490aac9fb36abc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?mar=C3=ADa=20a=2E=20matienzo?= Date: Wed, 23 Jul 2025 12:49:04 -0700 Subject: [PATCH 4/5] upload artifacts per build matrix item --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 936d76d..f5a7fbb 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -26,5 +26,5 @@ jobs: if: ${{ always() }} uses: actions/upload-artifact@v4 with: - name: artifacts + name: artifacts-${{ matrix.ruby }}-${{ matrix.os }} path: artifacts/** From 55f1d2d0e0d44096555f43dfbc022011f86b7373 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?mar=C3=ADa=20a=2E=20matienzo?= Date: Wed, 23 Jul 2025 12:57:27 -0700 Subject: [PATCH 5/5] prepare 0.1.0 for release --- CHANGES.md | 4 +++- berkeley_library-alma.gemspec | 4 ++-- lib/berkeley_library/alma/module_info.rb | 6 +++--- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index 3d77847..aa7d6cc 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,5 +1,7 @@ -# (next) +# 0.1.0 (23 July 2025) +- Update to support Ruby 3.3+. +- Update Rubocop & style changes. - Add `alma-oclc-lookup` script. # 0.0.7.1 (24 May 2022) diff --git a/berkeley_library-alma.gemspec b/berkeley_library-alma.gemspec index 62b942b..0204e42 100644 --- a/berkeley_library-alma.gemspec +++ b/berkeley_library-alma.gemspec @@ -8,8 +8,8 @@ require 'berkeley_library/alma/module_info' Gem::Specification.new do |spec| spec.name = BerkeleyLibrary::Alma::ModuleInfo::NAME - spec.author = BerkeleyLibrary::Alma::ModuleInfo::AUTHOR - spec.email = BerkeleyLibrary::Alma::ModuleInfo::AUTHOR_EMAIL + spec.author = BerkeleyLibrary::Alma::ModuleInfo::AUTHORS + spec.email = BerkeleyLibrary::Alma::ModuleInfo::AUTHOR_EMAILS spec.summary = BerkeleyLibrary::Alma::ModuleInfo::SUMMARY spec.description = BerkeleyLibrary::Alma::ModuleInfo::DESCRIPTION spec.license = BerkeleyLibrary::Alma::ModuleInfo::LICENSE diff --git a/lib/berkeley_library/alma/module_info.rb b/lib/berkeley_library/alma/module_info.rb index a3f9927..a8634a7 100644 --- a/lib/berkeley_library/alma/module_info.rb +++ b/lib/berkeley_library/alma/module_info.rb @@ -2,12 +2,12 @@ module BerkeleyLibrary module Alma class ModuleInfo NAME = 'berkeley_library-alma'.freeze - AUTHOR = 'David Moles'.freeze - AUTHOR_EMAIL = 'dmoles@berkeley.edu'.freeze + AUTHORS = ['David Moles', 'marĂ­a a. matienzo'].freeze + AUTHOR_EMAILS = ['dmoles@berkeley.edu', 'matienzo@berkeley.edu'].freeze SUMMARY = 'Alma/Primo utilities for the UC Berkeley Library'.freeze DESCRIPTION = 'A gem providing Alma/Primo-related utility code for the UC Berkeley Library'.freeze LICENSE = 'MIT'.freeze - VERSION = '0.0.7.1'.freeze + VERSION = '0.1.0'.freeze HOMEPAGE = 'https://github.com/BerkeleyLibrary/alma'.freeze end end