Skip to content

Commit e650960

Browse files
authored
Merge pull request #39 from kateinoigakukun/katei/support-no-io-console-size
Make `io/console/size` as optional dependency
2 parents e89ddf1 + 0b26205 commit e650960

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

lib/power_assert/inspector.rb

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
require 'power_assert/configuration'
2-
require 'io/console/size'
2+
begin
3+
require 'io/console/size'
4+
rescue LoadError
5+
end
36

47
module PowerAssert
58
class InspectedValue
@@ -44,7 +47,8 @@ def initialize(value, indent)
4447
def inspect
4548
if PowerAssert.configuration.colorize_message
4649
if PowerAssert.configuration.inspector == :pp
47-
width = [IO.console_size[1] - 1 - @indent, 10].max
50+
console_width = IO.respond_to?(:console_size) ? IO.console_size[1] : 80
51+
width = [console_width - 1 - @indent, 10].max
4852
IRB::ColorPrinter.pp(@value, '', width)
4953
else
5054
IRB::Color.colorize_code(@value.to_s, ignore_error: true)

0 commit comments

Comments
 (0)