Skip to content

Commit

Permalink
Merge pull request #321 from LD4P/rubo
Browse files Browse the repository at this point in the history
Set ruby 3.2 target for rubocop.
  • Loading branch information
ndushay authored Dec 6, 2023
2 parents 8051ba9 + 698b583 commit 970bf3f
Show file tree
Hide file tree
Showing 20 changed files with 71 additions and 70 deletions.
1 change: 1 addition & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ require: rubocop-rspec

AllCops:
NewCops: enable
TargetRubyVersion: 3.2

Layout/LineLength:
Max: 120
Expand Down
6 changes: 3 additions & 3 deletions lib/rdf2marc.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def initialize(conn) # rubocop:disable Lint/MissingSuper
end

def open_url(base_uri, headers: {}, **_options)
response = @conn.get(base_uri, nil, self.class.headers(headers: headers))
response = @conn.get(base_uri, nil, self.class.headers(headers:))
raise IOError, "<#{base_uri}>: #{response.status}" unless response.success?

# If a Location is returned, it defines the base resource for this file, not it's actual ending location
Expand All @@ -62,9 +62,9 @@ def initialize(caching_adapter, noncaching_adapter, only_host:)
@only_host = only_host
end

def get(uri, *stuff, **options)
def get(uri, *stuff, **)
adapter = uri.match?(@only_host) ? @caching_adapter : @noncaching_adapter
adapter.get(uri, *stuff, **options)
adapter.get(uri, *stuff, **)
end
end

Expand Down
8 changes: 4 additions & 4 deletions lib/rdf2marc/caches/s3_cache.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ def initialize(bucket_name, path, **options)
private

# @param [ActiveSupport::Cache::Entry] entry the cache entry
def write_entry(key, entry, **options)
write_serialized_entry(key, serialize_entry(entry, **options), **options)
def write_entry(key, entry, **)
write_serialized_entry(key, serialize_entry(entry, **), **)
end

def read_entry(key, **options)
deserialize_entry(read_serialized_entry(key, **options))
def read_entry(key, **)
deserialize_entry(read_serialized_entry(key, **))
end

def write_serialized_entry(key, payload, **_options)
Expand Down
12 changes: 6 additions & 6 deletions lib/rdf2marc/graph_query.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,30 +16,30 @@ def initialize(graph, default_subject_term: nil)
end

def path_first(path, subject_term: default_subject_term)
patterns, subj = patterns_for_path(path, subject_term: subject_term)
patterns, subj = patterns_for_path(path, subject_term:)
query_first(patterns, subj)
end

def path_first_literal(path, subject_term: default_subject_term)
to_literal(path_first(path, subject_term: subject_term))
to_literal(path_first(path, subject_term:))
end

def path_first_uri(path, subject_term: default_subject_term)
to_uri(path_first(path, subject_term: subject_term))
to_uri(path_first(path, subject_term:))
end

def path_all(path, subject_term: default_subject_term)
patterns, subj = patterns_for_path(path, subject_term: subject_term)
patterns, subj = patterns_for_path(path, subject_term:)
query_all(patterns, subj)
end

def path_all_literal(path, subject_term: default_subject_term)
patterns, subj = patterns_for_path(path, subject_term: subject_term)
patterns, subj = patterns_for_path(path, subject_term:)
to_literals(query_all(patterns, subj))
end

def path_all_uri(path, subject_term: default_subject_term)
patterns, subj = patterns_for_path(path, subject_term: subject_term)
patterns, subj = patterns_for_path(path, subject_term:)
to_uris(query_all(patterns, subj))
end

Expand Down
2 changes: 1 addition & 1 deletion lib/rdf2marc/rdf2model/mapper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ def generate
control_fields: Mappers::ControlFields.new(item).generate,
number_and_code_fields: Mappers::NumberAndCodeFields.new(item).generate,
main_entry_fields: main_entry,
title_fields: Mappers::TitleFields.new(item, has_100_field: has_100_field).generate,
title_fields: Mappers::TitleFields.new(item, has_100_field:).generate,
physical_description_fields: Mappers::PhysicalDescriptionFields.new(item).generate,
series_statement_fields: Mappers::SeriesStatementFields.new(item).generate,
note_fields: Mappers::NoteFields.new(item).generate,
Expand Down
4 changes: 2 additions & 2 deletions lib/rdf2marc/rdf2model/mappers/added_entry_fields.rb
Original file line number Diff line number Diff line change
Expand Up @@ -51,14 +51,14 @@ def added_entry_names(types, key_symbol, model_class)
end

