Class: LgPodPlugin::Main

Inherits:
Object
  • Object
show all
Defined in:
lib/lg_pod_plugin/installer/main.rb

Class Method Summary collapse

Class Method Details

.check_podfile_exist?(workspace) ⇒ Boolean

Returns:

  • (Boolean)

Raises:

  • (Informative)


54
55
56
57
58
59
60
# File 'lib/lg_pod_plugin/installer/main.rb', line 54

def self.check_podfile_exist?(workspace)
  podfile_path = workspace.join("Podfile")
  return podfile_path if podfile_path.exist?
  podfile_path = workspace.join("Podfile.rb")
  return podfile_path if podfile_path.exist?
  raise Informative, "No `Podfile' found in the project directory."
end

.clean_sandboxObject

删除旧的换成目录



10
11
12
13
14
15
16
17
18
# File 'lib/lg_pod_plugin/installer/main.rb', line 10

def self.clean_sandbox
  sand_box = LFileManager.download_director
  sand_box.each_child do |f|
    ftype = File::ftype(f)
    next unless ftype == "directory"
    next if f.to_path.include?("database")
    FileUtils.rm_rf f.to_path
  end
end

.install_external_pod(project) ⇒ Object



37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/lg_pod_plugin/installer/main.rb', line 37

def self.install_external_pod(project)
  #下载 External pods
  LgPodPlugin.log_blue "Pre-downloading External Pods" unless project.targets.empty?
  all_installers = Hash.new
  project.targets.each do |target|
    target.dependencies.each do |_, pod|
      installer = LPodInstaller.new
      download_params = installer.install(pod)
      if download_params
        all_installers[download_params["name"]] = installer
      end
    end
  end
  # 通过 swift 可执行文件进行异步下载任务
  LgPodPlugin::Concurrency.async_download_pods(all_installers.values)
end

.run(command, options = {}) ⇒ Object



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/lg_pod_plugin/installer/main.rb', line 21

def self.run(command, options = {})
  self.clean_sandbox
  workspace = Pathname(Dir.pwd)
  update = (command == "update")
  LSqliteDb.shared.init_database
  repo_update = options[:repo_update] ||= false
  LgPodPlugin.log_blue "当前工作目录 #{workspace}"
  podfile_path = check_podfile_exist?(workspace)
  return unless podfile_path
  project = LProject.shared.setup(workspace, podfile_path, update, repo_update)
  self.install_external_pod(project)
  # # 安装开发版本pod
  verbose = options[:verbose] ||= false
  ReleasePod.install_release_pod(update, repo_update, verbose)
end