Class: PolishGeeks::DevTools::Commands::ExpiresIn
- Defined in:
- lib/polish_geeks/dev_tools/commands/expires_in.rb
Overview
Checking Rails cache options especially expires_in
Constant Summary collapse
- CHECKED_DIRS =
List of dirs that we will check for
%w( app lib ).freeze
- CHECKED_REGEXP =
Regexp that we want to use to catch invalid things that occur instead of expires_in
'expire_in\|expir_in'.freeze
Constants inherited from Base
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
-
#error_message ⇒ String
Error message.
-
#excludes ⇒ Array<String>
List of files/directories that should be excluded from checking.
-
#execute ⇒ Object
Executes this command.
-
#label ⇒ String
Label with this validator description.
-
#valid? ⇒ Boolean
True if not find expire_in.
Methods inherited from Base
Instance Method Details
#error_message ⇒ String
Returns error message.
42 43 44 45 46 47 |
# File 'lib/polish_geeks/dev_tools/commands/expires_in.rb', line 42 def err = 'Following files use expire_in instead of expires_in:' err << "\n\n" err << @output.join("\n") err << "\n" end |
#excludes ⇒ Array<String>
Note:
This should be set in the initializer for this gem in the place where it is going to be used
Returns list of files/directories that should be excluded from checking.
57 58 59 |
# File 'lib/polish_geeks/dev_tools/commands/expires_in.rb', line 57 def excludes DevTools.config.expires_in_files_ignored || [] end |
#execute ⇒ Object
Executes this command
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/polish_geeks/dev_tools/commands/expires_in.rb', line 19 def execute results = CHECKED_DIRS.map do |directory| path = File.join(PolishGeeks::DevTools.app_root, directory) shell_command(path).split("\n") end @output = results .flatten .map { |line| line.split(':').first } .map { |line| line.gsub!(PolishGeeks::DevTools.app_root, '') } .uniq @output.delete_if do |line| excludes.any? { |exclude| line =~ /#{exclude}/ } end end |
#label ⇒ String
Returns label with this validator description.
37 38 39 |
# File 'lib/polish_geeks/dev_tools/commands/expires_in.rb', line 37 def label 'Expires in' end |
#valid? ⇒ Boolean
Returns true if not find expire_in.
50 51 52 |
# File 'lib/polish_geeks/dev_tools/commands/expires_in.rb', line 50 def valid? @output.empty? end |