kalibro_client 3.0.1 → 4.0.0.alpha1

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 (56) hide show
  1. checksums.yaml +4 -4
  2. data/features/metric_collector_details/find_by_name.feature +12 -4
  3. data/features/step_definitions/metric_collector_details_steps.rb +11 -7
  4. data/features/step_definitions/metric_configuration_steps.rb +2 -2
  5. data/features/step_definitions/module_result_steps.rb +1 -1
  6. data/features/support/env.rb +0 -3
  7. data/kalibro_client.gemspec +1 -0
  8. data/lib/kalibro_client.rb +4 -39
  9. data/lib/kalibro_client/entities/base.rb +12 -207
  10. data/lib/kalibro_client/entities/configurations/base.rb +3 -3
  11. data/lib/kalibro_client/entities/configurations/kalibro_configuration.rb +0 -4
  12. data/lib/kalibro_client/entities/configurations/metric_configuration.rb +1 -19
  13. data/lib/kalibro_client/entities/configurations/reading_group.rb +1 -5
  14. data/lib/kalibro_client/entities/miscellaneous/base.rb +4 -2
  15. data/lib/kalibro_client/entities/miscellaneous/metric.rb +0 -2
  16. data/lib/kalibro_client/entities/processor/base.rb +3 -3
  17. data/lib/kalibro_client/entities/processor/hotspot_metric_result.rb +1 -1
  18. data/lib/kalibro_client/entities/processor/metric_collector_details.rb +19 -7
  19. data/lib/kalibro_client/entities/processor/module_result.rb +0 -13
  20. data/lib/kalibro_client/entities/processor/project.rb +0 -4
  21. data/lib/kalibro_client/entities/processor/repository.rb +0 -4
  22. data/lib/kalibro_client/entities/processor/tree_metric_result.rb +1 -1
  23. data/lib/kalibro_client/errors.rb +1 -4
  24. data/lib/kalibro_client/kalibro_cucumber_helpers.rb +7 -36
  25. data/lib/kalibro_client/kalibro_cucumber_helpers/cleaner.rb +27 -0
  26. data/lib/kalibro_client/version.rb +1 -1
  27. data/spec/entities/base_spec.rb +17 -449
  28. data/spec/entities/configurations/kalibro_configuration_spec.rb +0 -35
  29. data/spec/entities/configurations/kalibro_range_spec.rb +3 -3
  30. data/spec/entities/configurations/metric_configuration_spec.rb +1 -58
  31. data/spec/entities/configurations/reading_group_spec.rb +0 -32
  32. data/spec/entities/configurations/reading_spec.rb +3 -3
  33. data/spec/entities/processor/metric_collector_details_spec.rb +46 -25
  34. data/spec/entities/processor/module_result_spec.rb +0 -41
  35. data/spec/entities/processor/project_spec.rb +1 -35
  36. data/spec/entities/processor/repository_spec.rb +1 -14
  37. data/spec/{savon/fixtures → fixtures}/config.yml +0 -0
  38. data/spec/{savon/fixtures → fixtures}/invalid_config.yml +0 -0
  39. data/spec/kalibro_cucumber_helpers/cleaner_spec.rb +32 -0
  40. metadata +26 -32
  41. data/lib/kalibro_client/errors/record_invalid.rb +0 -19
  42. data/lib/kalibro_client/errors/record_not_found.rb +0 -22
  43. data/lib/kalibro_client/errors/request_error.rb +0 -27
  44. data/lib/kalibro_client/errors/standard.rb +0 -24
  45. data/lib/kalibro_client/helpers/date_attributes.rb +0 -11
  46. data/lib/kalibro_client/helpers/hash_converters.rb +0 -48
  47. data/lib/kalibro_client/helpers/request_methods.rb +0 -64
  48. data/lib/kalibro_client/helpers/xml_converters.rb +0 -20
  49. data/lib/kalibro_client/kalibro_cucumber_helpers/configuration.rb +0 -30
  50. data/spec/errors/record_invalid_spec.rb +0 -45
  51. data/spec/helpers/date_attributes_spec.rb +0 -30
  52. data/spec/helpers/hash_converters_spec.rb +0 -120
  53. data/spec/helpers/xml_converters_spec.rb +0 -64
  54. data/spec/kalibro_entities_spec.rb +0 -112
  55. data/spec/savon/fixtures/project/does_not_exists.xml +0 -1
  56. data/spec/savon/savon_test_helper.rb +0 -14
