A script that looks for obsolete URIs still in the code base.
This commit is contained in:
parent
1e2a9c575a
commit
1bf36caef7
6 changed files with 379 additions and 0 deletions
42
utilities/ISF-transition/obsoleteUris/obsolete_uris.rb
Normal file
42
utilities/ISF-transition/obsoleteUris/obsolete_uris.rb
Normal file
|
@ -0,0 +1,42 @@
|
|||
class ObsoleteUrisError < StandardError; end
|
||||
|
||||
class ObsoleteUris
|
||||
# ------------------------------------------------------------------------------------
|
||||
private
|
||||
# ------------------------------------------------------------------------------------
|
||||
|
||||
def get_localname(uri)
|
||||
delimiter = uri.rindex(/[\/#]/)
|
||||
return uri[delimiter+1..-1] if delimiter
|
||||
raise "BOGUS URI in obsolete_uris file -- no localname: '#{uri}'"
|
||||
end
|
||||
|
||||
# ------------------------------------------------------------------------------------
|
||||
public
|
||||
# ------------------------------------------------------------------------------------
|
||||
|
||||
def initialize(file)
|
||||
@uris = []
|
||||
@localnames = []
|
||||
File.read(file).split(/[\r\n]+/).each do |line|
|
||||
# ignore blank lines, and lines starting with '#' or '!'.
|
||||
line.strip!
|
||||
next if line.length == 0 || line[0..0] == '#' || line[0] == ?!
|
||||
|
||||
if line =~ /^(\S+)/
|
||||
@uris << $1
|
||||
@localnames << get_localname($1)
|
||||
else
|
||||
raise "BOGUS line in obsolete_uris file: '#{line}'"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def uris()
|
||||
@uris
|
||||
end
|
||||
|
||||
def localnames()
|
||||
@localnames
|
||||
end
|
||||
end
|
Loading…
Add table
Add a link
Reference in a new issue