spira 2.1.0 → 3.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 60a2f2001ee3ca4803b5c0f10dd0ee95be394583
4
- data.tar.gz: 4fd45e81ca7128e36b97a08701ee2dacbec31f82
2
+ SHA256:
3
+ metadata.gz: 97fddc3a248df0d23723ea8967034dab05e28d23ccced070f1e87b910896adcf
4
+ data.tar.gz: e0828af26e91756329cbf511785d005dc528d0971683f992547fe2dde76f03cb
5
5
  SHA512:
6
- metadata.gz: 74b6ff7e40373eb2e704f64ff1e3602b60f17ea5042b27189199052f5a47989aa0a894075de4a4d6b4bb35fcd8b7ec0b5631213694058778ba3f3a67482bd326
7
- data.tar.gz: 0664e654b6331a8003cc676e7b026ca31d8b3a39159ed6a010eebf776324cec9a07e79aaee61185f2575f323b1d5fe7459747aa08507ad9fed92ed337d5fa6a7
6
+ metadata.gz: 5c146fef9d47e59add48611de4e460c290f60a410efbefeadf9f64e76e5b56be97a3d5ad1257640c657dcbfe805035edd435f697651f037214971faebc41c139
7
+ data.tar.gz: 5c69eca5680a622992a4bd7ab0647b6308fe2daaf5c9c651cd14207f870c4d79efcc227768cc974dde9e04f859a33cc1240dafba694eed7dc45b241ba67f5f97
data/README.md CHANGED
@@ -1,4 +1,9 @@
1
- # Spira [![Build Status](https://travis-ci.org/ruby-rdf/spira.png?branch=develop)](http://travis-ci.org/ruby-rdf/spira) [![Coverage Status](https://coveralls.io/repos/ruby-rdf/spira/badge.png?branch=develop)](https://coveralls.io/r/ruby-rdf/spira) [![Code Climate](https://codeclimate.com/github/ruby-rdf/spira.png)](https://codeclimate.com/github/ruby-rdf/spira) [![Dependency Status](https://gemnasium.com/ruby-rdf/spira.png)](https://gemnasium.com/ruby-rdf/spira)
1
+ # Spira
2
+
3
+ [![Gem Version](https://badge.fury.io/rb/spira.png)](https://badge.fury.io/rb/spira)
4
+ [![Build Status](https://github.com/ruby-rdf/spira/workflows/CI/badge.svg?branch=develop)](https://github.com/ruby-rdf/spira/actions?query=workflow%3ACI)
5
+ [![Coverage Status](https://coveralls.io/repos/ruby-rdf/spira/badge.png?branch=develop)](https://coveralls.io/r/ruby-rdf/spira)
6
+ [![Code Climate](https://codeclimate.com/github/ruby-rdf/spira.png)](https://codeclimate.com/github/ruby-rdf/spira)
2
7
 
3
8
  It's time to breathe life into your linked data.
4
9
 
@@ -13,19 +18,18 @@ losing access to statement-oriented nature of linked data, if you so choose.
13
18
  It can be used either to access existing RDF data in a resource-oriented way,
14
19
  or to create a new store of RDF data based on simple defaults.
15
20
 
16
- An introductory blog post is at <http://blog.datagraph.org/2010/05/spira>
17
-
18
- A changelog is available in the {file:CHANGES.md} file.
19
-
20
21
  ### Example
21
22
 
22
23
  ```ruby
24
+ require 'spira'
25
+ require 'rdf/vocab'
26
+
23
27
  class Person < Spira::Base
24
28
 
25
- configure :base_uri => "http://example.org/example/people"
29
+ configure base_uri: "http://example.org/example/people"
26
30
 
27
- property :name, :predicate => RDF::Vocab::FOAF.name, :type => String
28
- property :age, :predicate => RDF::Vocab::FOAF.age, :type => Integer
31
+ property :name, predicate: RDF::Vocab::FOAF.name, type: String
32
+ property :age, predicate: RDF::Vocab::FOAF.age, type: Integer
29
33
 
30
34
  end
31
35
 
@@ -100,7 +104,7 @@ The easiest way to work with Spira is to install it via Rubygems:
100
104
 
101
105
  $ sudo gem install spira
102
106
 
103
- Downloads will be available on the github project page, as well as on Rubyforge.
107
+ Downloads will be available on the github project page.
104
108
 
105
109
  ## Defining Model Classes
106
110
 
@@ -110,17 +114,18 @@ without the `RDF::` prefix. For example:
110
114
 
111
115
  ```ruby
112
116
  require 'spira'
117
+ require 'rdf/vocab'
113
118
 
114
119
  class CD < Spira::Base
115
- configure :base_uri => 'http://example.org/cds'
116
- property :name, :predicate => RDF::Vocab::DC.title, :type => XSD.string
117
- property :artist, :predicate => URI.new('http://example.org/vocab/artist'), :type => :artist
120
+ configure base_uri: 'http://example.org/cds'
121
+ property :name, predicate: RDF::Vocab::DC.title, type: XSD.string
122
+ property :artist, predicate: RDF::URI.new('http://example.org/vocab/artist'), type: :artist
118
123
  end
119
124
 
120
125
  class Artist < Spira::Base
121
- configure :base_uri => 'http://example.org/artists'
122
- property :name, :predicate => RDF::Vocab::DC.title, :type => XSD.string
123
- has_many :cds, :predicate => URI.new('http://example.org/vocab/published_cd'), :type => XSD.string
126
+ configure base_uri: 'http://example.org/artists'
127
+ property :name, predicate: RDF::Vocab::DC.title, type: XSD.string
128
+ has_many :cds, predicate: RDF::URI.new('http://example.org/vocab/published_cd'), type: XSD.string
124
129
  end
125
130
  ```
126
131
 
@@ -210,15 +215,18 @@ CD.for RDF::URI.new('http://example.org/cds/queens-greatest-hits')
210
215
  A class with a `type` set is assigned an `RDF.type` on creation and saving.
211
216
 
212
217
  ```ruby
218
+ require 'spira'
219
+ require 'rdf/vocab'
220
+
213
221
  class Album < Spira::Base
214
- type URI.new('http://example.org/types/album')
215
- property :name, :predicate => RDF::Vocab::DC.title
222
+ type RDF::URI.new('http://example.org/types/album')
223
+ property :name, predicate: RDF::Vocab::DC.title
216
224
  end
217
225
 
218
226
  Spira.repository = RDF::Repository.new
219
227
 
220
228
  rolling_stones = Album.for RDF::URI.new('http://example.org/cds/rolling-stones-hits')
221
- # See RDF.rb at http://rdf.rubyforge.org/RDF/Enumerable.html for more information about #has_predicate?
229
+ # See RDF.rb at https://www.rubydoc.info/github/ruby-rdf/rdf/RDF/Enumerable.html for more information about #has_predicate?
222
230
  rolling_stones.has_predicate?(RDF.type) #=> true
223
231
  Album.type #=> RDF::URI('http://example.org/types/album')
224
232
  ```
@@ -263,10 +271,10 @@ A class with a `default_vocabulary` set will transparently create predicates for
263
271
 
264
272
  ```ruby
265
273
  class Song < Spira::Base
266
- configure :default_vocabulary => URI.new('http://example.org/vocab'),
267
- :base_uri => 'http://example.org/songs'
274
+ configure default_vocabulary: RDF::URI.new('http://example.org/vocab'),
275
+ base_uri: 'http://example.org/songs'
268
276
  property :title
269
- property :author, :type => :artist
277
+ property :author, type: :artist
270
278
  end
271
279
 
272
280
  Spira.repository = RDF::Repository.new
@@ -288,8 +296,8 @@ will always return a list, including an empty list for no value. All options
288
296
  for `property` work for `has_many`.
289
297
 
290
298
  ```ruby
291
- property :artist, :type => :artist #=> cd.artist returns a single value
292
- has_many :cds, :type => :cd #=> artist.cds returns an array
299
+ property :artist, type: :artist #=> cd.artist returns a single value
300
+ has_many :cds, type: :cd #=> artist.cds returns an array
293
301
  ```
294
302
 
295
303
  Property always takes a symbol name as a name, and a variable list of options. The supported options are:
@@ -308,7 +316,7 @@ properties having a single item, ie defined with `property`.
308
316
 
309
317
  ```ruby
310
318
  class Article < Spira::Base
311
- property :label, :localized => true
319
+ property :label, localized: true
312
320
  end
313
321
 
314
322
  Spira.repository = RDF::Repository.new
@@ -368,8 +376,8 @@ Classes can now use this particular type like so:
368
376
 
369
377
  ```ruby
370
378
  class Test < Spira::Base
371
- property :test1, :type => Integer
372
- property :test2, :type => RDF::XSD.integer
379
+ property :test1, type: Integer
380
+ property :test2, type: RDF::XSD.integer
373
381
  end
374
382
  ```
375
383
 
@@ -384,7 +392,7 @@ are implemented:
384
392
 
385
393
  The default type for a Spira property is `Spira::Types::Any`, which uses
386
394
  `RDF::Literal`'s automatic boxing/unboxing of XSD types as best it can.
387
- See [`RDF::Literal`](http://rdf.rubyforge.org/RDF/Literal.html) for more information.
395
+ See [`RDF::Literal`](https://www.rubydoc.info/github/ruby-rdf/rdf/RDF/Literal.html) for more information.
388
396
 
389
397
  You can implement your own types as well. Your class' serialize method should
390
398
  turn an RDF::Value into a ruby object, and vice versa.
@@ -404,7 +412,7 @@ module MyModule
404
412
  end
405
413
 
406
414
  class MyClass < Spira::Base
407
- property :property1, :type => MyModule::MyType
415
+ property :property1, type: MyModule::MyType
408
416
  end
409
417
  ```
410
418
 
@@ -467,6 +475,10 @@ All model objects are fully-functional as `RDF::Enumerable`, `RDF::Queryable`,
467
475
  and `RDF::Mutable`. This lets you manipulate objects on the RDF statement
468
476
  level. You can also access attributes that are not defined as properties.
469
477
 
478
+ ## Documentation
479
+
480
+ <https://www.rubydoc.info/github/ruby-rdf/spira>
481
+
470
482
  ## Support
471
483
 
472
484
  There are a number of ways to ask for help. In declining order of preference:
@@ -493,7 +505,10 @@ This repository uses [Git Flow](https://github.com/nvie/gitflow) to mange develo
493
505
  list in the the `README`. Alphabetical order applies.
494
506
  * Do note that in order for us to merge any non-trivial changes (as a rule
495
507
  of thumb, additions larger than about 15 lines of code), we need an
496
- explicit [public domain dedication][PDD] on record from you.
508
+ explicit [public domain dedication][PDD] on record from you,
509
+ which you will be asked to agree to on the first commit to a repo within the organization.
510
+ Note that the agreement applies to all repos in the [Ruby RDF](https://github.com/ruby-rdf/) organization.
497
511
 
498
- [public-rdf-ruby w3c mailing list]: http://lists.w3.org/Archives/Public/public-rdf-ruby/
499
- [RDF.rb]: http://rubygems.org/gems/rdf
512
+ [public-rdf-ruby w3c mailing list]: https://lists.w3.org/Archives/Public/public-rdf-ruby/
513
+ [RDF.rb]: https://rubygems.org/gems/rdf
514
+ [PDD]: https://unlicense.org/#unlicensing-contributions
data/UNLICENSE CHANGED
@@ -21,4 +21,4 @@ OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
21
21
  ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
22
22
  OTHER DEALINGS IN THE SOFTWARE.
23
23
 
24
- For more information, please refer to <http://unlicense.org/>
24
+ For more information, please refer to <https:///unlicense.org/>
data/VERSION CHANGED
@@ -1 +1 @@
1
- 2.1.0
1
+ 3.2.0
data/lib/spira/base.rb CHANGED
@@ -32,8 +32,6 @@ module Spira
32
32
  # @return [RDF::URI]
33
33
  attr_reader :subject
34
34
 
35
- attr_accessor :attributes
36
-
37
35
  class << self
38
36
  attr_reader :reflections, :properties
39
37
 
@@ -95,7 +93,7 @@ module Spira
95
93
  end
96
94
 
97
95
  def instantiate_record(subj)
98
- new(:_subject => id_for(subj))
96
+ new(_subject: id_for(subj))
99
97
  end
100
98
 
101
99
  end # class methods
@@ -109,31 +107,40 @@ module Spira
109
107
  # Initialize a new Spira::Base instance of this resource class using
110
108
  # a new blank node subject. Accepts a hash of arguments for initial
111
109
  # attributes. To use a URI or existing blank node as a subject, use
112
- # {Spira.for} instead.
110
+ # the `.for` method on the subclass instead.
111
+ #
112
+ # @example
113
+ # class Person < Spira::Base; end
114
+ # bob = Person.for("bob")
113
115
  #
114
116
  # @param [Hash{Symbol => Any}] props Default attributes for this instance
115
117
  # @yield [self] Executes a given block
116
118
  # @yieldparam [self] self The newly created instance
117
- # @see Spira.for
119
+ # @see Spira::Persistence::ClassMethods#for
118
120
  # @see RDF::URI#as
119
121
  # @see RDF::Node#as
120
122
  def initialize(props = {}, options = {})
121
123
  @subject = props.delete(:_subject) || RDF::Node.new
124
+ @attrs = {}
122
125
 
123
- @attributes = {}
124
126
  reload props
125
127
 
126
128
  yield self if block_given?
127
129
  end
128
130
 
131
+ # Returns the attributes
132
+ def attributes
133
+ @attrs
134
+ end
135
+
129
136
  # Freeze the attributes hash such that associations are still accessible, even on destroyed records.
130
137
  def freeze
131
- @attributes.freeze; self
138
+ @attrs.freeze; self
132
139
  end
133
140
 
134
141
  # Returns +true+ if the attributes hash has been frozen.
135
142
  def frozen?
136
- @attributes.frozen?
143
+ @attrs.frozen?
137
144
  end
138
145
 
139
146
  ##
@@ -185,7 +192,7 @@ module Spira
185
192
  # an RDF level, and will work across subclasses as long as the attributes
186
193
  # are the same.
187
194
  #
188
- # @see http://rdf.rubyforge.org/isomorphic/
195
+ # @see https://rubygems.org/gems/rdf-isomorphic/
189
196
  def ==(other)
190
197
  # TODO: define behavior for equality on subclasses.
191
198
  # TODO: should we compare attributes here?
@@ -257,7 +264,7 @@ module Spira
257
264
  # @param [RDF::Resource] new_subject
258
265
  # @return [Spira::Base] copy
259
266
  def copy(new_subject)
260
- self.class.new(attributes.merge(:_subject => new_subject))
267
+ self.class.new(@attrs.merge(_subject: new_subject))
261
268
  end
262
269
 
263
270
  ##
@@ -284,20 +291,19 @@ module Spira
284
291
  private
285
292
 
286
293
  def reset_changes
287
- @previously_changed = changes
288
- @changed_attributes.clear
294
+ clear_changes_information
289
295
  end
290
296
 
291
297
  def write_attribute(name, value)
292
298
  name = name.to_s
293
299
  if self.class.properties[name]
294
- if attributes[name].is_a?(Promise)
295
- changed_attributes[name] = attributes[name] unless changed_attributes.include?(name)
296
- attributes[name] = value
300
+ if @attrs[name].is_a?(Promise)
301
+ changed_attributes[name] = @attrs[name] unless changed_attributes.include?(name)
302
+ @attrs[name] = value
297
303
  else
298
304
  if value != read_attribute(name)
299
305
  attribute_will_change!(name)
300
- attributes[name] = value
306
+ @attrs[name] = value
301
307
  end
302
308
  end
303
309
  else
@@ -309,7 +315,7 @@ module Spira
309
315
  # Get the current value for the given attribute
310
316
  #
311
317
  def read_attribute(name)
312
- value = attributes[name.to_s]
318
+ value = @attrs[name.to_s]
313
319
 
314
320
  refl = self.class.reflections[name]
315
321
  if refl && !value
@@ -334,7 +340,7 @@ module Spira
334
340
  end
335
341
 
336
342
  def serialize_localized_property(value, locale)
337
- RDF::Literal.new(value, :language => locale)
343
+ RDF::Literal.new(value, language: locale)
338
344
  end
339
345
 
340
346
  def unserialize_localized_properties(values, locale)
@@ -350,7 +356,7 @@ module Spira
350
356
  end
351
357
 
352
358
  def serialize_hash_localized_properties(values)
353
- values.map { |lang, property| RDF::Literal.new(property, :language => lang) }
359
+ values.map { |lang, property| RDF::Literal.new(property, language: lang) }
354
360
  end
355
361
 
356
362
  # Build a Ruby value from an RDF value.
@@ -20,7 +20,7 @@ module Spira
20
20
  # @param [Hash] args
21
21
  # args can contain:
22
22
  # :conditions - Hash of properties and values
23
- # :limit - Fixnum, limiting the amount of returned records
23
+ # :limit - Integer, limiting the amount of returned records
24
24
  # @return [Spira::Base, Array]
25
25
  def find(scope, *args)
26
26
  case scope
@@ -73,7 +73,7 @@ module Spira
73
73
  # cannot handle such patterns, we iterate across types "manually"
74
74
  types.each do |tp|
75
75
  break if limit.zero?
76
- q = conditions_to_query(conditions.merge(:type => tp))
76
+ q = conditions_to_query(conditions.merge(type: tp))
77
77
  repository.query(q) do |solution|
78
78
  break if limit.zero?
79
79
  if offset.zero?
@@ -112,24 +112,24 @@ module Spira
112
112
  #
113
113
  # ==== Examples
114
114
  # # Create a single new object
115
- # User.create(:first_name => 'Jamie')
115
+ # User.create(first_name: 'Jamie')
116
116
  #
117
117
  # # Create a single new object using the :admin mass-assignment security role
118
- # User.create({ :first_name => 'Jamie', :is_admin => true }, :as => :admin)
118
+ # User.create({ first_name: 'Jamie', is_admin: true }, as: :admin)
119
119
  #
120
120
  # # Create a single new object bypassing mass-assignment security
121
- # User.create({ :first_name => 'Jamie', :is_admin => true }, :without_protection => true)
121
+ # User.create({ first_name: 'Jamie', is_admin: true }, without_protection: true)
122
122
  #
123
123
  # # Create an Array of new objects
124
- # User.create([{ :first_name => 'Jamie' }, { :first_name => 'Jeremy' }])
124
+ # User.create([{ first_name: 'Jamie' }, { first_name: 'Jeremy' }])
125
125
  #
126
126
  # # Create a single object and pass it into a block to set other attributes.
127
- # User.create(:first_name => 'Jamie') do |u|
127
+ # User.create(first_name: 'Jamie') do |u|
128
128
  # u.is_admin = false
129
129
  # end
130
130
  #
131
131
  # # Creating an Array of new objects using a block, where the block is executed for each object:
132
- # User.create([{ :first_name => 'Jamie' }, { :first_name => 'Jeremy' }]) do |u|
132
+ # User.create([{ first_name: 'Jamie' }, { first_name: 'Jeremy' }]) do |u|
133
133
  # u.is_admin = false
134
134
  # end
135
135
  def create(attributes = nil, options = {}, &block)
@@ -171,7 +171,7 @@ module Spira
171
171
  # @yield [self] Executes a given block and calls `#save!`
172
172
  # @yieldparam [self] self The newly created instance
173
173
  # @return [Spira::Base] The newly created instance
174
- # @see http://rdf.rubyforge.org/RDF/URI.html
174
+ # @see https://www.rubydoc.info/github/ruby-rdf/rdf/RDF/URI.html
175
175
  def for(identifier, attributes = {}, &block)
176
176
  self.project(id_for(identifier), attributes, &block)
177
177
  end
@@ -192,7 +192,7 @@ module Spira
192
192
  # @param [Hash{Symbol => Any}] attributes Initial attributes
193
193
  # @return [Spira::Base] the newly created instance
194
194
  def project(subject, attributes = {}, &block)
195
- new(attributes.merge(:_subject => subject), &block)
195
+ new(attributes.merge(_subject: subject), &block)
196
196
  end
197
197
 
198
198
  ##
@@ -205,7 +205,7 @@ module Spira
205
205
  # @param [Any] identifier
206
206
  # @return [RDF::URI, RDF::Node]
207
207
  # @raise [ArgumentError] If this class cannot create an identifier from the given argument
208
- # @see http://rdf.rubyforge.org/RDF/URI.html
208
+ # @see https://www.rubydoc.info/github/ruby-rdf/rdf/RDF/URI.html
209
209
  # @see Spira.base_uri
210
210
  # @see Spira.for
211
211
  def id_for(identifier)
@@ -303,10 +303,10 @@ module Spira
303
303
  ##
304
304
  # Enumerate each RDF statement that makes up this projection. This makes
305
305
  # each instance an `RDF::Enumerable`, with all of the nifty benefits
306
- # thereof. See <http://rdf.rubyforge.org/RDF/Enumerable.html> for
306
+ # thereof. See <https://www.rubydoc.info/github/ruby-rdf/rdf/RDF/Enumerable.html> for
307
307
  # information on arguments.
308
308
  #
309
- # @see http://rdf.rubyforge.org/RDF/Enumerable.html
309
+ # @see https://www.rubydoc.info/github/ruby-rdf/rdf/RDF/Enumerable.html
310
310
  def each
311
311
  if block_given?
312
312
  self.class.properties.each do |name, property|
@@ -333,7 +333,7 @@ module Spira
333
333
  ##
334
334
  # The number of RDF::Statements this projection has.
335
335
  #
336
- # @see http://rdf.rubyforge.org/RDF/Enumerable.html#count
336
+ # @see https://www.rubydoc.info/github/ruby-rdf/rdf/RDF/Enumerable.html#count
337
337
  def count
338
338
  each.count
339
339
  end
@@ -342,7 +342,7 @@ module Spira
342
342
  # Update multiple attributes of this repository.
343
343
  #
344
344
  # @example Update multiple attributes
345
- # person.update_attributes(:name => 'test', :age => 10)
345
+ # person.update_attributes(name: 'test', age: 10)
346
346
  # #=> person
347
347
  # person.name
348
348
  # #=> 'test'
@@ -366,7 +366,7 @@ module Spira
366
366
  # NB: "props" argument is ignored, it is handled in Base
367
367
  #
368
368
  def reload(props = {})
369
- sts = self.class.repository.query(:subject => subject)
369
+ sts = self.class.repository.query({subject: subject})
370
370
  self.class.properties.each do |name, options|
371
371
  name = name.to_s
372
372
  if sts
@@ -15,8 +15,8 @@ module Spira
15
15
  #
16
16
  def configure(options = {})
17
17
  singleton_class.class_eval do
18
- { :base_uri => options[:base_uri],
19
- :default_vocabulary => options[:default_vocabulary]
18
+ { base_uri: options[:base_uri],
19
+ default_vocabulary: options[:default_vocabulary]
20
20
  }.each do |name, value|
21
21
  # redefine reader methods only when required,
22
22
  # otherwise, use the ancestor methods
@@ -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 => RDF::Vocab::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 => RDF::Vocab::FOAF.name
66
+ # property :name, predicate: RDF::Vocab::FOAF.name
67
67
  # @example An integer property
68
- # property :age, :predicate => RDF::Vocab::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
@@ -81,12 +81,12 @@ module Spira
81
81
  if opts.delete(:localized)
82
82
  raise 'Only Spira::Types::Any properties can accept the :localized option' unless type_for(opts[:type]) == Spira::Types::Any
83
83
  define_localized_property_methods(name, opts)
84
- has_many "#{name}_native", opts.merge(:type => Spira::Types::Native)
84
+ has_many "#{name}_native", opts.merge(type: Spira::Types::Native)
85
85
  else
86
86
  unset_has_many(name)
87
87
  predicate = predicate_for(opts[:predicate], name)
88
88
  type = type_for(opts[:type])
89
- properties[name] = HashWithIndifferentAccess.new(:predicate => predicate, :type => type)
89
+ properties[name] = HashWithIndifferentAccess.new(predicate: predicate, type: type)
90
90
 
91
91
  define_attribute_method name
92
92
  define_method "#{name}=" do |arg|
data/lib/spira/type.rb CHANGED
@@ -26,13 +26,13 @@ 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 => RDF::Vocab::FOAF.age, :type => Integer
30
- # property :age, :predicate => RDF::Vocab::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.
34
34
  #
35
- # @see http://rdf.rubyforge.org/RDF/Value.html
35
+ # @see https://www.rubydoc.info/github/ruby-rdf/rdf/RDF/Value.html
36
36
  # @see Spira::Resource
37
37
  module Type
38
38
 
@@ -6,7 +6,7 @@ module Spira::Types
6
6
  # Its behavior is defined as 'What `RDF::Literal` does' for a given value.
7
7
  #
8
8
  # @see Spira::Type
9
- # @see http://rdf.rubyforge.org/RDF/Literal.html
9
+ # @see https://www.rubydoc.info/github/ruby-rdf/rdf/RDF/Literal.html
10
10
  class Any
11
11
 
12
12
  include Spira::Type
@@ -8,7 +8,7 @@ module Spira::Types
8
8
  # `Spira::Types::AnyURI`, `AnyURI`, or `XSD.anyURI`.
9
9
  #
10
10
  # @see Spira::Type
11
- # @see http://rdf.rubyforge.org/RDF/Literal.html
11
+ # @see https://www.rubydoc.info/github/ruby-rdf/rdf/RDF/Literal.html
12
12
  class AnyURI
13
13
 
14
14
  include Spira::Type
@@ -18,10 +18,10 @@ module Spira::Types
18
18
  end
19
19
 
20
20
  def self.serialize(value)
21
- RDF::Literal.new(value, :datatype => XSD.anyURI)
21
+ RDF::Literal.new(value, datatype: XSD.anyURI)
22
22
  end
23
23
 
24
- register_alias XSD.anyURI
24
+ register_alias RDF::XSD.anyURI
25
25
 
26
26
  end
27
27
  end
@@ -8,7 +8,7 @@ module Spira::Types
8
8
  # `Spira::Types::Boolean`, `Boolean`, or `XSD.boolean`.
9
9
  #
10
10
  # @see Spira::Type
11
- # @see http://rdf.rubyforge.org/RDF/Literal.html
11
+ # @see https://www.rubydoc.info/github/ruby-rdf/rdf/RDF/Literal.html
12
12
  class Boolean
13
13
 
14
14
  include Spira::Type
@@ -19,9 +19,9 @@ module Spira::Types
19
19
 
20
20
  def self.serialize(value)
21
21
  if value
22
- RDF::Literal.new(true, :datatype => RDF::XSD.boolean)
22
+ RDF::Literal.new(true, datatype: RDF::XSD.boolean)
23
23
  else
24
- RDF::Literal.new(false, :datatype => RDF::XSD.boolean)
24
+ RDF::Literal.new(false, datatype: RDF::XSD.boolean)
25
25
  end
26
26
  end
27
27
 
@@ -8,7 +8,7 @@ module Spira::Types
8
8
  # `Spira::Types::Date`, `Date`, or `XSD.date`.
9
9
  #
10
10
  # @see Spira::Type
11
- # @see http://rdf.rubyforge.org/RDF/Literal.html
11
+ # @see https://www.rubydoc.info/github/ruby-rdf/rdf/RDF/Literal.html
12
12
  class Date
13
13
  include Spira::Type
14
14
 
@@ -17,10 +17,10 @@ module Spira::Types
17
17
  end
18
18
 
19
19
  def self.serialize(value)
20
- RDF::Literal.new(value, :datatype => XSD.date)
20
+ RDF::Literal.new(value, datatype: XSD.date)
21
21
  end
22
22
 
23
- register_alias XSD.date
23
+ register_alias RDF::XSD.date
24
24
 
25
25
  end
26
26
  end
@@ -8,7 +8,7 @@ module Spira::Types
8
8
  # `Spira::Types::DateTime`, `DateTime`, or `XSD.dateTime`.
9
9
  #
10
10
  # @see Spira::Type
11
- # @see http://rdf.rubyforge.org/RDF/Literal.html
11
+ # @see https://www.rubydoc.info/github/ruby-rdf/rdf/RDF/Literal.html
12
12
  class DateTime
13
13
  include Spira::Type
14
14
 
@@ -17,10 +17,10 @@ module Spira::Types
17
17
  end
18
18
 
19
19
  def self.serialize(value)
20
- RDF::Literal.new(value, :datatype => XSD.dateTime)
20
+ RDF::Literal.new(value, datatype: XSD.dateTime)
21
21
  end
22
22
 
23
- register_alias XSD.dateTime
23
+ register_alias RDF::XSD.dateTime
24
24
 
25
25
  end
26
26
  end
@@ -10,7 +10,7 @@ module Spira::Types
10
10
  # `Spira::Types::Integer`, `Integer`, or `XSD.integer`.
11
11
  #
12
12
  # @see Spira::Type
13
- # @see http://rdf.rubyforge.org/RDF/Literal.html
13
+ # @see https://www.rubydoc.info/github/ruby-rdf/rdf/RDF/Literal.html
14
14
  class Decimal
15
15
  include Spira::Type
16
16
 
@@ -20,7 +20,7 @@ module Spira::Types
20
20
  end
21
21
 
22
22
  def self.serialize(value)
23
- RDF::Literal.new(value.is_a?(BigDecimal) ? value.to_s('F') : value.to_s, :datatype => RDF::XSD.decimal)
23
+ RDF::Literal.new(value.is_a?(BigDecimal) ? value.to_s('F') : value.to_s, datatype: RDF::XSD.decimal)
24
24
  end
25
25
 
26
26
  register_alias RDF::XSD.decimal
@@ -8,7 +8,7 @@ module Spira::Types
8
8
  # `Spira::Types::Double`, `Double`, or `XSD.double`.
9
9
  #
10
10
  # @see Spira::Type
11
- # @see http://rdf.rubyforge.org/RDF/Literal.html
11
+ # @see https://www.rubydoc.info/github/ruby-rdf/rdf/RDF/Literal.html
12
12
  class Double
13
13
 
14
14
  include Spira::Type
@@ -18,7 +18,7 @@ module Spira::Types
18
18
  end
19
19
 
20
20
  def self.serialize(value)
21
- RDF::Literal.new(value.to_f, :datatype => RDF::XSD.double)
21
+ RDF::Literal.new(value.to_f, datatype: RDF::XSD.double)
22
22
  end
23
23
 
24
24
  register_alias RDF::XSD.double