Commit 24336d9e2ece055219764bc03e64cba753320dcd
Committed by
João M. M. da Silva
1 parent
109621c4
Exists in
master
and in
29 other branches
Started refactoring models
Showing
2 changed files
with
25 additions
and
11 deletions
Show diff stats
plugins/mezuro/lib/kalibro/base_tool.rb
1 | class Kalibro::BaseTool < Kalibro::Model | 1 | class Kalibro::BaseTool < Kalibro::Model |
2 | 2 | ||
3 | - attr_accessor :name, :description, :supported_metric | 3 | + attr_accessor :name, :description, :collector_class_name, :supported_metric |
4 | 4 | ||
5 | def self.all_names | 5 | def self.all_names |
6 | - request("BaseTool", :get_base_tool_names)[:base_tool_name].to_a | 6 | + request("BaseTool", :all_base_tool_names)[:base_tool_name].to_a |
7 | end | 7 | end |
8 | 8 | ||
9 | def self.find_by_name(base_tool_name) | 9 | def self.find_by_name(base_tool_name) |
plugins/mezuro/lib/kalibro/configuration.rb
1 | class Kalibro::Configuration < Kalibro::Model | 1 | class Kalibro::Configuration < Kalibro::Model |
2 | 2 | ||
3 | - attr_accessor :name, :description, :metric_configuration | ||
4 | - | 3 | + attr_accessor :name, :description, :id |
4 | +=begin | ||
5 | def metric_configuration=(value) | 5 | def metric_configuration=(value) |
6 | @metric_configuration = Kalibro::MetricConfiguration.to_objects_array value | 6 | @metric_configuration = Kalibro::MetricConfiguration.to_objects_array value |
7 | end | 7 | end |
@@ -13,21 +13,35 @@ class Kalibro::Configuration < Kalibro::Model | @@ -13,21 +13,35 @@ class Kalibro::Configuration < Kalibro::Model | ||
13 | def metric_configurations=(metric_configurations) | 13 | def metric_configurations=(metric_configurations) |
14 | @metric_configuration = metric_configurations | 14 | @metric_configuration = metric_configurations |
15 | end | 15 | end |
16 | +=end | ||
17 | + | ||
18 | + def self.exists?(id) | ||
19 | + request("Configuration", :configuration_exists, {:configuration_id => id})[:exists] | ||
20 | + end | ||
16 | 21 | ||
17 | - def self.find_by_name(configuration_name) | ||
18 | - new request("Configuration", :get_configuration, {:configuration_name => configuration_name})[:configuration] | 22 | + def self.find(id) |
23 | + if(exists?(id)) | ||
24 | + new request("Configuration", :get_configuration, {:configuration_name => configuration_name})[:configuration] | ||
25 | + else | ||
26 | + nil | ||
27 | + end | ||
19 | end | 28 | end |
20 | 29 | ||
21 | - def self.all_names | ||
22 | - request("Configuration", :get_configuration_names)[:configuration_name] | 30 | + def self.configuration_of(repository_id) |
31 | + new request("Configuration", :configuration_of, {:repository_id => repository_id})[:configuration] | ||
23 | end | 32 | end |
24 | 33 | ||
34 | + def self.all | ||
35 | + request("Configuration", :all_configuration)[:configuration] | ||
36 | + end | ||
37 | + | ||
38 | + | ||
25 | def update_attributes(attributes={}) | 39 | def update_attributes(attributes={}) |
26 | attributes.each { |field, value| send("#{field}=", value) if self.class.is_valid?(field) } | 40 | attributes.each { |field, value| send("#{field}=", value) if self.class.is_valid?(field) } |
27 | save | 41 | save |
28 | end | 42 | end |
29 | 43 | ||
30 | - def metric_configurations_hash | ||
31 | - self.to_hash[:metric_configuration] | ||
32 | - end | 44 | +# def metric_configurations_hash |
45 | +# self.to_hash[:metric_configuration] | ||
46 | +# end | ||
33 | end | 47 | end |