bibframe_ruby 0.1.0 → 0.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: fcbdeff768bfbc758d78355aa9f9de7e98a513cc0a0c63a43ac1e2b9b2c4e6bb
4
- data.tar.gz: c2e8be5aed30fa4cb8a6bc88c5d0e70b267b3b2c3b73aa5a141fc76169696c74
3
+ metadata.gz: ee4d1179d85cde61e67c01da92b6fd036ec9a01ce0a53f26ed7f3aa4ca837140
4
+ data.tar.gz: f3181cde09408b09fba1444983d4eb42bd2c26e863e427cd88b092be1078162e
5
5
  SHA512:
6
- metadata.gz: 1be2ad497cc3ba26bf0eca414bcdc27cf80aaebae69db92fb469462fec0f85cf2ad28aff7a7f3b00f993b31c408804cff391434b97de96387135c424bc2b34ad
7
- data.tar.gz: a09548d0df9b71f46188ac47935dd1dc13e827259183ce716a8b9aac2e555a016c7a07f9cd9770c3c38957514718df3163162447d551c484ac53afcab1dfd56a
6
+ metadata.gz: 9a3a57a85e5f18c9e5a34d27b518f50ae82f64b4982183cf86c0e245bc710791e14c3ce542e94625a8da6a6ba605b8ea209feeaac813511f7d738bf08d1777d5
7
+ data.tar.gz: f0310d9973e81e15c5b564dca7433f38e5cded5932a1b95a80a79c0d6eb2e46960554a69d8d95c0d9844953107a718f71e0e5ce8f7e89116abb87cd3cf4c0a04
data/.rubocop_todo.yml ADDED
@@ -0,0 +1,55 @@
1
+ # This configuration was generated by
2
+ # `rubocop --auto-gen-config`
3
+ # on 2026-09-09 02:40:46 UTC using RuboCop version 1.90.0.
4
+ # The point is for the user to remove these configuration records
5
+ # one by one as the offenses are removed from the code base.
6
+ # Note that changes in the inspected code, or installation of new
7
+ # versions of RuboCop, may require this file to be generated again.
8
+
9
+ # Offense count: 4
10
+ # Configuration parameters: AllowedMethods, AllowedPatterns, CountRepeatedAttributes.
11
+ Metrics/AbcSize:
12
+ Max: 40
13
+
14
+ # Offense count: 1
15
+ # Configuration parameters: CountComments, CountAsOne.
16
+ Metrics/ClassLength:
17
+ Max: 216
18
+
19
+ # Offense count: 3
20
+ # Configuration parameters: AllowedMethods, AllowedPatterns.
21
+ Metrics/CyclomaticComplexity:
22
+ Max: 13
23
+
24
+ # Offense count: 5
25
+ # Configuration parameters: CountComments, CountAsOne, AllowedMethods, AllowedPatterns.
26
+ Metrics/MethodLength:
27
+ Max: 21
28
+
29
+ # Offense count: 3
30
+ # Configuration parameters: AllowedMethods, AllowedPatterns.
31
+ Metrics/PerceivedComplexity:
32
+ Max: 14
33
+
34
+ # Offense count: 2
35
+ # Configuration parameters: CountAsOne.
36
+ RSpec/ExampleLength:
37
+ Max: 13
38
+
39
+ # Offense count: 2
40
+ RSpec/MultipleDescribes:
41
+ Exclude:
42
+ - 'spec/bibframe_ruby/agent_spec.rb'
43
+ - 'spec/bibframe_ruby/parser_turtle_spec.rb'
44
+
45
+ # Offense count: 1
46
+ # Configuration parameters: AllowSubject.
47
+ RSpec/MultipleMemoizedHelpers:
48
+ Max: 6
49
+
50
+ # Offense count: 1
51
+ # Configuration parameters: CustomTransform, IgnoreMethods, IgnoreMetadata, InflectorPath, EnforcedInflector.
52
+ # SupportedInflectors: default, active_support
53
+ RSpec/SpecFilePathFormat:
54
+ Exclude:
55
+ - 'spec/parse_uri_spec.rb'
@@ -1,6 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ # BibframeRuby::Graph: Container for parsed BIBFRAME resources with typed collection accessors
3
4
  module BibframeRuby
5
+ # Container returned by BibframeRuby.parse that holds all parsed resources with typed collection accessors.
4
6
  class Graph
5
7
  attr_reader :works, :instances, :items, :hubs, :resources
