From 973845b9b8756f7a678f9be5c5e13de176f9e24f Mon Sep 17 00:00:00 2001 From: "E. Lynette Rayle" Date: Thu, 14 Apr 2016 16:29:48 -0400 Subject: [PATCH] FIX ruby 2.0 const_defined? "A::B" error --- lib/ld4l/open_annotation_rdf/annotation.rb | 2 +- lib/ld4l/open_annotation_rdf/comment_annotation.rb | 2 +- .../open_annotation_rdf/semantic_tag_annotation.rb | 2 +- lib/ld4l/open_annotation_rdf/tag_annotation.rb | 2 +- spec/ld4l/open_annotation_rdf/comment_body_spec.rb | 12 ++++++------ .../open_annotation_rdf/semantic_tag_body_spec.rb | 2 +- spec/ld4l/open_annotation_rdf/tag_body_spec.rb | 2 +- 7 files changed, 12 insertions(+), 12 deletions(-) diff --git a/lib/ld4l/open_annotation_rdf/annotation.rb b/lib/ld4l/open_annotation_rdf/annotation.rb index 40d8910..5d91102 100644 --- a/lib/ld4l/open_annotation_rdf/annotation.rb +++ b/lib/ld4l/open_annotation_rdf/annotation.rb @@ -23,7 +23,7 @@ def self.resume(uri_or_str) # get motivatedBy m = a.get_values(:motivatedBy) - m = m.to_a if Object.const_defined?("ActiveTriples::Relation") && m.kind_of?(ActiveTriples::Relation) + m = m.to_a if Object::ActiveTriples.const_defined?("Relation") && m.kind_of?(ActiveTriples::Relation) # TODO: Should m's class be validated? I've seen it be RDF::Vocabulary::Term and RDF::URI. For now, removing the validation. return a unless m.kind_of?(Array) && m.size > 0 diff --git a/lib/ld4l/open_annotation_rdf/comment_annotation.rb b/lib/ld4l/open_annotation_rdf/comment_annotation.rb index 39d3f6a..23ab15f 100644 --- a/lib/ld4l/open_annotation_rdf/comment_annotation.rb +++ b/lib/ld4l/open_annotation_rdf/comment_annotation.rb @@ -53,7 +53,7 @@ def initialize(*args) # set motivatedBy m = get_values(:motivatedBy) - m = m.to_a if Object.const_defined?("ActiveTriples::Relation") && m.kind_of?(ActiveTriples::Relation) + m = m.to_a if Object::ActiveTriples.const_defined?("Relation") && m.kind_of?(ActiveTriples::Relation) set_value(:motivatedBy, RDFVocabularies::OA.commenting) unless m.kind_of?(Array) && m.size > 0 # resume CommentBody if it exists diff --git a/lib/ld4l/open_annotation_rdf/semantic_tag_annotation.rb b/lib/ld4l/open_annotation_rdf/semantic_tag_annotation.rb index 97ef067..6ab7ab0 100644 --- a/lib/ld4l/open_annotation_rdf/semantic_tag_annotation.rb +++ b/lib/ld4l/open_annotation_rdf/semantic_tag_annotation.rb @@ -59,7 +59,7 @@ def initialize(*args) # set motivatedBy m = get_values(:motivatedBy) - m = m.to_a if Object.const_defined?("ActiveTriples::Relation") && m.kind_of?(ActiveTriples::Relation) + m = m.to_a if Object::ActiveTriples.const_defined?("Relation") && m.kind_of?(ActiveTriples::Relation) set_value(:motivatedBy, RDFVocabularies::OA.tagging) unless m.kind_of?(Array) && m.size > 0 # resume SemanticTagBody if it exists diff --git a/lib/ld4l/open_annotation_rdf/tag_annotation.rb b/lib/ld4l/open_annotation_rdf/tag_annotation.rb index 50b01c2..60b8c1a 100644 --- a/lib/ld4l/open_annotation_rdf/tag_annotation.rb +++ b/lib/ld4l/open_annotation_rdf/tag_annotation.rb @@ -102,7 +102,7 @@ def initialize(*args) # set motivatedBy m = get_values(:motivatedBy) - m = m.to_a if Object.const_defined?("ActiveTriples::Relation") && m.kind_of?(ActiveTriples::Relation) + m = m.to_a if Object::ActiveTriples.const_defined?("Relation") && m.kind_of?(ActiveTriples::Relation) set_value(:motivatedBy, RDFVocabularies::OA.tagging) unless m.kind_of?(Array) && m.size > 0 # resume TagBody if it exists diff --git a/spec/ld4l/open_annotation_rdf/comment_body_spec.rb b/spec/ld4l/open_annotation_rdf/comment_body_spec.rb index d339144..8a59c22 100644 --- a/spec/ld4l/open_annotation_rdf/comment_body_spec.rb +++ b/spec/ld4l/open_annotation_rdf/comment_body_spec.rb @@ -62,7 +62,7 @@ describe 'type' do it "should be set to text and ContentAsText from new" do expected_results = subject.type - expected_results = expected_results.to_a if Object.const_defined?("ActiveTriples::Relation") && expected_results.kind_of?(ActiveTriples::Relation) + expected_results = expected_results.to_a if subject.respond_to? 'persistence_strategy' # >= ActiveTriples 0.8 expect(expected_results.size).to eq 2 expect(expected_results).to include RDFVocabularies::DCTYPES.Text expect(expected_results).to include RDFVocabularies::CNT.ContentAsText @@ -71,7 +71,7 @@ it "should be settable" do subject.type = RDFVocabularies::DCTYPES.Text expected_results = subject.type - expected_results = expected_results.to_a if Object.const_defined?("ActiveTriples::Relation") && expected_results.kind_of?(ActiveTriples::Relation) + expected_results = expected_results.to_a if subject.respond_to? 'persistence_strategy' # >= ActiveTriples 0.8 expect(expected_results.size).to eq 1 expect(expected_results).to include RDFVocabularies::DCTYPES.Text end @@ -80,7 +80,7 @@ t = [RDFVocabularies::DCTYPES.Text, RDFVocabularies::CNT.ContentAsText] subject.set_value(:type,t) expected_results = subject.type - expected_results = expected_results.to_a if Object.const_defined?("ActiveTriples::Relation") && expected_results.kind_of?(ActiveTriples::Relation) + expected_results = expected_results.to_a if subject.respond_to? 'persistence_strategy' # >= ActiveTriples 0.8 expect(expected_results.size).to eq 2 expect(expected_results).to include RDFVocabularies::DCTYPES.Text expect(expected_results).to include RDFVocabularies::CNT.ContentAsText @@ -90,7 +90,7 @@ subject.type = RDFVocabularies::DCTYPES.Text subject.type = RDFVocabularies::CNT.ContentAsText expected_results = subject.type - expected_results = expected_results.to_a if Object.const_defined?("ActiveTriples::Relation") && expected_results.kind_of?(ActiveTriples::Relation) + expected_results = expected_results.to_a if subject.respond_to? 'persistence_strategy' # >= ActiveTriples 0.8 expect(expected_results.size).to eq 1 expect(expected_results).to include RDFVocabularies::CNT.ContentAsText end @@ -99,7 +99,7 @@ t = [RDFVocabularies::DCTYPES.Text, RDFVocabularies::CNT.ContentAsText] subject.set_value(:type,t) expected_results = subject.type - expected_results = expected_results.to_a if Object.const_defined?("ActiveTriples::Relation") && expected_results.kind_of?(ActiveTriples::Relation) + expected_results = expected_results.to_a if subject.respond_to? 'persistence_strategy' # >= ActiveTriples 0.8 expect(expected_results.size).to eq 2 expect(expected_results).to include RDFVocabularies::DCTYPES.Text expect(expected_results).to include RDFVocabularies::CNT.ContentAsText @@ -109,7 +109,7 @@ t[1] = RDFVocabularies::OA.SemanticTag # dummy type for testing subject.set_value(:type,t) expected_results = subject.type - expected_results = expected_results.to_a if Object.const_defined?("ActiveTriples::Relation") && expected_results.kind_of?(ActiveTriples::Relation) + expected_results = expected_results.to_a if subject.respond_to? 'persistence_strategy' # >= ActiveTriples 0.8 expect(expected_results.size).to eq 2 expect(expected_results).to include RDFVocabularies::OA.Tag expect(expected_results).to include RDFVocabularies::OA.SemanticTag diff --git a/spec/ld4l/open_annotation_rdf/semantic_tag_body_spec.rb b/spec/ld4l/open_annotation_rdf/semantic_tag_body_spec.rb index a5edeaf..bfb3082 100644 --- a/spec/ld4l/open_annotation_rdf/semantic_tag_body_spec.rb +++ b/spec/ld4l/open_annotation_rdf/semantic_tag_body_spec.rb @@ -62,7 +62,7 @@ describe 'type' do it "should be set to text and astext from new" do expected_results = subject.type - expected_results = expected_results.to_a if Object.const_defined?("ActiveTriples::Relation") && expected_results.kind_of?(ActiveTriples::Relation) + expected_results = expected_results.to_a if subject.respond_to? 'persistence_strategy' # >= ActiveTriples 0.8 expect(expected_results.size).to eq 1 expect(expected_results).to include RDFVocabularies::OA.SemanticTag end diff --git a/spec/ld4l/open_annotation_rdf/tag_body_spec.rb b/spec/ld4l/open_annotation_rdf/tag_body_spec.rb index d809125..6659212 100644 --- a/spec/ld4l/open_annotation_rdf/tag_body_spec.rb +++ b/spec/ld4l/open_annotation_rdf/tag_body_spec.rb @@ -62,7 +62,7 @@ describe 'type' do it "should be set to text and astext from new" do expected_results = subject.type - expected_results = expected_results.to_a if Object.const_defined?("ActiveTriples::Relation") && expected_results.kind_of?(ActiveTriples::Relation) + expected_results = expected_results.to_a if subject.respond_to? 'persistence_strategy' # >= ActiveTriples 0.8 expect(expected_results.size).to eq 2 expect(expected_results).to include RDFVocabularies::OA.Tag expect(expected_results).to include RDFVocabularies::CNT.ContentAsText