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



25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/cocoapods/sandbox/file_accessor.rb', line 25

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



15
16
17
# File 'lib/cocoapods/sandbox/file_accessor.rb', line 15

def path_list
  @path_list
end

#spec_consumerSpecification::Consumer (readonly)



20
21
22
# File 'lib/cocoapods/sandbox/file_accessor.rb', line 20

def spec_consumer
  @spec_consumer
end

Instance Method Details

#headersArray<Pathname>



76
77
78
79
# File 'lib/cocoapods/sandbox/file_accessor.rb', line 76

def headers
  extensions = HEADER_EXTENSIONS
  source_files.select { |f| extensions.include?(f.extname) }
end

#inspectString



58
59
60
# File 'lib/cocoapods/sandbox/file_accessor.rb', line 58

def inspect
  "<#{self.class} spec=#{spec.name} platform=#{platform_name} root=#{root}>"
end

#licensePathname



158
159
160
161
162
163
164
# File 'lib/cocoapods/sandbox/file_accessor.rb', line 158

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



52
53
54
# File 'lib/cocoapods/sandbox/file_accessor.rb', line 52

def platform_name
  spec_consumer.platform_name
end

#prefix_headerPathname



143
144
145
146
147
# File 'lib/cocoapods/sandbox/file_accessor.rb', line 143

def prefix_header
  if spec_consumer.prefix_header_file
    path_list.root + spec_consumer.prefix_header_file
  end
end

#preserve_pathsArray<Pathname>



103
104
105
# File 'lib/cocoapods/sandbox/file_accessor.rb', line 103

def preserve_paths
  paths_for_attribute(:preserve_paths, true)
end

#public_headersArray<Pathname>



83
84
85
86
87
88
89
90
91
92
# File 'lib/cocoapods/sandbox/file_accessor.rb', line 83

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



151
152
153
# File 'lib/cocoapods/sandbox/file_accessor.rb', line 151

def readme
  path_list.glob(%w(        readme{*,.*}        )).first
end

#resource_bundle_filesArray<Pathname>



137
138
139
# File 'lib/cocoapods/sandbox/file_accessor.rb', line 137

def resource_bundle_files
  resource_bundles.values.flatten
end

#resource_bundlesHash{String => Array<Pathname>}



125
126
127
128
129
130
131
132
# File 'lib/cocoapods/sandbox/file_accessor.rb', line 125

def resource_bundles
  result = {}
  spec_consumer.resource_bundles.each do |name, file_patterns|
    paths = expanded_paths(file_patterns, :include_dirs => true)
    result[name] = paths
  end
  result
end

#resourcesHash{ Symbol => Array<Pathname> }



97
98
99
# File 'lib/cocoapods/sandbox/file_accessor.rb', line 97

def resources
  paths_for_attribute(:resources, true)
end

#rootPathname



40
41
42
# File 'lib/cocoapods/sandbox/file_accessor.rb', line 40

def root
  path_list.root if path_list
end

#source_filesArray<Pathname>



70
71
72
# File 'lib/cocoapods/sandbox/file_accessor.rb', line 70

def source_files
  paths_for_attribute(:source_files)
end

#specSpecification



46
47
48
# File 'lib/cocoapods/sandbox/file_accessor.rb', line 46

def spec
  spec_consumer.spec
end

#vendored_frameworksArray<Pathname>



110
111
112
# File 'lib/cocoapods/sandbox/file_accessor.rb', line 110

def vendored_frameworks
  paths_for_attribute(:vendored_frameworks, true)
end

#vendored_librariesArray<Pathname>



117
118
119
# File 'lib/cocoapods/sandbox/file_accessor.rb', line 117

def vendored_libraries
  paths_for_attribute(:vendored_libraries)
end