kalibro_client 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
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,79 @@
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 MetricResult < KalibroClient::Entities::Processor::Base
21
+
22
+ attr_accessor :id, :value, :aggregated_value, :module_result_id, :metric_configuration_id
23
+
24
+ def initialize(attributes={})
25
+ value = attributes["value"]
26
+ @value = (value == "NaN") ? attributes["aggregated_value"].to_f : value.to_f
27
+ attributes.each do |field, value|
28
+ if field!= "value" and field!= "aggregated_value" and self.class.is_valid?(field)
29
+ send("#{field}=", value)
30
+ end
31
+ end
32
+ @kalibro_errors = []
33
+ end
34
+
35
+ def id=(value)
36
+ @id = value.to_i
37
+ end
38
+
39
+ def metric_configuration=(value)
40
+ @metric_configuration = KalibroClient::Entities::Configurations::MetricConfiguration.to_object value
41
+ @metric_configuration_id = @metric_configuration.id
42
+ end
43
+
44
+ def metric_configuration
45
+ unless @metric_configuration.nil?
46
+ return @metric_configuration
47
+ end
48
+ @metric_configuration = KalibroClient::Entities::Configurations::MetricConfiguration.find @metric_configuration_id
49
+ return @metric_configuration
50
+ end
51
+
52
+ def value=(value)
53
+ @value = value.to_f
54
+ end
55
+
56
+ def aggregated_value=(value)
57
+ @aggregated_value = value.to_f
58
+ end
59
+
60
+ def descendant_values
61
+ descendant_values = self.class.request(':id/descendant_values', {id: id}, :get)['descendant_values']
62
+ descendant_values.map {|descendant_value| descendant_value.to_f}
63
+ end
64
+
65
+ def self.metric_results_of(module_result_id)
66
+ create_objects_array_from_hash ModuleResult.request(":id/metric_results", {id: module_result_id}, :get)
67
+ end
68
+
69
+ def self.history_of(metric_name, kalibro_module_id, repository_id)
70
+ response = Repository.request(':id/metric_result_history_of', {metric_name: metric_name,
71
+ kalibro_module_id: kalibro_module_id,
72
+ id: repository_id})['metric_result_history_of']
73
+ response.map { |date_metric_result|
74
+ KalibroClient::Entities::Miscellaneous::DateMetricResult.new date_metric_result }
75
+ end
76
+ end
77
+ end
78
+ end
79
+ end
@@ -0,0 +1,82 @@
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 ModuleResult < KalibroClient::Entities::Processor::Base
21
+
22
+ attr_accessor :id, :kalibro_module, :grade, :parent_id, :height, :processing_id
23
+
24
+ def children
25
+ response = self.class.request(':id/children', {id: id}, :get)
26
+ self.class.create_objects_array_from_hash(response)
27
+ end
28
+
29
+ def parents
30
+ if parent_id == 0
31
+ []
32
+ else
33
+ parent = self.class.find(parent_id)
34
+ parent.parents << parent
35
+ end
36
+ end
37
+
38
+ def id=(value)
39
+ @id = value.to_i
40
+ end
41
+
42
+ def kalibro_module
43
+ @kalibro_module ||= KalibroClient::Entities::Processor::KalibroModule.to_object self.class.request(":id/kalibro_module", {id: id}, :get)["kalibro_module"]
44
+ end
45
+
46
+ def height=(value)
47
+ @height = value.to_i
48
+ end
49
+
50
+ def processing_id=(value)
51
+ @processing_id = value.to_i
52
+ end
53
+
54
+ def grade=(value)
55
+ @grade = value.to_f
56
+ end
57
+
58
+ def parent_id=(value)
59
+ @parent_id = value.to_i
60
+ end
61
+
62
+ def folder?
63
+ self.children.count > 0
64
+ end
65
+
66
+ def file?
67
+ !self.folder?
68
+ end
69
+
70
+ def self.history_of(module_result_id)
71
+ response = self.create_array_from_hash(self.request('history_of', {id: module_result_id})['date_module_results'])
72
+ response.map do |date_module_result_pair|
73
+ date_module_result = KalibroClient::Entities::Miscellaneous::DateModuleResult.new
74
+ date_module_result.date = date_module_result_pair.first
75
+ date_module_result.module_result = KalibroClient::Entities::Processor::ModuleResult.new date_module_result_pair.last
76
+ date_module_result
77
+ end
78
+ end
79
+ end
80
+ end
81
+ end
82
+ end
@@ -0,0 +1,31 @@
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 ProcessTime < KalibroClient::Entities::Processor::Base
21
+
22
+ attr_accessor :state, :time, :processing_id, :id
23
+
24
+ def time=(time)
25
+ @time = time.to_i
26
+ end
27
+
28
+ end
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,109 @@
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 Processing < KalibroClient::Entities::Processor::Base
21
+
22
+ attr_accessor :id, :date, :state, :error, :root_module_result_id, :error_message, :repository_id
23
+ attr_reader :process_times
24
+
25
+ def id=(value)
26
+ @id = value.to_i
27
+ end
28
+
29
+ def repository_id=(value)
30
+ @repository_id = value.to_i
31
+ end
32
+
33
+ def date=(value)
34
+ @date = value.is_a?(String) ? DateTime.parse(value) : value
35
+ end
36
+
37
+ def process_times
38
+ unless @process_times.nil?
39
+ return @process_times
40
+ end
41
+ @process_times = ProcessTime.create_objects_array_from_hash(self.class.request(":id/process_times", {id: id}, :get))
42
+ end
43
+
44
+ def root_module_result_id=(value)
45
+ @root_module_result_id = value.to_i
46
+ end
47
+
48
+ def self.processing_of(repository_id)
49
+ if has_ready_processing(repository_id)
50
+ last_ready_processing_of(repository_id)
51
+ else
52
+ last_processing_of(repository_id)
53
+ end
54
+ end
55
+
56
+ def self.processing_with_date_of(repository_id, date)
57
+ date = date.is_a?(String) ? DateTime.parse(date) : date
58
+ if has_processing_after(repository_id, date)
59
+ first_processing_after(repository_id, date)
60
+ elsif has_processing_before(repository_id, date)
61
+ last_processing_before(repository_id, date)
62
+ else
63
+ nil
64
+ end
65
+ end
66
+
67
+ def self.has_processing(repository_id)
68
+ Repository.request("#{repository_id}/has_processing")['has_processing']
69
+ end
70
+
71
+ def self.has_ready_processing(repository_id)
72
+ Repository.request("#{repository_id}/has_ready_processing", {}, :get)['has_ready_processing']
73
+ end
74
+
75
+ def self.has_processing_after(repository_id, date)
76
+ Repository.request("#{repository_id}/has_processing/after", {:date => date})['has_processing_in_time']
77
+ end
78
+
79
+ def self.has_processing_before(repository_id, date)
80
+ Repository.request("#{repository_id}/has_processing/before", {:date => date})['has_processing_in_time']
81
+ end
82
+
83
+ def self.last_processing_state_of(repository_id)
84
+ Repository.request("#{repository_id}/last_processing_state", {}, :get)['processing_state']
85
+ end
86
+
87
+ def self.last_ready_processing_of(repository_id)
88
+ new(Repository.request(':id/last_ready_processing', {id: repository_id}, :get)['last_ready_processing'])
89
+ end
90
+
91
+ def self.first_processing_of(repository_id)
92
+ new(Repository.request("#{repository_id}/first_processing")['processing'])
93
+ end
94
+
95
+ def self.last_processing_of(repository_id)
96
+ new(Repository.request("#{repository_id}/last_processing")['processing'])
97
+ end
98
+
99
+ def self.first_processing_after(repository_id, date)
100
+ new(Repository.request("#{repository_id}/first_processing/after", {:date => date})["processing"])
101
+ end
102
+
103
+ def self.last_processing_before(repository_id, date)
104
+ new(Repository.request("#{repository_id}/last_processing/before", {:date => date})['processing'])
105
+ end
106
+ end
107
+ end
108
+ end
109
+ 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 Processor
20
+ class Project < KalibroClient::Entities::Processor::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,75 @@
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 Repository < KalibroClient::Entities::Processor::Base
21
+
22
+ attr_accessor :id, :name, :description, :license, :period, :scm_type, :address, :configuration_id, :project_id, :send_email, :code_directory
23
+
24
+ def self.repository_types
25
+ request('types', {}, :get)['types'].to_a
26
+ end
27
+
28
+ def self.repositories_of(project_id)
29
+ create_objects_array_from_hash(request('', {}, :get, "projects/#{project_id}"))
30
+ end
31
+
32
+ def id=(value)
33
+ @id = value.to_i
34
+ end
35
+
36
+ def period=(value)
37
+ @period = value.to_i
38
+ end
39
+
40
+ def configuration_id=(value)
41
+ @configuration_id = value.to_i
42
+ end
43
+
44
+ def project_id=(value)
45
+ @project_id = value.to_i
46
+ end
47
+
48
+ def process
49
+ self.class.request("#{self.id}/process", {}, :get)
50
+ end
51
+
52
+ def cancel_processing_of_repository
53
+ self.class.request('cancel_process', {id: self.id})
54
+ end
55
+
56
+ def self.all
57
+ projects = Project.all
58
+ repositories = []
59
+
60
+ projects.each do |project|
61
+ repositories.concat(repositories_of(project.id))
62
+ end
63
+
64
+ return repositories
65
+ end
66
+
67
+ private
68
+
69
+ def save_params
70
+ {repository: self.to_hash, project_id: project_id}
71
+ end
72
+ end
73
+ end
74
+ end
75
+ end
@@ -0,0 +1,18 @@
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
+ require 'kalibro_client/errors/standard'
18
+ require 'kalibro_client/errors/record_not_found'
@@ -0,0 +1,22 @@
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 Errors
19
+ class RecordNotFound < Standard
20
+ end
21
+ end
22
+ end