Class: VCLog::Report
- Inherits:
-
Object
- Object
- VCLog::Report
- Defined in:
- lib/vclog/report.rb
Overview
The Report class acts a controller for outputing change log / release history.
Constant Summary collapse
- DIR =
Directory of this file, so as to locate templates.
File.dirname(__FILE__)
Instance Attribute Summary collapse
-
#options ⇒ Object
readonly
OpenStruct of report options.
-
#repo ⇒ Object
readonly
Instance of VCLog::Repo.
Instance Method Summary collapse
-
#changelog ⇒ Object
Returns a Changelog object.
-
#email ⇒ Object
Email address as given on the command line or from the repo.
-
#h(input) ⇒ Object
private
HTML escape.
-
#homepage ⇒ Object
TODO.
-
#initialize(repo, options) ⇒ Report
constructor
Setup new Reporter instance.
-
#print ⇒ Object
Print report.
-
#r(input) ⇒ Object
private
Convert from RDoc to HTML.
-
#rdoc ⇒ RDoc::Markup::ToHtml
private
RDoc converter.
-
#releases ⇒ Object
Compute and return set of releases for
changelogchanges. -
#repository ⇒ Object
Repo repository URL.
-
#require_formatter(format) ⇒ Object
private
Depending on the format special libraries may by required.
-
#title ⇒ Object
Report title.
-
#url ⇒ Object
Repository URL.
-
#user ⇒ Object
User as given by the command line or from the repo.
Constructor Details
#initialize(repo, options) ⇒ Report
Setup new Reporter instance.
33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/vclog/report.rb', line 33 def initialize(repo, ) @repo = repo = case when Hash OpenStruct.new() else end .level ||= 0 end |
Instance Attribute Details
#options ⇒ Object (readonly)
OpenStruct of report options.
25 26 27 |
# File 'lib/vclog/report.rb', line 25 def end |
#repo ⇒ Object (readonly)
Instance of VCLog::Repo.
20 21 22 |
# File 'lib/vclog/report.rb', line 20 def repo @repo end |
Instance Method Details
#changelog ⇒ Object
Returns a Changelog object.
48 49 50 51 |
# File 'lib/vclog/report.rb', line 48 def changelog changes = .point ? repo.changes : repo.change_points ChangeLog.new(changes).above(.level) end |
#email ⇒ Object
Email address as given on the command line or from the repo.
70 71 72 |
# File 'lib/vclog/report.rb', line 70 def email .email || repo.email end |
#h(input) ⇒ Object (private)
HTML escape.
154 155 156 157 158 159 160 161 162 163 |
# File 'lib/vclog/report.rb', line 154 def h(input) result = input.to_s.dup result.gsub!("&", "&") result.gsub!("<", "<") result.gsub!(">", ">") result.gsub!("'", "'") #result.gsub!("@", "&at;") result.gsub!("\"", """) return result end |
#homepage ⇒ Object
TODO
91 92 93 |
# File 'lib/vclog/report.rb', line 91 def homepage .homepage end |
#print ⇒ Object
Print report.
116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 |
# File 'lib/vclog/report.rb', line 116 def print .type ||= 'changelog' .format ||= 'ansi' require_formatter(.format) tmp_file = Dir[File.join(DIR, 'templates', "#{options.type}.#{options.format}.{erb,rb}")].first tmp = File.read(tmp_file) case File.extname(tmp_file) when '.rb' eval(tmp, binding, tmp_file) when '.erb' erb = ERB.new(tmp, nil, '<>') erb.result(binding) else raise "unrecognized template - #{tmp_file}" end end |
#r(input) ⇒ Object (private)
Convert from RDoc to HTML.
168 169 170 |
# File 'lib/vclog/report.rb', line 168 def r(input) rdoc.convert(input) end |
#rdoc ⇒ RDoc::Markup::ToHtml (private)
RDoc converter.
177 178 179 180 181 182 183 |
# File 'lib/vclog/report.rb', line 177 def rdoc @_rdoc ||= ( gem 'rdoc' rescue nil # to ensure latest version require 'rdoc' RDoc::Markup::ToHtml.new ) end |
#releases ⇒ Object
Compute and return set of releases for changelog changes.
56 57 58 |
# File 'lib/vclog/report.rb', line 56 def releases repo.releases(changelog.changes) end |
#repository ⇒ Object
Repo repository URL.
77 78 79 |
# File 'lib/vclog/report.rb', line 77 def repository repo.repository end |
#require_formatter(format) ⇒ Object (private)
Depending on the format special libraries may by required.
142 143 144 145 146 147 148 149 |
# File 'lib/vclog/report.rb', line 142 def require_formatter(format) case format.to_s when 'yaml' require 'yaml' when 'json' require 'json' end end |
#title ⇒ Object
Report title.
100 101 102 103 104 105 106 107 108 |
# File 'lib/vclog/report.rb', line 100 def title return .title if .title case .type when :history "RELEASE HISTORY" else "CHANGELOG" end end |
#url ⇒ Object
Ensure this is being provided.
Repository URL.
86 87 88 |
# File 'lib/vclog/report.rb', line 86 def url .url || repo.repository end |
#user ⇒ Object
User as given by the command line or from the repo.
63 64 65 |
# File 'lib/vclog/report.rb', line 63 def user .user || repo.user end |