class Pod::Command::Vemars::Patch

Public Class Methods

new(argv) click to toggle source
Calls superclass method
# File lib/cocoapods-vemars/command/vemars/patch.rb, line 31
def initialize(argv)
  @baseline = argv.shift_argument
  @path = argv.option('path', '')
  @selected_components = argv.option('com', '').split(',')
  @config_json = argv.option('config', '/onekit-config.json') 
  @repo_no_update = argv.flag?('pod_repo_no_update',false)
  git_url = argv.option('git', 'https://github.com/volcengine/ve_Template_iOS.git')
  service_url = argv.option('service_url',nil)
  sources = argv.option('sources','https://github.com/volcengine/volcengine-specs.git,https://cdn.cocoapods.org/')
  @project = VemarsProject.new(@appkey, @selected_components, @config_json, @baseline, git_url, service_url,sources)
  super
  @additional_args = argv.remainder!
end
options() click to toggle source
Calls superclass method
# File lib/cocoapods-vemars/command/vemars/patch.rb, line 18
def self.options
  options = [
    ['--path=PODFILE_PATH',    'the /path/to/Dir_contains_Podfile'],
    ['--com=COM1,COM2', 'Selected components in vemars.'],
    ['--config=CONFIG_PATH', 'config path of vemars.'],
    ['--service_url=SERVICE_URL', 'url of vemars CLI service.'],
    ['--git=GIT_URL', 'git url of demo repo'],
    ['--pod_repo_no_update',    'do not run pod repo update'],
    ['--sources','pod repos sources']
  ]
  options.concat(super.reject { |option, _| option == '--silent' })
end

Public Instance Methods

openXcodeWorkSpaceIfNeeded() click to toggle source
# File lib/cocoapods-vemars/command/vemars/patch.rb, line 83
def openXcodeWorkSpaceIfNeeded
  workspaces = Dir.entries(@path).select { |e| e.end_with?(".xcworkspace") }
  full_path = File.join(@path, workspaces.first)
  system("open -a /Applications/Xcode.app '#{full_path}'")
end
podInstallIfNeeded() click to toggle source
# File lib/cocoapods-vemars/command/vemars/patch.rb, line 61
def podInstallIfNeeded
  puts "Current dir: #{Dir.pwd}"
  project_dir = @path
  puts "Pod install directory: #{project_dir}"
  if @silent
    puts "Pod install skipped!"
    puts "You can run Pod install in '#{project_dir}' later!"
    return
  end

  Dir.chdir(project_dir) do
    # system('bundle install')
    # system('bundle exec pod install --repo-update')
    if @repo_no_update
      puts "pod install with no repo update"
      system('pod install --no-repo-update')
    else
      system('pod install --repo-update')
    end
  end
end
run() click to toggle source
# File lib/cocoapods-vemars/command/vemars/patch.rb, line 55
def run
  @project.patch @path
  podInstallIfNeeded
  openXcodeWorkSpaceIfNeeded
end
validate!() click to toggle source
Calls superclass method
# File lib/cocoapods-vemars/command/vemars/patch.rb, line 45
def validate!
  super
  if @path.nil? || @path.empty?
    help! 'A project path where Podfile locates is required '
  end
  unless File.exist? @config_json
    help! "onekit-config.json is not found at #{Dir.pwd}"
  end
end