sonarqube-client 0.0.0 → 0.0.1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1e5c848304338dee76e0a4b1b08c46efdc7c3061
4
- data.tar.gz: ce4957d40b5a6eaaf651d3c9edf0deefc2d4df71
3
+ metadata.gz: 64c7070d55e7746cbfe8ec2a8dd088f53a25a273
4
+ data.tar.gz: 369e824b95082c608fea15d9141313d0dacc1bab
5
5
  SHA512:
6
- metadata.gz: 66ae5d99b34c55cdb05c6e70bf74601268de8cdd570ad9adb8c933bbddc72b53cf9f890ca2080b681b40abfcaf73f88f91b16091c62489d5caf676dc6c2dc545
7
- data.tar.gz: 8662428d509991e30ca8bb1c7a262866674c4caa26cf67146f7323e93b5f8c4fc0fe185a7875f9ec390ed8f68be36a8cbc00dbcd4197b544228eb4ca7eccc04e
6
+ metadata.gz: bfbbb0d549ee281fc1de3f1cfd8082b17cf12ef18bf48597d484c529b8e7d0cc9ec7ba4106e3e9fbd69e8fe668f13e704ea67d951ba66d35144be306120b4ecb
7
+ data.tar.gz: f539a01d8c48bcaa8f24862bd236afbd232d675842e40cbd98e4c68341510cbcd7ec32c179f9fc1e2efae002f313a25c6f0185f557e38f37ef09b0685254388a
@@ -20,12 +20,12 @@ require 'nokogiri'
20
20
  require 'json'
21
21
  require 'logger'
22
22
 
23
- require File.dirname(__FILE__) + '/sonarqube/client.rb'
24
- require File.dirname(__FILE__) + '/sonarqube/issues.rb'
25
- require File.dirname(__FILE__) + '/sonarqube/logger.rb'
26
- require File.dirname(__FILE__) + '/sonarqube/projects.rb'
27
- require File.dirname(__FILE__) + '/sonarqube/timemachine.rb'
28
- require File.dirname(__FILE__) + '/sonarqube/version.rb'
23
+ require File.dirname(__FILE__) + '/sonarqube-client/client.rb'
24
+ require File.dirname(__FILE__) + '/sonarqube-client/issues.rb'
25
+ require File.dirname(__FILE__) + '/sonarqube-client/logger.rb'
26
+ require File.dirname(__FILE__) + '/sonarqube-client/projects.rb'
27
+ require File.dirname(__FILE__) + '/sonarqube-client/timemachine.rb'
28
+ require File.dirname(__FILE__) + '/sonarqube-client/version.rb'
29
29
 
30
30
 
31
31
 
@@ -75,9 +75,9 @@ module SonarQube
75
75
 
76
76
  def sonarqube(server_url, username='', password='')
77
77
  if [username, password].reduce(:+) == ''
78
- proc {|endpoint| RestClient::Resource.new server_url + endpoint}.curry
78
+ proc {|endpoint| JSON.parse((RestClient::Resource.new server_url + endpoint).get)}.curry
79
79
  else
80
- proc {|endpoint| RestClient::Resource.new server_url + endpoint, a, b}.curry
80
+ proc {|endpoint| JSON.parse((RestClient::Resource.new server_url + endpoint, username, password).get)}.curry
81
81
  end
82
82
  end
83
83
 
@@ -16,6 +16,8 @@
16
16
 
17
17
  module SonarQube
18
18
  module Projects
19
+ require 'ostruct'
20
+
19
21
  class Projects
20
22
  @@endpoint='/api/projects/'
21
23
 
@@ -29,37 +31,38 @@ module SonarQube
29
31
 
30
32
  #Returns all projects
31
33
  #
32
- # @return [JSON] A JSON object, containing all the projects.
33
- #
34
+ # @return [Array<OpenStruct>] An Array of OpenStruct objects containing the project details (e.g. [#<OpenStruct id="1", k="bad:project", nm="My bad project", sc="PRJ", qu="TRK">]).
34
35
  def get
35
- JSON.parse(@connector["#{@@endpoint}index?format=json"].get)
36
+ response = JSON.parse(@connector["#{@@endpoint}index?format=json"].get, object_class: OpenStruct)
37
+ return response.length > 0 ? response : nil
36
38
  end
37
39
 
38
40
  #Search for a project using the project index number (id)
39
41
  #
40
42
  # @param [String] index project index number to use in the search
