Class: FaceControl::Checkers::Example

Inherits:
Object
  • Object
show all
Defined in:
lib/face_control/checkers/_example.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#options=(value) ⇒ Object (writeonly)

Define only if you use @options in the following methods



8
9
10
# File 'lib/face_control/checkers/_example.rb', line 8

def options=(value)
  @options = value
end

Instance Method Details

#command(filenames) ⇒ String

Returns Command line to check the files.

Parameters:

  • filenames (String)

    Files with added lines in the pull request only relevant to this checker (filtered by globs above)

Returns:

  • (String)

    Command line to check the files



20
21
22
# File 'lib/face_control/checkers/_example.rb', line 20

def command(filenames)
  "ls -l #{filenames}"
end

#parse(command_output) ⇒ Object

Parameters:

  • command_output (String)

    Stdout of the command above



26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/face_control/checkers/_example.rb', line 26

def parse(command_output)
  command_output.split("\n").map do |line|
    fields = line.split

    mode = fields.first
    file = fields.last

    unless mode == '-rwxr-xr-x'
      Comment.new(file: file, line: 1, text: 'Invalid file mode')
    end
  end
end

#relevant_globsArray<String>

Returns Shell globs to filter only files relevant to this checker out of all files with added lines in the pull request.

Returns:

  • (Array<String>)

    Shell globs to filter only files relevant to this checker out of all files with added lines in the pull request



13
14
15
# File 'lib/face_control/checkers/_example.rb', line 13

def relevant_globs
  %w(bin/*)
end