1
0
Fork 0
mirror of https://github.com/pry/pry.git synced 2022-11-09 12:35:05 -05:00

moving fundamental helper methods from command_helpers to base_helprs (set_file_and_dir_locals() and no_color())

This commit is contained in:
John Mair 2011-05-05 01:45:29 +12:00
parent 1e655ed1d7
commit 676cf20365
2 changed files with 17 additions and 8 deletions

View file

@ -14,6 +14,15 @@ class Pry
end
end
# turn off color for duration of block
def no_color(&block)
old_color_state = Pry.color
Pry.color = false
yield
ensure
Pry.color = old_color_state
end
def gem_installed?(gem_name)
require 'rubygems'
!!Gem.source_index.find_name(gem_name).first
@ -26,6 +35,14 @@ class Pry
end
end
def set_file_and_dir_locals(file_name)
return if !target
$_file_temp = File.expand_path(file_name)
$_dir_temp = File.dirname($_file_temp)
target.eval("_file_ = $_file_temp")
target.eval("_dir_ = $_dir_temp")
end
def stub_proc(name, options)
gems_needed = Array(options[:requires_gem])
gems_not_installed = gems_needed.select { |g| !gem_installed?(g) }

View file

@ -23,14 +23,6 @@ class Pry
end
end
def set_file_and_dir_locals(file_name)
return if !target
$_file_temp = File.expand_path(file_name)
$_dir_temp = File.dirname($_file_temp)
target.eval("_file_ = $_file_temp")
target.eval("_dir_ = $_dir_temp")
end
def add_line_numbers(lines, start_line)
line_array = lines.each_line.to_a
line_array.each_with_index.map do |line, idx|