Skip to content

Commit acf4ad5

Browse files
committed
Finish 3.1.1
2 parents 1aa855f + bf18275 commit acf4ad5

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

74 files changed

+464
-345
lines changed

.byebug_history

Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
c
2+
subject.query({subject: Cars.car3, predicate: RDF.type, object: Cars.car})
3+
subject.query({subject: Cars.car3, predicate: RDF.type, object: Cars.car3})
4+
subject.query({subject: Cars.car3, predicate: RDF.type}).to_a
5+
subject.query({subject: Cars.car2}).to_a
6+
subject.query({subject: Cars.car2, predicate: RDF.type}).to_a
7+
subject.query({subject: Cars.car2, predicate: RDF.type})
8+
subject.query({subject: Cars.car2, predicate: RDF.type, object: Cars.car3})
9+
subject.query({subject: Cars.car2, predicate: RDF.type, object: Cars.car})
10+
Cars.car3.attributes
11+
Cars.car3
12+
car3.attributes
13+
puts subject.dump(:ttl)
14+
subject.count
15+
subject
16+
c
17+
objects
18+
n
19+
options[:predicate]
20+
n
21+
name
22+
n
23+
s
24+
sts.to_a
25+
sts
26+
n
27+
s
28+
n
29+
s
30+
person.attributes
31+
person
32+
c
33+
p.attributes
34+
n
35+
exit
36+
props
37+
n
38+
s
39+
Person.new(name: "Dick").attributes
40+
friend.attributes
41+
friend
42+
exit
43+
self.class.repository.dump(:ttl)
44+
self.class.repository
45+
self.class.repository.query({subject: subject}).to_a
46+
s
47+
n
48+
s
49+
c
50+
sts.to_a
51+
sts
52+
name
53+
sts.to_a
54+
sts
55+
objects
56+
n
57+
options
58+
s
59+
n
60+
s
61+
n
62+
s
63+
exit
64+
self.class.properties
65+
options
66+
options[:predicate]
67+
n
68+
options
69+
name
70+
s
71+
self.class.properties
72+
sts
73+
n
74+
s
75+
attributes
76+
n
77+
s
78+
attributes
79+
n
80+
s
81+
c
82+
props
83+
self.attributes
84+
self
85+
n
86+
s
87+
c
88+
person.attributes
89+
person
90+
person.name
91+
person.reload
92+
person.reolad
93+
c
94+
person
95+
n
96+
value
97+
n
98+
@attrs[name]
99+
n
100+
s
101+
self.class.properties[name]
102+
self.class.properties
103+
n
104+
name
105+
s
106+
name
107+
n
108+
s

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,4 @@ gems.tags
1212
Gemfile.lock
1313
bin/
1414
/.bundle/
15+
/releases

.travis.yml

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,15 @@
11
language: ruby
22
bundler_args: --without debug
33
script: "bundle exec rake spec"
4-
before_install: "gem update --system"
54
env:
65
- CI=true
76
rvm:
8-
- 2.2
9-
- 2.3
107
- 2.4
118
- 2.5
12-
- jruby-9
13-
- rbx-3
9+
- 2.6
10+
- 2.7
11+
- jruby
1412
matrix:
1513
allow_failures:
16-
- rvm: jruby-9
17-
- rvm: rbx-3
14+
- rvm: jruby
1815
sudo: false

Gemfile

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ gem 'rdf', github: "ruby-rdf/rdf", branch: "develop"
55

66
group :development, :test do
77
gem 'ebnf', github: "dryruby/ebnf", branch: "develop"
8+
gem 'json-ld', github: "ruby-rdf/json-ld", branch: "develop"
89
gem 'rdf-isomorphic', github: "ruby-rdf/rdf-isomorphic", branch: "develop"
910
gem 'rdf-spec', github: "ruby-rdf/rdf-spec", branch: "develop"
1011
gem 'rdf-turtle', github: "ruby-rdf/rdf-turtle", branch: "develop"
@@ -17,14 +18,9 @@ group :development, :test do
1718
end
1819

