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 +4 -4
- data/.rubocop_todo.yml +55 -0
- data/lib/bibframe_ruby/graph.rb +2 -0
- data/lib/bibframe_ruby/graph_builder.rb +12 -11
- data/lib/bibframe_ruby/models/agent.rb +2 -0
- data/lib/bibframe_ruby/models/contribution.rb +2 -0
- data/lib/bibframe_ruby/models/hub.rb +2 -0
- data/lib/bibframe_ruby/models/instance.rb +2 -0
- data/lib/bibframe_ruby/models/item.rb +2 -0
- data/lib/bibframe_ruby/models/organization.rb +2 -0
- data/lib/bibframe_ruby/models/person.rb +2 -0
- data/lib/bibframe_ruby/models/subject.rb +2 -0
- data/lib/bibframe_ruby/models/title.rb +2 -0
- data/lib/bibframe_ruby/models/work.rb +2 -0
- data/lib/bibframe_ruby/parser.rb +3 -1
- data/lib/bibframe_ruby/resource.rb +2 -0
- data/lib/bibframe_ruby/version.rb +2 -1
- data/lib/bibframe_ruby.rb +1 -0
- metadata +3 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: ee4d1179d85cde61e67c01da92b6fd036ec9a01ce0a53f26ed7f3aa4ca837140
|
|
4
|
+
data.tar.gz: f3181cde09408b09fba1444983d4eb42bd2c26e863e427cd88b092be1078162e
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
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'
|
data/lib/bibframe_ruby/graph.rb
CHANGED
|
@@ -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.
|
|
103
|
-
instances: @resources.values.
|
|
104
|
-
items: @resources.values.
|
|
105
|
-
hubs: @resources.values.
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
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"])
|
data/lib/bibframe_ruby/parser.rb
CHANGED
|
@@ -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
|
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.
|
|
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
|