kalibro_gem 0.0.1.rc7

Sign up to get free protection for your applications and to get access to all the features.
Files changed (160) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +19 -0
  3. data/.ruby-gemset +1 -0
  4. data/.ruby-version +1 -0
  5. data/.travis.yml +21 -0
  6. data/AUTHORS +4 -0
  7. data/COPYING +674 -0
  8. data/COPYING.LESSER +165 -0
  9. data/Gemfile +4 -0
  10. data/README.md +77 -0
  11. data/Rakefile +6 -0
  12. data/cucumber.yml +1 -0
  13. data/features/base_tool/all_names.feature +8 -0
  14. data/features/base_tool/find_by_name.feature +12 -0
  15. data/features/configuration/all.feature +10 -0
  16. data/features/metric_configuration/find.feature +18 -0
  17. data/features/metric_configuration/metric_configurations_of.feature +18 -0
  18. data/features/metric_result/descendant_results.feature +19 -0
  19. data/features/metric_result/history_of.feature +20 -0
  20. data/features/metric_result/metric_results_of.feature +19 -0
  21. data/features/module_result/children.feature +18 -0
  22. data/features/module_result/find.feature +15 -0
  23. data/features/module_result/history_of.feature +11 -0
  24. data/features/processing/first_processing_after.feature +18 -0
  25. data/features/processing/first_processing_of.feature +18 -0
  26. data/features/processing/has_processing.feature +18 -0
  27. data/features/processing/has_processing_after.feature +18 -0
  28. data/features/processing/has_processing_before.feature +18 -0
  29. data/features/processing/has_ready_processing.feature +18 -0
  30. data/features/processing/last_processing_before.feature +18 -0
  31. data/features/processing/last_processing_of.feature +18 -0
  32. data/features/processing/last_processing_state_of.feature +18 -0
  33. data/features/processing/last_ready_processing_of.feature +18 -0
  34. data/features/processing/processing_of.feature +32 -0
  35. data/features/processing/processing_with_date_of.feature +32 -0
  36. data/features/project/all.feature +10 -0
  37. data/features/project/creation.feature +9 -0
  38. data/features/project/destroy.feature +10 -0
  39. data/features/project/exists.feature +9 -0
  40. data/features/project/find.feature +10 -0
  41. data/features/range/ranges_of.feature +22 -0
  42. data/features/range/save.feature +32 -0
  43. data/features/reading/find.feature +11 -0
  44. data/features/reading/readings_of.feature +11 -0
  45. data/features/reading_group/all.feature +10 -0
  46. data/features/repository/all.feature +14 -0
  47. data/features/repository/cancel_processing.feature +14 -0
  48. data/features/repository/exists.feature +14 -0
  49. data/features/repository/find.feature +14 -0
  50. data/features/repository/of.feature +15 -0
  51. data/features/repository/process.feature +16 -0
  52. data/features/repository/types.feature +9 -0
  53. data/features/step_definitions/base_tool_steps.rb +28 -0
  54. data/features/step_definitions/configuration_steps.rb +11 -0
  55. data/features/step_definitions/metric_configuration_steps.rb +52 -0
  56. data/features/step_definitions/metric_result_steps.rb +29 -0
  57. data/features/step_definitions/metric_steps.rb +3 -0
  58. data/features/step_definitions/module_result_steps.rb +30 -0
  59. data/features/step_definitions/processing_steps.rb +91 -0
  60. data/features/step_definitions/project_steps.rb +48 -0
  61. data/features/step_definitions/range_steps.rb +41 -0
  62. data/features/step_definitions/reading_group_steps.rb +19 -0
  63. data/features/step_definitions/reading_steps.rb +20 -0
  64. data/features/step_definitions/repository_steps.rb +61 -0
  65. data/features/support/env.rb +25 -0
  66. data/features/support/kalibro_cucumber_helpers.yml.sample +10 -0
  67. data/kalibro_gem.gemspec +48 -0
  68. data/lib/kalibro_gem.rb +61 -0
  69. data/lib/kalibro_gem/entities.rb +37 -0
  70. data/lib/kalibro_gem/entities/base_tool.rb +54 -0
  71. data/lib/kalibro_gem/entities/configuration.rb +33 -0
  72. data/lib/kalibro_gem/entities/date_metric_result.rb +39 -0
  73. data/lib/kalibro_gem/entities/date_module_result.rb +39 -0
  74. data/lib/kalibro_gem/entities/metric.rb +21 -0
  75. data/lib/kalibro_gem/entities/metric_configuration.rb +70 -0
  76. data/lib/kalibro_gem/entities/metric_configuration_snapshot.rb +57 -0
  77. data/lib/kalibro_gem/entities/metric_result.rb +74 -0
  78. data/lib/kalibro_gem/entities/model.rb +162 -0
  79. data/lib/kalibro_gem/entities/module.rb +27 -0
  80. data/lib/kalibro_gem/entities/module_result.rb +77 -0
  81. data/lib/kalibro_gem/entities/process_time.rb +31 -0
  82. data/lib/kalibro_gem/entities/processing.rb +113 -0
  83. data/lib/kalibro_gem/entities/project.rb +34 -0
  84. data/lib/kalibro_gem/entities/range.rb +75 -0
  85. data/lib/kalibro_gem/entities/range_snapshot.rb +37 -0
  86. data/lib/kalibro_gem/entities/reading.rb +51 -0
  87. data/lib/kalibro_gem/entities/reading_group.rb +43 -0
  88. data/lib/kalibro_gem/entities/repository.rb +86 -0
  89. data/lib/kalibro_gem/entities/repository_observer.rb +50 -0
  90. data/lib/kalibro_gem/entities/stack_trace_element.rb +31 -0
  91. data/lib/kalibro_gem/entities/throwable.rb +42 -0
  92. data/lib/kalibro_gem/errors.rb +18 -0
  93. data/lib/kalibro_gem/errors/record_not_found.rb +22 -0
  94. data/lib/kalibro_gem/errors/standard.rb +24 -0
  95. data/lib/kalibro_gem/helpers/aggregation_options.rb +25 -0
  96. data/lib/kalibro_gem/helpers/hash_converters.rb +48 -0
  97. data/lib/kalibro_gem/helpers/request_methods.rb +47 -0
  98. data/lib/kalibro_gem/helpers/xml_converters.rb +20 -0
  99. data/lib/kalibro_gem/kalibro_cucumber_helpers.rb +40 -0
  100. data/lib/kalibro_gem/kalibro_cucumber_helpers/configuration.rb +39 -0
  101. data/lib/kalibro_gem/kalibro_cucumber_helpers/hooks.rb +50 -0
  102. data/lib/kalibro_gem/kalibro_cucumber_helpers/scripts/delete_all_kalibro_entries.sh +23 -0
  103. data/lib/kalibro_gem/kalibro_cucumber_helpers/scripts/prepare_kalibro_query_file.sh +38 -0
  104. data/lib/kalibro_gem/kalibro_cucumber_helpers/scripts/put_kalibro_on_test_mode.sh +35 -0
  105. data/lib/kalibro_gem/kalibro_cucumber_helpers/scripts/return_kalibro_from_test_mode.sh +26 -0
  106. data/lib/kalibro_gem/version.rb +19 -0
  107. data/lib/rake/test_task.rb +57 -0
  108. data/spec/entities/base_tool_spec.rb +168 -0
  109. data/spec/entities/configuration_spec.rb +61 -0
  110. data/spec/entities/date_metric_result_spec.rb +62 -0
  111. data/spec/entities/date_module_result_spec.rb +61 -0
  112. data/spec/entities/metric_configuration_snapshot_spec.rb +107 -0
  113. data/spec/entities/metric_configuration_spec.rb +149 -0
  114. data/spec/entities/metric_result_spec.rb +201 -0
  115. data/spec/entities/metric_spec.rb +47 -0
  116. data/spec/entities/model_spec.rb +275 -0
  117. data/spec/entities/module_result_spec.rb +163 -0
  118. data/spec/entities/process_time_spec.rb +33 -0
  119. data/spec/entities/processing_spec.rb +334 -0
  120. data/spec/entities/project_spec.rb +68 -0
  121. data/spec/entities/range_snapshot_spec.rb +50 -0
  122. data/spec/entities/range_spec.rb +181 -0
  123. data/spec/entities/reading_group_spec.rb +90 -0
  124. data/spec/entities/reading_spec.rb +106 -0
  125. data/spec/entities/repository_observer_spec.rb +123 -0
  126. data/spec/entities/repository_spec.rb +191 -0
  127. data/spec/entities/stack_trace_element_spec.rb +26 -0
  128. data/spec/entities/throwable_spec.rb +51 -0
  129. data/spec/factories/base_tools.rb +31 -0
  130. data/spec/factories/configurations.rb +29 -0
  131. data/spec/factories/date_metric_results.rb +28 -0
  132. data/spec/factories/date_module_results.rb +22 -0
  133. data/spec/factories/metric_configurations.rb +28 -0
  134. data/spec/factories/metric_configurations_snapshot.rb +26 -0
  135. data/spec/factories/metric_results.rb +24 -0
  136. data/spec/factories/metrics.rb +35 -0
  137. data/spec/factories/models.rb +20 -0
  138. data/spec/factories/module_results.rb +33 -0
  139. data/spec/factories/modules.rb +22 -0
  140. data/spec/factories/process_times.rb +27 -0
  141. data/spec/factories/processings.rb +25 -0
  142. data/spec/factories/projects.rb +29 -0
  143. data/spec/factories/ranges.rb +30 -0
  144. data/spec/factories/ranges_snapshot.rb +26 -0
  145. data/spec/factories/reading_groups.rb +23 -0
  146. data/spec/factories/readings.rb +25 -0
  147. data/spec/factories/repositories.rb +34 -0
  148. data/spec/factories/repository_observers.rb +24 -0
  149. data/spec/factories/stack_trace_elements.rb +24 -0
  150. data/spec/factories/throwables.rb +23 -0
  151. data/spec/helpers/aggregation_options_spec.rb +31 -0
  152. data/spec/helpers/hash_converters_spec.rb +111 -0
  153. data/spec/helpers/xml_converters_spec.rb +64 -0
  154. data/spec/kalibro_entities_spec.rb +108 -0
  155. data/spec/savon/fixtures/config.yml +1 -0
  156. data/spec/savon/fixtures/invalid_config.yml +2 -0
  157. data/spec/savon/fixtures/project/does_not_exists.xml +1 -0
  158. data/spec/savon/savon_test_helper.rb +14 -0
  159. data/spec/spec_helper.rb +60 -0
  160. metadata +463 -0
