active-triples 0.4.1 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +0 -1
- data/.travis.yml +3 -10
- data/Gemfile +0 -22
- data/active-triples.gemspec +1 -6
- data/lib/active_triples/identifiable.rb +1 -11
- data/lib/active_triples/node_config.rb +9 -5
- data/lib/active_triples/properties.rb +1 -13
- data/lib/active_triples/repositories.rb +17 -0
- data/lib/active_triples/resource.rb +35 -3
- data/lib/active_triples/term.rb +19 -10
- data/lib/active_triples/version.rb +1 -1
- data/spec/active_triples/list_spec.rb +1 -1
- data/spec/active_triples/repositories_spec.rb +76 -0
- data/spec/active_triples/resource_spec.rb +112 -0
- data/spec/pragmatic_context_spec.rb +1 -3
- metadata +7 -82
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 42a735382f3d5ad34bb75398f7dbe41bc4092ed0
|
4
|
+
data.tar.gz: 64e572f52e992165f32a84202a73b6266032ce81
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8e1c1c02dc97fddfb50dd818fd97087a9d8032d8e0552dc5d712da15c5f7363ed0a90eada66d2dfa28692049a6fb1ab6427ffe6167115565ca2cb66537a41d7f
|
7
|
+
data.tar.gz: 4fc879ad051dd585c8eb4b1570f4b1530002e7e2b91a15ee2511b1771d38c3edf4074ee550123598e74d591173483c79141b8d174cb255ae6a385c682fcb67cd
|
data/.gitignore
CHANGED
data/.travis.yml
CHANGED
@@ -1,19 +1,12 @@
|
|
1
1
|
anguage: ruby
|
2
2
|
bundler_args: --without debug
|
3
3
|
script: "bundle exec rspec spec"
|
4
|
-
env:
|
5
|
-
- CI=true
|
6
4
|
rvm:
|
7
5
|
- 1.9.3
|
8
6
|
- 2.0.0
|
9
|
-
- 2.1
|
10
|
-
- 2.
|
11
|
-
- 2.3
|
12
|
-
- 2.4
|
7
|
+
- 2.1.0
|
8
|
+
- 2.1.1
|
13
9
|
- jruby-19mode
|
14
|
-
cache: bundler
|
15
|
-
sudo: false
|
16
10
|
matrix:
|
17
11
|
allow_failures:
|
18
|
-
- rvm: jruby-19mode
|
19
|
-
dist: trusty
|
12
|
+
- rvm: jruby-19mode
|
data/Gemfile
CHANGED
@@ -1,25 +1,3 @@
|
|
1
1
|
source "https://rubygems.org"
|
2
2
|
|
3
3
|
gemspec
|
4
|
-
|
5
|
-
version = Gem::Version.new(RUBY_VERSION)
|
6
|
-
|
7
|
-
if (version <= Gem::Version.new('2.2.4')) &&
|
8
|
-
(version >= Gem::Version.new('2.0.0'))
|
9
|
-
gem 'ruby_dep', '< 1.4.0'
|
10
|
-
end
|
11
|
-
|
12
|
-
gem 'listen', '< 3.1' if version <= Gem::Version.new('2.2.3')
|
13
|
-
gem 'activesupport', '< 5' if version <= Gem::Version.new('2.2.2')
|
14
|
-
|
15
|
-
if version <= Gem::Version.new('2.1.0')
|
16
|
-
gem 'deprecation', '< 0.3.0'
|
17
|
-
gem 'nokogiri', '< 1.7'
|
18
|
-
end
|
19
|
-
|
20
|
-
if version <= Gem::Version.new('2.0.0')
|
21
|
-
gem 'public_suffix', '< 1.5'
|
22
|
-
gem 'json-ld', '< 1.8'
|
23
|
-
gem 'linkeddata', '<= 1.1.11'
|
24
|
-
gem 'webmock', '< 2.3'
|
25
|
-
end
|
data/active-triples.gemspec
CHANGED
@@ -15,18 +15,13 @@ Gem::Specification.new do |s|
|
|
15
15
|
s.required_ruby_version = '>= 1.9.3'
|
16
16
|
|
17
17
|
s.add_dependency('rdf', '~> 1.1')
|
18
|
-
s.add_dependency('
|
18
|
+
s.add_dependency('linkeddata', '~> 1.1')
|
19
19
|
s.add_dependency('activemodel', '>= 3.0.0')
|
20
20
|
s.add_dependency('deprecation', '~> 0.1')
|
21
21
|
s.add_dependency('activesupport', '>= 3.0.0')
|
22
22
|
|
23
23
|
s.add_development_dependency('rdoc')
|
24
24
|
s.add_development_dependency('rspec')
|
25
|
-
s.add_development_dependency('rdf-spec', '~> 1.99')
|
26
|
-
s.add_development_dependency('rdf-rdfxml', '>= 1.1.5', '~> 1.1')
|
27
|
-
s.add_development_dependency('rdf-turtle', '~> 1.99')
|
28
|
-
s.add_development_dependency('rdf-isomorphic', '~> 1.99')
|
29
|
-
s.add_development_dependency('json-ld', '~> 1.99')
|
30
25
|
s.add_development_dependency('guard-rspec')
|
31
26
|
s.add_development_dependency('webmock')
|
32
27
|
s.add_development_dependency('nokogiri')
|
@@ -33,16 +33,6 @@ module ActiveTriples::Identifiable
|
|
33
33
|
self.class.resource_class
|
34
34
|
end
|
35
35
|
|
36
|
-
def update_resource(&block)
|
37
|
-
resource_class.properties.each do |name, property|
|
38
|
-
if block_given?
|
39
|
-
yield name, property
|
40
|
-
else
|
41
|
-
resource.set_value(property.predicate, self.send(property.term))
|
42
|
-
end
|
43
|
-
end
|
44
|
-
end
|
45
|
-
|
46
36
|
public
|
47
37
|
|
48
38
|
module ClassMethods
|
@@ -50,7 +40,7 @@ module ActiveTriples::Identifiable
|
|
50
40
|
delegate :configure, :property, :properties, to: :resource_class
|
51
41
|
|
52
42
|
def resource_class
|
53
|
-
@resource_class ||= Class.new(ActiveTriples::Resource)
|
43
|
+
@resource_class ||= self.const_set(:GeneratedResourceSchema, Class.new(ActiveTriples::Resource))
|
54
44
|
end
|
55
45
|
|
56
46
|
def from_uri(uri, *args)
|
@@ -1,14 +1,12 @@
|
|
1
1
|
module ActiveTriples
|
2
2
|
class NodeConfig
|
3
|
-
attr_accessor :predicate, :term, :class_name, :type, :behaviors, :
|
3
|
+
attr_accessor :predicate, :term, :class_name, :type, :behaviors, :cast
|
4
4
|
|
5
5
|
def initialize(term, predicate, args={})
|
6
6
|
self.term = term
|
7
7
|
self.predicate = predicate
|
8
|
-
self.class_name = args.
|
9
|
-
self.
|
10
|
-
self.cast = args.delete(:cast) { true }
|
11
|
-
raise ArgumentError, "Invalid arguments for Rdf Node configuration: #{args} on #{predicate}" unless args.empty?
|
8
|
+
self.class_name = args.fetch(:class_name) { default_class_name }
|
9
|
+
self.cast = args.fetch(:cast) { true }
|
12
10
|
yield(self) if block_given?
|
13
11
|
end
|
14
12
|
|
@@ -38,6 +36,12 @@ module ActiveTriples
|
|
38
36
|
self.behaviors = iobj.behaviors
|
39
37
|
end
|
40
38
|
|
39
|
+
private
|
40
|
+
|
41
|
+
def default_class_name
|
42
|
+
nil
|
43
|
+
end
|
44
|
+
|
41
45
|
# this enables a cleaner API for solr integration
|
42
46
|
class IndexObject
|
43
47
|
attr_accessor :data_type, :behaviors
|
@@ -17,18 +17,6 @@ module ActiveTriples
|
|
17
17
|
initialize_generated_modules
|
18
18
|
end
|
19
19
|
|
20
|
-
##
|
21
|
-
# Registers properties for Resource-like classes
|
22
|
-
# @param [Symbol] name of the property (and its accessor methods)
|
23
|
-
# @param [Hash] opts for this property, must include a :predicate
|
24
|
-
# @yield [index] index sets solr behaviors for the property
|
25
|
-
def property(name, opts={}, &block)
|
26
|
-
self.config[name] = NodeConfig.new(name, opts[:predicate], opts.except(:predicate)).tap do |config|
|
27
|
-
config.with_index(&block) if block_given?
|
28
|
-
end
|
29
|
-
register_property(name)
|
30
|
-
end
|
31
|
-
|
32
20
|
module ClassMethods
|
33
21
|
def inherited(child_class) #:nodoc:
|
34
22
|
child_class.initialize_generated_modules
|
@@ -57,7 +45,7 @@ module ActiveTriples
|
|
57
45
|
reflection = PropertyBuilder.build(self, name, opts, &block)
|
58
46
|
Reflection.add_reflection self, name, reflection
|
59
47
|
end
|
60
|
-
|
48
|
+
|
61
49
|
def protected_property_name?(name)
|
62
50
|
reject = self.instance_methods.map! { |s| s.to_s.gsub(/=$/, '').to_sym }
|
63
51
|
reject -= properties.keys.map { |k| k.to_sym }
|
@@ -32,5 +32,22 @@ module ActiveTriples
|
|
32
32
|
end
|
33
33
|
module_function :repositories
|
34
34
|
|
35
|
+
##
|
36
|
+
# Check for the specified rdf_subject in the specified repository
|
37
|
+
# defaulting to search all registered repositories.
|
38
|
+
# @param [String] rdf_subject
|
39
|
+
# @param [Symbol] repository name
|
40
|
+
def has_subject?(rdf_subject,repo_name=nil)
|
41
|
+
search_repositories = [repositories[repo_name]] if repo_name
|
42
|
+
search_repositories ||= repositories.values
|
43
|
+
found = false
|
44
|
+
search_repositories.each do |repo|
|
45
|
+
found = repo.has_subject? rdf_subject
|
46
|
+
break if found
|
47
|
+
end
|
48
|
+
found
|
49
|
+
end
|
50
|
+
module_function :has_subject?
|
51
|
+
|
35
52
|
end
|
36
53
|
end
|
@@ -316,8 +316,8 @@ module ActiveTriples
|
|
316
316
|
def get_term(args)
|
317
317
|
@term_cache ||= {}
|
318
318
|
term = Term.new(self, args)
|
319
|
-
@term_cache["#{term.send(:rdf_subject)}/#{term.property}"] ||= term
|
320
|
-
@term_cache["#{term.send(:rdf_subject)}/#{term.property}"]
|
319
|
+
@term_cache["#{term.send(:rdf_subject)}/#{term.property}/#{term.term_args}"] ||= term
|
320
|
+
@term_cache["#{term.send(:rdf_subject)}/#{term.property}/#{term.term_args}"]
|
321
321
|
end
|
322
322
|
|
323
323
|
##
|
@@ -407,7 +407,39 @@ module ActiveTriples
|
|
407
407
|
else
|
408
408
|
repository.delete [rdf_subject, nil, nil]
|
409
409
|
end
|
410
|
-
|
410
|
+
end
|
411
|
+
|
412
|
+
##
|
413
|
+
# Test if the rdf_subject that would be generated using a
|
414
|
+
# specific ID is already in use in the triplestore.
|
415
|
+
#
|
416
|
+
# @param [Integer, #read] ID to test
|
417
|
+
#
|
418
|
+
# @return [TrueClass, FalseClass] true, if the ID is in
|
419
|
+
# use in the triplestore; otherwise, false.
|
420
|
+
# NOTE: If the ID is in use in an object not yet
|
421
|
+
# persisted, false will be returned presenting
|
422
|
+
# a window of opportunity for an ID clash.
|
423
|
+
def self.id_persisted?(test_id)
|
424
|
+
rdf_subject = self.new(test_id).rdf_subject
|
425
|
+
ActiveTriples::Repositories.has_subject?(rdf_subject)
|
426
|
+
end
|
427
|
+
|
428
|
+
##
|
429
|
+
# Test if the rdf_subject that would be generated using a
|
430
|
+
# specific URI is already in use in the triplestore.
|
431
|
+
#
|
432
|
+
# @param [String, RDF::URI, #read] URI to test
|
433
|
+
#
|
434
|
+
# @return [TrueClass, FalseClass] true, if the URI is in
|
435
|
+
# use in the triplestore; otherwise, false.
|
436
|
+
# NOTE: If the URI is in use in an object not yet
|
437
|
+
# persisted, false will be returned presenting
|
438
|
+
# a window of opportunity for an ID clash.
|
439
|
+
def self.uri_persisted?(test_uri)
|
440
|
+
rdf_subject = test_uri.kind_of?(RDF::URI) ? test_uri : RDF::URI(test_uri)
|
441
|
+
ActiveTriples::Repositories.has_subject?(rdf_subject)
|
442
|
+
end
|
411
443
|
|
412
444
|
private
|
413
445
|
|
data/lib/active_triples/term.rb
CHANGED
@@ -3,7 +3,7 @@ require 'active_support/core_ext/module/delegation'
|
|
3
3
|
module ActiveTriples
|
4
4
|
class Term
|
5
5
|
|
6
|
-
attr_accessor :parent, :value_arguments, :node_cache
|
6
|
+
attr_accessor :parent, :value_arguments, :node_cache, :term_args
|
7
7
|
attr_reader :reflections
|
8
8
|
|
9
9
|
delegate *(Array.public_instance_methods - [:send, :__send__, :__id__, :class, :object_id] + [:as_json]), :to => :result
|
@@ -14,18 +14,23 @@ module ActiveTriples
|
|
14
14
|
self.value_arguments = value_arguments
|
15
15
|
end
|
16
16
|
|
17
|
+
def value_arguments=(value_args)
|
18
|
+
if value_args.kind_of?(Array) && value_args.last.kind_of?(Hash)
|
19
|
+
self.term_args = value_args.pop
|
20
|
+
end
|
21
|
+
@value_arguments = value_args
|
22
|
+
end
|
23
|
+
|
17
24
|
def clear
|
18
25
|
set(nil)
|
19
26
|
end
|
20
27
|
|
21
28
|
def result
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
return result if !property_config || property_config[:multivalue]
|
28
|
-
result.first
|
29
|
+
parent.query(:subject => rdf_subject, :predicate => predicate)
|
30
|
+
.each_with_object([]) do |x, collector|
|
31
|
+
converted_object = convert_object(x.object)
|
32
|
+
collector << converted_object unless converted_object.nil?
|
33
|
+
end
|
29
34
|
end
|
30
35
|
|
31
36
|
def set(values)
|
@@ -90,7 +95,7 @@ module ActiveTriples
|
|
90
95
|
end
|
91
96
|
|
92
97
|
def type_property
|
93
|
-
{ :
|
98
|
+
{ :predicate => RDF.type, :cast => false }
|
94
99
|
end
|
95
100
|
|
96
101
|
def reset!
|
@@ -147,7 +152,7 @@ module ActiveTriples
|
|
147
152
|
def convert_object(value)
|
148
153
|
case value
|
149
154
|
when RDF::Literal
|
150
|
-
value.object
|
155
|
+
return_literals? ? value : value.object
|
151
156
|
when RDF::Resource
|
152
157
|
make_node(value)
|
153
158
|
else
|
@@ -176,6 +181,10 @@ module ActiveTriples
|
|
176
181
|
!!property_config[:cast]
|
177
182
|
end
|
178
183
|
|
184
|
+
def return_literals?
|
185
|
+
term_args && term_args[:literal]
|
186
|
+
end
|
187
|
+
|
179
188
|
def final_parent
|
180
189
|
@final_parent ||= begin
|
181
190
|
parent = self.parent
|
@@ -25,4 +25,80 @@ describe ActiveTriples::Repositories do
|
|
25
25
|
end
|
26
26
|
end
|
27
27
|
|
28
|
+
describe '#has_subject?' do
|
29
|
+
|
30
|
+
let(:resource2) do
|
31
|
+
DummyResource2.new(2)
|
32
|
+
end
|
33
|
+
|
34
|
+
before do
|
35
|
+
class DummyResource1 < ActiveTriples::Resource
|
36
|
+
configure :base_uri => "http://example.org/r1/",
|
37
|
+
:type => RDF::URI("http://example.org/SomeClass"),
|
38
|
+
:repository => :repo1
|
39
|
+
end
|
40
|
+
class DummyResource2 < ActiveTriples::Resource
|
41
|
+
configure :base_uri => "http://example.org/r2/",
|
42
|
+
:type => RDF::URI("http://example.org/SomeClass"),
|
43
|
+
:repository => :repo2
|
44
|
+
end
|
45
|
+
class DummyResource3 < ActiveTriples::Resource
|
46
|
+
configure :base_uri => "http://example.org/r3/",
|
47
|
+
:type => RDF::URI("http://example.org/SomeClass"),
|
48
|
+
:repository => :repo3
|
49
|
+
end
|
50
|
+
ActiveTriples::Repositories.add_repository :repo1, RDF::Repository.new
|
51
|
+
ActiveTriples::Repositories.add_repository :repo2, RDF::Repository.new
|
52
|
+
ActiveTriples::Repositories.add_repository :repo3, RDF::Repository.new
|
53
|
+
|
54
|
+
DummyResource1.new('1').persist!
|
55
|
+
DummyResource2.new('2').persist!
|
56
|
+
DummyResource3.new('3').persist!
|
57
|
+
|
58
|
+
end
|
59
|
+
after do
|
60
|
+
DummyResource1.new('1').destroy!
|
61
|
+
DummyResource2.new('2').destroy!
|
62
|
+
DummyResource3.new('3').destroy!
|
63
|
+
|
64
|
+
Object.send(:remove_const, "DummyResource1") if Object
|
65
|
+
Object.send(:remove_const, "DummyResource2") if Object
|
66
|
+
Object.send(:remove_const, "DummyResource3") if Object
|
67
|
+
ActiveTriples::Repositories.clear_repositories!
|
68
|
+
end
|
69
|
+
|
70
|
+
context 'when checking only one named repository' do
|
71
|
+
context 'and rdf_subject exists in the repository' do
|
72
|
+
it 'should return true' do
|
73
|
+
expect(ActiveTriples::Repositories.has_subject?(resource2.rdf_subject,:repo2)).to be_truthy
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
context 'and rdf_subject exists in another repository' do
|
78
|
+
it 'should return false' do
|
79
|
+
expect(ActiveTriples::Repositories.has_subject?(resource2.rdf_subject,:repo1)).to be_falsey
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
context 'and rdf_subject does not exists in any repository' do
|
84
|
+
it 'should return false' do
|
85
|
+
expect(ActiveTriples::Repositories.has_subject?("#{resource2.rdf_subject}_NOEXIST",:repo1)).to be_falsey
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
context 'when checking all repositories' do
|
91
|
+
context 'and rdf_subject exists in one repository' do
|
92
|
+
it 'should return true' do
|
93
|
+
expect(ActiveTriples::Repositories.has_subject?(resource2.rdf_subject)).to be_truthy
|
94
|
+
end
|
95
|
+
end
|
96
|
+
|
97
|
+
context 'and rdf_subject does not exists in any repository' do
|
98
|
+
it 'should return false' do
|
99
|
+
expect(ActiveTriples::Repositories.has_subject?("#{resource2.rdf_subject}_NOEXIST")).to be_falsey
|
100
|
+
end
|
101
|
+
end
|
102
|
+
end
|
103
|
+
end
|
28
104
|
end
|
@@ -162,6 +162,98 @@ describe ActiveTriples::Resource do
|
|
162
162
|
end
|
163
163
|
end
|
164
164
|
|
165
|
+
describe "#id_persisted?" do
|
166
|
+
|
167
|
+
subject {DummyResourceWithBaseURI.new('1')}
|
168
|
+
|
169
|
+
before do
|
170
|
+
class DummyResourceWithBaseURI < ActiveTriples::Resource
|
171
|
+
configure :base_uri => "http://example.org",
|
172
|
+
:type => RDF::URI("http://example.org/SomeClass"),
|
173
|
+
:repository => :default
|
174
|
+
end
|
175
|
+
ActiveTriples::Repositories.add_repository :default, RDF::Repository.new
|
176
|
+
subject.persist!
|
177
|
+
end
|
178
|
+
after do
|
179
|
+
Object.send(:remove_const, "DummyResourceWithBaseURI") if Object
|
180
|
+
ActiveTriples::Repositories.clear_repositories!
|
181
|
+
end
|
182
|
+
|
183
|
+
context "when ID is a string" do
|
184
|
+
it "should be false if ID does not exist" do
|
185
|
+
expect(DummyResourceWithBaseURI.id_persisted?('2')).to be_falsey
|
186
|
+
end
|
187
|
+
|
188
|
+
it "should be true if ID exists" do
|
189
|
+
expect(DummyResourceWithBaseURI.id_persisted?('1')).to be_truthy
|
190
|
+
end
|
191
|
+
end
|
192
|
+
|
193
|
+
context "when ID is numeric" do
|
194
|
+
it "should be false if ID does not exist" do
|
195
|
+
expect(DummyResourceWithBaseURI.id_persisted?(2)).to be_falsey
|
196
|
+
end
|
197
|
+
|
198
|
+
it "should be true if ID exists" do
|
199
|
+
expect(DummyResourceWithBaseURI.id_persisted?(1)).to be_truthy
|
200
|
+
end
|
201
|
+
end
|
202
|
+
|
203
|
+
context "when object with ID in use is not persisted" do
|
204
|
+
it "should be false" do
|
205
|
+
DummyResourceWithBaseURI.new('3')
|
206
|
+
expect(DummyResourceWithBaseURI.id_persisted?(3)).to be_falsey
|
207
|
+
end
|
208
|
+
end
|
209
|
+
end
|
210
|
+
|
211
|
+
describe "#uri_persisted?" do
|
212
|
+
|
213
|
+
subject {DummyResourceWithBaseURI.new('11')}
|
214
|
+
|
215
|
+
before do
|
216
|
+
class DummyResourceWithBaseURI < ActiveTriples::Resource
|
217
|
+
configure :base_uri => "http://example.org",
|
218
|
+
:type => RDF::URI("http://example.org/SomeClass"),
|
219
|
+
:repository => :default
|
220
|
+
end
|
221
|
+
ActiveTriples::Repositories.add_repository :default, RDF::Repository.new
|
222
|
+
subject.persist!
|
223
|
+
end
|
224
|
+
after do
|
225
|
+
Object.send(:remove_const, "DummyResourceWithBaseURI") if Object
|
226
|
+
ActiveTriples::Repositories.clear_repositories!
|
227
|
+
end
|
228
|
+
|
229
|
+
context "when URI is a http string" do
|
230
|
+
it "should be false if URI does not exist" do
|
231
|
+
expect(DummyResourceWithBaseURI.uri_persisted?("http://example.org/22")).to be_falsey
|
232
|
+
end
|
233
|
+
|
234
|
+
it "should be true if URI does exist" do
|
235
|
+
expect(DummyResourceWithBaseURI.uri_persisted?("http://example.org/11")).to be_truthy
|
236
|
+
end
|
237
|
+
end
|
238
|
+
|
239
|
+
context "when URI is a RDF::URI" do
|
240
|
+
it "should be false if URI does not exist" do
|
241
|
+
expect(DummyResourceWithBaseURI.uri_persisted?(RDF::URI("http://example.org/22"))).to be_falsey
|
242
|
+
end
|
243
|
+
|
244
|
+
it "should be true if URI does exist" do
|
245
|
+
expect(DummyResourceWithBaseURI.uri_persisted?(RDF::URI("http://example.org/11"))).to be_truthy
|
246
|
+
end
|
247
|
+
end
|
248
|
+
|
249
|
+
context "when object with URI is not persisted" do
|
250
|
+
it "should be false" do
|
251
|
+
DummyResourceWithBaseURI.new('13')
|
252
|
+
expect(DummyResourceWithBaseURI.uri_persisted?("http://example.org/13")).to be_falsey
|
253
|
+
end
|
254
|
+
end
|
255
|
+
end
|
256
|
+
|
165
257
|
describe '#destroy!' do
|
166
258
|
before do
|
167
259
|
subject.title = 'Creative Commons'
|
@@ -463,6 +555,26 @@ describe ActiveTriples::Resource do
|
|
463
555
|
subject.set_value(RDF::URI("http://opaquenamespace.org/jokes"), RDF::DC.title, 'Comet in Moominland')
|
464
556
|
expect(subject.get_values(RDF::URI("http://opaquenamespace.org/jokes"),:title)).to eq ["Comet in Moominland"]
|
465
557
|
end
|
558
|
+
|
559
|
+
context "literals are set" do
|
560
|
+
let(:literal1) { RDF::Literal.new("test", :language => :en) }
|
561
|
+
let(:literal2) { RDF::Literal.new("test", :language => :fr) }
|
562
|
+
before do
|
563
|
+
subject.set_value(RDF::DC.title, [literal1, literal2])
|
564
|
+
end
|
565
|
+
context "and literals are not requested" do
|
566
|
+
it "should return a string" do
|
567
|
+
# Should this de-duplicate?
|
568
|
+
expect(subject.get_values(RDF::DC.title)).to eq ["test", "test"]
|
569
|
+
end
|
570
|
+
end
|
571
|
+
context "and literals are requested" do
|
572
|
+
it "should return literals" do
|
573
|
+
expect(subject.get_values(RDF::DC.title, :literal => true)).to eq [literal1, literal2]
|
574
|
+
end
|
575
|
+
end
|
576
|
+
end
|
577
|
+
|
466
578
|
end
|
467
579
|
|
468
580
|
describe '#[]' do
|
@@ -1,6 +1,5 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
require 'pragmatic_context'
|
3
|
-
require 'json/ld'
|
4
3
|
|
5
4
|
describe 'PragmaticContext integration' do
|
6
5
|
before do
|
@@ -42,8 +41,7 @@ describe 'PragmaticContext integration' do
|
|
42
41
|
end
|
43
42
|
|
44
43
|
it 'should have contexts' do
|
45
|
-
expect(subject.as_jsonld['@context'].keys)
|
46
|
-
.to contain_exactly("license", "title")
|
44
|
+
expect(subject.as_jsonld['@context'].keys).to eq ["license", "title"]
|
47
45
|
end
|
48
46
|
|
49
47
|
it 'should use context with dump' do
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: active-triples
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tom Johnson
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2014-12-08 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rdf
|
@@ -26,19 +26,19 @@ dependencies:
|
|
26
26
|
- !ruby/object:Gem::Version
|
27
27
|
version: '1.1'
|
28
28
|
- !ruby/object:Gem::Dependency
|
29
|
-
name:
|
29
|
+
name: linkeddata
|
30
30
|
requirement: !ruby/object:Gem::Requirement
|
31
31
|
requirements:
|
32
32
|
- - "~>"
|
33
33
|
- !ruby/object:Gem::Version
|
34
|
-
version: '
|
34
|
+
version: '1.1'
|
35
35
|
type: :runtime
|
36
36
|
prerelease: false
|
37
37
|
version_requirements: !ruby/object:Gem::Requirement
|
38
38
|
requirements:
|
39
39
|
- - "~>"
|
40
40
|
- !ruby/object:Gem::Version
|
41
|
-
version: '
|
41
|
+
version: '1.1'
|
42
42
|
- !ruby/object:Gem::Dependency
|
43
43
|
name: activemodel
|
44
44
|
requirement: !ruby/object:Gem::Requirement
|
@@ -109,82 +109,6 @@ dependencies:
|
|
109
109
|
- - ">="
|
110
110
|
- !ruby/object:Gem::Version
|
111
111
|
version: '0'
|
112
|
-
- !ruby/object:Gem::Dependency
|
113
|
-
name: rdf-spec
|
114
|
-
requirement: !ruby/object:Gem::Requirement
|
115
|
-
requirements:
|
116
|
-
- - "~>"
|
117
|
-
- !ruby/object:Gem::Version
|
118
|
-
version: '1.99'
|
119
|
-
type: :development
|
120
|
-
prerelease: false
|
121
|
-
version_requirements: !ruby/object:Gem::Requirement
|
122
|
-
requirements:
|
123
|
-
- - "~>"
|
124
|
-
- !ruby/object:Gem::Version
|
125
|
-
version: '1.99'
|
126
|
-
- !ruby/object:Gem::Dependency
|
127
|
-
name: rdf-rdfxml
|
128
|
-
requirement: !ruby/object:Gem::Requirement
|
129
|
-
requirements:
|
130
|
-
- - ">="
|
131
|
-
- !ruby/object:Gem::Version
|
132
|
-
version: 1.1.5
|
133
|
-
- - "~>"
|
134
|
-
- !ruby/object:Gem::Version
|
135
|
-
version: '1.1'
|
136
|
-
type: :development
|
137
|
-
prerelease: false
|
138
|
-
version_requirements: !ruby/object:Gem::Requirement
|
139
|
-
requirements:
|
140
|
-
- - ">="
|
141
|
-
- !ruby/object:Gem::Version
|
142
|
-
version: 1.1.5
|
143
|
-
- - "~>"
|
144
|
-
- !ruby/object:Gem::Version
|
145
|
-
version: '1.1'
|
146
|
-
- !ruby/object:Gem::Dependency
|
147
|
-
name: rdf-turtle
|
148
|
-
requirement: !ruby/object:Gem::Requirement
|
149
|
-
requirements:
|
150
|
-
- - "~>"
|
151
|
-
- !ruby/object:Gem::Version
|
152
|
-
version: '1.99'
|
153
|
-
type: :development
|
154
|
-
prerelease: false
|
155
|
-
version_requirements: !ruby/object:Gem::Requirement
|
156
|
-
requirements:
|
157
|
-
- - "~>"
|
158
|
-
- !ruby/object:Gem::Version
|
159
|
-
version: '1.99'
|
160
|
-
- !ruby/object:Gem::Dependency
|
161
|
-
name: rdf-isomorphic
|
162
|
-
requirement: !ruby/object:Gem::Requirement
|
163
|
-
requirements:
|
164
|
-
- - "~>"
|
165
|
-
- !ruby/object:Gem::Version
|
166
|
-
version: '1.99'
|
167
|
-
type: :development
|
168
|
-
prerelease: false
|
169
|
-
version_requirements: !ruby/object:Gem::Requirement
|
170
|
-
requirements:
|
171
|
-
- - "~>"
|
172
|
-
- !ruby/object:Gem::Version
|
173
|
-
version: '1.99'
|
174
|
-
- !ruby/object:Gem::Dependency
|
175
|
-
name: json-ld
|
176
|
-
requirement: !ruby/object:Gem::Requirement
|
177
|
-
requirements:
|
178
|
-
- - "~>"
|
179
|
-
- !ruby/object:Gem::Version
|
180
|
-
version: '1.99'
|
181
|
-
type: :development
|
182
|
-
prerelease: false
|
183
|
-
version_requirements: !ruby/object:Gem::Requirement
|
184
|
-
requirements:
|
185
|
-
- - "~>"
|
186
|
-
- !ruby/object:Gem::Version
|
187
|
-
version: '1.99'
|
188
112
|
- !ruby/object:Gem::Dependency
|
189
113
|
name: guard-rspec
|
190
114
|
requirement: !ruby/object:Gem::Requirement
|
@@ -303,8 +227,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
303
227
|
version: '0'
|
304
228
|
requirements: []
|
305
229
|
rubyforge_project:
|
306
|
-
rubygems_version: 2.
|
230
|
+
rubygems_version: 2.2.2
|
307
231
|
signing_key:
|
308
232
|
specification_version: 4
|
309
233
|
summary: RDF graphs in ActiveModel wrappers.
|
310
234
|
test_files: []
|
235
|
+
has_rdoc:
|