Skip to content

Commit 5a872b5

Browse files
committed
Generate deprecation warnings only if class is actually included, not when the file is loaded.
1 parent ca295af commit 5a872b5

14 files changed

Lines changed: 56 additions & 28 deletions

lib/rdf/spec/countable.rb

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,10 @@ module RDF_Countable
5252
extend RSpec::SharedContext
5353
include RDF::Spec::Matchers
5454

55-
warn "[DEPRECATION] `RDF_Countable` is deprecated. "\
56-
"Please use `it_behaves_like 'an RDF::Countable'`"
55+
def self.included(mod)
56+
warn "[DEPRECATION] `RDF_Countable` is deprecated. "\
57+
"Please use `it_behaves_like 'an RDF::Countable'`"
58+
end
5759

5860
describe 'examples for' do
5961
include_examples 'an RDF::Countable' do

lib/rdf/spec/durable.rb

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,10 @@ module RDF_Durable
5555
extend RSpec::SharedContext
5656
include RDF::Spec::Matchers
5757

58-
warn "[DEPRECATION] `RDF_Durable` is deprecated. "\
59-
"Please use `it_behaves_like 'an RDF::Durable'`"
58+
def self.included(mod)
59+
warn "[DEPRECATION] `RDF_Durable` is deprecated. "\
60+
"Please use `it_behaves_like 'an RDF::Durable'`"
61+
end
6062

6163
describe 'examples for' do
6264
include_examples 'an RDF::Durable'

lib/rdf/spec/enumerable.rb

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -475,8 +475,10 @@ module RDF_Enumerable
475475
extend RSpec::SharedContext
476476
include RDF::Spec::Matchers
477477

478-
warn "[DEPRECATION] `RDF_Enumerable` is deprecated. "\
479-
"Please use `it_behaves_like 'an RDF::Enumerable'`"
478+
def self.included(mod)
479+
warn "[DEPRECATION] `RDF_Enumerable` is deprecated. "\
480+
"Please use `it_behaves_like 'an RDF::Enumerable'`"
481+
end
480482

481483
describe 'examples for' do
482484
include_examples 'an RDF::Enumerable' do

lib/rdf/spec/format.rb

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,10 @@ module RDF_Format
5858
extend RSpec::SharedContext
5959
include RDF::Spec::Matchers
6060

61-
warn "[DEPRECATION] `RDF_Format` is deprecated. "\
62-
"Please use `it_behaves_like 'an RDF::Format'`"
61+
def self.included(mod)
62+
warn "[DEPRECATION] `RDF_Format` is deprecated. "\
63+
"Please use `it_behaves_like 'an RDF::Format'`"
64+
end
6365

6466
describe 'examples for' do
6567
include_examples 'an RDF::Format' do

lib/rdf/spec/http_adapter.rb

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -276,8 +276,10 @@ module RDF_HttpAdapter
276276
extend RSpec::SharedContext
277277
include RDF::Spec::Matchers
278278

279-
warn "[DEPRECATION] `RDF_HttpAdapter` is deprecated. "\
280-
"Please use `it_behaves_like 'an RDF::HttpAdapter'`"
279+
def self.included(mod)
280+
warn "[DEPRECATION] `RDF_HttpAdapter` is deprecated. "\
281+
"Please use `it_behaves_like 'an RDF::HttpAdapter'`"
282+
end
281283

282284
describe 'examples for' do
283285
include_examples 'an RDF::HttpAdapter' do

lib/rdf/spec/indexable.rb

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,10 @@ module RDF_Indexable
3030
extend RSpec::SharedContext
3131
include RDF::Spec::Matchers
3232

33-
warn "[DEPRECATION] `RDF_Indexable` is deprecated. "\
34-
"Please use `it_behaves_like 'an RDF::Indexable'`"
33+
def self.included(mod)
34+
warn "[DEPRECATION] `RDF_Indexable` is deprecated. "\
35+
"Please use `it_behaves_like 'an RDF::Indexable'`"
36+
end
3537

3638
describe 'examples for' do
3739
include_examples 'an RDF::Indexable' do

lib/rdf/spec/inferable.rb

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,10 @@ module RDF_Inferable
1212
extend RSpec::SharedContext
1313
include RDF::Spec::Matchers
1414

15-
warn "[DEPRECATION] `RDF_Inferable` is deprecated. "\
16-
"Please use `it_behaves_like 'an RDF::Inferable'`"
15+
def self.included(mod)
16+
warn "[DEPRECATION] `RDF_Inferable` is deprecated. "\
17+
"Please use `it_behaves_like 'an RDF::Inferable'`"
18+
end
1719

1820
describe 'examples for' do
1921
include_examples 'an RDF::Inferable'

lib/rdf/spec/mutable.rb

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -150,8 +150,10 @@ module RDF_Mutable
150150
extend RSpec::SharedContext
151151
include RDF::Spec::Matchers
152152

153-
warn "[DEPRECATION] `RDF_Mutable` is deprecated. "\
154-
"Please use `it_behaves_like 'an RDF::Mutable'`"
153+
def self.included(mod)
154+
warn "[DEPRECATION] `RDF_Mutable` is deprecated. "\
155+
"Please use `it_behaves_like 'an RDF::Mutable'`"
156+
end
155157

156158
describe 'examples for' do
157159
include_examples 'an RDF::Mutable' do

lib/rdf/spec/queryable.rb

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -534,8 +534,10 @@ module RDF_Queryable
534534
extend RSpec::SharedContext
535535
include RDF::Spec::Matchers
536536

537-
warn "[DEPRECATION] `RDF_Queryable` is deprecated. "\
538-
"Please use `it_behaves_like 'an RDF::Queryable'`"
537+
def self.included(mod)
538+
warn "[DEPRECATION] `RDF_Queryable` is deprecated. "\
539+
"Please use `it_behaves_like 'an RDF::Queryable'`"
540+
end
539541

540542
describe 'examples for' do
541543
include_examples 'an RDF::Queryable' do

lib/rdf/spec/readable.rb

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,10 @@ module RDF_Readable
2222
extend RSpec::SharedContext
2323
include RDF::Spec::Matchers
2424

25-
warn "[DEPRECATION] `RDF_Readable` is deprecated. "\
26-
"Please use `it_behaves_like 'an RDF::Readable'`"
25+
def self.included(mod)
26+
warn "[DEPRECATION] `RDF_Readable` is deprecated. "\
27+
"Please use `it_behaves_like 'an RDF::Readable'`"
28+
end
2729

2830
describe 'examples for' do
2931
include_examples 'an RDF::Readable' do

0 commit comments

Comments
 (0)