Module: Gerry::Api::Projects

Included in:
Client
Defined in:
lib/gerry/api/projects.rb

Instance Method Summary collapse

Instance Method Details

#create_project_access(project, permissions) ⇒ Object



48
49
50
51
52
53
# File 'lib/gerry/api/projects.rb', line 48

def create_project_access(project, permissions)
  access = {
    'add' => permissions
  }
  post("/projects/#{project}/access", access)
end

#find_project(name) ⇒ Hash

Get the projects that start with the specified prefix and accessible by the caller.

Parameters:

  • name (String)

    the project name.

Returns:

  • (Hash)

    the projects.



16
17
18
# File 'lib/gerry/api/projects.rb', line 16

def find_project(name)
  get("/projects/#{name}")
end

#get_head(project) ⇒ String

Get the symbolic HEAD ref for the specified project.

Parameters:

  • project (String)

    the project name.

Returns:

  • (String)

    the current ref to which HEAD points to.



24
25
26
# File 'lib/gerry/api/projects.rb', line 24

def get_head(project)
  get("/projects/#{project}/HEAD")
end

#project_access(project) ⇒ Object

lists the access rights for signle project



44
45
46
# File 'lib/gerry/api/projects.rb', line 44

def project_access(project)
  get("/projects/#{project}/access")
end

#project_commit(project, commit_id) ⇒ Object

Retrieves a commit of a project.



64
65
66
# File 'lib/gerry/api/projects.rb', line 64

def project_commit(project, commit_id)
  get("/projects/#{project}/commits/#{commit_id}")
end

#project_file(project, commit_id, file_id) ⇒ Object



68
69
70
# File 'lib/gerry/api/projects.rb', line 68

def project_file(project, commit_id, file_id)
  get("/projects/#{project}/commits/#{commit_id}/files/#{file_id}/content")
end

#projectsHash

Get the projects accessible by the caller.

Returns:

  • (Hash)

    the projects.



7
8
9
# File 'lib/gerry/api/projects.rb', line 7

def projects
  get('/projects/')
end

#remove_project_access(project, permissions) ⇒ Object



55
56
57
58
59
60
# File 'lib/gerry/api/projects.rb', line 55

def remove_project_access(project, permissions)
  access = {
    'remove' => permissions
  }
  post("/projects/#{project}/access", access)
end

#set_head(project, branch) ⇒ String

Set the symbolic HEAD ref for the specified project to point to the specified branch.

Parameters:

  • project (String)

    the project name.

  • branch (String)

    the branch to point to.

Returns:

  • (String)

    the new ref to which HEAD points to.



34
35
36
37
38
39
40
# File 'lib/gerry/api/projects.rb', line 34

def set_head(project, branch)
  url = "/projects/#{project}/HEAD"
  body = {
    ref: 'refs/heads/' + branch
  }
  put(url, body)
end