kalibro_client 1.1.0 → 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 15bcca85f96a24bd55b802949805c93d4db2e5ad
|
4
|
+
data.tar.gz: 83b823a0de3a999ff5465073b0df0bc40eb9faed
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ab72cff243dc5c1303e799cf051938935aea76fec5886a089a99d9ad753ae571492fb56603cca72ea68b31da9558e604ae24a42f8bb44d38bd04ddbcebc44176
|
7
|
+
data.tar.gz: 2b28c6858132fd53576bfa144ad4ed57b1b947673ad4c779045d4fd25538a7b260a3ec3b95a33b4d5f7a088eb587f07b1300b61c7c252ac432db80ede00c18cf
|
@@ -2,12 +2,21 @@ module KalibroClient
|
|
2
2
|
module Entities
|
3
3
|
module Miscellaneous
|
4
4
|
class Granularity
|
5
|
-
|
5
|
+
include Comparable
|
6
6
|
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
7
|
+
GRANULARITIES = [:METHOD, :CLASS, :PACKAGE, :SOFTWARE, :FUNCTION]
|
8
|
+
|
9
|
+
GRANULARITIES.each do |name|
|
10
|
+
self.const_set(name, name)
|
11
|
+
end
|
12
|
+
|
13
|
+
PARENTS = {
|
14
|
+
METHOD: CLASS,
|
15
|
+
CLASS: PACKAGE,
|
16
|
+
PACKAGE: SOFTWARE,
|
17
|
+
SOFTWARE: SOFTWARE,
|
18
|
+
FUNCTION: PACKAGE
|
19
|
+
}
|
11
20
|
|
12
21
|
attr_reader :type
|
13
22
|
|
@@ -20,45 +29,41 @@ module KalibroClient
|
|
20
29
|
end
|
21
30
|
|
22
31
|
def parent
|
23
|
-
|
24
|
-
|
32
|
+
parent_type = PARENTS[self.type]
|
33
|
+
raise ArgumentError.new("Not supported granularity type #{type}") if parent_type.nil?
|
34
|
+
|
35
|
+
return self if self.type == parent_type
|
36
|
+
Granularity.new(parent_type)
|
25
37
|
end
|
26
38
|
|
27
39
|
def to_s
|
28
40
|
self.type.to_s
|
29
41
|
end
|
30
42
|
|
31
|
-
|
32
|
-
|
33
|
-
|
43
|
+
# FYI: this is a spaceship operator
|
44
|
+
def <=>(other)
|
45
|
+
return nil if [[:FUNCTION, :METHOD], [:METHOD, :FUNCTION]].include?([self.type, other.type])
|
34
46
|
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
def >=(other_granularity)
|
44
|
-
(self > other_granularity) || (self == other_granularity)
|
47
|
+
if self.type == other.type
|
48
|
+
return 0
|
49
|
+
elsif self.is_lower_than?(other.type)
|
50
|
+
return -1
|
51
|
+
else
|
52
|
+
return 1
|
53
|
+
end
|
45
54
|
end
|
46
55
|
|
47
|
-
def
|
48
|
-
|
49
|
-
end
|
56
|
+
def is_lower_than?(other_type)
|
57
|
+
current_type = self.type
|
50
58
|
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
elsif self > other_granularity
|
55
|
-
return 1
|
56
|
-
else
|
57
|
-
return 0
|
59
|
+
while current_type != PARENTS[current_type]
|
60
|
+
return true if PARENTS[current_type] == other_type
|
61
|
+
current_type = PARENTS[current_type]
|
58
62
|
end
|
63
|
+
|
64
|
+
return false
|
59
65
|
end
|
60
66
|
end
|
61
|
-
|
62
67
|
end
|
63
68
|
end
|
64
69
|
end
|
@@ -18,7 +18,7 @@ module KalibroClient
|
|
18
18
|
module Entities
|
19
19
|
module Processor
|
20
20
|
class MetricCollectorDetails < KalibroClient::Entities::Processor::Base
|
21
|
-
attr_accessor :name, :description, :supported_metrics
|
21
|
+
attr_accessor :name, :description, :supported_metrics
|
22
22
|
|
23
23
|
def supported_metrics=(value)
|
24
24
|
@supported_metrics = {}
|
@@ -32,6 +32,14 @@ describe KalibroClient::Entities::Miscellaneous::Granularity do
|
|
32
32
|
expect(subject.parent.type).to eq(KalibroClient::Entities::Miscellaneous::Granularity::CLASS)
|
33
33
|
end
|
34
34
|
end
|
35
|
+
|
36
|
+
context 'with a FUNCTION granularity' do
|
37
|
+
subject { FactoryGirl.build(:granularity, type: KalibroClient::Entities::Miscellaneous::Granularity::FUNCTION) }
|
38
|
+
|
39
|
+
it 'should return PACKAGE' do
|
40
|
+
expect(subject.parent.type).to eq(KalibroClient::Entities::Miscellaneous::Granularity::PACKAGE)
|
41
|
+
end
|
42
|
+
end
|
35
43
|
end
|
36
44
|
|
37
45
|
describe 'Comparison Operators' do
|
@@ -92,6 +100,18 @@ describe KalibroClient::Entities::Miscellaneous::Granularity do
|
|
92
100
|
expect(subject <=> other_granularity).to eq(1)
|
93
101
|
end
|
94
102
|
end
|
103
|
+
|
104
|
+
context 'comparing unrelated ones' do
|
105
|
+
let(:function_granularity) { FactoryGirl.build(:granularity, type: KalibroClient::Entities::Miscellaneous::Granularity::FUNCTION) }
|
106
|
+
let(:method_granularity) { FactoryGirl.build(:granularity, type: KalibroClient::Entities::Miscellaneous::Granularity::METHOD) }
|
107
|
+
|
108
|
+
it 'should raise an ArgumentError' do
|
109
|
+
expect { function_granularity < method_granularity }.to raise_error(ArgumentError)
|
110
|
+
expect { function_granularity <= method_granularity }.to raise_error(ArgumentError)
|
111
|
+
expect { function_granularity >= method_granularity }.to raise_error(ArgumentError)
|
112
|
+
expect { function_granularity > method_granularity }.to raise_error(ArgumentError)
|
113
|
+
end
|
114
|
+
end
|
95
115
|
end
|
96
116
|
|
97
117
|
describe 'to_s' do
|
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.2.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-
|
14
|
+
date: 2015-08-17 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: bundler
|
@@ -379,7 +379,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
379
379
|
version: '0'
|
380
380
|
requirements: []
|
381
381
|
rubyforge_project:
|
382
|
-
rubygems_version: 2.4.
|
382
|
+
rubygems_version: 2.4.5
|
383
383
|
signing_key:
|
384
384
|
specification_version: 4
|
385
385
|
summary: KalibroClient is a communication interface with the KalibroProcessor and
|