ladder 0.1.1 → 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/.ruby-version +1 -1
- data/README.md +7 -6
- data/ladder.gemspec +3 -2
- data/lib/ladder/resource.rb +5 -7
- data/lib/ladder/resource/dynamic.rb +49 -43
- data/lib/ladder/version.rb +1 -1
- data/spec/ladder/dynamic_spec.rb +147 -1
- data/spec/shared/resource.rb +38 -40
- data/spec/spec_helper.rb +2 -0
- metadata +19 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: eae01f78a4a1a7f0b6a81fdae649c7b8afff280e
|
4
|
+
data.tar.gz: d5ea2050c1d1b9972b46c8edb5a0e37d1f9ec206
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1715db5f2296eaf36139f553fefdbb5a3d071c578c7fc3ef132cf61023a8641740b4fff28bce5dbf85486067ff5e2e25e71fd8821360bc03834b4791df3812ff
|
7
|
+
data.tar.gz: 7aaf433f31b7edf78f752f374830e6b4dac9c7f54707c1ffba731fda7b4a918783e64b5d5269a0b163a5ac72c7ec35be397fea0df8c73759e6d2ef492eb6653e
|
data/.ruby-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2.1.
|
1
|
+
2.1.5
|
data/README.md
CHANGED
@@ -1,5 +1,6 @@
|
|
1
|
-

