Method: Pod::Specification.name_and_version_from_string

Defined in:
lib/cocoapods-core/specification.rb

.name_and_version_from_string(string_representation) ⇒ Array<String, Version>

Returns the name and the version of a pod.

Examples:

Input examples


"libPusher (1.0)"
"RestKit/JSON (1.0)"

Parameters:

Returns:

  • (Array<String, Version>)

    the name and the version of a pod.



156
157
158
159
160
161
162
163
164
165
166
167
# File 'lib/cocoapods-core/specification.rb', line 156

def self.name_and_version_from_string(string_representation)
  match_data = string_representation.match(/\A((?:\s?[^\s(])+)(?: \((.+)\))?\Z/)
  unless match_data
    raise Informative, 'Invalid string representation for a ' \
      "specification: `#{string_representation}`. " \
      'The string representation should include the name and ' \
      'optionally the version of the Pod.'
  end
  name = match_data[1]
  vers = Version.new(match_data[2])
  [name, vers]
end