1920
group :test do
20-
gem 'coveralls', :require => false
21-
gem 'simplecov', '~> 0.10', :require => false
21+
gem 'simplecov', platforms: :mri
22+
gem 'coveralls', '~> 0.8', platforms: :mri
2223
gem 'guard' #, '~> 2.13.0'
2324
gem 'guard-rspec' #, '~> 3.1.0'
2425
gem 'guard-ctags-bundler' #, '~> 1.4.0'
2526
end
26-
27-
#group :debug do
28-
# gem "debugger", :platforms => [:mri_19, :mri_20]
29-
# gem "ruby-debug", :platforms => [:jruby]
30-
#end

Guardfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
guard "ctags-bundler", :emacs => true do
1+
guard "ctags-bundler", emacs: true do
22
watch(/^(lib|spec\/support)\/.*\.rb$/)
33
watch("Gemfile.lock")
44
end

README.md

Lines changed: 30 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,15 @@ A changelog is available in the {file:CHANGES.md} file.
2020
### Example
2121

2222
```ruby
23+
require 'spira'
24+
require 'rdf/vocab'
25+
2326
class Person < Spira::Base
2427

25-
configure :base_uri => "http://example.org/example/people"
28+
configure base_uri: "http://example.org/example/people"
2629

27-
property :name, :predicate => RDF::Vocab::FOAF.name, :type => String
28-
property :age, :predicate => RDF::Vocab::FOAF.age, :type => Integer
30+
property :name, predicate: RDF::Vocab::FOAF.name, type: String
31+
property :age, predicate: RDF::Vocab::FOAF.age, type: Integer
2932

3033
end
3134

@@ -110,17 +113,18 @@ without the `RDF::` prefix. For example:
110113

111114
```ruby
112115
require 'spira'
116+
require 'rdf/vocab'
113117

114118
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 => RDF::URI.new('http://example.org/vocab/artist'), :type => :artist
119+
configure base_uri: 'http://example.org/cds'
120+
property :name, predicate: RDF::Vocab::DC.title, type: XSD.string
121+
property :artist, predicate: RDF::URI.new('http://example.org/vocab/artist'), type: :artist
118122
end
119123

120124
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 => RDF::URI.new('http://example.org/vocab/published_cd'), :type => XSD.string
125+
configure base_uri: 'http://example.org/artists'
126+
property :name, predicate: RDF::Vocab::DC.title, type: XSD.string
127+
has_many :cds, predicate: RDF::URI.new('http://example.org/vocab/published_cd'), type: XSD.string
124128
end
125129
```
126130

@@ -210,9 +214,12 @@ CD.for RDF::URI.new('http://example.org/cds/queens-greatest-hits')
210214
A class with a `type` set is assigned an `RDF.type` on creation and saving.
211215

212216
```ruby
217+
require 'spira'
218+
require 'rdf/vocab'
219+
213220
class Album < Spira::Base
214221
type RDF::URI.new('http://example.org/types/album')
215-
property :name, :predicate => RDF::Vocab::DC.title
222+
property :name, predicate: RDF::Vocab::DC.title
216223
end
217224

218225
Spira.repository = RDF::Repository.new
@@ -263,10 +270,10 @@ A class with a `default_vocabulary` set will transparently create predicates for
263270

264271
```ruby
265272
class Song < Spira::Base
266-
configure :default_vocabulary => RDF::URI.new('http://example.org/vocab'),
267-
:base_uri => 'http://example.org/songs'
273+
configure default_vocabulary: RDF::URI.new('http://example.org/vocab'),
274+
base_uri: 'http://example.org/songs'
268275
property :title
269-
property :author, :type => :artist
276+
property :author, type: :artist
270277
end
271278

272279
Spira.repository = RDF::Repository.new
@@ -288,8 +295,8 @@ will always return a list, including an empty list for no value. All options
288295
for `property` work for `has_many`.
289296

290297
```ruby
291-
property :artist, :type => :artist #=> cd.artist returns a single value
292-
has_many :cds, :type => :cd #=> artist.cds returns an array
298+
property :artist, type: :artist #=> cd.artist returns a single value
299+
has_many :cds, type: :cd #=> artist.cds returns an array
293300
```
294301

295302
Property always takes a symbol name as a name, and a variable list of options. The supported options are:
@@ -308,7 +315,7 @@ properties having a single item, ie defined with `property`.
308315

309316
```ruby
310317
class Article < Spira::Base
311-
property :label, :localized => true
318+
property :label, localized: true
312319
end
313320

