Repository create/delete RPC calls
This commit is contained in:
parent
f27f5558e9
commit
5ca703b96b
|
@ -7,7 +7,8 @@ class Repository < ActiveRecord::Base
|
||||||
|
|
||||||
scope :recent, order("name ASC")
|
scope :recent, order("name ASC")
|
||||||
|
|
||||||
before_create :create_directory
|
before_create :xml_rpc_create
|
||||||
|
before_destroy :xml_rpc_destroy
|
||||||
|
|
||||||
def path
|
def path
|
||||||
build_path(unixname)
|
build_path(unixname)
|
||||||
|
@ -27,7 +28,6 @@ class Repository < ActiveRecord::Base
|
||||||
File.join(platform.path, dir)
|
File.join(platform.path, dir)
|
||||||
end
|
end
|
||||||
|
|
||||||
#TODO: Spec me
|
|
||||||
def create_directory
|
def create_directory
|
||||||
exists = File.exists?(path) && File.directory?(path)
|
exists = File.exists?(path) && File.directory?(path)
|
||||||
raise "Directory #{path} already exists" if exists
|
raise "Directory #{path} already exists" if exists
|
||||||
|
@ -39,4 +39,23 @@ class Repository < ActiveRecord::Base
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def xml_rpc_create
|
||||||
|
result = BuildServer.create_repo name, platform.name
|
||||||
|
if result == BuildServer::SUCCESS
|
||||||
|
return true
|
||||||
|
else
|
||||||
|
raise "Failed to create repository #{name} inside platform #{platform.name}."
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def xml_rpc_destroy
|
||||||
|
result = BuildServer.delete_repo name, platform.name
|
||||||
|
if result == BuildServer::SUCCESS
|
||||||
|
return true
|
||||||
|
else
|
||||||
|
raise "Failed to delete repository #{name} inside platform #{platform.name}."
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue