kalibro_client 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (171) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +19 -0
  3. data/.rspec +2 -0
  4. data/.ruby-gemset +1 -0
  5. data/.ruby-version +1 -0
  6. data/.travis.yml +27 -0
  7. data/AUTHORS +4 -0
  8. data/COPYING +674 -0
  9. data/COPYING.LESSER +165 -0
  10. data/Gemfile +4 -0
  11. data/README.md +77 -0
  12. data/Rakefile +6 -0
  13. data/cucumber.yml +1 -0
  14. data/features/kalibro_configuration/all.feature +10 -0
  15. data/features/kalibro_configuration/creation.feature +9 -0
  16. data/features/kalibro_configuration/destroy.feature +10 -0
  17. data/features/kalibro_configuration/metric_configurations.feature +12 -0
  18. data/features/metric_collector_details/all_names.feature +8 -0
  19. data/features/metric_collector_details/find_by_name.feature +12 -0
  20. data/features/metric_configuration/creation.feature +11 -0
  21. data/features/metric_configuration/destroy.feature +12 -0
  22. data/features/metric_configuration/find.feature +18 -0
  23. data/features/metric_configuration/metric_configurations_of.feature +18 -0
  24. data/features/metric_result/descendant_values.feature +19 -0
  25. data/features/metric_result/history_of.feature +20 -0
  26. data/features/metric_result/metric_results_of.feature +20 -0
  27. data/features/module_result/children.feature +19 -0
  28. data/features/module_result/find.feature +22 -0
  29. data/features/module_result/history_of.feature +19 -0
  30. data/features/processing/first_processing_after.feature +18 -0
  31. data/features/processing/first_processing_of.feature +18 -0
  32. data/features/processing/has_processing.feature +18 -0
  33. data/features/processing/has_processing_after.feature +18 -0
  34. data/features/processing/has_processing_before.feature +18 -0
  35. data/features/processing/has_ready_processing.feature +18 -0
  36. data/features/processing/last_processing_before.feature +18 -0
  37. data/features/processing/last_processing_of.feature +18 -0
  38. data/features/processing/last_processing_state_of.feature +18 -0
  39. data/features/processing/last_ready_processing_of.feature +19 -0
  40. data/features/processing/processing_of.feature +32 -0
  41. data/features/processing/processing_with_date_of.feature +32 -0
  42. data/features/project/all.feature +10 -0
  43. data/features/project/creation.feature +9 -0
  44. data/features/project/destroy.feature +10 -0
  45. data/features/project/exists.feature +9 -0
  46. data/features/project/find.feature +10 -0
  47. data/features/range/destroy.feature +14 -0
  48. data/features/range/exists.feature +13 -0
  49. data/features/range/find.feature +14 -0
  50. data/features/range/ranges_of.feature +22 -0
  51. data/features/range/save.feature +14 -0
  52. data/features/reading/destroy.feature +13 -0
  53. data/features/reading/exists.feature +13 -0
  54. data/features/reading/find.feature +11 -0
  55. data/features/reading/readings_of.feature +11 -0
  56. data/features/reading_group/all.feature +10 -0
  57. data/features/reading_group/creation.feature +9 -0
  58. data/features/reading_group/destroy.feature +11 -0
  59. data/features/repository/all.feature +14 -0
  60. data/features/repository/cancel_processing.feature +14 -0
  61. data/features/repository/destroy.feature +14 -0
  62. data/features/repository/exists.feature +14 -0
  63. data/features/repository/find.feature +14 -0
  64. data/features/repository/of.feature +15 -0
  65. data/features/repository/process.feature +16 -0
  66. data/features/repository/types.feature +8 -0
  67. data/features/step_definitions/configuration_steps.rb +40 -0
  68. data/features/step_definitions/metric_collector_details_steps.rb +28 -0
  69. data/features/step_definitions/metric_configuration_steps.rb +61 -0
  70. data/features/step_definitions/metric_result_steps.rb +33 -0
  71. data/features/step_definitions/metric_steps.rb +3 -0
  72. data/features/step_definitions/module_result_steps.rb +46 -0
  73. data/features/step_definitions/processing_steps.rb +95 -0
  74. data/features/step_definitions/project_steps.rb +48 -0
  75. data/features/step_definitions/range_steps.rb +72 -0
  76. data/features/step_definitions/reading_group_steps.rb +36 -0
  77. data/features/step_definitions/reading_steps.rb +47 -0
  78. data/features/step_definitions/repository_steps.rb +71 -0
  79. data/features/support/env.rb +25 -0
  80. data/features/support/kalibro_cucumber_helpers.yml.sample +3 -0
  81. data/kalibro_client.gemspec +49 -0
  82. data/lib/kalibro_client.rb +62 -0
  83. data/lib/kalibro_client/entities.rb +40 -0
  84. data/lib/kalibro_client/entities/base.rb +196 -0
  85. data/lib/kalibro_client/entities/configurations/base.rb +13 -0
  86. data/lib/kalibro_client/entities/configurations/kalibro_configuration.rb +37 -0
  87. data/lib/kalibro_client/entities/configurations/kalibro_range.rb +77 -0
  88. data/lib/kalibro_client/entities/configurations/metric_configuration.rb +93 -0
  89. data/lib/kalibro_client/entities/configurations/range_snapshot.rb +37 -0
  90. data/lib/kalibro_client/entities/configurations/reading.rb +56 -0
  91. data/lib/kalibro_client/entities/configurations/reading_group.rb +34 -0
  92. data/lib/kalibro_client/entities/miscellaneous/base.rb +57 -0
  93. data/lib/kalibro_client/entities/miscellaneous/compound_metric.rb +21 -0
  94. data/lib/kalibro_client/entities/miscellaneous/date_metric_result.rb +14 -0
  95. data/lib/kalibro_client/entities/miscellaneous/date_module_result.rb +18 -0
  96. data/lib/kalibro_client/entities/miscellaneous/granularity.rb +54 -0
  97. data/lib/kalibro_client/entities/miscellaneous/metric.rb +19 -0
  98. data/lib/kalibro_client/entities/miscellaneous/native_metric.rb +24 -0
  99. data/lib/kalibro_client/entities/processor/base.rb +16 -0
  100. data/lib/kalibro_client/entities/processor/kalibro_module.rb +27 -0
  101. data/lib/kalibro_client/entities/processor/metric_collector_details.rb +53 -0
  102. data/lib/kalibro_client/entities/processor/metric_result.rb +79 -0
  103. data/lib/kalibro_client/entities/processor/module_result.rb +82 -0
  104. data/lib/kalibro_client/entities/processor/process_time.rb +31 -0
  105. data/lib/kalibro_client/entities/processor/processing.rb +109 -0
  106. data/lib/kalibro_client/entities/processor/project.rb +34 -0
  107. data/lib/kalibro_client/entities/processor/repository.rb +75 -0
  108. data/lib/kalibro_client/errors.rb +18 -0
  109. data/lib/kalibro_client/errors/record_not_found.rb +22 -0
  110. data/lib/kalibro_client/errors/standard.rb +24 -0
  111. data/lib/kalibro_client/helpers/aggregation_options.rb +25 -0
  112. data/lib/kalibro_client/helpers/hash_converters.rb +48 -0
  113. data/lib/kalibro_client/helpers/request_methods.rb +55 -0
  114. data/lib/kalibro_client/helpers/xml_converters.rb +20 -0
  115. data/lib/kalibro_client/kalibro_cucumber_helpers.rb +60 -0
  116. data/lib/kalibro_client/kalibro_cucumber_helpers/configuration.rb +30 -0
  117. data/lib/kalibro_client/kalibro_cucumber_helpers/hooks.rb +25 -0
  118. data/lib/kalibro_client/version.rb +19 -0
  119. data/lib/rake/test_task.rb +57 -0
  120. data/spec/entities/base_spec.rb +313 -0
  121. data/spec/entities/configurations/base_spec.rb +26 -0
  122. data/spec/entities/configurations/kalibro_configuration_spec.rb +91 -0
  123. data/spec/entities/configurations/kalibro_range_spec.rb +174 -0
  124. data/spec/entities/configurations/metric_configuration_spec.rb +230 -0
  125. data/spec/entities/configurations/range_snapshot_spec.rb +50 -0
  126. data/spec/entities/configurations/reading_group_spec.rb +60 -0
  127. data/spec/entities/configurations/reading_spec.rb +87 -0
  128. data/spec/entities/miscellaneous/base_spec.rb +49 -0
  129. data/spec/entities/miscellaneous/compound_metric_spec.rb +36 -0
  130. data/spec/entities/miscellaneous/date_metric_result_spec.rb +4 -0
  131. data/spec/entities/miscellaneous/date_module_result_spec.rb +0 -0
  132. data/spec/entities/miscellaneous/granularity_spec.rb +96 -0
  133. data/spec/entities/miscellaneous/metric_spec.rb +15 -0
  134. data/spec/entities/miscellaneous/native_metric_spec.rb +37 -0
  135. data/spec/entities/processor/base_spec.rb +26 -0
  136. data/spec/entities/processor/metric_collector_details_spec.rb +146 -0
  137. data/spec/entities/processor/metric_result_spec.rb +209 -0
  138. data/spec/entities/processor/module_result_spec.rb +178 -0
  139. data/spec/entities/processor/process_time_spec.rb +33 -0
  140. data/spec/entities/processor/processing_spec.rb +333 -0
  141. data/spec/entities/processor/project_spec.rb +68 -0
  142. data/spec/entities/processor/repository_spec.rb +140 -0
  143. data/spec/factories/date_metric_results.rb +30 -0
  144. data/spec/factories/date_module_results.rb +24 -0
  145. data/spec/factories/granularities.rb +23 -0
  146. data/spec/factories/kalibro_configurations.rb +34 -0
  147. data/spec/factories/kalibro_module.rb +28 -0
  148. data/spec/factories/kalibro_ranges.rb +40 -0
  149. data/spec/factories/metric_collector_details.rb +30 -0
  150. data/spec/factories/metric_configurations.rb +31 -0
  151. data/spec/factories/metric_results.rb +24 -0
  152. data/spec/factories/metrics.rb +48 -0
  153. data/spec/factories/models.rb +23 -0
  154. data/spec/factories/module_results.rb +43 -0
  155. data/spec/factories/process_times.rb +27 -0
  156. data/spec/factories/processings.rb +24 -0
  157. data/spec/factories/projects.rb +35 -0
  158. data/spec/factories/ranges_snapshot.rb +26 -0
  159. data/spec/factories/reading_groups.rb +28 -0
  160. data/spec/factories/readings.rb +30 -0
  161. data/spec/factories/repositories.rb +39 -0
  162. data/spec/helpers/aggregation_options_spec.rb +31 -0
  163. data/spec/helpers/hash_converters_spec.rb +111 -0
  164. data/spec/helpers/xml_converters_spec.rb +64 -0
  165. data/spec/kalibro_entities_spec.rb +112 -0
  166. data/spec/savon/fixtures/config.yml +2 -0
  167. data/spec/savon/fixtures/invalid_config.yml +2 -0
  168. data/spec/savon/fixtures/project/does_not_exists.xml +1 -0
  169. data/spec/savon/savon_test_helper.rb +14 -0
  170. data/spec/spec_helper.rb +111 -0
  171. metadata +479 -0
