Class: DeepTest::Options
- Inherits:
-
Object
show all
- Defined in:
- lib/deep_test/options.rb
Defined Under Namespace
Classes: InvalidOptionError
Constant Summary
collapse
- VALID_OPTIONS =
[
Option.new(:distributed_server, Option::String, nil),
Option.new(:number_of_workers, Option::Integer, 2),
Option.new(:metrics_file, Option::String, nil),
Option.new(:pattern, Option::String, nil),
Option.new(:server_port, Option::Integer, 6969),
Option.new(:sync_options, Option::Hash, {}),
Option.new(:timeout_in_seconds, Option::Integer, 30),
Option.new(:ui, Option::String, "DeepTest::UI::Console"),
Option.new(:worker_listener, Option::String, "DeepTest::NullWorkerListener"),
Option.new(:libs, Option::Array, []),
Option.new(:requires, Option::Array, []),
]
- UI_INSTANCES =
Don’t store UI instances in the options instance, which will need to be dumped over DRb. UI instances may not be dumpable and we don’t want to have to start yet another DRb Server
{}
Class Method Summary
collapse
Instance Method Summary
collapse
Constructor Details
#initialize(hash) ⇒ Options
Returns a new instance of Options.
37
38
39
40
41
42
43
|
# File 'lib/deep_test/options.rb', line 37
def initialize(hash)
@origin_hostname = Socket.gethostname
check_option_keys(hash)
VALID_OPTIONS.each do |option|
send("#{option.name}=", hash[option.name] || option.default)
end
end
|
Class Method Details
.from_command_line(command_line) ⇒ Object
29
30
31
32
33
34
35
|
# File 'lib/deep_test/options.rb', line 29
def self.from_command_line(command_line)
hash = {}
VALID_OPTIONS.each do |option|
hash[option.name] = option.from_command_line(command_line)
end
new(hash)
end
|
Instance Method Details
#gathering_metrics? ⇒ Boolean
45
46
47
|
# File 'lib/deep_test/options.rb', line 45
def gathering_metrics?
!@metrics_file.nil?
end
|
#mirror_path(base) ⇒ Object
78
79
80
81
82
|
# File 'lib/deep_test/options.rb', line 78
def mirror_path(base)
raise "No source directory specified in sync_options" unless sync_options[:source]
relative_mirror_path = origin_hostname + sync_options[:source].gsub('/','_')
"#{base}/#{relative_mirror_path}"
end
|
#new_listener_list ⇒ Object
49
50
51
52
53
54
|
# File 'lib/deep_test/options.rb', line 49
def new_listener_list
listeners = worker_listener.split(',').map do |listener|
eval(listener).new
end
ListenerList.new(listeners)
end
|
#origin_hostname ⇒ Object
56
57
58
|
# File 'lib/deep_test/options.rb', line 56
def origin_hostname
(Socket.gethostname == @origin_hostname) ? 'localhost' : @origin_hostname
end
|
#server ⇒ Object
98
99
100
|
# File 'lib/deep_test/options.rb', line 98
def server
Server.remote_reference(origin_hostname, server_port)
end
|
#to_command_line ⇒ Object
69
70
71
72
73
74
75
76
|
# File 'lib/deep_test/options.rb', line 69
def to_command_line
command_line = []
VALID_OPTIONS.each do |option|
value = send(option.name)
command_line << option.to_command_line(value)
end
command_line.compact.join(' ')
end
|
#ui=(value) ⇒ Object
21
22
23
|
# File 'lib/deep_test/options.rb', line 21
def ui=(value)
@ui = value.to_s
end
|
#ui_instance ⇒ Object
65
66
67
|
# File 'lib/deep_test/options.rb', line 65
def ui_instance
UI_INSTANCES[self] ||= eval(ui).new(self)
end
|
#worker_listener=(value) ⇒ Object
25
26
27
|
# File 'lib/deep_test/options.rb', line 25
def worker_listener=(value)
@worker_listener = value.to_s
end
|