module RuboCop::SketchUp::ExtensionProject

Public Instance Methods

config_path() click to toggle source

@return [Pathname]

# File lib/rubocop/sketchup/extension_project.rb, line 12
def config_path
  path = config.instance_variable_get(:@loaded_path)
  if path
    Pathname.new(path).expand_path.dirname
  else
    Pathname.new(Dir.pwd).expand_path
  end
end
extension_directory() click to toggle source
# File lib/rubocop/sketchup/extension_project.rb, line 59
def extension_directory
  extension_root_file.dirname
end
extension_root_file() click to toggle source
# File lib/rubocop/sketchup/extension_project.rb, line 50
def extension_root_file
  unless extension_root_files.size == 1
    num_files = extension_root_files.size
    raise "More than one root extension file (#{num_files})"
  end

  extension_root_files.first
end
extension_root_files() click to toggle source
# File lib/rubocop/sketchup/extension_project.rb, line 46
def extension_root_files
  Dir.glob("#{source_path}/*.rb").map { |path| Pathname.new(path) }
end
path_relative_to_source(processed_source) click to toggle source

@param [RuboCop::ProcessedSource] processed_source

# File lib/rubocop/sketchup/extension_project.rb, line 32
def path_relative_to_source(processed_source)
  source_filename = processed_source.buffer.name
  rel_path = config.path_relative_to_config(source_filename)
  path = Pathname.new(rel_path).expand_path
  path.relative_path_from(source_path)
end
relative_source_path() click to toggle source

@return [Pathname]

# File lib/rubocop/sketchup/extension_project.rb, line 22
def relative_source_path
  Pathname.new(extension_source_path_config)
end
root_file?(processed_source) click to toggle source

@param [RuboCop::ProcessedSource] processed_source

# File lib/rubocop/sketchup/extension_project.rb, line 40
def root_file?(processed_source)
  filename = path_relative_to_source(processed_source)
  filename.extname.casecmp('.rb').zero? &&
    filename.parent.to_s == '.'
end
source_path() click to toggle source

@return [Pathname]

# File lib/rubocop/sketchup/extension_project.rb, line 27
def source_path
  config_path.join(relative_source_path)
end