Class: CycleDetectionAction
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 CycleDetectionAction.
47
48
49
50
51
52
|
# File 'lib/kwala/actions/cycle_detection.rb', line 47
def initialize
@cycle_detector = CycleDetector.new
@cycle_detector.print_strategy = self
@output_directory = nil
@cycles = nil
end
|
Instance Method Details
#build_action(context) ⇒ Object
54
55
56
57
|
# File 'lib/kwala/actions/cycle_detection.rb', line 54
def build_action(context)
@cycle_detector.make_graph(context.project_directory)
end
|
#detailed_display(context) ⇒ Object
84
85
86
87
88
89
90
91
92
93
94
95
96
97
|
# File 'lib/kwala/actions/cycle_detection.rb', line 84
def detailed_display(context)
template = TemplateFile.new(self.class.detailed_template_file)
@output_directory = context.output_directory
@cycle_detector.print_graph
["demos.jar", "prefuse.jar"].each do |jarfile|
FileUtils.cp(EXTERNAL_DIR + jarfile, context.output_directory)
end
det_res = ProjectBuilderUtils.expand_template(template, context.amrita_data)
det_file = "#{context.output_directory}/#{context.project_name}_cycle.html"
[det_file, det_res]
end
|
#print_cycles(cycles) ⇒ Object
114
115
116
|
# File 'lib/kwala/actions/cycle_detection.rb', line 114
def print_cycles(cycles)
@cycles = cycles
end
|
#print_graph(graph) ⇒ Object
100
101
102
103
104
105
106
107
108
109
110
111
112
|
# File 'lib/kwala/actions/cycle_detection.rb', line 100
def print_graph(graph)
graph_ml = CycleDetector::GraphMLPrintStrategy.new
begin
oldstd = $stdout
$stdout = StringIO.new
graph_ml.print_graph(graph)
gxml = $stdout.string
ensure
$stdout = oldstd
end
File.open(@output_directory + "/require_graph.xml", "w") { |f| f.puts gxml }
end
|
#summary_display(context) ⇒ Object
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
|
# File 'lib/kwala/actions/cycle_detection.rb', line 60
def summary_display(context)
template = TemplateFile.new(self.class.summary_template_file)
@cycle_detector.print_unique_cycles( @cycle_detector.find_cycles )
if @cycles.empty?
context.amrita_data[:cycle_results] = "There are no require cycles."
else
data = @cycles.map do |cycle|
{
:name => "#{ cycle.first} <=> #{ cycle.last }",
:list => cycle
}
end
context.amrita_data[:cycle_results] = { :entry => data }
end
loc_base = "#{context.project_name}_cycle.html"
context.amrita_data[:cycle_details] =
Amrita.e(:a, :href => loc_base ) { "Require Graph Details" }
summary_expand(template, context)
end
|