Skip to content

Commit

Permalink
feat(client): add project_languages methode
Browse files Browse the repository at this point in the history
  • Loading branch information
fe80 committed Aug 16, 2024
1 parent d6cf272 commit 40d3b66
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 1 deletion.
13 changes: 12 additions & 1 deletion lib/gitlab/client/projects.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
class Gitlab::Client
# Defines methods related to projects.
# @see https://docs.gitlab.com/ce/api/projects.html
module Projects
module Projects # rubocop:disable Metrics/ModuleLength
# Gets a list of projects owned by the authenticated user.
#
# @example
Expand Down Expand Up @@ -704,5 +704,16 @@ def delete_project_custom_attribute(key, project_id = nil)
def project_deploy_tokens(project, options = {})
get("/projects/#{url_encode project}/deploy_tokens", query: options)
end

# Get languages used with percentage value
#
# @example
# Gitlab.project_languages(42)
#
# @param [Integer, String] id The ID or path of a project.
# @return [Gitlab::ObjectifiedHash]
def project_languages(project)
get("/projects/#{url_encode project}/languages")
end
end
end
1 change: 1 addition & 0 deletions spec/fixtures/project_languages.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"Ruby":99.99,"Shell":0.01}
11 changes: 11 additions & 0 deletions spec/gitlab/client/projects_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -925,4 +925,15 @@
expect(@custom_attributes.first.username).to eq 'gitlab+deploy-token-93'
end
end

describe '.project_languages' do
before do
stub_get('/projects/2/languages', 'project_languages')
@custom_attributes = Gitlab.project_languages(2)
end

it 'Return a GitlabHash with lanagues informations' do
expect(@custom_attributes).to be_a Gitlab::ObjectifiedHash
end
end
end

0 comments on commit 40d3b66

Please sign in to comment.