class SonarQube::Projects::Projects

Public Class Methods

new(connector) click to toggle source

Constructor

@param [RestClient::Resource] connector The rest-client resource object
# File lib/sonarqube-client/projects.rb, line 28
def initialize connector
  @connector=connector
end

Public Instance Methods

delete_id(id) click to toggle source

Delete a project with the specified id

@param [String] id id of the project to be deleted
@return [JSON] A JSON object, containing all the project details (what details?).
@example puts \"this will delete the project with id 47: #\\{delete_id 47\}\"
# File lib/sonarqube-client/projects.rb, line 73
def delete_id id
  JSON.parse(@connector["#{@@endpoint}delete?id=#{id}"].get)
end
delete_key(key) click to toggle source

Delete a project with the specified key

@param [String] key key of the project to be deleted
@return [JSON] A JSON object, containing all the project details (what details?).
@example puts \"this will delete the project with the key \'my:awesome:project\': #\\{delete_key 'my:awesome:project'\}\"
# File lib/sonarqube-client/projects.rb, line 82
def delete_key key
  JSON.parse(@connector["#{@@endpoint}delete?key=#{key}"].get)
end
get() click to toggle source

Returns all projects

@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">]).
# File lib/sonarqube-client/projects.rb, line 35
def get
  response = JSON.parse(@connector["#{@@endpoint}index?format=json"].get, object_class: OpenStruct)
  return response.length > 0 ? response : nil
end
name_contains(search_string) click to toggle source

Return all projects that their name contains the provided string

@param [String] search_string search string to search with
@example puts \"this will return all the projects that their name contains the string \'java\': #\\{name_contains 'java'\}\"
@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.
# File lib/sonarqube-client/projects.rb, line 63
def name_contains search_string
  response = JSON.parse(@connector["#{@@endpoint}index?format=json&search=#{search_string}"].get, object_class: OpenStruct)
  return response.length > 0 ? response : nil
end
search_by_index(index) click to toggle source

Search for a project using the project index number (id)

@param [String] index project index number to use in the search
@example puts \"this will return the project with id 47: #\\{search_by_key 47\}\"
@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.
# File lib/sonarqube-client/projects.rb, line 45
def search_by_index index
  JSON.parse(@connector["#{@@endpoint}index?format=json&key=#{index}"].get, object_class: OpenStruct)[0]
end
search_by_key(key) click to toggle source

Search for a project using the project key

@param [String] key project key to use in the search
@example puts \"this will return all the project with key \'my:awesome:project\': #\\{search_by_key 'my:awesome:project'\}\"
@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.
# File lib/sonarqube-client/projects.rb, line 54
def search_by_key key
  JSON.parse(@connector["#{@@endpoint}index?format=json&key=#{key}"].get, object_class: OpenStruct)[0]
end