Skip to content
Merged
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
6 changes: 3 additions & 3 deletions .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: [ '2.7', '3.0', '3.1' ]
ruby: [ '3.3', '3.4' ]
runs-on: ${{ matrix.os }}

steps:
Expand All @@ -24,7 +24,7 @@ jobs:

- name: Upload artifacts
if: ${{ always() }}
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: artifacts
name: artifacts-${{ matrix.ruby }}-${{ matrix.os }}
path: artifacts/**
33 changes: 33 additions & 0 deletions .github/workflows/gem-push.yml
Original file line number Diff line number Diff line change
@@ -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}}"
138 changes: 138 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
4 changes: 3 additions & 1 deletion CHANGES.md
Original file line number Diff line number Diff line change
@@ -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)
Expand Down
5 changes: 3 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -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 \
Expand All @@ -12,6 +12,7 @@ RUN apk --no-cache --update upgrade && \
openssl \
tzdata \
xz-libs \
yaml-dev \
&& rm -rf /var/cache/apk/*

WORKDIR /opt/app
Expand Down Expand Up @@ -51,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"]
10 changes: 5 additions & 5 deletions berkeley_library-alma.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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'
Expand Down
2 changes: 1 addition & 1 deletion bin/alma-mms-lookup
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion bin/alma-oclc-lookup
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions lib/berkeley_library/alma/module_info.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion lib/berkeley_library/alma/record_id.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion lib/berkeley_library/alma/sru/xml_reader.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion rakelib/.rubocop.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
inherit_from: ../.rubocop.yml

require:
plugins:
- rubocop-rake
12 changes: 8 additions & 4 deletions spec/.rubocop.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
inherit_from: ../.rubocop.yml

require:
plugins:
- rubocop-rspec

AllCops:
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -122,5 +128,3 @@ RSpec/VerifiedDoubles:
RSpec/IdenticalEqualityAssertion: # new in 2.4
Enabled: true

RSpec/Rails/AvoidSetupHook: # new in 2.4
Enabled: true
2 changes: 1 addition & 1 deletion spec/lib/berkeley_library/alma/config_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 4 additions & 4 deletions spec/lib/berkeley_library/alma/sru/sru_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -60,15 +60,15 @@ 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
stub_request(:get, query_uri_page_2).to_return(body: File.read('spec/data/availability-sru-page-2.xml'))

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

Expand All @@ -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

Expand Down
2 changes: 1 addition & 1 deletion spec/lib/berkeley_library/alma/sru/xml_reader_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading