Class: ProjectGen::HeadersStore
- Inherits:
-
Object
- Object
- ProjectGen::HeadersStore
- Defined in:
- lib/cocoapods-project-gen/gen/build/headers_store.rb
Overview
Provides support for managing a header directory. It also keeps track of the header search paths.
Defined Under Namespace
Classes: SEARCH_PATHS_KEY
Instance Attribute Summary collapse
-
#sandbox ⇒ Sandbox
readonly
The sandbox where this header directory is stored.
Adding headers collapse
-
#add_file(namespace, relative_header_path, ln: false, mkdir: true, source: false) ⇒ Pathname
Adds a header to the directory.
-
#add_files(namespace, relative_header_paths, ln: false, source: false) ⇒ Array<Pathname>
Adds headers to the directory.
Instance Method Summary collapse
-
#initialize(sandbox, relative_path, visibility_scope) ⇒ HeadersStore
constructor
A new instance of HeadersStore.
-
#root(source: false) ⇒ Pathname
The absolute path of this header directory.
Constructor Details
#initialize(sandbox, relative_path, visibility_scope) ⇒ HeadersStore
Returns a new instance of HeadersStore.
36 37 38 39 40 41 42 |
# File 'lib/cocoapods-project-gen/gen/build/headers_store.rb', line 36 def initialize(sandbox, relative_path, visibility_scope) @sandbox = sandbox @relative_path = relative_path @search_paths = [] @search_paths_cache = {} @visibility_scope = visibility_scope end |
Instance Attribute Details
#sandbox ⇒ Sandbox (readonly)
Returns the sandbox where this header directory is stored.
25 26 27 |
# File 'lib/cocoapods-project-gen/gen/build/headers_store.rb', line 25 def sandbox @sandbox end |
Instance Method Details
#add_file(namespace, relative_header_path, ln: false, mkdir: true, source: false) ⇒ Pathname
Note:
This method does not add the file to the search paths.
Adds a header to the directory.
83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 |
# File 'lib/cocoapods-project-gen/gen/build/headers_store.rb', line 83 def add_file(namespace, relative_header_path, ln: false, mkdir: true, source: false) namespaced_path = root(source: source) + namespace namespaced_path.mkpath if mkdir absolute_source = (sandbox.root + relative_header_path) source = absolute_source.relative_path_from(namespaced_path) full_namespaced_path = namespaced_path.join(relative_header_path.basename) return full_namespaced_path if full_namespaced_path.exist? if ln if Gem.win_platform? FileUtils.ln(absolute_source, namespaced_path, force: true) else FileUtils.ln_sf(source, namespaced_path) end else FileUtils.cp_r(absolute_source, namespaced_path) end full_namespaced_path end |
#add_files(namespace, relative_header_paths, ln: false, source: false) ⇒ Array<Pathname>
Note:
This method does not add the files to the search paths.
Adds headers to the directory.
62 63 64 65 66 67 |
# File 'lib/cocoapods-project-gen/gen/build/headers_store.rb', line 62 def add_files(namespace, relative_header_paths, ln: false, source: false) root(source: source).join(namespace).mkpath unless relative_header_paths.empty? relative_header_paths.map do |relative_header_path| add_file(namespace, relative_header_path, ln: ln, mkdir: false, source: source) end end |
#root(source: false) ⇒ Pathname
Returns the absolute path of this header directory.
13 14 15 16 17 18 19 20 21 |
# File 'lib/cocoapods-project-gen/gen/build/headers_store.rb', line 13 def root(source: false) root = if source sandbox.sources_root else sandbox.headers_root end root + @relative_path end |