kalibro_client 2.1.2 → 3.0.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: e191f0d8e9425cbd141f40fa5394d0304111a341
4
- data.tar.gz: 332b0704428ff197560f47326e24d4f501b49509
3
+ metadata.gz: 40b036706870cceebb217fb718eb8816f1cda7e6
4
+ data.tar.gz: 1f6b0ced25ec1c38a6c1269ce340958ead0f4760
5
5
  SHA512:
6
- metadata.gz: 218d5627657e6aea3dcf3d164b49b7f412cee62cec5486bb8ac7e145b1387d0e6860ed1b325d87d39d537e2e4fb3e55d965d3083694d9b4d24a133895187ecf8
7
- data.tar.gz: 61551fff5abe5367175a4d9d4f045b3de3edc20739c13c1d4dbcf8fee65661276aeb02f6fc8a24b9e5b9c93a6489011969fd0dfc646aada426a5cbc4a875b85c
6
+ metadata.gz: 942f57893671ef4a267c52550005bd355c9d69e6ec86d7f3f62edaf606a24efb94741bb54944238dcb57ddab6f0ed85b05f4046a54eead1e44bcdab5ff19e963
7
+ data.tar.gz: 80559612be69e952c80dc779404d1bdc02274f4c05aecb1dc39f34704e10602b8b02f084db4669ea84a9b49a54d5d841cfb028fcb8161c27bab472fb0ef923d2
data/.ruby-version CHANGED
@@ -1 +1 @@
1
- ruby-2.2.3
1
+ ruby-2.3.0
data/.travis.yml CHANGED
@@ -1,15 +1,21 @@
1
1
  language: ruby
2
2
  rvm:
3
- - 2.2.3
3
+ - 2.3.0
4
+ - 2.0.0-p598 # CentOS 7
5
+ - 2.1.5 # Debian 8
4
6
 
5
7
  addons:
6
8
  postgresql: "9.3"
7
9
 
10
+ before_install:
11
+ - if ruby --version | cut -d ' ' -f 2 | grep -q 2.1.5p273 ; then gem update --system 2.4.8; fi
12
+ - gem --version
13
+
8
14
  before_script:
9
15
  # 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
10
16
  - sudo apt-get remove libzmq3
11
17
  - git clone https://github.com/mezuro/kalibro_install.git -b v4.0 kalibro_install
12
- - KALIBRO_PROCESSOR_VERSION='v1.1.2' KALIBRO_CONFIGURATIONS_VERSION='v1.2.0' ./kalibro_install/install.sh
18
+ - KALIBRO_PROCESSOR_VERSION='v1.1.6' KALIBRO_CONFIGURATIONS_VERSION='v2.0.0' ./kalibro_install/install.sh
13
19
  - cp features/support/kalibro_cucumber_helpers.yml.sample features/support/kalibro_cucumber_helpers.yml
14
20
  - export BUNDLE_GEMFILE=$PWD/Gemfile
15
21
  - export CODECLIMATE_REPO_TOKEN=46cbb96b053b03ad66b0355bd96d0787f56fc5a4fc171b8d6eb30c421c5e6777
data/AUTHORS CHANGED
@@ -1,5 +1,6 @@
1
1
  Daniel Quadros Miranda
2
2
  Diego Araújo Martinez
3
+ Eduardo Silva Araújo
3
4
  Heitor Reis Ribeiro
4
5
  Rafael Reggiani Manzo
5
6
 