@@ -0,0 +1,32 @@
1
+ require 'rspec/mocks'
2
+ require 'faraday'
3
+ require 'likeno'
4
+ require 'kalibro_client/kalibro_cucumber_helpers'
5
+
6
+ describe KalibroClient::KalibroCucumberHelpers::Cleaner do
7
+ let(:address_key) { :test_address }
8
+ let(:likeno_config) { {address_key => 'http://test'} }
9
+
10
+ subject { described_class.new(address_key) }
11
+
12
+ describe 'endpoint' do
13
+ it 'is expected to return "tests"' do
14
+ expect(subject.endpoint).to eq('tests')
15
+ end
16
+ end
17
+
18
+ describe 'address' do
19
+ it 'is expected to find the address in Likeno' do
20
+ Likeno.expects(:config).returns likeno_config
21
+ expect(subject.address).to eq(likeno_config[address_key])
22
+ end
23
+ end
24
+
25
+ describe 'clean_database' do
26
+ it 'is expected to make a request to the correct address' do
27
+ subject.expects(:request).with('clean_database', {}, :post)
28
+
29
+ subject.clean_database
30
+ end
31
+ end
32
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kalibro_client
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.1
4
+ version: 4.0.0.alpha1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daniel Quadros Miranda
@@ -11,7 +11,7 @@ authors:
11
11
  autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
- date: 2016-02-29 00:00:00.000000000 Z
14
+ date: 2016-03-30 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: bundler
@@ -167,6 +167,20 @@ dependencies:
167
167
  - - "~>"
168
168
  - !ruby/object:Gem::Version
169
169
  version: '0.9'
170
+ - !ruby/object:Gem::Dependency
171
+ name: likeno
172
+ requirement: !ruby/object:Gem::Requirement
173
+ requirements:
174
+ - - "~>"
175
+ - !ruby/object:Gem::Version
176
+ version: '1.1'
177
+ type: :runtime
178
+ prerelease: false
179
+ version_requirements: !ruby/object:Gem::Requirement
180
+ requirements:
181
+ - - "~>"
182
+ - !ruby/object:Gem::Version
183
+ version: '1.1'
170
184
  description: KalibroClient is a Ruby gem intended to be an interface for Ruby applications
171
185
  who want to use the open source code analysis webservice Kalibro.
172
186
  email:
@@ -299,18 +313,10 @@ files:
299
313
  - lib/kalibro_client/entities/processor/repository.rb
300
314
  - lib/kalibro_client/entities/processor/tree_metric_result.rb
301
315
  - lib/kalibro_client/errors.rb
302
- - lib/kalibro_client/errors/record_invalid.rb
303
- - lib/kalibro_client/errors/record_not_found.rb
304
- - lib/kalibro_client/errors/request_error.rb
305
- - lib/kalibro_client/errors/standard.rb
306
316
  - lib/kalibro_client/helpers/aggregation_options.rb
307
- - lib/kalibro_client/helpers/date_attributes.rb
308
- - lib/kalibro_client/helpers/hash_converters.rb
309
317
  - lib/kalibro_client/helpers/range_methods.rb
310
- - lib/kalibro_client/helpers/request_methods.rb
311
- - lib/kalibro_client/helpers/xml_converters.rb
312
318
  - lib/kalibro_client/kalibro_cucumber_helpers.rb
313
- - lib/kalibro_client/kalibro_cucumber_helpers/configuration.rb
319
+ - lib/kalibro_client/kalibro_cucumber_helpers/cleaner.rb
314
320
  - lib/kalibro_client/kalibro_cucumber_helpers/hooks.rb
315
321
  - lib/kalibro_client/version.rb
316
322
  - lib/rake/test_task.rb
