Class: Pod::Sandbox::FileAccessor
- Inherits:
-
Object
- Object
- Pod::Sandbox::FileAccessor
- Defined in:
- lib/cocoapods/sandbox/file_accessor.rb
Overview
The FileAccessor always returns absolute paths.
Resolves the file patterns of a specification against its root directory, taking into account any exclude pattern and the default extensions to use for directories.
Constant Summary collapse
- HEADER_EXTENSIONS =
Xcodeproj::Constants::HEADER_FILES_EXTENSIONS
- SOURCE_FILE_EXTENSIONS =
(%w(.m .mm .c .cc .cxx .cpp .c++ .swift) + HEADER_EXTENSIONS).uniq.freeze
- GLOB_PATTERNS =
{ :readme => 'readme{*,.*}'.freeze, :license => 'licen{c,s}e{*,.*}'.freeze, :source_files => "*{#{SOURCE_FILE_EXTENSIONS.join(',')}}".freeze, :public_header_files => "*{#{HEADER_EXTENSIONS.join(',')}}".freeze, }.freeze
Instance Attribute Summary collapse
-
#path_list ⇒ Sandbox::PathList
readonly
The directory where the source of the Pod is located.
-
#spec_consumer ⇒ Specification::Consumer
readonly
The consumer of the specification for which the file patterns should be resolved.
Paths collapse
-
.vendored_frameworks_headers(framework) ⇒ Array<Pathname>
The paths of the headers included in the vendored framework.
-
.vendored_frameworks_headers_dir(framework) ⇒ Pathname
The path of the header directory of the vendored framework.
-
#arc_source_files ⇒ Array<Pathname>
The source files of the specification that use ARC.
-
#headers ⇒ Array<Pathname>
The headers of the specification.
-
#license ⇒ Pathname
The path of the license file as indicated in the specification or auto-detected.
-
#module_map ⇒ Pathname, Nil
The path of the custom module map file of the specification, if specified.
-
#non_arc_source_files ⇒ Array<Pathname>
The source files of the specification that do not use ARC.
-
#prefix_header ⇒ Pathname
The of the prefix header file of the specification.
-
#preserve_paths ⇒ Array<Pathname>
The files of the specification to preserve.
-
#private_headers ⇒ Array<Pathname>
The private headers of the specification.
-
#public_headers(include_frameworks = false) ⇒ Array<Pathname>
The public headers of the specification.
-
#readme ⇒ Pathname
The path of the auto-detected README file.
-
#resource_bundle_files ⇒ Array<Pathname>
The paths of the files which should be included in resources bundles by the Pod.
-
#resource_bundles ⇒ Hash{String => Array<Pathname>}
A hash that describes the resource bundles of the Pod.
-
#resources ⇒ Array<Pathname>
The resources of the specification.
-
#source_files ⇒ Array<Pathname>
The source files of the specification.
-
#vendored_frameworks ⇒ Array<Pathname>
The paths of the framework bundles that come shipped with the Pod.
-
#vendored_frameworks_headers ⇒ Array<Pathname>
The paths of the framework headers that come shipped with the Pod.
-
#vendored_libraries ⇒ Array<Pathname>
The paths of the library bundles that come shipped with the Pod.
Instance Method Summary collapse
-
#initialize(path_list, spec_consumer) ⇒ FileAccessor
constructor
Initialize a new instance.
-
#inspect ⇒ String
A string suitable for debugging.
-
#platform_name ⇒ Specification
The platform used to consume the specification.
-
#root ⇒ Pathname
The directory which contains the files of the Pod.
-
#spec ⇒ Specification
The specification.
Constructor Details
#initialize(path_list, spec_consumer) ⇒ FileAccessor
Initialize a new instance
35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/cocoapods/sandbox/file_accessor.rb', line 35 def initialize(path_list, spec_consumer) if path_list.is_a?(PathList) @path_list = path_list else @path_list = PathList.new(path_list) end @spec_consumer = spec_consumer unless @spec_consumer raise Informative, 'Attempt to initialize File Accessor without a specification consumer.' end end |
Instance Attribute Details
#path_list ⇒ Sandbox::PathList (readonly)
Returns the directory where the source of the Pod is located.
23 24 25 |
# File 'lib/cocoapods/sandbox/file_accessor.rb', line 23 def path_list @path_list end |
#spec_consumer ⇒ Specification::Consumer (readonly)
Returns the consumer of the specification for which the file patterns should be resolved.
28 29 30 |
# File 'lib/cocoapods/sandbox/file_accessor.rb', line 28 def spec_consumer @spec_consumer end |
Class Method Details
.vendored_frameworks_headers(framework) ⇒ Array<Pathname>
Returns The paths of the headers included in the vendored framework.
169 170 171 172 |
# File 'lib/cocoapods/sandbox/file_accessor.rb', line 169 def self.vendored_frameworks_headers(framework) headers_dir = vendored_frameworks_headers_dir(framework) Pathname.glob(headers_dir + '**/' + GLOB_PATTERNS[:public_header_files]) end |
.vendored_frameworks_headers_dir(framework) ⇒ Pathname
Returns The path of the header directory of the vendored framework.
160 161 162 |
# File 'lib/cocoapods/sandbox/file_accessor.rb', line 160 def self.vendored_frameworks_headers_dir(framework) (framework + 'Headers').realpath end |
Instance Method Details
#arc_source_files ⇒ Array<Pathname>
Returns the source files of the specification that use ARC.
87 88 89 90 91 92 93 94 95 96 |
# File 'lib/cocoapods/sandbox/file_accessor.rb', line 87 def arc_source_files case spec_consumer.requires_arc when TrueClass source_files when FalseClass [] else paths_for_attribute(:requires_arc) & source_files end end |
#headers ⇒ Array<Pathname>
Returns the headers of the specification.
107 108 109 110 |
# File 'lib/cocoapods/sandbox/file_accessor.rb', line 107 def headers extensions = HEADER_EXTENSIONS source_files.select { |f| extensions.include?(f.extname) } end |
#inspect ⇒ String
Returns A string suitable for debugging.
68 69 70 |
# File 'lib/cocoapods/sandbox/file_accessor.rb', line 68 def inspect "<#{self.class} spec=#{spec.name} platform=#{platform_name} root=#{root}>" end |
#license ⇒ Pathname
Returns The path of the license file as indicated in the specification or auto-detected.
227 228 229 230 231 232 233 |
# File 'lib/cocoapods/sandbox/file_accessor.rb', line 227 def license if spec_consumer.spec.root.license[:file] path_list.root + spec_consumer.spec.root.license[:file] else path_list.glob([GLOB_PATTERNS[:license]]).first end end |
#module_map ⇒ Pathname, Nil
Returns The path of the custom module map file of the specification, if specified.
237 238 239 240 241 |
# File 'lib/cocoapods/sandbox/file_accessor.rb', line 237 def module_map if module_map = spec_consumer.spec.root.module_map path_list.root + module_map end end |
#non_arc_source_files ⇒ Array<Pathname>
Returns the source files of the specification that do not use ARC.
101 102 103 |
# File 'lib/cocoapods/sandbox/file_accessor.rb', line 101 def non_arc_source_files source_files - arc_source_files end |
#platform_name ⇒ Specification
Returns the platform used to consume the specification.
62 63 64 |
# File 'lib/cocoapods/sandbox/file_accessor.rb', line 62 def platform_name spec_consumer.platform_name end |
#prefix_header ⇒ Pathname
Returns The of the prefix header file of the specification.
212 213 214 215 216 |
# File 'lib/cocoapods/sandbox/file_accessor.rb', line 212 def prefix_header if spec_consumer.prefix_header_file path_list.root + spec_consumer.prefix_header_file end end |
#preserve_paths ⇒ Array<Pathname>
Returns the files of the specification to preserve.
144 145 146 |
# File 'lib/cocoapods/sandbox/file_accessor.rb', line 144 def preserve_paths paths_for_attribute(:preserve_paths, true) end |
#private_headers ⇒ Array<Pathname>
Returns The private headers of the specification.
132 133 134 |
# File 'lib/cocoapods/sandbox/file_accessor.rb', line 132 def private_headers private_header_files end |
#public_headers(include_frameworks = false) ⇒ Array<Pathname>
Returns the public headers of the specification.
118 119 120 121 122 123 124 125 126 127 128 |
# File 'lib/cocoapods/sandbox/file_accessor.rb', line 118 def public_headers(include_frameworks = false) public_headers = public_header_files private_headers = private_header_files if public_headers.nil? || public_headers.empty? header_files = headers else header_files = public_headers end header_files += vendored_frameworks_headers if include_frameworks header_files - private_headers end |
#readme ⇒ Pathname
Returns The path of the auto-detected README file.
220 221 222 |
# File 'lib/cocoapods/sandbox/file_accessor.rb', line 220 def readme path_list.glob([GLOB_PATTERNS[:readme]]).first end |
#resource_bundle_files ⇒ Array<Pathname>
Returns The paths of the files which should be included in resources bundles by the Pod.
206 207 208 |
# File 'lib/cocoapods/sandbox/file_accessor.rb', line 206 def resource_bundle_files resource_bundles.values.flatten end |
#resource_bundles ⇒ Hash{String => Array<Pathname>}
Returns A hash that describes the resource bundles of the Pod. The keys represent the name of the bundle while the values the path of the resources.
194 195 196 197 198 199 200 201 |
# File 'lib/cocoapods/sandbox/file_accessor.rb', line 194 def resource_bundles result = {} spec_consumer.resource_bundles.each do |name, file_patterns| paths = (file_patterns, :include_dirs => true) result[name] = paths end result end |
#resources ⇒ Array<Pathname>
Returns the resources of the specification.
138 139 140 |
# File 'lib/cocoapods/sandbox/file_accessor.rb', line 138 def resources paths_for_attribute(:resources, true) end |
#root ⇒ Pathname
Returns the directory which contains the files of the Pod.
50 51 52 |
# File 'lib/cocoapods/sandbox/file_accessor.rb', line 50 def root path_list.root if path_list end |
#source_files ⇒ Array<Pathname>
Returns the source files of the specification.
80 81 82 |
# File 'lib/cocoapods/sandbox/file_accessor.rb', line 80 def source_files paths_for_attribute(:source_files) end |
#spec ⇒ Specification
Returns the specification.
56 57 58 |
# File 'lib/cocoapods/sandbox/file_accessor.rb', line 56 def spec spec_consumer.spec end |
#vendored_frameworks ⇒ Array<Pathname>
Returns The paths of the framework bundles that come shipped with the Pod.
151 152 153 |
# File 'lib/cocoapods/sandbox/file_accessor.rb', line 151 def vendored_frameworks paths_for_attribute(:vendored_frameworks, true) end |
#vendored_frameworks_headers ⇒ Array<Pathname>
Returns The paths of the framework headers that come shipped with the Pod.
177 178 179 180 181 |
# File 'lib/cocoapods/sandbox/file_accessor.rb', line 177 def vendored_frameworks_headers vendored_frameworks.map do |framework| self.class.vendored_frameworks_headers(framework) end.flatten.uniq end |
#vendored_libraries ⇒ Array<Pathname>
Returns The paths of the library bundles that come shipped with the Pod.
186 187 188 |
# File 'lib/cocoapods/sandbox/file_accessor.rb', line 186 def vendored_libraries paths_for_attribute(:vendored_libraries) end |