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
|
# File 'lib/checkout.rb', line 6
def self.go(args)
require LIB_DIR + 'common'
app = KRL_COMMON::get_app rescue nil
raise "You are already in an application: #{app.application_id}" if app
ruleset_id = args.to_s
puts "Checking out: #{ruleset_id}"
raise "Please specify a ruleset id." if ruleset_id.empty?
root_dir = Dir.pwd + "/#{ruleset_id}"
raise "Directory already exists." if File.exists?(root_dir)
user = User.new
app = user.find_application({:application_id => ruleset_id})
puts "Creating directory: #{root_dir}"
FileUtils.mkdir root_dir
app_details = {
:name => app.name,
:ruleset_id => app.application_id,
:role => user.owns_current? ? "owner" : "developer"
}
File.open(root_dir + "/.app", "w") { |f| f.print(app_details.to_yaml) }
File.open(root_dir + "/#{ruleset_id}.krl", "w") { |f| f.print(app.krl) }
end
|