Commit 4e7213ba1eba2a78cbbf891da0c73e8a88e59a09

Authored by Paulo Meireles
2 parents 285c0e25 8cf59529

[Mezuro] Merge branch 'merging_configuration' into 'mezuro'

Conflicts:
	plugins/mezuro/lib/kalibro/client/kalibro_client.rb
	plugins/mezuro/views/content_viewer/_module_result.rhtml
Showing 51 changed files with 874 additions and 95 deletions   Show diff stats
plugins/mezuro/controllers/mezuro_plugin_profile_controller.rb
@@ -35,4 +35,93 @@ class MezuroPluginProfileController < ProfileController @@ -35,4 +35,93 @@ class MezuroPluginProfileController < ProfileController
35 render :partial =>'content_viewer/source_tree', :locals => { :source_tree => source_tree, :project_name => content.project.name} 35 render :partial =>'content_viewer/source_tree', :locals => { :source_tree => source_tree, :project_name => content.project.name}
36 end 36 end
37 37
  38 + def choose_base_tool
  39 + @configuration_name = params[:configuration_name]
  40 + @tool_names = Kalibro::Client::BaseToolClient.new
  41 + end
  42 +
  43 + def choose_metric
  44 + @configuration_name = params[:configuration_name]
  45 + @collector_name = params[:collector_name]
  46 + @collector = Kalibro::Client::BaseToolClient.new.base_tool(@collector_name)
  47 + end
  48 +
  49 + def new_metric_configuration
  50 + metric_name = params[:metric_name]
  51 + collector_name = params[:collector_name]
  52 + collector = Kalibro::Client::BaseToolClient.new.base_tool(collector_name)
  53 + @metric = collector.supported_metrics.find {|metric| metric.name == metric_name}
  54 + @configuration_name = params[:configuration_name]
  55 + end
  56 +
  57 + def edit_metric_configuration
  58 + metric_name = params[:metric_name]
  59 + @configuration_name = params[:configuration_name]
  60 + @metric_configuration = Kalibro::Client::MetricConfigurationClient.new.metric_configuration(@configuration_name, metric_name)
  61 + @metric = @metric_configuration.metric
  62 + end
  63 +
  64 + def create_metric_configuration
  65 + @configuration_name = params[:configuration_name]
  66 + metric_configuration = new_metric_configuration_instance
  67 + Kalibro::Client::MetricConfigurationClient.new.save(metric_configuration, @configuration_name)
  68 + redirect_to "/#{profile.identifier}/#{@configuration_name.downcase.gsub(/\s/, '-')}"
  69 + end
  70 +
  71 + def update_metric_configuration
  72 + @configuration_name = params[:configuration_name]
  73 + metric_configuration = new_metric_configuration_instance
  74 + Kalibro::Client::MetricConfigurationClient.new.save(metric_configuration, @configuration_name)
  75 + redirect_to "/#{profile.identifier}/#{@configuration_name.downcase.gsub(/\s/, '-')}"
  76 + end
  77 +
  78 + def new_range
  79 + @metric_name = params[:metric_name]
  80 + @configuration_name = params[:configuration_name]
  81 + end
  82 +
  83 + def create_range
  84 + @range = new_range_instance
  85 + configuration_name = params[:configuration_name]
  86 + metric_name = params[:metric_name]
  87 + metric_configuration_client = Kalibro::Client::MetricConfigurationClient.new
  88 + metric_configuration = metric_configuration_client.metric_configuration(configuration_name, metric_name)
  89 + metric_configuration.add_range(@range)
  90 + metric_configuration_client.save(metric_configuration, configuration_name)
  91 + end
  92 +
  93 + def remove_metric_configuration
  94 + configuration_name = params[:configuration_name]
  95 + metric_name = params[:metric_name]
  96 + Kalibro::Client::MetricConfigurationClient.new.remove(configuration_name, metric_name)
  97 + redirect_to "/#{profile.identifier}/#{configuration_name.downcase.gsub(/\s/, '-')}"
  98 + end
  99 +
  100 + private
  101 +
  102 + def new_metric_configuration_instance
  103 + metric_configuration = Kalibro::Entities::MetricConfiguration.new
  104 + metric_configuration.metric = Kalibro::Entities::NativeMetric.new
  105 + metric_configuration.metric.name = params[:metric][:name]
  106 + metric_configuration.metric.description = params[:description]
  107 + metric_configuration.metric.origin = params[:metric][:origin]
  108 + metric_configuration.metric.scope = params[:scope]
  109 + metric_configuration.metric.language = params[:language]
  110 + metric_configuration.code = params[:metric_configuration][:code]
  111 + metric_configuration.weight = params[:metric_configuration][:weight]
  112 + metric_configuration.aggregation_form = params[:metric_configuration][:aggregation]
  113 + metric_configuration
  114 + end
  115 +
  116 + def new_range_instance
  117 + range = Kalibro::Entities::Range.new
  118 + range.beginning = params[:range][:beginning]
  119 + range.end = params[:range][:end]
  120 + range.label = params[:range][:label]
  121 + range.grade = params[:range][:grade]
  122 + range.color = params[:range][:color]
  123 + range.comments = params[:range][:comments]
  124 + range
  125 + end
38 end 126 end
  127 +
plugins/mezuro/lib/kalibro/client/base_tool_client.rb
@@ -13,4 +13,4 @@ class Kalibro::Client::BaseToolClient @@ -13,4 +13,4 @@ class Kalibro::Client::BaseToolClient
13 Kalibro::Entities::BaseTool.from_hash(hash) 13 Kalibro::Entities::BaseTool.from_hash(hash)
14 end 14 end
15 15
16 -end  
17 \ No newline at end of file 16 \ No newline at end of file
  17 +end
plugins/mezuro/lib/kalibro/client/kalibro_client.rb
1 class Kalibro::Client::KalibroClient 1 class Kalibro::Client::KalibroClient
  2 +
  3 + def self.process_project(project_name)
  4 + new.process_project(project_name)
  5 + end
2 6
3 def initialize 7 def initialize
4 @port = Kalibro::Client::Port.new('Kalibro') 8 @port = Kalibro::Client::Port.new('Kalibro')
@@ -12,16 +16,16 @@ class Kalibro::Client::KalibroClient @@ -12,16 +16,16 @@ class Kalibro::Client::KalibroClient
12 @port.request(:process_project, {:project_name => project_name}) 16 @port.request(:process_project, {:project_name => project_name})
13 end 17 end
14 18
15 - def process_periodically(project_name, days)  
16 - @port.request(:process_periodically, {:project_name => project_name, :period_in_days => days})  
17 - end 19 + def process_periodically(project_name, period_in_days)
  20 + @port.request(:process_periodically, {:project_name => project_name, :period_in_days => period_in_days})
  21 + end
  22 +
  23 + def process_period(project_name)
  24 + @port.request(:get_process_period, {:project_name => project_name})[:period]
  25 + end
18 26
19 - def self.process_project(project_name, days)  
20 - if days.to_i.zero?  
21 - new.process_project(project_name)  
22 - else  
23 - new.process_periodically(project_name, days)  
24 - end 27 + def cancel_periodic_process(project_name)
  28 + @port.request(:cancel_periodic_process, {:project_name => project_name})
25 end 29 end
26 30
27 end 31 end
plugins/mezuro/lib/kalibro/client/metric_configuration_client.rb 0 → 100644
@@ -0,0 +1,28 @@ @@ -0,0 +1,28 @@
  1 +class Kalibro::Client::MetricConfigurationClient
  2 +
  3 + def initialize
  4 + @port = Kalibro::Client::Port.new('MetricConfiguration')
  5 + end
  6 +
  7 + def save(metric_configuration, configuration_name)
  8 + @port.request(:save_metric_configuration, {
  9 + :metric_configuration => metric_configuration.to_hash,
  10 + :configuration_name => configuration_name})
  11 + end
  12 +
  13 + def metric_configuration(configuration_name, metric_name)
  14 + hash = @port.request(:get_metric_configuration, {
  15 + :configuration_name => configuration_name,
  16 + :metric_name => metric_name
  17 + })[:metric_configuration]
  18 + Kalibro::Entities::MetricConfiguration.from_hash(hash)
  19 + end
  20 +
  21 + def remove (configuration_name, metric_name)
  22 + @port.request(:remove_metric_configuration, {
  23 + :configuration_name => configuration_name,
  24 + :metric_name=> metric_name
  25 + })
  26 + end
  27 +
  28 +end
0 \ No newline at end of file 29 \ No newline at end of file
plugins/mezuro/lib/kalibro/client/module_result_client.rb
@@ -13,7 +13,7 @@ class Kalibro::Client::ModuleResultClient @@ -13,7 +13,7 @@ class Kalibro::Client::ModuleResultClient
13 def module_result(project_name, module_name, date) 13 def module_result(project_name, module_name, date)
14 hash = @port.request(:get_module_result, 14 hash = @port.request(:get_module_result,
15 {:project_name => project_name, :module_name => module_name, 15 {:project_name => project_name, :module_name => module_name,
16 - :date => date_with_milliseconds(date)})[:module_result] 16 + :date => Kalibro::Entities::Entity.date_with_milliseconds(date)})[:module_result]
17 Kalibro::Entities::ModuleResult.from_hash(hash) 17 Kalibro::Entities::ModuleResult.from_hash(hash)
18 end 18 end
19 19
@@ -23,11 +23,4 @@ class Kalibro::Client::ModuleResultClient @@ -23,11 +23,4 @@ class Kalibro::Client::ModuleResultClient
23 Kalibro::Entities::Entity.new.to_entity_array(value, Kalibro::Entities::ModuleResult) 23 Kalibro::Entities::Entity.new.to_entity_array(value, Kalibro::Entities::ModuleResult)
24 end 24 end
25 25
26 - private  
27 -  
28 - def date_with_milliseconds(date)  
29 - milliseconds = "." + (date.sec_fraction * 60 * 60 * 24 * 1000).to_s  
30 - date.to_s[0..18] + milliseconds + date.to_s[19..-1]  
31 - end  
32 -  
33 end 26 end
34 \ No newline at end of file 27 \ No newline at end of file
plugins/mezuro/lib/kalibro/client/port.rb
@@ -7,7 +7,8 @@ end @@ -7,7 +7,8 @@ end
7 class Kalibro::Client::Port 7 class Kalibro::Client::Port
8 8
9 def initialize(endpoint) 9 def initialize(endpoint)
10 - @client = Savon::Client.new("#{service_address}#{endpoint}Endpoint/?wsdl") 10 + @endpoint = endpoint
  11 + initialize_client
