-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #39 from ActiveTriples/feature/refactor-schemas
Refactor Schemas into LinkedDataFragments Namespace
- Loading branch information
Showing
26 changed files
with
161 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
# A sample Guardfile | ||
# More info at https://github.com/guard/guard#readme | ||
|
||
## Uncomment and set this to only include directories you want to watch | ||
# directories %w(app lib config test spec features) \ | ||
# .select{|d| Dir.exists?(d) ? d : UI.warning("Directory #{d} does not exist")} | ||
|
||
## Note: if you are using the `directories` clause above and you are not | ||
## watching the project directory ('.'), then you will want to move | ||
## the Guardfile to a watched dir and symlink it back, e.g. | ||
# | ||
# $ mkdir config | ||
# $ mv Guardfile config/ | ||
# $ ln -s config/Guardfile . | ||
# | ||
# and, you'll have to watch "config/Guardfile" instead of "Guardfile" | ||
|
||
# Using -W0 to suppress warnings in automatic test runs | ||
guard :rspec, cmd: 'RUBYOPT="-W0" bundle exec rspec' do | ||
require 'guard/rspec/dsl' | ||
dsl = Guard::RSpec::Dsl.new(self) | ||
|
||
# Feel free to open issues for suggestions and improvements | ||
|
||
# RSpec files | ||
rspec = dsl.rspec | ||
watch(rspec.spec_helper) { rspec.spec_dir } | ||
watch(rspec.spec_support) { rspec.spec_dir } | ||
watch(rspec.spec_files) | ||
|
||
# Ruby files | ||
ruby = dsl.ruby | ||
dsl.watch_spec_files_for(ruby.lib_files) | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
class Control | ||
include ActiveTriples::RDFSource | ||
apply_schema ControlSchema | ||
apply_schema LinkedDataFragments::ControlSchema | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
class Template < ActiveTriples::Resource | ||
include ActiveTriples::RDFSource | ||
apply_schema TemplateSchema | ||
|
||
apply_schema LinkedDataFragments::TemplateSchema | ||
end |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
require 'active_triples' | ||
|
||
# must require 'rdf/vocab' first, due to const_missing metaprogramming in | ||
# pre-2.0 verisons | ||
require 'rdf/vocab' | ||
require 'rdf/vocab/hydra' | ||
require 'rdf/vocab/void' | ||
|
||
require 'linked_data_fragments/schemas' | ||
|
||
## | ||
# A linked data caching fragment | ||
module LinkedDataFragments | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
require 'linked_data_fragments/schemas/control_schema' | ||
require 'linked_data_fragments/schemas/dataset_schema' | ||
require 'linked_data_fragments/schemas/result_schema' | ||
require 'linked_data_fragments/schemas/template_schema' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
module LinkedDataFragments | ||
## | ||
# A HydraCore control schema | ||
class ControlSchema < ActiveTriples::Schema | ||
property :variable, :predicate => RDF::Vocab::HYDRA.variable | ||
property :property, :predicate => RDF::Vocab::HYDRA.property, :cast => false | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
module LinkedDataFragments | ||
## | ||
# A schema for `hydracore:Collection`/`Dataset` nodes. | ||
class DatasetSchema < ActiveTriples::Schema | ||
property :subset, predicate: RDF::VOID.subset | ||
property :uri_lookup_endpoint, predicate: RDF::VOID.uriLookupEndpoint | ||
|
||
# Change search so that it points to a search node. | ||
property :search, predicate: RDF::URI.intern("http://www.w3.org/ns/hydra/core#search") | ||
property :member, predicate: RDF::URI.intern("http://www.w3.org/ns/hydra/core#member") | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
module LinkedDataFragments | ||
## | ||
# Schema for Result model | ||
class ResultSchema < ActiveTriples::Schema | ||
property :subset, :predicate => RDF::VOID.subset | ||
|
||
# Descriptive | ||
property :title, :predicate => RDF::Vocab::DC.title | ||
property :description, :predicate => RDF::Vocab::DC.description | ||
property :source, :predicate => RDF::Vocab::DC.source | ||
|
||
# Pagination | ||
property :triples_count, :predicate => RDF::Vocab::VOID.triples | ||
property :total_items, :predicate => RDF::URI("http://www.w3.org/ns/hydra/core#totalItems") | ||
property :items_per_page, :predicate => RDF::URI("http://www.w3.org/ns/hydra/core#itemsPerPage") | ||
property :first_page, :predicate => RDF::URI("http://www.w3.org/ns/hydra/core#firstPage") | ||
end | ||
end | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
module LinkedDataFragments | ||
## | ||
# Schema for template models | ||
class TemplateSchema < ActiveTriples::Schema | ||
property :template, :predicate => RDF::Vocab::HYDRA.search | ||
property :mapping, :predicate => RDF::Vocab::HYDRA.mapping | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
require 'spec_helper' | ||
|
||
describe LinkedDataFragments::ControlSchema do | ||
it_behaves_like 'a schema', [:variable, :property] | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
require 'spec_helper' | ||
|
||
describe LinkedDataFragments::DatasetSchema do | ||
it_behaves_like 'a schema', [:subset, :uri_lookup_endpoint, :search, :member] | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
require 'spec_helper' | ||
|
||
describe LinkedDataFragments::ResultSchema do | ||
it_behaves_like 'a schema', [:subset, | ||
:title, | ||
:description, | ||
:source, | ||
:triples_count, | ||
:total_items, | ||
:items_per_page, | ||
:first_page | ||
] | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
require 'spec_helper' | ||
|
||
describe LinkedDataFragments::TemplateSchema do | ||
it_behaves_like 'a schema', [:template, :mapping] | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
shared_examples 'a schema' do |properties| | ||
let(:fake_source) do | ||
klass = Class.new { include ActiveTriples::RDFSource } | ||
klass.apply_schema described_class | ||
klass | ||
end | ||
|
||
let(:source) { fake_source.new } | ||
let(:value) { :moomin } | ||
|
||
properties.each do |property| | ||
it "has configured property #{property}" do | ||
expect { source.send("#{property}=".to_sym, value) } | ||
.to change { source.send(property).to_a } | ||
.to contain_exactly(value) | ||
end | ||
end | ||
end |