Sha256: 66021245490200ae31c90af8b8b486d0a352e474feb697581de05eb9997e4d66

Contents?: true

Size: 1.27 KB

Versions: 3

Compression:

Stored size: 1.27 KB

Contents

class Module
    def strong_alias(to, from)
      # https://tieba.baidu.com/p/5535445605?red_tag=0735709674  贴吧大神给出的方案
      # 类方法可以看做singleton class(单例类)的实例方法,下面两个方法都可以,上面这个方式也适用于早起的ruby版本
      (class << self;self;end).send(:alias_method, to, from)
      # self.singleton_class.send(:alias_method, to, from)
    end
end

module Pod
    class Command
      class Repo < Command
        class Push < Repo
            attr_accessor :skip_validate

            self.strong_alias(:old_options, :options)
            def self.options
              [
                ['--skip-validate', '跳过验证,不验证推送的podspec文件,默认为验证']
              ].concat(self.old_options)
            end

            # 调用原方法的两种方式
            old_validate_podspec_files = instance_method(:validate_podspec_files)
            define_method(:validate_podspec_files) do
                old_validate_podspec_files.bind(self).() unless @skip_validate
            end

            alias_method :old_check_repo_status, :check_repo_status
            def check_repo_status
                old_check_repo_status unless @skip_validate
            end
        end
      end
    end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
cocoapods-util-0.0.14 lib/cocoapods-util/command/cocoapods-extend/repo/push_helper.rb
cocoapods-util-0.0.12 lib/cocoapods-util/command/cocoapods-extend/repo/push_helper.rb
cocoapods-util-0.0.11 lib/cocoapods-util/cocoapods-extend/repo/push_helper.rb