Class: Pod::Command::Cache::Proxy::Add

Inherits:
Pod::Command::Cache::Proxy show all
Defined in:
lib/cocoapods-cache-proxy/command/cache_proxy/add.rb

Instance Method Summary collapse

Methods inherited from Pod::Command::Cache::Proxy

#init

Constructor Details

#initialize(argv) ⇒ Add

Returns a new instance of Add.



21
22
23
24
25
26
# File 'lib/cocoapods-cache-proxy/command/cache_proxy/add.rb', line 21

def initialize(argv)
    init
    @name, @url, @user, @password = argv.shift_argument, argv.shift_argument, argv.shift_argument, argv.shift_argument
    @silent = argv.flag?('silent', false)
    super
end

Instance Method Details

#runObject



36
37
38
39
40
41
42
43
# File 'lib/cocoapods-cache-proxy/command/cache_proxy/add.rb', line 36

def run
    raise Pod::Informative.exception "`#{@name}` 已经存在" if CPSH.check_source_conf_exists(@name)
    #raise Pod::Informative.exception "官方源不存在, 请先添加官方源" unless Pod::Config.instance.sources_manager.master_repo_functional?
    
    UI.section("Add proxy server config `#{@url}` into local spec repo `#{@name}`".green) do
        CPSH.init_cache_proxy_source(@name, @url, @user, @password)
    end
end

#validate!Object



28
29
30
31
32
33
34
# File 'lib/cocoapods-cache-proxy/command/cache_proxy/add.rb', line 28

def validate!
    super
    help! 'This command requires both a repo name.' unless @name
    help! 'This command requires both a repo url.' unless @url
    help! 'This command requires both a repo user.' unless @user
    help! 'This command requires both a repo password.' unless @password
end