11 end 12 end
12 13
13 def service_address 14 def service_address
@@ -18,9 +19,20 @@ class Kalibro::Client::Port @@ -18,9 +19,20 @@ class Kalibro::Client::Port
18 @service_address 19 @service_address
19 end 20 end
20 21
  22 + def service_address=(address)
  23 + @service_address = address
  24 + initialize_client
  25 + end
  26 +
21 def request(action, request_body = nil) 27 def request(action, request_body = nil)
22 response = @client.request(:kalibro, action) { soap.body = request_body } 28 response = @client.request(:kalibro, action) { soap.body = request_body }
23 response.to_hash["#{action}_response".to_sym] 29 response.to_hash["#{action}_response".to_sym]
24 end 30 end
25 31
  32 + private
  33 +
  34 + def initialize_client
  35 + @client = Savon::Client.new("#{service_address}#{@endpoint}Endpoint/?wsdl")
  36 + end
  37 +
26 end 38 end
plugins/mezuro/lib/kalibro/entities/configuration.rb
@@ -7,7 +7,11 @@ class Kalibro::Entities::Configuration < Kalibro::Entities::Entity @@ -7,7 +7,11 @@ class Kalibro::Entities::Configuration < Kalibro::Entities::Entity
7 end 7 end
8 8
9 def metric_configurations 9 def metric_configurations
10 - @metric_configuration 10 + if @metric_configuration != nil
  11 + @metric_configuration
  12 + else
  13 + []
  14 + end
11 end 15 end
12 16
13 def metric_configurations=(metric_configurations) 17 def metric_configurations=(metric_configurations)
plugins/mezuro/lib/kalibro/entities/entity.rb
@@ -2,10 +2,19 @@ class Kalibro::Entities::Entity @@ -2,10 +2,19 @@ class Kalibro::Entities::Entity
2 2
3 def self.from_hash(hash) 3 def self.from_hash(hash)
4 entity = self.new 4 entity = self.new
5 - hash.each { |field, value| entity.set(field, value) } 5 + hash.each { |field, value| entity.set(field, value) if is_valid?(field) }
6 entity 6 entity
7 end 7 end
8 8
  9 + def self.is_valid?(field)
  10 + field.to_s[0] != '@' and field != :attributes!
  11 + end
  12 +
  13 + def self.date_with_milliseconds(date)
  14 + milliseconds = "." + (date.sec_fraction * 60 * 60 * 24 * 1000).to_s
  15 + date.to_s[0..18] + milliseconds + date.to_s[19..-1]
  16 + end
  17 +
9 def set(field, value) 18 def set(field, value)
10 send("#{field}=", value) if not field.to_s.start_with? '@' 19 send("#{field}=", value) if not field.to_s.start_with? '@'
11 end 20 end
@@ -24,16 +33,16 @@ class Kalibro::Entities::Entity @@ -24,16 +33,16 @@ class Kalibro::Entities::Entity
24 fields.each do |field| 33 fields.each do |field|
25 field_value = self.get(field) 34 field_value = self.get(field)
26 hash[field] = convert_to_hash(field_value) if ! field_value.nil? 35 hash[field] = convert_to_hash(field_value) if ! field_value.nil?
  36 + if need_xml_type?(field_value)
  37 + hash = {:attributes! => {}}.merge(hash)
  38 + hash[:attributes!][field.to_sym] = {
  39 + 'xmlns:xsi'=> 'http://www.w3.org/2001/XMLSchema-instance',
  40 + 'xsi:type' => 'kalibro:' + xml_class_name(field_value) }
  41 + end
27 end 42 end
28 hash 43 hash
29 end 44 end
30 45
31 - def convert_to_hash(value)  
32 - return value.collect { |element| convert_to_hash(element) } if value.kind_of?(Array)  
33 - return value.to_hash if value.kind_of?(Kalibro::Entities::Entity)  
34 - value  
35 - end  
36 -  
37 def ==(other) 46 def ==(other)
38 begin 47 begin
39 fields.each.inject(true) { |equal, field| equal && (self.get(field) == other.get(field)) } 48 fields.each.inject(true) { |equal, field| equal && (self.get(field) == other.get(field)) }
@@ -42,6 +51,8 @@ class Kalibro::Entities::Entity @@ -42,6 +51,8 @@ class Kalibro::Entities::Entity
42 end 51 end
43 end 52 end
44 53
  54 + protected
  55 +
45 def fields 56 def fields
46 instance_variable_names.each.collect { |variable| variable.to_s.sub(/@/, '').to_sym } 57 instance_variable_names.each.collect { |variable| variable.to_s.sub(/@/, '').to_sym }
47 end 58 end
@@ -50,4 +61,24 @@ class Kalibro::Entities::Entity @@ -50,4 +61,24 @@ class Kalibro::Entities::Entity
50 send("#{field}") 61 send("#{field}")
51 end 62 end
52 63
  64 + def convert_to_hash(value)
  65 + return value.collect { |element| convert_to_hash(element) } if value.is_a?(Array)
  66 + return value.to_hash if value.is_a?(Kalibro::Entities::Entity)
  67 + return self.class.date_with_milliseconds(value) if value.is_a?(DateTime)
  68 + return 'INF' if value.is_a?(Float) and value.infinite? == 1
  69 + return '-INF' if value.is_a?(Float) and value.infinite? == -1
  70 + value
  71 + end
  72 +
  73 + def need_xml_type?(value)
  74 + value.is_a?(Kalibro::Entities::Entity) and value.class.superclass != Kalibro::Entities::Entity
  75 + end
  76 +
  77 + def xml_class_name(entity)
  78 + xml_name = entity.class.name
  79 + xml_name["Kalibro::Entities::"] = ""
  80 + xml_name[0..0] = xml_name[0..0].downcase
  81 + xml_name + "Xml"
  82 + end
  83 +
53 end 84 end
plugins/mezuro/lib/kalibro/entities/error.rb
1 class Kalibro::Entities::Error < Kalibro::Entities::Entity 1 class Kalibro::Entities::Error < Kalibro::Entities::Entity
2 2
3 - attr_accessor :message, :stack_trace_element 3 + attr_accessor :error_class, :message, :stack_trace_element
4 4
5 def stack_trace_element=(value) 5 def stack_trace_element=(value)
6 @stack_trace_element = to_entity_array(value, Kalibro::Entities::StackTraceElement) 6 @stack_trace_element = to_entity_array(value, Kalibro::Entities::StackTraceElement)
plugins/mezuro/lib/kalibro/entities/metric.rb
@@ -2,4 +2,4 @@ class Kalibro::Entities::Metric &lt; Kalibro::Entities::Entity @@ -2,4 +2,4 @@ class Kalibro::Entities::Metric &lt; Kalibro::Entities::Entity
2 2
3 attr_accessor :name, :scope, :description 3 attr_accessor :name, :scope, :description
4 4
5 -end  
6 \ No newline at end of file 5 \ No newline at end of file
  6 +end
plugins/mezuro/lib/kalibro/entities/metric_configuration.rb
@@ -11,10 +11,19 @@ class Kalibro::Entities::MetricConfiguration &lt; Kalibro::Entities::Entity @@ -11,10 +11,19 @@ class Kalibro::Entities::MetricConfiguration &lt; Kalibro::Entities::Entity
11 end 11 end
12 end 12 end
13 13
  14 + def weight=(value)
  15 + @weight = value.to_f
  16 + end
  17 +
14 def range=(value) 18 def range=(value)
15 @range = to_entity_array(value, Kalibro::Entities::Range) 19 @range = to_entity_array(value, Kalibro::Entities::Range)
16 end 20 end
17 21
  22 + def add_range(new_range)
  23 + @range = [] if @range.nil?
  24 + @range << new_range
  25 + end
  26 +
18 def ranges 27 def ranges
19 @range 28 @range
20 end 29 end
@@ -23,4 +32,4 @@ class Kalibro::Entities::MetricConfiguration &lt; Kalibro::Entities::Entity @@ -23,4 +32,4 @@ class Kalibro::Entities::MetricConfiguration &lt; Kalibro::Entities::Entity
23 @range = ranges 32 @range = ranges
24 end 33 end
25 34
26 -end  
27 \ No newline at end of file 35 \ No newline at end of file
  36 +end
plugins/mezuro/lib/kalibro/entities/metric_result.rb
@@ -14,12 +14,17 @@ class Kalibro::Entities::MetricResult &lt; Kalibro::Entities::Entity @@ -14,12 +14,17 @@ class Kalibro::Entities::MetricResult &lt; Kalibro::Entities::Entity
14 end 14 end
15 end 15 end
16 16
  17 + def value=(value)
  18 + @value = value.to_f
  19 + end
  20 +
17 def range=(value) 21 def range=(value)
18 @range = to_entity(value, Kalibro::Entities::Range) 22 @range = to_entity(value, Kalibro::Entities::Range)
19 end 23 end
20 24
21 def descendent_result=(value) 25 def descendent_result=(value)
22 - @descendent_result = to_entity_array(value) 26 + array = value.kind_of?(Array) ? value : [value]
  27 + @descendent_result = array.collect {|element| element.to_f}
