Module: IRT::Commands::Core

Included in:
IRB::ExtendCommandBundle
Defined in:
lib/irt/commands/core.rb,
lib/irt/extensions/rails.rb

Instance Method Summary collapse

Instance Method Details

#irt(obj = nil) ⇒ Object Also known as: open_session



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/irt/commands/core.rb', line 5

def irt(obj=nil)
  irt_mode = context.irt_mode
  to_mode = case obj
            when nil
              :interactive
            when Binding
              :binding
            else
              :inspect
            end
  raise IRT::SessionModeError, "You cannot pass binding in #{irt_mode} mode" \
    if to_mode == :binding && (irt_mode == :binding || caller[0].match(/^\(/))
  raise IRT::SessionModeError, "You cannot open another interactive session in #{irt_mode} mode" \
    if to_mode == :interactive && irt_mode != :file
  IRT::Session.enter to_mode, obj
end

#original_rerunObject



28
29
30
31
32
33
# File 'lib/irt/extensions/rails.rb', line 28

def rerun
  ensure_session
  Directives::Test.test_summary
  Directives::Test.reset_variables
  IRT::Session.run_file
end

#pager(arg = nil, &block) ⇒ Object Also known as: pg

Raises:

  • (ArgumentError)


62
63
64
65
66
67
68
69
70
# File 'lib/irt/commands/core.rb', line 62

def pager(arg=nil, &block)
  ensure_session
  raise ArgumentError, "You must pass an arguent or a block" if arg.nil? && block.nil?
  # in case of a block we will just capture in memory its whole output to stdout
  output = arg || capture(:stdout, &block)
  IO.popen(IRT.pager_command, 'w') do |io|
    io.puts output
  end
end

#rerunObject



45
46
47
48
49
50
# File 'lib/irt/commands/core.rb', line 45

def rerun
  ensure_session
  Directives::Test.test_summary
  Directives::Test.reset_variables
  IRT::Session.run_file
end

#restartObject Also known as: rs

rerun the same shell command



33
34
35
36
37
38
39
40
41
42
# File 'lib/irt/commands/core.rb', line 33

def restart
  ensure_session
  ensure_cli
  IRB.irb_at_exit
  str = "Restarting: `#{ENV['IRT_COMMAND']}`"
  puts
  puts IRT.dye(" #{str} ", "*** #{str} ***", :error_color, :bold, :reversed)
  puts
  exec ENV["IRT_COMMAND"]
end

#rrObject



51
52
53
54
55
56
# File 'lib/irt/commands/core.rb', line 51

def rerun
  ensure_session
  Directives::Test.test_summary
  Directives::Test.reset_variables
  IRT::Session.run_file
end

#run(file_path) ⇒ Object



53
54
55
56
# File 'lib/irt/commands/core.rb', line 53

def run(file_path)
  ensure_session
  IRT::Session.run_file file_path
end

#sh(*args) ⇒ Object



58
59
60
# File 'lib/irt/commands/core.rb', line 58

def sh(*args)
  system *args
end

#vdiff(a, b) ⇒ Object Also known as: vd



23
24
25
26
27
28
29
# File 'lib/irt/commands/core.rb', line 23

def vdiff(a,b)
  ensure_session
  puts IRT::Differ.new(a,b, :value, {:a_marker => 'a',
                                     :b_marker => 'b',
                                     :a_label => '',
                                     :b_label => ''}).output
end