-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcreate.rb
More file actions
63 lines (44 loc) · 1.41 KB
/
create.rb
File metadata and controls
63 lines (44 loc) · 1.41 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
require File.dirname(__FILE__) + '/command.rb'
module Kure
class Create < Command
def initialize(repository, name, path='.')
super(repository)
@name = name
@path = path
end
def execute()
if Dir.exists?(@name) then
return false
else
status = Hash.new
pending = Hash.new
properties = Hash.new
repo_path = @path + '/' + @name
Dir.mkdir(repo_path)
Dir.mkdir("#{repo_path}/#{@repository.base_dir}")
Dir.mkdir("#{repo_path}/#{@repository.versions_dir}")
Dir.mkdir("#{repo_path}/#{@repository.staging_dir}")
f = File.new("#{repo_path}/#{@repository.pending_file}","w")
f.print(pending.to_yaml)
f.close
@repository.load_pending(@name)
f = File.new("#{repo_path}/#{@repository.status_file}","w")
f.print(status.to_yaml)
f.close
@repository.load_status(@name)
last_version = -1
f = File.new("#{repo_path}/#{@repository.last_version_file}","w")
f.print(last_version)
f.close
@repository.load_last_version(@name)
properties[:name] = @name
properties[:clone] = false
f = File.new("#{repo_path}/#{@repository.properties_file}","w")
f.print(properties.to_yaml)
f.close
@repository.load_properties(@name)
return true
end
end
end
end