23 end 28 end
24 29
25 def descendent_results 30 def descendent_results
plugins/mezuro/lib/kalibro/entities/module_result.rb
@@ -6,6 +6,15 @@ class Kalibro::Entities::ModuleResult &lt; Kalibro::Entities::Entity @@ -6,6 +6,15 @@ class Kalibro::Entities::ModuleResult &lt; Kalibro::Entities::Entity
6 @module = to_entity(value, Kalibro::Entities::Module) 6 @module = to_entity(value, Kalibro::Entities::Module)
7 end 7 end
8 8
  9 + def date=(value)
  10 + @date = value
  11 + @date = DateTime.parse(value) if value.is_a?(String)
  12 + end
  13 +
  14 + def grade=(value)
  15 + @grade = value.to_f
  16 + end
  17 +
9 def metric_result=(value) 18 def metric_result=(value)
10 @metric_result = to_entity_array(value, Kalibro::Entities::MetricResult) 19 @metric_result = to_entity_array(value, Kalibro::Entities::MetricResult)
11 end 20 end
plugins/mezuro/lib/kalibro/entities/native_metric.rb
@@ -2,4 +2,16 @@ class Kalibro::Entities::NativeMetric &lt; Kalibro::Entities::Metric @@ -2,4 +2,16 @@ class Kalibro::Entities::NativeMetric &lt; Kalibro::Entities::Metric
2 2
3 attr_accessor :origin, :language 3 attr_accessor :origin, :language
4 4
  5 + def languages
  6 + @language
  7 + end
  8 +
  9 + def languages=(languages)
  10 + @language = languages
  11 + end
  12 +
  13 + def language=(value)
  14 + @language = to_entity_array(value)
  15 + end
  16 +
5 end 17 end
plugins/mezuro/lib/kalibro/entities/project_result.rb
@@ -6,6 +6,19 @@ class Kalibro::Entities::ProjectResult &lt; Kalibro::Entities::Entity @@ -6,6 +6,19 @@ class Kalibro::Entities::ProjectResult &lt; Kalibro::Entities::Entity
6 @project = to_entity(value, Kalibro::Entities::Project) 6 @project = to_entity(value, Kalibro::Entities::Project)
7 end 7 end
8 8
  9 + def date=(value)
  10 + @date = value
  11 + @date = DateTime.parse(value) if value.is_a?(String)
  12 + end
  13 +
  14 + def load_time=(value)
  15 + @load_time = value.to_i
  16 + end
  17 +
  18 + def analysis_time=(value)
  19 + @analysis_time = value.to_i
  20 + end
  21 +
9 def source_tree=(value) 22 def source_tree=(value)
10 @source_tree = to_entity(value, Kalibro::Entities::ModuleNode) 23 @source_tree = to_entity(value, Kalibro::Entities::ModuleNode)
11 end 24 end
plugins/mezuro/lib/kalibro/entities/range.rb
@@ -2,4 +2,18 @@ class Kalibro::Entities::Range &lt; Kalibro::Entities::Entity @@ -2,4 +2,18 @@ class Kalibro::Entities::Range &lt; Kalibro::Entities::Entity
2 2
3 attr_accessor :beginning, :end, :label, :grade, :color, :comments 3 attr_accessor :beginning, :end, :label, :grade, :color, :comments
4 4
  5 + def beginning=(value)
  6 + @beginning = value.to_f
  7 + @beginning = -1.0/0.0 if value == "-INF"
  8 + end
  9 +
  10 + def end=(value)
  11 + @end = value.to_f
  12 + @end = 1.0/0.0 if value == "INF"
  13 + end
  14 +
  15 + def grade=(value)
  16 + @grade = value.to_f
  17 + end
  18 +
5 end 19 end
6 \ No newline at end of file 20 \ No newline at end of file
plugins/mezuro/lib/kalibro/entities/stack_trace_element.rb
@@ -2,4 +2,8 @@ class Kalibro::Entities::StackTraceElement &lt; Kalibro::Entities::Entity @@ -2,4 +2,8 @@ class Kalibro::Entities::StackTraceElement &lt; Kalibro::Entities::Entity
2 2
3 attr_accessor :declaring_class, :method_name, :file_name, :line_number 3 attr_accessor :declaring_class, :method_name, :file_name, :line_number
4 4
  5 + def line_number=(value)
  6 + @line_number = value.to_i
  7 + end
  8 +
5 end 9 end
6 \ No newline at end of file 10 \ No newline at end of file
plugins/mezuro/lib/mezuro_plugin/configuration_content.rb
@@ -8,7 +8,7 @@ class MezuroPlugin::ConfigurationContent &lt; Article @@ -8,7 +8,7 @@ class MezuroPlugin::ConfigurationContent &lt; Article
8 'Sets of thresholds to interpret metrics' 8 'Sets of thresholds to interpret metrics'
9 end 9 end
10 10
11 - settings_items :description 11 + settings_items :description, :metrics
12 12
13 include ActionView::Helpers::TagHelper 13 include ActionView::Helpers::TagHelper
14 def to_html(options = {}) 14 def to_html(options = {})
plugins/mezuro/lib/mezuro_plugin/metric_configuration_content.rb 0 → 100644
@@ -0,0 +1,37 @@ @@ -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
@@ -80,4 +80,10 @@ function showLoadingProcess(firstLoad){ @@ -80,4 +80,10 @@ function showLoadingProcess(firstLoad){
80 80
81 showProjectTree("<img src='/images/loading-small.gif'/>"); 81 showProjectTree("<img src='/images/loading-small.gif'/>");
82 showModuleResult("<img src='/images/loading-small.gif'/>"); 82 showModuleResult("<img src='/images/loading-small.gif'/>");
83 -} 83 +}
  84 +
  85 +function sourceNodeToggle(id){
  86 + var suffixes = ['_hidden', '_plus', '_minus'];
  87 + for (var i in suffixes)
  88 + jQuery('#' + id + suffixes[i]).toggle();
  89 +}
plugins/mezuro/test/fixtures/base_tool_fixtures.rb
  1 +require File.dirname(__FILE__) + '/native_metric_fixtures'
  2 +
1 class BaseToolFixtures 3 class BaseToolFixtures
2 4
3 def self.analizo 5 def self.analizo
plugins/mezuro/test/fixtures/compound_metric_fixtures.rb
@@ -4,12 +4,12 @@ class CompoundMetricFixtures @@ -4,12 +4,12 @@ class CompoundMetricFixtures
4 sc = Kalibro::Entities::CompoundMetric.new 4 sc = Kalibro::Entities::CompoundMetric.new
5 sc.name = 'Structural Complexity' 5 sc.name = 'Structural Complexity'
6 sc.scope = 'CLASS' 6 sc.scope = 'CLASS'
7 - sc.script = 'return cbo * lcom4;' 7 + sc.script = 'return 42;'
8 sc 8 sc
9 end 9 end
10 10
11 def self.sc_hash 11 def self.sc_hash
12 - {:name => 'Structural Complexity', :scope => 'CLASS', :script => 'return cbo * lcom4;'} 12 + {:name => 'Structural Complexity', :scope => 'CLASS', :script => 'return 42;'}
13 end 13 end
14 14
15 end 15 end
plugins/mezuro/test/fixtures/compound_metric_with_error_fixtures.rb
@@ -10,7 +10,10 @@ class CompoundMetricWithErrorFixtures @@ -10,7 +10,10 @@ class CompoundMetricWithErrorFixtures
10 end 10 end
11 11
12 def self.create_hash 12 def self.create_hash
13 - {:metric => CompoundMetricFixtures.sc_hash, :error => ErrorFixtures.create_hash} 13 + {:metric => CompoundMetricFixtures.sc_hash, :error => ErrorFixtures.create_hash,
  14 + :attributes! => {:metric => {
  15 + 'xmlns:xsi'=> 'http://www.w3.org/2001/XMLSchema-instance',
  16 + 'xsi:type' => 'kalibro:compoundMetricXml' }}}
14 end 17 end
15 18
16 end 19 end
plugins/mezuro/test/fixtures/error_fixtures.rb
@@ -4,6 +4,7 @@ class ErrorFixtures @@ -4,6 +4,7 @@ class ErrorFixtures
4 4
5 def self.create 5 def self.create
6 error = Kalibro::Entities::Error.new 6 error = Kalibro::Entities::Error.new
  7 + error.error_class = 'java.lang.Exception'