41
- # @example puts \"this will return all the projects that their id is 47: #\\{search_by_key 47\}\"
42
- # @return [JSON] A JSON object containing the project details (what details?).
43
+ # @example puts \"this will return the project with id 47: #\\{search_by_key 47\}\"
44
+ # @return [OpenStruct, nil] An OpenStruct object containing the project details (e.g. #<OpenStruct id="1", k="bad:project", nm="My bad project", sc="PRJ", qu="TRK">) or nil.
43
45
  def search_by_index index
44
- JSON.parse(@connector["#{@@endpoint}index?key=#{index}"].get)
46
+ JSON.parse(@connector["#{@@endpoint}index?format=json&key=#{index}"].get, object_class: OpenStruct)[0]
45
47
  end
46
48
 
47
49
  #Search for a project using the project key
48
50
  #
49
51
  # @param [String] key project key to use in the search
50
- # @example puts \"this will return all the projects that their key is \'my:awesome:project\': #\\{search_by_key 'my:awesome:project'\}\"
51
- # @return [JSON] A JSON object containing the project details (what details?).
52
+ # @example puts \"this will return all the project with key \'my:awesome:project\': #\\{search_by_key 'my:awesome:project'\}\"
53
+ # @return [OpenStruct] An OpenStruct object containing the project details (e.g. #<OpenStruct id="1", k="bad:project", nm="My bad project", sc="PRJ", qu="TRK">) or nil.
52
54
  def search_by_key key
53
- JSON.parse(@connector["#{@@endpoint}index?key=#{key}"].get)
55
+ JSON.parse(@connector["#{@@endpoint}index?format=json&key=#{key}"].get, object_class: OpenStruct)[0]
54
56
  end
55
57
 
56
58
  #Return all projects that their name contains the provided string
57
59
  #
58
60
  # @param [String] search_string search string to search with
59
- # @return [JSON] A JSON object, containing all the project details (what details?).
60
61
  # @example puts \"this will return all the projects that their name contains the string \'java\': #\\{name_contains 'java'\}\"
62
+ # @return [Array<OpenStruct>, nil] An Array of OpenStruct objects containing the project details (e.g. [#<OpenStruct id="1", k="bad:project", nm="My bad project", sc="PRJ", qu="TRK">]) or nil.
61
63
  def name_contains search_string
62
- JSON.parse(@connector["#{@@endpoint}index?search=#{search_string}"].get)
64
+ response = JSON.parse(@connector["#{@@endpoint}index?format=json&search=#{search_string}"].get, object_class: OpenStruct)
65
+ return response.length > 0 ? response : nil
63
66
  end
64
67
 
65
68
  #Delete a project with the specified id
@@ -86,7 +89,7 @@ module SonarQube
86
89
  # @return A JSON object, containing all the projects.
87
90
  #
88
91
  def get
89
- JSON.parse(@connector["#{@@endpoint}api/projects/index"].get)
92
+ 'api/projects/index?format=json'
90
93
  end
91
94
 
92
95
  #Search for a project by key (functional interface)
@@ -101,7 +104,7 @@ module SonarQube
101
104
  #http://localhost:9000/api/projects/index?key=35
102
105
  #http://localhost:9000/api/projects/index?key=java-sonar-runner-simple
103
106
  def search_by_key key
104
- 'api/projects/index?key=' + key
107
+ '/api/projects/index?key=' + key
105
108
  end
106
109
 
107
110
  #Search for a project by name
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sonarqube-client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.0
4
+ version: 0.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dimitrios Dimas
@@ -75,12 +75,12 @@ extensions: []
75
75
  extra_rdoc_files: []
76
76
  files:
77
77
  - lib/sonarqube-client.rb
78
- - lib/sonarqube/client.rb
79
- - lib/sonarqube/issues.rb
80
- - lib/sonarqube/logger.rb
81
- - lib/sonarqube/projects.rb
82
- - lib/sonarqube/timemachine.rb
83
- - lib/sonarqube/version.rb
78
+ - lib/sonarqube-client/client.rb
79
+ - lib/sonarqube-client/issues.rb
80
+ - lib/sonarqube-client/logger.rb
81
+ - lib/sonarqube-client/projects.rb
82
+ - lib/sonarqube-client/timemachine.rb
83
+ - lib/sonarqube-client/version.rb
84
84
  homepage: http://rubygems.org/gems/sonarqube-client
85
85
  licenses:
86
86
  - GPL-2.0
@@ -104,6 +104,6 @@ rubyforge_project:
104
104
  rubygems_version: 2.5.1
105
105
  signing_key:
106
106
  specification_version: 4
107
- summary: SonarQube client
107
+ summary: A SonarQube client
108
108
  test_files: []
109
109
  has_rdoc: