Add AwesomePrint support to Pry
This commit is contained in:
16
pryrc
16
pryrc
@@ -1,6 +1,18 @@
|
|||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
require 'awesome_print'
|
# Locate the gem directory for the current Ruby version and add the awesome_print directory to load path
|
||||||
|
version_path_prefix = RbConfig::CONFIG['prefix']
|
||||||
|
base_version = File.basename(version_path_prefix).tap { |basename| basename[-1] = '0' }
|
||||||
|
gems_path = File.join(version_path_prefix, 'lib', 'ruby', 'gems', base_version, 'gems')
|
||||||
|
ap_gem_dir_name = Dir.new(gems_path).children.detect { |file| file.start_with? 'awesome_print' }
|
||||||
|
|
||||||
Pry.print = proc { |output, value| output.puts value.ai({ limit: true }) }
|
if ap_gem_dir_name.nil?
|
||||||
|
puts 'Could not find AwesonePrint gem in this environment'
|
||||||
|
else
|
||||||
|
$LOAD_PATH << File.join(gems_path, ap_gem_dir_name, 'lib')
|
||||||
|
require 'awesome_print'
|
||||||
|
|
||||||
|
Pry.print = proc { |output, value| output.puts value.ai({ limit: true }) }
|
||||||
|
puts 'AwesomePrint available in this session'
|
||||||
|
end
|
||||||
Pry.config.editor = proc { |file, line| "code --wait --goto #{file}:#{line} --disable-workspace-trust" }
|
Pry.config.editor = proc { |file, line| "code --wait --goto #{file}:#{line} --disable-workspace-trust" }
|
||||||
|
|||||||
Reference in New Issue
Block a user