@@ -0,0 +1,25 @@
1
+ # SimpleCov for test coverage report
2
+ require 'simplecov'
3
+ SimpleCov.start do
4
+ add_group "Entities", "lib/kalibro_gem/entities"
5
+ add_group "Errors", "lib/kalibro_gem/errors"
6
+ add_group "Helpers", "lib/kalibro_gem/helpers"
7
+ add_group "Cucumber Helpers", "lib/kalibro_gem/kalibro_cucumber_helpers"
8
+
9
+ add_filter "/spec/"
10
+ add_filter "/features/"
11
+
12
+ coverage_dir 'coverage/cucumber'
13
+ end
14
+
15
+ # Kalibro hooks
16
+ require 'kalibro_gem/kalibro_cucumber_helpers/hooks'
17
+
18
+ # Configuring the right hooks
19
+ KalibroGem::KalibroCucumberHelpers.configure_from_yml("#{__dir__}/kalibro_cucumber_helpers.yml")
20
+
21
+ # The gem itself
22
+ require 'kalibro_gem'
23
+
24
+ require 'factory_girl'
25
+ FactoryGirl.find_definitions
@@ -0,0 +1,10 @@
1
+ kalibro_cucumber_helpers:
2
+ database: "kalibro_test"
3
+ user: "kalibro"
4
+ password: "kalibro"
5
+ psql_file_path: "/tmp/PostgreSQL.sql"
6
+ query_file_path: "/tmp/query"
7
+ kalibro_home: "/usr/share/tomcat6/.kalibro"
8
+ tomcat_user: "tomcat6"
9
+ tomcat_group: "tomcat6"
10
+ tomcat_restart_command: "sudo\\ service\\ tomcat6\\ restart"
@@ -0,0 +1,48 @@
1
+ # This file is part of KalibroGem
2
+ # Copyright (C) 2013 it's respectives authors (please see the AUTHORS file)
3
+ #
4
+ # This program is free software: you can redistribute it and/or modify
5
+ # it under the terms of the GNU General Public License as published by
6
+ # the Free Software Foundation, either version 3 of the License, or
7
+ # (at your option) any later version.
8
+ #
9
+ # This program is distributed in the hope that it will be useful,
10
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
11
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
+ # GNU General Public License for more details.
13
+
14
+ # You should have received a copy of the GNU General Public License
15
+ # along with this program. If not, see <http://www.gnu.org/licenses/>.
16
+
17
+ # coding: utf-8
18
+ lib = File.expand_path('../lib', __FILE__)
19
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
20
+ require 'kalibro_gem/version'
21
+
22
+ Gem::Specification.new do |spec|
23
+ spec.name = "kalibro_gem"
24
+ spec.version = KalibroGem::VERSION
25
+ spec.authors = ["Carlos Morais", "Daniel Paulino Alves", "Diego Araújo Martinez", "Fellipe Souto", "Guilherme Rojas V. de Lima", "João M. M. da Silva", "Rafael Reggiani Manzo", "Renan Fichberg"]
26
+ spec.email = ["carlos88morais@gmail.com", "danpaulalves@gmail.com", "diegamc90@gmail.com", "fllsouto@gmail.com","guilhermehrojas@gmail.com", "jaodsilv@linux.ime.usp.br", "rr.manzo@gmail.com", "rfichberg@gmail.com"]
27
+ spec.description = "KalibroGem is a Ruby gem intended to be an interface for Ruby applications who want to use the open source code analysis webservice Kalibro (http://gitorious.org/kalibro/kalibro)."
28
+ spec.summary = "KalibroEntites is a communication interface with the Kalibro service."
29
+ spec.homepage = "https://github.com/mezuro/kalibro_gem"
30
+ spec.license = "LGPLv3"
31
+
32
+ spec.files = `git ls-files`.split($/)
33
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
34
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
35
+ spec.require_paths = ["lib"]
36
+
37
+ spec.add_development_dependency "bundler", "~> 1.3"
38
+ spec.add_development_dependency "rake"
39
+ spec.add_development_dependency "rspec", "~> 2.14"
40
+ spec.add_development_dependency "cucumber", "~> 1.3.5"
41
+ spec.add_development_dependency "mocha", "~> 0.14.0"
42
+ spec.add_development_dependency "simplecov"
43
+ spec.add_development_dependency "factory_girl", "~> 4.3.0"
44
+ spec.add_development_dependency 'coveralls'
45
+
46
+ spec.add_dependency "savon-ng-1.6", "~> 2.4.1"
47
+ spec.add_dependency "activesupport", "~> 4.0.1"
48
+ end
@@ -0,0 +1,61 @@
1
+ # This file is part of KalibroGem
2
+ # Copyright (C) 2013 it's respectives authors (please see the AUTHORS file)
3
+ #
4
+ # This program is free software: you can redistribute it and/or modify
5
+ # it under the terms of the GNU General Public License as published by
6
+ # the Free Software Foundation, either version 3 of the License, or
7
+ # (at your option) any later version.
8
+ #
9
+ # This program is distributed in the hope that it will be useful,
10
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
11
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
+ # GNU General Public License for more details.
13
+
14
+ # You should have received a copy of the GNU General Public License
15
+ # along with this program. If not, see <http://www.gnu.org/licenses/>.
16
+
17
+ require 'yaml'
18
+ require 'logger'
19
+ require "kalibro_gem/version"
20
+ require "kalibro_gem/errors"
21
+ require "kalibro_gem/entities"
22
+
23
+ module KalibroGem
24
+ @config = {
25
+ address: "http://localhost:8080/KalibroService/"
26
+ }
27
+
28
+ @valid_config_keys = @config.keys
29
+
30
+ @logger = Logger.new(STDOUT)
31
+
32
+ # Configure through hash
33
+ def KalibroGem.configure(opts = {})
34
+ opts.each {|k,v| @config[k.to_sym] = v if @valid_config_keys.include? k.to_sym}
35
+ end
36
+
37
+ # Configure through yaml file
38
+ def KalibroGem.configure_with(path_to_yaml_file)
39
+ begin
40
+ config = YAML::load(IO.read(path_to_yaml_file))
41
+ rescue Errno::ENOENT
42
+ logger.warn("YAML configuration file couldn't be found. Using defaults."); return
43
+ rescue Psych::SyntaxError
44
+ logger.warn("YAML configuration file contains invalid syntax. Using defaults."); return
45
+ end
46
+
47
+ configure(config)
48
+ end
49
+
50
+ def KalibroGem.config
51
+ @config
52
+ end
53
+
54
+ def KalibroGem.logger
55
+ @logger
56
+ end
57
+
58
+ def KalibroGem.logger=(logger)
59
+ @logger = logger
60
+ end
61
+ end
@@ -0,0 +1,37 @@
1
+ # This file is part of KalibroGem
2
+ # Copyright (C) 2013 it's respectives authors (please see the AUTHORS file)
3
+ #
4
+ # This program is free software: you can redistribute it and/or modify
5
+ # it under the terms of the GNU General Public License as published by
6
+ # the Free Software Foundation, either version 3 of the License, or
7
+ # (at your option) any later version.
8
+ #
9
+ # This program is distributed in the hope that it will be useful,
10
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
11
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
+ # GNU General Public License for more details.
13
+
14
+ # You should have received a copy of the GNU General Public License
15
+ # along with this program. If not, see <http://www.gnu.org/licenses/>.
16
+
17
+ require 'kalibro_gem/entities/base_tool'
18
+ require 'kalibro_gem/entities/configuration'
19
+ require 'kalibro_gem/entities/date_metric_result'
20
+ require 'kalibro_gem/entities/date_module_result'
21
+ require 'kalibro_gem/entities/metric'
22
+ require 'kalibro_gem/entities/metric_configuration'
23
+ require 'kalibro_gem/entities/metric_configuration_snapshot'
24
+ require 'kalibro_gem/entities/metric_result'
25
+ require 'kalibro_gem/entities/module'
26
+ require 'kalibro_gem/entities/module_result'
27
+ require 'kalibro_gem/entities/process_time'
28
+ require 'kalibro_gem/entities/processing'
29
+ require 'kalibro_gem/entities/project'
30
+ require 'kalibro_gem/entities/range'
31
+ require 'kalibro_gem/entities/range_snapshot'
32
+ require 'kalibro_gem/entities/reading'
33
+ require 'kalibro_gem/entities/reading_group'
34
+ require 'kalibro_gem/entities/repository'
35
+ require 'kalibro_gem/entities/repository_observer'
36
+ require 'kalibro_gem/entities/stack_trace_element'
37
+ require 'kalibro_gem/entities/throwable'
@@ -0,0 +1,54 @@
1
+ # This file is part of KalibroGem
2
+ # Copyright (C) 2013 it's respectives authors (please see the AUTHORS file)
3
+ #
4
+ # This program is free software: you can redistribute it and/or modify
5
+ # it under the terms of the GNU General Public License as published by
6
+ # the Free Software Foundation, either version 3 of the License, or
7
+ # (at your option) any later version.
8
+ #
9
+ # This program is distributed in the hope that it will be useful,
10
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
11
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
+ # GNU General Public License for more details.
13
+
14
+ # You should have received a copy of the GNU General Public License
15
+ # along with this program. If not, see <http://www.gnu.org/licenses/>.
16
+
17
+ require "kalibro_gem/entities/model"
18
+
19
+ module KalibroGem
20
+ module Entities
21
+ class BaseTool < Model
22
+ attr_accessor :name, :description, :collector_class_name, :supported_metric
23
+
24
+ def supported_metric=(value)
25
+ @supported_metric = KalibroGem::Entities::Metric.to_objects_array value
26
+ end
27
+
28
+ def supported_metrics
29
+ @supported_metric
30
+ end
31
+
32
+ def metric(name)
33
+ supported_metrics.find {|metric| metric.name == name}
34
+ end
35
+
36
+ def self.find_by_name(base_tool_name)
37
+ begin
38
+ new request(:get_base_tool, {:base_tool_name => base_tool_name})[:base_tool]
39
+ rescue
40
+ raise KalibroGem::Errors::RecordNotFound
41
+ end
42
+ end
43
+
44
+ def self.all_names
45
+ request(:all_base_tool_names)[:base_tool_name].to_a
46
+ end
47
+
48
+ def self.all
49
+ base_tools = all_names
50
+ base_tools.map{ |name| find_by_name(name) }
51
+ end
52
+ end
53
+ end
54
+ end
@@ -0,0 +1,33 @@
1
+ # This file is part of KalibroGem
2
+ # Copyright (C) 2013 it's respectives authors (please see the AUTHORS file)
3
+ #
4
+ # This program is free software: you can redistribute it and/or modify
5
+ # it under the terms of the GNU General Public License as published by
6
+ # the Free Software Foundation, either version 3 of the License, or
7
+ # (at your option) any later version.
8
+ #
9
+ # This program is distributed in the hope that it will be useful,
10
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
11
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
+ # GNU General Public License for more details.
13
+
14
+ # You should have received a copy of the GNU General Public License
15
+ # along with this program. If not, see <http://www.gnu.org/licenses/>.
16
+
17
+ require "kalibro_gem/entities/model"
18
+
19
+ module KalibroGem
20
+ module Entities
21
+ class Configuration < Model
22
+ attr_accessor :id, :name, :description
23
+
24
+ def id=(value)
25
+ @id = value.to_i
26
+ end
27
+
28
+ def self.all
29
+ create_objects_array_from_hash request(:all_configurations)[:configuration]
30
+ end
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,39 @@
1
+ # This file is part of KalibroGem
2
+ # Copyright (C) 2013 it's respectives authors (please see the AUTHORS file)
3
+ #
4
+ # This program is free software: you can redistribute it and/or modify
5
+ # it under the terms of the GNU General Public License as published by
6
+ # the Free Software Foundation, either version 3 of the License, or
7
+ # (at your option) any later version.
8
+ #
9
+ # This program is distributed in the hope that it will be useful,
10
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
11
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
+ # GNU General Public License for more details.
13
+
14
+ # You should have received a copy of the GNU General Public License
15
+ # along with this program. If not, see <http://www.gnu.org/licenses/>.
16
+
17
+ require "kalibro_gem/entities/model"
18
+
19
+ module KalibroGem
20
+ module Entities
21
+ class DateMetricResult < Model
22
+
23
+ attr_accessor :date, :metric_result
24
+
25
+ def date=(value)
26
+ @date = value.is_a?(String) ? DateTime.parse(value) : value
27
+ end
28
+
29
+ def metric_result=(value)
30
+ @metric_result = KalibroGem::Entities::MetricResult.to_object value
31
+ end
32
+
33
+ def result
34
+ @metric_result.value
35
+ end
36
+
37
+ end
38
+ end
39
+ end
@@ -0,0 +1,39 @@
1
+ # This file is part of KalibroGem
2
+ # Copyright (C) 2013 it's respectives authors (please see the AUTHORS file)
3
+ #
4
+ # This program is free software: you can redistribute it and/or modify
5
+ # it under the terms of the GNU General Public License as published by
6
+ # the Free Software Foundation, either version 3 of the License, or
7
+ # (at your option) any later version.
8
+ #
9
+ # This program is distributed in the hope that it will be useful,
10
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
11
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
+ # GNU General Public License for more details.
13
+
14
+ # You should have received a copy of the GNU General Public License
15
+ # along with this program. If not, see <http://www.gnu.org/licenses/>.
16
+
17
+ require "kalibro_gem/entities/model"
18
+
19
+ module KalibroGem
20
+ module Entities
21
+ class DateModuleResult < Model
22
+
23
+ attr_accessor :date, :module_result
24
+
25
+ def date=(value)
26
+ @date = value.is_a?(String) ? DateTime.parse(value) : value
27
+ end
28
+
29
+ def module_result=(value)
30
+ @module_result = KalibroGem::Entities::ModuleResult.to_object value
31
+ end
32
+
33
+ def result
34
+ @module_result.grade
35
+ end
36
+
37
+ end
38
+ end
39
+ end
@@ -0,0 +1,21 @@
1
+ module KalibroGem
2
+ module Entities
3
+ class Metric < Model
4
+
5
+ attr_accessor :name, :compound, :scope, :description, :script, :language
6
+
7
+ def languages
8
+ @language
9
+ end
10
+
11
+ def languages=(languages)
12
+ @language = languages
13
+ end
14
+
15
+ def language=(value)
16
+ @language = self.class.to_objects_array value
17
+ end
18
+
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,70 @@
1
+ # This file is part of KalibroGem
2
+ # Copyright (C) 2013 it's respectives authors (please see the AUTHORS file)
3
+ #
4
+ # This program is free software: you can redistribute it and/or modify
5
+ # it under the terms of the GNU General Public License as published by
6
+ # the Free Software Foundation, either version 3 of the License, or
7
+ # (at your option) any later version.
8
+ #
9
+ # This program is distributed in the hope that it will be useful,
10
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
11
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
+ # GNU General Public License for more details.
13
+
14
+ # You should have received a copy of the GNU General Public License
15
+ # along with this program. If not, see <http://www.gnu.org/licenses/>.
16
+
17
+ require "kalibro_gem/entities/model"
18
+
19
+ module KalibroGem
20
+ module Entities
21
+ class MetricConfiguration < Model
22
+
23
+ attr_accessor :id, :code, :metric, :base_tool_name, :weight, :aggregation_form, :reading_group_id, :configuration_id
24
+
25
+ def id=(value)
26
+ @id = value.to_i
27
+ end
28
+
29
+ def reading_group_id=(value)
30
+ @reading_group_id = value.to_i
31
+ end
32
+
33
+ def metric=(value)
34
+ @metric = KalibroGem::Entities::Metric.to_object(value)
35
+ end
36
+
37
+ def weight=(value)
38
+ @weight = value.to_f
39
+ end
40
+
41
+ def update_attributes(attributes={})
42
+ attributes.each { |field, value| send("#{field}=", value) if self.class.is_valid?(field) }
43
+ save
44
+ end
45
+
46
+ def to_hash
47
+ super :except => [:configuration_id]
48
+ end
49
+
50
+ def self.find(id)
51
+ #TODO: on future versions of Kalibro this begin/rescue will be unnecessary
52
+ begin
53
+ new request(:get_metric_configuration, {:metric_configuration_id => id})[:metric_configuration]
54
+ rescue Savon::SOAPFault
55
+ raise KalibroGem::Errors::RecordNotFound
56
+ end
57
+ end
58
+
59
+ def self.metric_configurations_of(configuration_id)
60
+ create_objects_array_from_hash request(:metric_configurations_of, {:configuration_id => configuration_id})[:metric_configuration]
61
+ end
62
+
63
+ private
64
+
65
+ def save_params
66
+ {:metric_configuration => self.to_hash, :configuration_id => self.configuration_id}
67
+ end
68
+ end
69
+ end
70
+ end