Skip to content

Commit

Permalink
Finish 3.1.1
Browse files Browse the repository at this point in the history
  • Loading branch information
gkellogg committed Dec 16, 2019
2 parents 1aa855f + bf18275 commit acf4ad5
Show file tree
Hide file tree
Showing 74 changed files with 464 additions and 345 deletions.
108 changes: 108 additions & 0 deletions .byebug_history
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
c
subject.query({subject: Cars.car3, predicate: RDF.type, object: Cars.car})
subject.query({subject: Cars.car3, predicate: RDF.type, object: Cars.car3})
subject.query({subject: Cars.car3, predicate: RDF.type}).to_a
subject.query({subject: Cars.car2}).to_a
subject.query({subject: Cars.car2, predicate: RDF.type}).to_a
subject.query({subject: Cars.car2, predicate: RDF.type})
subject.query({subject: Cars.car2, predicate: RDF.type, object: Cars.car3})
subject.query({subject: Cars.car2, predicate: RDF.type, object: Cars.car})
Cars.car3.attributes
Cars.car3
car3.attributes
puts subject.dump(:ttl)
subject.count
subject
c
objects
n
options[:predicate]
n
name
n
s
sts.to_a
sts
n
s
n
s
person.attributes
person
c
p.attributes
n
exit
props
n
s
Person.new(name: "Dick").attributes
friend.attributes
friend
exit
self.class.repository.dump(:ttl)
self.class.repository
self.class.repository.query({subject: subject}).to_a
s
n
s
c
sts.to_a
sts
name
sts.to_a
sts
objects
n
options
s
n
s
n
s
exit
self.class.properties
options
options[:predicate]
n
options
name
s
self.class.properties
sts
n
s
attributes
n
s
attributes
n
s
c
props
self.attributes
self
n
s
c
person.attributes
person
person.name
person.reload
person.reolad
c
person
n
value
n
@attrs[name]
n
s
self.class.properties[name]
self.class.properties
n
name
s
name
n
s
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,4 @@ gems.tags
Gemfile.lock
bin/
/.bundle/
/releases
11 changes: 4 additions & 7 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,18 +1,15 @@
language: ruby
bundler_args: --without debug
script: "bundle exec rake spec"
before_install: "gem update --system"
env:
- CI=true
rvm:
- 2.2
- 2.3
- 2.4
- 2.5
- jruby-9
- rbx-3
- 2.6
- 2.7
- jruby
matrix:
allow_failures:
- rvm: jruby-9
- rvm: rbx-3
- rvm: jruby
sudo: false
10 changes: 3 additions & 7 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ gem 'rdf', github: "ruby-rdf/rdf", branch: "develop"

group :development, :test do
gem 'ebnf', github: "dryruby/ebnf", branch: "develop"
gem 'json-ld', github: "ruby-rdf/json-ld", branch: "develop"
gem 'rdf-isomorphic', github: "ruby-rdf/rdf-isomorphic", branch: "develop"
gem 'rdf-spec', github: "ruby-rdf/rdf-spec", branch: "develop"
gem 'rdf-turtle', github: "ruby-rdf/rdf-turtle", branch: "develop"
Expand All @@ -17,14 +18,9 @@ group :development, :test do
end

group :test do
gem 'coveralls', :require => false
gem 'simplecov', '~> 0.10', :require => false
gem 'simplecov', platforms: :mri
gem 'coveralls', '~> 0.8', platforms: :mri
gem 'guard' #, '~> 2.13.0'
gem 'guard-rspec' #, '~> 3.1.0'
gem 'guard-ctags-bundler' #, '~> 1.4.0'
end

#group :debug do
# gem "debugger", :platforms => [:mri_19, :mri_20]
# gem "ruby-debug", :platforms => [:jruby]
#end
2 changes: 1 addition & 1 deletion Guardfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
guard "ctags-bundler", :emacs => true do
guard "ctags-bundler", emacs: true do
watch(/^(lib|spec\/support)\/.*\.rb$/)
watch("Gemfile.lock")
end
Expand Down
49 changes: 30 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,15 @@ A changelog is available in the {file:CHANGES.md} file.
### Example

```ruby
require 'spira'
require 'rdf/vocab'

class Person < Spira::Base

configure :base_uri => "http://example.org/example/people"
configure base_uri: "http://example.org/example/people"

property :name, :predicate => RDF::Vocab::FOAF.name, :type => String
property :age, :predicate => RDF::Vocab::FOAF.age, :type => Integer
property :name, predicate: RDF::Vocab::FOAF.name, type: String
property :age, predicate: RDF::Vocab::FOAF.age, type: Integer

end

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

```ruby
require 'spira'
require 'rdf/vocab'

class CD < Spira::Base
configure :base_uri => 'http://example.org/cds'
property :name, :predicate => RDF::Vocab::DC.title, :type => XSD.string
property :artist, :predicate => RDF::URI.new('http://example.org/vocab/artist'), :type => :artist
configure base_uri: 'http://example.org/cds'
property :name, predicate: RDF::Vocab::DC.title, type: XSD.string
property :artist, predicate: RDF::URI.new('http://example.org/vocab/artist'), type: :artist
end

