Class: Pod::Command::Reinstall

Inherits:
Pod::Command show all
Includes:
ProjectDirectory, RepoUpdate
Defined in:
lib/cocoapods-dongjia/command/reinstall.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(argv) ⇒ Reinstall

Returns a new instance of Reinstall.



27
28
29
30
31
32
# File 'lib/cocoapods-dongjia/command/reinstall.rb', line 27

def initialize(argv)
  @save = argv.flag?("save")
  path = argv.shift_argument
  @project_path = Pathname.new(path) if path
  super
end

Class Method Details

.optionsObject



21
22
23
24
25
# File 'lib/cocoapods-dongjia/command/reinstall.rb', line 21

def self.options
  [
    ["--save", "将重新生成的 project.pbxproj 文件保存下来"]
  ]
end

Instance Method Details

#runObject



51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
# File 'lib/cocoapods-dongjia/command/reinstall.rb', line 51

def run

  deintegrator = Deintegrator.new
  deintegrator.deintegrate_project(@project)
  @project.save if @save

  verify_podfile_exists!
  installer = installer_for_config
  installer.repo_update = repo_update?(:default => false)
  installer.update = false
  installer.deployment = @deployment
  installer.clean_install = @clean_install
  installer.install!

end

#validate!Object



34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/cocoapods-dongjia/command/reinstall.rb', line 34

def validate!
  super

  unless @project_path
    xcodeprojs = Pathname.glob('*.xcodeproj')
    @project_path = xcodeprojs.first if xcodeprojs.size == 1
  end

  help! 'A valid Xcode project file is required.' unless @project_path
  help! "#{@project_path} does not exist." unless @project_path.exist?
  unless @project_path.directory? && (@project_path + 'project.pbxproj').exist?
    help! "#{@project_path} is not a valid Xcode project."
  end

  @project = Xcodeproj::Project.open(@project_path)
end