7 error.message = 'Error message from ErrorTest' 8 error.message = 'Error message from ErrorTest'
8 error.stack_trace = [ 9 error.stack_trace = [
9 StackTraceElementFixtures.create('my method 1', 42), 10 StackTraceElementFixtures.create('my method 1', 42),
@@ -12,7 +13,8 @@ class ErrorFixtures @@ -12,7 +13,8 @@ class ErrorFixtures
12 end 13 end
13 14
14 def self.create_hash 15 def self.create_hash
15 - {:message => 'Error message from ErrorTest', :stack_trace_element => [ 16 + {:error_class => 'java.lang.Exception', :message => 'Error message from ErrorTest',
  17 + :stack_trace_element => [
16 StackTraceElementFixtures.create_hash('my method 1', 42), 18 StackTraceElementFixtures.create_hash('my method 1', 42),
17 StackTraceElementFixtures.create_hash('my method 2', 84)]} 19 StackTraceElementFixtures.create_hash('my method 2', 84)]}
18 end 20 end
plugins/mezuro/test/fixtures/metric_configuration_fixtures.rb
@@ -14,6 +14,15 @@ class MetricConfigurationFixtures @@ -14,6 +14,15 @@ class MetricConfigurationFixtures
14 amloc 14 amloc
15 end 15 end
16 16
  17 + def self.metric_configuration_without_ranges
  18 + amloc = Kalibro::Entities::MetricConfiguration.new
  19 + amloc.metric = NativeMetricFixtures.amloc
  20 + amloc.code = 'amloc'
  21 + amloc.weight = 1.0
  22 + amloc.aggregation_form = 'AVERAGE'
  23 + amloc
  24 + end
  25 +
17 def self.sc_configuration 26 def self.sc_configuration
18 sc = Kalibro::Entities::MetricConfiguration.new 27 sc = Kalibro::Entities::MetricConfiguration.new
19 sc.metric = CompoundMetricFixtures.sc 28 sc.metric = CompoundMetricFixtures.sc
@@ -25,12 +34,18 @@ class MetricConfigurationFixtures @@ -25,12 +34,18 @@ class MetricConfigurationFixtures
25 34
26 def self.amloc_configuration_hash 35 def self.amloc_configuration_hash
27 {:metric => NativeMetricFixtures.amloc_hash, :code => 'amloc', :weight => 1.0, 36 {:metric => NativeMetricFixtures.amloc_hash, :code => 'amloc', :weight => 1.0,
28 - :aggregation_form => 'AVERAGE', :range =>  
29 - [RangeFixtures.amloc_excellent_hash, RangeFixtures.amloc_bad_hash]} 37 + :aggregation_form => 'AVERAGE',
  38 + :range => [RangeFixtures.amloc_excellent_hash, RangeFixtures.amloc_bad_hash],
  39 + :attributes! => {:metric => {
  40 + 'xmlns:xsi'=> 'http://www.w3.org/2001/XMLSchema-instance',
  41 + 'xsi:type' => 'kalibro:nativeMetricXml' }}}
30 end 42 end
31 43
32 def self.sc_configuration_hash 44 def self.sc_configuration_hash
33 - {:metric => CompoundMetricFixtures.sc_hash, :code => 'sc', :weight => 1.0, :aggregation_form => 'AVERAGE'} 45 + {:metric => CompoundMetricFixtures.sc_hash, :code => 'sc', :weight => 1.0, :aggregation_form => 'AVERAGE',
  46 + :attributes! => {:metric => {
  47 + 'xmlns:xsi'=> 'http://www.w3.org/2001/XMLSchema-instance',
  48 + 'xsi:type' => 'kalibro:compoundMetricXml' }}}
34 end 49 end
35 50
36 end 51 end
plugins/mezuro/test/fixtures/metric_result_fixtures.rb
@@ -23,11 +23,17 @@ class MetricResultFixtures @@ -23,11 +23,17 @@ class MetricResultFixtures
23 23
24 def self.amloc_result_hash 24 def self.amloc_result_hash
25 {:metric => NativeMetricFixtures.amloc_hash, :value => 0.0, :descendent_result => [40.0, 42.0], 25 {:metric => NativeMetricFixtures.amloc_hash, :value => 0.0, :descendent_result => [40.0, 42.0],
26 - :range => RangeFixtures.amloc_excellent_hash} 26 + :range => RangeFixtures.amloc_excellent_hash,
  27 + :attributes! => {:metric => {
  28 + 'xmlns:xsi'=> 'http://www.w3.org/2001/XMLSchema-instance',
  29 + 'xsi:type' => 'kalibro:nativeMetricXml' }}}
27 end 30 end
28 31
29 def self.sc_result_hash 32 def self.sc_result_hash
30 - {:metric => CompoundMetricFixtures.sc_hash, :value => 1.0, :descendent_result => [2.0, 42.0]} 33 + {:metric => CompoundMetricFixtures.sc_hash, :value => 1.0, :descendent_result => [2.0, 42.0],
  34 + :attributes! => {:metric => {
  35 + 'xmlns:xsi'=> 'http://www.w3.org/2001/XMLSchema-instance',
  36 + 'xsi:type' => 'kalibro:compoundMetricXml' }}}
31 end 37 end
32 38
33 end 39 end
plugins/mezuro/test/fixtures/module_node_fixtures.rb
@@ -5,17 +5,17 @@ class ModuleNodeFixtures @@ -5,17 +5,17 @@ class ModuleNodeFixtures
5 node.module = ModuleFixtures.qt_calculator 5 node.module = ModuleFixtures.qt_calculator
6 org_node = new_node('org', 'PACKAGE') 6 org_node = new_node('org', 'PACKAGE')
7 org_node.children = [new_node('org.Window', 'CLASS')] 7 org_node.children = [new_node('org.Window', 'CLASS')]
8 - node.children = [new_node('Dialog', 'CLASS'), new_node('main', 'CLASS'), org_node] 8 + node.children = [org_node, new_node('Dialog', 'CLASS'), new_node('main', 'CLASS')]
9 node 9 node
10 end 10 end
11 11
12 def self.qt_calculator_tree_hash 12 def self.qt_calculator_tree_hash
13 {:module => ModuleFixtures.qt_calculator_hash, 13 {:module => ModuleFixtures.qt_calculator_hash,
14 :child => [ 14 :child => [
15 - {:module => {:name => 'Dialog', :granularity => 'CLASS'}},  
16 - {:module => {:name => 'main', :granularity => 'CLASS'}},  
17 {:module => {:name => 'org', :granularity => 'PACKAGE'}, 15 {:module => {:name => 'org', :granularity => 'PACKAGE'},
18 - :child => [{:module => {:name => 'org.Window', :granularity => 'CLASS'}}]} 16 + :child => [{:module => {:name => 'org.Window', :granularity => 'CLASS'}}]},
  17 + {:module => {:name => 'Dialog', :granularity => 'CLASS'}},
  18 + {:module => {:name => 'main', :granularity => 'CLASS'}}
19 ] 19 ]
20 } 20 }
21 end 21 end
plugins/mezuro/test/fixtures/module_result_fixtures.rb
@@ -18,7 +18,7 @@ class ModuleResultFixtures @@ -18,7 +18,7 @@ class ModuleResultFixtures
18 18
19 def self.create_hash 19 def self.create_hash
20 {:module => ModuleFixtures.qt_calculator_hash, 20 {:module => ModuleFixtures.qt_calculator_hash,
21 - :date => DateTime.parse('Thu, 20 Oct 2011 18:26:43.151 +0000'), :grade => 10.0, :metric_result => [ 21 + :date => '2011-10-20T18:26:43.151+00:00', :grade => 10.0, :metric_result => [
22 MetricResultFixtures.amloc_result_hash, 22 MetricResultFixtures.amloc_result_hash,
23 MetricResultFixtures.sc_result_hash], 23 MetricResultFixtures.sc_result_hash],
24 :compound_metric_with_error => [CompoundMetricWithErrorFixtures.create_hash]} 24 :compound_metric_with_error => [CompoundMetricWithErrorFixtures.create_hash]}
plugins/mezuro/test/fixtures/native_metric_fixtures.rb
@@ -5,12 +5,12 @@ class NativeMetricFixtures @@ -5,12 +5,12 @@ class NativeMetricFixtures
5 total_cof.name = 'Total Coupling Factor' 5 total_cof.name = 'Total Coupling Factor'
6 total_cof.scope = 'APPLICATION' 6 total_cof.scope = 'APPLICATION'
7 total_cof.origin = 'Analizo' 7 total_cof.origin = 'Analizo'
8 - total_cof.language = 'JAVA' 8 + total_cof.languages = ['JAVA']
9 total_cof 9 total_cof
10 end 10 end
11 11
12 def self.total_cof_hash 12 def self.total_cof_hash
13 - {:name => 'Total Coupling Factor', :scope => 'APPLICATION', :origin => 'Analizo', :language => 'JAVA'} 13 + {:name => 'Total Coupling Factor', :scope => 'APPLICATION', :origin => 'Analizo', :language => ['JAVA']}
14 end 14 end
15 15
16 def self.amloc 16 def self.amloc
@@ -18,12 +18,12 @@ class NativeMetricFixtures @@ -18,12 +18,12 @@ class NativeMetricFixtures
18 total_cof.name = 'Average Method LOC' 18 total_cof.name = 'Average Method LOC'
19 total_cof.scope = 'CLASS' 19 total_cof.scope = 'CLASS'
20 total_cof.origin = 'Analizo' 20 total_cof.origin = 'Analizo'
21 - total_cof.language = 'JAVA' 21 + total_cof.languages = ['JAVA']
22 total_cof 22 total_cof
23 end 23 end
24 24
25 def self.amloc_hash 25 def self.amloc_hash
26 - {:name => 'Average Method LOC', :scope => 'CLASS', :origin => 'Analizo', :language => 'JAVA'} 26 + {:name => 'Average Method LOC', :scope => 'CLASS', :origin => 'Analizo', :language => ['JAVA']}
27 end 27 end
28 28
29 end 29 end
30 \ No newline at end of file 30 \ No newline at end of file
plugins/mezuro/test/fixtures/project_result_fixtures.rb
@@ -15,7 +15,7 @@ class ProjectResultFixtures @@ -15,7 +15,7 @@ class ProjectResultFixtures
15 end 15 end
16 16
17 def self.qt_calculator_hash 17 def self.qt_calculator_hash
18 - {:project => ProjectFixtures.qt_calculator_hash, :date => ModuleResultFixtures.create.date, 18 + {:project => ProjectFixtures.qt_calculator_hash, :date => ModuleResultFixtures.create_hash[:date],
19 :load_time => 14878, :analysis_time => 1022, :source_tree => ModuleNodeFixtures.qt_calculator_tree_hash} 19 :load_time => 14878, :analysis_time => 1022, :source_tree => ModuleNodeFixtures.qt_calculator_tree_hash}
20 end 20 end
21 21
plugins/mezuro/test/fixtures/range_fixtures.rb
@@ -27,7 +27,7 @@ class RangeFixtures @@ -27,7 +27,7 @@ class RangeFixtures
27 end 27 end
28 28
29 def self.amloc_bad_hash 29 def self.amloc_bad_hash
30 - {:beginning => 19.5, :end => Infinity, :label => 'Bad',:grade => 0.0, :color => 'ffff0000'} 30 + {:beginning => 19.5, :end => "INF", :label => 'Bad',:grade => 0.0, :color => 'ffff0000'}
31 end 31 end
32 32
33 end 33 end
plugins/mezuro/test/functional/echo_port_test.rb 0 → 100644
@@ -0,0 +1,88 @@ @@ -0,0 +1,88 @@
  1 +require "test_helper"
  2 +
  3 +require "#{RAILS_ROOT}/plugins/mezuro/test/fixtures/base_tool_fixtures"
  4 +require "#{RAILS_ROOT}/plugins/mezuro/test/fixtures/configuration_fixtures"
  5 +require "#{RAILS_ROOT}/plugins/mezuro/test/fixtures/module_result_fixtures"
  6 +require "#{RAILS_ROOT}/plugins/mezuro/test/fixtures/project_result_fixtures"
  7 +
  8 +class EchoPortTest < ActiveSupport::TestCase
  9 +
  10 + def setup
  11 + @port = Kalibro::Client::Port.new('Echo')
  12 + @port.service_address=('http://valinhos.ime.usp.br:50688/KalibroFake/');
  13 + end
  14 +
  15 + should 'echo base tool' do
  16 + test BaseToolFixtures.analizo, 'BaseTool' do |base_tool|
  17 + base_tool.name = "echo " + base_tool.name
  18 + end
  19 + end
  20 +
  21 + should 'echo configuration' do
  22 + test ConfigurationFixtures.kalibro_configuration, 'Configuration' do |configuration|
  23 + configuration.name = "echo " + configuration.name
  24 + end
  25 + end
  26 +
  27 + should 'echo metric configuration' do
  28 + test_metric_configuration(MetricConfigurationFixtures.amloc_configuration)
  29 + test_metric_configuration(MetricConfigurationFixtures.sc_configuration)
  30 + end
  31 +
  32 + should 'echo module result' do
  33 + test ModuleResultFixtures.create, 'ModuleResult' do |module_result|
  34 + module_result.module.name = "echo." + module_result.module.name
  35 + end
  36 + end
  37 +
  38 + should 'echo project' do
  39 + test(ProjectFixtures.qt_calculator, 'Project') do |project|
  40 + project.name = "echo " + project.name
  41 + end
  42 + end
  43 +
  44 + should 'echo project result' do
  45 + test(ProjectResultFixtures.qt_calculator, 'ProjectResult') do |project_result|
  46 + project_result.project.name = "echo " + project_result.project.name
  47 + end
  48 + end
  49 +
  50 + should 'echo raw project' do
  51 + project = ProjectFixtures.qt_calculator
  52 + echoed = @port.request(:echo_raw_project, {:project => project.to_hash})[:project]
  53 + project.name = "echo " + project.name
  54 + project.state = nil
  55 + project.error = nil
  56 + assert_equal project, Kalibro::Entities::Project.from_hash(echoed)
  57 + end
  58 +
  59 + should 'work with enums' do
  60 + test_granularity("METHOD", "CLASS")
  61 + test_granularity("CLASS", "PACKAGE")
  62 + test_granularity("PACKAGE", "PACKAGE")
  63 + test_granularity("APPLICATION", "APPLICATION")
  64 + end
  65 +
  66 + private
  67 +
  68 + def test_metric_configuration(fixture)
  69 + test fixture, 'MetricConfiguration' do |metric_configuration|
  70 + metric_configuration.code = "echo_" + metric_configuration.code
  71 + end
  72 + end
  73 +
  74 + def test(fixture, entity_name)
  75 + entity_symbol = entity_name.underscore.to_sym
  76 + request_body = {entity_symbol => fixture.to_hash}
  77 + echoed = @port.request("echo_#{entity_symbol}".to_sym, request_body)[entity_symbol]
  78 + yield fixture
  79 + entity_class = "Kalibro::Entities::#{entity_name}".constantize
  80 + assert_equal fixture, entity_class.from_hash(echoed)
  81 + end
  82 +
  83 + def test_granularity(granularity, parent)
  84 + body = {:granularity => granularity}
  85 + assert_equal parent, @port.request(:infer_parent_granularity, body)[:parent_granularity]
  86 + end
  87 +
  88 +end
0 \ No newline at end of file 89 \ No newline at end of file
plugins/mezuro/test/functional/mezuro_plugin_profile_controller_test.rb
@@ -3,6 +3,9 @@ require &#39;test_helper&#39; @@ -3,6 +3,9 @@ require &#39;test_helper&#39;
3 require "#{RAILS_ROOT}/plugins/mezuro/test/fixtures/module_result_fixtures" 3 require "#{RAILS_ROOT}/plugins/mezuro/test/fixtures/module_result_fixtures"
4 require "#{RAILS_ROOT}/plugins/mezuro/test/fixtures/project_result_fixtures" 4 require "#{RAILS_ROOT}/plugins/mezuro/test/fixtures/project_result_fixtures"
5 require "#{RAILS_ROOT}/plugins/mezuro/test/fixtures/error_fixtures" 5 require "#{RAILS_ROOT}/plugins/mezuro/test/fixtures/error_fixtures"
  6 +require "#{RAILS_ROOT}/plugins/mezuro/test/fixtures/base_tool_fixtures"
  7 +require "#{RAILS_ROOT}/plugins/mezuro/test/fixtures/native_metric_fixtures"
  8 +require "#{RAILS_ROOT}/plugins/mezuro/test/fixtures/metric_configuration_fixtures"
6 9
7 class MezuroPluginProfileControllerTest < ActionController::TestCase 10 class MezuroPluginProfileControllerTest < ActionController::TestCase
8 11
@@ -16,6 +19,12 @@ class MezuroPluginProfileControllerTest &lt; ActionController::TestCase @@ -16,6 +19,12 @@ class MezuroPluginProfileControllerTest &lt; ActionController::TestCase
16 @module_result = ModuleResultFixtures.create 19 @module_result = ModuleResultFixtures.create
17 @project = @project_result.project 20 @project = @project_result.project
18 @name = @project.name 21 @name = @project.name
  22 +
  23 + @collector = BaseToolFixtures.analizo
  24 + @base_tool_client = Kalibro::Client::BaseToolClient.new
  25 + @metric = NativeMetricFixtures.amloc
  26 + @metric_configuration_client = Kalibro::Client::MetricConfigurationClient.new
  27 + @metric_configuration = MetricConfigurationFixtures.amloc_configuration
19 end 28 end
20 29
21 should 'not find module result for inexistent project content' do 30 should 'not find module result for inexistent project content' do
@@ -65,6 +74,91 @@ class MezuroPluginProfileControllerTest &lt; ActionController::TestCase @@ -65,6 +74,91 @@ class MezuroPluginProfileControllerTest &lt; ActionController::TestCase
65 assert_select('h5', 'Metric results for: Qt-Calculator (APPLICATION)') 74 assert_select('h5', 'Metric results for: Qt-Calculator (APPLICATION)')
66 end 75 end
67 76
  77 + should 'assign configuration name in choose_base_tool' do
  78 + get :choose_base_tool, :profile => @profile.identifier, :configuration_name => "test name"
  79 + assert_equal assigns(:configuration_name), "test name"
  80 + end
  81 +
  82 + should 'create base tool client' do
  83 + get :choose_base_tool, :profile => @profile.identifier, :configuration_name => "test name"
  84 + assert assigns(:tool_names).instance_of?(Kalibro::Client::BaseToolClient)
  85 + end
  86 +
  87 + should 'assign configuration and collector name in choose_metric' do
  88 + Kalibro::Client::BaseToolClient.expects(:new).returns(@base_tool_client)
  89 + @base_tool_client.expects(:base_tool).with(@collector.name).returns(@collector)
  90 + get :choose_metric, :profile => @profile.identifier, :configuration_name => "test name", :collector_name => "Analizo"
  91 + assert_equal assigns(:configuration_name), "test name"
  92 + assert_equal assigns(:collector_name), "Analizo"
  93 + end
  94 +
  95 + should 'get collector by name' do
  96 + Kalibro::Client::BaseToolClient.expects(:new).returns(@base_tool_client)
  97 + @base_tool_client.expects(:base_tool).with(@collector.name).returns(@collector)
  98 + get :choose_metric, :profile => @profile.identifier, :configuration_name => "test name", :collector_name => "Analizo"
  99 + assert_equal assigns(:collector), @collector
  100 + end
  101 +
  102 + should 'get choosed native metric and configuration name' do
  103 + Kalibro::Client::BaseToolClient.expects(:new).returns(@base_tool_client)
  104 + @base_tool_client.expects(:base_tool).with(@collector.name).returns(@collector)
  105 + get :new_metric_configuration, :profile => @profile.identifier, :configuration_name => "test name", :collector_name => "Analizo", :metric_name => @metric.name
  106 + assert_equal assigns(:configuration_name), "test name"
  107 + assert_equal assigns(:metric), @metric
  108 + end
  109 +
  110 + should 'assign configuration name and get metric_configuration' do
  111 + Kalibro::Client::MetricConfigurationClient.expects(:new).returns(@metric_configuration_client)
  112 + @metric_configuration_client.expects(:metric_configuration).with("test name", @metric.name).returns(@metric_configuration)
  113 + get :edit_metric_configuration, :profile => @profile.identifier, :configuration_name => "test name", :metric_name => @metric.name
  114 + assert_equal assigns(:configuration_name), "test name"
  115 + assert_equal assigns(:metric_configuration), @metric_configuration
  116 + assert_equal assigns(:metric), @metric_configuration.metric
  117 + end
  118 +
  119 + should 'test metric creation' do
  120 + Kalibro::Client::MetricConfigurationClient.expects(:new).returns(@metric_configuration_client)
  121 + @metric_configuration_client.expects(:save)
  122 + get :create_metric_configuration, :profile => @profile.identifier, :configuration_name => "test name", :description => @metric.description,
  123 + :scope => @metric.scope, :language => @metric.language, :metric => { :name => @metric.name, :origin => @metric.origin},
  124 + :metric_configuration => { :code => @metric_configuration.code, :weight => @metric_configuration.code, :aggregation => @metric_configuration.aggregation_form }
  125 + assert_equal assigns(:configuration_name), "test name"
  126 + assert_response 302
  127 + end
  128 +
  129 + should 'test metric edition' do
  130 + Kalibro::Client::MetricConfigurationClient.expects(:new).returns(@metric_configuration_client)
  131 + @metric_configuration_client.expects(:save)
  132 + get :create_metric_configuration, :profile => @profile.identifier, :configuration_name => "test name", :description => @metric.description,
  133 + :scope => @metric.scope, :language => @metric.language, :metric => { :name => @metric.name, :origin => @metric.origin},
  134 + :metric_configuration => { :code => @metric_configuration.code, :weight => @metric_configuration.code, :aggregation => @metric_configuration.aggregation_form }
  135 + assert_equal assigns(:configuration_name), "test name"
  136 + assert_response 302
  137 + end
  138 +
  139 + should 'assign configuration name and metric name to new range' do
  140 + get :new_range, :profile => @profile.identifier, :configuration_name => "test name", :metric_name => @metric.name
  141 + assert_equal assigns(:configuration_name), "test name"
  142 + assert_equal assigns(:metric_name), @metric.name
  143 + end
  144 +
  145 + should 'create instance range' do
  146 + Kalibro::Client::MetricConfigurationClient.expects(:new).returns(@metric_configuration_client)
  147 + @metric_configuration_client.expects(:metric_configuration).with("test name", @metric.name).returns(@metric_configuration)
  148 + @metric_configuration_client.expects(:save)
  149 + range = @metric_configuration.ranges[0]
  150 + get :create_range, :profile => @profile.identifier, :range => { :beginning => range.beginning, :end => range.end, :label => range.label,
  151 + :grade => range.grade, :color => range.color, :comments => range.comments }, :configuration_name => "test name", :metric_name => @metric.name
  152 + assert assigns(:range).instance_of?(Kalibro::Entities::Range)
  153 + end
  154 +
  155 + should 'redirect from remove metric configuration' do
  156 + Kalibro::Client::MetricConfigurationClient.expects(:new).returns(@metric_configuration_client)
  157 + @metric_configuration_client.expects(:remove)
  158 + get :remove_metric_configuration, :profile => @profile.identifier, :configuration_name => "test name", :metric_name => @metric.name
  159 + assert_response 302
  160 + end
  161 +
68 private 162 private
69 163
70 def create_project_content 164 def create_project_content
plugins/mezuro/test/unit/kalibro/client/metric_configuration_client_test.rb 0 → 100644
@@ -0,0 +1,44 @@ @@ -0,0 +1,44 @@
  1 +require "test_helper"
  2 +
  3 +require "#{RAILS_ROOT}/plugins/mezuro/test/fixtures/metric_configuration_fixtures"
  4 +
  5 +class MetricConfigurationClientTest < ActiveSupport::TestCase
  6 +
  7 + def setup
  8 + @port = mock
  9 + Kalibro::Client::Port.expects(:new).with('MetricConfiguration').returns(@port)
  10 + @client = Kalibro::Client::MetricConfigurationClient.new
  11 + end
  12 +
  13 + should 'save metric configuration' do
  14 + configuration = MetricConfigurationFixtures.amloc_configuration
  15 + @port.expects(:request).with(:save_metric_configuration, {
  16 + :metric_configuration => configuration.to_hash,
  17 + :configuration_name => 'x'
  18 + })
  19 + @client.save(configuration, 'x')
  20 + end
  21 +
  22 + should 'get metric configuration by name' do
  23 + configuration = MetricConfigurationFixtures.amloc_configuration
  24 + request_body = {
  25 + :configuration_name => 'configuration.name',
  26 + :metric_name => configuration.metric.name
  27 + }
  28 + response_hash = {:metric_configuration => configuration.to_hash}
  29 + @port.expects(:request).with(:get_metric_configuration, request_body).returns(response_hash)
  30 + assert_equal configuration, @client.metric_configuration('configuration.name', configuration.metric.name)
  31 + end
  32 +
  33 + should 'remove metric configuration by name' do
  34 + metric_name = 'MetricConfigurationClientTest'
  35 + configuration_name = 'xxxx'
  36 + request_body = {
  37 + :configuration_name => configuration_name,
  38 + :metric_name => metric_name
  39 + }
  40 + @port.expects(:request).with(:remove_metric_configuration, request_body)
  41 + @client.remove(configuration_name, metric_name)
  42 + end
  43 +
  44 +end
0 \ No newline at end of file 45 \ No newline at end of file
plugins/mezuro/test/unit/kalibro/client/project_result_client_test.rb
@@ -13,59 +13,46 @@ class ProjectResultClientTest &lt; ActiveSupport::TestCase @@ -13,59 +13,46 @@ class ProjectResultClientTest &lt; ActiveSupport::TestCase
13 @project_name = @result.project.name 13 @project_name = @result.project.name
14 @date = @result.date 14 @date = @result.date
15 @flag = DateTime.now.sec % 2 == 0 15 @flag = DateTime.now.sec % 2 == 0
  16 +
  17 + @request = {:project_name => @project_name}
  18 + @request_with_date = {:project_name => @project_name, :date => @date}
  19 + @flag_response = {:has_results => @flag}
  20 + @result_response = {:project_result => @result.to_hash}
16 end 21 end
17 22
18 should 'retrieve if project has results' do 23 should 'retrieve if project has results' do
19 - @port.expects(:request).with(:has_results_for, request).returns(flag_response) 24 + @port.expects(:request).with(:has_results_for, @request).returns(@flag_response)
20 assert_equal @flag, @client.has_results_for(@project_name) 25 assert_equal @flag, @client.has_results_for(@project_name)
21 end 26 end
22 27
23 should 'retrieve if project has results before date' do 28 should 'retrieve if project has results before date' do
24 - @port.expects(:request).with(:has_results_before, request_with_date).returns(flag_response) 29 + @port.expects(:request).with(:has_results_before, @request_with_date).returns(@flag_response)
25 assert_equal @flag, @client.has_results_before(@project_name, @date) 30 assert_equal @flag, @client.has_results_before(@project_name, @date)
26 end 31 end
27 32
28 should 'retrieve if project has results after date' do 33 should 'retrieve if project has results after date' do
29 - @port.expects(:request).with(:has_results_after, request_with_date).returns(flag_response) 34 + @port.expects(:request).with(:has_results_after, @request_with_date).returns(@flag_response)
30 assert_equal @flag, @client.has_results_after(@project_name, @date) 35 assert_equal @flag, @client.has_results_after(@project_name, @date)
31 end 36 end
32 37
33 should 'get first result of project' do 38 should 'get first result of project' do
34 - @port.expects(:request).with(:get_first_result_of, request).returns(result_response) 39 + @port.expects(:request).with(:get_first_result_of, @request).returns(@result_response)
35 assert_equal @result, @client.first_result(@project_name) 40 assert_equal @result, @client.first_result(@project_name)
36 end 41 end
37 42
38 should 'get last result of project' do 43 should 'get last result of project' do
39 - @port.expects(:request).with(:get_last_result_of, request).returns(result_response) 44 + @port.expects(:request).with(:get_last_result_of, @request).returns(@result_response)
40 assert_equal @result, @client.last_result(@project_name) 45 assert_equal @result, @client.last_result(@project_name)
41 end 46 end
42 47
43 should 'get first result of project after date' do 48 should 'get first result of project after date' do
44 - @port.expects(:request).with(:get_first_result_after, request_with_date).returns(result_response) 49 + @port.expects(:request).with(:get_first_result_after, @request_with_date).returns(@result_response)
45 assert_equal @result, @client.first_result_after(@project_name, @date) 50 assert_equal @result, @client.first_result_after(@project_name, @date)
46 end 51 end
47 52
48 should 'get last result of project before date' do 53 should 'get last result of project before date' do
49 - @port.expects(:request).with(:get_last_result_before, request_with_date).returns(result_response) 54 + @port.expects(:request).with(:get_last_result_before, @request_with_date).returns(@result_response)
50 assert_equal @result, @client.last_result_before(@project_name, @date) 55 assert_equal @result, @client.last_result_before(@project_name, @date)
51 end 56 end
52 57
53 - private  
54 -  
55 - def request  
56 - {:project_name => @project_name}  
57 - end  
58 -  
59 - def request_with_date  
60 - {:project_name => @project_name, :date => @date}  
61 - end  
62 -  
63 - def flag_response  
64 - {:has_results => @flag}  
65 - end  
66 -  
67 - def result_response  
68 - {:project_result => @result.to_hash}  
69 - end  
70 -  
71 end 58 end
72 \ No newline at end of file 59 \ No newline at end of file
plugins/mezuro/test/unit/kalibro/entities/configuration_test.rb
@@ -17,4 +17,4 @@ class ConfigurationTest &lt; ActiveSupport::TestCase @@ -17,4 +17,4 @@ class ConfigurationTest &lt; ActiveSupport::TestCase
17 assert_equal @hash, @configuration.to_hash 17 assert_equal @hash, @configuration.to_hash
18 end 18 end
19 19
20 -end  
21 \ No newline at end of file 20 \ No newline at end of file
  21 +end
plugins/mezuro/test/unit/kalibro/entities/metric_configuration_test.rb
1 require "test_helper" 1 require "test_helper"
2 2
3 require "#{RAILS_ROOT}/plugins/mezuro/test/fixtures/metric_configuration_fixtures" 3 require "#{RAILS_ROOT}/plugins/mezuro/test/fixtures/metric_configuration_fixtures"
  4 +require "#{RAILS_ROOT}/plugins/mezuro/test/fixtures/range_fixtures"
4 5
5 class MetricConfigurationTest < ActiveSupport::TestCase 6 class MetricConfigurationTest < ActiveSupport::TestCase
6 7
7 def setup 8 def setup
8 @hash = MetricConfigurationFixtures.amloc_configuration_hash 9 @hash = MetricConfigurationFixtures.amloc_configuration_hash
9 - @range = MetricConfigurationFixtures.amloc_configuration 10 + @metric_configuration = MetricConfigurationFixtures.amloc_configuration
  11 + @metric_configuration_without_ranges = MetricConfigurationFixtures.metric_configuration_without_ranges
  12 + @range1 = RangeFixtures.amloc_excellent
  13 + @range2 = RangeFixtures.amloc_bad
10 end 14 end
11 15
12 should 'create metric configuration from hash' do 16 should 'create metric configuration from hash' do
13 - assert_equal @range, Kalibro::Entities::MetricConfiguration.from_hash(@hash) 17 + assert_equal @metric_configuration, Kalibro::Entities::MetricConfiguration.from_hash(@hash)
14 end 18 end
15 19
16 should 'convert metric configuration to hash' do 20 should 'convert metric configuration to hash' do
17 - assert_equal @hash, @range.to_hash 21 + assert_equal @hash, @metric_configuration.to_hash
18 end 22 end
19 23
20 should 'create appropriate metric type' do 24 should 'create appropriate metric type' do
@@ -24,4 +28,16 @@ class MetricConfigurationTest &lt; ActiveSupport::TestCase @@ -24,4 +28,16 @@ class MetricConfigurationTest &lt; ActiveSupport::TestCase
24 assert sc.metric.instance_of?(Kalibro::Entities::CompoundMetric) 28 assert sc.metric.instance_of?(Kalibro::Entities::CompoundMetric)
25 end 29 end
26 30
  31 + should 'add a range to an empty range list' do
  32 + @metric_configuration_without_ranges.add_range @range1
  33 + assert_equal @metric_configuration_without_ranges.ranges, [@range1]
  34 + end
  35 +
  36 + should 'add a range to an non-empty range list' do
  37 + @metric_configuration_without_ranges.ranges = [@range1]
  38 + @metric_configuration_without_ranges.add_range @range2
  39 + assert_equal @metric_configuration_without_ranges.ranges, [@range1, @range2]
  40 + end
  41 +
  42 +
27 end 43 end
plugins/mezuro/test/unit/kalibro/entities/project_result_test.rb
@@ -27,12 +27,12 @@ class ProjectResultTest &lt; ActiveSupport::TestCase @@ -27,12 +27,12 @@ class ProjectResultTest &lt; ActiveSupport::TestCase
27 27
28 should 'retrieve module node' do 28 should 'retrieve module node' do
29 node = @result.get_node("main") 29 node = @result.get_node("main")
30 - assert_equal @hash[:source_tree][:child][1], node.to_hash 30 + assert_equal @hash[:source_tree][:child][2], node.to_hash
31 end 31 end
32 32
33 should 'retrive complex module' do 33 should 'retrive complex module' do
34 node = @result.get_node("org.Window") 34 node = @result.get_node("org.Window")
35 - assert_equal @hash[:source_tree][:child][2][:child].first, node.to_hash 35 + assert_equal @hash[:source_tree][:child][0][:child].first, node.to_hash
36 end 36 end
37 37
38 should 'return source tree node when nil is given' do 38 should 'return source tree node when nil is given' do
@@ -44,6 +44,6 @@ class ProjectResultTest &lt; ActiveSupport::TestCase @@ -44,6 +44,6 @@ class ProjectResultTest &lt; ActiveSupport::TestCase
44 end 44 end
45 45
46 should 'return correct node when module name is given' do 46 should 'return correct node when module name is given' do
47 - assert_equal @hash[:source_tree][:child][1], @result.node_of("main").to_hash 47 + assert_equal @hash[:source_tree][:child][2], @result.node_of("main").to_hash
48 end 48 end
49 end 49 end
plugins/mezuro/test/unit/mezuro_plugin/configuration_content_test.rb
@@ -42,7 +42,7 @@ class ConfigurationContentTest &lt; ActiveSupport::TestCase @@ -42,7 +42,7 @@ class ConfigurationContentTest &lt; ActiveSupport::TestCase
42 @content.send :send_configuration_to_service 42 @content.send :send_configuration_to_service
43 end 43 end
44 44
45 - should 'remove project from service' do 45 + should 'remove configuration from service' do
46 Kalibro::Client::ConfigurationClient.expects(:remove).with(@content.name) 46 Kalibro::Client::ConfigurationClient.expects(:remove).with(@content.name)
47 @content.send :remove_configuration_from_service 47 @content.send :remove_configuration_from_service
48 end 48 end
plugins/mezuro/views/cms/mezuro_plugin/_configuration_content.html.erb
1 <h1> <%= _(MezuroPlugin::ConfigurationContent.short_description) %> </h1> 1 <h1> <%= _(MezuroPlugin::ConfigurationContent.short_description) %> </h1>
2 2
3 <% 3 <%
4 - begin  
5 - @configuration = @article.title.nil? ? nil : Kalibro::Client::ConfigurationClient.new.configuration(@article.title)  
6 - rescue  
7 - @configuration = nil  
8 - end 4 +begin
  5 + @configuration = @article.title.nil? ? nil : Kalibro::Client::ConfigurationClient.new.configuration(@article.title)
  6 +rescue
  7 + @configuration = nil
  8 +end
9 %> 9 %>
10 10
11 <%= error_messages_for 'kalibro_configuration' %> 11 <%= error_messages_for 'kalibro_configuration' %>
plugins/mezuro/views/content_viewer/_module_result.rhtml
@@ -19,7 +19,7 @@ @@ -19,7 +19,7 @@
19 <% range = metric_result.range %> 19 <% range = metric_result.range %>
20 <tr> 20 <tr>
21 <td><a href="#" data-show=".<%= metric_result.metric.name.delete("() ")%>"><%= metric_result.metric.name %></a></td> 21 <td><a href="#" data-show=".<%= metric_result.metric.name.delete("() ")%>"><%= metric_result.metric.name %></a></td>
22 - <td><%= MezuroPlugin::Helpers::ContentViewerHelper.format_grade(metric_result.value) %></td> <!--FIXME: Move to helper eventually--> 22 + <td><%= "%.02f" % metric_result.value %></td>
23 <td><%= metric_result.weight %></td> 23 <td><%= metric_result.weight %></td>
24 <% if range.nil? %> 24 <% if range.nil? %>
25 <td></td> 25 <td></td>
@@ -29,7 +29,7 @@ @@ -29,7 +29,7 @@
29 </tr> 29 </tr>
30 <tr class="<%= metric_result.metric.name.delete("() ")%>" style="display: none;"> 30 <tr class="<%= metric_result.metric.name.delete("() ")%>" style="display: none;">
31 <td colspan="4" align="right"> 31 <td colspan="4" align="right">
32 - <%= range.comments.nil? ? 'comment empty' : range.comments %> 32 + <%= range.nil? or range.comments.nil? ? 'comment empty' : range.comments %>
33 </td> 33 </td>
34 </tr> 34 </tr>
35 <% end %> 35 <% end %>
@@ -39,7 +39,7 @@ @@ -39,7 +39,7 @@
39 <td colspan = "4" align = "right"> 39 <td colspan = "4" align = "right">
40 <strong> 40 <strong>
41 <%= _('Grade:') %> 41 <%= _('Grade:') %>
42 - <%= MezuroPlugin::Helpers::ContentViewerHelper.format_grade(module_result.grade) %> <!--FIXME: Move to helper eventually --> 42 + <%= "%.02f" % module_result.grade %>
43 </strong> 43 </strong>
44 </td> 44 </td>
45 </tr> 45 </tr>
plugins/mezuro/views/content_viewer/show_configuration.rhtml
1 -<% @configuration = @page.configuration %> 1 +<% @configuration_content = @page
  2 +@configuration = Kalibro::Client::ConfigurationClient.new.configuration(@configuration_content.name) %>
2 3
3 <table id="project_info"> 4 <table id="project_info">
4 <tr> 5 <tr>
@@ -10,3 +11,27 @@ @@ -10,3 +11,27 @@
10 <td><%= @configuration.description %></td> 11 <td><%= @configuration.description %></td>
11 </tr> 12 </tr>
12 </table> 13 </table>
  14 +
  15 +<br/>
  16 +
  17 +<%= link_to "#{image_tag ('/plugins/mezuro/images/plus.png')}Add Metric", :controller => "mezuro_plugin_profile",
  18 +:action => "choose_base_tool", :params => {:configuration_name => @configuration.name} %><br/>
  19 +
  20 +<table>
  21 + <tr class="titles">
  22 + <td><h5>Metric Name</h5></td>
  23 + <td><h5>Collector Name</h5></td>
  24 + <td><h5>Metric Code</h5></td>
  25 + </tr>
  26 + <% @configuration.metric_configurations.each do |metric_configuration| %>
  27 + <tr class="metric">
  28 + <td><%= metric_configuration.metric.name %></td>
  29 + <td><%= metric_configuration.metric.origin %></td>
  30 + <td><%= metric_configuration.code %></td>
  31 + <td><%= link_to "Edit", :controller => "mezuro_plugin_profile", :action => "edit_metric_configuration", :params =>
  32 + {:configuration_name => @configuration.name, :metric_name => metric_configuration.metric.name} %></td>
  33 + <td><%= link_to "Remove", :controller => "mezuro_plugin_profile", :action => "remove_metric_configuration", :params =>
  34 + {:configuration_name => @configuration.name, :metric_name => metric_configuration.metric.name} %></td>
  35 + </tr>
  36 +<% end %>
  37 +</table>
plugins/mezuro/views/mezuro_plugin_profile/_new_range.html.erb 0 → 100644
@@ -0,0 +1,55 @@ @@ -0,0 +1,55 @@
  1 +<% remote_form_for :range, :url => {:action =>"create_range", :controller => "mezuro_plugin_profile"}, :method => :get do |f| %>
  2 + <%= hidden_field_tag :configuration_name, configuration_name %>
  3 + <%= hidden_field_tag :metric_name, metric_name %>
  4 + <table>
  5 + <tr>
  6 + <td>
  7 + <%= f.label :label, "Label:" %>
  8 + </td>
  9 + <td>
  10 + <%= f.text_field :label %>
  11 + </td>
  12 + </tr>
  13 + <tr>
  14 + <td>
  15 + <%= f.label :beginning, "Beginning:" %>
  16 + </td>
  17 + <td>
  18 + <%= f.text_field :beginning %>
  19 + </td>
  20 + </tr>
  21 + <tr>
  22 + <td>
  23 + <%= f.label :end, "End:" %>
  24 + </td>
  25 + <td>
  26 + <%= f.text_field :end %>
  27 + </td>
  28 + </tr>
  29 + <tr>
  30 + <td>
  31 + <%= f.label :grade, "Grade:" %>
  32 + </td>
  33 + <td>
  34 + <%= f.text_field :grade %>
  35 + </td>
  36 + </tr>
  37 + <tr>
  38 + <td>
  39 + <%= f.label :color, "Color:" %>
  40 + </td>
  41 + <td>
  42 + <%= f.text_field :color %>
  43 + </td>
  44 + </tr>
  45 + <tr>
  46 + <td>
  47 + <%= f.label :comments, "Comments:" %>
  48 + </td>
  49 + <td>
  50 + <%= f.text_field :comments %>
  51 + </td>
  52 + </tr>
  53 + </table>
  54 + <%= f.submit "Save Range" %>
  55 +<% end %>
plugins/mezuro/views/mezuro_plugin_profile/_range.html.erb 0 → 100644
@@ -0,0 +1,15 @@ @@ -0,0 +1,15 @@
  1 +<tr>
  2 + <td>
  3 + <%=range.label%>
  4 + </td>
  5 + <td>
  6 + <%=range.beginning%>
  7 + </td>
  8 + <td>
  9 + <%=range.end%>
  10 + </td>
  11 + <td>
  12 + <%=range.grade%>
  13 + </td>
  14 + <td bgcolor="#<%= range.color[2..-1] %>"></td>
  15 +</tr>
plugins/mezuro/views/mezuro_plugin_profile/choose_base_tool.html.erb 0 → 100644
@@ -0,0 +1,13 @@ @@ -0,0 +1,13 @@
  1 +<h2><%= @configuration_name%> Configuration</h2>
  2 +
  3 +<h5>Base Tools:</h5>
  4 +<table id="project_info">
  5 + <% @tool_names.base_tool_names.each do |collector_name| %>
  6 + <tr>
  7 + <td>
  8 + <%= link_to collector_name, :controller => "mezuro_plugin_profile", :action => "choose_metric", :params =>
  9 + {:configuration_name => @configuration_name, :collector_name => collector_name} %>
  10 + </td>
  11 + </tr>
  12 + <% end %>
  13 +</table>
plugins/mezuro/views/mezuro_plugin_profile/choose_metric.html.erb 0 → 100644
@@ -0,0 +1,18 @@ @@ -0,0 +1,18 @@
  1 +<h2><%= @configuration_name %> Configuration</h2>
  2 +
  3 +<table id="project_info">
  4 + <tr>
  5 + <h5>Metric Collector: <%= @collector_name %></h5>
  6 + </tr>
  7 + <tr>
  8 + <h5>Choose a metric to add:</h5>
  9 + </tr>
  10 + <% @collector.supported_metrics.each do |metric| %>
  11 + <tr class="metric" title="<%= metric.name %>">
  12 + <td>
  13 + <%= link_to metric.name, :controller => "mezuro_plugin_profile", :action => "new_metric_configuration", :params => {:metric_name => metric.name,
  14 + :collector_name => @collector_name, :configuration_name => @configuration_name} %>
  15 + </td>
  16 + </tr>
  17 + <% end %>
  18 +</table>
plugins/mezuro/views/mezuro_plugin_profile/create_range.rjs 0 → 100644
@@ -0,0 +1,2 @@ @@ -0,0 +1,2 @@
  1 +page.visual_effect :toggle_slide, "new_range"
  2 +page.insert_html :bottom, "ranges", :partial => "range", :locals => {:range => @range}
plugins/mezuro/views/mezuro_plugin_profile/edit_metric_configuration.html.erb 0 → 100644
@@ -0,0 +1,77 @@ @@ -0,0 +1,77 @@
  1 +<h2><%= @configuration_name %> Configuration</h2>
  2 +
  3 +<% form_for :metric_configuration, :url => {:action =>"update_metric_configuration", :controller => "mezuro_plugin_profile"}, :method => :get do |f| %>
  4 + <%= hidden_field_tag :configuration_name, @configuration_name %>
  5 + <%= hidden_field_tag :scope, @metric.scope %>
  6 +
  7 + <% @metric.language.each do |language| %>
  8 + <%= hidden_field_tag "language[]", language %>
  9 + <% end %>
  10 +
  11 + <p>
  12 + <%= f.label :origin, "Collector Name:" %>
  13 + <%= @metric.origin %>
  14 + <%= hidden_field_tag "metric[origin]", @metric.origin %>
  15 + </p>
  16 + <p>
  17 + <%= f.label :metric_name, "Metric Name:" %>
  18 + <%= @metric.name %>
  19 + <%= hidden_field_tag "metric[name]", @metric.name %>
  20 + </p>
  21 + <p>
  22 + <%= f.label :description, "Description:" %>
  23 + <%= @metric.description %>
  24 + <%= text_field_tag "metric[description]", @metric.description %>
  25 + </p>
  26 + <p>
  27 + <%= f.label :code, "Code:" %>
  28 + <%= @metric_configuration.code %>
  29 + <%= f.hidden_field :code, :value => @metric_configuration.code %>
  30 + </p>
  31 + <p>
  32 + <%= f.label :aggregation_form, "Aggregation Form:" %>
  33 + <%= f.select :aggregation_form, [["Average","AVERAGE"], ["Median", "MEDIAN"], ["Maximum", "MAXIMUM"], ["Minimum", "MINIMUM"],
  34 + ["Count", "COUNT"], ["Standard Deviation", "STANDARD_DEVIATION"]] %>
  35 + </p>
  36 + <p>
  37 + <%= f.label :weight, "Weight:" %>
  38 + <%= f.text_field :weight %>
  39 + </p>
  40 +
  41 + <p>
  42 + <%= f.submit "Save" %>
  43 + </p>
  44 +<% end %>
  45 +
  46 +
  47 +<h5> Ranges </h5><br/>
  48 +
  49 +<table id="ranges">
  50 + <tr>
  51 + <td>
  52 + Label
  53 + </td>
  54 + <td>
  55 + Beginning
  56 + </td>
  57 + <td>
  58 + End
  59 + </td>
  60 + <td>
  61 + Grade
  62 + </td>
  63 + <td>
  64 + Color
  65 + </td>
  66 + </tr>
  67 + <% if (@metric_configuration.ranges!=nil)
  68 + @metric_configuration.ranges.each do |range| %>
  69 + <%= render :partial => "range", :locals => {:range => range} %>
  70 + <% end
  71 + end %>
  72 +</table>
  73 +
  74 +<br/>
  75 +<%= link_to_remote "New Range", :url => {:action =>"new_range", :controller => "mezuro_plugin_profile", :configuration_name => @configuration_name, :metric_name => @metric.name} %>
  76 +<div id="new_range" style="display:none"></div>
  77 +
plugins/mezuro/views/mezuro_plugin_profile/new_metric_configuration.html.erb 0 → 100644
@@ -0,0 +1,44 @@ @@ -0,0 +1,44 @@
  1 +<h2><%= @configuration_name %> Configuration</h2>
  2 +
  3 +<% form_for :metric_configuration, :url => {:action =>"create_metric_configuration", :controller => "mezuro_plugin_profile"}, :method => :get do |f| %>
  4 + <%= hidden_field_tag :configuration_name, @configuration_name %>
  5 + <%= hidden_field_tag :scope, @metric.scope %>
  6 +
  7 + <% @metric.language.each do |language| %>
  8 + <%= hidden_field_tag "language[]", language %>
  9 + <% end %>
  10 +
  11 + <p>
  12 + <%= f.label :origin, "Collector Name:" %>
  13 + <%= @metric.origin %>
  14 + <%= hidden_field_tag "metric[origin]", @metric.origin %>
  15 + </p>
  16 + <p>
  17 + <%= f.label :metric_name, "Metric Name:" %>
  18 + <%= @metric.name %>
  19 + <%= hidden_field_tag "metric[name]", @metric.name %>
  20 + </p>
  21 + <p>
  22 + <%= f.label :description, "Description:" %>
  23 + <%= @metric.description %>
  24 + <%= text_field_tag :description %>
  25 + </p>
  26 + <p>
  27 + <%= f.label :code, "Code:" %>
  28 + <%= f.text_field :code %>
  29 + </p>
  30 + <p>
  31 + <%= f.label :aggregation, "Aggregation:" %>
  32 + <%= f.select :aggregation, [["Average","AVERAGE"], ["Median", "MEDIAN"], ["Maximum", "MAXIMUM"], ["Minimum", "MINIMUM"],
  33 + ["Count", "COUNT"], ["Standard Deviation", "STANDARD_DEVIATION"]] %>
  34 + </p>
  35 + <p>
  36 + <%= f.label :weight, "Weight:" %>
  37 + <%= f.text_field :weight %>
  38 + </p>
  39 +
  40 + <p>
  41 + <%= f.submit "Add" %>
  42 + </p>
  43 +
  44 +<% end %>
plugins/mezuro/views/mezuro_plugin_profile/new_range.rjs 0 → 100644
@@ -0,0 +1,2 @@ @@ -0,0 +1,2 @@
  1 +page.replace_html 'new_range', :partial => "new_range", :locals => {:metric_name => @metric_name, :configuration_name => @configuration_name}
  2 +page.visual_effect :toggle_slide, "new_range"
plugins/mezuro/views/mezuro_plugin_profile/teste.html.erb 0 → 100644
@@ -0,0 +1 @@ @@ -0,0 +1 @@
  1 +<h3><%= @configuration_name %></h3>