class Pod::Command::Spec

Private Instance Methods

all_paths_from_set(set) click to toggle source

@return [String] of spec paths one on each line

# File lib/cocoapods/command/spec.rb, line 70
def all_paths_from_set(set)
  paths = ''

  sources = set.sources

  sources.each do |source|
    versions = source.versions(set.name)

    versions.each do |version|
      spec = source.specification(set.name, version)
      paths += "#{pathname_from_spec(spec, source)}\n"
    end
  end

  paths
end
get_path_of_spec(spec, show_all = false) click to toggle source

@param [String] spec

The name of the specification.

@param [Bool] show_all

Whether the paths for all the versions should be returned or
only the one for the last version.

@return [Pathname] the absolute path or paths of the given podspec

# File lib/cocoapods/command/spec.rb, line 42
def get_path_of_spec(spec, show_all = false)
  sets = config.sources_manager.search_by_name(spec)

  if sets.count == 1
    set = sets.first
  elsif sets.map(&:name).include?(spec)
    set = sets.find { |s| s.name == spec }
  else
    names = sets.map(&:name) * ', '
    raise Informative, "More than one spec found for '#{spec}':\n#{names}"
  end

  unless show_all
    best_spec, spec_source = spec_and_source_from_set(set)
    return pathname_from_spec(best_spec, spec_source)
  end

  all_paths_from_set(set)
end
pathname_from_spec(spec, _source) click to toggle source

@return [Pathname] the absolute path of the given spec and source

# File lib/cocoapods/command/spec.rb, line 64
def pathname_from_spec(spec, _source)
  Pathname(spec.defined_in_file)
end
spec_and_source_from_set(set) click to toggle source

@return [Specification, Source] the highest known specification with it's source of the given

set.
# File lib/cocoapods/command/spec.rb, line 90
def spec_and_source_from_set(set)
  sources = set.sources

  best_source = best_version = nil
  sources.each do |source|
    versions = source.versions(set.name)
    versions.each do |version|
      if !best_version || version > best_version
        best_source = source
        best_version = version
      end
    end
  end

  if !best_source || !best_version
    raise Informative, "Unable to locate highest known specification for `#{set.name}'"
  end

  [best_source.specification(set.name, best_version), best_source]
end
validate_regex!(query) click to toggle source

@param [String] query the regular expression string to validate

@raise if the query is not a valid regular expression

# File lib/cocoapods/command/spec.rb, line 27
def validate_regex!(query)
  /#{query}/
rescue RegexpError
  help! 'A valid regular expression is required.'
end