class Pod::Command::Jysource::Add

This is an example of a cocoapods plugin adding a top-level subcommand to the 'pod' command.

You can also create subcommands of existing or new commands. Say you wanted to add a subcommand to `list` to show newly deprecated pods, (e.g. `pod list deprecated`), there are a few things that would need to change.

@todo Create a PR to add your plugin to CocoaPods/cocoapods.org

in the `plugins.json` file, once your plugin is released.

Public Class Methods

new(argv) click to toggle source
Calls superclass method
# File lib/cocoapods-jysource/command/jysource/add.rb, line 36
def initialize(argv)
  @pod          = argv.shift_argument
  @tag          = argv.shift_argument
  @public       = argv.shift_argument
  super
end

Public Instance Methods

run() click to toggle source
# File lib/cocoapods-jysource/command/jysource/add.rb, line 48
def run
  UI.puts "开始下载源码:"
  UI.puts "#{@pod}  " + "  #{@tag} "

  if "#{@public}".empty? then
    if "#{@pod}".start_with?("JY") then
      git = "http://gitlab.hellobike.cn/Torrent/#{@pod}.git"
    else
      git = "git://podspec.hellobike.cn:4709/sources/#{@pod}.git"
    end
  else
    git = "https://github.com/#{@pod}"
    str = "#{@pod}".split("/")
    if str.length == 2 && "#{@public}".eql?("yes") then
      @pod = (str.last).to_s
    else
      help! '命令格式不正确'
    end
  end

  tag = @tag
  target_path = '/Users/Shared/JYSource/Pods/' + @pod
  FileUtils.rm_rf(target_path)

  options = { :git => git ,:tag => tag }
  options = Pod::Downloader.preprocess_options(options)
  downloader = Pod::Downloader.for_target(target_path, options)
  # downloader.cache_root = "~/Library/Caches/JYSource/#{@pod}"
  # downloader.max_cache_size = 500
  downloader.download
  downloader.checkout_options
  
  UI.puts "\033[32m源码下载成功...\033[0m\n"
end
validate!() click to toggle source
Calls superclass method
# File lib/cocoapods-jysource/command/jysource/add.rb, line 43
def validate!
  super
  help! 'A Pod name and version is required.' unless @pod && @tag 
end