Module: RuboCop::Packaging::LibHelperModule
- Included in:
- Cop::Packaging::BundlerSetupInTests, Cop::Packaging::RequireHardcodingLib, Cop::Packaging::RequireRelativeHardcodingLib
- Defined in:
- lib/rubocop/packaging/lib_helper_module.rb
Overview
This helper module extracts the methods which can be used in other cop classes.
Instance Method Summary collapse
-
#inspected_file_falls_in_lib? ⇒ Boolean
This method determines if that call is made from the “lib” directory.
-
#inspected_file_is_gemspec? ⇒ Boolean
This method determines if that call is made from the “gemspec” file.
-
#inspected_file_is_not_in_lib_or_gemspec? ⇒ Boolean
This method determines if the inspected file is not in lib/ or isn’t a gemspec file.
-
#root_dir ⇒ Object
For determining the root directory of the project.
-
#target_falls_in_lib?(str) ⇒ Boolean
This method determines if the calls are made to the “lib” directory.
-
#target_falls_in_lib_using_file?(str) ⇒ Boolean
This method determines if the calls (using the __FILE__ argument) are made to the “lib” directory.
Instance Method Details
#inspected_file_falls_in_lib? ⇒ Boolean
This method determines if that call is made from the “lib” directory.
25 26 27 |
# File 'lib/rubocop/packaging/lib_helper_module.rb', line 25 def inspected_file_falls_in_lib? @file_path.start_with?("#{root_dir}/lib") end |
#inspected_file_is_gemspec? ⇒ Boolean
This method determines if that call is made from the “gemspec” file.
30 31 32 |
# File 'lib/rubocop/packaging/lib_helper_module.rb', line 30 def inspected_file_is_gemspec? @file_path.end_with?("gemspec") end |
#inspected_file_is_not_in_lib_or_gemspec? ⇒ Boolean
This method determines if the inspected file is not in lib/ or isn’t a gemspec file.
36 37 38 |
# File 'lib/rubocop/packaging/lib_helper_module.rb', line 36 def inspected_file_is_not_in_lib_or_gemspec? !inspected_file_falls_in_lib? && !inspected_file_is_gemspec? end |
#root_dir ⇒ Object
For determining the root directory of the project.
9 10 11 |
# File 'lib/rubocop/packaging/lib_helper_module.rb', line 9 def root_dir RuboCop::ConfigFinder.project_root end |
#target_falls_in_lib?(str) ⇒ Boolean
This method determines if the calls are made to the “lib” directory.
14 15 16 |
# File 'lib/rubocop/packaging/lib_helper_module.rb', line 14 def target_falls_in_lib?(str) File.(str, @file_directory).start_with?("#{root_dir}/lib") end |
#target_falls_in_lib_using_file?(str) ⇒ Boolean
This method determines if the calls (using the __FILE__ argument) are made to the “lib” directory.
20 21 22 |
# File 'lib/rubocop/packaging/lib_helper_module.rb', line 20 def target_falls_in_lib_using_file?(str) File.(str, @file_path).start_with?("#{root_dir}/lib") end |