Module: Evilution::CLI::Parser::FileArgs Private

Defined in:
lib/evilution/cli/parser/file_args.rb

This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.

Defined Under Namespace

Classes: ParsedPaths

Class Method Summary collapse

Class Method Details

.expand_spec_dir(dir) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



23
24
25
26
27
28
29
30
# File 'lib/evilution/cli/parser/file_args.rb', line 23

def expand_spec_dir(dir)
  unless File.directory?(dir)
    warn("Error: #{dir} is not a directory")
    return []
  end

  Dir.glob(File.join(dir, "**/*_spec.rb"))
end

.parse(raw_args) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/evilution/cli/parser/file_args.rb', line 8

def parse(raw_args)
  files = []
  ranges = {}

  raw_args.each do |arg|
    file, range_str = arg.split(":", 2)
    files << file
    next unless range_str

    ranges[file] = parse_line_range(range_str)
  end

  ParsedPaths.new(files: files, ranges: ranges)
end

.parse_line_range(str) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



32
33
34
35
36
37
38
39
40
41
42
# File 'lib/evilution/cli/parser/file_args.rb', line 32

def parse_line_range(str)
  if str.include?("-")
    start_str, end_str = str.split("-", 2)
    start_line = Integer(start_str)
    end_line = end_str.empty? ? Float::INFINITY : Integer(end_str)
    start_line..end_line
  else
    line = Integer(str)
    line..line
  end
end