Class: Pod::Sandbox::FileAccessor

Inherits:
Object
  • Object
show all
Defined in:
lib/cocoapods/sandbox/file_accessor.rb

Overview

Note:

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

Paths collapse

Instance Method Summary collapse

Constructor Details

#initialize(path_list, spec_consumer) ⇒ FileAccessor

Returns a new instance of FileAccessor.

Parameters:

  • path_list (Sandbox::PathList)

    @see path_list

  • spec_consumer (Specification::Consumer)

    @see spec_consumer



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_listSandbox::PathList (readonly)

Returns the directory where the source of the Pod is located.

Returns:



17
18
19
# File 'lib/cocoapods/sandbox/file_accessor.rb', line 17

def path_list
  @path_list
end

#spec_consumerSpecification::Consumer (readonly)

Returns the consumer of the specification for which the file patterns should be resolved.

Returns:

  • (Specification::Consumer)

    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

#headersArray<Pathname>

Returns the headers of the specification.

Returns:

  • (Array<Pathname>)

    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

#inspectString

Returns A string suitable for debugging.

Returns:

  • (String)

    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

#licensePathname

Returns The path of the license file as indicated in the specification or auto-detected.

Returns:

  • (Pathname)

    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_nameSpecification

Returns the platform used to consume the specification.

Returns:

  • (Specification)

    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_headerPathname

Returns The of the prefix header file of the specification.

Returns:

  • (Pathname)

    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_pathsArray<Pathname>

Returns the files of the specification to preserve.

Returns:

  • (Array<Pathname>)

    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_headersArray<Pathname>

Returns the public headers of the specification.

Returns:

  • (Array<Pathname>)

    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

#readmePathname

Returns The path of the auto-detected README file.

Returns:

  • (Pathname)

    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

#resourcesHash{ Symbol => Array<Pathname> }

Returns the resources of the specification grouped by destination.

Returns:

  • (Hash{ Symbol => Array<Pathname> })

    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

#rootPathname

Returns the directory which contains the files of the Pod.

Returns:

  • (Pathname)

    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_filesArray<Pathname>

Returns the source files of the specification.

Returns:

  • (Array<Pathname>)

    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

#specSpecification

Returns the specification.

Returns:



44
45
46
# File 'lib/cocoapods/sandbox/file_accessor.rb', line 44

def spec
  spec_consumer.spec
end