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_headers_storage_paths(node) ⇒ Array<String>
- #get_storage_path(node) ⇒ String
-
#initialize(path) ⇒ Storage
constructor
A new instance of Storage.
- #prepare_storage(node) ⇒ Object
- #store_headers(node, path, 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
79 80 81 82 83 84 |
# File 'lib/injection/storage.rb', line 79 def get_all_headers_storage_paths headers_storage_dir_paths .map {|_, path| path} .flatten .uniq end |
#get_headers_storage_paths(node) ⇒ Array<String>
75 76 77 |
# File 'lib/injection/storage.rb', line 75 def get_headers_storage_paths(node) headers_storage_dir_paths[node.name] end |
#get_storage_path(node) ⇒ String
67 68 69 |
# File 'lib/injection/storage.rb', line 67 def get_storage_path(node) File.join(container_dir_path, node.name) end |
#prepare_storage(node) ⇒ Object
53 54 55 56 57 58 59 60 61 |
# File 'lib/injection/storage.rb', line 53 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 |
#store_headers(node, path, file_paths) ⇒ 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) storage_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, File.join(storage_path, File.basename(file_path))) end save_header_storage_path(storage_path, node) end |
#store_products(node, file_paths) ⇒ Object
43 44 45 46 47 48 49 |
# File 'lib/injection/storage.rb', line 43 def store_products(node, file_paths) storage_path = prepare_storage(node) file_paths.each do |path| FileUtils.cp_r(path, storage_path) end end |