Module: Bugsage::EditorLinks

Defined in:
lib/bugsage/editor_links.rb

Class Method Summary collapse

Class Method Details

.cursor_url(file_path, line = 1, column = 1) ⇒ Object



22
23
24
# File 'lib/bugsage/editor_links.rb', line 22

def cursor_url(file_path, line = 1, column = 1)
  "cursor://file/#{escape_path(file_path)}:#{line}:#{column}"
end

.escape_path(file_path) ⇒ Object



30
31
32
# File 'lib/bugsage/editor_links.rb', line 30

def escape_path(file_path)
  file_path.to_s.gsub(" ", "%20")
end

.for_location(location) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/bugsage/editor_links.rb', line 7

def for_location(location)
  file_path, line_number = CodeContext.extract_location(location)
  return {} unless file_path

  absolute = File.expand_path(file_path)
  line = line_number || 1

  {
    file_path: absolute,
    line_number: line,
    cursor: cursor_url(absolute, line),
    vscode: vscode_url(absolute, line)
  }
end

.vscode_url(file_path, line = 1, column = 1) ⇒ Object



26
27
28
# File 'lib/bugsage/editor_links.rb', line 26

def vscode_url(file_path, line = 1, column = 1)
  "vscode://file/#{escape_path(file_path)}:#{line}:#{column}"
end