Class: Rabbit::Command::Rabbit

Inherits:
Object
  • Object
show all
Includes:
GetText
Defined in:
lib/rabbit/command/rabbit.rb

Constant Summary

Constants included from GetText

GetText::DOMAIN

Class Method Summary collapse

Instance Method Summary collapse

Methods included from GetText

included

Constructor Details

#initializeRabbit

Returns a new instance of Rabbit.


33
34
35
# File 'lib/rabbit/command/rabbit.rb', line 33

def initialize
  @logger = nil
end

Class Method Details

.run(*arguments) ⇒ Object


28
29
30
# File 'lib/rabbit/command/rabbit.rb', line 28

def run(*arguments)
  new.run(arguments)
end

Instance Method Details

#run(arguments) ⇒ Object


37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
# File 'lib/rabbit/command/rabbit.rb', line 37

def run(arguments)
  GC.disable
  require "rbconfig"

  require "rabbit/console"
  require "rabbit/source"
  require "rabbit/renderer"
  require "rabbit/front"

  @options, @logger = parse_command_line_arguments(arguments)

  require "rabbit/canvas"
  GC.enable

  application = ::Rabbit.application
  succeeded = false
  application.signal_connect("command-line") do |_, command_line|
    application.activate
    succeeded ? 0 : 1
  end
  application.signal_connect("activate") do
    begin
      succeeded = catch do |abort_tag|
        @abort_tag = abort_tag
        __send__("do_#{@options.action}")
      end
    rescue
      @logger.error($!)
    end
  end
  exit_code = application.run
  application.windows.each(&:destroy)
  application.unref

  exit_code.zero?
end