class VCLog::Report
The Report
class acts a controller for outputing change log / release history.
Constants
- DIR
Directory of this file, so as to locate templates.
Attributes
options[R]
OpenStruct of report options.
repo[R]
Instance of VCLog::Repo
.
Public Class Methods
new(repo, options)
click to toggle source
Setup new Reporter instance.
@param [Repo] repo
An instance of VCLog::Repo.
# File lib/vclog/report.rb, line 33 def initialize(repo, options) @repo = repo options[:type] ||= 'changelog' options[:format] ||= 'ansi' @options = OpenStruct.new(options) @options.level ||= 0 end
Public Instance Methods
changelog()
click to toggle source
Returns a Changelog object.
# File lib/vclog/report.rb, line 47 def changelog changes = options.point ? repo.changes : repo.change_points ChangeLog.new(changes).above(options.level) end
email()
click to toggle source
Email address as given on the command line or from the repo.
# File lib/vclog/report.rb, line 83 def email options.email || repo.email end
format()
click to toggle source
Report
format.
# File lib/vclog/report.rb, line 69 def format options.format end
homepage()
click to toggle source
TODO
# File lib/vclog/report.rb, line 104 def homepage options.homepage end
print()
click to toggle source
Print report.
# File lib/vclog/report.rb, line 129 def print require_formatter(format) tmpl_glob = File.join(DIR, 'templates', "#{type}.#{format}.{erb,rb}") tmpl_file = Dir[tmpl_glob].first raise "could not find template -- #{tmp_glob}" unless tmpl_file tmpl = File.read(tmpl_file) case File.extname(tmpl_file) when '.rb' eval(tmpl, binding, tmpl_file) when '.erb' erb = ERB.new(tmpl, nil, '<>') erb.result(binding) else raise "unrecognized template type -- #{tmpl_file}" end end
releases()
click to toggle source
Compute and return set of releases for changelog
changes.
# File lib/vclog/report.rb, line 55 def releases repo.releases(changelog.changes) end
repository()
click to toggle source
Repo
repository URL.
# File lib/vclog/report.rb, line 90 def repository repo.repository end
title()
click to toggle source
Report
title.
# File lib/vclog/report.rb, line 113 def title return options.title if options.title case type when :history "RELEASE HISTORY" else "CHANGELOG" end end
type()
click to toggle source
Report
type.
# File lib/vclog/report.rb, line 62 def type options.type end
url()
click to toggle source
Repository URL.
@todo Ensure this is being provided.
# File lib/vclog/report.rb, line 99 def url options.url || repo.repository end
user()
click to toggle source
User as given by the command line or from the repo.
# File lib/vclog/report.rb, line 76 def user options.user || repo.user end
Private Instance Methods
h(input)
click to toggle source
HTML escape.
# File lib/vclog/report.rb, line 167 def h(input) result = input.to_s.dup result.gsub!("&", "&") result.gsub!("<", "<") result.gsub!(">", ">") result.gsub!("'", "'") #result.gsub!("@", "&at;") result.gsub!("\"", """) return result end
r(input)
click to toggle source
Convert from RDoc to HTML.
# File lib/vclog/report.rb, line 181 def r(input) rdoc.convert(input) end
rdoc()
click to toggle source
RDoc converter.
@return [RDoc::Markup::ToHtml] rdoc markup HTML converter.
# File lib/vclog/report.rb, line 190 def rdoc @_rdoc ||= ( gem 'rdoc' rescue nil # to ensure latest version require 'rdoc' RDoc::Markup::ToHtml.new ) end
require_formatter(format)
click to toggle source
Depending on the format special libraries may by required.
# File lib/vclog/report.rb, line 155 def require_formatter(format) case format.to_s when 'yaml' require 'yaml' when 'json' require 'json' end end