Class: PolishGeeks::DevTools::Commands::TasksFilesNames

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

Overview

Checks if tasks files (rake and capistrano) have proper extensions

Constant Summary collapse

CAP =

Capistrano tasks check rules

OpenStruct.new(
  dirs: %w(
    lib/capistrano
  ),
  regexp: /.*\.cap$/
)
RAKE =

Rake tasks check rules

OpenStruct.new(
  dirs: %w(
    lib/tasks
  ),
  regexp: /.*\.rake$/
)

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/tasks_files_names.rb', line 8

def counter
  @counter
end

Instance Method Details

#error_messageString

Returns message that should be printed when some files have invalid extensions/names.

Returns:

  • (String)

    message that should be printed when some files have invalid extensions/names



58
59
60
# File 'lib/polish_geeks/dev_tools/commands/tasks_files_names.rb', line 58

def error_message
  "Following files have invalid extensions: \n #{output.join("\n")}\n"
end

#executeArray<String>

Executes this command

Returns:

  • (Array<String>)

    command output array with list of spec files that dont have a proper name, or an empty array if everything is ok



29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/polish_geeks/dev_tools/commands/tasks_files_names.rb', line 29

def execute
  @output = []
  @counter = 0

  cap_files = files(CAP)
  @counter += cap_files.count

  cap_files.delete_if { |file| file =~ CAP.regexp }
  @output += cap_files

  rake_files = files(RAKE)
  @counter += rake_files.count

  rake_files.delete_if { |file| file =~ RAKE.regexp }
  @output += rake_files
end

#labelString

Returns default label for this command.

Returns:

  • (String)

    default label for this command



52
53
54
# File 'lib/polish_geeks/dev_tools/commands/tasks_files_names.rb', line 52

def label
  "Tasks files names: #{counter} files checked"
end

#valid?Boolean

Returns true if all files have proper names and extensions.

Returns:

  • (Boolean)

    true if all files have proper names and extensions



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

def valid?
  output.empty?
end