Polish the obsolete_URI script, so it can be used to scan an active workspace, not just a released directory.
This commit is contained in:
parent
354fe56def
commit
a7e53d9ac0
6 changed files with 96 additions and 18 deletions
|
@ -5,9 +5,15 @@ class Event
|
|||
attr_reader :string
|
||||
attr_reader :is_localname
|
||||
|
||||
require 'pathname'
|
||||
|
||||
# ------------------------------------------------------------------------------------
|
||||
private
|
||||
# ------------------------------------------------------------------------------------
|
||||
|
||||
def relativize(root, path)
|
||||
Pathname.new(path).relative_path_from(Pathname.new(root)).to_s
|
||||
end
|
||||
|
||||
# ------------------------------------------------------------------------------------
|
||||
public
|
||||
|
@ -21,7 +27,11 @@ class Event
|
|||
@is_localname = string[0] == ?:
|
||||
end
|
||||
|
||||
def to_s()
|
||||
"#{@path} \n #{@line_number} #{@line} \n #{@string} #{@is_localname ? "Localname" : "URI"}"
|
||||
def to_s(directory_root = nil)
|
||||
if directory_root
|
||||
"#{relativize(directory_root, @path)} \n #{@line_number} #{@line} \n #{@string} #{@is_localname ? "Localname" : "URI"}"
|
||||
else
|
||||
"#{@path} \n #{@line_number} #{@line} \n #{@string} #{@is_localname ? "Localname" : "URI"}"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue