Skip to content

Commit

Permalink
Finish 3.3.0
Browse files Browse the repository at this point in the history
  • Loading branch information
gkellogg committed Sep 1, 2023
2 parents fd6483f + b97c892 commit a94752e
Show file tree
Hide file tree
Showing 30 changed files with 96 additions and 70 deletions.
14 changes: 4 additions & 10 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,10 @@ jobs:
strategy:
fail-fast: false
matrix:
ruby:
- 2.6
- 2.7
- 3.0
- 3.1
- ruby-head
- jruby
ruby: ['3.0', 3.1, 3.2, ruby-head, jruby]
steps:
- name: Clone repository
uses: actions/checkout@v2
uses: actions/checkout@v3
- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
Expand All @@ -38,7 +32,7 @@ jobs:
- name: Run tests
run: ruby --version; bundle exec rspec spec || $ALLOW_FAILURES
- name: Coveralls GitHub Action
uses: coverallsapp/github-action@v1.1.2
if: "matrix.ruby == '3.0'"
uses: coverallsapp/github-action@v2
if: "matrix.ruby == '3.2'"
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
27 changes: 27 additions & 0 deletions .github/workflows/generate-docs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: Build & deploy documentation
on:
push:
branches:
- master
workflow_dispatch:
jobs:
build:
runs-on: ubuntu-latest
name: Update gh-pages with docs
steps:
- name: Clone repository
uses: actions/checkout@v3
- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: "3.1"
- name: Install required gem dependencies
run: gem install yard --no-document
- name: Build YARD Ruby Documentation
run: yardoc
- name: Deploy
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./doc/yard
publish_branch: gh-pages
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ group :development, :test do
end

group :test do
gem 'simplecov', '~> 0.21', platforms: :mri
gem 'simplecov', '~> 0.22', platforms: :mri
gem 'simplecov-lcov', '~> 0.8', platforms: :mri
gem 'guard' #, '~> 2.13.0'
gem 'guard-rspec' #, '~> 3.1.0'
Expand Down
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Spira

