J
Joel VanderWerf
This little script generates a simple web page containing a table of
(name, title, link-to-rdocs) for each installed gem. Could something
like this be incorporated into gem so that each time a gem is installed
you get a nice links page?
#!/usr/bin/env ruby
require "amrita/template"
include Amrita
Dir.chdir "/usr/local/lib/ruby/gems/1.8/doc"
tmpl = TemplateText.new <<END
<table border="1">
<tr><th>Name</th><th>Title</th><th>Gem Docs</tr>
<tr id=table1>
<td id="name"></td>
<td id="title"></td>
<td><a id="gemdocs"></a></td>
</tr>
</table>
END
links = Dir['*/rdoc/index.html']
linkdata = links.map do |link|
{
:name => link[/(.*?)\//,1],
:title =>
File.open(link).grep(/<title>/)[0][/<title>(.*?)<\/title>/,1],
:gemdocs => ahref=>link) { link }
}
end
data = {
:table1 => linkdata
}
tmpl.prettyprint = true
tmpl.expand(File.open("index.html", "w"), data)
(name, title, link-to-rdocs) for each installed gem. Could something
like this be incorporated into gem so that each time a gem is installed
you get a nice links page?
#!/usr/bin/env ruby
require "amrita/template"
include Amrita
Dir.chdir "/usr/local/lib/ruby/gems/1.8/doc"
tmpl = TemplateText.new <<END
<table border="1">
<tr><th>Name</th><th>Title</th><th>Gem Docs</tr>
<tr id=table1>
<td id="name"></td>
<td id="title"></td>
<td><a id="gemdocs"></a></td>
</tr>
</table>
END
links = Dir['*/rdoc/index.html']
linkdata = links.map do |link|
{
:name => link[/(.*?)\//,1],
:title =>
File.open(link).grep(/<title>/)[0][/<title>(.*?)<\/title>/,1],
:gemdocs => ahref=>link) { link }
}
end
data = {
:table1 => linkdata
}
tmpl.prettyprint = true
tmpl.expand(File.open("index.html", "w"), data)