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
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
-
#headers ⇒ Array<Pathname>
The headers of the specification.
-
#license ⇒ Pathname
The path of the license file as indicated in the specification or auto-detected.
-
#prefix_header ⇒ Pathname
The of the prefix header file of the specification.
-
#preserve_paths ⇒ Array<Pathname>
The files of the specification to preserve.
-
#public_headers ⇒ Array<Pathname>
The public headers of the specification.
-
#readme ⇒ Pathname
The path of the auto-detected README file.
-
#resources ⇒ Hash{ Symbol => Array<Pathname> }
The resources of the specification grouped by destination.
-
#source_files ⇒ Array<Pathname>
The source files of the specification.
Instance Method Summary collapse
-
#initialize(path_list, spec_consumer) ⇒ FileAccessor
constructor
A new instance of FileAccessor.
-
#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
Returns a new instance of FileAccessor.
27 28 29 30 31 32 33 34 |
# File 'lib/cocoapods/sandbox/file_accessor.rb', line 27 def initialize(path_list, spec_consumer) @path_list = path_list @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.
17 18 19 |
# File 'lib/cocoapods/sandbox/file_accessor.rb', line 17 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.
22 23 24 |
# File 'lib/cocoapods/sandbox/file_accessor.rb', line 22 def spec_consumer @spec_consumer end |
Instance Method Details
#headers ⇒ Array<Pathname>
Returns the headers of the specification.
74 75 76 77 |
# File 'lib/cocoapods/sandbox/file_accessor.rb', line 74 def headers extensions = HEADER_EXTENSIONS source_files.select { |f| extensions.include?(f.extname) } end |
#inspect ⇒ String
Returns A string suitable for debugging.
56 57 58 |
# File 'lib/cocoapods/sandbox/file_accessor.rb', line 56 def inspect "<#{self.class} spec=#{spec.name} platform=#{platform_name} root=#{path_list.root}>" end |
#license ⇒ Pathname
Returns The path of the license file as indicated in the specification or auto-detected.
122 123 124 125 126 127 128 |
# File 'lib/cocoapods/sandbox/file_accessor.rb', line 122 def license if spec_consumer.spec.root.license[:file] path_list.root + spec_consumer.spec.root.license[:file] else path_list.glob(%w[ licen{c,s}e{*,.*} ]).first end end |
#platform_name ⇒ Specification
Returns the platform used to consume the specification.
50 51 52 |
# File 'lib/cocoapods/sandbox/file_accessor.rb', line 50 def platform_name spec_consumer.platform_name end |
#prefix_header ⇒ Pathname
Returns The of the prefix header file of the specification.
107 108 109 110 111 |
# File 'lib/cocoapods/sandbox/file_accessor.rb', line 107 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.
101 102 103 |
# File 'lib/cocoapods/sandbox/file_accessor.rb', line 101 def preserve_paths paths_for_attribute(:preserve_paths, true) end |
#public_headers ⇒ Array<Pathname>
Returns the public headers of the specification.
81 82 83 84 85 86 87 88 89 90 |
# File 'lib/cocoapods/sandbox/file_accessor.rb', line 81 def public_headers public_headers = paths_for_attribute(:public_header_files) private_headers = paths_for_attribute(:private_header_files) if public_headers.nil? || public_headers.empty? header_files = headers else header_files = public_headers end header_files - private_headers end |
#readme ⇒ Pathname
Returns The path of the auto-detected README file.
115 116 117 |
# File 'lib/cocoapods/sandbox/file_accessor.rb', line 115 def readme path_list.glob(%w[ readme{*,.*} ]).first end |
#resources ⇒ Hash{ Symbol => Array<Pathname> }
Returns the resources of the specification grouped by destination.
95 96 97 |
# File 'lib/cocoapods/sandbox/file_accessor.rb', line 95 def resources paths_for_attribute(:resources, true) end |
#root ⇒ Pathname
Returns the directory which contains the files of the Pod.
38 39 40 |
# File 'lib/cocoapods/sandbox/file_accessor.rb', line 38 def root path_list.root end |
#source_files ⇒ Array<Pathname>
Returns the source files of the specification.
68 69 70 |
# File 'lib/cocoapods/sandbox/file_accessor.rb', line 68 def source_files paths_for_attribute(:source_files) end |
#spec ⇒ Specification
Returns the specification.
44 45 46 |
# File 'lib/cocoapods/sandbox/file_accessor.rb', line 44 def spec spec_consumer.spec end |