diff options
author | Kyrylo Silin <silin@kyrylo.org> | 2019-05-19 11:25:04 +0300 |
---|---|---|
committer | Kyrylo Silin <silin@kyrylo.org> | 2019-05-19 11:25:04 +0300 |
commit | e15f38dece265af0908f5460eba00a213f36aa01 (patch) | |
tree | 60067c72d7e0817b41d9a1109e99fc39479f5c84 | |
parent | 5967769d2ab3b057e7329a97b8e8c04460a8fd5e (diff) | |
download | pry-e15f38dece265af0908f5460eba00a213f36aa01.tar.gz |
terminal: rename 'bang' methods to normal ones
To be perfectly honest, I have no idea why these methods have exclamation
marks. Maybe because they may require `io/console`? Even then, there's nothing
dangerous in this.
-rw-r--r-- | lib/pry/color_printer.rb | 2 | ||||
-rw-r--r-- | lib/pry/helpers/table.rb | 6 | ||||
-rw-r--r-- | lib/pry/indent.rb | 2 | ||||
-rw-r--r-- | lib/pry/pager.rb | 4 | ||||
-rw-r--r-- | lib/pry/pry_class.rb | 2 | ||||
-rw-r--r-- | lib/pry/terminal.rb | 10 |
6 files changed, 13 insertions, 13 deletions
diff --git a/lib/pry/color_printer.rb b/lib/pry/color_printer.rb index 0a289014..ee6c2979 100644 --- a/lib/pry/color_printer.rb +++ b/lib/pry/color_printer.rb @@ -11,7 +11,7 @@ class Pry def self.default(_output, value, pry_instance) pry_instance.pager.open do |pager| pager.print pry_instance.config.output_prefix - pp(value, pager, Pry::Terminal.width! - 1) + pp(value, pager, Pry::Terminal.width - 1) end end diff --git a/lib/pry/helpers/table.rb b/lib/pry/helpers/table.rb index 59297f9c..f7bd40d0 100644 --- a/lib/pry/helpers/table.rb +++ b/lib/pry/helpers/table.rb @@ -5,7 +5,7 @@ class Pry def self.tablify_or_one_line(heading, things, config = Pry.config) plain_heading = Pry::Helpers::Text.strip_color(heading) attempt = Table.new(things, column_count: things.size) - if attempt.fits_on_line?(Terminal.width! - plain_heading.size - 2) + if attempt.fits_on_line?(Terminal.width - plain_heading.size - 2) "#{heading}: #{attempt}\n" else "#{heading}: \n#{tablify_to_screen_width(things, { indent: ' ' }, config)}\n" @@ -16,10 +16,10 @@ class Pry options ||= {} things = things.compact if (indent = options[:indent]) - usable_width = Terminal.width! - indent.size + usable_width = Terminal.width - indent.size tablify(things, usable_width, config).to_s.gsub(/^/, indent) else - tablify(things, Terminal.width!, config).to_s + tablify(things, Terminal.width, config).to_s end end diff --git a/lib/pry/indent.rb b/lib/pry/indent.rb index 306c82d0..e6e96dc3 100644 --- a/lib/pry/indent.rb +++ b/lib/pry/indent.rb @@ -394,7 +394,7 @@ class Pry line_to_measure = Pry::Helpers::Text.strip_color(prompt) << code whitespace = ' ' * overhang - cols = Terminal.width! + cols = Terminal.width lines = cols == 0 ? 1 : (line_to_measure.length / cols + 1).to_i if Helpers::Platform.windows_ansi? diff --git a/lib/pry/pager.rb b/lib/pry/pager.rb index 693e9e8e..7296510a 100644 --- a/lib/pry/pager.rb +++ b/lib/pry/pager.rb @@ -88,11 +88,11 @@ class Pry private def height - @height ||= Pry::Terminal.height! + @height ||= Pry::Terminal.height end def width - @width ||= Pry::Terminal.width! + @width ||= Pry::Terminal.width end end diff --git a/lib/pry/pry_class.rb b/lib/pry/pry_class.rb index 6a7b6a8c..6db46b14 100644 --- a/lib/pry/pry_class.rb +++ b/lib/pry/pry_class.rb @@ -300,7 +300,7 @@ Readline version #{Readline::VERSION} detected - will not auto_resize! correctly trap :WINCH do begin - Readline.set_screen_size(*Terminal.size!) + Readline.set_screen_size(*Terminal.size) rescue StandardError => e warn "\nPry.auto_resize!'s Readline.set_screen_size failed: #{e}" end diff --git a/lib/pry/terminal.rb b/lib/pry/terminal.rb index c09c6178..04367e2e 100644 --- a/lib/pry/terminal.rb +++ b/lib/pry/terminal.rb @@ -12,18 +12,18 @@ class Pry end # Return a screen size or a default if that fails. - def size!(default = [27, 80]) + def size(default = [27, 80]) screen_size || default end # Return a screen width or the default if that fails. - def width! - size![1] + def width + size[1] end # Return a screen height or the default if that fails. - def height! - size![0] + def height + size[0] end def actual_screen_size |