def added_entry_name_with_roles(contrib_term, role_uris, key_symbol, model_class)
result = LiteralOrRemoteResolver.resolve_model(term: contrib_term, item: item, key_symbol: key_symbol,
result = LiteralOrRemoteResolver.resolve_model(term: contrib_term, item:, key_symbol:,
model: model_class)
result[:relator_terms] = relator_terms(role_uris) if result && relator_terms(role_uris).present?
result
end

def relator_terms(role_uris)
role_uris.sort.map { |uri| LiteralOrRemoteResolver.resolve_label(term: uri, item: item) }
role_uris.sort.map { |uri| LiteralOrRemoteResolver.resolve_label(term: uri, item:) }
end
end
end
Expand Down
12 changes: 6 additions & 6 deletions lib/rdf2marc/rdf2model/mappers/control_fields.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@ module Mappers
class ControlFields < BaseMapper
def generate
{
latest_transaction: latest_transaction,
latest_transaction:,
general_info: {
place: place,
date_entered: date_entered,
place:,
date_entered:,
date1: item.instance.query.path_first_literal([[BF.provisionActivity, BF.Publication], [BF.date]]),
language: language,
book_illustrative_content: book_illustrative_content
language:,
book_illustrative_content:
}
}
end
Expand Down Expand Up @@ -57,7 +57,7 @@ def book_illustrative_content
item.work.query.path_first_uri([BF.illustrativeContent])
return nil if illustrative_content_uri.blank?

LiteralOrRemoteResolver.resolve_label(term: illustrative_content_uri, item: item)
LiteralOrRemoteResolver.resolve_label(term: illustrative_content_uri, item:)
end
end
end
Expand Down
6 changes: 3 additions & 3 deletions lib/rdf2marc/rdf2model/mappers/edition_imprint_fields.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ module Mappers
class EditionImprintFields < BaseMapper
def generate
{
editions: editions,
publication_distributions: publication_distributions
editions:,
publication_distributions:
}
end

Expand Down Expand Up @@ -36,7 +36,7 @@ def publication_distributions
def publication_distributions_for(terms, entity_function)
terms.map do |term|
{
entity_function: entity_function,
entity_function:,
publication_distribution_places: item.instance.query.path_all_literal([BFLC.simplePlace],
subject_term: term),
publisher_distributor_names: item.instance.query.path_all_literal([BFLC.simpleAgent],
Expand Down
2 changes: 1 addition & 1 deletion lib/rdf2marc/rdf2model/mappers/holdings_etc_fields.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def generate
uri: 'https://github.com/LD4P/rdf2marc'
}
],
electronic_locations: electronic_locations
electronic_locations:
}
end

Expand Down
8 changes: 4 additions & 4 deletions lib/rdf2marc/rdf2model/mappers/leader.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ module Mappers
class Leader < BaseMapper
def generate
{
type: type,
bibliographic_level: bibliographic_level,
encoding_level: encoding_level,
cataloging_form: cataloging_form
type:,
bibliographic_level:,
encoding_level:,
cataloging_form:
}
end

Expand Down
4 changes: 2 additions & 2 deletions lib/rdf2marc/rdf2model/mappers/main_entry_fields.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,15 @@ def primary_contributions
end

