5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
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
73
74
75
76
77
78
79
80
81
|
# File 'lib/nukumber/cli.rb', line 5
def initialize(args, out_stream = STDOUT)
directories = {
:features => 'features',
:definitions => 'test_definitions',
:support => 'support'
}
reporter_type = 'Mono'
reporter_type = 'Colour' if out_stream.tty?
filters = []
filenames = []
i = 0
while i < args.size do
if %w( -h --help ).include? args[i]
print_help(out_stream)
return
elsif %w( -fd --features ).include? args[i] and (i+1) < args.size
directories[:features] = args[i+1]
i += 2
next
elsif %w( -sd --support ).include? args[i] and (i+1) < args.size
directories[:support] = args[i+1]
i += 2
next
elsif %w( -dd --definitions ).include? args[i] and (i+1) < args.size
directories[:definitions] = args[i+1]
i += 2
next
elsif %w( -t --tag ).include? args[i] and (i+1) < args.size
filters << args[i+1] if args[i+1][0, 1] == '@'
i += 2
next
elsif %w( -f --format ).include? args[i] and i + 1 < args.size
if %w( c colour ).include? args[i+1]
reporter_type = 'Colour'
elsif %w( m mono ).include? args[i+1]
reporter_type = 'Mono'
elsif %w( h html ).include? args[i+1]
reporter_type = 'Html'
elsif %w( s silent ).include? args[i+1]
reporter_type = 'Abstract'
else
raise "\"#{args[i+1]}\" is an invalid argument to \"#{args[i]}\""
end
i += 2
next
end
arr = args[i].split(/:/)
filenames << arr.shift
arr.each { |n| filters << n.to_i unless n.to_i == 0 }
i += 1
end
reporter = eval("Nukumber::Reporter::#{reporter_type}").new(out_stream)
@runtime = Nukumber::Runtime.new(
directories,
filenames,
filters,
reporter
)
end
|