Class: Checklister::Gitlab::Project

Inherits:
Object
  • Object
show all
Defined in:
lib/checklister/gitlab/project.rb

Constant Summary collapse

DEFAULT_OPTIONS =

Default options that we want to pass when querying the gitlab project index

{ order_by: "id", sort: "asc", per_page: "200" }

Instance Method Summary collapse

Constructor Details

#initialize(client) ⇒ Project

Initialize a gitlab project instance

Examples:

Get a project's data

project = Checklister::Project.new(gitlab_client).get(1)

Parameters:

  • client (Object)

    an instance of Checklister::Client



36
37
38
# File 'lib/checklister/gitlab/project.rb', line 36

def initialize(client)
  @client = client
end

Instance Method Details

#all(options = {}) ⇒ Array

Get all gitlab's projects

Parameters:

  • options (optional, Hash) (defaults to: {})

    query options

Returns:

  • (Array)

    and array of project's properties as Hash



50
51
52
53
# File 'lib/checklister/gitlab/project.rb', line 50

def all(options = {})
  query_options = DEFAULT_OPTIONS.merge options
  @client.projects(query_options).map { |p| ProjectDecorator.new(p).to_hash }
end

#filtered_by_name(name, options = {}) ⇒ Array

Get gitlab's projects based on a search string (LIKE on project#name)

Parameters:

  • name (String)

    partial project's name

  • options (optional, Hash) (defaults to: {})

    query options

Returns:

  • (Array)

    and array of project's properties as Hash



59
60
61
62
# File 'lib/checklister/gitlab/project.rb', line 59

def filtered_by_name(name, options = {})
  query_options = DEFAULT_OPTIONS.merge options
  @client.project_search(name, query_options).map { |p| ProjectDecorator.new(p).to_hash }
end

#get(project_id) ⇒ Hash

Query a particular project based on it's id

Parameters:

  • project_id (Integer)

    gitlab project id

Returns:

  • (Hash)

    a project properties



43
44
45
# File 'lib/checklister/gitlab/project.rb', line 43

def get(project_id)
  ProjectDecorator.new(@client.project(project_id)).to_hash
end