Class: DRbQS::Execution::ServerDefinition

Inherits:
Object
  • Object
show all
Defined in:
lib/drbqs/execute/server_define.rb

Constant Summary collapse

HELP_MESSAGE =
<<HELP
* Server specific options
  These options are separated by '--' from command options.

HELP

Instance Method Summary collapse

Constructor Details

#initializeServerDefinition

Returns a new instance of ServerDefinition.



10
11
12
# File 'lib/drbqs/execute/server_define.rb', line 10

def initialize
  clear_definition
end

Instance Method Details

#clear_definitionObject



60
61
62
63
64
65
66
# File 'lib/drbqs/execute/server_define.rb', line 60

def clear_definition
  @server_create = nil
  @option_parse = nil
  @opts = {}
  @argv = nil
  @default_server_opts = nil
end

#create_test_server(options) ⇒ Object



85
86
87
88
89
# File 'lib/drbqs/execute/server_define.rb', line 85

def create_test_server(options)
  require 'drbqs/server/test/server'
  options.delete(:not_exit)
  create_server(options, DRbQS::Test::Server)
end

#define_server(default_opts = {}, &block) ⇒ Object



14
15
16
17
18
19
20
# File 'lib/drbqs/execute/server_define.rb', line 14

def define_server(default_opts = {}, &block)
  @default_server_opts = default_opts
  if @server_create
    raise ArgumentError, "The server has already defined."
  end
  @server_create = block
end

#option_help_messageObject



49
50
51
52
53
54
55
56
57
58
# File 'lib/drbqs/execute/server_define.rb', line 49

def option_help_message
  if @option_parse
    create_parser do |opt|
      @option_parse.call(opt, @opts)
      return opt.to_s
    end
  else
    nil
  end
end

#option_parser(mes = nil, &block) ⇒ Object



22
23
24
25
26
27
28
# File 'lib/drbqs/execute/server_define.rb', line 22

def option_parser(mes = nil, &block)
  if @option_parse
    raise ArgumentError, "The options parser has already defined."
  end
  @option_message = mes
  @option_parse = block
end

#parse_option(opt_argv) ⇒ Object



39
40
41
42
43
44
45
46
47
# File 'lib/drbqs/execute/server_define.rb', line 39

def parse_option(opt_argv)
  if @option_parse
    create_parser do |opt|
      @option_parse.call(opt, @opts)
      opt.parse!(opt_argv)
    end
  end
  @argv = opt_argv  
end

#start_server(options) ⇒ Object



76
77
78
79
80
81
82
83
# File 'lib/drbqs/execute/server_define.rb', line 76

def start_server(options)
  unless @server_create
    raise "Can not get server definition."
  end
  server = create_server(options)
  server.start
  server.wait
end