Module: Pod::Bazel::Util

Defined in:
lib/cocoapods/bazel/util.rb

Defined Under Namespace

Classes: SortKey

Class Method Summary collapse

Class Method Details

.resolve_value(string, resolved_values:) ⇒ Object

Recursively resolves the variables in string with the given resolved values.

Example: Given string = “$PODS_ROOT/Foo”, resolved_values = “//Pods” this function returns “//Pods/Foo”.



17
18
19
20
21
22
23
# File 'lib/cocoapods/bazel/util.rb', line 17

def resolve_value(string, resolved_values:)
  return string unless string =~ /\$(?:\{([_a-zA-Z0-0]+?)\}|\(([_a-zA-Z0-0]+?)\))/

  match, key = Regexp.last_match.values_at(0, 1, 2).compact
  sub = resolved_values.fetch(key, '')
  resolve_value(string.gsub(match, sub), resolved_values: resolved_values)
end

.sort_labels(labels) ⇒ Object



8
9
10
11
# File 'lib/cocoapods/bazel/util.rb', line 8

def sort_labels(labels)
  sort_keys = labels.map.with_index { |string, i| SortKey.new(string, i) }
  sort_keys.sort_by { |k| [k.phase, k.split, k.value, k.original_index] }.map(&:value)
end