Class: Pod::Command::Gen

Inherits:
Pod::Command show all
Defined in:
lib/cocoapods-modularization/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
59
# File 'lib/cocoapods-modularization/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
  UI.puts "options_hash: #{options_hash}"
  @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-modularization/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-modularization/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



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

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_spec.each do |spec, podfile|
    Generate::Installer.new(configuration, spec, podfile).install!
  end

  remove_warnings(UI.warnings)
end

#validate!Object



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

def validate!
  super

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