Permalink
Browse files

support pry. try > require 'ir_b/pry'

  • Loading branch information...
1 parent 6ee0ef0 commit 1a859d174a742ec0ae394970367d08e2724b5411 @jugyo committed Aug 23, 2011
Showing with 25 additions and 14 deletions.
  1. +2 −0 Rakefile
  2. +21 −14 lib/ir_b.rb
  3. +2 −0 lib/ir_b/pry.rb
View
@@ -10,6 +10,8 @@ begin
gem.email = "jugyo.org@gmail.com"
gem.homepage = "http://github.com/jugyo/ir_b"
gem.authors = ["jugyo"]
+ gem.add_dependency "pry"
+ gem.add_dependency "pry-doc"
gem.add_development_dependency "shoulda", ">= 0"
gem.add_development_dependency "rr", ">= 0"
end
View
@@ -26,23 +26,30 @@ def self.start_session(binding)
module IrB
class << self
+ attr_accessor :pry
+
def -(_binding)
- file = _binding.eval '__FILE__'
- ir_b_line = _binding.eval '__LINE__'
- puts "#{file}:#{ir_b_line}"
-
- File.open(file).each_with_index do |line, index|
- line_n = index + 1
- next unless line_n > (ir_b_line - 6)
- break if line_n > (ir_b_line + 5)
- if line_n == ir_b_line
- puts " =>#{line_n.to_s.rjust(3)}: #{line.chomp}"
- else
- puts "#{line_n.to_s.rjust(6)}: #{line.chomp}"
+ if pry
+ require 'pry'
+ _binding.pry
+ else
+ file = _binding.eval '__FILE__'
+ ir_b_line = _binding.eval '__LINE__'
+ puts "#{file}:#{ir_b_line}"
+
+ File.open(file).each_with_index do |line, index|
+ line_n = index + 1
+ next unless line_n > (ir_b_line - 6)
+ break if line_n > (ir_b_line + 5)
+ if line_n == ir_b_line
+ puts " =>#{line_n.to_s.rjust(3)}: #{line.chomp}"
+ else
+ puts "#{line_n.to_s.rjust(6)}: #{line.chomp}"
+ end
end
- end
- IRB.start_session(_binding)
+ IRB.start_session(_binding)
+ end
end
end
end
View
@@ -0,0 +1,2 @@
+require 'ir_b'
+IrB.pry = true

0 comments on commit 1a859d1

Please sign in to comment.