@@ -345,7 +351,6 @@ files:
345
351
  - spec/entities/processor/project_spec.rb
346
352
  - spec/entities/processor/repository_spec.rb
347
353
  - spec/entities/processor/tree_metric_result_spec.rb
348
- - spec/errors/record_invalid_spec.rb
349
354
  - spec/factories/date_metric_results.rb
350
355
  - spec/factories/date_module_results.rb
351
356
  - spec/factories/granularities.rb
@@ -367,16 +372,11 @@ files:
367
372
  - spec/factories/readings.rb
368
373
  - spec/factories/repositories.rb
369
374
  - spec/factories/tree_metric_results.rb
375
+ - spec/fixtures/config.yml
376
+ - spec/fixtures/invalid_config.yml
370
377
  - spec/helpers/aggregation_options_spec.rb
371
- - spec/helpers/date_attributes_spec.rb
372
- - spec/helpers/hash_converters_spec.rb
373
378
  - spec/helpers/range_methods_spec.rb
374
- - spec/helpers/xml_converters_spec.rb
375
- - spec/kalibro_entities_spec.rb
376
- - spec/savon/fixtures/config.yml
377
- - spec/savon/fixtures/invalid_config.yml
378
- - spec/savon/fixtures/project/does_not_exists.xml
379
- - spec/savon/savon_test_helper.rb
379
+ - spec/kalibro_cucumber_helpers/cleaner_spec.rb
380
380
  - spec/spec_helper.rb
381
381
  homepage: https://github.com/mezuro/kalibro_client
382
382
  licenses:
@@ -393,12 +393,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
393
393
  version: '0'
394
394
  required_rubygems_version: !ruby/object:Gem::Requirement
395
395
  requirements:
396
- - - ">="
396
+ - - ">"
397
397
  - !ruby/object:Gem::Version
398
- version: '0'
398
+ version: 1.3.1
399
399
  requirements: []
400
400
  rubyforge_project:
401
- rubygems_version: 2.6.1
401
+ rubygems_version: 2.5.1
402
402
  signing_key:
403
403
  specification_version: 4
404
404
  summary: KalibroClient is a communication interface with the KalibroProcessor and
@@ -509,7 +509,6 @@ test_files:
509
509
  - spec/entities/processor/project_spec.rb
510
510
  - spec/entities/processor/repository_spec.rb
511
511
  - spec/entities/processor/tree_metric_result_spec.rb
512
- - spec/errors/record_invalid_spec.rb
513
512
  - spec/factories/date_metric_results.rb
514
513
  - spec/factories/date_module_results.rb
515
514
  - spec/factories/granularities.rb
@@ -531,14 +530,9 @@ test_files:
531
530
  - spec/factories/readings.rb
532
531
  - spec/factories/repositories.rb
533
532
  - spec/factories/tree_metric_results.rb
533
+ - spec/fixtures/config.yml
534
+ - spec/fixtures/invalid_config.yml
534
535
  - spec/helpers/aggregation_options_spec.rb
535
- - spec/helpers/date_attributes_spec.rb
536
- - spec/helpers/hash_converters_spec.rb
537
536
  - spec/helpers/range_methods_spec.rb
538
- - spec/helpers/xml_converters_spec.rb
539
- - spec/kalibro_entities_spec.rb
540
- - spec/savon/fixtures/config.yml
541
- - spec/savon/fixtures/invalid_config.yml
542
- - spec/savon/fixtures/project/does_not_exists.xml
543
- - spec/savon/savon_test_helper.rb
537
+ - spec/kalibro_cucumber_helpers/cleaner_spec.rb
544
538
  - spec/spec_helper.rb
