From 52c72c50ed25b40e3b4bf62ee9570cdb96b238bf Mon Sep 17 00:00:00 2001 From: Tom Johnson Date: Wed, 1 Feb 2017 13:22:01 -0800 Subject: [PATCH] Remove `schemas` from app Replaces `app` schemas with those in `lib`. This breaks backward compatibility for any clients referring directly to the schema constants. It's otherwise a simple refactor. --- app/models/control.rb | 2 +- app/models/dataset.rb | 3 ++- app/models/result.rb | 2 +- app/models/template.rb | 3 ++- app/schemas/control_schema.rb | 4 ---- app/schemas/dataset_schema.rb | 10 ---------- app/schemas/result_schema.rb | 14 -------------- app/schemas/template_schema.rb | 4 ---- spec/models/control_spec.rb | 2 +- spec/models/dataset_spec.rb | 2 +- spec/models/result_spec.rb | 2 +- spec/models/template_spec.rb | 2 +- 12 files changed, 10 insertions(+), 40 deletions(-) delete mode 100644 app/schemas/control_schema.rb delete mode 100644 app/schemas/dataset_schema.rb delete mode 100644 app/schemas/result_schema.rb delete mode 100644 app/schemas/template_schema.rb diff --git a/app/models/control.rb b/app/models/control.rb index cdf92fe..dc9433e 100644 --- a/app/models/control.rb +++ b/app/models/control.rb @@ -1,4 +1,4 @@ class Control include ActiveTriples::RDFSource - apply_schema ControlSchema + apply_schema LinkedDataFragments::ControlSchema end diff --git a/app/models/dataset.rb b/app/models/dataset.rb index ec08ac4..9922afd 100644 --- a/app/models/dataset.rb +++ b/app/models/dataset.rb @@ -8,5 +8,6 @@ class Dataset RDF::URI.intern("http://www.w3.org/ns/hydra/core#Collection"), RDF::Vocab::VOID.Dataset ] - apply_schema DatasetSchema + + apply_schema LinkedDataFragments::DatasetSchema end diff --git a/app/models/result.rb b/app/models/result.rb index c4ca318..5868829 100644 --- a/app/models/result.rb +++ b/app/models/result.rb @@ -4,6 +4,6 @@ class Result RDF::URI("http://www.w3.org/ns/hydra/core#Collection"), RDF::URI("http://www.w3.org/ns/hydra/core#PagedCollection") ] - apply_schema ResultSchema + apply_schema LinkedDataFragments::ResultSchema end diff --git a/app/models/template.rb b/app/models/template.rb index 62dcbdc..5664aa7 100644 --- a/app/models/template.rb +++ b/app/models/template.rb @@ -1,4 +1,5 @@ class Template < ActiveTriples::Resource include ActiveTriples::RDFSource - apply_schema TemplateSchema + + apply_schema LinkedDataFragments::TemplateSchema end diff --git a/app/schemas/control_schema.rb b/app/schemas/control_schema.rb deleted file mode 100644 index 1825836..0000000 --- a/app/schemas/control_schema.rb +++ /dev/null @@ -1,4 +0,0 @@ -class ControlSchema < ActiveTriples::Schema - property :variable, :predicate => RDF::Vocab::HYDRA.variable - property :property, :predicate => RDF::Vocab::HYDRA.property, :cast => false -end diff --git a/app/schemas/dataset_schema.rb b/app/schemas/dataset_schema.rb deleted file mode 100644 index 6efa3f2..0000000 --- a/app/schemas/dataset_schema.rb +++ /dev/null @@ -1,10 +0,0 @@ -## -# 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 diff --git a/app/schemas/result_schema.rb b/app/schemas/result_schema.rb deleted file mode 100644 index 25a8702..0000000 --- a/app/schemas/result_schema.rb +++ /dev/null @@ -1,14 +0,0 @@ -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 diff --git a/app/schemas/template_schema.rb b/app/schemas/template_schema.rb deleted file mode 100644 index 613494c..0000000 --- a/app/schemas/template_schema.rb +++ /dev/null @@ -1,4 +0,0 @@ -class TemplateSchema < ActiveTriples::Schema - property :template, :predicate => RDF::Vocab::HYDRA.search - property :mapping, :predicate => RDF::Vocab::HYDRA.mapping -end diff --git a/spec/models/control_spec.rb b/spec/models/control_spec.rb index e408cb9..d91eaea 100644 --- a/spec/models/control_spec.rb +++ b/spec/models/control_spec.rb @@ -4,7 +4,7 @@ subject { described_class.new } it "should apply the control schema" do - ControlSchema.properties.each do |property| + LinkedDataFragments::ControlSchema.properties.each do |property| expect(subject.class.properties[property.name.to_s].predicate).to eq property.predicate end end diff --git a/spec/models/dataset_spec.rb b/spec/models/dataset_spec.rb index 8d79702..3299e8f 100644 --- a/spec/models/dataset_spec.rb +++ b/spec/models/dataset_spec.rb @@ -14,7 +14,7 @@ end it "should apply the dataset schema" do - DatasetSchema.properties.each do |property| + LinkedDataFragments::DatasetSchema.properties.each do |property| expect(subject.class.properties[property.name.to_s].predicate).to eq property.predicate end end diff --git a/spec/models/result_spec.rb b/spec/models/result_spec.rb index 9ef1d88..26e9bd0 100644 --- a/spec/models/result_spec.rb +++ b/spec/models/result_spec.rb @@ -19,7 +19,7 @@ end it "should apply the Result schema" do - ResultSchema.properties.each do |property| + LinkedDataFragments::ResultSchema.properties.each do |property| expect(subject.class.properties[property.name.to_s].predicate).to eq property.predicate end end diff --git a/spec/models/template_spec.rb b/spec/models/template_spec.rb index 03fdeda..e1370e5 100644 --- a/spec/models/template_spec.rb +++ b/spec/models/template_spec.rb @@ -5,7 +5,7 @@ let(:uri) { RDF::Node.new("triplePattern") } it "should apply the template schema" do - TemplateSchema.properties.each do |property| + LinkedDataFragments::TemplateSchema.properties.each do |property| expect(subject.class.properties[property.name.to_s].predicate).to eq property.predicate end end