Class: FlaggedCommentsAction
Constant Summary
collapse
[ "BUG", "FIXME", "???", "TODO", "XXX" ]
Regexp.new("\#\s*(" +
COMMENTFLAGS.map { |i| Regexp.escape(i)}.join("|") +
")\s*:?(.*)")
Instance Method Summary
collapse
Methods inherited from BuildAction
command_line_action_name, command_line_action_names, create_action_from_command_line_name, detailed_template_file, #score, summary_template_file
#get_implementors
Constructor Details
Returns a new instance of FlaggedCommentsAction.
49
50
51
|
# File 'lib/kwala/actions/flagged_comments.rb', line 49
def initialize
@comment_count = Hash.new { |h,k| h[k] = Array.new }
end
|
Instance Method Details
#annotate_url ⇒ Object
124
125
126
|
# File 'lib/kwala/actions/flagged_comments.rb', line 124
def annotate_url
"http://localhost/cgi-bin/viewcvs/cgi/viewcvs.cgi/"
end
|
#build_action(context) ⇒ Object
53
54
55
56
57
58
59
60
61
62
63
64
65
|
# File 'lib/kwala/actions/flagged_comments.rb', line 53
def build_action(context)
projbase = context.project_directory.split("/").last
(context.ruby_files + context.test_files).each do |file|
fcount = (file)
fcount.each do |cflag, val|
fnamemap = val.map do |idx, txt|
nfile = file.split(context.project_directory).last
["#{ projbase }/#{ nfile }\##{ idx }" , txt]
end
@comment_count[cflag].concat( fnamemap )
end
end
end
|
107
108
109
110
111
112
113
114
115
|
# File 'lib/kwala/actions/flagged_comments.rb', line 107
def (file)
res = Hash.new { |h,k| h[k] = Array.new }
IO.readlines(file).each_with_index do |line, idx|
if m = COMMENTREGEXP.match(line)
res[m[1]]<< [idx + 1 , m[2]]
end
end
res
end
|
#detailed_display(context) ⇒ Object
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
|
# File 'lib/kwala/actions/flagged_comments.rb', line 84
def detailed_display(context)
template = TemplateFile.new(self.class.detailed_template_file)
ares = COMMENTFLAGS.map do |ctype|
{ :type => ctype,
:count => @comment_count[ctype].size,
:entries => @comment_count[ctype].map do |file, txt|
{
:file => Amrita::e(:a, :href => link_to_file(file)) { file },
:txt => txt
}
end
}
end
context.amrita_data[:com_details] = { :entry => ares }
det_res = ProjectBuilderUtils.expand_template(template, context.amrita_data)
det_file = "#{context.output_directory}/#{context.project_name}_com.html"
[det_file, det_res]
end
|
#link_to_file(file) ⇒ Object
annotate does the line numbering and pointing
118
119
120
121
122
|
# File 'lib/kwala/actions/flagged_comments.rb', line 118
def link_to_file(file)
file, line = file.split("#")
view_url = annotate_url +
file.to_s + "?annotate=HEAD\#" + line.to_s
end
|
#summary_display(context) ⇒ Object
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
|
# File 'lib/kwala/actions/flagged_comments.rb', line 67
def summary_display(context)
template = TemplateFile.new(self.class.summary_template_file)
ares = COMMENTFLAGS.map do |ctype|
{ :type => ctype,
:count => @comment_count[ctype].size
}
end
context.amrita_data[:com_results] = { :entry => ares }
loc_base = "#{context.project_name}_com.html"
context.amrita_data[:com_details] =
(Amrita::e(:a, :href => loc_base) { "Flagged Comments Details" } )
summary_expand(template, context)
end
|