314321
Spira.repository = RDF::Repository.new
@@ -368,8 +375,8 @@ Classes can now use this particular type like so:
368375

369376
```ruby
370377
class Test < Spira::Base
371-
property :test1, :type => Integer
372-
property :test2, :type => RDF::XSD.integer
378+
property :test1, type: Integer
379+
property :test2, type: RDF::XSD.integer
373380
end
374381
```
375382

@@ -404,7 +411,7 @@ module MyModule
404411
end
405412

406413
class MyClass < Spira::Base
407-
property :property1, :type => MyModule::MyType
414+
property :property1, type: MyModule::MyType
408415
end
409416
```
410417

@@ -467,6 +474,10 @@ All model objects are fully-functional as `RDF::Enumerable`, `RDF::Queryable`,
467474
and `RDF::Mutable`. This lets you manipulate objects on the RDF statement
468475
level. You can also access attributes that are not defined as properties.
469476

477+
## Documentation
478+
479+
<https://www.rubydoc.info/github/ruby-rdf/spira>
480+
470481
## Support
471482

472483
There are a number of ways to ask for help. In declining order of preference:

Rakefile

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,18 @@ require 'rspec/core/rake_task'
44
require 'bundler/gem_tasks'
55
require 'yard'
66

7+
namespace :gem do
8+
desc "Build the spira-#{File.read('VERSION').chomp}.gem file"
9+
task :build do
10+
sh "gem build spira.gemspec && mv spira-#{File.read('VERSION').chomp}.gem pkg/"
11+
end
12+
13+
desc "Release the spira-#{File.read('VERSION').chomp}.gem file"
14+
task :release do
15+
sh "gem push pkg/spira-#{File.read('VERSION').chomp}.gem"
16+
end
17+
end
18+
719
YARD::Rake::YardocTask.new
820

921
desc 'Run specs'
@@ -35,7 +47,7 @@ task :console do
3547
sh "irb -rubygems -I lib -r spira -I spec/fixtures -r person -r event -r cds -r cars -r posts -I spec -r spec_helper -r loading"
3648
end
3749

38-
task :default => [:spec]
50+
task default: [:spec]
3951

4052
desc "Add analytics tracking information to yardocs"
4153
task :addanalytics do
@@ -64,6 +76,6 @@ EOC
6476
end
6577

6678
desc "Upload docs to rubyforge"
67-
task :uploadyardocs => [:yardoc, :addanalytics] do
79+
task uploadyardocs: [:yardoc, :addanalytics] do
6880
`rsync -av doc/yard/* bhuga@rubyforge.org:/var/www/gforge-projects/spira`
6981
end

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
3.1.0
1+
3.1.1

lib/spira.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
require "promise"
44
require "spira/exceptions"
55
require "spira/utils"
6+
require "rdf/vocab"
67

78
##
89
# Spira is a framework for building projections of RDF data into Ruby classes.

lib/spira/base.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ def inherited(child)
9393
end
9494

9595
def instantiate_record(subj)
96-
new(:_subject => id_for(subj))
96+
new(_subject: id_for(subj))
9797
end
9898

9999
end # class methods
@@ -260,7 +260,7 @@ def to_node
260260
# @param [RDF::Resource] new_subject
261261
# @return [Spira::Base] copy
262262
def copy(new_subject)
263-
self.class.new(@attrs.merge(:_subject => new_subject))
263+
self.class.new(@attrs.merge(_subject: new_subject))
264264
end
265265

266266
##
@@ -336,7 +336,7 @@ def merge_localized_property(name, arg)
336336
end
337337

338338
def serialize_localized_property(value, locale)
339-
RDF::Literal.new(value, :language => locale)
339+
RDF::Literal.new(value, language: locale)
340340
end
341341

342342
def unserialize_localized_properties(values, locale)
@@ -352,7 +352,7 @@ def hash_localized_properties(values)
352352
end
353353

354354
def serialize_hash_localized_properties(values)
355-
values.map { |lang, property| RDF::Literal.new(property, :language => lang) }
355+
values.map { |lang, property| RDF::Literal.new(property, language: lang) }
356356
end
357357

358358
# Build a Ruby value from an RDF value.

0 commit comments

Comments
 (0)