skip to main
|
skip to sidebar
2007/04/18
Processing Tag files with Ruby
#!/usr/bin/env ruby
def proctag(tagline)
# {tagname}
{tagfile}
{tagaddress}[;"
{tagfield}..]
# "A tagfield has a name, a colon, and a value: "name:value".
# The name of the "kind:" field can be omitted. A program reading the
# tags file can recognize the "kind:" field by the missing ':'.
ret = Array.new
# tagname
idxb = 0
idxe = tagline.index("\t")
ret[0] = tagline[idxb..idxe-1]
# tagfile
idxb = idxe+1
idxe = tagline.index("\t",idxb)
ret[1] = tagline[idxb..idxe-1]
# tagaddress
idxb = idxe+1
idxe = tagline.index(";\"",idxb)
idxe = -1 if idxe == nil
ret[2] = tagline[idxb..idxe-1]
# tagfields
ret[3] = nil
ret[4] = nil
if idxe != -1
fldlst = tagline[idxe+1..-1].strip.split("\t")
for act in fldlst
# handle kind
if !act.include?(':')
ret[3] = act
else
ret[4] = Hash.new if ret[4] == nil
hm = act.split(':')
ret[4][hm[0]]=hm[1]
ret[3] = hm[1] if hm[0] == 'kind'
end
end
end
return ret
end
while gets
next if $_[0] == ?!
m = proctag($_.chomp)
print m[3]," ",m[0],"\n"
end
0 comments:
Post a Comment
Newer Post
Older Post
Home
Subscribe to:
Post Comments (Atom)
notebook
Posts
Atom
Posts
Comments
Atom
Comments
Links
del.icio.us/teki321
twitter [ENG]
twitter [HUN]
repcsi.hu - Family blog [HUN]
Krisz's blog - Cooking [HUN]
Labels
blog
(1)
dev
(1)
python
(1)
ruby
(1)
tool
(10)
Blog Archive
►
2008
(3)
►
December
(1)
Python: changing the class of an instance
►
March
(1)
print the content of the clipboard as text (Window...
►
January
(1)
Ruby and VIM
▼
2007
(8)
▼
April
(2)
Windows Freeware Diff/Merge application
Processing Tag files with Ruby
►
March
(2)
Mercurial - status produces wrong slashes on Windo...
Mercurial - kdiff3 - hgmerge
►
February
(2)
bzrvss
SPE - python ide download link
►
January
(2)
bazaar merge plugin: extmerge
bazaar, Mercurial, darcs
►
2006
(4)
►
December
(3)
bzr-gtk
Bazzar in practice, WinMerge patch, bzr-gtk
VSS -> Bazaar
►
November
(1)
Initial post
0 comments:
Post a Comment