data/README.md CHANGED
@@ -4,7 +4,14 @@
4
4
  [![Code Climate](https://codeclimate.com/github/mezuro/kalibro_client.png)](https://codeclimate.com/github/mezuro/kalibro_client)
5
5
  [![Test Coverage](https://codeclimate.com/github/mezuro/kalibro_client/badges/coverage.svg)](https://codeclimate.com/github/mezuro/kalibro_client)
6
6
 
7
- KalibroClient is a Ruby gem intended to be an interface for Ruby applications who want to use the open source code analysis webservice Kalibro (http://gitorious.org/kalibro/kalibro).
7
+ KalibroClient is a Ruby gem intended to be an interface for Ruby applications who want to use the open source code analysis webservices from Kalibro (https://github.com/mezuro/kalibro_processor and https://github.com/mezuro/kalibro_configurations).
8
+
9
+ ## Contributing
10
+
11
+ Please, have a look the wiki pages about development workflow and code standards:
12
+
13
+ * https://github.com/mezuro/mezuro/wiki/Development-workflow
14
+ * https://github.com/mezuro/mezuro/wiki/Standards
8
15
 
9
16
  ## Installation
10
17
 
@@ -24,7 +31,7 @@ Or install it yourself as:
24
31
 
25
32
  KalibroClient is intended to be an easy interface that encapsulates the usage of all the Kalibro service's endpoints. So have a look at the available entities at `lib/kalibro_client/entities`.
26
33
 
27
- All the entities are subclasses from `Model`, so have a good look at it. Specially notice that all the entities have methods:
34
+ All the entities are subclasses from `KalibroClient::Entities::Base`, so have a good look at it. Specially notice that all the entities have methods:
28
35
 
29
36
  * `save`
30
37
  * `exists?`
@@ -35,7 +42,7 @@ These four methods should be useful.
35
42
 
36
43
  We hope to make available soon a full documentation on RDoc that will make easier to understand all this.
37
44
 
38
- A good example on how to get everything from KalibroClient should be Mezuro. So, have a look there for some examples.
45
+ A good example on how to get everything from KalibroClient should be Prezento (https://github.com/mezuro/prezento). So, have a look there for some examples.
39
46
 
40
47
  ### Cucumber helpers
41
48
 
@@ -47,31 +54,15 @@ Just add to your `env.rb` the following:
47
54
 
48
55
  The test configurations available are:
49
56
 
50
- * database
51
- * user
52
- * password
53
- * psql_file_path
54
- * query_file_path
55
- * kalibro_home
56
- * tomcat_user
57
- * tomcat_group
58
- * tomcat_restart_command
57
+ * `kalibro_processor_address`
58
+ * `kalibro_configurations_address`
59
59
 
60
60
  An example on how to change them is:
61
61
 
62
- KalibroClient::KalibroCucumberHelpers.configure do |config|
63
- config.database = "kalibro_test"
64
- end
62
+ ```ruby
63
+ KalibroClient::KalibroCucumberHelpers.configure do |config|
64
+ config.kalibro_processor_address = "http://localhost:8082"
65
+ end
66
+ ```
65
67
 
66
68
  We hope to make available soon an YAML parser for test configurations.
67
-
68
- ## Contributing
69
-
70
- 0. Install RVM (rvm.io)
71
- 1. Fork it
72
- 2. Run `bundle install`
73
- 3. Create your feature branch (`git checkout -b my-new-feature`)
74
- 4. Make your modifications and changes
75
- 5. Commit your changes (`git commit -am 'Add some feature'`)
76
- 6. Push to the branch (`git push origin my-new-feature`)
77
- 7. Create new Pull Request
@@ -18,3 +18,4 @@ Feature: Module Results
18
18
  When I get the first metric result of the given processing
19
19
  And I ask for the module result of the given metric result
20
20
  Then I should get the metric result's module result
21
+ And the module result should have a granularity
@@ -0,0 +1,18 @@
1
+ Feature: kalibro_module
2
+ In order to be able to retrieve the ModuleResult's KalibroModule
3
+ As a developer
4
+ I want to make the proper requests
5
+
6
+ @kalibro_configuration_restart @kalibro_processor_restart
7
+ Scenario: find a valid module result
8
+ Given I have a project with name "Kalibro"
9
+ And I have a kalibro configuration with name "Conf"
10
+ And I have a reading group with name "Group"
11
+ And I have a "saikuro" configuration within the given kalibro configuration
12
+ And the given project has the following Repositories:
13
+ | name | scm_type | address |
14
+ | Kalibro | GIT | https://github.com/mezuro/kalibro_processor.git |
15
+ And I call the process method for the given repository
16
+ And I wait up for a ready processing
17
+ When I ask for the kalibro_module of the processing root module result
18
+ Then I should get a KalibroModule
@@ -15,4 +15,4 @@ Feature: Last processing state
15
15
  And I call the process method for the given repository
16
16
  And I wait up to 1 seconds
17
17
  When I call the last_processing_state method for the given repository
18
- Then I should get "PREPARING"
18
+ Then I should get a valid state
@@ -15,7 +15,7 @@ Feature: Processing
15
15
  And I call the process method for the given repository
16
16
  And I wait up to 1 seconds
17
17
  When I call the processing method for the given repository
18
- Then I should get a Processing with state "PREPARING"
18
+ Then I should get a Processing
19
19
 
20
20
  @kalibro_processor_restart @kalibro_configuration_restart
21
21
  Scenario: With one repository just after with ready processing
@@ -44,3 +44,8 @@ end
44
44
  Then(/^I should get the metric result's module result$/) do
45
45
  expect(@module_result.id).to eq(@metric_result.module_result_id)
46
46
  end
47
+
48
+ Then(/^the module result should have a granularity$/) do
49
+ expect(@module_result.kalibro_module.granularity).to be_a(KalibroClient::Entities::Miscellaneous::Granularity)
50
+ end
51
+
@@ -44,3 +44,11 @@ end
44
44
  Then(/^The first children should have a module$/) do
45
45
  expect(@children.first.kalibro_module).to be_a(KalibroClient::Entities::Processor::KalibroModule)
46
46
  end
47
+
48
+ When(/^I ask for the kalibro_module of the processing root module result$/) do
49
+ @kalibro_module = KalibroClient::Entities::Processor::ModuleResult.find(@repository.processing.root_module_result_id).kalibro_module
50
+ end
51
+
52
+ Then(/^I should get a KalibroModule$/) do
53
+ expect(@kalibro_module).to be_a(KalibroClient::Entities::Processor::KalibroModule)
54
+ end
@@ -76,6 +76,13 @@ Then(/^I should get "(.*?)"$/) do |state|
76
76
  expect(@response).to eq(state)
77
77
  end
78
78
 
79
+ Then(/^I should get a valid state$/) do
80
+ # REFACTOR ME: maybe the list of valid states should be retrieved from the Processor
81
+ states = ["PREPARING", "DOWNLOADING", "COLLECTING",
82
+ "CHECKING", "BUILDING", "AGGREGATING", "CALCULATING", "INTERPRETING"]
83
+ expect(states).to include(@response)
84
+ end
85
+
79
86
  Then(/^I should get false$/) do
80
87
  expect(@response).to be_falsey
81
88
  end
@@ -37,8 +37,8 @@ Gem::Specification.new do |spec|
37
37
 
38
38
  spec.add_development_dependency "bundler", "~> 1.3"
39
39
  spec.add_development_dependency "rake"
40
- spec.add_development_dependency "rspec", "~> 3.3.0"
41
- spec.add_development_dependency "cucumber", "~> 2.0.2"
40
+ spec.add_development_dependency "rspec", "~> 3.0"
41
+ spec.add_development_dependency "cucumber", "~> 2.0"
42
42
  spec.add_development_dependency "mocha", "~> 1.1.0"
43
43
  spec.add_development_dependency "simplecov"
44
44
  spec.add_development_dependency "factory_girl", "~> 4.5.0"
@@ -1,7 +1,7 @@
1
1
  module KalibroClient
2
2
  module Entities
3
3
  module Miscellaneous
4
- class Granularity
4
+ class Granularity < KalibroClient::Entities::Miscellaneous::Base
5
5
  include Comparable
6
6
 
7
7
  GRANULARITIES = [:METHOD, :CLASS, :PACKAGE, :SOFTWARE, :FUNCTION]
@@ -21,6 +21,7 @@ module KalibroClient
21
21
  attr_reader :type
22
22
 
23
23
  def initialize(type)
24
+ type = type.to_sym
24
25
  if GRANULARITIES.include?(type)
25
26
  @type = type
26
27
  else
@@ -10,9 +10,18 @@ module KalibroClient
10
10
  @type = type
11
11
  @name = name
12
12
  @code = code
13
- @scope = scope
13
+ self.scope = scope
14
14
  @description = ""
15
15
  end
16
+
17
+ def scope=(value)
18
+ if value.is_a?(Hash) && !value["type"].nil?
19
+ value = value["type"]
20
+ else
21
+ value = value.to_s
22
+ end
23
+ @scope = KalibroClient::Entities::Miscellaneous::Granularity.new(value)
24
+ end
16
25
  end
17
26
  end
18
27
  end
@@ -20,6 +20,11 @@ module KalibroClient
20
20
  class KalibroModule < KalibroClient::Entities::Processor::Base
21
21
  attr_accessor :granularity, :id, :long_name, :module_result_id
22
22
 
23
+ def initialize(attributes = {}, persisted = false)
24
+ super
25
+ @granularity = KalibroClient::Entities::Miscellaneous::Granularity.new attributes['granularity']['type']
26
+ end
27
+
23
28
  def name=(value)
24
29
  @long_name = (value.is_a?(Array) ? value.join('.') : value)
25
30
  end
@@ -5,7 +5,7 @@
5
5
  # it under the terms of the GNU General Public License as published by
6
6
  # the Free Software Foundation, either version 3 of the License, or
7
7
  # (at your option) any later version.
8
- #
8
+ #
9
9
  # This program is distributed in the hope that it will be useful,
10
10
  # but WITHOUT ANY WARRANTY; without even the implied warranty of
11
11
  # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
@@ -15,5 +15,5 @@
15
15
  # along with this program. If not, see <http://www.gnu.org/licenses/>.
16
16
 
17
17
  module KalibroClient
18
- VERSION = "2.1.2"
18
+ VERSION = "3.0.0"
19
19
  end
@@ -21,7 +21,7 @@ describe KalibroClient::Entities::Miscellaneous::CompoundMetric, :type => :model
21
21
 
22
22
  context 'with a hash' do
23
23
  it 'is expected to create a object from the hash' do
24
- subject_hash = Hash[subject.to_hash.map { |k,v| if v.is_a?(Array) then [k.to_s, v] else [k.to_s, v.to_s] end}]
24
+ subject_hash = subject.to_hash
25
25
  expect(KalibroClient::Entities::Miscellaneous::CompoundMetric.to_object(subject_hash)).to eq(subject)
26
26
  end
27
27
  end
@@ -11,5 +11,22 @@ describe KalibroClient::Entities::Miscellaneous::Metric, :type => :model do
11
11
  expect(KalibroClient::Entities::Miscellaneous::Metric.new(compound, name, code, scope)).to be_a(KalibroClient::Entities::Miscellaneous::Metric)
12
12
  end
13
13
  end
14
+
15
+ describe 'scope=' do
16
+ subject { FactoryGirl.build(:metric) }
17
+ context 'with a valid granularity' do
18
+ it 'is expected to instantiate a Granularity' do
19
+ subject.scope = {"type" => "CLASS"}
20
+ expect(subject.scope).to be_a KalibroClient::Entities::Miscellaneous::Granularity
21
+ end
22
+ end
23
+
24
+ context 'with an invalid granularity' do
25
+ it 'is expected to raise a TypeError' do
26
+ scope = nil
27
+ expect { subject.scope = scope }.to raise_error TypeError
28
+ end
29
+ end
30
+ end
14
31
  end
15
32
  end
@@ -22,7 +22,7 @@ describe KalibroClient::Entities::Miscellaneous::NativeMetric, :type => :model d
22
22
 
23
23
  context 'with a hash' do
24
24
  it 'is expected to create a object from the hash' do
25
- subject_hash = Hash[subject.to_hash.map { |k,v| if v.is_a?(Array) then [k.to_s, v] else [k.to_s, v.to_s] end}]
25
+ subject_hash = subject.to_hash
26
26
  expect(KalibroClient::Entities::Miscellaneous::NativeMetric.to_object(subject_hash)).to eq(subject)
27
27
  end
28
28
  end
@@ -20,7 +20,7 @@ describe KalibroClient::Entities::Processor::HotspotMetricResult do
20
20
  describe 'new' do
21
21
  context 'with the expected attributes' do
22
22
  let(:attributes) { FactoryGirl.build(:hotspot_metric_result).to_hash }
23
- subject { KalibroClient::Entities::Processor::HotspotMetricResult.new attributes }
23
+ subject { KalibroClient::Entities::Processor::HotspotMetricResult.new attributes }
24
24
 
25
25
  it 'should cast the line_number attribute to an integer' do
26
26
  expect(subject.line_number).to be_a Integer
@@ -46,4 +46,3 @@ describe KalibroClient::Entities::Processor::HotspotMetricResult do
46
46
  end
47
47
  end
48
48
  end
49
-
@@ -5,7 +5,7 @@
5
5
  # it under the terms of the GNU General Public License as published by
6
6
  # the Free Software Foundation, either version 3 of the License, or
7
7
  # (at your option) any later version.
8
- #
8
+ #
9
9
  # This program is distributed in the hope that it will be useful,
10
10
  # but WITHOUT ANY WARRANTY; without even the implied warranty of
11
11
  # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
@@ -48,4 +48,10 @@ describe KalibroClient::Entities::Processor::KalibroModule do
48
48
  expect(subject.short_name).to eq(subject.long_name.split(".").last)
49
49
  end
50
50
  end
51
+
52
+ describe 'granularity' do
53
+ it 'is expected to be a granularity object' do
54
+ expect(subject.granularity).to be_a KalibroClient::Entities::Miscellaneous::Granularity
55
+ end
56
+ end
51
57
  end
@@ -63,18 +63,29 @@ describe KalibroClient::Entities::Processor::ModuleResult do
63
63
  let(:kalibro_module) { FactoryGirl.build(:kalibro_module) }
64
64
 
65
65
  before :each do
66
+ end
67
+
68
+ it 'is expected to request the kalibro_module' do
66
69
  KalibroClient::Entities::Processor::ModuleResult.
67
- expects(:request).once.
70
+ expects(:request).
68
71
  with(':id/kalibro_module', { id: subject.id }, :get).
69
72
  returns("kalibro_module" => kalibro_module.to_hash)
70
- end
71
-
72
- it 'should return the kalibro_module' do
73
73
  expect(subject.kalibro_module).to eq(kalibro_module)
74
74
  end
75
75
 
76
- it 'should not request the kalibro_module in cache' do
77
- expect(subject.kalibro_module).to eq(kalibro_module)
76
+ context 'when a previous request has already been made' do
77
+ before :each do
78
+ KalibroClient::Entities::Processor::ModuleResult.
79
+ expects(:request).
80
+ with(':id/kalibro_module', { id: subject.id }, :get).
81
+ returns("kalibro_module" => kalibro_module.to_hash)
82
+
83
+ subject.kalibro_module
84
+ end
85
+
86
+ it 'should not request the kalibro_module and return the cached one' do
87
+ expect(subject.kalibro_module).to eq(kalibro_module)
88
+ end
78
89
  end
79
90
  end
80
91
 
@@ -17,12 +17,14 @@
17
17
  FactoryGirl.define do
18
18
  factory :kalibro_module, class: KalibroClient::Entities::Processor::KalibroModule do
19
19
  name 'Qt-Calculator'
20
- granularity 'APPLICATION'
20
+ granularity { {type: FactoryGirl.build(:granularity).type }.stringify_keys }
21
21
 
22
22
  trait :with_id do
23
23
  id 1
24
24
  end
25
25
 
26
26
  factory :kalibro_module_with_id, traits: [:with_id]
27
+
28
+ initialize_with { KalibroClient::Entities::Processor::KalibroModule.new({ name: name, granularity: granularity }.stringify_keys) }
27
29
  end
28
30
  end
@@ -19,7 +19,7 @@ FactoryGirl.define do
19
19
  name "Total Abstract Classes"
20
20
  code "total_abstract_classes"
21
21
  type "native"
22
- scope "SOFTWARE"
22
+ scope FactoryGirl.build(:granularity)
23
23
  description ""
24
24
 
25
25
  initialize_with { KalibroClient::Entities::Miscellaneous::Metric.new(type, name, code, scope) }
@@ -28,7 +28,7 @@ FactoryGirl.define do
28
28
  factory :loc, class: KalibroClient::Entities::Miscellaneous::NativeMetric do
29
29
  name "Lines of Code"
30
30
  code "loc"
31
- scope "CLASS"
31
+ scope FactoryGirl.build(:granularity, type: "CLASS")
32
32
  description ""
33
33
  languages nil
34
34
  metric_collector_name "Analizo"
@@ -39,7 +39,7 @@ FactoryGirl.define do
39
39
  factory :compound_metric, class: KalibroClient::Entities::Miscellaneous::CompoundMetric do
40
40
  name "Lines of Code"
41
41
  code "loc"
42
- scope "CLASS"
42
+ scope FactoryGirl.build(:granularity, type: "CLASS")
43
43
  description ""
44
44
  script "return 0;"
45
45
 
@@ -59,7 +59,7 @@ FactoryGirl.define do
59
59
  factory :saikuro, class: KalibroClient::Entities::Miscellaneous::NativeMetric do
60
60
  name 'Cyclomatic Complexity'
61
61
  code 'saikuro'
62
- scope 'METHOD'
62
+ scope FactoryGirl.build(:granularity, type: 'METHOD')
63
63
  description ''
64
64
  metric_collector_name 'MetricFu'
65
65
  languages nil
@@ -79,6 +79,15 @@ describe HashConverters do
79
79
  expect(convert_to_hash(-1.0/0.0)).to eq('-INF')
80
80
  end
81
81
  end
82
+
83
+ context 'with a granularity' do
84
+ let(:granularity) { FactoryGirl.build(:granularity) }
85
+
86
+ it 'is expected to convert the granularity to a hash' do
87
+ expect(convert_to_hash(granularity)).to be_a Hash
88
+ expect(convert_to_hash(granularity)).to include 'type'
89
+ end
90
+ end
82
91
  end
83
92
 
84
93
  describe 'field_to_hash' 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: 2.1.2
4
+ version: 3.0.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-10-23 00:00:00.000000000 Z
14
+ date: 2016-02-05 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: bundler
@@ -47,28 +47,28 @@ dependencies:
47
47
  requirements:
48
48
  - - "~>"
49
49
  - !ruby/object:Gem::Version
50
- version: 3.3.0
50
+ version: '3.0'
51
51
  type: :development
52
52
  prerelease: false
53
53
  version_requirements: !ruby/object:Gem::Requirement
54
54
  requirements:
55
55
  - - "~>"
56
56
  - !ruby/object:Gem::Version
57
- version: 3.3.0
57
+ version: '3.0'
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: cucumber
60
60
  requirement: !ruby/object:Gem::Requirement
61
61
  requirements:
62
62
  - - "~>"
63
63
  - !ruby/object:Gem::Version
64
- version: 2.0.2
64
+ version: '2.0'
65
65
  type: :development
66
66
  prerelease: false
67
67
  version_requirements: !ruby/object:Gem::Requirement
68
68
  requirements:
69
69
  - - "~>"
70
70
  - !ruby/object:Gem::Version
71
- version: 2.0.2
71
+ version: '2.0'
72
72
  - !ruby/object:Gem::Dependency
73
73
  name: mocha
74
74
  requirement: !ruby/object:Gem::Requirement
@@ -216,6 +216,7 @@ files:
216
216
  - features/module_result/children.feature
217
217
  - features/module_result/find.feature
218
218
  - features/module_result/history_of.feature
219
+ - features/module_result/kalibro_module.feature
219
220
  - features/project/all.feature
220
221
  - features/project/creation.feature
221
222
  - features/project/destroy.feature
@@ -429,6 +430,7 @@ test_files:
429
430
  - features/module_result/children.feature
430
431
  - features/module_result/find.feature
431
432
  - features/module_result/history_of.feature
433
+ - features/module_result/kalibro_module.feature
432
434
  - features/project/all.feature
433
435
  - features/project/creation.feature
434
436
  - features/project/destroy.feature