def main_entry_name(term, key_symbol, model_class)
result = LiteralOrRemoteResolver.resolve_model(term: term, item: item, key_symbol: key_symbol,
result = LiteralOrRemoteResolver.resolve_model(term:, item:, key_symbol:,
model: model_class)
result[:relator_terms] = main_relator_terms if result && main_relator_terms.present?
result
end

def main_relator_terms
role_uris = item.work.query.path_all([[BF.contribution, BFLC.PrimaryContribution], [BF.role]])
role_uris.sort.map { |uri| LiteralOrRemoteResolver.resolve_label(term: uri, item: item) }
role_uris.sort.map { |uri| LiteralOrRemoteResolver.resolve_label(term: uri, item:) }
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion lib/rdf2marc/rdf2model/mappers/note_fields.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ def generate
notes << provision_activity_statement if provision_activity_statement
{
general_notes: notes,
table_of_contents: table_of_contents
table_of_contents:
}
end

Expand Down
16 changes: 8 additions & 8 deletions lib/rdf2marc/rdf2model/mappers/number_and_code_fields.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ module Mappers
class NumberAndCodeFields < BaseMapper
def generate
{
oclc_record_number: oclc_record_number,
lccn: lccn,
isbns: isbns,
cataloging_source: cataloging_source,
oclc_record_number:,
lccn:,
isbns:,
cataloging_source:,
geographic_area_code: geographic_area_codes,
lc_call_numbers: lc_call_numbers
lc_call_numbers:
}
end

Expand Down Expand Up @@ -69,10 +69,10 @@ def isbns
def cataloging_source
{
cataloging_agency: agency,
cataloging_language: cataloging_language,
cataloging_language:,
transcribing_agency: agency,
modifying_agencies: modifying_agencies,
description_conventions: description_conventions
modifying_agencies:,
description_conventions:
}
end

Expand Down
16 changes: 8 additions & 8 deletions lib/rdf2marc/rdf2model/mappers/physical_description_fields.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ module Mappers
class PhysicalDescriptionFields < BaseMapper
def generate
{
physical_descriptions: physical_descriptions,
media_types: media_types,
carrier_types: carrier_types,
content_types: content_types
physical_descriptions:,
media_types:,
carrier_types:,
content_types:
}
end

Expand All @@ -23,23 +23,23 @@ def physical_descriptions
illustrative_content_uri = item.instance.query.path_first_uri([BF.illustrativeContent]) ||
item.work.query.path_first_uri([BF.illustrativeContent])
if illustrative_content_uri
other_physical_details = LiteralOrRemoteResolver.resolve_label(term: illustrative_content_uri, item: item)
other_physical_details = LiteralOrRemoteResolver.resolve_label(term: illustrative_content_uri, item:)
end
extent_physical_descriptions = extent_terms.sort.map do |extent_term|
{
extents: item.instance.query.path_all_literal([RDF::RDFS.label], subject_term: extent_term).sort,
# Can be multiple notes, but only using one.
materials_specified: item.instance.query.path_first_literal([[BF.note, BF.Note],
RDF::RDFS.label], subject_term: extent_term),
other_physical_details: other_physical_details
other_physical_details:
}
end
dimensions = item.instance.query.path_all_literal([BF.dimensions]).sort
if extent_physical_descriptions.length == 1 && dimensions.length == 1
return [extent_physical_descriptions.first.merge(dimensions: dimensions)]
return [extent_physical_descriptions.first.merge(dimensions:)]
end

extent_physical_descriptions << { dimensions: dimensions } if dimensions.present?
extent_physical_descriptions << { dimensions: } if dimensions.present?
extent_physical_descriptions
end

Expand Down
2 changes: 1 addition & 1 deletion lib/rdf2marc/rdf2model/mappers/related_work_fields.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ module Mappers
class RelatedWorkFields < BaseMapper
def generate
{
title: title,
title:,
uri: uri.to_s
}
end
Expand Down
2 changes: 1 addition & 1 deletion lib/rdf2marc/rdf2model/mappers/series_statement_fields.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ module Mappers
class SeriesStatementFields < BaseMapper
def generate
{
series_statements: series_statements
series_statements:
}
end

Expand Down
14 changes: 7 additions & 7 deletions lib/rdf2marc/rdf2model/mappers/subject_access_fields.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ def generate
geographic_names: fast_places,
event_names: [],
topical_terms: [],
genre_forms: genre_forms
genre_forms:
}
subject_terms = item.work.query.path_all([BF.subject])
subject_terms.sort.each do |subject_term|
Expand All @@ -23,33 +23,33 @@ def generate
when 'corporate_name'
subj_fields[:corporate_names] <<
LiteralOrRemoteResolver.resolve_model(term: subject_term,
item: item, key_symbol: subject_type.to_sym,
item:, key_symbol: subject_type.to_sym,
model: Rdf2marc::Models::General::CorporateName)
when 'personal_name', 'family_name'
subj_fields[:personal_names] <<
LiteralOrRemoteResolver.resolve_model(term: subject_term,
item: item, key_symbol: :personal_name,
item:, key_symbol: :personal_name,
model: Rdf2marc::Models::General::PersonalName)
when 'meeting_name'
subj_fields[:meeting_names] <<
LiteralOrRemoteResolver.resolve_model(term: subject_term,
item: item, key_symbol: subject_type.to_sym,
item:, key_symbol: subject_type.to_sym,
model: Rdf2marc::Models::General::MeetingName)
when 'geographic_name'
subj_fields[:geographic_names] <<
LiteralOrRemoteResolver.resolve_model(term: subject_term,
item: item, key_symbol: subject_type.to_sym,
item:, key_symbol: subject_type.to_sym,
model: Rdf2marc::Models::SubjectAccessField::GeographicName)
when 'event_name'
subj_fields[:event_names] <<
LiteralOrRemoteResolver.resolve_model(term: subject_term,
item: item,
item:,
key_symbol: subject_type.to_sym,
model: Rdf2marc::Models::SubjectAccessField::EventName)
when 'topic'
subj_fields[:topical_terms] <<
LiteralOrRemoteResolver.resolve_model(term: subject_term,
item: item, key_symbol: :topic,
item:, key_symbol: :topic,
model: Rdf2marc::Models::SubjectAccessField::TopicalTerm)
end
end
Expand Down
8 changes: 4 additions & 4 deletions lib/rdf2marc/rdf2model/mappers/title_fields.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ def initialize(item_context, has_100_field:)

def generate
{
translated_titles: translated_titles,
translated_titles:,
title_statement: title_statement(@has_100_field),
variant_titles: variant_titles,
former_titles: former_titles
variant_titles:,
former_titles:
}
end

Expand Down Expand Up @@ -68,7 +68,7 @@ def variant_titles
type = variant_title_type(title_term, parallel_title_terms.include?(title_term))
{
note_added_entry: note_added_entry(type),
type: type,
type:,
title: item.instance.query.path_first_literal([BF.mainTitle], subject_term: title_term),
part_numbers: item.instance.query.path_all_literal([BF.partNumber], subject_term: title_term).sort,
part_names: item.instance.query.path_all_literal([BF.partName], subject_term: title_term).sort
Expand Down
Loading

0 comments on commit 970bf3f

Please sign in to comment.