Class: Highway::Steps::Library::CocoaPodsStep

Inherits:
Step
  • Object
show all
Defined in:
lib/highway/steps/library/cocoapods.rb

Class Method Summary collapse

Methods inherited from Step

root_parameter

Class Method Details

.nameObject



14
15
16
# File 'lib/highway/steps/library/cocoapods.rb', line 14

def self.name
  "cocoapods"
end

.parametersObject



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/highway/steps/library/cocoapods.rb', line 18

def self.parameters
  [
    Parameters::Single.new(
      name: "command",
      required: false,
      type: Types::Enum.new("install", "update"),
      default: "install",
    ),
    Parameters::Single.new(
      name: "update_specs_repo",
      required: false,
      type: Types::Enum.new("always", "never", "on-error"),
      default: "never",
    ),
  ]
end

.run(parameters:, context:, report:) ⇒ Object



35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
# File 'lib/highway/steps/library/cocoapods.rb', line 35

def self.run(parameters:, context:, report:)

  context.assert_gem_available!("cocoapods")

  command = parameters["command"]
  update_specs_repo = parameters["update_specs_repo"]

  repo_update_always = update_specs_repo == "always"
  repo_update_on_error = update_specs_repo == "on-error"

  if command == "install"

    context.run_action("cocoapods", options: {
      repo_update: repo_update_always,
      try_repo_update_on_error: repo_update_on_error,
      use_bundle_exec: context.should_use_bundle_exec?,
    })

  elsif command == "update"

    invocation = []
    invocation << "bundle exec" if context.should_use_bundle_exec?
    invocation << "pod update"
    invocation << "--repo-update" if repo_update_always

    context.run_sh(invocation.join(" "), on_error: lambda { |error|
      if repo_update_on_error
        context.run_sh((invocation + ["--repo-update"]).join(" "))
      else
        context.reporter.fatal!(error)
      end
    })

  end

end