class XcodeArchiveCache::Injection::Storage
Attributes
@return [String]
@return [Hash{XcodeArchiveCache::BuildGraph::Node => String}]
Public Class Methods
@param [String] path
# File lib/injection/storage.rb, line 15 def initialize(path) @container_dir_path = path @headers_storage_dir_paths = Hash.new prepare_container_dir end
Public Instance Methods
# File lib/injection/storage.rb, line 103 def get_all_headers_storage_paths headers_storage_dir_paths .map { |_, path| path } .flatten .uniq end
@param [XcodeArchiveCache::BuildGraph::Node] node
@return [String]
# File lib/injection/storage.rb, line 114 def get_default_headers_storage_path(node) "include/#{node.name}" end
@param [XcodeArchiveCache::BuildGraph::Node] node
@return [String]
# File lib/injection/storage.rb, line 99 def get_headers_storage_paths(node) headers_storage_dir_paths[node.name] end
@param [XcodeArchiveCache::BuildGraph::Node] node
@return [String]
# File lib/injection/storage.rb, line 55 def get_modulemap_path(node) modulemap_file_name = node.resulting_modulemap_file_name return if modulemap_file_name == nil storage_path = get_storage_path(node) stored_modulemap_file_path = get_stored_file_path(storage_path, modulemap_file_name) File.exist?(stored_modulemap_file_path) ? stored_modulemap_file_path : nil end
@param [XcodeArchiveCache::BuildGraph::Node] node
@return [String]
# File lib/injection/storage.rb, line 91 def get_storage_path(node) File.join(container_dir_path, node.name) end
@param [XcodeArchiveCache::BuildGraph::Node] node
# File lib/injection/storage.rb, line 77 def prepare_storage(node) path = get_storage_path(node) if File.exist?(path) raise StandardError.new, "Injection storage path is already busy" end FileUtils.mkdir_p(path) path end
@param [XcodeArchiveCache::BuildGraph::Node] node @param [Array<String>] file_paths
# File lib/injection/storage.rb, line 43 def store_default_headers(node, file_paths) store_headers(node, get_default_headers_storage_path(node), file_paths) end
@param [XcodeArchiveCache::BuildGraph::Node] node @param [String] path @param [Array<String>] file_paths
# File lib/injection/storage.rb, line 26 def store_headers(node, path, file_paths, save_path = true) storage_path = Pathname.new(path).absolute? ? path : get_full_header_storage_path(path) unless File.exist?(storage_path) FileUtils.mkdir_p(storage_path) end file_paths.each do |file_path| FileUtils.cp(file_path, get_stored_file_path(storage_path, file_path)) end save_header_storage_path(storage_path, node) if save_path end
# File lib/injection/storage.rb, line 47 def store_modulemap_headers(node, file_paths) store_headers(node, get_storage_path(node), file_paths, false) end
@param [XcodeArchiveCache::BuildGraph::Node] node @param [Array<String>] file_paths
# File lib/injection/storage.rb, line 67 def store_products(node, file_paths) storage_path = prepare_storage(node) file_paths.each do |path| FileUtils.cp_r(path, storage_path) end end
Private Instance Methods
@param [String] path
@return [String]
# File lib/injection/storage.rb, line 130 def get_full_header_storage_path(path) File.absolute_path(path, container_dir_path) end
@param [String] storage_path @param [String] file_path
@return [String]
# File lib/injection/storage.rb, line 139 def get_stored_file_path(storage_path, file_path) File.join(storage_path, File.basename(file_path)) end
# File lib/injection/storage.rb, line 120 def prepare_container_dir if File.exist?(container_dir_path) FileUtils.rm_rf(container_dir_path) end end
@param [String] path @param [XcodeArchiveCache::BuildGraph::Node] node
# File lib/injection/storage.rb, line 146 def save_header_storage_path(path, node) paths = get_headers_storage_paths(node) || [] containing_directory = File.dirname(path) unless paths.include?(containing_directory) paths.push(containing_directory) set_all_headers_storage_paths(paths, node) end end
@param [String] paths @param [XcodeArchiveCache::BuildGraph::Node] node
# File lib/injection/storage.rb, line 158 def set_all_headers_storage_paths(paths, node) headers_storage_dir_paths[node.name] = paths end