6
8
 
@@ -1,6 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ # BibframeRuby::GraphBuilder: Hydrates RDF triples into typed Ruby model objects
3
4
  module BibframeRuby
5
+ # Walks an RDF::Graph to instantiate typed model objects, populate their properties, and link relationships.
4
6
  class GraphBuilder
5
7
  BF = "http://id.loc.gov/ontologies/bibframe/"
6
8
  BFLC = "http://id.loc.gov/ontologies/bflc/"
@@ -99,10 +101,10 @@ module BibframeRuby
99
101
 
100
102
  {
101
103
  resources: @resources,
102
- works: @resources.values.select { |r| r.is_a?(Work) },
103
- instances: @resources.values.select { |r| r.is_a?(Instance) },
104
- items: @resources.values.select { |r| r.is_a?(Item) },
105
- hubs: @resources.values.select { |r| r.is_a?(Hub) }
104
+ works: @resources.values.grep(Work),
105
+ instances: @resources.values.grep(Instance),
106
+ items: @resources.values.grep(Item),
107
+ hubs: @resources.values.grep(Hub)
106
108
  }
107
109
  end
108
110
 
@@ -180,11 +182,10 @@ module BibframeRuby
180
182
  case object
181
183
  when RDF::Node
182
184
  resolve_blank_node(object, grouped, prop_name)
183
- when RDF::URI
184
- object.to_s
185
185
  when RDF::Literal
186
186
  object.object.to_s
187
187
  else
188
+ # Works for RDF::URI and other unexpected object types
188
189
  object.to_s
189
190
  end
190
191
  end
@@ -219,7 +220,7 @@ module BibframeRuby
219
220
  end
220
221
 
221
222
  def link_work_instances
222
- @resources.values.select { |r| r.is_a?(Work) }.each do |work|
223
+ @resources.values.grep(Work).each do |work|
223
224
  next unless work["instances"]
224
225
 
225
226
  work["instances"] = work["instances"].map do |ref|
@@ -228,7 +229,7 @@ module BibframeRuby
228
229
  end
229
230
  end
230
231
 
231
- @resources.values.select { |r| r.is_a?(Instance) }.each do |instance|
232
+ @resources.values.grep(Instance).each do |instance|
232
233
  next unless instance["work"]
233
234
 
234
235
  uri = instance["work"].is_a?(String) ? instance["work"] : instance["work"].id
@@ -237,7 +238,7 @@ module BibframeRuby
237
238
  end
238
239
 
239
240
  def link_instance_items
240
- @resources.values.select { |r| r.is_a?(Instance) }.each do |instance|
241
+ @resources.values.grep(Instance).each do |instance|
241
242
  next unless instance["items"]
242
243
 
243
244
  instance["items"] = instance["items"].map do |ref|
@@ -246,7 +247,7 @@ module BibframeRuby
246
247
  end
247
248
  end
248
249
 
249
- @resources.values.select { |r| r.is_a?(Item) }.each do |item|
250
+ @resources.values.grep(Item).each do |item|
250
251
  next unless item["instance"]
251
252
 
252
253
  uri = item["instance"].is_a?(String) ? item["instance"] : item["instance"].id
@@ -256,7 +257,7 @@ module BibframeRuby
256
257
 
257
258
  def replace_uri_stubs
258
259
  # Replace any remaining string URI references in contribution agents
259
- @resources.values.select { |r| r.is_a?(Contribution) }.each do |contrib|
260
+ @resources.values.grep(Contribution).each do |contrib|
260
261
  next unless contrib["agent"].is_a?(String)
261
262
 
262
263
  contrib["agent"] = @resources[contrib["agent"]] || stub_for(contrib["agent"])
@@ -1,6 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ # BibframeRuby::Agent: A BIBFRAME Agent resource
3
4
  module BibframeRuby
5
+ # Represents a BIBFRAME Agent — a person, organization, or other entity.
4
6
  class Agent < Resource
5
7
  def label
6
8
  self["label"]
@@ -1,6 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ # BibframeRuby::Contribution: A BIBFRAME Contribution resource
3
4
  module BibframeRuby
5
+ # Represents a BIBFRAME Contribution — an agent's role in creating a resource.
4
6
  class Contribution < Resource
5
7
  def agent
6
8
  self["agent"]
@@ -1,6 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ # BibframeRuby::Hub: A BIBFRAME Hub resource
3
4
  module BibframeRuby
5
+ # Represents a BIBFRAME Hub — an abstract bridge resource connecting related Works.
4
6
  class Hub < Resource
5
7
  def title
6
8
  self["title"]
@@ -1,6 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ # BibframeRuby::Instance: A BIBFRAME Instance resource
3
4
  module BibframeRuby
5
+ # Represents a BIBFRAME Instance — a specific embodiment of a Work.
4
6
  class Instance < Resource
5
7
  def title
6
8
  self["title"]
@@ -1,6 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ # BibframeRuby::Item: A BIBFRAME Item resource
3
4
  module BibframeRuby
5
+ # Represents a BIBFRAME Item — an individual copy of an Instance.
4
6
  class Item < Resource
5
7
  def instance
6
8
  self["instance"]
@@ -1,6 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ # BibframeRuby::Organization: A BIBFRAME Organization agent
3
4
  module BibframeRuby
5
+ # Represents a BIBFRAME Organization agent.
4
6
  class Organization < Agent
5
7
  end
6
8
  end
@@ -1,6 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ # BibframeRuby::Person: A BIBFRAME Person agent
3
4
  module BibframeRuby
5
+ # Represents a BIBFRAME Person agent.
4
6
  class Person < Agent
5
7
  end
6
8
  end
@@ -1,6 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ # BibframeRuby::Subject: A BIBFRAME Subject resource
3
4
  module BibframeRuby
5
+ # Represents a BIBFRAME Subject — a topic or concept associated with a resource.
4
6
  class Subject < Resource
5
7
  def label
6
8
  self["label"]
@@ -1,6 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ # BibframeRuby::Title: A BIBFRAME Title resource
3
4
  module BibframeRuby
5
+ # Represents a BIBFRAME Title with main title, subtitle, and non-sort number.
4
6
  class Title < Resource
5
7
  def main_title
6
8
  self["main_title"]
@@ -1,6 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ # BibframeRuby::Work: A BIBFRAME Work resource
3
4
  module BibframeRuby
5
+ # Represents a BIBFRAME Work — the intellectual content of a bibliographic resource.
4
6
  class Work < Resource
5
7
  def title
6
8
  self["title"]
@@ -1,10 +1,12 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "rdf"
4
3
  require "json/ld"
4
+ require "rdf"
5
5
  require "rdf/turtle"
6
6
 
7
+ # BibframeRuby::Parser: Converts serialized RDF input into an RDF graph
7
8
  module BibframeRuby
9
+ # Parses serialized RDF input (JSON-LD, Turtle) into an RDF::Graph using the appropriate reader.
8
10
  class Parser
9
11
  EXTENSION_MAP = {
10
12
  ".jsonld" => :jsonld,
@@ -1,6 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ # BibframeRuby::Resource: Base class for all BIBFRAME resource types
3
4
  module BibframeRuby
5
+ # Base class for all BIBFRAME resources. Provides URI identity, type tracking, and hash-style property access.
4
6
  class Resource
5
7
  attr_reader :id, :types
6
8
  attr_accessor :properties
@@ -1,5 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ # BibframeRuby::VERSION: Gem version constant
3
4
  module BibframeRuby
4
- VERSION = "0.1.0"
5
+ VERSION = "0.1.2"
5
6
  end
data/lib/bibframe_ruby.rb CHANGED
@@ -18,6 +18,7 @@ require_relative "bibframe_ruby/parser"
18
18
  require_relative "bibframe_ruby/graph_builder"
19
19
  require_relative "bibframe_ruby/graph"
20
20
 
21
+ # BibframeRuby: Main entry point for parsing BIBFRAME data into Ruby objects
21
22
  module BibframeRuby
22
23
  class Error < StandardError; end
23
24
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bibframe_ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Aaron Collier
@@ -72,6 +72,7 @@ executables: []
72
72
  extensions: []
73
73
  extra_rdoc_files: []
74
74
  files:
75
+ - ".rubocop_todo.yml"
75
76
  - README.md
76
77
  - Rakefile
77
78
  - lib/bibframe_ruby.rb
@@ -96,6 +97,7 @@ licenses: []
96
97
  metadata:
97
98
  homepage_uri: https://github.com/aaron-collier/bibframe_ruby
98
99
  source_code_uri: https://github.com/aaron-collier/bibframe_ruby
100
+ rubygems_mfa_required: 'true'
99
101
  rdoc_options: []
100
102
  require_paths:
101
103
  - lib