Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Irb integration for v1.2.6+ #81

Merged
merged 2 commits into from
Oct 6, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/amazing_print/custom_defaults.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def inspect_object(object)

def usual_rb
IRB::Irb.class_eval do
def output_value
def output_value(_omit = false) # rubocop:disable Style/OptionalBooleanParameter
ap @context.last_value
rescue NoMethodError
puts "(Object doesn't support #ai)"
Expand Down
6 changes: 3 additions & 3 deletions lib/amazing_print/formatters/base_formatter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def limited(data, width, is_hash: false)
else
# Calculate how many elements to be displayed above and below the separator.
head = limit / 2
tail = head - (limit - 1) % 2
tail = head - ((limit - 1) % 2)

# Add the proper elements to the temp array and format the separator.
temp = data[0, head] + [nil] + data[-tail, tail]
Expand Down Expand Up @@ -118,13 +118,13 @@ def indented(&blk)
INDENT_CACHE = (0..100).map { |i| ' ' * i }.map(&:freeze).freeze

def indent(n = indentation)
INDENT_CACHE[n] || ' ' * n
INDENT_CACHE[n] || (' ' * n)
end

def outdent
i = indentation - options[:indent].abs

INDENT_CACHE[i] || ' ' * i
INDENT_CACHE[i] || (' ' * i)
end

def align(value, width)
Expand Down
2 changes: 1 addition & 1 deletion spec/methods_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -440,7 +440,7 @@ def self.m2; end
class World
def self.m1; end
end
out = (Hello.methods & World.methods - Class.methods).ai(plain: true)
out = (Hello.methods & (World.methods - Class.methods)).ai(plain: true)
expect(out).to eq("[\n [0] m1() Hello\n]")
end

Expand Down