kalibro_client 1.2.2 → 1.3.0
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.
- checksums.yaml +4 -4
- data/.travis.yml +1 -1
- data/features/metric_configuration/creation.feature +7 -0
- data/features/step_definitions/metric_configuration_steps.rb +19 -5
- data/lib/kalibro_client/entities/configurations/metric_configuration.rb +3 -1
- data/lib/kalibro_client/entities/miscellaneous/hotspot_metric.rb +19 -0
- data/lib/kalibro_client/entities/miscellaneous/native_metric.rb +2 -3
- data/lib/kalibro_client/entities.rb +1 -0
- data/lib/kalibro_client/version.rb +1 -1
- data/spec/entities/configurations/metric_configuration_spec.rb +19 -3
- data/spec/entities/miscellaneous/hotspot_metric_spec.rb +50 -0
- data/spec/entities/miscellaneous/native_metric_spec.rb +7 -7
- data/spec/factories/metrics.rb +10 -0
- metadata +6 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 389fd917fcbbe1e5765f5f848cad583ecfaedc28
|
4
|
+
data.tar.gz: 42702af62588e9744a9895ccb2981fe7021f6278
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3e8e4a35f7884b9ebcd87cd12bf7db909a631e5b59f33b6223e7b0ef8254c9d007f039e7bb918c5fb3da4cd6be5436ddd126a608b35a012a5fddcee0c7d7309c
|
7
|
+
data.tar.gz: bacc3234fcb2db12348c837fa32606a168a6c1d7296e7b915c0db392a2703c80f8ff65efc4d2c2784860ddb2b1b88083e520144ca1de84a95c0c56b9fd6d04fc
|
data/.travis.yml
CHANGED
@@ -6,7 +6,7 @@ addons:
|
|
6
6
|
postgresql: "9.3"
|
7
7
|
|
8
8
|
before_script:
|
9
|
-
- git clone https://github.com/mezuro/kalibro_install.git -b
|
9
|
+
- git clone https://github.com/mezuro/kalibro_install.git -b v3.4 kalibro_install
|
10
10
|
- pushd kalibro_install
|
11
11
|
# Remove bugged libzmq3 package, see https://github.com/travis-ci/travis-ci/issues/982 and https://github.com/travis-ci/travis-ci/issues/1715 for details
|
12
12
|
- sudo apt-get remove libzmq3
|
@@ -9,3 +9,10 @@ Feature: Create
|
|
9
9
|
And I have a reading group with name "Group"
|
10
10
|
When I have a loc configuration within the given kalibro configuration
|
11
11
|
Then the metric configuration should exist
|
12
|
+
|
13
|
+
@kalibro_configuration_restart
|
14
|
+
Scenario: creating a hotspot metric configuration
|
15
|
+
Given I have a kalibro configuration with name "Kalibro for Ruby"
|
16
|
+
When I have a flay configuration within the given kalibro configuration
|
17
|
+
Then the metric configuration should exist
|
18
|
+
And its metric should be Hotspot one
|
@@ -36,6 +36,19 @@ When(/^I request all metric configurations of the given kalibro configuration$/)
|
|
36
36
|
@metric_configurations = KalibroClient::Entities::Configurations::MetricConfiguration.metric_configurations_of(@kalibro_configuration.id)
|
37
37
|
end
|
38
38
|
|
39
|
+
When(/^I destroy the metric configuration$/) do
|
40
|
+
@metric_configuration.destroy
|
41
|
+
end
|
42
|
+
|
43
|
+
When(/^I have a flay configuration within the given kalibro configuration$/) do
|
44
|
+
@metric_configuration = FactoryGirl.create(:metric_configuration,
|
45
|
+
{metric: FactoryGirl.build(:hotspot_metric),
|
46
|
+
weight: nil,
|
47
|
+
aggregation_form: nil,
|
48
|
+
reading_group_id: nil,
|
49
|
+
kalibro_configuration_id: @kalibro_configuration.id})
|
50
|
+
end
|
51
|
+
|
39
52
|
Then(/^it should return the same metric configuration as the given one$/) do
|
40
53
|
expect(@found_metric_configuration).to eq(@metric_configuration)
|
41
54
|
end
|
@@ -48,14 +61,15 @@ Then(/^I should get an empty list of metric configurations$/) do
|
|
48
61
|
expect(@metric_configurations).to eq([])
|
49
62
|
end
|
50
63
|
|
51
|
-
When(/^I destroy the metric configuration$/) do
|
52
|
-
@metric_configuration.destroy
|
53
|
-
end
|
54
|
-
|
55
64
|
Then(/^the metric configuration should no longer exist$/) do
|
56
65
|
expect { KalibroClient::Entities::Configurations::MetricConfiguration.find(@metric_configuration.id)}.to raise_error(KalibroClient::Errors::RecordNotFound)
|
57
66
|
end
|
58
67
|
|
59
68
|
Then(/^the metric configuration should exist$/) do
|
60
|
-
|
69
|
+
@found_metric_configuration = KalibroClient::Entities::Configurations::MetricConfiguration.find(@metric_configuration.id)
|
70
|
+
expect(@found_metric_configuration).to eq(@metric_configuration)
|
71
|
+
end
|
72
|
+
|
73
|
+
Then(/^its metric should be Hotspot one$/) do
|
74
|
+
expect(@found_metric_configuration.metric).to be_a(KalibroClient::Entities::Miscellaneous::HotspotMetric)
|
61
75
|
end
|
@@ -37,6 +37,8 @@ module KalibroClient
|
|
37
37
|
if value.is_a?(Hash)
|
38
38
|
if value['type'] == "NativeMetricSnapshot"
|
39
39
|
@metric = KalibroClient::Entities::Miscellaneous::NativeMetric.to_object(value)
|
40
|
+
elsif value['type'] == "HotspotMetricSnapshot"
|
41
|
+
@metric = KalibroClient::Entities::Miscellaneous::HotspotMetric.to_object(value)
|
40
42
|
else
|
41
43
|
@metric = KalibroClient::Entities::Miscellaneous::CompoundMetric.to_object(value)
|
42
44
|
end
|
@@ -69,7 +71,7 @@ module KalibroClient
|
|
69
71
|
def self.find(id)
|
70
72
|
metric_configuration = request(':id', {id: id}, :get)
|
71
73
|
raise KalibroClient::Errors::RecordNotFound unless metric_configuration['errors'].nil?
|
72
|
-
return new(metric_configuration['metric_configuration'])
|
74
|
+
return new(metric_configuration['metric_configuration'], true)
|
73
75
|
end
|
74
76
|
|
75
77
|
def self.exists?(id)
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module KalibroClient
|
2
|
+
module Entities
|
3
|
+
module Miscellaneous
|
4
|
+
class HotspotMetric < NativeMetric
|
5
|
+
def initialize(name, code, languages, metric_collector_name)
|
6
|
+
super(name, code, KalibroClient::Entities::Miscellaneous::Granularity.new(:SOFTWARE), languages, metric_collector_name, 'HotspotMetricSnapshot')
|
7
|
+
end
|
8
|
+
|
9
|
+
def self.to_object(value)
|
10
|
+
if value.is_a?(Hash)
|
11
|
+
new(value['name'], value['code'], value['languages'], value['metric_collector_name'])
|
12
|
+
else
|
13
|
+
value
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -4,9 +4,8 @@ module KalibroClient
|
|
4
4
|
class NativeMetric < Metric
|
5
5
|
attr_accessor :languages, :metric_collector_name
|
6
6
|
|
7
|
-
|
8
|
-
|
9
|
-
super('NativeMetricSnapshot', name, code, scope)
|
7
|
+
def initialize(name, code, scope, languages, metric_collector_name, type='NativeMetricSnapshot')
|
8
|
+
super(type, name, code, scope)
|
10
9
|
@languages = languages
|
11
10
|
@metric_collector_name = metric_collector_name
|
12
11
|
end
|
@@ -28,6 +28,7 @@ require 'kalibro_client/entities/miscellaneous/date_module_result'
|
|
28
28
|
require 'kalibro_client/entities/miscellaneous/metric'
|
29
29
|
require 'kalibro_client/entities/miscellaneous/granularity'
|
30
30
|
require 'kalibro_client/entities/miscellaneous/native_metric'
|
31
|
+
require 'kalibro_client/entities/miscellaneous/hotspot_metric'
|
31
32
|
require 'kalibro_client/entities/miscellaneous/compound_metric'
|
32
33
|
require 'kalibro_client/entities/processor/base'
|
33
34
|
require 'kalibro_client/entities/processor/metric_collector_details'
|
@@ -32,7 +32,6 @@ describe KalibroClient::Entities::Configurations::MetricConfiguration do
|
|
32
32
|
end
|
33
33
|
|
34
34
|
describe 'metric=' do
|
35
|
-
|
36
35
|
context 'with a Hash' do
|
37
36
|
context 'NativeMetric' do
|
38
37
|
let!(:metric) { FactoryGirl.build(:loc) }
|
@@ -65,6 +64,22 @@ describe KalibroClient::Entities::Configurations::MetricConfiguration do
|
|
65
64
|
expect(subject.metric).to eq(metric)
|
66
65
|
end
|
67
66
|
end
|
67
|
+
|
68
|
+
context 'HotspotMetric' do
|
69
|
+
let!(:metric) { FactoryGirl.build(:hotspot_metric) }
|
70
|
+
|
71
|
+
before :each do
|
72
|
+
KalibroClient::Entities::Miscellaneous::HotspotMetric.
|
73
|
+
expects(:to_object).at_least_once.
|
74
|
+
with(metric.to_hash).
|
75
|
+
returns(metric)
|
76
|
+
end
|
77
|
+
|
78
|
+
it 'should convert the argument and set the metric' do
|
79
|
+
subject.metric = metric.to_hash
|
80
|
+
expect(subject.metric).to eq(metric)
|
81
|
+
end
|
82
|
+
end
|
68
83
|
end
|
69
84
|
|
70
85
|
context 'with a Metric' do
|
@@ -190,8 +205,9 @@ describe KalibroClient::Entities::Configurations::MetricConfiguration do
|
|
190
205
|
end
|
191
206
|
|
192
207
|
it 'should return the metric_configuration' do
|
193
|
-
|
194
|
-
|
208
|
+
found_metric_configuration = KalibroClient::Entities::Configurations::MetricConfiguration.find(metric_configuration.id)
|
209
|
+
expect(found_metric_configuration.id).to eq(metric_configuration.id)
|
210
|
+
expect(found_metric_configuration.persisted).to be_truthy
|
195
211
|
end
|
196
212
|
end
|
197
213
|
|
@@ -0,0 +1,50 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe KalibroClient::Entities::Miscellaneous::HotspotMetric, :type => :model do
|
4
|
+
describe 'methods' do
|
5
|
+
describe 'initialize' do
|
6
|
+
context 'with valid attributes' do
|
7
|
+
let(:name){ "Sample name"}
|
8
|
+
let(:code){ "sample_code" }
|
9
|
+
let(:languages){ [:RUBY] }
|
10
|
+
let(:metric_collector_name){ "MetricFU" }
|
11
|
+
let(:hotspot_metric){ KalibroClient::Entities::Miscellaneous::HotspotMetric.new(name, code, languages, metric_collector_name) }
|
12
|
+
|
13
|
+
it 'is expected to return an instance of HotspotMetric' do
|
14
|
+
expect(hotspot_metric).to be_a(KalibroClient::Entities::Miscellaneous::HotspotMetric)
|
15
|
+
end
|
16
|
+
|
17
|
+
it 'is expected to have SOFTWARE as the default scope' do
|
18
|
+
expect(hotspot_metric.scope).to eq(KalibroClient::Entities::Miscellaneous::Granularity.new(:SOFTWARE))
|
19
|
+
end
|
20
|
+
|
21
|
+
it 'is expected to have HotspotMetricSnapshot type' do
|
22
|
+
expect(hotspot_metric.type).to eq("HotspotMetricSnapshot")
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
describe 'to_object' do
|
28
|
+
context 'with the expected attributes' do
|
29
|
+
let(:hotspot_metric_hash) { FactoryGirl.attributes_for(:hotspot_metric) }
|
30
|
+
it 'is expected to return a HotspotMetric' do
|
31
|
+
expect(KalibroClient::Entities::Miscellaneous::HotspotMetric.to_object(hotspot_metric_hash)).to be_a(KalibroClient::Entities::Miscellaneous::HotspotMetric)
|
32
|
+
end
|
33
|
+
|
34
|
+
context 'and with some extra attributes' do
|
35
|
+
let(:hotspot_metric_hash_extra) { hotspot_metric_hash.merge({"scope" => "SOFTWARE"}) }
|
36
|
+
it 'is expected to return a HotspotMetric' do
|
37
|
+
expect(KalibroClient::Entities::Miscellaneous::HotspotMetric.to_object(hotspot_metric_hash)).to be_a(KalibroClient::Entities::Miscellaneous::HotspotMetric)
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
context 'when the value is already an instance' do
|
43
|
+
let(:hotspot_metric) { FactoryGirl.build(:hotspot_metric) }
|
44
|
+
it 'is expected to return a HotspotMetric' do
|
45
|
+
expect(KalibroClient::Entities::Miscellaneous::HotspotMetric.to_object(hotspot_metric)).to be_a(KalibroClient::Entities::Miscellaneous::HotspotMetric)
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
@@ -4,14 +4,14 @@ describe KalibroClient::Entities::Miscellaneous::NativeMetric, :type => :model d
|
|
4
4
|
describe 'methods' do
|
5
5
|
describe 'initialize' do
|
6
6
|
context 'with valid attributes' do
|
7
|
-
name
|
8
|
-
code
|
9
|
-
scope
|
10
|
-
languages
|
11
|
-
metric_collector_name
|
12
|
-
native_metric
|
7
|
+
let(:name){ "Sample name" }
|
8
|
+
let(:code){ "sample_code" }
|
9
|
+
let(:scope){ KalibroClient::Entities::Miscellaneous::Granularity.new(:SOFTWARE) }
|
10
|
+
let(:languages){ [:C, :CPP, :JAVA] }
|
11
|
+
let(:metric_collector_name){ "Analizo" }
|
12
|
+
let(:native_metric){ KalibroClient::Entities::Miscellaneous::NativeMetric.new(name, code, scope, languages, metric_collector_name) }
|
13
13
|
|
14
|
-
it '
|
14
|
+
it 'is expected to return an instance of NativeMetric' do
|
15
15
|
expect(native_metric).to be_a(KalibroClient::Entities::Miscellaneous::NativeMetric)
|
16
16
|
end
|
17
17
|
end
|
data/spec/factories/metrics.rb
CHANGED
@@ -45,4 +45,14 @@ FactoryGirl.define do
|
|
45
45
|
|
46
46
|
initialize_with { KalibroClient::Entities::Miscellaneous::CompoundMetric.new(name, code, scope, script) }
|
47
47
|
end
|
48
|
+
|
49
|
+
factory :hotspot_metric, class: KalibroClient::Entities::Miscellaneous::HotspotMetric do
|
50
|
+
name "Flay"
|
51
|
+
code "flay"
|
52
|
+
description ""
|
53
|
+
metric_collector_name "MetricFu"
|
54
|
+
languages nil
|
55
|
+
|
56
|
+
initialize_with { KalibroClient::Entities::Miscellaneous::HotspotMetric.new(name, code, languages, metric_collector_name) }
|
57
|
+
end
|
48
58
|
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: 1.
|
4
|
+
version: 1.3.0
|
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: 2015-08-
|
14
|
+
date: 2015-08-28 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: bundler
|
@@ -278,6 +278,7 @@ files:
|
|
278
278
|
- lib/kalibro_client/entities/miscellaneous/date_metric_result.rb
|
279
279
|
- lib/kalibro_client/entities/miscellaneous/date_module_result.rb
|
280
280
|
- lib/kalibro_client/entities/miscellaneous/granularity.rb
|
281
|
+
- lib/kalibro_client/entities/miscellaneous/hotspot_metric.rb
|
281
282
|
- lib/kalibro_client/entities/miscellaneous/metric.rb
|
282
283
|
- lib/kalibro_client/entities/miscellaneous/native_metric.rb
|
283
284
|
- lib/kalibro_client/entities/processor/base.rb
|
@@ -319,6 +320,7 @@ files:
|
|
319
320
|
- spec/entities/miscellaneous/date_metric_result_spec.rb
|
320
321
|
- spec/entities/miscellaneous/date_module_result_spec.rb
|
321
322
|
- spec/entities/miscellaneous/granularity_spec.rb
|
323
|
+
- spec/entities/miscellaneous/hotspot_metric_spec.rb
|
322
324
|
- spec/entities/miscellaneous/metric_spec.rb
|
323
325
|
- spec/entities/miscellaneous/native_metric_spec.rb
|
324
326
|
- spec/entities/processor/base_spec.rb
|
@@ -379,7 +381,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
379
381
|
version: '0'
|
380
382
|
requirements: []
|
381
383
|
rubyforge_project:
|
382
|
-
rubygems_version: 2.4.5
|
384
|
+
rubygems_version: 2.4.5.1
|
383
385
|
signing_key:
|
384
386
|
specification_version: 4
|
385
387
|
summary: KalibroClient is a communication interface with the KalibroProcessor and
|
@@ -470,6 +472,7 @@ test_files:
|
|
470
472
|
- spec/entities/miscellaneous/date_metric_result_spec.rb
|
471
473
|
- spec/entities/miscellaneous/date_module_result_spec.rb
|
472
474
|
- spec/entities/miscellaneous/granularity_spec.rb
|
475
|
+
- spec/entities/miscellaneous/hotspot_metric_spec.rb
|
473
476
|
- spec/entities/miscellaneous/metric_spec.rb
|
474
477
|
- spec/entities/miscellaneous/native_metric_spec.rb
|
475
478
|
- spec/entities/processor/base_spec.rb
|