Class: PolishGeeks::DevTools::Commands::TasksFilesNames
- 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
Instance Attribute Summary collapse
-
#counter ⇒ Object
readonly
Returns the value of attribute counter.
Attributes inherited from Base
Instance Method Summary collapse
-
#error_message ⇒ String
Message that should be printed when some files have invalid extensions/names.
-
#execute ⇒ Array<String>
Executes this command.
-
#label ⇒ String
Default label for this command.
-
#valid? ⇒ Boolean
True if all files have proper names and extensions.
Methods inherited from Base
Instance Attribute Details
#counter ⇒ Object (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_message ⇒ String
Returns 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 "Following files have invalid extensions: \n #{output.join("\n")}\n" end |
#execute ⇒ Array<String>
Executes this command
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 |
#label ⇒ String
Returns 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.
47 48 49 |
# File 'lib/polish_geeks/dev_tools/commands/tasks_files_names.rb', line 47 def valid? output.empty? end |