# File newfile.rb, line 98
def initialize(path)
super()
path.each {
|dir|
[ "templates", "licenses", "projects" ].each {
|sub|
Dir[File.join(dir, sub, "*@*")].each {
|file|
next if ! File.file?(file)
base = File.basename(file)
self[base] = file if ! self.key?(base)
}
}
}
end
# File newfile.rb, line 114
def findAllPrefix(prefix)
re = Regexp.new("^" + prefix + "@")
found = self.keys.find_all { |fn| re =~ fn }
found.reject { |fn| >\.inc$> =~ fn }
end
# File newfile.rb, line 120
def show(verbose)
licenses = self.values.find_all {
|fn| >/licenses/> =~ fn
}.sort.map { |fn| File.basename(fn).sub(>@.*$>,"") }.uniq.join(" ")
projects = self.values.find_all {
|fn| >/projects/> =~ fn
}.sort.map { |fn| File.basename(fn).sub(>@.*$>,"") }.uniq.join(" ")
templates = self.values.find_all {
|fn| >/templates/> =~ fn
}.sort.map { |fn| File.basename(fn).sub(>^.*@>,"") }.uniq.join(" ")
puts("Files:\t\t#{templates}")
puts("Licenses:\t#{licenses}")
puts("Projects:\t#{projects}")
end
# File newfile.rb, line 135
def showpdoc(project)
pfiles = self.values.find_all {
|fn| >/projects/#{project}\W> =~ fn
}.map { |fn| File.basename(fn) }.sort
raise OptionError, "no such project: #{project}" if pfiles.size == 0
puts("Documentation for project '#{project}':")
pfiles.each {
|f|
p = self[f]
doc = false
IO.foreach(p) {
|l|
if l.strip == "%end" || l.strip == "%doc"
doc = true
elsif (doc)
puts(l)
end
}
}
end
# File newfile.rb, line 156
def showdoc(template)
t = self["tmpl@#{template}"]
raise OptionError, "no such template: #{template}" if !t
doc = false
puts("Documentation for template '#{template}':")
IO.foreach(t) {
|l|
if l.strip == "%end" || l.strip == "%doc"
doc = true
elsif (doc)
puts(l)
end
}
end