diff options
author | Kyrylo Silin <silin@kyrylo.org> | 2018-11-04 00:46:39 +0800 |
---|---|---|
committer | Kyrylo Silin <silin@kyrylo.org> | 2018-11-04 00:46:39 +0800 |
commit | d92f7b38791fb4154f08740817da46cfa98fedeb (patch) | |
tree | a5599414608f619ffe5692ca490292fc96dcfa79 | |
parent | d2de775095e8f6a2d4cb299040a87516a9fd9f3f (diff) | |
download | pry-d92f7b38791fb4154f08740817da46cfa98fedeb.tar.gz |
pry_instance: properly deprecate #{input,output}_array
Without this the warning will actually be printed on every line.
-rw-r--r-- | lib/pry/pry_instance.rb | 24 |
1 files changed, 20 insertions, 4 deletions
diff --git a/lib/pry/pry_instance.rb b/lib/pry/pry_instance.rb index 17d61f85..385f1fda 100644 --- a/lib/pry/pry_instance.rb +++ b/lib/pry/pry_instance.rb @@ -87,17 +87,33 @@ class Pry exec_hook(:when_started, target, options, self) end + @input_array_warn = false # @deprecated Use {#input_ring} instead. def input_array - warn "[DEPRECATED] '#{self.class.name}##{__method__}' is deprecated. " \ - "Use '#{self.class.name}#input_ring' instead." + unless @input_array_warn + loc = caller_locations(1..1).first + warn( + "#{loc.path}:#{loc.lineno}: warning: method #{self.class}##{__method__} " \ + "is deprecated. Use #{self.class}#input_ring instead" + ) + @input_array_warn = true + end + @input_ring end + @output_array_warn = false # @deprecated Use {#output_ring} instead. def output_array - warn "[DEPRECATED] '#{self.class.name}##{__method__}' is deprecated. " \ - "Use '#{self.class.name}#output_ring' instead" + unless @output_array_warn + loc = caller_locations(1..1).first + warn( + "#{loc.path}:#{loc.lineno}: warning: method #{self.class}##{__method__} " \ + "is deprecated. Use #{self.class}#output_ring instead" + ) + @output_array_warn = true + end + @output_ring end |