Skip to content

Commit 7eb3fe8

Browse files
committed
Print deprecation message for prompt_n methods
They were removed in #685, but we should still keep them to avoid breaking changes to tools like Chef. https://github.com/chef/chef/blob/533ff089479763f29045e4e6ddf388b73fc99338/lib/chef/shell.rb#L138
1 parent 2ce7593 commit 7eb3fe8

File tree

2 files changed

+25
-0
lines changed

2 files changed

+25
-0
lines changed

lib/irb/context.rb

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,19 @@ def main
229229
#
230230
# See IRB@Customizing+the+IRB+Prompt for more information.
231231
attr_accessor :prompt_c
232+
233+
# TODO: Remove this when developing v2.0
234+
def prompt_n
235+
warn "IRB::Context#prompt_n is deprecated and will be removed in the next major release."
236+
""
237+
end
238+
239+
# TODO: Remove this when developing v2.0
240+
def prompt_n=(_)
241+
warn "IRB::Context#prompt_n= is deprecated and will be removed in the next major release."
242+
""
243+
end
244+
232245
# Can be either the default <code>IRB.conf[:AUTO_INDENT]</code>, or the
233246
# mode set by #prompt_mode=
234247
#

test/irb/test_context.rb

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,18 @@ def test_eval_input_raise2x
9090
], out)
9191
end
9292

93+
def test_prompt_n_deprecation
94+
irb = IRB::Irb.new(IRB::WorkSpace.new(Object.new))
95+
96+
out, err = capture_output do
97+
irb.context.prompt_n = "foo"
98+
irb.context.prompt_n
99+
end
100+
101+
assert_include err, "IRB::Context#prompt_n is deprecated"
102+
assert_include err, "IRB::Context#prompt_n= is deprecated"
103+
end
104+
93105
def test_output_to_pipe
94106
require 'stringio'
95107
input = TestInputMethod.new(["n=1"])

0 commit comments

Comments
 (0)