mirror of
https://gitea.invidious.io/iv-org/shard-spectator.git
synced 2024-08-15 00:53:35 +00:00
Parse source strings
This commit is contained in:
parent
268db53bf8
commit
4f3ca20741
2 changed files with 31 additions and 0 deletions
|
@ -11,6 +11,18 @@ module Spectator
|
|||
def initialize(@file, @line)
|
||||
end
|
||||
|
||||
# Parses a source from a string.
|
||||
def self.parse(string)
|
||||
# Make sure to handle multiple colons.
|
||||
# If this ran on Windows, there's a possibility of a colon in the path.
|
||||
# The last element should always be the line number.
|
||||
parts = string.split(':')
|
||||
path = parts[0...-1].join(':')
|
||||
line = parts.last
|
||||
file = File.expand_path(path)
|
||||
self.new(file, line.to_i)
|
||||
end
|
||||
|
||||
# The relative path to the file from the current directory.
|
||||
# If the file isn't in the current directory or a sub-directory,
|
||||
# then the absolute path is provided.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue