Class: Smartest::CLIArguments
- Inherits:
-
Object
- Object
- Smartest::CLIArguments
- Defined in:
- lib/smartest/cli_arguments.rb
Constant Summary collapse
- DEFAULT_PROFILE_COUNT =
5- DEFAULT_PATHS =
["smartest/**/*_test.rb"].freeze
Instance Attribute Summary collapse
-
#files ⇒ Object
readonly
Returns the value of attribute files.
-
#line_filters ⇒ Object
readonly
Returns the value of attribute line_filters.
-
#profile_count ⇒ Object
readonly
Returns the value of attribute profile_count.
Instance Method Summary collapse
- #default_paths? ⇒ Boolean
- #filter_tests? ⇒ Boolean
-
#initialize(argv) ⇒ CLIArguments
constructor
A new instance of CLIArguments.
- #select_tests(tests) ⇒ Object
Constructor Details
#initialize(argv) ⇒ CLIArguments
Returns a new instance of CLIArguments.
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/smartest/cli_arguments.rb', line 12 def initialize(argv) @files = [] @whole_files = Set.new @line_filters = Hash.new { |hash, key| hash[key] = Set.new } @profile_count = DEFAULT_PROFILE_COUNT @default_paths = false paths = (argv) if paths.empty? @default_paths = true paths = DEFAULT_PATHS end parse_paths(paths) end |
Instance Attribute Details
#files ⇒ Object (readonly)
Returns the value of attribute files.
10 11 12 |
# File 'lib/smartest/cli_arguments.rb', line 10 def files @files end |
#line_filters ⇒ Object (readonly)
Returns the value of attribute line_filters.
10 11 12 |
# File 'lib/smartest/cli_arguments.rb', line 10 def line_filters @line_filters end |
#profile_count ⇒ Object (readonly)
Returns the value of attribute profile_count.
10 11 12 |
# File 'lib/smartest/cli_arguments.rb', line 10 def profile_count @profile_count end |
Instance Method Details
#default_paths? ⇒ Boolean
32 33 34 |
# File 'lib/smartest/cli_arguments.rb', line 32 def default_paths? @default_paths end |
#filter_tests? ⇒ Boolean
28 29 30 |
# File 'lib/smartest/cli_arguments.rb', line 28 def filter_tests? @line_filters.any? end |
#select_tests(tests) ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/smartest/cli_arguments.rb', line 36 def select_tests(tests) return tests unless filter_tests? tests.select do |test_case| next false unless test_case.location path = File.(test_case.location.path) @whole_files.include?(path) || @line_filters.fetch(path, []).any? { |line_filter| test_case.includes_line_range?(line_filter) } end end |