class Artist < Spira::Base
configure :base_uri => 'http://example.org/artists'
property :name, :predicate => RDF::Vocab::DC.title, :type => XSD.string
has_many :cds, :predicate => RDF::URI.new('http://example.org/vocab/published_cd'), :type => XSD.string
configure base_uri: 'http://example.org/artists'
property :name, predicate: RDF::Vocab::DC.title, type: XSD.string
has_many :cds, predicate: RDF::URI.new('http://example.org/vocab/published_cd'), type: XSD.string
end
```

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

```ruby
require 'spira'
require 'rdf/vocab'

class Album < Spira::Base
type RDF::URI.new('http://example.org/types/album')
property :name, :predicate => RDF::Vocab::DC.title
property :name, predicate: RDF::Vocab::DC.title
end

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

```ruby
class Song < Spira::Base
configure :default_vocabulary => RDF::URI.new('http://example.org/vocab'),
:base_uri => 'http://example.org/songs'
configure default_vocabulary: RDF::URI.new('http://example.org/vocab'),
base_uri: 'http://example.org/songs'
property :title
property :author, :type => :artist
property :author, type: :artist
end

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

```ruby
property :artist, :type => :artist #=> cd.artist returns a single value
has_many :cds, :type => :cd #=> artist.cds returns an array
property :artist, type: :artist #=> cd.artist returns a single value
has_many :cds, type: :cd #=> artist.cds returns an array
```

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

```ruby
class Article < Spira::Base
property :label, :localized => true
property :label, localized: true
end

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

```ruby
class Test < Spira::Base
property :test1, :type => Integer
property :test2, :type => RDF::XSD.integer
property :test1, type: Integer
property :test2, type: RDF::XSD.integer
end
```

Expand Down Expand Up @@ -404,7 +411,7 @@ module MyModule
end

class MyClass < Spira::Base
property :property1, :type => MyModule::MyType
property :property1, type: MyModule::MyType
end
```

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

## Documentation

<https://www.rubydoc.info/github/ruby-rdf/spira>

## Support

There are a number of ways to ask for help. In declining order of preference:
Expand Down
16 changes: 14 additions & 2 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,18 @@ require 'rspec/core/rake_task'
require 'bundler/gem_tasks'
require 'yard'

namespace :gem do
desc "Build the spira-#{File.read('VERSION').chomp}.gem file"
task :build do
sh "gem build spira.gemspec && mv spira-#{File.read('VERSION').chomp}.gem pkg/"
end

desc "Release the spira-#{File.read('VERSION').chomp}.gem file"
task :release do
sh "gem push pkg/spira-#{File.read('VERSION').chomp}.gem"
end
end

YARD::Rake::YardocTask.new

desc 'Run specs'
Expand Down Expand Up @@ -35,7 +47,7 @@ task :console do
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"
end

task :default => [:spec]
task default: [:spec]

desc "Add analytics tracking information to yardocs"
task :addanalytics do
Expand Down Expand Up @@ -64,6 +76,6 @@ EOC
end

desc "Upload docs to rubyforge"
task :uploadyardocs => [:yardoc, :addanalytics] do
task uploadyardocs: [:yardoc, :addanalytics] do
`rsync -av doc/yard/* bhuga@rubyforge.org:/var/www/gforge-projects/spira`
end
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3.1.0
3.1.1
1 change: 1 addition & 0 deletions lib/spira.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
require "promise"
require "spira/exceptions"
require "spira/utils"
require "rdf/vocab"

##
# Spira is a framework for building projections of RDF data into Ruby classes.
Expand Down
8 changes: 4 additions & 4 deletions lib/spira/base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ def inherited(child)
end

def instantiate_record(subj)
new(:_subject => id_for(subj))
new(_subject: id_for(subj))
end

end # class methods
Expand Down Expand Up @@ -260,7 +260,7 @@ def to_node
# @param [RDF::Resource] new_subject
# @return [Spira::Base] copy
def copy(new_subject)
self.class.new(@attrs.merge(:_subject => new_subject))
self.class.new(@attrs.merge(_subject: new_subject))
end

##
Expand Down Expand Up @@ -336,7 +336,7 @@ def merge_localized_property(name, arg)
end

def serialize_localized_property(value, locale)
RDF::Literal.new(value, :language => locale)
RDF::Literal.new(value, language: locale)
end

def unserialize_localized_properties(values, locale)
Expand All @@ -352,7 +352,7 @@ def hash_localized_properties(values)
end

def serialize_hash_localized_properties(values)
values.map { |lang, property| RDF::Literal.new(property, :language => lang) }
values.map { |lang, property| RDF::Literal.new(property, language: lang) }
end

# Build a Ruby value from an RDF value.
Expand Down
Loading

0 comments on commit acf4ad5

Please sign in to comment.