@@ -0,0 +1,37 @@
1
+ # This file is part of KalibroClient
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
+ module KalibroClient
18
+ module Entities
19
+ module Configurations
20
+ class RangeSnapshot < KalibroClient::Entities::Configurations::Base
21
+ attr_accessor :beginning, :end, :label, :grade, :color, :comments
22
+
23
+ def beginning=(value)
24
+ @beginning = ((value == "-INF") ? -1.0/0 : value.to_f)
25
+ end
26
+
27
+ def end=(value)
28
+ @end = ((value == "INF") ? 1.0/0 : value.to_f)
29
+ end
30
+
31
+ def grade=(value)
32
+ @grade = value.to_f
33
+ end
34
+ end
35
+ end
36
+ end
37
+ end
@@ -0,0 +1,56 @@
1
+ # This file is part of KalibroClient
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
+ module KalibroClient
18
+ module Entities
19
+ module Configurations
20
+ class Reading < KalibroClient::Entities::Configurations::Base
21
+
22
+ attr_accessor :id, :label, :grade, :color, :reading_group_id
23
+
24
+ def id=(value)
25
+ @id = value.to_i
26
+ end
27
+
28
+ def grade=(value)
29
+ @grade = value.to_f
30
+ end
31
+
32
+ def reading_group_id=(value)
33
+ @reading_group_id = value.to_i
34
+ end
35
+
36
+ def self.readings_of(reading_group_id)
37
+ create_objects_array_from_hash(request('', {}, :get, "reading_groups/#{reading_group_id}"))
38
+ end
39
+
40
+ private
41
+
42
+ def save_params
43
+ {reading: self.to_hash, reading_group_id: reading_group_id}
44
+ end
45
+
46
+ def save_prefix
47
+ "reading_groups/#{reading_group_id}"
48
+ end
49
+
50
+ def destroy_prefix
51
+ "reading_groups/#{reading_group_id}"
52
+ end
53
+ end
54
+ end
55
+ end
56
+ end
@@ -0,0 +1,34 @@
1
+ # This file is part of KalibroClient
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
+ module KalibroClient
18
+ module Entities
19
+ module Configurations
20
+ class ReadingGroup < KalibroClient::Entities::Configurations::Base
21
+
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('', {}, :get))
30
+ end
31
+ end
32
+ end
33
+ end
34
+ end
@@ -0,0 +1,57 @@
1
+ module KalibroClient
2
+ module Entities
3
+ module Miscellaneous
4
+ class Base
5
+ def initialize(attributes={})
6
+ attributes.each { |field, value| send("#{field}=", value) if self.class.is_valid?(field) }
7
+ end
8
+
9
+ include HashConverters
10
+ def to_hash(options={})
11
+ hash = Hash.new
12
+ excepts = options[:except].nil? ? [] : options[:except]
13
+
14
+ fields.each do |field|
15
+ hash = field_to_hash(field).merge(hash) if !excepts.include?(field)
16
+ end
17
+
18
+ hash
19
+ end
20
+
21
+ def self.to_object value
22
+ value.kind_of?(Hash) ? new(value) : value
23
+ end
24
+
25
+ def ==(another)
26
+ unless self.class == another.class
27
+ return false
28
+ end
29
+
30
+ self.variable_names.each do |name|
31
+ next if name == "created_at" or name == "updated_at"
32
+ unless self.send("#{name}") == another.send("#{name}") then
33
+ return false
34
+ end
35
+ end
36
+
37
+ return true
38
+ end
39
+
40
+ protected
41
+
42
+ def fields
43
+ instance_variable_names.each.collect { |variable| variable.to_s.sub(/@/, '') }
44
+ end
45
+
46
+ def instance_variable_names
47
+ instance_variables.map { |var| var.to_s }
48
+ end
49
+
50
+ def variable_names
51
+ instance_variable_names.each.collect { |variable| variable.to_s.sub(/@/, '') }
52
+ end
53
+
54
+ end
55
+ end
56
+ end
57
+ end
@@ -0,0 +1,21 @@
1
+ module KalibroClient
2
+ module Entities
3
+ module Miscellaneous
4
+ class CompoundMetric < Metric
5
+ attr_accessor :script
6
+ def initialize(name, code, scope, script)
7
+ super('CompoundMetricSnapshot', name, code, scope)
8
+ @script = script
9
+ end
10
+
11
+ def self.to_object(value)
12
+ if value.is_a?(Hash)
13
+ new(value['name'], value['code'], value['scope'], value['script'])
14
+ else
15
+ value
16
+ end
17
+ end
18
+ end
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,14 @@
1
+ module KalibroClient
2
+ module Entities
3
+ module Miscellaneous
4
+ class DateMetricResult < KalibroClient::Entities::Miscellaneous::Base
5
+ attr_reader :date, :metric_result
6
+
7
+ def initialize(attributes={})
8
+ @date = attributes["date"]
9
+ @metric_result = KalibroClient::Entities::Processor::MetricResult.new attributes["metric_result"]
10
+ end
11
+ end
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,18 @@
1
+ module KalibroClient
2
+ module Entities
3
+ module Miscellaneous
4
+ class DateModuleResult
5
+ attr_accessor :date, :module_result
6
+
7
+ def initialize(attributes={})
8
+ @date = attributes[:date]
9
+ @module_result = attributes[:module_result]
10
+ end
11
+
12
+ def result
13
+ @module_result.grade
14
+ end
15
+ end
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,54 @@
1
+ module KalibroClient
2
+ module Entities
3
+ module Miscellaneous
4
+ class Granularity
5
+ GRANULARITIES = [:METHOD, :CLASS, :PACKAGE, :SOFTWARE]
6
+
7
+ METHOD = GRANULARITIES[0]
8
+ CLASS = GRANULARITIES[1]
9
+ PACKAGE = GRANULARITIES[2]
10
+ SOFTWARE = GRANULARITIES[3]
11
+
12
+ attr_reader :type
13
+
14
+ def initialize(type)
15
+ if GRANULARITIES.include?(type)
16
+ @type = type
17
+ else
18
+ raise TypeError.new("Not supported granularity type #{type}")
19
+ end
20
+ end
21
+
22
+ def parent
23
+ return self if self.type == SOFTWARE
24
+ return Granularity.new(GRANULARITIES[GRANULARITIES.find_index(self.type) + 1])
25
+ end
26
+
27
+ def to_s
28
+ self.type.to_s
29
+ end
30
+
31
+ def <(other_granularity)
32
+ GRANULARITIES.find_index(self.type) < GRANULARITIES.find_index(other_granularity.type)
33
+ end
34
+
35
+ def ==(other_granularity)
36
+ self.type == other_granularity.type
37
+ end
38
+
39
+ def <=(other_granularity)
40
+ (self < other_granularity) || (self == other_granularity)
41
+ end
42
+
43
+ def >=(other_granularity)
44
+ (self > other_granularity) || (self == other_granularity)
45
+ end
46
+
47
+ def >(other_granularity)
48
+ !(self <= other_granularity)
49
+ end
50
+ end
51
+
52
+ end
53
+ end
54
+ end
@@ -0,0 +1,19 @@
1
+ require 'kalibro_client/helpers/hash_converters'
2
+
3
+ module KalibroClient
4
+ module Entities
5
+ module Miscellaneous
6
+ class Metric < KalibroClient::Entities::Miscellaneous::Base
7
+ attr_accessor :type, :name, :code, :scope, :description
8
+
9
+ def initialize(type, name, code, scope)
10
+ @type = type
11
+ @name = name
12
+ @code = code
13
+ @scope = scope
14
+ @description = ""
15
+ end
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,24 @@
1
+ module KalibroClient
2
+ module Entities
3
+ module Miscellaneous
4
+ class NativeMetric < Metric
5
+ attr_accessor :languages, :metric_collector_name
6
+
7
+ # TODO: Deprecate this constructor
8
+ def initialize(name, code, scope, languages, metric_collector_name)
9
+ super('NativeMetricSnapshot', name, code, scope)
10
+ @languages = languages
11
+ @metric_collector_name = metric_collector_name
12
+ end
13
+
14
+ def self.to_object(value)
15
+ if value.is_a?(Hash)
16
+ new(value['name'], value['code'], value['scope'], value['languages'], value['metric_collector_name'])
17
+ else
18
+ value
19
+ end
20
+ end
21
+ end
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,16 @@
1
+ require 'json'
2
+
3
+ module KalibroClient
4
+ module Entities
5
+ module Processor
6
+ class Base < KalibroClient::Entities::Base
7
+
8
+ attr_accessor :created_at, :updated_at
9
+ def self.address
10
+ :processor_address
11
+ end
12
+ end
13
+ end
14
+ end
15
+ end
16
+
@@ -0,0 +1,27 @@
1
+ # This file is part of KalibroClient
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
+ module KalibroClient
18
+ module Entities
19
+ module Processor
20
+ class KalibroModule < KalibroClient::Entities::Processor::Base
21
+
22
+ attr_accessor :name, :granlrty, :id, :long_name, :module_result_id
23
+
24
+ end
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,53 @@
1
+ # This file is part of KalibroClient
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
+ module KalibroClient
18
+ module Entities
19
+ module Processor
20
+ class MetricCollectorDetails < KalibroClient::Entities::Processor::Base
21
+ attr_accessor :name, :description, :supported_metrics, :wanted_metrics, :processing
22
+
23
+ def supported_metrics=(value)
24
+ @supported_metrics = {}
25
+ value.each do |code, metric|
26
+ @supported_metrics[code] = KalibroClient::Entities::Miscellaneous::Metric.new(metric[:type], metric[:name], metric[:code], metric[:scope])
27
+ end
28
+ end
29
+
30
+ def metric(name)
31
+ metric = self.supported_metrics.find {|code, metric| metric.name == name}
32
+ metric.nil? ? nil : metric.last
33
+ end
34
+
35
+ def self.find_by_name(metric_collector_name)
36
+ begin
37
+ new request(:find, {name: metric_collector_name})["metric_collector_details"]
38
+ rescue
39
+ raise KalibroClient::Errors::RecordNotFound
40
+ end
41
+ end
42
+
43
+ def self.all_names
44
+ request(:names, {}, :get)['metric_collector_names'].to_a
45
+ end
46
+
47
+ def self.all
48
+ create_objects_array_from_hash(request('', {}, :get))
49
+ end
50
+ end
51
+ end
52
+ end
53
+ end