Class: PolishGeeks::DevTools::Commands::FinalBlankLine

Inherits:
Base
  • Object
show all
Defined in:
lib/polish_geeks/dev_tools/commands/final_blank_line.rb

Overview

Validator used to check if all files have final blank line

Constant Summary collapse

DEFAULT_PATHS_TO_EXCLUDE =

Default paths which we want to exclude from analyse

%w(
  coverage
  tmp
  doc
  log
  vendor
  public
  app/assets/images
  app/assets/fonts
  .DS_Store
  .gem
).freeze

Constants inherited from Base

Base::TYPES

Instance Attribute Summary collapse

Attributes inherited from Base

#output, #stored_output

Instance Method Summary collapse

Methods inherited from Base

#ensure_executable!

Instance Attribute Details

#counterObject (readonly)

Returns the value of attribute counter.



8
9
10
# File 'lib/polish_geeks/dev_tools/commands/final_blank_line.rb', line 8

def counter
  @counter
end

Instance Method Details

#error_messageString

final blank line

Returns:

  • (String)

    message that should be printed when some files don’t have



47
48
49
# File 'lib/polish_geeks/dev_tools/commands/final_blank_line.rb', line 47

def error_message
  "Following files don't have final blank line: \n#{output.join("\n")}\n"
end

#executeObject

Executes this command and set output and counter variables



25
26
27
28
29
30
31
32
33
# File 'lib/polish_geeks/dev_tools/commands/final_blank_line.rb', line 25

def execute
  @output = []
  @counter = 0

  files_to_analyze.each do |file|
    @counter += 1
    @output << sanitize(file) unless file_valid?(file)
  end
end

#labelString

Returns default label for this command.

Returns:

  • (String)

    default label for this command



41
42
43
# File 'lib/polish_geeks/dev_tools/commands/final_blank_line.rb', line 41

def label
  "Final blank line: #{counter} files checked"
end

#valid?Boolean

Returns true if all files have final blank line.

Returns:

  • (Boolean)

    true if all files have final blank line



36
37
38
# File 'lib/polish_geeks/dev_tools/commands/final_blank_line.rb', line 36

def valid?
  output.empty?
end