diff --git a/plugins/mezuro/lib/kalibro/metric_configuration_snapshot.rb b/plugins/mezuro/lib/kalibro/metric_configuration_snapshot.rb index 99c3628..406f6c2 100644 --- a/plugins/mezuro/lib/kalibro/metric_configuration_snapshot.rb +++ b/plugins/mezuro/lib/kalibro/metric_configuration_snapshot.rb @@ -26,6 +26,7 @@ class Kalibro::MetricConfigurationSnapshot < Kalibro::Model def to_hash hash = super + puts hash hash[:attributes!][:range] = {'xmlns:xsi'=> 'http://www.w3.org/2001/XMLSchema-instance', 'xsi:type' => 'kalibro:rangeSnapshotXml' } hash diff --git a/plugins/mezuro/lib/kalibro/model.rb b/plugins/mezuro/lib/kalibro/model.rb index 369a749..3987145 100644 --- a/plugins/mezuro/lib/kalibro/model.rb +++ b/plugins/mezuro/lib/kalibro/model.rb @@ -15,7 +15,7 @@ class Kalibro::Model if(!excepts.include?(field)) field_value = send(field) if !field_value.nil? - hash[field] = convert_to_hash(field_value) + hash[field] = convert_to_hash(field_value) if field_value.is_a?(Kalibro::Model) hash = {:attributes! => {}}.merge(hash) hash[:attributes!][field.to_sym] = { @@ -91,7 +91,7 @@ class Kalibro::Model return self.class.date_with_milliseconds(value) if value.is_a?(DateTime) return 'INF' if value.is_a?(Float) and value.infinite? == 1 return '-INF' if value.is_a?(Float) and value.infinite? == -1 - value + value.to_s end def xml_instance_class_name(object) diff --git a/plugins/mezuro/lib/kalibro/process_time.rb b/plugins/mezuro/lib/kalibro/process_time.rb index f0af321..0ad0d73 100644 --- a/plugins/mezuro/lib/kalibro/process_time.rb +++ b/plugins/mezuro/lib/kalibro/process_time.rb @@ -2,4 +2,8 @@ class Kalibro::ProcessTime < Kalibro::Model attr_accessor :state, :time + def time=(time) + @time = time.to_i + end + end diff --git a/plugins/mezuro/lib/mezuro_plugin/helpers/content_viewer_helper.rb b/plugins/mezuro/lib/mezuro_plugin/helpers/content_viewer_helper.rb index feab0f9..364ed02 100644 --- a/plugins/mezuro/lib/mezuro_plugin/helpers/content_viewer_helper.rb +++ b/plugins/mezuro/lib/mezuro_plugin/helpers/content_viewer_helper.rb @@ -47,6 +47,11 @@ class MezuroPlugin::Helpers::ContentViewerHelper def self.format_name(metric_configuration_snapshot) metric_configuration_snapshot.metric.name.delete("() ") end + + def self.format_time(time) + time.class + #MezuroPluginModuleResultController.helpers.distance_of_time_in_words(0, time/1000, include_seconds = true) + end private diff --git a/plugins/mezuro/test/fixtures/configuration_fixtures.rb b/plugins/mezuro/test/fixtures/configuration_fixtures.rb index 37afced..1c5c220 100644 --- a/plugins/mezuro/test/fixtures/configuration_fixtures.rb +++ b/plugins/mezuro/test/fixtures/configuration_fixtures.rb @@ -15,7 +15,7 @@ class ConfigurationFixtures def self.configuration_hash { - :id => 42, + :id => "42", :name => 'Sample Configuration', :description => 'Kalibro configuration for Java projects.' } diff --git a/plugins/mezuro/test/fixtures/metric_configuration_fixtures.rb b/plugins/mezuro/test/fixtures/metric_configuration_fixtures.rb index 39ae3b0..264ef87 100644 --- a/plugins/mezuro/test/fixtures/metric_configuration_fixtures.rb +++ b/plugins/mezuro/test/fixtures/metric_configuration_fixtures.rb @@ -4,13 +4,13 @@ class MetricConfigurationFixtures def self.amloc_metric_configuration amloc = Kalibro::MetricConfiguration.new amloc_metric_configuration_hash - amloc.configuration_id = 13 + amloc.configuration_id = "13" amloc end def self.sc_metric_configuration sc = Kalibro::MetricConfiguration.new sc_metric_configuration_hash - sc.configuration_id = 13 + sc.configuration_id = "13" sc end @@ -19,22 +19,22 @@ class MetricConfigurationFixtures :code => 'amloc', :metric => MetricFixtures.amloc_hash, :base_tool_name => MetricFixtures.amloc_hash[:origin], - :weight => 1.0, + :weight => "1.0", :aggregation_form => 'AVERAGE', - :reading_group_id => 31, - :configuration_id => 13 + :reading_group_id => "31", + :configuration_id => "13" }) end def self.amloc_metric_configuration_hash { - :id => 42, + :id => "42", :code => 'amloc', :metric => MetricFixtures.amloc_hash, :base_tool_name => MetricFixtures.amloc_hash[:origin], - :weight => 1.0, + :weight => "1.0", :aggregation_form => 'AVERAGE', - :reading_group_id => 31, + :reading_group_id => "31", :attributes! => {:metric => { 'xmlns:xsi'=> 'http://www.w3.org/2001/XMLSchema-instance', 'xsi:type' => 'kalibro:metricXml' }} @@ -43,12 +43,12 @@ class MetricConfigurationFixtures def self.sc_metric_configuration_hash { - :id => 42, + :id => "42", :code => 'sc', :metric => MetricFixtures.compound_metric_hash, - :weight => 1.0, + :weight => "1.0", :aggregation_form => 'AVERAGE', - :reading_group_id => 31, + :reading_group_id => "31", :attributes! => {:metric => { 'xmlns:xsi'=> 'http://www.w3.org/2001/XMLSchema-instance', 'xsi:type' => 'kalibro:metricXml' }} diff --git a/plugins/mezuro/test/fixtures/metric_configuration_snapshot_fixtures.rb b/plugins/mezuro/test/fixtures/metric_configuration_snapshot_fixtures.rb index 24f0c82..b4dd198 100644 --- a/plugins/mezuro/test/fixtures/metric_configuration_snapshot_fixtures.rb +++ b/plugins/mezuro/test/fixtures/metric_configuration_snapshot_fixtures.rb @@ -10,7 +10,7 @@ class MetricConfigurationSnapshotFixtures def self.metric_configuration_snapshot_hash { :code => "code", - :weight => 1, + :weight => "1", :aggregation_form => 'AVERAGE', :metric => MetricFixtures.amloc_hash, :base_tool_name => "Analizo", @@ -43,11 +43,11 @@ class MetricConfigurationSnapshotFixtures def self.compound_metric_configuration_snapshot_hash { :code => "code", - :weight => 1, + :weight => "1", :aggregation_form => 'AVERAGE', :metric => MetricFixtures.compound_metric, :base_tool_name => "Analizo", - :range => RangeSnapshotFixtures.range_snapshot_hash, + :range => [RangeSnapshotFixtures.range_snapshot_hash], :attributes! => { :metric => { 'xmlns:xsi'=> 'http://www.w3.org/2001/XMLSchema-instance', diff --git a/plugins/mezuro/test/fixtures/metric_fixtures.rb b/plugins/mezuro/test/fixtures/metric_fixtures.rb index 927cfc1..4c44987 100644 --- a/plugins/mezuro/test/fixtures/metric_fixtures.rb +++ b/plugins/mezuro/test/fixtures/metric_fixtures.rb @@ -5,7 +5,7 @@ class MetricFixtures end def self.compound_metric_hash - {:name => 'Structural Complexity', :compound => true, :scope => 'CLASS', :script => 'return 42;', :description => 'Calculate the Structural Complexity of the Code'} + {:name => 'Structural Complexity', :compound => "true", :scope => 'CLASS', :script => 'return 42;', :description => 'Calculate the Structural Complexity of the Code'} end def self.total_cof @@ -13,7 +13,7 @@ class MetricFixtures end def self.total_cof_hash - {:name => 'Total Coupling Factor', :compound => false, :scope => 'APPLICATION', :origin => 'Analizo', :language => ['JAVA']} + {:name => 'Total Coupling Factor', :compound => "false", :scope => 'APPLICATION', :origin => 'Analizo', :language => ['JAVA']} end def self.amloc @@ -21,7 +21,7 @@ class MetricFixtures end def self.amloc_hash - {:name => 'Average Method LOC', :compound => false, :scope => 'CLASS', :origin => 'Analizo', :language => ['JAVA']} + {:name => 'Average Method LOC', :compound => "false", :scope => 'CLASS', :origin => 'Analizo', :language => ['JAVA']} end end diff --git a/plugins/mezuro/test/fixtures/metric_result_fixtures.rb b/plugins/mezuro/test/fixtures/metric_result_fixtures.rb index cca63b8..f34f0c0 100644 --- a/plugins/mezuro/test/fixtures/metric_result_fixtures.rb +++ b/plugins/mezuro/test/fixtures/metric_result_fixtures.rb @@ -13,7 +13,7 @@ class MetricResultFixtures def self.metric_result_with_error_hash { - :id => 41, + :id => "41", :configuration => MetricConfigurationSnapshotFixtures.metric_configuration_snapshot_hash, :error => ThrowableFixtures.throwable_hash } @@ -21,9 +21,9 @@ class MetricResultFixtures def self.native_metric_result_hash { - :id => 42, + :id => "42", :configuration => MetricConfigurationSnapshotFixtures.metric_configuration_snapshot_hash, - :value => 0.0, + :value => "0.0", :attributes! => { :configuration => @@ -37,9 +37,9 @@ class MetricResultFixtures def self.compound_metric_result_hash { - :id => 43, + :id => "43", :configuration => MetricConfigurationSnapshotFixtures.compound_metric_configuration_snapshot_hash, - :value => 1.0, + :value => "1.0", :attributes! => { :configuration => diff --git a/plugins/mezuro/test/fixtures/module_result_fixtures.rb b/plugins/mezuro/test/fixtures/module_result_fixtures.rb index 87f5743..bc04d34 100644 --- a/plugins/mezuro/test/fixtures/module_result_fixtures.rb +++ b/plugins/mezuro/test/fixtures/module_result_fixtures.rb @@ -8,10 +8,10 @@ class ModuleResultFixtures def self.module_result_hash { - :id => 42, + :id => "42", :module => ModuleFixtures.module_hash, - :grade => 10.0, - :parent_id => 31, + :grade => "10.0", + :parent_id => "31", :attributes! => { :module => @@ -25,12 +25,12 @@ class ModuleResultFixtures def self.parent_module_result_hash { - :id => 31, + :id => "31", :module => { :name => 'Qt-Calculator Parent', :granularity => 'APPLICATION' }, - :grade => 10.0, + :grade => "10.0", :attributes! => { :module => diff --git a/plugins/mezuro/test/fixtures/process_time_fixtures.rb b/plugins/mezuro/test/fixtures/process_time_fixtures.rb index cef8e4d..ece195f 100644 --- a/plugins/mezuro/test/fixtures/process_time_fixtures.rb +++ b/plugins/mezuro/test/fixtures/process_time_fixtures.rb @@ -5,7 +5,7 @@ class ProcessTimeFixtures end def self.process_time_hash - {:state => "Ready", :time => 1} + {:state => "Ready", :time => "1"} end end diff --git a/plugins/mezuro/test/fixtures/processing_fixtures.rb b/plugins/mezuro/test/fixtures/processing_fixtures.rb index 735f4c5..b56dcd4 100644 --- a/plugins/mezuro/test/fixtures/processing_fixtures.rb +++ b/plugins/mezuro/test/fixtures/processing_fixtures.rb @@ -9,17 +9,17 @@ class ProcessingFixtures def self.processing_hash { - :id => 31, + :id => "31", :date => '2011-10-20T18:26:43.151+00:00', :state => 'READY', :process_time => [ProcessTimeFixtures.process_time_hash], - :results_root_id => 13 + :results_root_id => "13" } end def self.processing_with_error_hash { - :id => 31, + :id => "31", :date => '2011-10-20T18:26:43.151+00:00', :state => 'ERROR', :process_time => [ProcessTimeFixtures.process_time_hash], diff --git a/plugins/mezuro/test/fixtures/project_content_fixtures.rb b/plugins/mezuro/test/fixtures/project_content_fixtures.rb index c75177b..11e2265 100644 --- a/plugins/mezuro/test/fixtures/project_content_fixtures.rb +++ b/plugins/mezuro/test/fixtures/project_content_fixtures.rb @@ -3,14 +3,7 @@ class ProjectContentFixtures def self.project_content content = MezuroPlugin::ProjectContent.new content.project_id = 42 - #content.name = 'Qt-Calculator' - #content.project_license = 'GPL' - #content.description = 'Calculator for Qt' - #content.repository_type = [RepositoryFixtures.repository_hash[:type]] - #content.repository_url = [RepositoryFixtures.repository_hash[:address]] - #content.configuration_name = 'Kalibro for Java' - #content.periodicity_in_days = 1 content end -end \ No newline at end of file +end diff --git a/plugins/mezuro/test/fixtures/project_fixtures.rb b/plugins/mezuro/test/fixtures/project_fixtures.rb index 08781e1..8c18f90 100644 --- a/plugins/mezuro/test/fixtures/project_fixtures.rb +++ b/plugins/mezuro/test/fixtures/project_fixtures.rb @@ -12,7 +12,7 @@ class ProjectFixtures def self.project_hash { - :id => 42, + :id => "42", :name => 'Qt-Calculator', :description => 'Calculator for Qt' } diff --git a/plugins/mezuro/test/fixtures/range_fixtures.rb b/plugins/mezuro/test/fixtures/range_fixtures.rb index 836e5ab..cef675e 100644 --- a/plugins/mezuro/test/fixtures/range_fixtures.rb +++ b/plugins/mezuro/test/fixtures/range_fixtures.rb @@ -5,11 +5,11 @@ class RangeFixtures end def self.created_range - Kalibro::Range.new :beginning => 19.5, :end => "INF", :reading_id => 1, :comments => "Test range 1" + Kalibro::Range.new :beginning => "19.5", :end => "INF", :reading_id => "1", :comments => "Test range 1" end def self.range_hash - {:id => 1, :beginning => 19.5, :end => "INF", :reading_id => 1, :comments => "Test range 1"} + {:id => "1", :beginning => "19.5", :end => "INF", :reading_id => "1", :comments => "Test range 1"} end end diff --git a/plugins/mezuro/test/fixtures/range_snapshot_fixtures.rb b/plugins/mezuro/test/fixtures/range_snapshot_fixtures.rb index 76b7ee1..bd6a75b 100644 --- a/plugins/mezuro/test/fixtures/range_snapshot_fixtures.rb +++ b/plugins/mezuro/test/fixtures/range_snapshot_fixtures.rb @@ -5,7 +5,7 @@ class RangeSnapshotFixtures end def self.range_snapshot_hash - { :end => 5, :label => "snapshot", :grade => 10, :color => "FF2284", :comments => "comment" } + { :end => "5", :label => "snapshot", :grade => "10", :color => "FF2284", :comments => "comment" } end end diff --git a/plugins/mezuro/test/fixtures/reading_fixtures.rb b/plugins/mezuro/test/fixtures/reading_fixtures.rb index 8db9c35..4e7dc4c 100644 --- a/plugins/mezuro/test/fixtures/reading_fixtures.rb +++ b/plugins/mezuro/test/fixtures/reading_fixtures.rb @@ -5,11 +5,11 @@ class ReadingFixtures end def self.created_reading # A created object has no id before being sent to kalibro - Kalibro::Reading.new :label => "Reading Test Label", :grade => 10.5, :color => "AABBCC" + Kalibro::Reading.new :label => "Reading Test Label", :grade => "10.5", :color => "AABBCC" end def self.reading_hash - {:id => 42, :label => "Reading Test Label", :grade => 10.5, :color => "AABBCC" } + {:id => "42", :label => "Reading Test Label", :grade => "10.5", :color => "AABBCC" } end end diff --git a/plugins/mezuro/test/fixtures/reading_group_fixtures.rb b/plugins/mezuro/test/fixtures/reading_group_fixtures.rb index fe0ae63..41f68a5 100644 --- a/plugins/mezuro/test/fixtures/reading_group_fixtures.rb +++ b/plugins/mezuro/test/fixtures/reading_group_fixtures.rb @@ -9,7 +9,7 @@ class ReadingGroupFixtures end def self.reading_group_hash - {:id => 42, :name => "Reading Group Test", :description => "Reading group in the fixtures"} + {:id => "42", :name => "Reading Group Test", :description => "Reading group in the fixtures"} end end diff --git a/plugins/mezuro/test/fixtures/repository_fixtures.rb b/plugins/mezuro/test/fixtures/repository_fixtures.rb index 7b8263e..884a6a8 100644 --- a/plugins/mezuro/test/fixtures/repository_fixtures.rb +++ b/plugins/mezuro/test/fixtures/repository_fixtures.rb @@ -12,12 +12,12 @@ class RepositoryFixtures :process_period => "1", :type => 'SUBVERSION', :address => 'https://qt-calculator.svn.sourceforge.net/svnroot/qt-calculator', - :configuration_id => 31 + :configuration_id => "31" }) end def self.repository_hash - {:id => 42, :name => "test repository", :description => "test description", :license => "GPL", :process_period => "1", :type => 'SUBVERSION', :address => 'https://qt-calculator.svn.sourceforge.net/svnroot/qt-calculator', :configuration_id => 31} + {:id => "42", :name => "test repository", :description => "test description", :license => "GPL", :process_period => "1", :type => 'SUBVERSION', :address => "https://qt-calculator.svn.sourceforge.net/svnroot/qt-calculator", :configuration_id => "31"} end def self.types diff --git a/plugins/mezuro/test/fixtures/stack_trace_element_fixtures.rb b/plugins/mezuro/test/fixtures/stack_trace_element_fixtures.rb index b27bf4f..30777ad 100644 --- a/plugins/mezuro/test/fixtures/stack_trace_element_fixtures.rb +++ b/plugins/mezuro/test/fixtures/stack_trace_element_fixtures.rb @@ -1,15 +1,15 @@ class StackTraceElementFixtures - def self.stack_trace_element(method_name = 'my method name', line_number = 42) - Kalibro::StackTraceElement.new stack_trace_element_hash(method_name, line_number) + def self.stack_trace_element + Kalibro::StackTraceElement.new stack_trace_element_hash end - def self.stack_trace_element_hash(method_name = 'my method name', line_number = 42) + def self.stack_trace_element_hash { :declaring_class => 'my.declaring.Class', - :method_name => method_name, + :method_name => 'my method name', :file_name => 'MyFile.java', - :line_number => line_number + :line_number => '42' } end diff --git a/plugins/mezuro/test/fixtures/throwable_fixtures.rb b/plugins/mezuro/test/fixtures/throwable_fixtures.rb index ce1b18d..4de270f 100644 --- a/plugins/mezuro/test/fixtures/throwable_fixtures.rb +++ b/plugins/mezuro/test/fixtures/throwable_fixtures.rb @@ -11,8 +11,7 @@ class ThrowableFixtures :target_string => 'Target String', :message => 'Throwable message from ThrowableTest', :stack_trace_element => [ - StackTraceElementFixtures.stack_trace_element_hash('my method 1', 42), - StackTraceElementFixtures.stack_trace_element_hash('my method 2', 84) + StackTraceElementFixtures.stack_trace_element_hash, StackTraceElementFixtures.stack_trace_element_hash ] } end diff --git a/plugins/mezuro/test/unit/kalibro/process_time_test.rb b/plugins/mezuro/test/unit/kalibro/process_time_test.rb index 7603c1b..9d4aa6c 100644 --- a/plugins/mezuro/test/unit/kalibro/process_time_test.rb +++ b/plugins/mezuro/test/unit/kalibro/process_time_test.rb @@ -17,4 +17,8 @@ class ProcessTimeTest < ActiveSupport::TestCase assert_equal @hash, @process_time.to_hash end + should 'get time as an integer' do + assert_equal 1.class, @process_time.time.class + end + end diff --git a/plugins/mezuro/views/mezuro_plugin_processing/_processing.rhtml b/plugins/mezuro/views/mezuro_plugin_processing/_processing.rhtml index 9e0003e..006265c 100644 --- a/plugins/mezuro/views/mezuro_plugin_processing/_processing.rhtml +++ b/plugins/mezuro/views/mezuro_plugin_processing/_processing.rhtml @@ -8,9 +8,10 @@ <%= @processing.date %> <% @processing.process_time.each do |process_time| %> + <%= process_time.inspect %> <%= _(process_time.state + ' time') %> - <%= process_time.time %> + <%= MezuroPlugin::Helpers::ContentViewerHelper.format_time(process_time.time) %> <% end %> @@ -33,4 +34,4 @@ }); - \ No newline at end of file + -- libgit2 0.21.2