Class: Project

Inherits:
Object
  • Object
show all
Includes:
API
Defined in:
lib/bitbucket/project.rb

Constant Summary collapse

LIMIT =
1000.to_s

Instance Attribute Summary collapse

Attributes included from API

#api

Class Method Summary collapse

Instance Method Summary collapse

Methods included from API

#create_api, #parsed_response, #request

Constructor Details

#initialize(server, data) ⇒ Project

Returns a new instance of Project.



12
13
14
15
16
# File 'lib/bitbucket/project.rb', line 12

def initialize(server,data)
  @bb = server
  @name = data['name']
  @key = data['key']
end

Instance Attribute Details

#keyObject (readonly)

Returns the value of attribute key.



10
11
12
# File 'lib/bitbucket/project.rb', line 10

def key
  @key
end

#nameObject (readonly)

Returns the value of attribute name.



10
11
12
# File 'lib/bitbucket/project.rb', line 10

def name
  @name
end

Class Method Details

.get_all(server) ⇒ Object



5
6
7
8
# File 'lib/bitbucket/project.rb', line 5

def self.get_all(server)
  data = server.request(:get, "rest/api/1.0/projects?limit=#{LIMIT}")
  data['values'].map {|p| new(server,p) }
end

Instance Method Details

#move_all_repos_to_project(new_project) ⇒ Object



22
23
24
25
26
# File 'lib/bitbucket/project.rb', line 22

def move_all_repos_to_project(new_project)
  repositories.each do |r|
    r.move_repo_to_project(new_project)
  end
end

#repositoriesObject



18
19
20
# File 'lib/bitbucket/project.rb', line 18

def repositories
  @repositories ||= Repository.get_all(@bb,key)
end

#set_hook_status(key, status, settings = nil) ⇒ Object



28
29
30
31
32
33
# File 'lib/bitbucket/project.rb', line 28

def set_hook_status(key,status,settings=nil)
  repositories.each do |r|
    r.set_hook_settings(key, settings) if status && settings
    r.set_hook_status(key, status)
  end
end