Class: Pod::Command::Bin::Umbrella

Inherits:
Pod::Command::Bin show all
Defined in:
lib/cocoapods-bin/command/bin/umbrella.rb

Instance Method Summary collapse

Methods included from CBin::SpecFilesHelper

#binary_spec, #binary_spec_files, #binary_template_spec, #binary_template_spec_file, #binary_template_spec_files, #clear_binary_spec_file_if_needed, #code_spec, #code_spec_files, #create_binary_spec_file, #find_spec_file, #spec_files

Methods included from CBin::SourcesHelper

#binary_source, #code_source, #sources_manager, #sources_option, #valid_sources

Constructor Details

#initialize(argv) ⇒ Umbrella

Returns a new instance of Umbrella.



13
14
15
16
17
# File 'lib/cocoapods-bin/command/bin/umbrella.rb', line 13

def initialize(argv)
  @path = Pathname.new(argv.shift_argument || '.')
  @spec_file = code_spec_files.first
  super
end

Instance Method Details

#runObject



26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/cocoapods-bin/command/bin/umbrella.rb', line 26

def run
  pod_name = @spec_file.to_s.split('.').first

  @path += "#{pod_name}.h" if @path.directory?

  UI.puts "Generateing umbrella file for #{pod_name}"

  header_generator = Pod::Generator::Header.new(Platform.ios)
  spec = Pod::Specification.from_file(Pathname.new(@spec_file))
  public_header_files = spec.consumer(:ios).public_header_files
  if public_header_files.empty?
    public_header_files = spec.consumer(:ios).source_files
  end
  public_header_files = Pathname.glob(public_header_files).map(&:basename).select do |pathname|
    pathname.extname.to_s == '.h' &&
      pathname.basename('.h').to_s != pod_name
  end

  header_generator.imports = public_header_files

  UI.puts "Save umbrella file to #{@path.expand_path}"

  header_generator.save_as(@path)

  UI.puts 'Done!'.green
end

#validate!Object



19
20
21
22
23
24
# File 'lib/cocoapods-bin/command/bin/umbrella.rb', line 19

def validate!
  super
  if @spec_file.nil?
    help! '[!] No `Podspec` found in the project directory.'
  end
end