@@ -1,19 +0,0 @@
1
- module KalibroClient
2
- module Errors
3
- class RecordInvalid < Standard
4
- attr_reader :record
5
-
6
- def initialize(record = nil)
7
- if record
8
- @record = record
9
- errors = @record.kalibro_errors.join(', ')
10
- message = "Record invalid: #{errors}"
11
- else
12
- message = 'Record invalid'
13
- end
14
-
15
- super(message)
16
- end
17
- end
18
- end
19
- end
@@ -1,22 +0,0 @@
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 < RequestError
20
- end
21
- end
22
- end
@@ -1,27 +0,0 @@
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 RequestError < Standard
20
- attr_reader :response
21
-
22
- def initialize(attributes={})
23
- @response = attributes[:response]
24
- end
25
- end
26
- end
27
- end
@@ -1,24 +0,0 @@
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
- #Inspired on:
18
- #https://github.com/rails/rails/blob/master/activerecord/lib/active_record/errors.rb
19
- module KalibroClient
20
- module Errors
21
- class Standard < StandardError
22
- end
23
- end
24
- end
@@ -1,11 +0,0 @@
1
- module DateAttributes
2
- attr_reader :created_at, :updated_at
3
-
4
- def created_at=(value)
5
- @created_at = DateTime.parse(value)
6
- end
7
-
8
- def updated_at=(value)
9
- @updated_at = DateTime.parse(value)
10
- end
11
- end
@@ -1,48 +0,0 @@
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 'date'
18
- require 'kalibro_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?(KalibroClient::Entities::Base) || value.is_a?(KalibroClient::Entities::Miscellaneous::Base)
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
@@ -1,64 +0,0 @@
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 RequestMethods
18
- def save_params
19
- {instance_class_name.underscore.to_sym => self.to_hash}
20
- end
21
-
22
- def save_action
23
- ""
24
- end
25
-
26
- def save_prefix
27
- ""
28
- end
29
-
30
- def destroy_action
31
- ":id"
32
- end
33
- alias_method :update_action, :destroy_action
34
-
35
- def destroy_params
36
- {id: self.id}
37
- end
38
-
39
- def destroy_prefix
40
- ""
41
- end
42
-
43
- def update_params
44
- {instance_class_name.underscore.to_sym => self.to_hash, :id => self.id}
45
- end
46
-
47
- def update_prefix
48
- ""
49
- end
50
-
51
- module ClassMethods
52
- def exists_action
53
- ":id/exists"
54
- end
55
-
56
- def id_params(id)
57
- {id: id}
58
- end
59
-
60
- def find_action
61
- ":id"
62
- end
63
- end
64
- end
@@ -1,20 +0,0 @@
1
- module XMLConverters
2
- def xml_instance_class_name(object)
3
- xml_name = object.class.name
4
- xml_name["KalibroClient::Entities::"] = "" if xml_name.start_with?("KalibroClient::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?(KalibroClient::Entities::Base)
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
@@ -1,30 +0,0 @@
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 KalibroCucumberHelpers
19
- class Configuration
20
- attr_accessor :kalibro_processor_address, :kalibro_configurations_address
21
-
22
- def initialize(attributes={})
23
- self.kalibro_processor_address = "http://localhost:8082"
24
- self.kalibro_configurations_address = "http://localhost:8083"
25
-
26
- attributes.each { |field, value| send("#{field}=", value) if respond_to?("#{field}=") }
27
- end
28
- end
29
- end
30
- end
@@ -1,45 +0,0 @@
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 'spec_helper'
18
-
19
- describe KalibroClient::Errors::RecordInvalid do
20
- describe 'initialize' do
21
- let(:default_message){ "Record invalid" }
22
-
23
- context 'without a record' do
24
- subject { KalibroClient::Errors::RecordInvalid.new }
25
-
26
- it 'is expected to have the default message' do
27
- expect(subject.message).to eq(default_message)
28
- end
29
- end
30
-
31
- context 'with a given record' do
32
- let!(:record) { mock('record') }
33
- let!(:kalibro_errors) { ['Kalibro', 'Error'] }
34
- subject { KalibroClient::Errors::RecordInvalid.new(record) }
35
-
36
- before :each do
37
- record.expects(:kalibro_errors).returns(kalibro_errors)
38
- end
39
-
40
- it 'is expected to return the default message concatenated with the errors' do
41
- expect(subject.message).to eq("#{default_message}: #{kalibro_errors.join(', ')}")
42
- end
43
- end
44
- end
45
- end