module RuboCop::Packaging::LibHelperModule

This helper module extracts the methods which can be used in other cop classes.

Public Instance Methods

inspected_file_falls_in_lib?() click to toggle source

This method determines if that call is made from the “lib” directory.

# 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?() click to toggle source

This method determines if that call is made from the “gemspec” file.

# 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?() click to toggle source

This method determines if the inspected file is not in lib/ or isn't a gemspec file.

# 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() click to toggle source

For determining the root directory of the project.

# File lib/rubocop/packaging/lib_helper_module.rb, line 9
def root_dir
  RuboCop::ConfigLoader.project_root
end
target_falls_in_lib?(str) click to toggle source

This method determines if the calls are made to the “lib” directory.

# File lib/rubocop/packaging/lib_helper_module.rb, line 14
def target_falls_in_lib?(str)
  File.expand_path(str, @file_directory).start_with?("#{root_dir}/lib")
end
target_falls_in_lib_using_file?(str) click to toggle source

This method determines if the calls (using the __FILE__ argument) are made to the “lib” directory.

# File lib/rubocop/packaging/lib_helper_module.rb, line 20
def target_falls_in_lib_using_file?(str)
  File.expand_path(str, @file_path).start_with?("#{root_dir}/lib")
end