Class: XcodeArchiveCache::Injection::Storage
- Inherits:
-
Object
- Object
- XcodeArchiveCache::Injection::Storage
- Defined in:
- lib/injection/storage.rb
Instance Attribute Summary collapse
- #container_dir_path ⇒ String readonly
- #headers_storage_dir_paths ⇒ Hash{XcodeArchiveCache::BuildGraph::Node => String} readonly
Instance Method Summary collapse
- #get_all_headers_storage_paths ⇒ Object
- #get_default_headers_storage_path(node) ⇒ String
- #get_headers_storage_paths(node) ⇒ String
- #get_modulemap_path(node) ⇒ String
- #get_storage_path(node) ⇒ String
-
#initialize(path) ⇒ Storage
constructor
A new instance of Storage.
- #prepare_storage(node) ⇒ Object
- #store_default_headers(node, file_paths) ⇒ Object
- #store_headers(node, path, file_paths, save_path = true) ⇒ Object
- #store_modulemap_headers(node, file_paths) ⇒ Object
- #store_products(node, file_paths) ⇒ Object
Constructor Details
#initialize(path) ⇒ Storage
Returns a new instance of Storage.
15 16 17 18 19 20 |
# File 'lib/injection/storage.rb', line 15 def initialize(path) @container_dir_path = path @headers_storage_dir_paths = Hash.new prepare_container_dir end |
Instance Attribute Details
#container_dir_path ⇒ String (readonly)
7 8 9 |
# File 'lib/injection/storage.rb', line 7 def container_dir_path @container_dir_path end |
#headers_storage_dir_paths ⇒ Hash{XcodeArchiveCache::BuildGraph::Node => String} (readonly)
11 12 13 |
# File 'lib/injection/storage.rb', line 11 def headers_storage_dir_paths @headers_storage_dir_paths end |
Instance Method Details
#get_all_headers_storage_paths ⇒ Object
108 109 110 111 112 113 |
# File 'lib/injection/storage.rb', line 108 def get_all_headers_storage_paths headers_storage_dir_paths .map { |_, path| path } .flatten .uniq end |
#get_default_headers_storage_path(node) ⇒ String
119 120 121 |
# File 'lib/injection/storage.rb', line 119 def get_default_headers_storage_path(node) "include/#{node.name}" end |
#get_headers_storage_paths(node) ⇒ String
104 105 106 |
# File 'lib/injection/storage.rb', line 104 def get_headers_storage_paths(node) headers_storage_dir_paths[node.name] end |
#get_modulemap_path(node) ⇒ String
55 56 57 58 59 60 61 62 |
# 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 |
#get_storage_path(node) ⇒ String
91 92 93 94 95 96 97 98 |
# File 'lib/injection/storage.rb', line 91 def get_storage_path(node) path = File.join(container_dir_path, node.name) if node.native_target path += "-#{node.native_target.uuid}" end path end |
#prepare_storage(node) ⇒ Object
77 78 79 80 81 82 83 84 85 |
# 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: #{path}" end FileUtils.mkdir_p(path) path end |
#store_default_headers(node, file_paths) ⇒ Object
43 44 45 |
# 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 |
#store_headers(node, path, file_paths, save_path = true) ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 38 |
# 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 |
#store_modulemap_headers(node, file_paths) ⇒ Object
47 48 49 |
# 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 |
#store_products(node, file_paths) ⇒ Object
67 68 69 70 71 72 73 |
# 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 |