Class: Reviewer::Arguments::Files

Inherits:
Object
  • Object
show all
Defined in:
lib/reviewer/arguments/files.rb

Overview

Generates a Ruby-friendly list (Array) of files to run the command against from the provided command line arguments

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(provided: [], keywords: [], output: Output.new, on_git_error: nil) ⇒ self

Generates an instance of files from the provided arguments

Examples:

Using the -f flag: ‘rvw -f ./file.rb`

reviewer = Reviewer::Arguments::Files.new(provided: ['./file.rb'], keywords: [])
reviewer.to_a # => ['./file.rb']

Using the --files flag: ‘rvw –files ./file.rb,./directory/file.rb

reviewer = Reviewer::Arguments::Files.new(provided: ['./file.rb','./directory/file.rb'], keywords: [])
reviewer.to_a # => ['./file.rb','./directory/file.rb']


31
32
33
34
35
36
# File 'lib/reviewer/arguments/files.rb', line 31

def initialize(provided: [], keywords: [], output: Output.new, on_git_error: nil)
  @provided = Array(provided)
  @keywords = Array(keywords)
  @output = output
  @on_git_error = on_git_error
end

Instance Attribute Details

#keywordsObject (readonly)

Returns the value of attribute keywords.



10
11
12
# File 'lib/reviewer/arguments/files.rb', line 10

def keywords
  @keywords
end

#providedObject (readonly) Also known as: raw

Returns the value of attribute provided.



10
11
12
# File 'lib/reviewer/arguments/files.rb', line 10

def provided
  @provided
end

Instance Method Details

#to_aArray<String>

Provides the full list of file/path values derived from the command-line arguments



41
# File 'lib/reviewer/arguments/files.rb', line 41

def to_a = file_list

#to_hHash<Symbol, Array<String>> Also known as: inspect

Summary of the state of the file arguments



51
52
53
54
55
56
# File 'lib/reviewer/arguments/files.rb', line 51

def to_h
  {
    provided: provided.sort,
    from_keywords: from_keywords
  }
end

#to_sString

Provides the full list of file/path values derived from the command-line arguments



46
# File 'lib/reviewer/arguments/files.rb', line 46

def to_s = to_a.join(',')