Class: PolishGeeks::DevTools::Commands::RequiredFiles

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

Overview

Checks for required files

Constant Summary

Constants inherited from Base

Base::TYPES

Instance Attribute Summary

Attributes inherited from Base

#output, #stored_output

Instance Method Summary collapse

Methods inherited from Base

#ensure_executable!

Instance Method Details

#error_messageString

Returns error message.

Returns:

  • (String)

    error message



23
24
25
26
27
28
29
# File 'lib/polish_geeks/dev_tools/commands/required_files.rb', line 23

def error_message
  return if @output.nil?
  err = 'Following files does not exist or are empty:'
  err << "\n"
  err << @output.join("\n")
  err << "\n"
end

#executeString

Executes this command

Returns:

  • (String)

    command output



10
11
12
13
14
15
16
17
18
19
20
# File 'lib/polish_geeks/dev_tools/commands/required_files.rb', line 10

def execute
  output = []
  required_files = ['README.md']
  required_files.concat(::PolishGeeks::DevTools.config.required_files_include || [])
  required_files.each do |required_file|
    file_path = File.join(::PolishGeeks::DevTools.app_root, required_file)
    output << "#{file_path} not exist" unless File.exist?(file_path)
    output << "#{file_path} is empty" if File.zero?(file_path)
  end
  @output = output
end

#valid?Boolean

Returns true if files exist and are not empty.

Returns:

  • (Boolean)

    true if files exist and are not empty



32
33
34
# File 'lib/polish_geeks/dev_tools/commands/required_files.rb', line 32

def valid?
  @output.empty?
end