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/
- DefaultRequirement =
          rubocop:disable Naming/ConstantName 
- ['>=', Version.new(0)] 
Constants inherited from Vendor::Gem::Requirement
Vendor::Gem::Requirement::OPS, Vendor::Gem::Requirement::PATTERN_RAW, Vendor::Gem::Requirement::SOURCE_SET_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. 
Instance Method Summary collapse
- 
  
    
      #initialize(*requirements)  ⇒ Requirement 
    
    
  
  
  
    constructor
  
  
  
  
  
  
  
    Constructs a requirement from ‘requirements`. 
- 
  
    
      #none?  ⇒ Bool 
    
    
  
  
  
  
  
  
  
  
  
    True if this pod has no requirements. 
Methods inherited from Vendor::Gem::Requirement
#==, #as_list, #concat, #encode_with, #exact?, #for_lockfile, #hash, #init_with, #marshal_dump, #marshal_load, #prerelease?, #pretty_print, #satisfied_by?, source_set, #specific?, #to_s, #to_yaml_properties, #yaml_initialize
Constructor Details
#initialize(*requirements) ⇒ Requirement
Duplicate requirements are ignored.
An empty set of ‘requirements` is the same as `“>= 0”`
Constructs a requirement from ‘requirements`.
| 80 81 82 83 84 85 86 87 88 89 90 | # File 'lib/cocoapods-core/requirement.rb', line 80 def initialize(*requirements) requirements = requirements.flatten requirements.compact! requirements.uniq! @requirements = if requirements.empty? [DefaultRequirement] else requirements.map! { |r| self.class.parse r } end end | 
Class Method Details
.create(input) ⇒ Requirement
Factory method to create a new requirement.
| 29 30 31 32 33 34 35 36 37 38 39 40 41 42 | # File 'lib/cocoapods-core/requirement.rb', line 29 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.
| 46 47 48 | # File 'lib/cocoapods-core/requirement.rb', line 46 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 ‘=`.
| 59 60 61 62 63 64 65 66 67 68 69 | # File 'lib/cocoapods-core/requirement.rb', line 59 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 | 
Instance Method Details
#none? ⇒ Bool
Returns true if this pod has no requirements.
| 95 96 97 98 99 100 101 | # File 'lib/cocoapods-core/requirement.rb', line 95 def none? if @requirements.size == 1 @requirements[0] == DefaultRequirement else false end end |