Method: Pod::Podfile::TargetDefinition#podspec_path_from_options

Defined in:
lib/cocoapods-core/podfile/target_definition.rb

#podspec_path_from_options(options) ⇒ Pathname (private)

The path of the podspec with the given options.

Parameters:

  • options (Hash)

    The options to use for finding the podspec. The supported keys are: :name, :path, :autodetect.

Returns:

  • (Pathname)

    The path.



1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
# File 'lib/cocoapods-core/podfile/target_definition.rb', line 1022

def podspec_path_from_options(options)
  if path = options[:path]
    if File.basename(path).include?('.podspec')
      path_with_ext = path
    else
      path_with_ext = "#{path}.podspec"
    end
    path_without_tilde = path_with_ext.gsub('~', ENV['HOME'])
    podfile.defined_in_file.dirname + path_without_tilde
  elsif name = options[:name]
    name = File.basename(name).include?('.podspec') ? name : "#{name}.podspec"
    podfile.defined_in_file.dirname + name
  elsif options[:autodetect]
    glob_pattern = podfile.defined_in_file.dirname + '*.podspec{,.json}'
    path = Pathname.glob(glob_pattern).first
    unless path
      raise Informative, 'Could not locate a podspec in the current directory. '\
        'You can specify the path via the path option.'
    end

    path
  end
end