kalibro_gatekeeper_client 0.0.1.rc1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (165) 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 +29 -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/all.feature +14 -0
  42. data/features/range/exists.feature +13 -0
  43. data/features/range/find.feature +14 -0
  44. data/features/range/ranges_of.feature +22 -0
  45. data/features/range/save.feature +14 -0
  46. data/features/reading/all.feature +13 -0
  47. data/features/reading/exists.feature +13 -0
  48. data/features/reading/find.feature +11 -0
  49. data/features/reading/readings_of.feature +11 -0
  50. data/features/reading_group/all.feature +10 -0
  51. data/features/repository/all.feature +14 -0
  52. data/features/repository/cancel_processing.feature +14 -0
  53. data/features/repository/exists.feature +14 -0
  54. data/features/repository/find.feature +14 -0
  55. data/features/repository/of.feature +15 -0
  56. data/features/repository/process.feature +16 -0
  57. data/features/repository/types.feature +9 -0
  58. data/features/step_definitions/base_tool_steps.rb +28 -0
  59. data/features/step_definitions/configuration_steps.rb +11 -0
  60. data/features/step_definitions/metric_configuration_steps.rb +52 -0
  61. data/features/step_definitions/metric_result_steps.rb +29 -0
  62. data/features/step_definitions/metric_steps.rb +3 -0
  63. data/features/step_definitions/module_result_steps.rb +30 -0
  64. data/features/step_definitions/processing_steps.rb +91 -0
  65. data/features/step_definitions/project_steps.rb +48 -0
  66. data/features/step_definitions/range_steps.rb +68 -0
  67. data/features/step_definitions/reading_group_steps.rb +19 -0
  68. data/features/step_definitions/reading_steps.rb +39 -0
  69. data/features/step_definitions/repository_steps.rb +61 -0
  70. data/features/support/env.rb +25 -0
  71. data/features/support/kalibro_cucumber_helpers.yml.sample +10 -0
  72. data/kalibro_gatekeeper_client.gemspec +49 -0
  73. data/lib/kalibro_gatekeeper_client/entities/base_tool.rb +55 -0
  74. data/lib/kalibro_gatekeeper_client/entities/configuration.rb +34 -0
  75. data/lib/kalibro_gatekeeper_client/entities/date_metric_result.rb +39 -0
  76. data/lib/kalibro_gatekeeper_client/entities/date_module_result.rb +39 -0
  77. data/lib/kalibro_gatekeeper_client/entities/metric.rb +21 -0
  78. data/lib/kalibro_gatekeeper_client/entities/metric_configuration.rb +76 -0
  79. data/lib/kalibro_gatekeeper_client/entities/metric_configuration_snapshot.rb +57 -0
  80. data/lib/kalibro_gatekeeper_client/entities/metric_result.rb +72 -0
  81. data/lib/kalibro_gatekeeper_client/entities/model.rb +174 -0
  82. data/lib/kalibro_gatekeeper_client/entities/module.rb +27 -0
  83. data/lib/kalibro_gatekeeper_client/entities/module_result.rb +75 -0
  84. data/lib/kalibro_gatekeeper_client/entities/process_time.rb +31 -0
  85. data/lib/kalibro_gatekeeper_client/entities/processing.rb +113 -0
  86. data/lib/kalibro_gatekeeper_client/entities/project.rb +35 -0
  87. data/lib/kalibro_gatekeeper_client/entities/range.rb +100 -0
  88. data/lib/kalibro_gatekeeper_client/entities/range_snapshot.rb +37 -0
  89. data/lib/kalibro_gatekeeper_client/entities/reading.rb +67 -0
  90. data/lib/kalibro_gatekeeper_client/entities/reading_group.rb +44 -0
  91. data/lib/kalibro_gatekeeper_client/entities/repository.rb +89 -0
  92. data/lib/kalibro_gatekeeper_client/entities/repository_observer.rb +50 -0
  93. data/lib/kalibro_gatekeeper_client/entities/stack_trace_element.rb +31 -0
  94. data/lib/kalibro_gatekeeper_client/entities/throwable.rb +42 -0
  95. data/lib/kalibro_gatekeeper_client/entities.rb +37 -0
  96. data/lib/kalibro_gatekeeper_client/errors/record_not_found.rb +22 -0
  97. data/lib/kalibro_gatekeeper_client/errors/standard.rb +24 -0
  98. data/lib/kalibro_gatekeeper_client/errors.rb +18 -0
  99. data/lib/kalibro_gatekeeper_client/helpers/aggregation_options.rb +25 -0
  100. data/lib/kalibro_gatekeeper_client/helpers/hash_converters.rb +48 -0
  101. data/lib/kalibro_gatekeeper_client/helpers/request_methods.rb +47 -0
  102. data/lib/kalibro_gatekeeper_client/helpers/xml_converters.rb +20 -0
  103. data/lib/kalibro_gatekeeper_client/kalibro_cucumber_helpers/configuration.rb +39 -0
  104. data/lib/kalibro_gatekeeper_client/kalibro_cucumber_helpers/hooks.rb +56 -0
  105. data/lib/kalibro_gatekeeper_client/kalibro_cucumber_helpers/scripts/delete_all_kalibro_entries.sh +23 -0
  106. data/lib/kalibro_gatekeeper_client/kalibro_cucumber_helpers/scripts/prepare_kalibro_query_file.sh +38 -0
  107. data/lib/kalibro_gatekeeper_client/kalibro_cucumber_helpers/scripts/put_kalibro_on_test_mode.sh +39 -0
  108. data/lib/kalibro_gatekeeper_client/kalibro_cucumber_helpers/scripts/return_kalibro_from_test_mode.sh +26 -0
  109. data/lib/kalibro_gatekeeper_client/kalibro_cucumber_helpers.rb +40 -0
  110. data/lib/kalibro_gatekeeper_client/version.rb +19 -0
  111. data/lib/kalibro_gatekeeper_client.rb +61 -0
  112. data/lib/rake/test_task.rb +57 -0
  113. data/spec/entities/base_tool_spec.rb +168 -0
  114. data/spec/entities/configuration_spec.rb +61 -0
  115. data/spec/entities/date_metric_result_spec.rb +62 -0
  116. data/spec/entities/date_module_result_spec.rb +61 -0
  117. data/spec/entities/metric_configuration_snapshot_spec.rb +107 -0
  118. data/spec/entities/metric_configuration_spec.rb +173 -0
  119. data/spec/entities/metric_result_spec.rb +188 -0
  120. data/spec/entities/metric_spec.rb +47 -0
  121. data/spec/entities/model_spec.rb +322 -0
  122. data/spec/entities/module_result_spec.rb +163 -0
  123. data/spec/entities/process_time_spec.rb +33 -0
  124. data/spec/entities/processing_spec.rb +334 -0
  125. data/spec/entities/project_spec.rb +68 -0
  126. data/spec/entities/range_snapshot_spec.rb +50 -0
  127. data/spec/entities/range_spec.rb +225 -0
  128. data/spec/entities/reading_group_spec.rb +90 -0
  129. data/spec/entities/reading_spec.rb +148 -0
  130. data/spec/entities/repository_observer_spec.rb +123 -0
  131. data/spec/entities/repository_spec.rb +191 -0
  132. data/spec/entities/stack_trace_element_spec.rb +26 -0
  133. data/spec/entities/throwable_spec.rb +51 -0
  134. data/spec/factories/base_tools.rb +31 -0
  135. data/spec/factories/configurations.rb +29 -0
  136. data/spec/factories/date_metric_results.rb +28 -0
  137. data/spec/factories/date_module_results.rb +22 -0
  138. data/spec/factories/metric_configurations.rb +28 -0
  139. data/spec/factories/metric_configurations_snapshot.rb +26 -0
  140. data/spec/factories/metric_results.rb +24 -0
  141. data/spec/factories/metrics.rb +35 -0
  142. data/spec/factories/models.rb +20 -0
  143. data/spec/factories/module_results.rb +33 -0
  144. data/spec/factories/modules.rb +22 -0
  145. data/spec/factories/process_times.rb +27 -0
  146. data/spec/factories/processings.rb +25 -0
  147. data/spec/factories/projects.rb +29 -0
  148. data/spec/factories/ranges.rb +35 -0
  149. data/spec/factories/ranges_snapshot.rb +26 -0
  150. data/spec/factories/reading_groups.rb +23 -0
  151. data/spec/factories/readings.rb +25 -0
  152. data/spec/factories/repositories.rb +34 -0
  153. data/spec/factories/repository_observers.rb +24 -0
  154. data/spec/factories/stack_trace_elements.rb +24 -0
  155. data/spec/factories/throwables.rb +23 -0
  156. data/spec/helpers/aggregation_options_spec.rb +31 -0
  157. data/spec/helpers/hash_converters_spec.rb +111 -0
  158. data/spec/helpers/xml_converters_spec.rb +64 -0
  159. data/spec/kalibro_entities_spec.rb +108 -0
  160. data/spec/savon/fixtures/config.yml +1 -0
  161. data/spec/savon/fixtures/invalid_config.yml +2 -0
  162. data/spec/savon/fixtures/project/does_not_exists.xml +1 -0
  163. data/spec/savon/savon_test_helper.rb +14 -0
  164. data/spec/spec_helper.rb +56 -0
  165. metadata +466 -0
