Skip to content

Commit

Permalink
FIX ruby 2.0 const_defined? "A::B" error
Browse files Browse the repository at this point in the history
  • Loading branch information
elrayle committed Apr 14, 2016
1 parent d2422b5 commit 973845b
Show file tree
Hide file tree
Showing 7 changed files with 12 additions and 12 deletions.
2 changes: 1 addition & 1 deletion lib/ld4l/open_annotation_rdf/annotation.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion lib/ld4l/open_annotation_rdf/comment_annotation.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion lib/ld4l/open_annotation_rdf/semantic_tag_annotation.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion lib/ld4l/open_annotation_rdf/tag_annotation.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 6 additions & 6 deletions spec/ld4l/open_annotation_rdf/comment_body_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion spec/ld4l/open_annotation_rdf/semantic_tag_body_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion spec/ld4l/open_annotation_rdf/tag_body_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 973845b

Please sign in to comment.