class Pod::Command::Bin::Open
Public Class Methods
new(argv)
click to toggle source
Calls superclass method
Pod::Command::Bin::new
# File lib/cocoapods-miBin/command/bin/open.rb, line 17 def initialize(argv) @install = argv.flag?('install') @update = argv.flag?('update') @deep = argv.option('deep').try(:to_i) || 3 super end
options()
click to toggle source
# File lib/cocoapods-miBin/command/bin/open.rb, line 9 def self.options [ ['--install', '先执行 install, 再执行 open. 相当于 pod install && pod bin open'], ['--update', '先执行 update, 再执行 open. 相当于 pod update && pod bin open'], ['--deep=5', '查找深度.'] ] end
Public Instance Methods
find_in_children(paths, deep)
click to toggle source
# File lib/cocoapods-miBin/command/bin/open.rb, line 41 def find_in_children(paths, deep) deep -= 1 pathname = paths.find { |ph| ph.extname == '.xcworkspace' } return pathname if pathname || paths.empty? || deep <= 0 find_in_children(paths.select(&:directory?).flat_map(&:children), deep) end
find_in_parent(path, deep)
click to toggle source
# File lib/cocoapods-miBin/command/bin/open.rb, line 50 def find_in_parent(path, deep) deep -= 1 pathname = path.children.find { |fn| fn.extname == '.xcworkspace' } return pathname if pathname || deep <= 0 find_in_parent(path.parent, deep) end
run()
click to toggle source
# File lib/cocoapods-miBin/command/bin/open.rb, line 24 def run if @install || @update command_class = Object.const_get("Pod::Command::#{@install ? 'Install' : 'Update'}") command = command_class.new(CLAide::ARGV.new([])) command.validate! command.run end path = find_in_children(Pathname.pwd.children, @deep) || find_in_parent(Pathname.pwd.parent, @deep) if path `open #{path}` else UI.puts "#{Pathname.pwd} 目录, 搜索上下深度 #{@deep} , 无法找到 xcworkspace 文件.".red end end