Module: RuboCop::SketchUp::ExtensionProject

Constant Summary

Constants included from Config

Config::DEFAULT_CONFIGURATION

Instance Method Summary collapse

Instance Method Details

#config_pathPathname

Returns:

  • (Pathname)


12
13
14
15
16
17
18
19
# 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

#path_relative_to_source(processed_source) ⇒ Object

Parameters:

  • processed_source (RuboCop::ProcessedSource)


32
33
34
35
36
37
# 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_pathPathname

Returns:

  • (Pathname)


22
23
24
# File 'lib/rubocop/sketchup/extension_project.rb', line 22

def relative_source_path
  Pathname.new(sketchup_source_path_config)
end

#root_file?(processed_source) ⇒ Boolean

Parameters:

  • processed_source (RuboCop::ProcessedSource)

Returns:

  • (Boolean)


40
41
42
43
44
# File 'lib/rubocop/sketchup/extension_project.rb', line 40

def root_file?(processed_source)
  filename = path_relative_to_source(processed_source)
  filename.extname.downcase == '.rb' &&
    filename.parent.to_s == '.'
end

#source_pathPathname

Returns:

  • (Pathname)


27
28
29
# File 'lib/rubocop/sketchup/extension_project.rb', line 27

def source_path
  config_path.join(relative_source_path)
end