Class: Pod::Requirement
- Inherits:
-
Vendor::Gem::Requirement
- Object
- Vendor::Gem::Requirement
- Pod::Requirement
- Defined in:
- lib/cocoapods-core/requirement.rb
Overview
Move support about external sources and head information here from the Dependency class.
A Requirement is a set of one or more version restrictions of a Dependency.
It is based on the RubyGems class adapted to support CocoaPods specific information.
Constant Summary collapse
- PATTERN =
Returns The regular expression used to validate input strings.
/\A\s*(#{quoted_operators})?\s*(#{Version::VERSION_PATTERN})\s*\z/
Constants inherited from Vendor::Gem::Requirement
Instance Attribute Summary
Attributes inherited from Vendor::Gem::Requirement
Class Method Summary collapse
-
.create(input) ⇒ Requirement
Factory method to create a new requirement.
-
.default ⇒ Requirement
The default requirement.
-
.parse(input) ⇒ Array
Parses the given object returning a tuple where the first entry is an operator and the second a version.
Methods inherited from Vendor::Gem::Requirement
#<=>, #as_list, #hash, #init_with, #initialize, #marshal_dump, #marshal_load, #none?, #prerelease?, #pretty_print, #satisfied_by?, #specific?, #to_s, #yaml_initialize
Constructor Details
This class inherits a constructor from Pod::Vendor::Gem::Requirement
Class Method Details
.create(input) ⇒ Requirement
Factory method to create a new requirement.
27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/cocoapods-core/requirement.rb', line 27 def self.create(input) case input when Requirement input when Version, Array new(input) else if input.respond_to? :to_str new([input.to_str]) else default end end end |
.default ⇒ Requirement
Returns The default requirement.
44 45 46 |
# File 'lib/cocoapods-core/requirement.rb', line 44 def self.default new('>= 0') end |
.parse(input) ⇒ Array
Parses the given object returning a tuple where the first entry is an operator and the second a version. If not operator is provided it defaults to ‘=`.
57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/cocoapods-core/requirement.rb', line 57 def self.parse(input) return ['=', input] if input.is_a?(Version) unless PATTERN =~ input.to_s raise ArgumentError, "Illformed requirement `#{input.inspect}`" end operator = Regexp.last_match[1] || '=' version = Version.new(Regexp.last_match[2]) [operator, version] end |