Add Docs and Fix YARD comments
This commit is contained in:
parent
26053b7bbe
commit
ee6ebc82b6
|
@ -0,0 +1,5 @@
|
|||
_site
|
||||
.sass-cache
|
||||
.jekyll-cache
|
||||
.jekyll-metadata
|
||||
vendor
|
|
@ -0,0 +1,25 @@
|
|||
---
|
||||
permalink: /404.html
|
||||
layout: default
|
||||
---
|
||||
|
||||
<style type="text/css" media="screen">
|
||||
.container {
|
||||
margin: 10px auto;
|
||||
max-width: 600px;
|
||||
text-align: center;
|
||||
}
|
||||
h1 {
|
||||
margin: 30px 0;
|
||||
font-size: 4em;
|
||||
line-height: 1;
|
||||
letter-spacing: -1px;
|
||||
}
|
||||
</style>
|
||||
|
||||
<div class="container">
|
||||
<h1>404</h1>
|
||||
|
||||
<p><strong>Page not found :(</strong></p>
|
||||
<p>The requested page could not be found.</p>
|
||||
</div>
|
|
@ -0,0 +1,30 @@
|
|||
source "https://rubygems.org"
|
||||
# Hello! This is where you manage which Jekyll version is used to run.
|
||||
# When you want to use a different version, change it below, save the
|
||||
# file and run `bundle install`. Run Jekyll with `bundle exec`, like so:
|
||||
#
|
||||
# bundle exec jekyll serve
|
||||
#
|
||||
# This will help ensure the proper Jekyll version is running.
|
||||
# Happy Jekylling!
|
||||
gem "jekyll", "~> 4.0.1"
|
||||
# This is the default theme for new Jekyll sites. You may change this to anything you like.
|
||||
gem "minima", "~> 2.5"
|
||||
# If you want to use GitHub Pages, remove the "gem "jekyll"" above and
|
||||
# uncomment the line below. To upgrade, run `bundle update github-pages`.
|
||||
# gem "github-pages", group: :jekyll_plugins
|
||||
# If you have any plugins, put them here!
|
||||
group :jekyll_plugins do
|
||||
gem "jekyll-feed", "~> 0.12"
|
||||
end
|
||||
|
||||
# Windows and JRuby does not include zoneinfo files, so bundle the tzinfo-data gem
|
||||
# and associated library.
|
||||
install_if -> { RUBY_PLATFORM =~ %r!mingw|mswin|java! } do
|
||||
gem "tzinfo", "~> 1.2"
|
||||
gem "tzinfo-data"
|
||||
end
|
||||
|
||||
# Performance-booster for watching directories on Windows
|
||||
gem "wdm", "~> 0.1.1", :install_if => Gem.win_platform?
|
||||
gem "just-the-docs"
|
|
@ -0,0 +1,90 @@
|
|||
# Welcome to Jekyll!
|
||||
#
|
||||
# This config file is meant for settings that affect your whole blog, values
|
||||
# which you are expected to set up once and rarely edit after that. If you find
|
||||
# yourself editing this file very often, consider using Jekyll's data files
|
||||
# feature for the data you need to update frequently.
|
||||
#
|
||||
# For technical reasons, this file is *NOT* reloaded automatically when you use
|
||||
# 'bundle exec jekyll serve'. If you change this file, please restart the server process.
|
||||
#
|
||||
# If you need help with YAML syntax, here are some quick references for you:
|
||||
# https://learn-the-web.algonquindesign.ca/topics/markdown-yaml-cheat-sheet/#yaml
|
||||
# https://learnxinyminutes.com/docs/yaml/
|
||||
#
|
||||
# Site settings
|
||||
# These are used to personalize your new site. If you look in the HTML files,
|
||||
# you will see them accessed via {{ site.title }}, {{ site.email }}, and so on.
|
||||
# You can create any custom variable you would like, and they will be accessible
|
||||
# in the templates via {{ site.myvariable }}.
|
||||
|
||||
title: Sonarqube Ruby
|
||||
email: marianilucas@gmail.com
|
||||
description: >- # this means to ignore newlines until "baseurl:"
|
||||
Sonarqube is a Ruby wrapper for the Sonarqube API Rest.
|
||||
baseurl: "/" # the subpath of your site, e.g. /blog
|
||||
url: "" # the base hostname & protocol for your site, e.g. http://example.com
|
||||
#twitter_username: jekyllrb
|
||||
github_username: psyreactor
|
||||
|
||||
# Build settings
|
||||
remote_theme: pmarsceill/just-the-docs
|
||||
theme: just-the-docs
|
||||
plugins:
|
||||
- jekyll-feed
|
||||
|
||||
# Exclude from processing.
|
||||
# The following items will not be processed, by default.
|
||||
# Any item listed under the `exclude:` key here will be automatically added to
|
||||
# the internal "default list".
|
||||
#
|
||||
# Excluded items can be processed by explicitly listing the directories or
|
||||
# their entries' file path in the `include:` list.
|
||||
#
|
||||
exclude:
|
||||
- .sass-cache/
|
||||
- .jekyll-cache/
|
||||
- gemfiles/
|
||||
- Gemfile
|
||||
- Gemfile.lock
|
||||
- node_modules/
|
||||
- vendor/bundle/
|
||||
- vendor/cache/
|
||||
- vendor/gems/
|
||||
- vendor/ruby/
|
||||
# Enable or disable the site search
|
||||
# Supports true (default) or false
|
||||
search_enabled: true
|
||||
search:
|
||||
# Split pages into sections that can be searched individually
|
||||
# Supports 1 - 6, default: 2
|
||||
heading_level: 2
|
||||
# Maximum amount of previews per search result
|
||||
# Default: 3
|
||||
previews: 3
|
||||
# Maximum amount of words to display before a matched word in the preview
|
||||
# Default: 5
|
||||
preview_words_before: 5
|
||||
# Maximum amount of words to display after a matched word in the preview
|
||||
# Default: 10
|
||||
preview_words_after: 10
|
||||
# Set the search token separator
|
||||
# Default: /[\s\-/]+/
|
||||
# Example: enable support for hyphenated search words
|
||||
tokenizer_separator: /[\s/]+/
|
||||
# Display the relative url in search results
|
||||
# Supports true (default) or false
|
||||
rel_url: true
|
||||
# Enable or disable the search button that appears in the bottom right corner of every page
|
||||
# Supports true or false (default)
|
||||
button: false
|
||||
|
||||
# Enable or disable heading anchors
|
||||
heading_anchors: true
|
||||
|
||||
# Aux links for the upper right navigation
|
||||
aux_links:
|
||||
"Sonarqube gem on GitHub":
|
||||
- "https://github.com/psyreactor/sonarqube"
|
||||
|
||||
footer_content: "2020 - Psyreactor. Distributed by an <a href=\"https://github.com/psyreactor/sonarqube/tree/master/LICENSE.txt\">BSD license.</a>"
|
|
@ -0,0 +1,29 @@
|
|||
---
|
||||
layout: post
|
||||
title: "Welcome to Jekyll!"
|
||||
date: 2020-08-23 12:22:05 -0300
|
||||
categories: jekyll update
|
||||
---
|
||||
You’ll find this post in your `_posts` directory. Go ahead and edit it and re-build the site to see your changes. You can rebuild the site in many different ways, but the most common way is to run `jekyll serve`, which launches a web server and auto-regenerates your site when a file is updated.
|
||||
|
||||
Jekyll requires blog post files to be named according to the following format:
|
||||
|
||||
`YEAR-MONTH-DAY-title.MARKUP`
|
||||
|
||||
Where `YEAR` is a four-digit number, `MONTH` and `DAY` are both two-digit numbers, and `MARKUP` is the file extension representing the format used in the file. After that, include the necessary front matter. Take a look at the source for this post to get an idea about how it works.
|
||||
|
||||
Jekyll also offers powerful support for code snippets:
|
||||
|
||||
{% highlight ruby %}
|
||||
def print_hi(name)
|
||||
puts "Hi, #{name}"
|
||||
end
|
||||
print_hi('Tom')
|
||||
#=> prints 'Hi, Tom' to STDOUT.
|
||||
{% endhighlight %}
|
||||
|
||||
Check out the [Jekyll docs][jekyll-docs] for more info on how to get the most out of Jekyll. File all bugs/feature requests at [Jekyll’s GitHub repo][jekyll-gh]. If you have questions, you can ask them on [Jekyll Talk][jekyll-talk].
|
||||
|
||||
[jekyll-docs]: https://jekyllrb.com/docs/home
|
||||
[jekyll-gh]: https://github.com/jekyll/jekyll
|
||||
[jekyll-talk]: https://talk.jekyllrb.com/
|
|
@ -0,0 +1,58 @@
|
|||
---
|
||||
permalink: /assets/js/search-data.json
|
||||
---
|
||||
{
|
||||
{%- assign i = 0 -%}
|
||||
{% for page in site.html_pages %}
|
||||
{%- if page.title and page.search_exclude != true -%}
|
||||
{%- assign page_content = page.content -%}
|
||||
{%- assign heading_level = site.search.heading_level | default: 2 -%}
|
||||
{%- for j in (2..heading_level) -%}
|
||||
{%- assign tag = '<h' | append: j -%}
|
||||
{%- assign closing_tag = '</h' | append: j -%}
|
||||
{%- assign page_content = page_content | replace: tag, '<h1' | replace: closing_tag, '</h1' -%}
|
||||
{%- endfor -%}
|
||||
{%- assign parts = page_content | split: '<h1' -%}
|
||||
{%- assign title_found = false -%}
|
||||
{% for part in parts offset: 1 %}
|
||||
{%- assign titleAndContent = part | split: '</h1>' -%}
|
||||
{%- assign title = titleAndContent[0] | replace_first: '>', '<h1>' | split: '<h1>' -%}
|
||||
{%- assign title = title[1] | strip_html -%}
|
||||
{%- assign content = titleAndContent[1] -%}
|
||||
{%- assign url = page.url -%}
|
||||
{%- if title == page.title and parts[0] == '' -%}
|
||||
{%- assign title_found = true -%}
|
||||
{%- else -%}
|
||||
{%- assign id = titleAndContent[0] -%}
|
||||
{%- assign id = id | split: 'id="' -%}
|
||||
{%- if id.size == 2 -%}
|
||||
{%- assign id = id[1] -%}
|
||||
{%- assign id = id | split: '"' -%}
|
||||
{%- assign id = id[0] -%}
|
||||
{%- capture url -%}{{ url | append: '#' | append: id }}{%- endcapture -%}
|
||||
{%- endif -%}
|
||||
{%- endif -%}
|
||||
{%- unless i == 0 -%},{%- endunless -%}
|
||||
"{{ i }}": {
|
||||
"doc": {{ page.title | jsonify }},
|
||||
"title": {{ title | jsonify }},
|
||||
"content": {{ content | replace: '</h', ' . </h' | replace: '<hr', ' . <hr' | replace: '</p', ' . </p' | replace: '<ul', ' . <ul' | replace: '</ul', ' . </ul' | replace: '<ol', ' . <ol' | replace: '</ol', ' . </ol' | replace: '</tr', ' . </tr' | replace: '<li', ' | <li' | replace: '</li', ' | </li' | replace: '</td', ' | </td' | replace: '<td', ' | <td' | replace: '</th', ' | </th' | replace: '<th', ' | <th' | strip_html | remove: 'Table of contents' | normalize_whitespace | replace: '. . .', '.' | replace: '. .', '.' | replace: '| |', '|' | append: ' ' | jsonify }},
|
||||
"url": "{{ url | absolute_url }}",
|
||||
"relUrl": "{{ url }}"
|
||||
}
|
||||
{%- assign i = i | plus: 1 -%}
|
||||
{%- endfor -%}
|
||||
{%- unless title_found -%}
|
||||
{%- unless i == 0 -%},{%- endunless -%}
|
||||
"{{ i }}": {
|
||||
"doc": {{ page.title | jsonify }},
|
||||
"title": {{ page.title | jsonify }},
|
||||
"content": {{ parts[0] | replace: '</h', ' . </h' | replace: '<hr', ' . <hr' | replace: '</p', ' . </p' | replace: '<ul', ' . <ul' | replace: '</ul', ' . </ul' | replace: '<ol', ' . <ol' | replace: '</ol', ' . </ol' | replace: '</tr', ' . </tr' | replace: '<li', ' | <li' | replace: '</li', ' | </li' | replace: '</td', ' | </td' | replace: '<td', ' | <td' | replace: '</th', ' | </th' | replace: '<th', ' | <th' | strip_html | remove: 'Table of contents' | normalize_whitespace | replace: '. . .', '.' | replace: '. .', '.' | replace: '| |', '|' | append: ' ' | jsonify }},
|
||||
"url": "{{ page.url | absolute_url }}",
|
||||
"relUrl": "{{ page.url }}"
|
||||
}
|
||||
{%- assign i = i | plus: 1 -%}
|
||||
{%- endunless -%}
|
||||
{%- endif -%}
|
||||
{% endfor %}
|
||||
}
|
|
@ -0,0 +1,100 @@
|
|||
---
|
||||
layout: default
|
||||
title: Groups
|
||||
nav_order: 2
|
||||
parent: Client
|
||||
---
|
||||
|
||||
<details close markdown="block">
|
||||
<summary>
|
||||
Table of contents
|
||||
</summary>
|
||||
{: .text-delta }
|
||||
1. TOC
|
||||
{:toc}
|
||||
</details>
|
||||
|
||||
# Groups
|
||||
|
||||
## Create Group
|
||||
```ruby
|
||||
group = Sonarqube.create_group('New-Group', {description: 'Sonarqube group users'})
|
||||
# => #<Sonarqube::ObjectifiedHash:46500 {hash: {"group"=>{"uuid"=>"AXQYrrgCsrvdoo0YodNM", "organization"=>"default-organization", "name"=>"New-Group", "description"=>"Sonarqube group users", "membersCount"=>0, "default"=>false}}}
|
||||
group.group.uuid
|
||||
# AXQYrrgCsrvdoo0YodNM
|
||||
group.group.description
|
||||
# Sonarqube group users
|
||||
```
|
||||
|
||||
## Delete Group
|
||||
```ruby
|
||||
group = Sonarqube.group_delete('New-Group')
|
||||
# => #<Sonarqube::ObjectifiedHash:46220 {hash: {}}
|
||||
group.to_hash.empty?
|
||||
# => true
|
||||
```
|
||||
|
||||
## Search Group
|
||||
```ruby
|
||||
groups = Sonarqube.search_groups({ q: 'sonar-users' })
|
||||
# => #<Sonarqube::ObjectifiedHash:46520 {hash: {"paging"=>{"pageIndex"=>1, "pageSize"=>100, "total"=>1}, "groups"=>[{"uuid"=>"AXOt93S3gMZPhbn-E_O7", "name"=>"sonar-users", "description"=>"Any new users created will automatically join this group", "membersCount"=>5, "default"=>true}]}}
|
||||
groups.groups.each do | group |
|
||||
puts "name: #{group.name}"
|
||||
puts "description: #{group.description}"
|
||||
puts "membersCount: #{group.membersCount}"
|
||||
end
|
||||
# name: sonar-users
|
||||
# description: Any new users created will automatically join this group
|
||||
# MembersCount: 5
|
||||
```
|
||||
|
||||
## Update Group
|
||||
```ruby
|
||||
group = Sonarqube.group_members('AXQRcKrW9pRiZzanEJ2E', { description: 'update group description' })
|
||||
# => #<Sonarqube::ObjectifiedHash:46080 {hash: {"group"=>{"uuid"=>"AXQRcKrW9pRiZzanEJ2E", "organization"=>"default-organization", "name"=>"Sonarqube-Group", "description"=>"update group description'", "membersCount"=>0, "default"=>false}}}
|
||||
group.group.uuid
|
||||
# AXQRcKrW9pRiZzanEJ2E
|
||||
group.group.description
|
||||
# update group description
|
||||
```
|
||||
## Add Member
|
||||
```ruby
|
||||
group = Sonarqube.add_member('AXQRcKrW9pRiZzanEJ2E', 'test-user')
|
||||
# => #<Sonarqube::ObjectifiedHash:46220 {hash: {}}
|
||||
group.to_hash.empty?
|
||||
# => true
|
||||
group = Sonarqube.add_member('AXQRcKrW9pRiZzanEJ2E', 'test-user', {name: 'sonar-groups'})
|
||||
# => #<Sonarqube::ObjectifiedHash:46220 {hash: {}}
|
||||
group.to_hash.empty?
|
||||
# => true
|
||||
```
|
||||
|
||||
## Remove Member
|
||||
```ruby
|
||||
group = Sonarqube.remove_member('AXQRcKrW9pRiZzanEJ2E', 'test-user')
|
||||
# => #<Sonarqube::ObjectifiedHash:46220 {hash: {}}
|
||||
group.to_hash.empty?
|
||||
# => true
|
||||
group = Sonarqube.remove_member('AXQRcKrW9pRiZzanEJ2E', 'test-user', {name: 'sonar-groups'})
|
||||
# => #<Sonarqube::ObjectifiedHash:46220 {hash: {}}
|
||||
group.to_hash.empty?
|
||||
# => true
|
||||
```
|
||||
|
||||
## List Members
|
||||
```ruby
|
||||
group = Sonarqube.list_members({name: 'sonar-groups'})
|
||||
# => #<Sonarqube::ObjectifiedHash:46080 {hash: {"users"=>[{"login"=>"admin", "name"=>"Administrator", "selected"=>true}, {"login"=>"new_user", "name"=>"key_new_user", "selected"=>true}, {"login"=>"login_name", "name"=>"name_user", "selected"=>true}, {"login"=>"newlogin", "name"=>"test QA", "selected"=>true}, {"login"=>"test4", "name"=>"user test", "selected"=>true}], "p"=>1, "ps"=>25, "total"=>5}}
|
||||
groups.users.each do | user |
|
||||
puts "name: #{user.name}"
|
||||
puts "login: #{user.login}"
|
||||
end
|
||||
# name: Administrator
|
||||
# login: admin
|
||||
# name: name_user
|
||||
# login: login_name
|
||||
# name: test QA
|
||||
# login: newlogin
|
||||
# name: user test
|
||||
# login: test4
|
||||
```
|
|
@ -0,0 +1,15 @@
|
|||
---
|
||||
layout: default
|
||||
title: Client
|
||||
nav_order: 3
|
||||
has_children: true
|
||||
---
|
||||
|
||||
# Client Api
|
||||
|
||||
The Sonarqube gem attempts to make the Sonarqube API as object-oriented and Ruby-like as possible. All of the methods and API calls are heavily documented with examples inline using YARD.
|
||||
In order to keep the examples versioned with the code, this documentation only lists a few examples for using the Sonarqube gem. Please see the inline documentation for the full API documentation
|
||||
|
||||
|
||||
{: .fs-6 .fw-300 }
|
||||
|
|
@ -0,0 +1,74 @@
|
|||
---
|
||||
layout: default
|
||||
title: Projects
|
||||
nav_order: 3
|
||||
parent: Client
|
||||
---
|
||||
|
||||
<details close markdown="block">
|
||||
<summary>
|
||||
Table of contents
|
||||
</summary>
|
||||
{: .text-delta }
|
||||
1. TOC
|
||||
{:toc}
|
||||
</details>
|
||||
|
||||
|
||||
# Projects
|
||||
|
||||
## Create Project
|
||||
```ruby
|
||||
project = Sonarqube.project_create('new_project')
|
||||
# => <Sonarqube::ObjectifiedHash:46200 {hash: {"project"=>{"key"=>"new_project", "name"=>"new_project", "qualifier"=>"TRK", "visibility"=>"public"}}}
|
||||
project.project.key
|
||||
# => "new_project"
|
||||
project.to_hash
|
||||
# => {"project"=>{"key"=>"new_project", "name"=>"new_project", "qualifier"=>"TRK", "visibility"=>"public"}}
|
||||
```
|
||||
|
||||
## Delete Project
|
||||
```ruby
|
||||
project = Sonarqube.project_delete('test')
|
||||
# => #<Sonarqube::ObjectifiedHash:46220 {hash: {}}
|
||||
project.to_hash.empty?
|
||||
# => true
|
||||
```
|
||||
|
||||
## Search Project
|
||||
```ruby
|
||||
projects = Sonarqube.project_search()
|
||||
# => #<Sonarqube::ObjectifiedHash:46240 {hash: {"paging"=>{"pageIndex"=>1, "pageSize"=>100, "total"=>2}, "components"=>[{"organization"=>"default-organization", "key"=>"old_key", "name"=>"new_proyect", "qualifier"=>"TRK", "visibility"=>"private"}, {"organization"=>"default-organization", "key"=>"test", "name"=>"test", "qualifier"=>"TRK", "visibility"=>"public"}]}}
|
||||
projects.components.each do | project |
|
||||
puts "name: #{project.name}"
|
||||
puts "key: #{project.key}"
|
||||
end
|
||||
# name: new_proyect
|
||||
# key: old_key
|
||||
# name: test
|
||||
# key: test
|
||||
```
|
||||
|
||||
## Update project key.
|
||||
```ruby
|
||||
Sonarqube.project_update_key('key_ori', 'key_new')
|
||||
# => #<Sonarqube::ObjectifiedHash:46220 {hash: {}}
|
||||
project.to_hash.empty?
|
||||
# => true
|
||||
```
|
||||
|
||||
## Update project visibility.
|
||||
```ruby
|
||||
Sonarqube.project_update_visibility('sonarqube', 'public')
|
||||
# => #<Sonarqube::ObjectifiedHash:46220 {hash: {}}
|
||||
project.to_hash.empty?
|
||||
# => true
|
||||
```
|
||||
|
||||
## Bulk delete projects.
|
||||
```ruby
|
||||
projects = Sonarqube.projects_bulk_delete({projects: 'new_proyect'})
|
||||
# => #<Sonarqube::ObjectifiedHash:46220 {hash: {}}
|
||||
project.to_hash.empty?
|
||||
# => true
|
||||
```
|
|
@ -0,0 +1,90 @@
|
|||
---
|
||||
layout: default
|
||||
title: Users
|
||||
nav_order: 1
|
||||
parent: Client
|
||||
---
|
||||
|
||||
<details close markdown="block">
|
||||
<summary>
|
||||
Table of contents
|
||||
</summary>
|
||||
{: .text-delta }
|
||||
1. TOC
|
||||
{:toc}
|
||||
</details>
|
||||
|
||||
# Users
|
||||
|
||||
## Create User
|
||||
```ruby
|
||||
user = Sonarqube.user_create('new_user', 'key_new_user' ,'secretpassword')
|
||||
# => #<Sonarqube::ObjectifiedHash:46320 {hash: {"user"=>{"login"=>"login_name", "name"=>"name_user", "scmAccounts"=>[], "active"=>true, "local"=>true}}}
|
||||
user.user.login
|
||||
# login_name
|
||||
user.user.name
|
||||
# name_user
|
||||
```
|
||||
|
||||
## Update User
|
||||
```ruby
|
||||
user = Sonarqube.update_user('test', { email: 'test@example.com', name: 'user test' })
|
||||
# => #<Sonarqube::ObjectifiedHash:46080 {hash: {"user"=>{"login"=>"test", "name"=>"user test", "email"=>"test@example.com", "active"=>true, "local"=>true, "externalIdentity"=>"test", "externalProvider"=>"sonarqube", "groups"=>[], "scmAccounts"=>[]}}}
|
||||
user.user.login
|
||||
# test
|
||||
user.user.name
|
||||
# 'user test'
|
||||
```
|
||||
|
||||
## Search User
|
||||
```ruby
|
||||
users = Sonarqube.users_search()
|
||||
# => #<Sonarqube::ObjectifiedHash:46340 {hash: {"paging"=>{"pageIndex"=>1, "pageSize"=>50, "total"=>5}, "users"=>[{"login"=>"admin", "name"=>"Administrator", "active"=>true, "groups"=>["sonar-administrators", "sonar-users"], "tokensCount"=>1, "local"=>true, "externalIdentity"=>"admin", "externalProvider"=>"sonarqube", "lastConnectionDate"=>"2020-08-22T23:09:14+0000"}, {"login"=>"new_user", "name"=>"key_new_user", "active"=>true, "groups"=>["sonar-users"], "tokensCount"=>0, "local"=>true, "externalIdentity"=>"new_user", "externalProvider"=>"sonarqube"}, {"login"=>"login_name", "name"=>"name_user", "active"=>true, "groups"=>["sonar-users"], "tokensCount"=>0, "local"=>true, "externalIdentity"=>"login_name", "externalProvider"=>"sonarqube"}, {"login"=>"test3", "name"=>"test QA", "active"=>true, "groups"=>["sonar-users"], "tokensCount"=>0, "local"=>true, "externalIdentity"=>"test3", "externalProvider"=>"sonarqube"}, {"login"=>"newlogin", "name"=>"test QA", "active"=>true, "groups"=>["sonar-users"], "tokensCount"=>0, "local"=>true, "externalIdentity"=>"newlogin", "externalProvider"=>"sonarqube"}]}}
|
||||
users.users.each do | user |
|
||||
puts "name: #{user.name}"
|
||||
puts "login: #{user.login}"
|
||||
puts "lastConection: #{user.lastConnectionDate}" if defined? user.lastConnectionDate
|
||||
end
|
||||
# name: Administrator
|
||||
# login: admin
|
||||
# lastConection: 2020-08-22T23:09:14+0000
|
||||
# name: key_new_user
|
||||
# login: new_user
|
||||
# name: name_user
|
||||
# login: login_name
|
||||
# name: test QA
|
||||
# login: test3
|
||||
# name: test QA
|
||||
# login: newlogin
|
||||
```
|
||||
## Deactivate User
|
||||
```ruby
|
||||
user = Sonarqube.deactivate_user('test')
|
||||
# => #<Sonarqube::ObjectifiedHash:46080 {hash: {"user"=>{"login"=>"test", "name"=>"user test", "email"=>"test@example.com", "active"=>false, "local"=>true, "externalIdentity"=>"test", "externalProvider"=>"sonarqube", "groups"=>[], "scmAccounts"=>[]}}}
|
||||
user.user.login
|
||||
# test
|
||||
user.user.active
|
||||
# false
|
||||
```
|
||||
|
||||
## Change Password User
|
||||
```ruby
|
||||
user = Sonarqube.change_password_user('joe', 'password')
|
||||
# => #<Sonarqube::ObjectifiedHash:46080 {hash: {"user"=>{"login"=>"joe", "name"=>"joe testing", "email"=>"test@example.com", "active"=>false, "local"=>true, "externalIdentity"=>"test", "externalProvider"=>"sonarqube", "groups"=>[], "scmAccounts"=>[]}}}
|
||||
user.user.login
|
||||
# test
|
||||
user.user.active
|
||||
# true
|
||||
|
||||
# For own user send old_passwod
|
||||
user = Sonarqube.change_password_user('admin', 'password', 'old_password')
|
||||
# => #<Sonarqube::ObjectifiedHash:46080 {hash: {"user"=>{"login"=>"admin", "name"=>"Sonarqube Admin", "email"=>"admin@example.com", "active"=>false, "local"=>true, "externalIdentity"=>"test", "externalProvider"=>"sonarqube", "groups"=>[], "scmAccounts"=>[]}}}
|
||||
```
|
||||
|
||||
## Update Login User.
|
||||
```ruby
|
||||
user = update_login_user(login, new_login, options = {})
|
||||
# => #<Sonarqube::ObjectifiedHash:46220 {hash: {}}
|
||||
user.to_hash.empty?
|
||||
# => true
|
||||
```
|
|
@ -0,0 +1,83 @@
|
|||
---
|
||||
# Feel free to add content and custom Front Matter to this file.
|
||||
# To modify the layout, see https://jekyllrb.com/docs/themes/#overriding-theme-defaults
|
||||
layout: page
|
||||
title: Configuration
|
||||
permalink: /config
|
||||
nav_order: 2
|
||||
---
|
||||
|
||||
# Configuration
|
||||
|
||||
## Create a connection
|
||||
|
||||
Before you can make a request, you must give Sonarqube your connection information.
|
||||
|
||||
```ruby
|
||||
Sonarqube.configure do |config|
|
||||
config.endpoint = 'https://example.net:9000' # API endpoint URL, default: ENV['SONARQUBE_API_ENDPOINT']
|
||||
config.private_token = 'Dfrt938dSgAOWd4' # user's private token, default: ENV['SONARQUBE_API_PRIVATE_TOKEN']
|
||||
# Optional
|
||||
# config.user_agent = 'Custom User Agent' # user agent, default: 'Sonarqube Ruby Gem [version]'
|
||||
# config.httparty = { } # Parameters config for httparty
|
||||
end
|
||||
```
|
||||
|
||||
|
||||
## SSL config disabled
|
||||
```ruby
|
||||
Sonarqube.configure do |config|
|
||||
config.endpoint = 'https://example.net:9000' # API endpoint URL, default: ENV['SONARQUBE_API_ENDPOINT']
|
||||
config.private_token = 'Dfrt938dSgAOWd4' # user's private token, default: ENV['SONARQUBE_API_PRIVATE_TOKEN']
|
||||
# Optional
|
||||
config.user_agent = 'Sonarqube Gem Agent' # user agent, default: 'Sonarqube Ruby Gem [version]'
|
||||
config.httparty = { verify: false } # Parameters config for httparty
|
||||
end
|
||||
httparty:
|
||||
)
|
||||
```
|
||||
|
||||
All of these parameters are also configurable via the top-level Sonarqube object.
|
||||
|
||||
## Top-level Sonarqube Object
|
||||
```ruby
|
||||
# set an API endpoint
|
||||
Sonarqube.endpoint = 'https://example.net:9000'
|
||||
# => "https://example.net:9000"
|
||||
|
||||
# set a user private token
|
||||
Sonarqube.private_token = 'Dfrt938dSgAOWd4'
|
||||
# => "Dfrt938dSgAOWd4"
|
||||
# disable ssl verify
|
||||
Sonarqube.httparty = { verify: false }
|
||||
|
||||
# configure a proxy server
|
||||
Sonarqube.http_proxy('proxyhost', 8888)
|
||||
# proxy server with basic auth
|
||||
Sonarqube.http_proxy('proxyhost', 8888, 'proxyuser', 'strongpasswordhere')
|
||||
```
|
||||
|
||||
Or, if you want to be really Unixy, these parameters are all configurable via environment variables:
|
||||
|
||||
## Sonarqube will use these env
|
||||
|
||||
```
|
||||
ENV['SONARQUBE_API_ENDPOINT'] = 'https://example.com:9000'
|
||||
ENV['SONARQUBE_API_PRIVATE_TOKEN'] = 'Dfrt938dSgAOWd4'
|
||||
ENV['SONARQUBE_API_HTTPARTY_OPTIONS'] = '{read_timeout: 60}'
|
||||
```
|
||||
You can also create a full Client object with hash parameters:
|
||||
|
||||
|
||||
## object with hash parameters
|
||||
|
||||
```ruby
|
||||
sonar = Sonarqube.client(
|
||||
endpoint: 'https://example.com:9000',
|
||||
private_token: 'Dfrt938dSgAOWd4',
|
||||
httparty: {
|
||||
headers: { 'Cookie' => 'sonarqube_canary=true' }
|
||||
}
|
||||
)
|
||||
# => #<Sonarqube::Client:0x00000001e62408 @endpoint="https://api.example.com", @private_token="Dfrt938dSgAOWd4", @user_agent="Sonarqube Ruby Gem 2.0.0">
|
||||
```
|
|
@ -0,0 +1,201 @@
|
|||
---
|
||||
layout: page
|
||||
title: Contributing
|
||||
nav_order: 4
|
||||
---
|
||||
|
||||
# Contributing to Sonarqube
|
||||
|
||||
Please take a moment to review this document in order to make the contribution
|
||||
process easy and effective for everyone involved!
|
||||
|
||||
## Using the issue tracker
|
||||
|
||||
You can use the issues tracker for:
|
||||
|
||||
* [bug reports](#bug-reports)
|
||||
* [feature requests](#feature-requests)
|
||||
* [submitting pull requests](#pull-requests)
|
||||
|
||||
Use [Stackoverflow](http://stackoverflow.com/) for questions and personal support requests.
|
||||
|
||||
## Bug reports
|
||||
|
||||
A bug is a _demonstrable problem_ that is caused by the code in the repository.
|
||||
Good bug reports are extremely helpful - thank you!
|
||||
|
||||
Guidelines for bug reports:
|
||||
|
||||
1. **Use the GitHub issue search** — check if the issue has already been
|
||||
reported.
|
||||
|
||||
2. **Check if the issue has been fixed** — try to reproduce it using the
|
||||
`master` branch in the repository.
|
||||
|
||||
3. **Isolate and report the problem** — ideally create a reduced test
|
||||
case.
|
||||
|
||||
Please try to be as detailed as possible in your report. Include information about
|
||||
your Ruby, Sonarqube client and Sonarqube instance versions. Please provide steps to
|
||||
reproduce the issue as well as the outcome you were expecting! All these details
|
||||
will help developers to fix any potential bugs.
|
||||
|
||||
Example:
|
||||
|
||||
> Short and descriptive example bug report title
|
||||
>
|
||||
> A summary of the issue and the environment in which it occurs. If suitable,
|
||||
> include the steps required to reproduce the bug.
|
||||
>
|
||||
> 1. This is the first step
|
||||
> 2. This is the second step
|
||||
> 3. Further steps, etc.
|
||||
>
|
||||
> Any other information you want to share that is relevant to the issue being
|
||||
> reported. This might include the lines of code that you have identified as
|
||||
> causing the bug, and potential solutions (and your opinions on their
|
||||
> merits).
|
||||
|
||||
## Feature requests
|
||||
|
||||
Feature requests are welcome. But take a moment to find out whether your idea
|
||||
fits with the scope and aims of the project. It's up to *you* to make a strong
|
||||
case to convince the community of the merits of this feature.
|
||||
Please provide as much detail and context as possible.
|
||||
|
||||
## Contributing Documentation
|
||||
|
||||
Code documentation has a special convention: it uses [YARD](http://yardoc.org/)
|
||||
formatting and the first paragraph is considered to be a short summary.
|
||||
|
||||
For methods say what it will do. For example write something like:
|
||||
|
||||
```ruby
|
||||
# Reverses the contents of a String or IO object.
|
||||
#
|
||||
# @param [String, #read] contents the contents to reverse
|
||||
# @return [String] the contents reversed lexically
|
||||
def reverse(contents)
|
||||
contents = contents.read if contents.respond_to? :read
|
||||
contents.reverse
|
||||
end
|
||||
```
|
||||
|
||||
For classes, modules say what it is. For example write something like:
|
||||
|
||||
```ruby
|
||||
# Defines methods related to groups.
|
||||
module Groups
|
||||
```
|
||||
|
||||
Keep in mind that the documentation notes might show up in a summary somewhere,
|
||||
long texts in the documentation notes create very ugly summaries. As a rule of thumb
|
||||
anything longer than 80 characters is too long.
|
||||
|
||||
Try to keep unnecessary details out of the first paragraph, it's only there to
|
||||
give a user a quick idea of what the documented "thing" does/is. The rest of the
|
||||
documentation notes can contain the details, for example parameters and what
|
||||
is returned.
|
||||
|
||||
If possible include examples. For example:
|
||||
|
||||
```ruby
|
||||
# Gets information about a project.
|
||||
#
|
||||
# @example
|
||||
# Sonarqube.project(3)
|
||||
# Sonarqube.project('sonarqube')
|
||||
#
|
||||
# @param [Integer, String] id The ID or name of a project.
|
||||
# @return [Sonarqube::ObjectifiedHash]
|
||||
def project(id)
|
||||
```
|
||||
|
||||
This makes it easy to test the examples so that they don't go stale and examples
|
||||
are often a great help in explaining what a method does.
|
||||
|
||||
## Pull requests
|
||||
|
||||
Good pull requests - patches, improvements, new features - are a fantastic
|
||||
help. They should remain focused in scope and avoid containing unrelated
|
||||
commits.
|
||||
|
||||
**IMPORTANT**: By submitting a patch, you agree that your work will be
|
||||
licensed under the license used by the project.
|
||||
|
||||
If you have any large pull request in mind (e.g. implementing features,
|
||||
refactoring code, etc), **please ask first** otherwise you risk spending
|
||||
a lot of time working on something that the project's developers might
|
||||
not want to merge into the project.
|
||||
|
||||
Please adhere to the coding conventions in the project (indentation,
|
||||
accurate comments, etc.) and don't forget to add your own tests and
|
||||
documentation. When working with git, we recommend the following process
|
||||
in order to craft an excellent pull request:
|
||||
|
||||
1. [Fork](https://help.github.com/articles/fork-a-repo/) the project, clone your fork,
|
||||
and configure the remotes:
|
||||
|
||||
```sh
|
||||
# Clone your fork of the repo into the current directory
|
||||
git clone https://github.com/<your-username>/sonarqube
|
||||
# Navigate to the newly cloned directory
|
||||
cd sonarqube
|
||||
# Assign the original repo to a remote called "upstream"
|
||||
git remote add upstream https://github.com/psyreactor/sonarqube
|
||||
```
|
||||
|
||||
2. If you cloned a while ago, get the latest changes from upstream:
|
||||
|
||||
```bash
|
||||
git checkout master
|
||||
git pull upstream master
|
||||
```
|
||||
|
||||
3. Create a new topic branch (off of `master`) to contain your feature, change,
|
||||
or fix.
|
||||
|
||||
**IMPORTANT**: Making changes in `master` is discouraged. You should always
|
||||
keep your local `master` in sync with upstream `master` and make your
|
||||
changes in topic branches.
|
||||
|
||||
```sh
|
||||
git checkout -b <topic-branch-name>
|
||||
```
|
||||
|
||||
4. Commit your changes in logical chunks. Keep your commit messages organized,
|
||||
with a short description in the first line and more detailed information on
|
||||
the following lines. Feel free to use Git's
|
||||
[interactive rebase](https://help.github.com/articles/about-git-rebase/)
|
||||
feature to tidy up your commits before making them public.
|
||||
|
||||
5. Make sure all the tests are still passing.
|
||||
|
||||
```sh
|
||||
rake
|
||||
```
|
||||
|
||||
6. Push your topic branch up to your fork:
|
||||
|
||||
```sh
|
||||
git push origin <topic-branch-name>
|
||||
```
|
||||
|
||||
7. [Open a Pull Request](https://help.github.com/articles/using-pull-requests/)
|
||||
with a clear title and description.
|
||||
|
||||
8. If you haven't updated your pull request for a while, you should consider
|
||||
rebasing on master and resolving any conflicts.
|
||||
|
||||
**IMPORTANT**: _Never ever_ merge upstream `master` into your branches. You
|
||||
should always `git rebase` on `master` to bring your changes up to date when
|
||||
necessary.
|
||||
|
||||
```sh
|
||||
git checkout master
|
||||
git pull upstream master
|
||||
git checkout <your-topic-branch>
|
||||
git rebase master
|
||||
```
|
||||
|
||||
Thank you for your contributions!
|
|
@ -0,0 +1,35 @@
|
|||
---
|
||||
# Feel free to add content and custom Front Matter to this file.
|
||||
# To modify the layout, see https://jekyllrb.com/docs/themes/#overriding-theme-defaults
|
||||
layout: page
|
||||
title: Install
|
||||
permalink: /
|
||||
nav_order: 1
|
||||
---
|
||||
|
||||
# Sonarqube
|
||||
|
||||
[![Build Status](https://img.shields.io/github/workflow/status/psyreactor/sonarqube/CI/master)](https://github.com/psyreactor/sonarqube/actions?query=workflow%3ARuby)
|
||||
[![Inline docs](https://inch-ci.org/github/psyreactor/sonarqube.svg)](https://inch-ci.org/github/psyreactor/sonarqube)
|
||||
[![Gem version](https://img.shields.io/gem/v/sonarqube.svg)](https://rubygems.org/gems/sonarqube)
|
||||
[![License](https://img.shields.io/badge/license-BSD-red.svg)](https://github.com/psyreactor/sonarqube/blob/master/LICENSE.txt)
|
||||
|
||||
[website](https://psyreactor.github.io/sonarqube) |
|
||||
[documentation](https://www.rubydoc.info/gems/sonarqube/frames)
|
||||
|
||||
Sonarqube is a Ruby wrapper for the Sonarqube API this gem only supports Sonarqube 7.9.
|
||||
|
||||
## Installation
|
||||
|
||||
Install it from rubygems:
|
||||
|
||||
```sh
|
||||
gem install sonarqube
|
||||
```
|
||||
|
||||
Or add to a Gemfile:
|
||||
|
||||
```ruby
|
||||
gem 'sonarqube'
|
||||
# gem 'sonarqube', github: 'psyreactor/sonarqube'
|
||||
```
|
|
@ -29,7 +29,7 @@ class Sonarqube::Client
|
|||
# Sonarqube.create_group('new-group')
|
||||
# Sonarqube.create_group('sonarqube', { description: 'New Sonarqube project' })
|
||||
#
|
||||
# @param [String] name(required) The name of a group.
|
||||
# @param [String] name (required) The name of a group.
|
||||
# @param [Hash] options A customizable set of options.
|
||||
# @option options [String] :description Description for the new group. A group description cannot be larger than 200 characters.
|
||||
# @return [Sonarqube::ObjectifiedHash] Information about created group.
|
||||
|
@ -44,7 +44,7 @@ class Sonarqube::Client
|
|||
# @example
|
||||
# Sonarqube.delete_group('projecto')
|
||||
#
|
||||
# @param [String] name(required) The name of a group
|
||||
# @param [String] name (required) The name of a group
|
||||
# @return [Sonarqube::ObjectifiedHash] Empty hash response.
|
||||
def delete_group(name)
|
||||
post('/api/user_groups/delete', body: { name: name })
|
||||
|
@ -57,7 +57,7 @@ class Sonarqube::Client
|
|||
# Sonarqube.group_members('AXQRcKrW9pRiZzanEJ2E')
|
||||
# Sonarqube.group_members('AXQRcKrW9pRiZzanEJ2E, { description: 'update group description })
|
||||
#
|
||||
# @param [String] id(required) The ID of a group.
|
||||
# @param [String] id (required) The ID of a group.
|
||||
# @param [Hash] options A customizable set of options.
|
||||
# @option options [String] :description New optional description for the group. A group description cannot be larger than 200 characters. If value is not defined, then description is not changed.
|
||||
# @option options [String] :name New optional name for the group. A group name cannot be larger than 255 characters and must be unique. Value 'anyone' (whatever the case) is reserved and cannot be used. If value is empty or not defined, then name is not changed.
|
||||
|
@ -73,8 +73,8 @@ class Sonarqube::Client
|
|||
# Sonarqube.add_member('AXQRcKrW9pRiZzanEJ2E', 'test-user')
|
||||
# Sonarqube.add_member('AXQRcKrW9pRiZzanEJ2E', 'test-user', {name: 'sonar-groups'})
|
||||
#
|
||||
# @param [String] id(required) The id of group.
|
||||
# @param [String] login(required) The login of user.
|
||||
# @param [String] id (required) The id of group.
|
||||
# @param [String] login (required) The login of user.
|
||||
# @param [Hash] options A customizable set of options.
|
||||
# @option options [String] :name Optional name of group.
|
||||
# @return [Sonarqube::ObjectifiedHash]
|
||||
|
@ -85,14 +85,14 @@ class Sonarqube::Client
|
|||
end
|
||||
alias member_add add_member
|
||||
|
||||
# Reomve a user to a group.
|
||||
# Remove a user to a group.
|
||||
#
|
||||
# @example
|
||||
# Sonarqube.remove_member('AXQRcKrW9pRiZzanEJ2E', 'test-user')
|
||||
# Sonarqube.remove_member('AXQRcKrW9pRiZzanEJ2E', 'test-user', {name: 'sonar-groups'})
|
||||
#
|
||||
# @param [String] id(required) The id of group.
|
||||
# @param [String] login(required) The login of user.
|
||||
# @param [String] id (required) The id of group.
|
||||
# @param [String] login (required) The login of user.
|
||||
# @param [Hash] options A customizable set of options.
|
||||
# @option options [String] :name Optional name of group.
|
||||
# @return [Sonarqube::ObjectifiedHash]
|
||||
|
@ -110,8 +110,8 @@ class Sonarqube::Client
|
|||
# Sonarqube.list_members({name: 'sonar-groups'})
|
||||
#
|
||||
# @param [Hash] options A customizable set of options.
|
||||
# @option options [String] :name(required) Name of group.
|
||||
# @option options [String] :id(required) Id of group.
|
||||
# @option options [String] :name (required) Name of group.
|
||||
# @option options [String] :id (required) Id of group.
|
||||
# @return [Sonarqube::ObjectifiedHash] Information about added team member.
|
||||
def list_members(options = {})
|
||||
raise ArgumentError, 'Missing required parameters' if options[:id].nil? && options[:name].nil?
|
||||
|
|
|
@ -55,7 +55,7 @@ class Sonarqube::Client
|
|||
end
|
||||
|
||||
alias project_delete delete_project
|
||||
# Gets a list of project hooks.
|
||||
# Update project key.
|
||||
#
|
||||
# @example
|
||||
# Sonarqube.project_update_key(42)
|
||||
|
@ -69,11 +69,10 @@ class Sonarqube::Client
|
|||
end
|
||||
|
||||
alias update_key_project project_update_key
|
||||
# Gets a project hook.
|
||||
# Update project visibility.
|
||||
#
|
||||
# @example
|
||||
# Sonarqube.project_hook(42, 5)
|
||||
# Sonarqube.project_hook('sonarqube', 5)
|
||||
# project_update_visibility('sonarqube', 'public')
|
||||
#
|
||||
# @param [String] project The name fo project.
|
||||
# @param [String] visibility The visibility of a project.
|
||||
|
|
|
@ -29,9 +29,9 @@ class Sonarqube::Client
|
|||
# or
|
||||
# Sonarqube.create_user('joe', 'joe', 'secret')
|
||||
#
|
||||
# @param [String] name(required) The name of a user.
|
||||
# @param [String] login(required) The login of a user.
|
||||
# @param [String] password(required only is local user) The password of a user.
|
||||
# @param [String] name (required) The name of a user.
|
||||
# @param [String] login (required) The login of a user.
|
||||
# @param [String] password (required only is local user) The password of a user.
|
||||
# @param [Hash] options A customizable set of options.
|
||||
# @option options [String] :email The emails of a user.
|
||||
# @option options [String] :local Specify if the user should be authenticated from SonarQube server or from an external authentication system. Password should not be set when local is set to false.
|
||||
|
@ -50,7 +50,7 @@ class Sonarqube::Client
|
|||
# @example
|
||||
# Sonarqube.update_user('joe', { email: 'joe.smith@foo.org', name: 'Joe' })
|
||||
#
|
||||
# @param [String] login(required) The login of a user
|
||||
# @param [String] login (required) The login of a user
|
||||
# @param [Hash] options A customizable set of options.
|
||||
# @option options [String] :email The email of a user.
|
||||
# @option options [String] :name The name of a user.
|
||||
|
@ -65,9 +65,9 @@ class Sonarqube::Client
|
|||
# Blocks the specified user. Available only for admin.
|
||||
#
|
||||
# @example
|
||||
# Sonarqube.block_user(15)
|
||||
# Sonarqube.deactivate_user('login')
|
||||
#
|
||||
# @param [String] login(required) The login of a user
|
||||
# @param [String] login (required) The login of a user
|
||||
# @param [Hash] options A customizable set of options.
|
||||
def deactivate_user(login, options = {})
|
||||
post('/api/users/deactivate', body: { login: login }.merge!(options))
|
||||
|
@ -80,9 +80,9 @@ class Sonarqube::Client
|
|||
# Sonarqube.change_password_user('joe', 'password')
|
||||
# Sonarqube.change_password_user('admin', 'password', admin)
|
||||
#
|
||||
# @param [String] login(required) The login of a user
|
||||
# @param [String] password(required) New password for login
|
||||
# @param [String] old_password(optional) Previous password. Required when changing one's own password.
|
||||
# @param [String] login (required) The login of a user
|
||||
# @param [String] password (required) New password for login
|
||||
# @param [String] old_password (optional) Previous password. Required when changing one's own password.
|
||||
# @param [Hash] options A customizable set of options.
|
||||
def change_password_user(login, password, old_password = nil, options = {})
|
||||
body = { login: login, password: password }
|
||||
|
@ -91,13 +91,13 @@ class Sonarqube::Client
|
|||
end
|
||||
|
||||
alias user_change_password change_password_user
|
||||
# Creates a new user session.
|
||||
# Update login user.
|
||||
#
|
||||
# @example
|
||||
# Sonarqube.session('jack@example.com', 'secret12345')
|
||||
# Sonarqube.update_login_user('test', 'new_test')
|
||||
#
|
||||
# @param [String] login(required) The login of a user
|
||||
# @param [String] new_login(required) The new login of a user
|
||||
# @param [String] login (required) The login of a user
|
||||
# @param [String] new_login (required) The new login of a user
|
||||
# @param [Hash] options A customizable set of options.
|
||||
# @return [Sonarqube::ObjectifiedHash]
|
||||
def update_login_user(login, new_login, options = {})
|
||||
|
@ -108,7 +108,7 @@ class Sonarqube::Client
|
|||
# Lists the groups a user belongs to.
|
||||
#
|
||||
# @example
|
||||
# Sonarqube.group_user
|
||||
# Sonarqube.group_user('login')
|
||||
#
|
||||
# @param [String] login A customizable set of options.
|
||||
# @param [Hash] options A customizable set of options.
|
||||
|
|
Loading…
Reference in New Issue