linked_vocabs 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +18 -0
- data/Gemfile +6 -0
- data/LICENSE.txt +191 -0
- data/README.md +27 -0
- data/Rakefile +17 -0
- data/lib/linked_vocabs.rb +75 -0
- data/lib/linked_vocabs/controlled.rb +199 -0
- data/lib/linked_vocabs/deep_fetch.rb +53 -0
- data/lib/linked_vocabs/validators.rb +7 -0
- data/lib/linked_vocabs/validators/authority_validator.rb +11 -0
- data/lib/linked_vocabs/validators/property_validator.rb +21 -0
- data/lib/linked_vocabs/version.rb +3 -0
- data/lib/linked_vocabs/vocabularies.rb +6 -0
- data/lib/rdf/dcmitype.rb +138 -0
- data/lib/rdf/geonames.rb +8 -0
- data/lib/rdf/lcsh.rb +8 -0
- data/linked_vocabs.gemspec +31 -0
- data/spec/controlled_spec.rb +170 -0
- data/spec/linked_vocabs_spec.rb +38 -0
- data/spec/property_validator_spec.rb +74 -0
- data/spec/spec_helper.rb +7 -0
- metadata +196 -0
@@ -0,0 +1,38 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe LinkedVocabs do
|
4
|
+
describe '#vocabularies' do
|
5
|
+
it 'should have be a hash' do
|
6
|
+
expect(LinkedVocabs.vocabularies).to be_a Hash
|
7
|
+
end
|
8
|
+
|
9
|
+
it 'should have prefixes' do
|
10
|
+
LinkedVocabs.vocabularies.each_pair do |vocab, config|
|
11
|
+
expect(config).to have_key :prefix
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
describe '#add_vocabulary' do
|
17
|
+
before do
|
18
|
+
LinkedVocabs.add_vocabulary('aat', 'http://vocab.getty.edu/aat/', :strict => false, :fetch => false)
|
19
|
+
end
|
20
|
+
|
21
|
+
it 'should register a vocabulary' do
|
22
|
+
expect(LinkedVocabs.vocabularies).to have_key :aat
|
23
|
+
end
|
24
|
+
|
25
|
+
context 'with no source url given' do
|
26
|
+
before do
|
27
|
+
LinkedVocabs.add_vocabulary('lcsh', 'http://id.loc.gov/authorities/subjects/')
|
28
|
+
end
|
29
|
+
|
30
|
+
it 'should set strict to false ' do
|
31
|
+
expect(LinkedVocabs.vocabularies[:lcsh][:strict]).to eq false
|
32
|
+
end
|
33
|
+
it 'should set fetch to false ' do
|
34
|
+
expect(LinkedVocabs.vocabularies[:lcsh][:fetch]).to eq false
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
@@ -0,0 +1,74 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe LinkedVocabs::Validators::PropertyValidator do
|
4
|
+
before do
|
5
|
+
class DummyAuthority < ActiveTriples::Resource
|
6
|
+
include LinkedVocabs::Controlled
|
7
|
+
use_vocabulary :dcmitype
|
8
|
+
|
9
|
+
property :type, :predicate => RDF::DC.type, :class_name => DummyAuthority
|
10
|
+
end
|
11
|
+
|
12
|
+
class DummyResource < ActiveTriples::Resource
|
13
|
+
validates_vocabulary_of :type
|
14
|
+
|
15
|
+
property :type, :predicate => RDF::DC.type, :class_name => DummyAuthority
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
after do
|
20
|
+
Object.send(:remove_const, 'DummyAuthority') if Object
|
21
|
+
Object.send(:remove_const, 'DummyResource') if Object
|
22
|
+
end
|
23
|
+
|
24
|
+
subject { DummyResource.new }
|
25
|
+
let(:authority) { DummyAuthority }
|
26
|
+
|
27
|
+
context 'with value in vocabulary' do
|
28
|
+
before do
|
29
|
+
subject.type = authority.list_terms.first
|
30
|
+
end
|
31
|
+
it 'is valid' do
|
32
|
+
expect(subject).to be_valid
|
33
|
+
end
|
34
|
+
|
35
|
+
it 'is invalid with other invalid values' do
|
36
|
+
subject.type << 'freetext value'
|
37
|
+
expect(subject).not_to be_valid
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
context 'with value out of vocabulary' do
|
42
|
+
before do
|
43
|
+
subject.type = authority.new
|
44
|
+
end
|
45
|
+
it 'is invalid' do
|
46
|
+
expect(subject).not_to be_valid
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
context 'with value of wrong class' do
|
51
|
+
before do
|
52
|
+
class NotAuthority < ActiveTriples::Resource; end
|
53
|
+
subject.type = NotAuthority.new
|
54
|
+
end
|
55
|
+
|
56
|
+
after do
|
57
|
+
Object.send(:remove_const, 'NotAuthority') if Object
|
58
|
+
end
|
59
|
+
|
60
|
+
it 'is invalid' do
|
61
|
+
expect(subject).not_to be_valid
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
context 'with literal value' do
|
66
|
+
before do
|
67
|
+
subject.type = 'freetext value'
|
68
|
+
end
|
69
|
+
it 'is invalid' do
|
70
|
+
expect(subject).not_to be_valid
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
end
|
data/spec/spec_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,196 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: linked_vocabs
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Tom Johnson
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-10-15 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rspec
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: guard
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: guard-rspec
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rake
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :runtime
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: active-triples
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: 0.1.0
|
90
|
+
type: :runtime
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: 0.1.0
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: rdf
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ">="
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: 1.1.2.1
|
104
|
+
type: :runtime
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ">="
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: 1.1.2.1
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: sparql
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - ">="
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0'
|
118
|
+
type: :runtime
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - ">="
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '0'
|
125
|
+
- !ruby/object:Gem::Dependency
|
126
|
+
name: sparql-client
|
127
|
+
requirement: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - ">="
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: '0'
|
132
|
+
type: :runtime
|
133
|
+
prerelease: false
|
134
|
+
version_requirements: !ruby/object:Gem::Requirement
|
135
|
+
requirements:
|
136
|
+
- - ">="
|
137
|
+
- !ruby/object:Gem::Version
|
138
|
+
version: '0'
|
139
|
+
description: Linked Data Controlled Vocabularies for ActiveFedora::Rdf.
|
140
|
+
email:
|
141
|
+
- johnson.tom@gmail.com
|
142
|
+
executables: []
|
143
|
+
extensions: []
|
144
|
+
extra_rdoc_files: []
|
145
|
+
files:
|
146
|
+
- ".gitignore"
|
147
|
+
- Gemfile
|
148
|
+
- LICENSE.txt
|
149
|
+
- README.md
|
150
|
+
- Rakefile
|
151
|
+
- lib/linked_vocabs.rb
|
152
|
+
- lib/linked_vocabs/controlled.rb
|
153
|
+
- lib/linked_vocabs/deep_fetch.rb
|
154
|
+
- lib/linked_vocabs/validators.rb
|
155
|
+
- lib/linked_vocabs/validators/authority_validator.rb
|
156
|
+
- lib/linked_vocabs/validators/property_validator.rb
|
157
|
+
- lib/linked_vocabs/version.rb
|
158
|
+
- lib/linked_vocabs/vocabularies.rb
|
159
|
+
- lib/rdf/dcmitype.rb
|
160
|
+
- lib/rdf/geonames.rb
|
161
|
+
- lib/rdf/lcsh.rb
|
162
|
+
- linked_vocabs.gemspec
|
163
|
+
- spec/controlled_spec.rb
|
164
|
+
- spec/linked_vocabs_spec.rb
|
165
|
+
- spec/property_validator_spec.rb
|
166
|
+
- spec/spec_helper.rb
|
167
|
+
homepage:
|
168
|
+
licenses:
|
169
|
+
- APACHE2
|
170
|
+
metadata: {}
|
171
|
+
post_install_message:
|
172
|
+
rdoc_options: []
|
173
|
+
require_paths:
|
174
|
+
- lib
|
175
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
176
|
+
requirements:
|
177
|
+
- - ">="
|
178
|
+
- !ruby/object:Gem::Version
|
179
|
+
version: '0'
|
180
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
181
|
+
requirements:
|
182
|
+
- - ">="
|
183
|
+
- !ruby/object:Gem::Version
|
184
|
+
version: '0'
|
185
|
+
requirements: []
|
186
|
+
rubyforge_project:
|
187
|
+
rubygems_version: 2.2.1
|
188
|
+
signing_key:
|
189
|
+
specification_version: 4
|
190
|
+
summary: Linked Data Controlled Vocabularies for ActiveFedora::Rdf.
|
191
|
+
test_files:
|
192
|
+
- spec/controlled_spec.rb
|
193
|
+
- spec/linked_vocabs_spec.rb
|
194
|
+
- spec/property_validator_spec.rb
|
195
|
+
- spec/spec_helper.rb
|
196
|
+
has_rdoc:
|