Commit d2957e16f672299dd4d945b10b191d3af48ee6ed
Committed by
João M. M. da Silva
1 parent
d4addbf0
Exists in
master
and in
23 other branches
added samples to new configuration method
Showing
8 changed files
with
61 additions
and
4 deletions
Show diff stats
plugins/mezuro/controllers/mezuro_plugin_profile_controller.rb
... | ... | @@ -27,4 +27,8 @@ class MezuroPluginProfileController < ProfileController |
27 | 27 | render :partial => 'content_viewer/module_result', :locals => { :module_result => module_result} |
28 | 28 | end |
29 | 29 | |
30 | + def teste | |
31 | + @configuration_name = params[:configuration_name] | |
32 | + end | |
33 | + | |
30 | 34 | end | ... | ... |
plugins/mezuro/lib/kalibro/entities/configuration.rb
... | ... | @@ -17,9 +17,9 @@ class Kalibro::Entities::Configuration < Kalibro::Entities::Entity |
17 | 17 | end |
18 | 18 | |
19 | 19 | def create_metric_configurations(metrics) |
20 | - @metric_configurations = [] | |
20 | + @metric_configuration = [] | |
21 | 21 | metrics.each do |metric| |
22 | - @metric_configurations << create_metric_configuration(metric) | |
22 | + @metric_configuration << create_metric_configuration(metric) | |
23 | 23 | end |
24 | 24 | end |
25 | 25 | |
... | ... | @@ -28,6 +28,8 @@ class Kalibro::Entities::Configuration < Kalibro::Entities::Entity |
28 | 28 | origin = splitted_metric[0] |
29 | 29 | name = splitted_metric[1] |
30 | 30 | metric = Kalibro::Entities::NativeMetric.new_with_origin_and_name(origin, name) |
31 | + metric.scope = 'CLASS' | |
32 | + metric.languages = ['JAVA'] | |
31 | 33 | Kalibro::Entities::MetricConfiguration.new_with_metric_and_code(metric, name) |
32 | 34 | end |
33 | 35 | ... | ... |
plugins/mezuro/lib/kalibro/entities/metric_configuration.rb
... | ... | @@ -7,9 +7,18 @@ class Kalibro::Entities::MetricConfiguration < Kalibro::Entities::Entity |
7 | 7 | configuration = new |
8 | 8 | configuration.metric = metric |
9 | 9 | configuration.code = code |
10 | + configuration.ranges = [new_range] | |
10 | 11 | configuration |
11 | 12 | end |
12 | 13 | |
14 | + def self.new_range | |
15 | + created_range = Kalibro::Entities::Range.new | |
16 | + created_range.beginning = 0 | |
17 | + created_range.end = 10 | |
18 | + created_range.label = "" | |
19 | + created_range | |
20 | + end | |
21 | + | |
13 | 22 | def metric=(value) |
14 | 23 | if value.kind_of?(Hash) |
15 | 24 | @metric = to_entity(value, Kalibro::Entities::CompoundMetric) if value.has_key?(:script) | ... | ... |
plugins/mezuro/lib/mezuro_plugin/metric_configuration_content.rb
0 → 100644
... | ... | @@ -0,0 +1,37 @@ |
1 | +class MezuroPlugin::MetricConfigurationContent < Article | |
2 | + | |
3 | + def self.short_description | |
4 | + 'Kalibro Configurated Metric' | |
5 | + end | |
6 | + | |
7 | + def self.description | |
8 | + 'Sets of thresholds to interpret a metric' | |
9 | + end | |
10 | + | |
11 | + settings_items :description, :code, :weight, :scope, :aggregation_form, :range | |
12 | + | |
13 | + include ActionView::Helpers::TagHelper | |
14 | + def to_html(options = {}) | |
15 | + lambda do | |
16 | + render :file => 'content_viewer/show_configuration.rhtml' | |
17 | + end | |
18 | + end | |
19 | + | |
20 | + def metric_configuration | |
21 | + Kalibro::Client::MetricConfigurationClient.metric_configuration(name) | |
22 | + end | |
23 | + | |
24 | + after_save :send_metric_configuration_to_service | |
25 | + after_destroy :remove_metric_configuration_from_service | |
26 | + | |
27 | + private | |
28 | + | |
29 | + def send_metric_configuration_to_service | |
30 | + Kalibro::Client::MetricConfigurationClient.save(self) | |
31 | + end | |
32 | + | |
33 | + def remove_metric_configuration_from_service | |
34 | + Kalibro::Client::MetricConfigurationClient.remove(name) | |
35 | + end | |
36 | + | |
37 | +end | ... | ... |
plugins/mezuro/public/javascripts/project_content.js
plugins/mezuro/views/cms/mezuro_plugin/_configuration_content.html.erb
... | ... | @@ -31,7 +31,7 @@ end |
31 | 31 | metric_id = collector_name + ":" + metric.name %> |
32 | 32 | <tr class="metric" title="<%= metric.description %>"> |
33 | 33 | <td> |
34 | - <% #FIXME Tratar caso com 0 métricas selecionadas | |
34 | + <% #FIXME Tratar caso com 0 métricas selecionadas %> | |
35 | 35 | <%= check_box_tag "article[metrics][]", metric_id, false, {:id => metric_id.gsub(/[\/ ]/, '_')} %> |
36 | 36 | <%= label_tag metric_id, metric.name %> |
37 | 37 | </td> | ... | ... |
plugins/mezuro/views/content_viewer/show_configuration.rhtml
... | ... | @@ -11,6 +11,10 @@ |
11 | 11 | </tr> |
12 | 12 | </table> |
13 | 13 | |
14 | +<%= link_to "Teste", "/profile/#{profile.identifier}/plugins/mezuro/teste" %> | |
15 | +<%= link_to "Teste", :controller => "mezuro_plugin_profile", :action => "teste", :params => {:configuration_name => | |
16 | +@configuration_content.name}%> | |
17 | + | |
14 | 18 | <h3>Metrics</h3> |
15 | 19 | <% @tool_names = Kalibro::Client::BaseToolClient.new |
16 | 20 | @tool_names.base_tool_names.each do |collector_name| %> | ... | ... |
plugins/mezuro/views/mezuro_plugin_profile/teste.html.erb
0 → 100644
... | ... | @@ -0,0 +1 @@ |
1 | +<h3><%= @configuration_name %></h3> | ... | ... |