deprecation 0.0.3 → 0.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -3,9 +3,15 @@ require "active_support/concern"
3
3
 
4
4
  module Deprecation
5
5
 
6
+ class <<self
7
+ attr_accessor :default_deprecation_behavior
8
+ end
9
+
10
+ self.default_deprecation_behavior = :stderr
11
+
6
12
  # Returns the current behavior or if one isn't set, defaults to +:stderr+
7
13
  def deprecation_behavior
8
- @deprecation_behavior ||= [Deprecation.behaviors(self)[:stderr]]
14
+ @deprecation_behavior ||= [Deprecation.behaviors(self)[Deprecation.default_deprecation_behavior]]
9
15
  end
10
16
 
11
17
  # Sets the behavior to the specified value. Can be a single value, array, or
@@ -1,5 +1,6 @@
1
1
  module Deprecation
2
2
  class << self
3
+ attr_accessor :show_full_callstack
3
4
  # Outputs a deprecation warning to the output configured by <tt>ActiveSupport::Deprecation.behavior</tt>
4
5
  #
5
6
  # Deprecation.warn("something broke!")
@@ -56,6 +57,9 @@ module Deprecation
56
57
  end
57
58
 
58
59
  def deprecation_caller_message(callstack)
60
+ if Deprecation.show_full_callstack
61
+ return "(Callstack: #{callstack.join "\n\t"})"
62
+ end
59
63
  file, line, method = extract_callstack(callstack)
60
64
  if file
61
65
  if line && method
@@ -1,3 +1,3 @@
1
1
  module Deprecation
2
- VERSION = "0.0.3"
2
+ VERSION = "0.0.5"
3
3
  end
@@ -59,4 +59,19 @@ describe Deprecation do
59
59
  expect { subject.e }.to raise_error /e is deprecated and will be removed from asdf 1.4/
60
60
  end
61
61
  end
62
+
63
+ describe "full callstack" do
64
+ before(:all) do
65
+ Deprecation.show_full_callstack = true
66
+ end
67
+
68
+ after(:all) do
69
+ Deprecation.show_full_callstack = false
70
+ end
71
+
72
+ it "should" do
73
+ expect { subject.a }.to raise_error /Callstack:/
74
+ end
75
+
76
+ end
62
77
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: deprecation
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.5
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-05-30 00:00:00.000000000 Z
12
+ date: 2012-06-12 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activesupport
@@ -108,7 +108,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
108
108
  version: '0'
109
109
  segments:
110
110
  - 0
111
- hash: -2973133465478962044
111
+ hash: -2491741378934253569
112
112
  required_rubygems_version: !ruby/object:Gem::Requirement
113
113
  none: false
114
114
  requirements: