Class: Phoenx::GenerateWorkspace

Inherits:
Object
  • Object
show all
Defined in:
lib/phoenx/use_cases/generate_workspace.rb

Instance Method Summary collapse

Constructor Details

#initialize(workspace) ⇒ GenerateWorkspace

Returns a new instance of GenerateWorkspace.



9
10
11
12
# File 'lib/phoenx/use_cases/generate_workspace.rb', line 9

def initialize(workspace)
	@workspace = workspace
	@project_files = []
end

Instance Method Details

#generateObject



47
48
49
50
# File 'lib/phoenx/use_cases/generate_workspace.rb', line 47

def generate
	self.generate_projects
	self.generate_workspace
end

#generate_project(name, value) ⇒ Object



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/phoenx/use_cases/generate_workspace.rb', line 22

def generate_project(name, value)
	path = value
	if path == nil
		path = '.'
	end
	abort "Missing project folder ".red + path.bold unless Dir.exists?(path)
	Dir.chdir(path) do
		file_name = name + '.' + PROJECT_EXTENSION
		specs = Dir[file_name]
		puts "> Project ".green + name.bold
		abort "Missing project specification ".red + (path + file_name).bold unless specs.first
		file = File.read(specs.first)
		spec = eval(file)
		generator = Phoenx::GenerateProject.new spec
		generator.build
	end
end

#generate_projectsObject



40
41
42
43
44
45
# File 'lib/phoenx/use_cases/generate_workspace.rb', line 40

def generate_projects
	@workspace.generated_projects.each do |key,value| 
		self.generate_project(key,value)
	end
	self.generate_project(@workspace.main_project_name,@workspace.main_project_path)
end

#generate_workspaceObject



14
15
16
17
18
19
20
# File 'lib/phoenx/use_cases/generate_workspace.rb', line 14

def generate_workspace
	workspace = Xcodeproj::Workspace.new(@workspace.main_project_path + @workspace.main_project_name + "." + XCODE_PROJECT_EXTENSION)
	@workspace.projects.each do |key,value| 
		workspace << value + key + "." + XCODE_PROJECT_EXTENSION
	end
	workspace.save_as(@workspace.name + "." + XCODE_WORKSPACE_EXTENSION)
end