active-triples 1.1.1 → 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitlab-ci.yml +20 -0
- data/CHANGES.md +6 -0
- data/Gemfile +0 -1
- data/active-triples.gemspec +2 -2
- data/lib/active_triples/configuration.rb +5 -4
- data/lib/active_triples/persistence_strategies/repository_strategy.rb +1 -1
- data/lib/active_triples/properties.rb +1 -1
- data/lib/active_triples/rdf_source.rb +32 -9
- data/lib/active_triples/relation.rb +1 -1
- data/lib/active_triples/util/extended_bounded_description.rb +1 -1
- data/lib/active_triples/version.rb +1 -1
- data/spec/active_triples/rdf_source_spec.rb +1 -1
- data/spec/active_triples/resource_spec.rb +4 -4
- metadata +6 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6c0e9d67f468229ed99433d744dde2215e21e5571e19b081bcb0a8edd5f42380
|
4
|
+
data.tar.gz: 4a33d1eeedc668e14402e1dbe5507b914427b3eef9b651d72226e53652465a9f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c54cf20963fc02882da7848b480653392fe5051ada1311bf04572556507978c7eda8ce4b2102a035faf315b399d3708ba6cfcd02eafedcccccf470aed2c65ef3
|
7
|
+
data.tar.gz: 278a128edabab0162e5dea4df901b7ecfd83bbf3c62820f8b65d447304edcc662ab93115cb1f2b9527fa64377708e00c6c3f0e8accc7dd79a361e8a937136db0
|
data/.gitlab-ci.yml
CHANGED
@@ -36,6 +36,26 @@ ruby-2-7:
|
|
36
36
|
extends: .rspec
|
37
37
|
stage: test
|
38
38
|
|
39
|
+
ruby-3-0:
|
40
|
+
image: ruby:3.0
|
41
|
+
extends: .rspec
|
42
|
+
stage: test
|
43
|
+
before_script:
|
44
|
+
- ruby -v
|
45
|
+
- gem install bundler
|
46
|
+
- gem update --system
|
47
|
+
- bundle install --jobs $(nproc) "${FLAGS[@]}"
|
48
|
+
|
49
|
+
ruby-3-1:
|
50
|
+
image: ruby:3.1
|
51
|
+
extends: .rspec
|
52
|
+
stage: test
|
53
|
+
|
54
|
+
ruby-3-2:
|
55
|
+
image: ruby:3.2
|
56
|
+
extends: .rspec
|
57
|
+
stage: test
|
58
|
+
|
39
59
|
ruby-latest:
|
40
60
|
image: ruby:latest
|
41
61
|
extends: .rspec
|
data/CHANGES.md
CHANGED
data/Gemfile
CHANGED
data/active-triples.gemspec
CHANGED
@@ -6,9 +6,9 @@ Gem::Specification.new do |s|
|
|
6
6
|
s.name = "active-triples"
|
7
7
|
s.version = ActiveTriples::VERSION
|
8
8
|
s.platform = Gem::Platform::RUBY
|
9
|
-
s.authors = ["
|
9
|
+
s.authors = ["Tamsin Johnson", "Trey Pendragon"]
|
10
10
|
s.homepage = 'https://gitlab.com/no_reply/ActiveTriples'
|
11
|
-
s.email = '
|
11
|
+
s.email = 'tomjohnson@ucsb.edu'
|
12
12
|
s.summary = %q{RDF graphs in ActiveModel wrappers.}
|
13
13
|
s.description = %q{ActiveTriples provides tools for modeling RDF as discrete resources.}
|
14
14
|
s.license = 'Apache-2.0'
|
@@ -11,10 +11,11 @@ module ActiveTriples
|
|
11
11
|
|
12
12
|
##
|
13
13
|
# @param item_factory [ItemFactory]
|
14
|
-
# @param [Hash] options the configuration options.
|
15
|
-
|
14
|
+
# @param [Hash] options the configuration options. (Ruby 3+)
|
15
|
+
# @param [Hash] options2 the configuration options. (Ruby 2.x)
|
16
|
+
def initialize(options = {}, item_factory: ItemFactory.new, **options2)
|
16
17
|
@item_factory = item_factory
|
17
|
-
@inner_hash = Hash[options.to_a]
|
18
|
+
@inner_hash = Hash[options.to_a + options2.to_a]
|
18
19
|
end
|
19
20
|
|
20
21
|
##
|
@@ -26,7 +27,7 @@ module ActiveTriples
|
|
26
27
|
# result of merging.
|
27
28
|
def merge(options)
|
28
29
|
options = options.to_h
|
29
|
-
new_config = self.class.new(
|
30
|
+
new_config = self.class.new(options)
|
30
31
|
|
31
32
|
new_config.items.each do |property, item|
|
32
33
|
build_configuration_item(property).set item.value
|
@@ -66,7 +66,7 @@ module ActiveTriples
|
|
66
66
|
registered_preds = registered_predicates << RDF.type
|
67
67
|
unregistered_preds = []
|
68
68
|
|
69
|
-
query(
|
69
|
+
query([rdf_subject, nil, nil]) do |stmt|
|
70
70
|
unregistered_preds << stmt.predicate unless
|
71
71
|
registered_preds.include? stmt.predicate
|
72
72
|
end
|
@@ -92,11 +92,9 @@ module ActiveTriples
|
|
92
92
|
##
|
93
93
|
# @!method to_base
|
94
94
|
# @return (see RDF::Term#to_base)
|
95
|
-
# @!method term?
|
96
|
-
# @return (see RDF::Term#term?)
|
97
95
|
# @!method escape
|
98
96
|
# @return (see RDF::Term#escape)
|
99
|
-
delegate :to_base, :
|
97
|
+
delegate :to_base, :escape, to: :to_term
|
100
98
|
|
101
99
|
##
|
102
100
|
# Initialize an instance of this resource class. Defaults to a
|
@@ -110,7 +108,7 @@ module ActiveTriples
|
|
110
108
|
# @see RDF::Graph
|
111
109
|
# @todo move this logic out to a Builder?
|
112
110
|
def initialize(*args, &block)
|
113
|
-
@observers
|
111
|
+
@observers = Set.new
|
114
112
|
|
115
113
|
resource_uri = args.shift unless args.first.is_a?(Hash)
|
116
114
|
@rdf_subject = get_uri(resource_uri) if resource_uri
|
@@ -122,7 +120,12 @@ module ActiveTriples
|
|
122
120
|
persistence_strategy.parent = args.shift
|
123
121
|
end
|
124
122
|
|
125
|
-
|
123
|
+
graph_params = if args.empty? || args.first.nil?
|
124
|
+
{}
|
125
|
+
else
|
126
|
+
args.shift
|
127
|
+
end
|
128
|
+
persistence_strategy.graph = RDF::Graph.new(**graph_params, &block)
|
126
129
|
reload
|
127
130
|
|
128
131
|
# Append type to graph if necessary.
|
@@ -398,9 +401,9 @@ module ActiveTriples
|
|
398
401
|
# @yieldparam [ActiveTriples::RDFSource] resource self
|
399
402
|
#
|
400
403
|
# @return [ActiveTriples::RDFSource] self
|
401
|
-
def fetch(
|
404
|
+
def fetch(**args, &_block)
|
402
405
|
begin
|
403
|
-
load(rdf_subject,
|
406
|
+
load(rdf_subject, **args)
|
404
407
|
rescue => e
|
405
408
|
if block_given?
|
406
409
|
yield(self)
|
@@ -575,6 +578,26 @@ module ActiveTriples
|
|
575
578
|
!persisted?
|
576
579
|
end
|
577
580
|
|
581
|
+
##
|
582
|
+
# @overload term?
|
583
|
+
# Returns `false` indicating this is not an RDF::Statemenet.
|
584
|
+
# @see RDF::Value#statement?
|
585
|
+
# @return [Boolean]
|
586
|
+
# @overload term?(value)
|
587
|
+
# Returns `true` if `self` contains the given RDF subject term.
|
588
|
+
#
|
589
|
+
# @param [RDF::Resource] value
|
590
|
+
# @return [Boolean]
|
591
|
+
#
|
592
|
+
# See RDF::Enumerable#term?
|
593
|
+
def term?(*args)
|
594
|
+
case args.length
|
595
|
+
when 0 then to_term.term?
|
596
|
+
when 1 then args.first && graph.term?(args.first)
|
597
|
+
else raise ArgumentError("wrong number of arguments (given #{args.length}, expected 0 or 1)")
|
598
|
+
end
|
599
|
+
end
|
600
|
+
|
578
601
|
def mark_for_destruction
|
579
602
|
@marked_for_destruction = true
|
580
603
|
end
|
@@ -641,7 +664,7 @@ module ActiveTriples
|
|
641
664
|
# @param [RDF::Term] new_subject
|
642
665
|
# @return [void]
|
643
666
|
def rewrite_statement_uris(old_subject, new_subject)
|
644
|
-
graph.query(
|
667
|
+
graph.query([old_subject, nil, nil]).each do |st|
|
645
668
|
graph.delete(st)
|
646
669
|
|
647
670
|
st.subject = new_subject
|
@@ -649,7 +672,7 @@ module ActiveTriples
|
|
649
672
|
graph.insert(st)
|
650
673
|
end
|
651
674
|
|
652
|
-
graph.query(
|
675
|
+
graph.query([nil, nil, old_subject]).each do |st|
|
653
676
|
graph.delete(st)
|
654
677
|
|
655
678
|
st.object = new_subject
|
@@ -481,7 +481,7 @@ module ActiveTriples
|
|
481
481
|
##
|
482
482
|
# @private
|
483
483
|
def objects(&block)
|
484
|
-
solutions = parent.query(
|
484
|
+
solutions = parent.query([rdf_subject, predicate, nil])
|
485
485
|
solutions.extend(RDF::Enumerable) unless solutions.respond_to?(:each_object)
|
486
486
|
|
487
487
|
solutions.each_object(&block)
|
@@ -55,7 +55,7 @@ module ActiveTriples
|
|
55
55
|
ancestors = @ancestors.dup
|
56
56
|
|
57
57
|
if block_given?
|
58
|
-
statements = source_graph.query(
|
58
|
+
statements = source_graph.query([starting_node, nil, nil]).each
|
59
59
|
statements.each_statement { |st| yield st }
|
60
60
|
|
61
61
|
ancestors << starting_node
|
@@ -743,7 +743,7 @@ describe ActiveTriples::RDFSource do
|
|
743
743
|
|
744
744
|
it 'has errors' do
|
745
745
|
expect { subject.valid? }
|
746
|
-
.to change { subject.errors.messages }
|
746
|
+
.to change { subject.errors.messages.transform_values { |v| v.map(&:to_s) } }
|
747
747
|
.from({})
|
748
748
|
.to(include(base: ['The underlying graph must be valid']))
|
749
749
|
end
|
@@ -470,7 +470,7 @@ describe ActiveTriples::Resource do
|
|
470
470
|
describe '#set_value' do
|
471
471
|
it 'should set a value in the graph' do
|
472
472
|
subject.set_value(RDF::Vocab::DC.title, 'Comet in Moominland')
|
473
|
-
subject.query(
|
473
|
+
subject.query([subject.rdf_subject, nil, RDF::Vocab::DC.title]).each_statement do |s|
|
474
474
|
expect(s.object.to_s).to eq 'Comet in Moominland'
|
475
475
|
end
|
476
476
|
end
|
@@ -522,14 +522,14 @@ describe ActiveTriples::Resource do
|
|
522
522
|
|
523
523
|
it "should be able to accept a subject" do
|
524
524
|
expect{subject.set_value(RDF::URI("http://opaquenamespace.org/jokes"), RDF::Vocab::DC.title, 'Comet in Moominland')}.not_to raise_error
|
525
|
-
expect(subject.query(
|
525
|
+
expect(subject.query([RDF::URI("http://opaquenamespace.org/jokes"), RDF::Vocab::DC.title, nil]).statements.to_a.length).to eq 1
|
526
526
|
end
|
527
527
|
end
|
528
528
|
|
529
529
|
describe '#[]=' do
|
530
530
|
it 'should set a value in the graph' do
|
531
531
|
subject[RDF::Vocab::DC.title] = 'Comet in Moominland'
|
532
|
-
subject.query(
|
532
|
+
subject.query([subject.rdf_subject, nil, RDF::Vocab::DC.title]).each_statement do |s|
|
533
533
|
expect(s.object.to_s).to eq 'Comet in Moominland'
|
534
534
|
end
|
535
535
|
end
|
@@ -616,7 +616,7 @@ describe ActiveTriples::Resource do
|
|
616
616
|
end
|
617
617
|
|
618
618
|
it 'should be the type in the graph' do
|
619
|
-
subject.query(
|
619
|
+
subject.query([subject.rdf_subject, nil, RDF.type]).statements do |s|
|
620
620
|
expect(s.object).to eq RDF::URI('http://example.org/AnotherClass')
|
621
621
|
end
|
622
622
|
end
|
metadata
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: active-triples
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
|
-
-
|
8
|
-
- Trey
|
7
|
+
- Tamsin Johnson
|
8
|
+
- Trey Pendragon
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2023-01-26 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rdf
|
@@ -252,7 +252,7 @@ dependencies:
|
|
252
252
|
- !ruby/object:Gem::Version
|
253
253
|
version: 0.1.2
|
254
254
|
description: ActiveTriples provides tools for modeling RDF as discrete resources.
|
255
|
-
email:
|
255
|
+
email: tomjohnson@ucsb.edu
|
256
256
|
executables: []
|
257
257
|
extensions: []
|
258
258
|
extra_rdoc_files:
|
@@ -353,7 +353,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
353
353
|
- !ruby/object:Gem::Version
|
354
354
|
version: '0'
|
355
355
|
requirements: []
|
356
|
-
rubygems_version: 3.1.
|
356
|
+
rubygems_version: 3.1.6
|
357
357
|
signing_key:
|
358
358
|
specification_version: 4
|
359
359
|
summary: RDF graphs in ActiveModel wrappers.
|