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
  .swp
  .swo
).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



49
50
51
# File 'lib/polish_geeks/dev_tools/commands/final_blank_line.rb', line 49

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



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

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



43
44
45
# File 'lib/polish_geeks/dev_tools/commands/final_blank_line.rb', line 43

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



38
39
40
# File 'lib/polish_geeks/dev_tools/commands/final_blank_line.rb', line 38

def valid?
  output.empty?
end