|
2
|
+
|
3
|
+
[](https://rubygems.org/gems/ladder) [](https://travis-ci.org/ladder/ladder)
|
3
4
|
|
4
5
|
# Ladder
|
5
6
|
|
@@ -13,9 +14,9 @@ Ladder is a dynamic, scalable metadata framework written in Ruby using well-know
|
|
13
14
|
|
14
15
|
Ladder was loosely conceived over the course of several years prior to 2011. In early 2012, Ladder began existence as an opportunity to escape from a decade of LAMP development and become familiar with Ruby. From 2012 to late 2013, a closed prototype was built under the auspices of [Deliberate Data](http://deliberatedata.com) as a proof-of-concept to test the feasibility of the design.
|
15
16
|
|
16
|
-
From mid-2014, Ladder is being re-architected as a series of Ruby modules that can be used individually and incorporated within existing Ruby frameworks (eg. [Project Hydra](http://projecthydra.org)), or used together as a comprehensive stack. Ladder is intended to encourage the LAM community to think less dogmatically about our established (often monolithic and/or niche) toolsets and instead embrace a broader vision of
|
17
|
+
From mid-2014, Ladder is being re-architected as a series of Ruby modules that can be used individually and incorporated within existing Ruby frameworks (eg. [Project Hydra](http://projecthydra.org)), or used together as a comprehensive stack. Ladder is intended to encourage the [LAM](http://en.wikipedia.org/wiki/GLAM_(industry_sector)) community to think less dogmatically about our established (often monolithic and/or niche) toolsets and instead embrace a broader vision of adopting more widely-used technologies.
|
17
18
|
|
18
|
-
For those interested in the historical code, the original [prototype](https://github.com/
|
19
|
+
For those interested in the historical code, the original [prototype](https://github.com/ladder/ladder/tree/prototype) branch is available, as is an [experimental](https://github.com/ladder/ladder/tree/l2) branch.
|
19
20
|
|
20
21
|
## Installation
|
21
22
|
|
@@ -581,7 +582,7 @@ es.as_indexed_json
|
|
581
582
|
|
582
583
|
Anyone and everyone is welcome to contribute. Go crazy.
|
583
584
|
|
584
|
-
1. Fork it ( https://github.com/
|
585
|
+
1. Fork it ( https://github.com/ladder/ladder/fork )
|
585
586
|
2. Create your feature branch (`git checkout -b my-new-feature`)
|
586
587
|
3. Commit your changes (`git commit -am 'Add some feature'`)
|
587
588
|
4. Push to the branch (`git push origin my-new-feature`)
|
@@ -598,4 +599,4 @@ Many thanks to Christopher Knight [@NomadicKnight](https://twitter.com/Nomadic_K
|
|
598
599
|
## License
|
599
600
|
|
600
601
|
Apache License Version 2.0
|
601
|
-
http://apache.org/licenses/LICENSE-2.0.txt
|
602
|
+
http://apache.org/licenses/LICENSE-2.0.txt
|
data/ladder.gemspec
CHANGED
@@ -11,7 +11,7 @@ Gem::Specification.new do |spec|
|
|
11
11
|
spec.email = "mj@suhonos.ca"
|
12
12
|
spec.summary = %q{Opinionated ActiveModel framework.}
|
13
13
|
spec.description = %q{Ladder is a metadata framework for RDF modelling, persistence, and full-text indexing.}
|
14
|
-
spec.homepage = "https://github.com/
|
14
|
+
spec.homepage = "https://github.com/ladder/ladder"
|
15
15
|
spec.license = "APACHE2"
|
16
16
|
spec.required_ruby_version = '>= 1.9.3'
|
17
17
|
|
@@ -21,7 +21,7 @@ Gem::Specification.new do |spec|
|
|
21
21
|
spec.require_paths = ["lib"]
|
22
22
|
|
23
23
|
spec.add_dependency "mongoid", "~> 4.0"
|
24
|
-
spec.add_dependency "active-triples", "~> 0.
|
24
|
+
spec.add_dependency "active-triples", "~> 0.4"
|
25
25
|
spec.add_dependency "elasticsearch-model", "~> 0.1"
|
26
26
|
|
27
27
|
spec.add_development_dependency "bundler", "~> 1.7"
|
@@ -30,4 +30,5 @@ Gem::Specification.new do |spec|
|
|
30
30
|
spec.add_development_dependency "rspec", "~> 3.1"
|
31
31
|
spec.add_development_dependency "rake", "~> 10.3"
|
32
32
|
spec.add_development_dependency "yard", "~> 0.8"
|
33
|
+
spec.add_development_dependency "simplecov", "~> 0.9"
|
33
34
|
end
|
data/lib/ladder/resource.rb
CHANGED
@@ -32,16 +32,14 @@ module Ladder::Resource
|
|
32
32
|
end
|
33
33
|
|
34
34
|
##
|
35
|
-
#
|
36
|
-
#
|
37
|
-
# @see ActiveTriples::Identifiable
|
35
|
+
# Populate resource properties from ActiveModel
|
38
36
|
def update_resource(opts = {})
|
39
|
-
|
40
|
-
value = update_from_field(name) if fields[name]
|
41
|
-
value = update_from_relation(name, opts) if relations[name]
|
37
|
+
resource_class.properties.each do |name, property|
|
38
|
+
value = update_from_field(name) if fields[name]
|
39
|
+
value = update_from_relation(name, opts) if relations[name]
|
42
40
|
|
43
41
|
cast_uri = RDF::URI.new(value)
|
44
|
-
resource.set_value(
|
42
|
+
resource.set_value(property.predicate, cast_uri.valid? ? cast_uri : value) if value
|
45
43
|
end
|
46
44
|
|
47
45
|
resource
|
@@ -26,49 +26,6 @@ module Ladder::Resource::Dynamic
|
|
26
26
|
|
27
27
|
resource
|
28
28
|
end
|
29
|
-
|
30
|
-
def <<(data)
|
31
|
-
# ActiveTriples::Resource expects: RDF::Statement, Hash, or Array
|
32
|
-
data = RDF::Statement.from(data) unless data.is_a? RDF::Statement
|
33
|
-
|
34
|
-
# Define predicate on object unless it's defined on the class
|
35
|
-
if resource_class.properties.values.map(&:predicate).include? data.predicate
|
36
|
-
field_name = resource_class.properties.select { |name, term| term.predicate == data.predicate }.keys.first.to_sym
|
37
|
-
else
|
38
|
-
qname = data.predicate.qname
|
39
|
-
|
40
|
-
if respond_to? qname.last or :name == qname.last
|
41
|
-
field_name = qname.join('_').to_sym
|
42
|
-
else
|
43
|
-
field_name = qname.last
|
44
|
-
end
|
45
|
-
|
46
|
-
property field_name, predicate: data.predicate
|
47
|
-
end
|
48
|
-
|
49
|
-
# Set the value in Mongoid
|
50
|
-
value = case data.object
|
51
|
-
when RDF::Literal
|
52
|
-
data.object.object
|
53
|
-
when RDF::URI
|
54
|
-
data.object.to_s
|
55
|
-
else
|
56
|
-
data.object
|
57
|
-
end
|
58
|
-
|
59
|
-
self.send("#{field_name}=", value)
|
60
|
-
end
|
61
|
-
|
62
|
-
private
|
63
|
-
|
64
|
-
##
|
65
|
-
# Overload ActiveTriples #resource_class
|
66
|
-
#
|
67
|
-
# @see ActiveTriples::Identifiable
|
68
|
-
def resource_class
|
69
|
-
@modified_resource_class ||= self.class.resource_class.clone
|
70
|
-
end
|
71
|
-
|
72
29
|
end
|
73
30
|
|
74
31
|
##
|
@@ -76,11 +33,45 @@ module Ladder::Resource::Dynamic
|
|
76
33
|
def property(field_name, *opts)
|
77
34
|
# Store context information
|
78
35
|
self._context ||= Hash.new(nil)
|
36
|
+
|
37
|
+
# Ensure new field name is unique
|
38
|
+
field_name = opts.first[:predicate].qname.join('_').to_sym if respond_to? field_name or :name == field_name
|
39
|
+
|
79
40
|
self._context[field_name] = opts.first[:predicate].to_s
|
80
41
|
|
81
42
|
apply_context
|
82
43
|
end
|
83
44
|
|
45
|
+
def <<(data)
|
46
|
+
# ActiveTriples::Resource expects: RDF::Statement, Hash, or Array
|
47
|
+
data = RDF::Statement.from(data) unless data.is_a? RDF::Statement
|
48
|
+
|
49
|
+
# Define predicate on object unless it's defined on the class
|
50
|
+
if resource_class.properties.values.map(&:predicate).include? data.predicate
|
51
|
+
field_name = resource_class.properties.select { |name, term| term.predicate == data.predicate }.keys.first.to_sym
|
52
|
+
else
|
53
|
+
qname = data.predicate.qname
|
54
|
+
|
55
|
+
if respond_to? qname.last or :name == qname.last
|
56
|
+
field_name = qname.join('_').to_sym
|
57
|
+
else
|
58
|
+
field_name = qname.last
|
59
|
+
end
|
60
|
+
|
61
|
+
property field_name, predicate: data.predicate
|
62
|
+
end
|
63
|
+
|
64
|
+
# Set the value in Mongoid
|
65
|
+
value = case data.object
|
66
|
+
when RDF::Literal
|
67
|
+
data.object.object
|
68
|
+
else
|
69
|
+
data.object.to_s
|
70
|
+
end
|
71
|
+
|
72
|
+
self.send("#{field_name}=", value)
|
73
|
+
end
|
74
|
+
|
84
75
|
private
|
85
76
|
|
86
77
|
##
|
@@ -112,4 +103,19 @@ module Ladder::Resource::Dynamic
|
|
112
103
|
end
|
113
104
|
end
|
114
105
|
|
106
|
+
public
|
107
|
+
|
108
|
+
module ClassMethods
|
109
|
+
|
110
|
+
private
|
111
|
+
|
112
|
+
##
|
113
|
+
# Overload ActiveTriples #resource_class
|
114
|
+
#
|
115
|
+
# @see ActiveTriples::Identifiable
|
116
|
+
def resource_class
|
117
|
+
@modified_resource_class ||= self.class.resource_class.clone
|
118
|
+
end
|
119
|
+
end
|
120
|
+
|
115
121
|
end
|
data/lib/ladder/version.rb
CHANGED
data/spec/ladder/dynamic_spec.rb
CHANGED
@@ -18,8 +18,154 @@ describe Ladder::Resource::Dynamic do
|
|
18
18
|
end
|
19
19
|
|
20
20
|
it_behaves_like 'a Resource'
|
21
|
+
|
22
|
+
shared_context 'with data' do
|
23
|
+
let(:subject) { Thing.new }
|
24
|
+
|
25
|
+
before do
|
26
|
+
# non-localized literal
|
27
|
+
subject.class.field :alt
|
28
|
+
subject.class.property :alt, :predicate => RDF::DC.alternative
|
29
|
+
subject.alt = 'Mumintrollet pa kometjakt'
|
30
|
+
|
31
|
+
# localized literal
|
32
|
+
subject.class.property :title, :predicate => RDF::DC.title
|
33
|
+
subject.title = 'Comet in Moominland'
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
describe '#property' do
|
38
|
+
include_context 'with data'
|
39
|
+
|
40
|
+
context 'with undefined property' do
|
41
|
+
before do
|
42
|
+
subject.property :description, :predicate => RDF::DC.description
|
43
|
+
subject.description = "Second in Tove Jansson's series of Moomin books"
|
44
|
+
end
|
45
|
+
|
46
|
+
it 'should create a context' do
|
47
|
+
expect(subject._context).to eq({:description => RDF::DC.description.to_uri.to_s})
|
48
|
+
end
|
49
|
+
|
50
|
+
it 'should build an accessor' do
|
51
|
+
expect(subject.description).to eq "Second in Tove Jansson's series of Moomin books"
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
context 'with conflicting property' do
|
56
|
+
before do
|
57
|
+
subject.property :title, :predicate => RDF::DC11.title
|
58
|
+
subject.dc11_title = "Kometjakten"
|
59
|
+
end
|
60
|
+
|
61
|
+
it 'should create a context' do
|
62
|
+
expect(subject._context).to eq({:dc11_title => RDF::DC11.title.to_uri.to_s})
|
63
|
+
end
|
64
|
+
|
65
|
+
it 'should build an accessor' do
|
66
|
+
expect(subject.dc11_title).to eq "Kometjakten"
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
describe '#<<' do
|
72
|
+
include_context 'with data'
|
73
|
+
|
74
|
+
context 'with defined field' do
|
75
|
+
before do
|
76
|
+
subject << RDF::Statement(nil, RDF::DC.title, 'Kometen kommer')
|
77
|
+
end
|
78
|
+
|
79
|
+
it 'should not create a context' do
|
80
|
+
expect(subject._context).to be nil
|
81
|
+
end
|
82
|
+
|
83
|
+
it 'should update existing values' do
|
84
|
+
expect(subject.title).to eq 'Kometen kommer'
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
context 'with undefined field' do
|
89
|
+
before do
|
90
|
+
subject << RDF::Statement(nil, RDF::DC.description, "Second in Tove Jansson's series of Moomin books")
|
91
|
+
end
|
92
|
+
|
93
|
+
it 'should create a context' do
|
94
|
+
expect(subject._context).to eq({:description => RDF::DC.description.to_uri.to_s})
|
95
|
+
end
|
96
|
+
|
97
|
+
it 'should build an accessor' do
|
98
|
+
expect(subject.description).to eq "Second in Tove Jansson's series of Moomin books"
|
99
|
+
end
|
100
|
+
end
|
101
|
+
|
102
|
+
context 'with conflicting field' do
|
103
|
+
before do
|
104
|
+
subject << RDF::Statement(nil, RDF::DC11.title, "Kometjakten")
|
105
|
+
end
|
106
|
+
|
107
|
+
it 'should create a context' do
|
108
|
+
expect(subject._context).to eq({:dc11_title => RDF::DC11.title.to_uri.to_s})
|
109
|
+
end
|
110
|
+
|
111
|
+
it 'should build an accessor' do
|
112
|
+
expect(subject.dc11_title).to eq "Kometjakten"
|
113
|
+
end
|
114
|
+
end
|
115
|
+
|
116
|
+
|
117
|
+
context 'with a URI value' do
|
118
|
+
before do
|
119
|
+
subject << RDF::Statement(nil, RDF::DC.identifier, RDF::URI('http://some.uri'))
|
120
|
+
subject.update_resource
|
121
|
+
end
|
122
|
+
|
123
|
+
it 'should store the URI as a string' do
|
124
|
+
expect(subject.identifier).to eq 'http://some.uri'
|
125
|
+
end
|
126
|
+
|
127
|
+
it 'should cast a URI into the resource' do
|
128
|
+
query = subject.resource.query(:subject => subject.rdf_subject, :predicate => RDF::DC.identifier)
|
129
|
+
expect(query.count).to eq 1
|
130
|
+
expect(query.first_object).to be_a_kind_of RDF::URI
|
131
|
+
end
|
132
|
+
end
|
133
|
+
|
134
|
+
end
|
21
135
|
|
22
|
-
#
|
136
|
+
describe '#update_resource' do
|
137
|
+
include_context 'with data'
|
138
|
+
|
139
|
+
before do
|
140
|
+
# undefined property
|
141
|
+
subject.property :description, :predicate => RDF::DC.description
|
142
|
+
subject.description = "Second in Tove Jansson's series of Moomin books"
|
143
|
+
|
144
|
+
# conflicting property
|
145
|
+
subject.property :title, :predicate => RDF::DC11.title
|
146
|
+
subject.dc11_title = "Kometjakten"
|
147
|
+
|
148
|
+
# defined field
|
149
|
+
subject << RDF::Statement(nil, RDF::DC.title, 'Kometen kommer')
|
150
|
+
|
151
|
+
# conflicting field
|
152
|
+
subject << RDF::Statement(nil, RDF::DC.alternative, "Kometjakten")
|
153
|
+
|
154
|
+
# URI value
|
155
|
+
subject << RDF::Statement(nil, RDF::DC.identifier, RDF::URI('http://some.uri'))
|
156
|
+
|
157
|
+
subject.update_resource
|
158
|
+
end
|
159
|
+
|
160
|
+
it 'should have updated values' do
|
161
|
+
expect(subject.resource.statements.count).to eq 5
|
162
|
+
expect(subject.resource.query(:predicate => RDF::DC.description, :object => "Second in Tove Jansson's series of Moomin books").count).to eq 1
|
163
|
+
expect(subject.resource.query(:predicate => RDF::DC11.title, :object => "Kometjakten").count).to eq 1
|
164
|
+
expect(subject.resource.query(:predicate => RDF::DC.title, :object => RDF::Literal.new('Kometen kommer', :language => :en)).count).to eq 1
|
165
|
+
expect(subject.resource.query(:predicate => RDF::DC.alternative, :object => "Kometjakten").count).to eq 1
|
166
|
+
expect(subject.resource.query(:predicate => RDF::DC.identifier, :object => RDF::URI('http://some.uri')).count).to eq 1
|
167
|
+
end
|
168
|
+
end
|
23
169
|
|
24
170
|
after do
|
25
171
|
Object.send(:remove_const, :LADDER_BASE_URI) if Object
|
data/spec/shared/resource.rb
CHANGED
@@ -3,8 +3,23 @@ shared_examples 'a Resource' do
|
|
3
3
|
let(:person) { Person.new }
|
4
4
|
|
5
5
|
shared_context 'with data' do
|
6
|
+
before do
|
7
|
+
# non-localized literal
|
8
|
+
subject.class.field :alt
|
9
|
+
subject.class.property :alt, :predicate => RDF::DC.alternative
|
10
|
+
subject.alt = 'Mumintrollet pa kometjakt'
|
11
|
+
|
12
|
+
# localized literal
|
13
|
+
subject.class.property :title, :predicate => RDF::DC.title
|
14
|
+
subject.title = 'Comet in Moominland'
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
shared_context 'with relations' do
|
6
19
|
let(:concept) { Concept.new }
|
7
20
|
let(:part) { Part.new }
|
21
|
+
|
22
|
+
include_context 'with data'
|
8
23
|
|
9
24
|
before do
|
10
25
|
class Concept
|
@@ -15,15 +30,6 @@ shared_examples 'a Resource' do
|
|
15
30
|
include Ladder::Resource
|
16
31
|
end
|
17
32
|
|
18
|
-
# non-localized literal
|
19
|
-
subject.class.field :alt
|
20
|
-
subject.class.property :alt, :predicate => RDF::DC.alternative
|
21
|
-
subject.alt = 'Mumintrollet pa kometjakt'
|
22
|
-
|
23
|
-
# localized literal
|
24
|
-
subject.class.property :title, :predicate => RDF::DC.title
|
25
|
-
subject.title = 'Comet in Moominland'
|
26
|
-
|
27
33
|
# many-to-many
|
28
34
|
person.class.property :things, :predicate => RDF::DC.relation, :class_name => 'Thing'
|
29
35
|
subject.class.property :people, :predicate => RDF::DC.creator, :class_name => 'Person'
|
@@ -70,11 +76,7 @@ shared_examples 'a Resource' do
|
|
70
76
|
|
71
77
|
describe '#property' do
|
72
78
|
context 'with non-localized literal' do
|
73
|
-
|
74
|
-
subject.class.field :alt
|
75
|
-
subject.class.property :alt, :predicate => RDF::DC.alternative
|
76
|
-
subject.alt = 'Mumintrollet pa kometjakt'
|
77
|
-
end
|
79
|
+
include_context 'with data'
|
78
80
|
|
79
81
|
it 'should return non-localized value' do
|
80
82
|
expect(subject.alt).to eq 'Mumintrollet pa kometjakt'
|
@@ -95,10 +97,7 @@ shared_examples 'a Resource' do
|
|
95
97
|
end
|
96
98
|
|
97
99
|
context 'with localized literal' do
|
98
|
-
|
99
|
-
subject.class.property :title, :predicate => RDF::DC.title
|
100
|
-
subject.title = 'Comet in Moominland'
|
101
|
-
end
|
100
|
+
include_context 'with data'
|
102
101
|
|
103
102
|
it 'should return localized value' do
|
104
103
|
expect(subject.title).to eq 'Comet in Moominland'
|
@@ -119,12 +118,7 @@ shared_examples 'a Resource' do
|
|
119
118
|
end
|
120
119
|
|
121
120
|
context 'with many-to-many' do
|
122
|
-
|
123
|
-
subject.class.property :people, :predicate => RDF::DC.creator, :class_name => 'Person'
|
124
|
-
person.class.property :things, :predicate => RDF::DC.relation, :class_name => 'Thing'
|
125
|
-
subject.people << person
|
126
|
-
subject.save
|
127
|
-
end
|
121
|
+
include_context 'with relations'
|
128
122
|
|
129
123
|
it 'should have a relation' do
|
130
124
|
expect(subject.relations['people'].relation).to eq (Mongoid::Relations::Referenced::ManyToMany)
|
@@ -146,28 +140,24 @@ shared_examples 'a Resource' do
|
|
146
140
|
end
|
147
141
|
|
148
142
|
context 'with one-sided has-many' do
|
149
|
-
|
150
|
-
subject.class.has_and_belongs_to_many :people, inverse_of: nil
|
151
|
-
subject.class.property :people, :predicate => RDF::DC.creator, :class_name => 'Person'
|
152
|
-
subject.people << person
|
153
|
-
end
|
143
|
+
include_context 'with relations'
|
154
144
|
|
155
145
|
it 'should have a relation' do
|
156
|
-
expect(subject.relations['
|
157
|
-
expect(subject.
|
146
|
+
expect(subject.relations['concepts'].relation).to eq (Mongoid::Relations::Referenced::ManyToMany)
|
147
|
+
expect(subject.concepts.to_a).to include concept
|
158
148
|
end
|
159
149
|
|
160
150
|
it 'should not have an inverse relation' do
|
161
|
-
expect(subject.relations['
|
162
|
-
expect(
|
151
|
+
expect(subject.relations['concepts'].inverse_of).to be nil
|
152
|
+
expect(concept.relations).to be_empty
|
163
153
|
end
|
164
154
|
|
165
155
|
it 'should have a valid predicate' do
|
166
|
-
expect(subject.class.properties['
|
156
|
+
expect(subject.class.properties['concepts'].predicate).to eq RDF::DC.subject
|
167
157
|
end
|
168
158
|
|
169
159
|
it 'should not have an inverse predicate' do
|
170
|
-
expect(
|
160
|
+
expect(concept.class.properties).to be_empty
|
171
161
|
end
|
172
162
|
end
|
173
163
|
|
@@ -203,9 +193,8 @@ shared_examples 'a Resource' do
|
|
203
193
|
end
|
204
194
|
|
205
195
|
describe '#update_resource' do
|
206
|
-
|
207
196
|
context 'without related: true' do
|
208
|
-
include_context 'with
|
197
|
+
include_context 'with relations'
|
209
198
|
|
210
199
|
before do
|
211
200
|
subject.update_resource
|
@@ -248,7 +237,7 @@ shared_examples 'a Resource' do
|
|
248
237
|
end
|
249
238
|
|
250
239
|
context 'with related: true' do
|
251
|
-
include_context 'with
|
240
|
+
include_context 'with relations'
|
252
241
|
|
253
242
|
before do
|
254
243
|
subject.update_resource(:related => true)
|
@@ -314,7 +303,7 @@ shared_examples 'a Resource' do
|
|
314
303
|
end
|
315
304
|
|
316
305
|
context 'with related and then without related' do
|
317
|
-
include_context 'with
|
306
|
+
include_context 'with relations'
|
318
307
|
|
319
308
|
before do
|
320
309
|
subject.update_resource(:related => true)
|
@@ -344,11 +333,20 @@ shared_examples 'a Resource' do
|
|
344
333
|
end
|
345
334
|
|
346
335
|
describe '#as_jsonld' do
|
347
|
-
include_context 'with
|
336
|
+
include_context 'with relations'
|
348
337
|
|
349
338
|
it 'should output a valid jsonld representation of itself' do
|
350
339
|
g = RDF::Graph.new << JSON::LD::API.toRdf(subject.as_jsonld)
|
351
340
|
expect(subject.resource.to_hash == g.to_hash).to be true
|
352
341
|
end
|
353
342
|
end
|
343
|
+
|
344
|
+
describe '#rdf_label' do
|
345
|
+
include_context 'with data'
|
346
|
+
|
347
|
+
it 'should return the default label' do
|
348
|
+
expect(subject.rdf_label.to_a).to eq ['Comet in Moominland']
|
349
|
+
end
|
350
|
+
end
|
351
|
+
|
354
352
|
end
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ladder
|
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
|
- MJ Suhonos
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-11-
|
11
|
+
date: 2014-11-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: mongoid
|
@@ -30,14 +30,14 @@ dependencies:
|
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: '0.
|
33
|
+
version: '0.4'
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: '0.
|
40
|
+
version: '0.4'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: elasticsearch-model
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -136,6 +136,20 @@ dependencies:
|
|
136
136
|
- - "~>"
|
137
137
|
- !ruby/object:Gem::Version
|
138
138
|
version: '0.8'
|
139
|
+
- !ruby/object:Gem::Dependency
|
140
|
+
name: simplecov
|
141
|
+
requirement: !ruby/object:Gem::Requirement
|
142
|
+
requirements:
|
143
|
+
- - "~>"
|
144
|
+
- !ruby/object:Gem::Version
|
145
|
+
version: '0.9'
|
146
|
+
type: :development
|
147
|
+
prerelease: false
|
148
|
+
version_requirements: !ruby/object:Gem::Requirement
|
149
|
+
requirements:
|
150
|
+
- - "~>"
|
151
|
+
- !ruby/object:Gem::Version
|
152
|
+
version: '0.9'
|
139
153
|
description: Ladder is a metadata framework for RDF modelling, persistence, and full-text
|
140
154
|
indexing.
|
141
155
|
email: mj@suhonos.ca
|
@@ -165,7 +179,7 @@ files:
|
|
165
179
|
- spec/shared/resource.rb
|
166
180
|
- spec/shared/searchable.rb
|
167
181
|
- spec/spec_helper.rb
|
168
|
-
homepage: https://github.com/
|
182
|
+
homepage: https://github.com/ladder/ladder
|
169
183
|
licenses:
|
170
184
|
- APACHE2
|
171
185
|
metadata: {}
|