Class: FTest::CLI
- Inherits:
-
Object
show all
- Defined in:
- lib/ftest/cli.rb
Defined Under Namespace
Classes: ArgvParser, Options
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Constructor Details
#initialize(argv, stdout) ⇒ CLI
Returns a new instance of CLI.
12
13
14
15
|
# File 'lib/ftest/cli.rb', line 12
def initialize argv, stdout
@argv = argv
@stdout = stdout
end
|
Instance Attribute Details
#options ⇒ Object
Returns the value of attribute options.
10
11
12
|
# File 'lib/ftest/cli.rb', line 10
def options
@options
end
|
Class Method Details
.run(argv) ⇒ Object
5
6
7
8
|
# File 'lib/ftest/cli.rb', line 5
def self.run argv
instance = new argv, $stdout
instance.()
end
|
Instance Method Details
#build_logger ⇒ Object
31
32
33
34
35
36
|
# File 'lib/ftest/cli.rb', line 31
def build_logger
logger = Logger.new @stdout
logger.level = options.log_level
logger.progname = "ftest"
logger
end
|
#call ⇒ Object
17
18
19
20
21
|
# File 'lib/ftest/cli.rb', line 17
def call
@options = ArgvParser.(@argv)
setup_config
Runner.(filter_files) or exit 1
end
|
#filter_files ⇒ Object
38
39
40
41
42
|
# File 'lib/ftest/cli.rb', line 38
def filter_files
resolve_files.reject do |path|
path.end_with? "init.rb"
end
end
|
#resolve_files ⇒ Object
44
45
46
47
48
49
50
51
52
|
# File 'lib/ftest/cli.rb', line 44
def resolve_files
options.paths.flat_map do |path|
if path.end_with? ".rb"
[path]
else
Dir[File.join path, "**/*.rb"]
end
end
end
|