[![Gem Version](https://badge.fury.io/rb/spira.png)](https://badge.fury.io/rb/spira)
[![Gem Version](https://badge.fury.io/rb/spira.svg)](https://badge.fury.io/rb/spira)
[![Build Status](https://github.com/ruby-rdf/spira/workflows/CI/badge.svg?branch=develop)](https://github.com/ruby-rdf/spira/actions?query=workflow%3ACI)
[![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)
Expand Down Expand Up @@ -226,7 +226,7 @@ end
Spira.repository = RDF::Repository.new

rolling_stones = Album.for RDF::URI.new('http://example.org/cds/rolling-stones-hits')
# See RDF.rb at https://www.rubydoc.info/github/ruby-rdf/rdf/RDF/Enumerable.html for more information about #has_predicate?
# See RDF.rb at https://ruby-rdf.github.io/rdf/RDF/Enumerable.html for more information about #has_predicate?
rolling_stones.has_predicate?(RDF.type) #=> true
Album.type #=> RDF::URI('http://example.org/types/album')
```
Expand Down Expand Up @@ -392,7 +392,7 @@ are implemented:

The default type for a Spira property is `Spira::Types::Any`, which uses
`RDF::Literal`'s automatic boxing/unboxing of XSD types as best it can.
See [`RDF::Literal`](https://www.rubydoc.info/github/ruby-rdf/rdf/RDF/Literal.html) for more information.
See [`RDF::Literal`](https://ruby-rdf.github.io/rdf/RDF/Literal.html) for more information.

You can implement your own types as well. Your class' serialize method should
turn an RDF::Value into a ruby object, and vice versa.
Expand Down Expand Up @@ -477,7 +477,7 @@ level. You can also access attributes that are not defined as properties.

## Documentation

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

## Support

Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3.2.0
3.3.0
10 changes: 5 additions & 5 deletions lib/spira/persistence.rb
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ def create(attributes = nil, options = {}, &block)
# @yield [self] Executes a given block and calls `#save!`
# @yieldparam [self] self The newly created instance
# @return [Spira::Base] The newly created instance
# @see https://www.rubydoc.info/github/ruby-rdf/rdf/RDF/URI.html
# @see https://ruby-rdf.github.io/rdf/RDF/URI.html
def for(identifier, attributes = {}, &block)
self.project(id_for(identifier), attributes, &block)
end
Expand Down Expand Up @@ -205,7 +205,7 @@ def project(subject, attributes = {}, &block)
# @param [Any] identifier
# @return [RDF::URI, RDF::Node]
# @raise [ArgumentError] If this class cannot create an identifier from the given argument
# @see https://www.rubydoc.info/github/ruby-rdf/rdf/RDF/URI.html
# @see https://ruby-rdf.github.io/rdf/RDF/URI.html
# @see Spira.base_uri
# @see Spira.for
def id_for(identifier)
Expand Down Expand Up @@ -303,10 +303,10 @@ def destroy!(*args)
##
# Enumerate each RDF statement that makes up this projection. This makes
# each instance an `RDF::Enumerable`, with all of the nifty benefits
# thereof. See <https://www.rubydoc.info/github/ruby-rdf/rdf/RDF/Enumerable.html> for
# thereof. See <https://ruby-rdf.github.io/rdf/RDF/Enumerable.html> for
# information on arguments.
#
# @see https://www.rubydoc.info/github/ruby-rdf/rdf/RDF/Enumerable.html
# @see https://ruby-rdf.github.io/rdf/RDF/Enumerable.html
def each
if block_given?
self.class.properties.each do |name, property|
Expand All @@ -333,7 +333,7 @@ def each
##
# The number of RDF::Statements this projection has.
#
# @see https://www.rubydoc.info/github/ruby-rdf/rdf/RDF/Enumerable.html#count
# @see https://ruby-rdf.github.io/rdf/RDF/Enumerable.html#count
def count
each.count
end
Expand Down
2 changes: 1 addition & 1 deletion lib/spira/type.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ module Spira
# `Spira::Type`s include the RDF namespace and thus have all of the base RDF
# vocabularies available to them without the `RDF::` prefix.
#
# @see https://www.rubydoc.info/github/ruby-rdf/rdf/RDF/Value.html
# @see https://ruby-rdf.github.io/rdf/RDF/Value.html
# @see Spira::Resource
module Type

Expand Down
2 changes: 1 addition & 1 deletion lib/spira/types/any.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ module Spira::Types
# Its behavior is defined as 'What `RDF::Literal` does' for a given value.
#
# @see Spira::Type
# @see https://www.rubydoc.info/github/ruby-rdf/rdf/RDF/Literal.html
# @see https://ruby-rdf.github.io/rdf/RDF/Literal.html
class Any

include Spira::Type
Expand Down
2 changes: 1 addition & 1 deletion lib/spira/types/anyURI.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ module Spira::Types
# `Spira::Types::AnyURI`, `AnyURI`, or `XSD.anyURI`.
#
# @see Spira::Type
# @see https://www.rubydoc.info/github/ruby-rdf/rdf/RDF/Literal.html
# @see https://ruby-rdf.github.io/rdf/RDF/Literal.html
class AnyURI

include Spira::Type
Expand Down
2 changes: 1 addition & 1 deletion lib/spira/types/boolean.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ module Spira::Types
# `Spira::Types::Boolean`, `Boolean`, or `XSD.boolean`.
#
# @see Spira::Type
# @see https://www.rubydoc.info/github/ruby-rdf/rdf/RDF/Literal.html
# @see https://ruby-rdf.github.io/rdf/RDF/Literal.html
class Boolean

include Spira::Type
Expand Down
2 changes: 1 addition & 1 deletion lib/spira/types/date.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ module Spira::Types
# `Spira::Types::Date`, `Date`, or `XSD.date`.
#
# @see Spira::Type
# @see https://www.rubydoc.info/github/ruby-rdf/rdf/RDF/Literal.html
# @see https://ruby-rdf.github.io/rdf/RDF/Literal.html
class Date
include Spira::Type

Expand Down
2 changes: 1 addition & 1 deletion lib/spira/types/dateTime.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ module Spira::Types
# `Spira::Types::DateTime`, `DateTime`, or `XSD.dateTime`.
#
# @see Spira::Type
# @see https://www.rubydoc.info/github/ruby-rdf/rdf/RDF/Literal.html
# @see https://ruby-rdf.github.io/rdf/RDF/Literal.html
class DateTime
include Spira::Type

Expand Down
2 changes: 1 addition & 1 deletion lib/spira/types/decimal.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ module Spira::Types
# `Spira::Types::Integer`, `Integer`, or `XSD.integer`.
#
# @see Spira::Type
# @see https://www.rubydoc.info/github/ruby-rdf/rdf/RDF/Literal.html
# @see https://ruby-rdf.github.io/rdf/RDF/Literal.html
class Decimal
include Spira::Type

Expand Down
2 changes: 1 addition & 1 deletion lib/spira/types/double.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ module Spira::Types
# `Spira::Types::Double`, `Double`, or `XSD.double`.
#
# @see Spira::Type
# @see https://www.rubydoc.info/github/ruby-rdf/rdf/RDF/Literal.html
# @see https://ruby-rdf.github.io/rdf/RDF/Literal.html
class Double

include Spira::Type
Expand Down
2 changes: 1 addition & 1 deletion lib/spira/types/float.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ module Spira::Types
# `Spira::Types::Float`, `Float`, or `XSD.float`.
#
# @see Spira::Type
# @see https://www.rubydoc.info/github/ruby-rdf/rdf/RDF/Literal.html
# @see https://ruby-rdf.github.io/rdf/RDF/Literal.html
class Float

include Spira::Type
Expand Down
2 changes: 1 addition & 1 deletion lib/spira/types/gYear.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ module Spira::Types
# `Spira::Types::GYear`, `GYear`, or `XSD.gYear`.
#
# @see Spira::Type
# @see https://www.rubydoc.info/github/ruby-rdf/rdf/RDF/Literal.html
# @see https://ruby-rdf.github.io/rdf/RDF/Literal.html
class GYear
include Spira::Type

Expand Down
2 changes: 1 addition & 1 deletion lib/spira/types/int.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ module Spira::Types
# `Spira::Types::Int`, `Int`, or `XSD.int`.
#
# @see Spira::Type
# @see https://www.rubydoc.info/github/ruby-rdf/rdf/RDF/Literal.html
# @see https://ruby-rdf.github.io/rdf/RDF/Literal.html
class Int

include Spira::Type
Expand Down
2 changes: 1 addition & 1 deletion lib/spira/types/integer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ module Spira::Types
# `Spira::Types::Integer`, `Integer`, or `XSD.integer`.
#
# @see Spira::Type
# @see https://www.rubydoc.info/github/ruby-rdf/rdf/RDF/Literal.html
# @see https://ruby-rdf.github.io/rdf/RDF/Literal.html
class Integer

include Spira::Type
Expand Down
2 changes: 1 addition & 1 deletion lib/spira/types/long.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ module Spira::Types
# `Spira::Types::Long`, `Long`, or `XSD.long`.
#
# @see Spira::Type
# @see https://www.rubydoc.info/github/ruby-rdf/rdf/RDF/Literal.html
# @see https://ruby-rdf.github.io/rdf/RDF/Literal.html
class Long

include Spira::Type
Expand Down
2 changes: 1 addition & 1 deletion lib/spira/types/negativeInteger.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ module Spira::Types
# `Spira::Types::NegativeInteger`, `NegativeInteger`, or `XSD.negativeInteger`.
#
# @see Spira::Type
# @see https://www.rubydoc.info/github/ruby-rdf/rdf/RDF/Literal.html
# @see https://ruby-rdf.github.io/rdf/RDF/Literal.html
class NegativeInteger

include Spira::Type
Expand Down
2 changes: 1 addition & 1 deletion lib/spira/types/nonNegativeInteger.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ module Spira::Types
# `Spira::Types::NonNegativeInteger`, `NonNegativeInteger`, or `XSD.nonNegativeInteger`.
#
# @see Spira::Type
# @see https://www.rubydoc.info/github/ruby-rdf/rdf/RDF/Literal.html
# @see https://ruby-rdf.github.io/rdf/RDF/Literal.html
class NonNegativeInteger

include Spira::Type
Expand Down
2 changes: 1 addition & 1 deletion lib/spira/types/nonPositiveInteger.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ module Spira::Types
# `Spira::Types::NonPositiveInteger`, `NonPositiveInteger`, or `XSD.nonPositiveInteger`.
#
# @see Spira::Type
# @see https://www.rubydoc.info/github/ruby-rdf/rdf/RDF/Literal.html
# @see https://ruby-rdf.github.io/rdf/RDF/Literal.html
class NonPositiveInteger

include Spira::Type
Expand Down
2 changes: 1 addition & 1 deletion lib/spira/types/positiveInteger.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ module Spira::Types
# `Spira::Types::PositiveInteger`, `PositiveInteger`, or `XSD.positiveInteger`.
#
# @see Spira::Type
# @see https://www.rubydoc.info/github/ruby-rdf/rdf/RDF/Literal.html
# @see https://ruby-rdf.github.io/rdf/RDF/Literal.html
class PositiveInteger

include Spira::Type
Expand Down
2 changes: 1 addition & 1 deletion lib/spira/types/string.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ module Spira::Types
# `Spira::Types::String`, `String`, or `XSD.string`.
#
# @see Spira::Type
# @see https://www.rubydoc.info/github/ruby-rdf/rdf/RDF/Literal.html
# @see https://ruby-rdf.github.io/rdf/RDF/Literal.html
class String

include Spira::Type
Expand Down
2 changes: 1 addition & 1 deletion lib/spira/types/time.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ module Spira::Types
# `Spira::Types::Time`, `Time`, or `XSD.time`.
#
# @see Spira::Type
# @see https://www.rubydoc.info/github/ruby-rdf/rdf/RDF/Literal.html
# @see https://ruby-rdf.github.io/rdf/RDF/Literal.html
class Time
include Spira::Type

Expand Down
2 changes: 1 addition & 1 deletion lib/spira/types/uri.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ module Spira::Types
# ruby representation.
#
# @see Spira::Type
# @see https://www.rubydoc.info/github/ruby-rdf/rdf/RDF/URI.html
# @see https://ruby-rdf.github.io/rdf/RDF/URI.html
class URI

include Spira::Type
Expand Down
18 changes: 9 additions & 9 deletions spec/querying_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -155,34 +155,34 @@ class ::LoadTest < Spira::Base

it "should not query the repository when loading a parent and not accessing a child" do
name_statements = parent_statements.select {|st| st.predicate == RDF::Vocab::FOAF.name }
expect(repo).to receive(:query).with(subject: uri).once.and_return(name_statements)
expect(repo).to receive(:query).with({subject: uri}).once.and_return(name_statements)

test = uri.as(LoadTest)
test.name
end

it "should query the repository when loading a parent and accessing a field on a child" do
name_statements = parent_statements.select {|st| st.predicate == RDF::Vocab::FOAF.name }
expect(repo).to receive(:query).with(subject: uri).once.and_return(parent_statements)
expect(repo).to receive(:query).with(subject: child_uri).once.and_return(name_statements)
expect(repo).to receive(:query).with({subject: uri}).once.and_return(parent_statements)
expect(repo).to receive(:query).with({subject: child_uri}).once.and_return(name_statements)

test = uri.as(LoadTest)
test.child.name
end

it "should not re-query to access a child twice" do
name_statements = parent_statements.select {|st| st.predicate == RDF::Vocab::FOAF.name }
expect(repo).to receive(:query).with(subject: uri).once.and_return(parent_statements)
expect(repo).to receive(:query).with(subject: child_uri).once.and_return(name_statements)
expect(repo).to receive(:query).with({subject: uri}).once.and_return(parent_statements)
expect(repo).to receive(:query).with({subject: child_uri}).once.and_return(name_statements)

test = uri.as(LoadTest)
2.times { test.child.name }
end

it "should re-query to access a child's parent from the child" do
name_statements = parent_statements.select {|st| st.predicate == RDF::Vocab::FOAF.name }
expect(repo).to receive(:query).with(subject: uri).twice.and_return(parent_statements)
expect(repo).to receive(:query).with(subject: child_uri).once.and_return(child_statements)
expect(repo).to receive(:query).with({subject: uri}).twice.and_return(parent_statements)
expect(repo).to receive(:query).with({subject: child_uri}).once.and_return(child_statements)

test = uri.as(LoadTest)
3.times do
Expand All @@ -193,8 +193,8 @@ class ::LoadTest < Spira::Base
it "should re-query for children after a #reload" do
parent_name_statements = parent_statements.select {|st| st.predicate == RDF::Vocab::FOAF.name }
child_name_statements = child_statements.select {|st| st.predicate == RDF::Vocab::FOAF.name }
expect(repo).to receive(:query).with(subject: uri).exactly(4).times.and_return(parent_statements)
expect(repo).to receive(:query).with(subject: child_uri).twice.and_return(child_statements)
expect(repo).to receive(:query).with({subject: uri}).exactly(4).times.and_return(parent_statements)
expect(repo).to receive(:query).with({subject: child_uri}).twice.and_return(child_statements)

test = uri.as(LoadTest)
expect(test.child.child.name).to eql "a name"
Expand Down
2 changes: 1 addition & 1 deletion spec/types/date_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
context "when unserializing" do
it "should unserialize XSD dates to dates" do
value = Spira::Types::Date.unserialize(RDF::Literal.new(@date, datatype: RDF::XSD.date))
expect(value).to equal @date
expect(value).to eql @date
end
end

Expand Down
Loading

0 comments on commit a94752e

Please sign in to comment.