Class: Pindo::Command::Lib::Update
- Inherits:
-
Pindo::Command::Lib
- Object
- Pindo::Command
- Pindo::Command::Lib
- Pindo::Command::Lib::Update
- Defined in:
- lib/pindo/command/lib/update.rb
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(argv) ⇒ Update
constructor
A new instance of Update.
- #run ⇒ Object
- #validate! ⇒ Object
Constructor Details
#initialize(argv) ⇒ Update
Returns a new instance of Update.
41 42 43 44 45 46 47 |
# File 'lib/pindo/command/lib/update.rb', line 41 def initialize(argv) @args_install_flag = argv.flag?('install', false) @project_dir = argv.option('p') @additional_args = argv.remainder! super(argv) end |
Class Method Details
.options ⇒ Object
34 35 36 37 38 39 |
# File 'lib/pindo/command/lib/update.rb', line 34 def self. [ ['--install', '更新完lib之后执行pod install, pindo lib update --install'], ['--p', '指定需要lint的pod库所在目录, 例如 --p=~/Users/xxx/MyPod'], ].concat(super) end |
Instance Method Details
#run ⇒ Object
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 |
# File 'lib/pindo/command/lib/update.rb', line 54 def run working_dir = @project_dir pod_array = pindo_single_config.pod_repo_dict pod_index_url = nil if !pod_array.nil? pod_index_url = pod_array['podindex'] else raise Informative, '私有Pod索引地址未知!!' end sources = Pod::Config.instance.sources_manager.all repos_path = File.("~/.cocoapods/repos") private_source = sources.select { |s| s.git? && s.url.to_s.eql?(pod_index_url)}.first if !private_source.nil? puts "私有Pod地址:#{pod_index_url}" puts "私有Pod目录:~/.cocoapods" getcode_to_dir(reponame:File.basename(private_source.repo), remote_url: pod_index_url, path:repos_path) else puts "私有Pod地址:#{pod_index_url}" puts "私有Pod目录:~/.cocoapods" repository_name = pod_index_url.split("/").last.chomp(".git") getcode_to_dir(reponame:repository_name, remote_url: pod_index_url, path:repos_path) end if @args_install_flag begin if File.exist?("#{working_dir}/Podfile") Pod::Command::Install::run(['--clean-install']) end rescue => e puts e. end end end |
#validate! ⇒ Object
49 50 51 52 |
# File 'lib/pindo/command/lib/update.rb', line 49 def validate! super @project_dir=Dir.pwd if @project_dir.nil? || @project_dir.empty? end |