Class: Pod::Command::Gen

Inherits:
Pod::Command show all
Defined in:
lib/cocoapods/command/gen.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(argv) ⇒ Gen

Returns a new instance of Gen.



42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# File 'lib/cocoapods/command/gen.rb', line 42

def initialize(argv)
  options_hash = Generate::Configuration.options.each_with_object({}) do |option, options|
    value =
      if option.name == :podspec_paths
        argv.arguments!
      elsif option.flag?
        argv.flag?(option.cli_name)
      else
        argv.option(option.cli_name)
      end

    next if value.nil?
    options[option.name] = option.coerce(value)
  end
  @configuration = merge_configuration(options_hash)
  super
end

Instance Attribute Details

#configurationConfiguration (readonly)

Returns the configuration used when generating workspaces.

Returns:

  • (Configuration)

    the configuration used when generating workspaces



40
41
42
# File 'lib/cocoapods/command/gen.rb', line 40

def configuration
  @configuration
end

Class Method Details

.optionsObject



23
24
25
26
27
28
29
30
31
# File 'lib/cocoapods/command/gen.rb', line 23

def self.options
  super.concat(Generate::Configuration.options.map do |option|
    next unless option.cli_name

    flag = "--#{option.cli_name}"
    flag += "=#{option.arg_name}" if option.arg_name
    [flag, option.message]
  end.compact)
end

Instance Method Details

#runObject



60
61
62
63
64
65
66
67
68
69
70
71
72
# File 'lib/cocoapods/command/gen.rb', line 60

def run
  UI.puts "[pod gen] Running with #{configuration.to_s.gsub("\n", "         \n")}" if configuration.pod_config.verbose?

  # this is done here rather than in the installer so we only update sources once,
  # even if there are multiple podspecs
  update_sources if configuration.repo_update?

  Generate::PodfileGenerator.new(configuration).podfiles_by_specs.each do |specs, podfile|
    Generate::Installer.new(configuration, specs, podfile).install!
  end

  remove_warnings(UI.warnings)
end

#validate!Object



74
75
76
77
78
79
# File 'lib/cocoapods/command/gen.rb', line 74

def validate!
  super

  config_errors = configuration.validate
  help! config_errors.join("\n    ") if config_errors.any?
end