@@ -0,0 +1,67 @@
1
+ # This file is part of KalibroGatekeeperClient
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 KalibroGatekeeperClient
18
+ module Entities
19
+ class Reading < Model
20
+
21
+ attr_accessor :id, :label, :grade, :color, :group_id
22
+
23
+ def id=(value)
24
+ @id = value.to_i
25
+ end
26
+
27
+ def grade=(value)
28
+ @grade = value.to_f
29
+ end
30
+
31
+ def self.find(id)
32
+ response = request('get', {id: id})
33
+ raise KalibroGatekeeperClient::Errors::RecordNotFound unless response['error'].nil?
34
+ new response
35
+ end
36
+
37
+ def self.readings_of(group_id)
38
+ create_objects_array_from_hash(request('of', {reading_group_id: group_id})['readings'])
39
+ end
40
+
41
+ def self.all
42
+ reading_groups = ReadingGroup.all
43
+ readings = []
44
+
45
+ reading_groups.each do |reading_group|
46
+ readings.concat(readings_of(reading_group.id))
47
+ end
48
+ return readings
49
+ end
50
+
51
+ def self.exists?(id)
52
+ begin
53
+ return true unless find(id).nil?
54
+ rescue KalibroGatekeeperClient::Errors::RecordNotFound
55
+ return false
56
+ end
57
+ end
58
+
59
+ private
60
+
61
+ def save_params
62
+ {reading: self.to_hash, reading_group_id: group_id}
63
+ end
64
+
65
+ end
66
+ end
67
+ end
@@ -0,0 +1,44 @@
1
+ # This file is part of KalibroGatekeeperClient
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 KalibroGatekeeperClient
18
+ module Entities
19
+ class ReadingGroup < Model
20
+
21
+ attr_accessor :id, :name, :description
22
+
23
+ def id=(value)
24
+ @id = value.to_i
25
+ end
26
+
27
+ def self.all
28
+ # FIXME: for some reason, the JSON is not getting automatically parsed
29
+ create_objects_array_from_hash(JSON.parse(request('all', {}, :get))['reading_groups'])
30
+ end
31
+
32
+ private
33
+
34
+ def self.id_params(id)
35
+ {id: id}
36
+ end
37
+
38
+ def destroy_params
39
+ {id: self.id}
40
+ end
41
+
42
+ end
43
+ end
44
+ end
@@ -0,0 +1,89 @@
1
+ # This file is part of KalibroGatekeeperClient
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_gatekeeper_client/entities/model"
18
+
19
+ module KalibroGatekeeperClient
20
+ module Entities
21
+ class Repository < Model
22
+
23
+ attr_accessor :id, :name, :description, :license, :process_period, :type, :address, :configuration_id, :project_id, :send_email
24
+
25
+ def self.repository_types
26
+ request('supported_types', {}, :get)['supported_types'].to_a
27
+ end
28
+
29
+ def self.repositories_of(project_id)
30
+ repositories = create_objects_array_from_hash request('of', {project_id: project_id})['repositories']
31
+ end
32
+
33
+ def id=(value)
34
+ @id = value.to_i
35
+ end
36
+
37
+ def process_period=(value)
38
+ @process_period = value.to_i
39
+ end
40
+
41
+ def configuration_id=(value)
42
+ @configuration_id = value.to_i
43
+ end
44
+
45
+ def project_id=(value)
46
+ @project_id = value.to_i
47
+ end
48
+
49
+ def process
50
+ self.class.request('process', {id: self.id})
51
+ end
52
+
53
+ def cancel_processing_of_repository
54
+ self.class.request('cancel_process', {id: self.id})
55
+ end
56
+
57
+ def self.all
58
+ projects = Project.all
59
+ repositories = []
60
+
61
+ projects.each do |project|
62
+ repositories.concat(repositories_of(project.id))
63
+ end
64
+
65
+ return repositories
66
+ end
67
+
68
+ def self.find(id)
69
+ all.each { |repository| return repository if repository.id == id }
70
+
71
+ raise KalibroGatekeeperClient::Errors::RecordNotFound
72
+ end
73
+
74
+ def self.exists?(id)
75
+ begin
76
+ return true unless find(id).nil?
77
+ rescue KalibroGatekeeperClient::Errors::RecordNotFound
78
+ return false
79
+ end
80
+ end
81
+
82
+ private
83
+
84
+ def save_params
85
+ {repository: self.to_hash, project_id: project_id}
86
+ end
87
+ end
88
+ end
89
+ end
@@ -0,0 +1,50 @@
1
+ # This file is part of KalibroGatekeeperClient
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_gatekeeper_client/entities/model"
18
+
19
+ module KalibroGatekeeperClient
20
+ module Entities
21
+ class RepositoryObserver < Model
22
+ attr_accessor :id, :repository_id, :name, :email
23
+
24
+ def id=(value)
25
+ @id = value.to_i
26
+ end
27
+
28
+ def repository_id=(value)
29
+ @repository_id = value.to_i
30
+ end
31
+
32
+ def name=(value)
33
+ @name = value
34
+ end
35
+
36
+ def email=(value)
37
+ @email = value
38
+ end
39
+
40
+ # FIXME: the index of the second parameter of the request must be repository_id. It can't be fixed here until Kalibro webservice remain with this name!
41
+ def self.repository_observers_of(value)
42
+ create_objects_array_from_hash request(:repository_observers_of, {:repository_observer_id => value})[:repository_observer]
43
+ end
44
+
45
+ def self.all
46
+ create_objects_array_from_hash request(:all_repository_observers)[:repository_observer]
47
+ end
48
+ end
49
+ end
50
+ end
@@ -0,0 +1,31 @@
1
+ # This file is part of KalibroGatekeeperClient
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_gatekeeper_client/entities/model"
18
+
19
+ module KalibroGatekeeperClient
20
+ module Entities
21
+ class StackTraceElement < Model
22
+
23
+ attr_accessor :declaring_class, :method_name, :file_name, :line_number
24
+
25
+ def line_number=(value)
26
+ @line_number = value.to_i
27
+ end
28
+
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,42 @@
1
+ # This file is part of KalibroGatekeeperClient
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_gatekeeper_client/entities/model"
18
+
19
+ module KalibroGatekeeperClient
20
+ module Entities
21
+ class Throwable < Model
22
+
23
+ attr_accessor :target_string, :message, :cause, :stack_trace_element
24
+
25
+ def stack_trace_element=(value)
26
+ @stack_trace_element = KalibroGatekeeperClient::Entities::StackTraceElement.to_objects_array value
27
+ end
28
+
29
+ def stack_trace
30
+ @stack_trace_element
31
+ end
32
+
33
+ def stack_trace=(stack_trace)
34
+ @stack_trace_element = stack_trace
35
+ end
36
+
37
+ def cause=(cause_value)
38
+ @cause = KalibroGatekeeperClient::Entities::Throwable.to_object cause_value
39
+ end
40
+ end
41
+ end
42
+ end
@@ -0,0 +1,37 @@
1
+ # This file is part of KalibroGatekeeperClient
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_gatekeeper_client/entities/base_tool'
18
+ require 'kalibro_gatekeeper_client/entities/configuration'
19
+ require 'kalibro_gatekeeper_client/entities/date_metric_result'
20
+ require 'kalibro_gatekeeper_client/entities/date_module_result'
21
+ require 'kalibro_gatekeeper_client/entities/metric'
22
+ require 'kalibro_gatekeeper_client/entities/metric_configuration'
23
+ require 'kalibro_gatekeeper_client/entities/metric_configuration_snapshot'
24
+ require 'kalibro_gatekeeper_client/entities/metric_result'
25
+ require 'kalibro_gatekeeper_client/entities/module'
26
+ require 'kalibro_gatekeeper_client/entities/module_result'
27
+ require 'kalibro_gatekeeper_client/entities/process_time'
28
+ require 'kalibro_gatekeeper_client/entities/processing'
29
+ require 'kalibro_gatekeeper_client/entities/project'
30
+ require 'kalibro_gatekeeper_client/entities/range'
31
+ require 'kalibro_gatekeeper_client/entities/range_snapshot'
32
+ require 'kalibro_gatekeeper_client/entities/reading'
33
+ require 'kalibro_gatekeeper_client/entities/reading_group'
34
+ require 'kalibro_gatekeeper_client/entities/repository'
35
+ require 'kalibro_gatekeeper_client/entities/repository_observer'
36
+ require 'kalibro_gatekeeper_client/entities/stack_trace_element'
37
+ require 'kalibro_gatekeeper_client/entities/throwable'
@@ -0,0 +1,22 @@
1
+ # This file is part of KalibroGatekeeperClient
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 KalibroGatekeeperClient
18
+ module Errors
19
+ class RecordNotFound < Standard
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,24 @@
1
+ # This file is part of KalibroGatekeeperClient
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
+ #Inspired on:
18
+ #https://github.com/rails/rails/blob/master/activerecord/lib/active_record/errors.rb
19
+ module KalibroGatekeeperClient
20
+ module Errors
21
+ class Standard < StandardError
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,18 @@
1
+ # This file is part of KalibroGatekeeperClient
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_gatekeeper_client/errors/standard'
18
+ require 'kalibro_gatekeeper_client/errors/record_not_found'
@@ -0,0 +1,25 @@
1
+ # This file is part of KalibroGatekeeperClient
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 AggregationOptions
18
+ #TODO: internationalization
19
+ def all_with_label
20
+ [
21
+ ["Average","AVERAGE"], ["Median", "MEDIAN"], ["Maximum", "MAXIMUM"], ["Minimum", "MINIMUM"],
22
+ ["Count", "COUNT"], ["Standard Deviation", "STANDARD_DEVIATION"]
23
+ ]
24
+ end
25
+ end
@@ -0,0 +1,48 @@
1
+ # This file is part of KalibroGatekeeperClient
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 'date'
18
+ require 'kalibro_gatekeeper_client/helpers/xml_converters'
19
+
20
+ module HashConverters
21
+ include XMLConverters
22
+
23
+ #FIXME: we can think about a better name. This method actually receives an DateTime and converts it to string
24
+ def date_with_milliseconds(date)
25
+ milliseconds = "." + (date.sec_fraction * 60 * 60 * 24 * 1000).to_s
26
+ date.to_s[0..18] + milliseconds + date.to_s[19..-1]
27
+ end
28
+
29
+ def convert_to_hash(value)
30
+ return value if value.nil?
31
+ return value.collect { |element| convert_to_hash(element) } if value.is_a?(Array)
32
+ return value.to_hash if value.is_a?(KalibroGatekeeperClient::Entities::Model)
33
+ return date_with_milliseconds(value) if value.is_a?(DateTime)
34
+ return 'INF' if value.is_a?(Float) and value.infinite? == 1
35
+ return '-INF' if value.is_a?(Float) and value.infinite? == -1
36
+ value.to_s
37
+ end
38
+
39
+ def field_to_hash(field)
40
+ hash = Hash.new
41
+ field_value = send(field)
42
+ if !field_value.nil?
43
+ hash[field] = convert_to_hash(field_value)
44
+ hash = get_xml(field, field_value).merge(hash)
45
+ end
46
+ hash
47
+ end
48
+ end
@@ -0,0 +1,47 @@
1
+ # This file is part of KalibroGatekeeperClient
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 RequestMethods
18
+ def save_params
19
+ {instance_class_name.underscore.to_sym => self.to_hash}
20
+ end
21
+
22
+ def save_action
23
+ "save"
24
+ end
25
+
26
+ def destroy_action
27
+ "destroy"
28
+ end
29
+
30
+ def destroy_params
31
+ {id: self.id}
32
+ end
33
+
34
+ module ClassMethods
35
+ def exists_action
36
+ "exists"
37
+ end
38
+
39
+ def id_params(id)
40
+ {id: id}
41
+ end
42
+
43
+ def find_action
44
+ "get"
45
+ end
46
+ end
47
+ end
@@ -0,0 +1,20 @@
1
+ module XMLConverters
2
+ def xml_instance_class_name(object)
3
+ xml_name = object.class.name
4
+ xml_name["KalibroGatekeeperClient::Entities::"] = "" if xml_name.start_with?("KalibroGatekeeperClient::Entities::")
5
+ xml_name[0..0] = xml_name[0..0].downcase
6
+ xml_name + "Xml"
7
+ end
8
+
9
+ def get_xml(field, field_value)
10
+ hash = Hash.new
11
+ if field_value.is_a?(KalibroGatekeeperClient::Entities::Model)
12
+ hash = {:attributes! => {}}
13
+ hash[:attributes!][field.to_sym] = {
14
+ 'xmlns:xsi'=> 'http://www.w3.org/2001/XMLSchema-instance',
15
+ 'xsi:type' => 'kalibro:' + xml_instance_class_name(field_value)
16
+ }
17
+ end
18
+ hash
19
+ end
20
+ end
@@ -0,0 +1,39 @@
1
+ # This file is part of KalibroGatekeeperClient
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 KalibroGatekeeperClient
18
+ module KalibroCucumberHelpers
19
+ class Configuration
20
+ attr_accessor :database, :user, :password,
21
+ :query_file_path, :psql_file_path, :kalibro_home,
22
+ :tomcat_user, :tomcat_group, :tomcat_restart_command
23
+
24
+ def initialize(attributes={})
25
+ self.database = "kalibro_test"
26
+ self.user = "kalibro"
27
+ self.password = "kalibro"
28
+ self.psql_file_path = "/tmp/PostgreSQL.sql"
29
+ self.query_file_path = "/tmp/query"
30
+ self.kalibro_home = "/usr/share/tomcat6/.kalibro"
31
+ self.tomcat_user = "tomcat6"
32
+ self.tomcat_group = "tomcat6"
33
+ self.tomcat_restart_command = "sudo\\ service\\ tomcat6\\ restart"
34
+
35
+ attributes.each { |field, value| send("#{field}=", value) if respond_to?("#{field}=") }
36
+ end
37
+ end
38
+ end
39
+ end
@@ -0,0 +1,56 @@
1
+ # This file is part of KalibroGatekeeperClient
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_gatekeeper_client/kalibro_cucumber_helpers'
18
+
19
+ Before do
20
+ if !$dunit
21
+ command = "#{__dir__}/scripts/put_kalibro_on_test_mode.sh \\
22
+ #{KalibroGatekeeperClient::KalibroCucumberHelpers.configuration.kalibro_home} \\
23
+ #{KalibroGatekeeperClient::KalibroCucumberHelpers.configuration.tomcat_restart_command} \\
24
+ #{KalibroGatekeeperClient::KalibroCucumberHelpers.configuration.tomcat_user} \\
25
+ #{KalibroGatekeeperClient::KalibroCucumberHelpers.configuration.tomcat_group}"
26
+ system command
27
+
28
+ command = "#{__dir__}/scripts/prepare_kalibro_query_file.sh \\
29
+ #{KalibroGatekeeperClient::KalibroCucumberHelpers.configuration.psql_file_path} \\
30
+ #{KalibroGatekeeperClient::KalibroCucumberHelpers.configuration.query_file_path}"
31
+ system command
32
+
33
+ command = "#{__dir__}/scripts/delete_all_kalibro_entries.sh \\
34
+ #{KalibroGatekeeperClient::KalibroCucumberHelpers.configuration.password} \\
35
+ #{KalibroGatekeeperClient::KalibroCucumberHelpers.configuration.database} \\
36
+ #{KalibroGatekeeperClient::KalibroCucumberHelpers.configuration.query_file_path}"
37
+ system command
38
+
39
+ $dunit = true
40
+ end
41
+ end
42
+
43
+ After ('@kalibro_restart') do
44
+ command = "#{__dir__}/scripts/delete_all_kalibro_entries.sh \\
45
+ #{KalibroGatekeeperClient::KalibroCucumberHelpers.configuration.password} \\
46
+ #{KalibroGatekeeperClient::KalibroCucumberHelpers.configuration.database} \\
47
+ #{KalibroGatekeeperClient::KalibroCucumberHelpers.configuration.query_file_path}"
48
+ system command
49
+ end
50
+
51
+ at_exit do
52
+ command = "#{__dir__}/scripts/return_kalibro_from_test_mode.sh \\
53
+ #{KalibroGatekeeperClient::KalibroCucumberHelpers.configuration.kalibro_home} \\
54
+ #{KalibroGatekeeperClient::KalibroCucumberHelpers.configuration.tomcat_restart_command}"
55
+ system command
56
+ end