class Umbrellify::ProjectManager
Public Class Methods
new(project_path, configuration)
click to toggle source
# File lib/umbrellify/managers/project_manager.rb, line 5 def initialize(project_path, configuration) @project_path = project_path @configuration = configuration end
Public Instance Methods
apply()
click to toggle source
-=-=-=-=-=-=-=-=-=-=-=- Public Interface =-=-=-=-=-=-=-=-=-=-=-=-¶ ↑
# File lib/umbrellify/managers/project_manager.rb, line 12 def apply open_project umbrella_target = add_umbrella_target_if_needed umbrella_files_path = create_umbrella_files add_umbrella_files_to_target(umbrella_files_path, umbrella_target) add_dependency_to_main_target(umbrella_target) @project.save end
Private Instance Methods
add_dependency_to_main_target(target)
click to toggle source
# File lib/umbrellify/managers/project_manager.rb, line 72 def add_dependency_to_main_target(target) main_target.add_dependency(target) end
add_files(directory, group, target)
click to toggle source
# File lib/umbrellify/managers/project_manager.rb, line 107 def add_files(directory, group, target) Dir.glob(directory) do |item| next if item == "." or item == ".DS_Store" if File.directory?(item) new_folder = File.basename(item) created_group = group.new_group(new_folder) add_files("#{item}/*", created_group, target) else file_reference = group.new_file(item) target.add_file_references([file_reference]) end end end
add_umbrella_files_to_target(path, target)
click to toggle source
# File lib/umbrellify/managers/project_manager.rb, line 60 def add_umbrella_files_to_target(path, target) work_group = @project.main_group work_group.children.select { |child| child.name == umbrella_name }.each do |child| remove_files(child) end add_files(path, work_group, target) end
add_umbrella_target_if_needed()
click to toggle source
# File lib/umbrellify/managers/project_manager.rb, line 31 def add_umbrella_target_if_needed existing_umbrella_targets = @project.targets.select { |t| t.name == umbrella_name } umbrella_target = existing_umbrella_targets.first if umbrella_target.nil? umbrella_target = @project.new_target(:framework, umbrella_name, :ios, "10.0") @project.save end return umbrella_target end
create_umbrella_files()
click to toggle source
# File lib/umbrellify/managers/project_manager.rb, line 46 def create_umbrella_files project_dir_path = File.dirname(@project_path) work_path = "#{project_dir_path}/#{umbrella_name}" umbrella_source_path = "#{work_path}/#{umbrella_name}-combined.swift" Dir.mkdir(work_path) unless Dir.exist?(work_path) File.write(umbrella_source_path, umbrella_source(@configuration.managed_imports)) return work_path end
main_target()
click to toggle source
# File lib/umbrellify/managers/project_manager.rb, line 86 def main_target @project.targets.select { |t| t.name == @configuration.main_target_name }.first end
open_project()
click to toggle source
remove_files(object)
click to toggle source
# File lib/umbrellify/managers/project_manager.rb, line 124 def remove_files(object) if object.isa == "PBXGroup" object.children.each do |child| remove_files(child) end end object.remove_from_project end
umbrella_name()
click to toggle source
umbrella_source(managed_frameworks)
click to toggle source
# File lib/umbrellify/managers/project_manager.rb, line 94 def umbrella_source(managed_frameworks) exported_imports = managed_frameworks.map { |f| "@_exported import #{f}" }.join("\n") source = <<SOURCE // This file is generated automatically by Umbrellify. // Do not edit contents of this file! #{exported_imports} SOURCE end