class PPL::Command

Public Class Methods

ensure_not_root_or_allowed!(argv, uid = Process.uid, is_windows = Gem.win_platform?) click to toggle source

确保root用户

@return [void]

# File lib/pod-pipeline/command.rb, line 50
def self.ensure_not_root_or_allowed!(argv, uid = Process.uid, is_windows = Gem.win_platform?)
    root_allowed = argv.include?('--allow-root') || !ENV['COCOAPODS_ALLOW_ROOT'].nil?
    help! 'You cannot run Pod-Pipeline as root.' unless root_allowed || uid != 0 || is_windows
end
git_version() click to toggle source

读取Git版本号,返回一个新的 {Gem::Version} 实例

@return [Gem::Version]

# File lib/pod-pipeline/command.rb, line 59
def self.git_version
    raw_version = `git version`
    unless match = raw_version.scan(/\d+\.\d+\.\d+/).first
        raise "Failed to extract git version from `git --version` (#{raw_version.inspect})"
    end
    Gem::Version.new(match)
end
new(argv) click to toggle source
Calls superclass method
# File lib/pod-pipeline/command.rb, line 92
def initialize(argv)
    @argv_extension = Hash.new
    self.class.options_extension_hash.each_key { |key|
        @argv_extension[key] = Array.new
        self.class.options.each do |option|
            name = option.first
            if name.include?(key)
                is_option = name.include? '='
                if is_option
                    option = name.gsub(/(--)(.*)(=.*)/,"\\2")
                    value = argv.option(option, '')
                    @argv_extension[key] << name.gsub(/(--.*=)(.*)/,"\\1#{value}").gsub("#{key}-",'') unless value.empty?
                else
                    flag = name.gsub(/(--)(.*)/,'\\2')
                    value = argv.flag?(flag)
                    @argv_extension[key] << name.gsub("#{key}-",'') if value
                end
            end
        end
    }

    super
end
options() click to toggle source
# File lib/pod-pipeline/command.rb, line 15
def self.options
    [
      ['--help', '展示改命令的介绍面板'],
    ]
end
options_extension() click to toggle source
# File lib/pod-pipeline/command.rb, line 21
def self.options_extension
    options = Array.new
    options_extension_hash.each { |_key, _options_extension|
        _options_extension.each { |_option_extension| 
          options << [_option_extension.first.gsub(/(--)(.*)/,"\\1#{_key}-\\2"), _option_extension.last]
        } 
    }
    options
end
options_extension_hash() click to toggle source
# File lib/pod-pipeline/command.rb, line 31
def self.options_extension_hash
    Hash[
      
    ]
end
run(argv) click to toggle source
Calls superclass method
# File lib/pod-pipeline/command.rb, line 37
def self.run(argv)
    ensure_not_root_or_allowed! argv
    verify_minimum_git_version!
    verify_xcode_license_approved!
      
    super(argv)
end
verify_minimum_git_version!() click to toggle source

检查Git版本号是否低于 1.8.5

@raise Git版本号低于 1.8.5

@return [void]

# File lib/pod-pipeline/command.rb, line 73
def self.verify_minimum_git_version!
    if git_version < Gem::Version.new('1.8.5')
        raise 'You need at least git version 1.8.5 to use Pod-Pipeline'
    end
end
verify_xcode_license_approved!() click to toggle source

检查xcode许可是否被批准

@return [void]

# File lib/pod-pipeline/command.rb, line 84
def self.verify_xcode_license_approved!
    if `/usr/bin/xcrun clang 2>&1` =~ /license/ && !$?.success?
      raise 'You have not agreed to the Xcode license, which ' \
        'you must do to use CocoaPods. Agree to the license by running: ' \
        '`xcodebuild -license`.'
    end
end

Public Instance Methods

argv_extension() click to toggle source
# File lib/pod-pipeline/command.rb, line 116
def argv_extension
    @argv_extension 
end