Class: XcodeArchiveCache::Modulemap::HeaderPathExtractor

Inherits:
Object
  • Object
show all
Includes:
Logs
Defined in:
lib/modulemap/header_path_extractor.rb

Instance Method Summary collapse

Methods included from Logs

#debug, #error, #info, #set_log_level

Instance Method Details

#extract_all_paths(modulemap_path) ⇒ Array<String>

Parameters:

  • modulemap_path (String)

Returns:

  • (Array<String>)


29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/modulemap/header_path_extractor.rb', line 29

def extract_all_paths(modulemap_path)
  modulemap_dir = File.dirname(modulemap_path)
  modulemap_lines = FileHandler.new.read_modulemap_lines(modulemap_path)
  header_paths = []

  modulemap_lines.each do |line|
    header_declaration = extract_header_declaration(line)
    if header_declaration
      header_paths << get_full_header_path(modulemap_dir, header_declaration.path)
    end
  end

  debug("modulemap header paths: #{header_paths}")

  header_paths
end

#extract_header_declaration(line) ⇒ XcodeArchiveCache::Modulemap::HeaderPathDeclaration

Parameters:

  • line (String)

Returns:



59
60
61
62
63
64
# File 'lib/modulemap/header_path_extractor.rb', line 59

def extract_header_declaration(line)
  if line.include?("header") && !line.include?("exclude")
    components = line.split("\"")
    HeaderPathDeclaration.new(components[0], components[1])
  end
end

#get_full_header_path(modulemap_dir, path) ⇒ String

Parameters:

  • modulemap_dir (String)
  • path (String)

Returns:

  • (String)


51
52
53
# File 'lib/modulemap/header_path_extractor.rb', line 51

def get_full_header_path(modulemap_dir, path)
  Pathname.new(path).absolute? ? path : File.join(modulemap_dir, path)
end