Class: PodBuilder::Analyze

Inherits:
Object
  • Object
show all
Defined in:
lib/pod_builder/analyze.rb

Class Method Summary collapse

Class Method Details

.installer_at(path, repo_update = false) ⇒ Pod::Installer

Returns The Pod::Installer instance created by processing the Podfile.

Returns:

  • (Pod::Installer)

    The Pod::Installer instance created by processing the Podfile



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/pod_builder/analyze.rb', line 9

def self.installer_at(path, repo_update = false)
  CLAide::Command::PluginManager.load_plugins("cocoapods")
  
  # Manually load inline podbuilder-rome plugin
  pluginspec = Gem::Specification.new("podbuilder-rome", PodBuilder::VERSION)
  pluginspec.activate

  if !CLAide::Command::PluginManager.loaded_plugins["cocoapods"].map(&:name).include?(pluginspec.name)
    CLAide::Command::PluginManager.loaded_plugins["cocoapods"].push(pluginspec)
  end

  current_dir = Dir.pwd
  Dir.chdir(path)

  config = Pod::Config.new()
  installer = Pod::Installer.new(config.sandbox, config.podfile, config.lockfile)
  installer.repo_update = repo_update
  installer.update = false 

  installer.prepare

  analyzer = installer.resolve_dependencies

  Dir.chdir(current_dir)

  return installer, analyzer
end

.podfile_items(installer, analyzer) ⇒ Array<PodfileItem>

Returns The PodfileItem in the Podfile (including subspecs) and dependencies.

Returns:

  • (Array<PodfileItem>)

    The PodfileItem in the Podfile (including subspecs) and dependencies



39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# File 'lib/pod_builder/analyze.rb', line 39

def self.podfile_items(installer, analyzer)
  sandbox = installer.sandbox
  analysis_result = installer.analysis_result
  
  all_podfile_pods = analysis_result.podfile_dependency_cache.podfile_dependencies

  external_source_pods = all_podfile_pods.select(&:external_source)
  checkout_options = external_source_pods.map { |x| [x.name.split("/").first, x.external_source] }.to_h

  # this adds the :commit which might be missing in checkout_options
  # will also overwrite :branch with :commit which is desired
  checkout_options.merge!(analyzer.sandbox.checkout_sources)
  
  all_specs = analysis_result.specifications
  
  supported_platforms = analyzer.instance_variable_get("@result").targets.map { |t| t.platform.safe_string_name.downcase }
  
  return all_specs.map { |spec| PodfileItem.new(spec, all_specs, checkout_options, supported_platforms) }.sort_by(&:name)
end