spira 1.1.1 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +5 -5
- data/VERSION +1 -1
- data/lib/spira/base.rb +2 -1
- data/lib/spira/persistence.rb +1 -1
- data/lib/spira/resource.rb +3 -3
- data/lib/spira/type.rb +2 -2
- data/lib/spira/utils.rb +27 -19
- metadata +46 -24
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: dbed11be22b47543853764d62b1930a8b113c67f
|
4
|
+
data.tar.gz: 2090996379c9642b5d52b5ec820ea380e87a5641
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b8c274d445a9d0c7ab289521653e2906b7e7ed390ea981e93114bcb8f0324841627b6f5f670c92fff9d077d1a53776082b5d3c04d2e8c32fb539a5c9bb47eb69
|
7
|
+
data.tar.gz: 8aa1a2b9e3b452f2dfa17e9238839b2ba6a6e7be497ba8aae000244bc735edc42a092cb4539ffcd00d5d5a87cdcf68d6f29f8441a3ecffbe0d7d83bd2e4ac8f7
|
data/README.md
CHANGED
@@ -24,8 +24,8 @@ class Person < Spira::Base
|
|
24
24
|
|
25
25
|
configure :base_uri => "http://example.org/example/people"
|
26
26
|
|
27
|
-
property :name, :predicate => FOAF.name, :type => String
|
28
|
-
property :age, :predicate => FOAF.age, :type => Integer
|
27
|
+
property :name, :predicate => RDF::Vocab::FOAF.name, :type => String
|
28
|
+
property :age, :predicate => RDF::Vocab::FOAF.age, :type => Integer
|
29
29
|
|
30
30
|
end
|
31
31
|
|
@@ -113,13 +113,13 @@ require 'spira'
|
|
113
113
|
|
114
114
|
class CD < Spira::Base
|
115
115
|
configure :base_uri => 'http://example.org/cds'
|
116
|
-
property :name, :predicate => DC.title, :type => XSD.string
|
116
|
+
property :name, :predicate => RDF::Vocab::DC.title, :type => XSD.string
|
117
117
|
property :artist, :predicate => URI.new('http://example.org/vocab/artist'), :type => :artist
|
118
118
|
end
|
119
119
|
|
120
120
|
class Artist < Spira::Base
|
121
121
|
configure :base_uri => 'http://example.org/artists'
|
122
|
-
property :name, :predicate => DC.title, :type => XSD.string
|
122
|
+
property :name, :predicate => RDF::Vocab::DC.title, :type => XSD.string
|
123
123
|
has_many :cds, :predicate => URI.new('http://example.org/vocab/published_cd'), :type => XSD.string
|
124
124
|
end
|
125
125
|
```
|
@@ -212,7 +212,7 @@ A class with a `type` set is assigned an `RDF.type` on creation and saving.
|
|
212
212
|
```ruby
|
213
213
|
class Album < Spira::Base
|
214
214
|
type URI.new('http://example.org/types/album')
|
215
|
-
property :name, :predicate => DC.title
|
215
|
+
property :name, :predicate => RDF::Vocab::DC.title
|
216
216
|
end
|
217
217
|
|
218
218
|
Spira.repository = RDF::Repository.new
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
2.0.0
|
data/lib/spira/base.rb
CHANGED
@@ -20,8 +20,9 @@ module Spira
|
|
20
20
|
extend ActiveModel::Naming
|
21
21
|
include ActiveModel::Conversion
|
22
22
|
include ActiveModel::Dirty
|
23
|
+
include ActiveModel::Serialization
|
23
24
|
|
24
|
-
include ::RDF, ::RDF::Enumerable, ::RDF::Queryable
|
25
|
+
include ::RDF, ::RDF::Enumerable, ::RDF::Queryable, Utils
|
25
26
|
|
26
27
|
define_model_callbacks :save, :destroy, :create, :update
|
27
28
|
|
data/lib/spira/persistence.rb
CHANGED
@@ -460,7 +460,7 @@ module Spira
|
|
460
460
|
# Destroy all model data
|
461
461
|
# AND non-model data, where this resource is referred to as object.
|
462
462
|
def destroy_model_data(*args)
|
463
|
-
if self.class.repository.delete(
|
463
|
+
if self.class.repository.delete(statements) && self.class.repository.delete([nil, nil, subject])
|
464
464
|
@destroyed = true
|
465
465
|
freeze
|
466
466
|
end
|
data/lib/spira/resource.rb
CHANGED
@@ -61,11 +61,11 @@ module Spira
|
|
61
61
|
# represents an RDF predicate.
|
62
62
|
#
|
63
63
|
# @example A simple string property
|
64
|
-
# property :name, :predicate => FOAF.name, :type => String
|
64
|
+
# property :name, :predicate => RDF::Vocab::FOAF.name, :type => String
|
65
65
|
# @example A property which defaults to {Spira::Types::Any}
|
66
|
-
# property :name, :predicate => FOAF.name
|
66
|
+
# property :name, :predicate => RDF::Vocab::FOAF.name
|
67
67
|
# @example An integer property
|
68
|
-
# property :age, :predicate => FOAF.age, :type => Integer
|
68
|
+
# property :age, :predicate => RDF::Vocab::FOAF.age, :type => Integer
|
69
69
|
# @param [Symbol] name The name of this property
|
70
70
|
# @param [Hash{Symbol => Any}] opts property options
|
71
71
|
# @option opts [RDF::URI] :predicate The RDF predicate which will refer to this property
|
data/lib/spira/type.rb
CHANGED
@@ -26,8 +26,8 @@ module Spira
|
|
26
26
|
# Spira by default. It allows either of the following forms to declare an
|
27
27
|
# integer property on a Spira resource:
|
28
28
|
#
|
29
|
-
# property :age, :predicate => FOAF.age, :type => Integer
|
30
|
-
# property :age, :predicate => FOAF.age, :type => RDF::XSD.integer
|
29
|
+
# property :age, :predicate => RDF::Vocab::FOAF.age, :type => Integer
|
30
|
+
# property :age, :predicate => RDF::Vocab::FOAF.age, :type => RDF::XSD.integer
|
31
31
|
#
|
32
32
|
# `Spira::Type`s include the RDF namespace and thus have all of the base RDF
|
33
33
|
# vocabularies available to them without the `RDF::` prefix.
|
data/lib/spira/utils.rb
CHANGED
@@ -1,29 +1,37 @@
|
|
1
1
|
module Spira
|
2
2
|
module Utils
|
3
3
|
##
|
4
|
-
# Rename
|
5
|
-
# Changes are immediately saved to the repository.
|
6
|
-
#
|
7
|
-
# @param [RDF::Resource] old_subject
|
4
|
+
# Rename the subject of a Spira object to something else
|
8
5
|
# @param [RDF::Resource] new_subject
|
9
6
|
# @param [RDF::Repository] repository
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
7
|
+
# @return [Spira::Base] A new instance using this subject
|
8
|
+
def rename!(new_subject, repository = nil)
|
9
|
+
repository ||= Spira.repository
|
10
|
+
repository.rename!(subject, new_subject)
|
11
|
+
self.class.for(new_subject)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
18
15
|
|
19
|
-
|
20
|
-
|
21
|
-
|
16
|
+
module RDF
|
17
|
+
class Repository
|
18
|
+
##
|
19
|
+
# Rename a resource in the Repository to the new given subject.
|
20
|
+
#
|
21
|
+
# @param [RDF::Resource] old_subject
|
22
|
+
# @param [RDF::Resource] new_subject
|
23
|
+
# @return [self]
|
24
|
+
def rename!(old_subject, new_subject)
|
25
|
+
transaction(mutable: true) do |tx|
|
26
|
+
query(subject: old_subject) do |statement|
|
27
|
+
tx.insert RDF::Statement.new(new_subject, statement.predicate, statement.object)
|
28
|
+
tx.delete(statement)
|
29
|
+
end
|
30
|
+
query(object: old_subject) do |statement|
|
31
|
+
tx.insert RDF::Statement.new(statement.subject, statement.predicate, new_subject)
|
32
|
+
tx.delete(statement)
|
33
|
+
end
|
22
34
|
end
|
23
|
-
|
24
|
-
repository.insert *update_repository
|
25
|
-
repository.delete *(old_subject_statements + old_object_statements)
|
26
35
|
end
|
27
|
-
module_function :rename!
|
28
36
|
end
|
29
37
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: spira
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 2.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ben Lavender
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir:
|
10
10
|
- bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2016-04-11 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rdf
|
@@ -17,34 +17,28 @@ dependencies:
|
|
17
17
|
requirements:
|
18
18
|
- - "~>"
|
19
19
|
- !ruby/object:Gem::Version
|
20
|
-
version: '
|
21
|
-
- - ">="
|
22
|
-
- !ruby/object:Gem::Version
|
23
|
-
version: 1.1.16.1
|
20
|
+
version: '2.0'
|
24
21
|
type: :runtime
|
25
22
|
prerelease: false
|
26
23
|
version_requirements: !ruby/object:Gem::Requirement
|
27
24
|
requirements:
|
28
25
|
- - "~>"
|
29
26
|
- !ruby/object:Gem::Version
|
30
|
-
version: '
|
31
|
-
- - ">="
|
32
|
-
- !ruby/object:Gem::Version
|
33
|
-
version: 1.1.16.1
|
27
|
+
version: '2.0'
|
34
28
|
- !ruby/object:Gem::Dependency
|
35
29
|
name: rdf-isomorphic
|
36
30
|
requirement: !ruby/object:Gem::Requirement
|
37
31
|
requirements:
|
38
32
|
- - "~>"
|
39
33
|
- !ruby/object:Gem::Version
|
40
|
-
version: '
|
34
|
+
version: '2.0'
|
41
35
|
type: :runtime
|
42
36
|
prerelease: false
|
43
37
|
version_requirements: !ruby/object:Gem::Requirement
|
44
38
|
requirements:
|
45
39
|
- - "~>"
|
46
40
|
- !ruby/object:Gem::Version
|
47
|
-
version: '
|
41
|
+
version: '2.0'
|
48
42
|
- !ruby/object:Gem::Dependency
|
49
43
|
name: promise
|
50
44
|
requirement: !ruby/object:Gem::Requirement
|
@@ -65,70 +59,98 @@ dependencies:
|
|
65
59
|
requirements:
|
66
60
|
- - ">"
|
67
61
|
- !ruby/object:Gem::Version
|
68
|
-
version: '
|
62
|
+
version: '4'
|
69
63
|
type: :runtime
|
70
64
|
prerelease: false
|
71
65
|
version_requirements: !ruby/object:Gem::Requirement
|
72
66
|
requirements:
|
73
67
|
- - ">"
|
74
68
|
- !ruby/object:Gem::Version
|
75
|
-
version: '
|
69
|
+
version: '4'
|
76
70
|
- !ruby/object:Gem::Dependency
|
77
71
|
name: activesupport
|
78
72
|
requirement: !ruby/object:Gem::Requirement
|
79
73
|
requirements:
|
80
74
|
- - ">"
|
81
75
|
- !ruby/object:Gem::Version
|
82
|
-
version: '
|
76
|
+
version: '4'
|
83
77
|
type: :runtime
|
84
78
|
prerelease: false
|
85
79
|
version_requirements: !ruby/object:Gem::Requirement
|
86
80
|
requirements:
|
87
81
|
- - ">"
|
88
82
|
- !ruby/object:Gem::Version
|
89
|
-
version: '
|
83
|
+
version: '4'
|
90
84
|
- !ruby/object:Gem::Dependency
|
91
85
|
name: rdf-spec
|
92
86
|
requirement: !ruby/object:Gem::Requirement
|
93
87
|
requirements:
|
94
88
|
- - "~>"
|
95
89
|
- !ruby/object:Gem::Version
|
96
|
-
version: '
|
90
|
+
version: '2.0'
|
91
|
+
type: :development
|
92
|
+
prerelease: false
|
93
|
+
version_requirements: !ruby/object:Gem::Requirement
|
94
|
+
requirements:
|
95
|
+
- - "~>"
|
96
|
+
- !ruby/object:Gem::Version
|
97
|
+
version: '2.0'
|
98
|
+
- !ruby/object:Gem::Dependency
|
99
|
+
name: rdf-turtle
|
100
|
+
requirement: !ruby/object:Gem::Requirement
|
101
|
+
requirements:
|
102
|
+
- - "~>"
|
103
|
+
- !ruby/object:Gem::Version
|
104
|
+
version: '2.0'
|
105
|
+
type: :development
|
106
|
+
prerelease: false
|
107
|
+
version_requirements: !ruby/object:Gem::Requirement
|
108
|
+
requirements:
|
109
|
+
- - "~>"
|
110
|
+
- !ruby/object:Gem::Version
|
111
|
+
version: '2.0'
|
112
|
+
- !ruby/object:Gem::Dependency
|
113
|
+
name: rdf-vocab
|
114
|
+
requirement: !ruby/object:Gem::Requirement
|
115
|
+
requirements:
|
116
|
+
- - "~>"
|
117
|
+
- !ruby/object:Gem::Version
|
118
|
+
version: '2.0'
|
97
119
|
type: :development
|
98
120
|
prerelease: false
|
99
121
|
version_requirements: !ruby/object:Gem::Requirement
|
100
122
|
requirements:
|
101
123
|
- - "~>"
|
102
124
|
- !ruby/object:Gem::Version
|
103
|
-
version: '
|
125
|
+
version: '2.0'
|
104
126
|
- !ruby/object:Gem::Dependency
|
105
127
|
name: rspec
|
106
128
|
requirement: !ruby/object:Gem::Requirement
|
107
129
|
requirements:
|
108
130
|
- - "~>"
|
109
131
|
- !ruby/object:Gem::Version
|
110
|
-
version: 3.
|
132
|
+
version: '3.4'
|
111
133
|
type: :development
|
112
134
|
prerelease: false
|
113
135
|
version_requirements: !ruby/object:Gem::Requirement
|
114
136
|
requirements:
|
115
137
|
- - "~>"
|
116
138
|
- !ruby/object:Gem::Version
|
117
|
-
version: 3.
|
139
|
+
version: '3.4'
|
118
140
|
- !ruby/object:Gem::Dependency
|
119
141
|
name: rspec-its
|
120
142
|
requirement: !ruby/object:Gem::Requirement
|
121
143
|
requirements:
|
122
144
|
- - "~>"
|
123
145
|
- !ruby/object:Gem::Version
|
124
|
-
version: '1.
|
146
|
+
version: '1.2'
|
125
147
|
type: :development
|
126
148
|
prerelease: false
|
127
149
|
version_requirements: !ruby/object:Gem::Requirement
|
128
150
|
requirements:
|
129
151
|
- - "~>"
|
130
152
|
- !ruby/object:Gem::Version
|
131
|
-
version: '1.
|
153
|
+
version: '1.2'
|
132
154
|
- !ruby/object:Gem::Dependency
|
133
155
|
name: yard
|
134
156
|
requirement: !ruby/object:Gem::Requirement
|
@@ -199,7 +221,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
199
221
|
requirements:
|
200
222
|
- - ">="
|
201
223
|
- !ruby/object:Gem::Version
|
202
|
-
version:
|
224
|
+
version: '2.0'
|
203
225
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
204
226
|
requirements:
|
205
227
|
- - ">="
|
@@ -207,7 +229,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
207
229
|
version: '0'
|
208
230
|
requirements: []
|
209
231
|
rubyforge_project: spira
|
210
|
-
rubygems_version: 2.4.
|
232
|
+
rubygems_version: 2.4.8
|
211
233
|
signing_key:
|
212
234
|
specification_version: 4
|
213
235
|
summary: A framework for using the information in RDF.rb repositories as model objects.
|