Module: HMap::Helper::Pods

Defined in:
lib/cocoapods-hmap/pods_helper.rb

Overview

A collection of Pods Helper functions used throughout cocoapods-hmap.

Constant Summary collapse

HEADER_EXTENSIONS =
Pod::Sandbox::FileAccessor::HEADER_EXTENSIONS

Private helpers collapse

Class Method Summary collapse

Class Method Details

.paths_for_attribute(key, attribute, include_dirs: false) ⇒ Array<Pathname>

Returns the list of the paths founds in the file system for the attribute with given name. It takes into account any dir pattern and any file excluded in the specification.

Parameters:

  • attribute (Symbol)

    the name of the attribute.

Returns:

  • (Array<Pathname>)

    the paths.



28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/cocoapods-hmap/pods_helper.rb', line 28

def self.paths_for_attribute(key, attribute, include_dirs: false)
  file_patterns = key.spec_consumer.send(attribute)
  options = {
    exclude_patterns: key.spec_consumer.exclude_files,
    dir_pattern: Pod::Sandbox::FileAccessor::GLOB_PATTERNS[attribute],
    include_dirs: include_dirs
  }
  extensions = HEADER_EXTENSIONS
  key.path_list.relative_glob(file_patterns, options).map do |f|
    [f, key.path_list.root.join(f)] if extensions.include?(f.extname)
  end.compact
end

.pod_analyze(config) ⇒ Object



11
12
13
14
15
# File 'lib/cocoapods-hmap/pods_helper.rb', line 11

def self.pod_analyze(config)
  podfile = Pod::Podfile.from_file(config.podfile_path)
  lockfile = Pod::Lockfile.from_file(config.lockfile_path)
  Pod::Installer::Analyzer.new(config.sandbox, podfile, lockfile).analyze
end

.pod_target_source_header(target, hmap_t) ⇒ Object



41
42
43
44
45
# File 'lib/cocoapods-hmap/pods_helper.rb', line 41

def self.pod_target_source_header(target, hmap_t)
  target.header_mappings_by_file_accessor.keys.flat_map do |key|
    paths_for_attribute(key, hmap_t)
  end
end

.pod_target_source_header_map(target, hmap_t) ⇒ Object



47
48
49
50
51
52
53
54
# File 'lib/cocoapods-hmap/pods_helper.rb', line 47

def self.pod_target_source_header_map(target, hmap_t)
  pod_target_source_header(target, hmap_t).each_with_object({}) do |f, sum|
    file = f[1]
    key = f[0].to_s
    r_key = file.basename.to_s
    sum[r_key] = [key, r_key].uniq
  end
end