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 .i .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, :podspecs => '*.{podspec,podspec.json}'.freeze, :docs => 'doc{s}{*,.*}/**/*'.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.
-
#developer_files ⇒ Array<Pathname>
Paths to include for local pods to assist in development.
-
#docs ⇒ Array<Pathname>
The paths of auto-detected docs.
-
#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.
-
#other_source_files ⇒ Array<Pathname] the source files that do not match any of the recognized file extensions
Array<Pathname] the source files that do not match any of the recognized file extensions.
-
#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.
-
#spec_license ⇒ Pathname
The path of the license file specified in the specification, if it exists.
-
#specs ⇒ Array<Pathname>
The paths of auto-detected podspecs.
-
#vendored_dynamic_artifacts ⇒ Array<Pathname>
The paths of the dynamic binary artifacts that come shipped with the Pod.
-
#vendored_dynamic_frameworks ⇒ Array<Pathname>
The paths of the dynamic framework bundles that come shipped with the Pod.
-
#vendored_dynamic_libraries ⇒ Array<Pathname>
The paths of the dynamic libraries that come shipped with the Pod.
-
#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.
-
#vendored_static_artifacts ⇒ Array<Pathname>
The paths of the static binary artifacts that come shipped with the Pod.
-
#vendored_static_frameworks ⇒ Array<Pathname>
The paths of the static (fake) framework bundles that come shipped with the Pod.
-
#vendored_static_libraries ⇒ Array<Pathname>
The paths of the static libraries 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
39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/cocoapods/sandbox/file_accessor.rb', line 39 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)
27 28 29 |
# File 'lib/cocoapods/sandbox/file_accessor.rb', line 27 def path_list @path_list end |
#spec_consumer ⇒ Specification::Consumer (readonly)
32 33 34 |
# File 'lib/cocoapods/sandbox/file_accessor.rb', line 32 def spec_consumer @spec_consumer end |
Class Method Details
.vendored_frameworks_headers(framework) ⇒ Array<Pathname>
197 198 199 200 |
# File 'lib/cocoapods/sandbox/file_accessor.rb', line 197 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
187 188 189 190 |
# File 'lib/cocoapods/sandbox/file_accessor.rb', line 187 def self.vendored_frameworks_headers_dir(framework) dir = framework + 'Headers' dir.directory? ? dir.realpath : dir end |
Instance Method Details
#arc_source_files ⇒ Array<Pathname>
91 92 93 94 95 96 97 98 99 100 |
# File 'lib/cocoapods/sandbox/file_accessor.rb', line 91 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 |
#developer_files ⇒ Array<Pathname>
323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 |
# File 'lib/cocoapods/sandbox/file_accessor.rb', line 323 def developer_files podspecs = specs result = [module_map, prefix_header] if license_path = spec_consumer.license[:file] license_path = root + license_path unless File.exist?(license_path) UI.warn "A license was specified in podspec `#{spec.name}` but the file does not exist - #{license_path}" end end if podspecs.size <= 1 result += [license, readme, podspecs, docs] else # Manually add non-globbing files since there are multiple podspecs in the same folder result << podspec_file if license_file = spec_license absolute_path = root + license_file result << absolute_path if File.exist?(absolute_path) end end result.compact.flatten.sort end |
#docs ⇒ Array<Pathname>
307 308 309 |
# File 'lib/cocoapods/sandbox/file_accessor.rb', line 307 def docs path_list.glob([GLOB_PATTERNS[:docs]]) end |
#headers ⇒ Array<Pathname>
118 119 120 121 |
# File 'lib/cocoapods/sandbox/file_accessor.rb', line 118 def headers extensions = HEADER_EXTENSIONS source_files.select { |f| extensions.include?(f.extname) } end |
#inspect ⇒ String
72 73 74 |
# File 'lib/cocoapods/sandbox/file_accessor.rb', line 72 def inspect "<#{self.class} spec=#{spec.name} platform=#{platform_name} root=#{root}>" end |
#license ⇒ Pathname
287 288 289 |
# File 'lib/cocoapods/sandbox/file_accessor.rb', line 287 def license spec_license || path_list.glob([GLOB_PATTERNS[:license]]).first end |
#module_map ⇒ Pathname, Nil
293 294 295 296 297 |
# File 'lib/cocoapods/sandbox/file_accessor.rb', line 293 def module_map if module_map = spec_consumer.module_map path_list.root + module_map end end |
#non_arc_source_files ⇒ Array<Pathname>
105 106 107 |
# File 'lib/cocoapods/sandbox/file_accessor.rb', line 105 def non_arc_source_files source_files - arc_source_files end |
#other_source_files ⇒ Array<Pathname] the source files that do not match any of the recognized file extensions
111 112 113 114 |
# File 'lib/cocoapods/sandbox/file_accessor.rb', line 111 def other_source_files extensions = SOURCE_FILE_EXTENSIONS source_files.reject { |f| extensions.include?(f.extname) } end |
#platform_name ⇒ Specification
66 67 68 |
# File 'lib/cocoapods/sandbox/file_accessor.rb', line 66 def platform_name spec_consumer.platform_name end |
#prefix_header ⇒ Pathname
272 273 274 275 276 |
# File 'lib/cocoapods/sandbox/file_accessor.rb', line 272 def prefix_header if file = spec_consumer.prefix_header_file path_list.root + file end end |
#preserve_paths ⇒ Array<Pathname>
155 156 157 |
# File 'lib/cocoapods/sandbox/file_accessor.rb', line 155 def preserve_paths paths_for_attribute(:preserve_paths, true) end |
#private_headers ⇒ Array<Pathname>
143 144 145 |
# File 'lib/cocoapods/sandbox/file_accessor.rb', line 143 def private_headers private_header_files end |
#public_headers(include_frameworks = false) ⇒ Array<Pathname>
129 130 131 132 133 134 135 136 137 138 139 |
# File 'lib/cocoapods/sandbox/file_accessor.rb', line 129 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
280 281 282 |
# File 'lib/cocoapods/sandbox/file_accessor.rb', line 280 def readme path_list.glob([GLOB_PATTERNS[:readme]]).first end |
#resource_bundle_files ⇒ Array<Pathname>
266 267 268 |
# File 'lib/cocoapods/sandbox/file_accessor.rb', line 266 def resource_bundle_files resource_bundles.values.flatten end |
#resource_bundles ⇒ Hash{String => Array<Pathname>}
252 253 254 255 256 257 258 259 260 261 |
# File 'lib/cocoapods/sandbox/file_accessor.rb', line 252 def resource_bundles result = {} spec_consumer.resource_bundles.each do |name, file_patterns| paths = (file_patterns, :exclude_patterns => spec_consumer.exclude_files, :include_dirs => true) result[name] = paths end result end |
#resources ⇒ Array<Pathname>
149 150 151 |
# File 'lib/cocoapods/sandbox/file_accessor.rb', line 149 def resources paths_for_attribute(:resources, true) end |
#root ⇒ Pathname
54 55 56 |
# File 'lib/cocoapods/sandbox/file_accessor.rb', line 54 def root path_list.root if path_list end |
#source_files ⇒ Array<Pathname>
84 85 86 |
# File 'lib/cocoapods/sandbox/file_accessor.rb', line 84 def source_files paths_for_attribute(:source_files) end |
#spec ⇒ Specification
60 61 62 |
# File 'lib/cocoapods/sandbox/file_accessor.rb', line 60 def spec spec_consumer.spec end |
#spec_license ⇒ Pathname
314 315 316 317 318 319 |
# File 'lib/cocoapods/sandbox/file_accessor.rb', line 314 def spec_license if file = spec_consumer.license[:file] absolute_path = root + file absolute_path if File.exist?(absolute_path) end end |
#specs ⇒ Array<Pathname>
301 302 303 |
# File 'lib/cocoapods/sandbox/file_accessor.rb', line 301 def specs path_list.glob([GLOB_PATTERNS[:podspecs]]) end |
#vendored_dynamic_artifacts ⇒ Array<Pathname>
237 238 239 |
# File 'lib/cocoapods/sandbox/file_accessor.rb', line 237 def vendored_dynamic_artifacts vendored_dynamic_libraries + vendored_dynamic_frameworks end |
#vendored_dynamic_frameworks ⇒ Array<Pathname>
169 170 171 172 173 |
# File 'lib/cocoapods/sandbox/file_accessor.rb', line 169 def vendored_dynamic_frameworks vendored_frameworks.select do |framework| dynamic_binary?(framework + framework.basename('.*')) end end |
#vendored_dynamic_libraries ⇒ Array<Pathname>
221 222 223 224 225 |
# File 'lib/cocoapods/sandbox/file_accessor.rb', line 221 def vendored_dynamic_libraries vendored_libraries.select do |library| dynamic_binary?(library) end end |
#vendored_frameworks ⇒ Array<Pathname>
162 163 164 |
# File 'lib/cocoapods/sandbox/file_accessor.rb', line 162 def vendored_frameworks paths_for_attribute(:vendored_frameworks, true) end |
#vendored_frameworks_headers ⇒ Array<Pathname>
205 206 207 208 209 |
# File 'lib/cocoapods/sandbox/file_accessor.rb', line 205 def vendored_frameworks_headers vendored_frameworks.flat_map do |framework| self.class.vendored_frameworks_headers(framework) end.uniq end |
#vendored_libraries ⇒ Array<Pathname>
214 215 216 |
# File 'lib/cocoapods/sandbox/file_accessor.rb', line 214 def vendored_libraries paths_for_attribute(:vendored_libraries) end |
#vendored_static_artifacts ⇒ Array<Pathname>
244 245 246 |
# File 'lib/cocoapods/sandbox/file_accessor.rb', line 244 def vendored_static_artifacts vendored_static_libraries + vendored_static_frameworks end |
#vendored_static_frameworks ⇒ Array<Pathname>
178 179 180 |
# File 'lib/cocoapods/sandbox/file_accessor.rb', line 178 def vendored_static_frameworks vendored_frameworks - vendored_dynamic_frameworks end |
#vendored_static_libraries ⇒ Array<Pathname>
230 231 232 |
# File 'lib/cocoapods/sandbox/file_accessor.rb', line 230 def vendored_static_libraries vendored_libraries - vendored_dynamic_libraries end |