Commit 0aa43634be4e7decfd8b7598e4838a2a6420d88d
Committed by
Paulo Meireles
1 parent
8f4bd8de
Exists in
master
and in
29 other branches
Moving service call from view to project_content
Showing
2 changed files
with
25 additions
and
11 deletions
Show diff stats
plugins/mezuro/lib/mezuro_plugin/project_content.rb
@@ -17,26 +17,39 @@ class MezuroPlugin::ProjectContent < Article | @@ -17,26 +17,39 @@ class MezuroPlugin::ProjectContent < Article | ||
17 | end | 17 | end |
18 | end | 18 | end |
19 | 19 | ||
20 | + def project | ||
21 | + Kalibro::Client::ProjectClient.new.project(title) | ||
22 | + end | ||
23 | + | ||
24 | + def project_result | ||
25 | + @project_result ||= Kalibro::Client::ProjectResultClient.new.last_result(title) | ||
26 | + end | ||
27 | + | ||
28 | + def module_result(module_name) | ||
29 | + @module_client ||= Kalibro::Client::ModuleResultClient.new | ||
30 | + @module_client.module_result(title, module_name, project_result.date) | ||
31 | + end | ||
32 | + | ||
20 | after_save :send_project_to_service | 33 | after_save :send_project_to_service |
21 | 34 | ||
22 | private | 35 | private |
23 | 36 | ||
24 | def send_project_to_service | 37 | def send_project_to_service |
25 | - Kalibro::Client::ProjectClient.save(project) | 38 | + Kalibro::Client::ProjectClient.save(create_project) |
26 | Kalibro::Client::KalibroClient.process_project(title) | 39 | Kalibro::Client::KalibroClient.process_project(title) |
27 | end | 40 | end |
28 | 41 | ||
29 | - def project | 42 | + def create_project |
30 | project = Kalibro::Entities::Project.new | 43 | project = Kalibro::Entities::Project.new |
31 | project.name = title | 44 | project.name = title |
32 | project.license = license | 45 | project.license = license |
33 | project.description = description | 46 | project.description = description |
34 | - project.repository = repository | 47 | + project.repository = create_repository |
35 | project.configuration_name = configuration_name | 48 | project.configuration_name = configuration_name |
36 | project | 49 | project |
37 | end | 50 | end |
38 | 51 | ||
39 | - def repository | 52 | + def create_repository |
40 | repository = Kalibro::Entities::Repository.new | 53 | repository = Kalibro::Entities::Repository.new |
41 | repository.type = repository_type | 54 | repository.type = repository_type |
42 | repository.address = repository_url | 55 | repository.address = repository_url |
plugins/mezuro/views/content_viewer/show_project.rhtml
1 | -<% @project = Kalibro::Client::ProjectClient.new.project(@page.name) %> | 1 | +<% @project = @page.project %> |
2 | 2 | ||
3 | <table id="project_info"> | 3 | <table id="project_info"> |
4 | <tr> | 4 | <tr> |
@@ -29,14 +29,16 @@ | @@ -29,14 +29,16 @@ | ||
29 | 29 | ||
30 | <br /> | 30 | <br /> |
31 | 31 | ||
32 | + | ||
33 | + | ||
32 | <% if ! @project.error.nil? %> | 34 | <% if ! @project.error.nil? %> |
33 | <h3><%= _('ERROR') %></h3> | 35 | <h3><%= _('ERROR') %></h3> |
34 | - <% @error = @project.error %> | ||
35 | <p> | 36 | <p> |
36 | <%= "State when error ocurred: #{@project.state}" %> | 37 | <%= "State when error ocurred: #{@project.state}" %> |
37 | <br/> | 38 | <br/> |
38 | - <%= @error.message %> | ||
39 | - <ul><% @error.stack_trace.each do |trace| %> | 39 | + <% error = @project.error %> |
40 | + <%= error.message %> | ||
41 | + <ul><% error.stack_trace.each do |trace| %> | ||
40 | <li><%= "#{trace.declaring_class}.#{trace.method_name}(#{trace.file_name}:#{trace.line_number})" %></li> | 42 | <li><%= "#{trace.declaring_class}.#{trace.method_name}(#{trace.file_name}:#{trace.line_number})" %></li> |
41 | <% end %></ul> | 43 | <% end %></ul> |
42 | </p> | 44 | </p> |
@@ -48,8 +50,7 @@ | @@ -48,8 +50,7 @@ | ||
48 | </p> | 50 | </p> |
49 | <% elsif @project.state == 'READY' %> | 51 | <% elsif @project.state == 'READY' %> |
50 | <h3><%= _('LAST RESULT') %></h3> | 52 | <h3><%= _('LAST RESULT') %></h3> |
51 | - <% @project_result = Kalibro::Client::ProjectResultClient.new.last_result(@project.name) %> | ||
52 | - <% @module_client = Kalibro::Client::ModuleResultClient.new %> | 53 | + <% @project_result = @page.project_result %> |
53 | 54 | ||
54 | <table id="project_result_info"> | 55 | <table id="project_result_info"> |
55 | <tr> | 56 | <tr> |
@@ -68,7 +69,7 @@ | @@ -68,7 +69,7 @@ | ||
68 | <h5><%= _('Source tree') %></h5> | 69 | <h5><%= _('Source tree') %></h5> |
69 | <%= @project_result.source_tree.print %> | 70 | <%= @project_result.source_tree.print %> |
70 | 71 | ||
71 | - <% @module_result = @module_client.module_result(@project.name, @project.name, @project_result.date) %> | 72 | + <% @module_result = @page.module_result(@project.name) %> |
72 | 73 | ||
73 | <h5><%= _('Metric Result') %> </h5> | 74 | <h5><%= _('Metric Result') %> </h5> |
74 | <strong> | 75 | <strong> |