lg_pod_plugin 1.0.0 → 1.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2b53208ed4fa32c2ca693aaa0b1d960ba2699e0a1b5e89c521123f489c35dc9b
4
- data.tar.gz: da8650d3f68524a9b25667094edc57386509ef86c7ca90c1dacd350365efe8ea
3
+ metadata.gz: c7a39307dd5e4f73faefa55775b51e880f9f0fda326cc618c62b957ddcba669e
4
+ data.tar.gz: 46777e3af13f74c44086743bb48352373539806a22aafc758eb104dde3f4864c
5
5
  SHA512:
6
- metadata.gz: 42d727f09c1e37babdde7cc562af7c5301e11813b37768d138b57bb76f3fe28e40ad1e1fc3d81db341fa5c901275e2c894778814a285768240fbbff872368b84
7
- data.tar.gz: 3ce6ae923d9c7c8af2a5a514d137935efeb111607b1bc52c49e4bd7c130c48153857816efd67c07b8b77e80110e5710c25da861316d70339993377fc866f3027
6
+ metadata.gz: a945450a624206b131df0b963fbd8616b4df179112b54f41625ed90a46b5480823d74b80c0dc75c227f56de3d74fe225cb44243396d11ff7d864399adcbd89a0
7
+ data.tar.gz: c72bbba5713477f4f094387b650298768e94ec3de1a831daead4d2eb588654cb58190d3cbd474e983bc7b02c2b3ce144c032f27722ea75802020a513488490a8
data/README.md CHANGED
@@ -1,3 +1,4 @@
1
+ 安装和使用教程: https://juejin.cn/post/7142388587852464135
1
2
  # LgPodPlugin
2
3
 
3
4
  Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/lg_pod_plugin`. To experiment with that code, run `bin/console` for an interactive prompt.
@@ -0,0 +1,18 @@
1
+ # require 'claide'
2
+ #
3
+ # module LgPodPlugin
4
+ # class Cache < Command
5
+ # self.abstract_command = true
6
+ # self.summary = 'Inter-process communication'
7
+ # def initialize(argv)
8
+ #
9
+ # end
10
+ # def output_pipe
11
+ # pp "hello world"
12
+ # end
13
+ #
14
+ # def run
15
+ # pp "run"
16
+ # end
17
+ # end
18
+ # end
@@ -0,0 +1,35 @@
1
+ # require 'claide'
2
+ #
3
+ # module LgPodPlugin
4
+ # class Command < CLAide::Command
5
+ # require_relative './cache'
6
+ #
7
+ # self.abstract_command = true
8
+ # self.command = 'pod'
9
+ # self.version = VERSION
10
+ # self.description = 'this is my command lint tool!'
11
+ # self.plugin_prefixes = %w(claide cocoapods)
12
+ #
13
+ # def self.options
14
+ # [
15
+ # ['--allow-root', 'Allows CocoaPods to run as root'],
16
+ # ['--silent', 'Show nothing'],
17
+ # ].concat(super)
18
+ # end
19
+ #
20
+ # def self.run(argv)
21
+ # super(argv)
22
+ # end
23
+ #
24
+ # def initialize(argv)
25
+ # super
26
+ # # config.silent = argv.flag?('silent', config.silent)
27
+ # # config.allow_root = argv.flag?('allow-root', config.allow_root)
28
+ # # config.verbose = self.verbose? unless verbose.nil?
29
+ # unless self.ansi_output?
30
+ # Colored2.disable!
31
+ # String.send(:define_method, :colorize) { |string, _| string }
32
+ # end
33
+ # end
34
+ # end
35
+ # end
@@ -28,24 +28,15 @@ class Cache
28
28
  #判断缓存是否存在且有效命中缓存
29
29
  def find_pod_cache(name ,git, branch, is_update)
30
30
  last_commit = nil
31
-
32
31
  if is_update
33
- puts "git ls-remote #{git} #{branch}"
34
- sha = %x(git ls-remote #{git} #{branch}).split(" ").first
35
- if sha
36
- last_commit = sha
37
- else
38
- ls = Git.ls_remote(git, :refs => true )
39
- find_branch = ls["branches"][branch]
40
- if find_branch
41
- last_commit = find_branch[:sha]
42
- end
43
- end
32
+ last_commit = GitUtil.git_ls_remote_refs(git, branch)
44
33
  else
45
34
  local_pod_path = self.get_download_path(name, git, branch)
46
35
  if Dir.exist?(local_pod_path)
47
36
  local_git = Git.open(Pathname("#{local_pod_path}"))
48
37
  last_commit = local_git.log(1).to_s
38
+ else
39
+ last_commit = GitUtil.git_ls_remote_refs(git, branch)
49
40
  end
50
41
  end
51
42
  unless last_commit
@@ -158,7 +149,7 @@ class Cache
158
149
  pods_pecs.each do |s_name, s_spec|
159
150
  destination = path_for_pod(request, {})
160
151
  if !File.exist?(destination) || is_update
161
- puts "Copying #{name} from `#{target}` to `#{destination}` "
152
+ LgPodPlugin.log_green "Copying #{name} from `#{target}` to `#{destination}` "
162
153
  copy_and_clean(target, destination, s_spec)
163
154
  end
164
155
  cache_pod_spec = path_for_spec(request, {})
@@ -3,7 +3,7 @@ require_relative 'cache.rb'
3
3
  require_relative 'database.rb'
4
4
  require_relative 'file_path.rb'
5
5
 
6
- module LgPodPlugin
6
+ module LgPodPlugin
7
7
 
8
8
  class Downloader
9
9
  attr_accessor :git_util
@@ -50,19 +50,18 @@ module LgPodPlugin
50
50
  self.git_util = git
51
51
  is_update = self.is_update_pod
52
52
  self.git_util.git_init(self.name, self.options)
53
- # if name == "LAddressComponents" || name == "LLogger" || name == "LUnityFramework" || name == "LUser"
53
+ # if name == "LBase" || name == "LLogger" || name == "LUnityFramework" || name == "LUser"
54
54
  # pp name
55
55
  # end
56
56
  # tag = options[:tag]
57
57
  git_url = options[:git]
58
58
  # commit = options[:commit]
59
59
  branch = options[:branch]
60
- puts "Pre-downloading: `#{name}` \n"
61
-
60
+ LgPodPlugin.log_green "Using `#{name}` (#{branch})"
62
61
  # 发现本地有缓存, 不需要更新缓存
63
62
  need_download, new_commit = self.cache.find_pod_cache(name, git_url, branch, is_update)
64
63
  unless need_download
65
- puts "find the cache of `#{name}`, you can use it now."
64
+ LgPodPlugin.log_green "find the cache of `#{name}`, you can use it now."
66
65
  return
67
66
  end
68
67
 
@@ -91,7 +90,7 @@ module LgPodPlugin
91
90
  if new_commit != current_commit && is_update
92
91
  #删除旧的pod 缓存
93
92
  self.cache.clean_old_cache(name, git_url, current_commit)
94
- puts "git pull #{name} origin/#{current_branch}\n"
93
+ LgPodPlugin.log_green "git pull #{name} origin/#{current_branch}"
95
94
  self.git_util.should_pull(git, current_branch, new_commit)
96
95
  current_commit = new_commit
97
96
  end
@@ -104,15 +103,15 @@ module LgPodPlugin
104
103
  else
105
104
  branch_exist = git.branches.local.find {|e| e.to_s == branch}
106
105
  if branch_exist
107
- puts "git switch #{name} #{git_url} -b #{branch}\n"
106
+ LgPodPlugin.log_green "git switch #{name} #{git_url} -b #{branch}"
108
107
  self.git_util.git_switch(branch)
109
108
  else
110
- puts "git checkout #{name} #{git_url} -b #{branch}\n"
109
+ LgPodPlugin.log_green "git checkout #{name} #{git_url} -b #{branch}"
111
110
  self.git_util.git_checkout(branch)
112
111
  end
113
112
  current_commit = git.log(1).to_s
114
113
  if current_commit != new_commit
115
- puts "git pull #{name} #{git_url} -b #{branch}\n"
114
+ LgPodPlugin.log_green "git pull #{name} #{git_url} -b #{branch}"
116
115
  self.git_util.should_pull(git, current_branch, new_commit)
117
116
  current_commit = new_commit
118
117
  end
@@ -27,9 +27,8 @@ module LgPodPlugin
27
27
  def git_clone(path)
28
28
  if self.branch
29
29
  temp_git_path = path.join("l-temp-pod")
30
- puts "git clone --template= --single-branch --depth 1 --branch #{self.branch} #{self.git}\n"
30
+ LgPodPlugin.log_blue "git clone --template= --single-branch --depth 1 --branch #{self.branch} #{self.git}"
31
31
  system("git clone --template= --single-branch --depth 1 --branch #{self.branch} #{self.git} #{temp_git_path}")
32
- puts "\n"
33
32
  temp_git_path
34
33
  else
35
34
  nil
@@ -76,12 +75,12 @@ module LgPodPlugin
76
75
  end
77
76
 
78
77
  # 本地pod库git操作
79
- def git_local_pod_check
80
- FileUtils.chdir(self.path)
78
+ def git_local_pod_check(path)
79
+ FileUtils.chdir(path)
81
80
  git = Git.open(Pathname("./"))
82
81
  current_branch = git.current_branch
83
82
  last_stash_message = "#{current_branch}_pod_install_cache"
84
- if self.branch == current_branch
83
+ if self.branch == current_branch || !self.branch
85
84
  # 是否恢复储藏内容到暂存区
86
85
  self.should_pull(git ,current_branch)
87
86
  else
@@ -104,12 +103,30 @@ module LgPodPlugin
104
103
  end
105
104
  end
106
105
 
106
+ # 获取最新的一条 commit 信息
107
+ def self.git_ls_remote_refs(git, branch)
108
+ last_commit = nil
109
+ LgPodPlugin.log_green "git ls-remote #{git} #{branch}"
110
+ sha = %x(git ls-remote #{git} #{branch}).split(" ").first
111
+ if sha
112
+ last_commit = sha
113
+ return last_commit
114
+ else
115
+ ls = Git.ls_remote(git, :refs => true )
116
+ find_branch = ls["branches"][branch]
117
+ if find_branch
118
+ last_commit = find_branch[:sha]
119
+ return last_commit
120
+ end
121
+ return nil
122
+ end
123
+ end
124
+
107
125
  # 是否pull 代码
108
126
  def should_pull(git, branch, new_commit = nil)
109
127
  git_url = git.remote.url
110
128
  if new_commit == nil
111
- puts "git ls-remote #{git_url} #{branch}"
112
- new_commit = %x(git ls-remote #{git_url} #{branch}).split(" ").first
129
+ new_commit = GitUtil.git_ls_remote_refs(git_url, branch)
113
130
  end
114
131
  local_commit = git.log(1).to_s #本地最后一条 commit hash 值
115
132
  if local_commit != new_commit
@@ -9,52 +9,105 @@ require_relative 'git_util'
9
9
  require_relative 'pod_spec.rb'
10
10
 
11
11
  module LgPodPlugin
12
+
12
13
  class Installer
14
+ attr_accessor :name
15
+ attr_accessor :version
16
+ attr_accessor :options
17
+ attr_accessor :profile
18
+ attr_accessor :target
19
+ attr_accessor :real_name
13
20
  attr_accessor :downloader
14
21
  attr_accessor :git_util
15
- def initialize(defined_in_file = nil, profile, &block)
16
- @defined_in_file = defined_in_file
17
- @target = profile.send(:current_target_definition)
22
+
23
+ def initialize(profile, name, *requirements)
24
+ if name.include?("/")
25
+ self.name = name.split("/").first
26
+ else
27
+ self.name = name
28
+ end
29
+ self.real_name = name
30
+ self.profile = profile
18
31
  self.git_util = GitUtil.new
19
32
  self.downloader = Downloader.new
20
- if block
21
- instance_eval(&block)
33
+ self.target = profile.send(:current_target_definition)
34
+
35
+ unless requirements && !requirements.empty?
36
+ self.pod(self.real_name, requirements)
37
+ return
38
+ end
39
+
40
+ first = requirements[0].first
41
+ if "#{first.class}" == "String"
42
+ self.version = first
43
+ elsif "#{first.class}" == "Hash"
44
+ self.options = first
22
45
  end
46
+
47
+ hash_map = requirements[0].last
48
+ if "#{hash_map.class}" == "Hash"
49
+ self.options = hash_map
50
+ end
51
+
52
+ self.pod(name, requirements)
53
+
23
54
  end
24
55
 
56
+ private
57
+
25
58
  # @param [Object] name
26
59
  # @param [Hash] options
27
60
  # @return [Object] nil
28
- def pod(name, options = {})
61
+ def pod(name, *requirements)
29
62
  unless name
30
63
  raise StandardError, 'A dependency requires a name.'
31
64
  end
32
- if options[0].is_a?(String)
33
- version = options[0].to_s
34
- @target.store_pod(name, version)
65
+
66
+ if !requirements
67
+ self.target.store_pod(self.real_name)
35
68
  return
36
69
  end
37
70
 
38
- path = options[:path]
39
- tag = options[:tag]
40
- commit = options[:commit]
41
- url = options[:git]
42
- branch = options[:branch]
43
- depth = options[:depth] ||= true
71
+ if self.version && !self.options
72
+ self.target.store_pod(self.real_name, self.version)
73
+ return
74
+ end
75
+
76
+ if self.version && self.options
77
+ self.target.store_pod(self.real_name, self.version, self.options)
78
+ return
79
+ end
80
+
81
+ hash_map = self.options
82
+ unless hash_map.is_a?(Hash)
83
+ self.target.store_pod(self.real_name)
84
+ return
85
+ end
44
86
 
87
+ real_path = nil
88
+ tag = hash_map[:tag]
89
+ url = hash_map[:git]
90
+ path = hash_map[:path]
91
+ commit = hash_map[:commit]
92
+ branch = hash_map[:branch]
93
+ depth = hash_map[:depth] ||= true
94
+ if path
95
+ profile_path = self.profile.send(:defined_in_file).dirname
96
+ real_path = Pathname.new(path).expand_path(profile_path)
97
+ end
45
98
  # 找到本地组件库 执行 git pull
46
- if path && File.directory?(path)
47
- self.install_local_pod(name, options)
99
+ if real_path && File.directory?(real_path)
100
+ hash_map[:path] = real_path
101
+ self.install_local_pod(self.name, hash_map)
48
102
  return
49
103
  end
50
104
 
51
105
  # 根据tag, commit下载文件
52
- hash_map = options
53
106
  hash_map.delete(:path)
54
107
  if tag || commit
55
108
  hash_map.delete(:branch)
56
109
  hash_map.delete(:depth)
57
- @target.store_pod(name, hash_map)
110
+ self.target.store_pod(self.real_name, hash_map)
58
111
  return
59
112
  end
60
113
 
@@ -63,17 +116,19 @@ module LgPodPlugin
63
116
  hash_map.delete(:tag)
64
117
  hash_map.delete(:commit)
65
118
  hash_map.delete(:depth)
66
- self.downloader.download_init(name, options)
119
+ self.downloader.download_init(self.name, options)
67
120
  self.downloader.pre_download_pod(self.git_util)
68
- @target.store_pod(name, hash_map)
121
+ self.target.store_pod(self.real_name, hash_map)
69
122
  end
70
123
 
71
124
  end
72
125
 
126
+ private
127
+
73
128
  def install_form_specs(spec_path = nil)
74
129
  spec_path ||= './Specs'
75
130
  path = File.expand_path(spec_path, Dir.pwd)
76
- file_objects = Dir.glob(File.expand_path("*.rb",path)).map do |file_path|
131
+ file_objects = Dir.glob(File.expand_path("*.rb", path)).map do |file_path|
77
132
  #读取 xxx.rb文件
78
133
  Spec.form_file(file_path)
79
134
  end
@@ -88,27 +143,30 @@ module LgPodPlugin
88
143
  end
89
144
 
90
145
  private
146
+
91
147
  def install_local_pod(name, options = {})
92
148
  hash_map = options
93
- path = options[:path]
149
+ local_path = options[:path]
94
150
  branch = options[:branch]
95
- unless Dir.exist?(path)
96
- puts "no such file or directory at path => `#{path}`"
151
+ unless Dir.glob(File.expand_path(".git", local_path)).count > 0
152
+ LgPodPlugin.log_red("pod `#{name}` at path => #{local_path} 找不到.git目录")
97
153
  return
98
154
  end
99
- local_path = Pathname(path)
100
- unless local_path.glob("*.git").empty?
101
- puts "path => `#{local_path}` 找不到.git目录"
155
+ unless Dir.glob(File.expand_path("#{name}.podspec", local_path)).count > 0
156
+ LgPodPlugin.log_red("pod `#{name}` at path => #{local_path} 找不到#{name}.podspec文件")
157
+ return
102
158
  end
159
+
103
160
  self.git_util.git_init(name, :branch => branch, :path => local_path)
104
- self.git_util.git_local_pod_check
161
+ self.git_util.git_local_pod_check(local_path)
162
+ hash_map[:path] = local_path.to_path
105
163
  hash_map.delete(:tag)
106
164
  hash_map.delete(:git)
107
165
  hash_map.delete(:depth)
108
166
  hash_map.delete(:commit)
109
167
  hash_map.delete(:branch)
110
168
  # 安装本地私有组件库
111
- @target.store_pod(name, hash_map)
169
+ self.target.store_pod(self.real_name, hash_map)
112
170
  end
113
171
 
114
172
  end
@@ -1,3 +1,3 @@
1
1
  module LgPodPlugin
2
- VERSION = "1.0.0"
2
+ VERSION = "1.0.2"
3
3
  end
data/lib/lg_pod_plugin.rb CHANGED
@@ -1,22 +1,68 @@
1
1
  require 'git'
2
2
  require 'sqlite3'
3
3
  require "lg_pod_plugin/version"
4
+ require 'cocoapods/user_interface'
4
5
  require_relative 'lg_pod_plugin/database'
5
6
  require_relative 'lg_pod_plugin/download'
6
7
  require_relative 'lg_pod_plugin/git_util'
7
8
  require_relative 'lg_pod_plugin/pod_spec'
8
9
  require_relative 'lg_pod_plugin/install'
10
+ require 'cocoapods-core/podfile/target_definition'
9
11
 
10
12
  module LgPodPlugin
11
13
 
14
+ class String
15
+ # colorization
16
+ def colorize(color_code)
17
+ "\e[#{color_code}m#{self}\e[0m"
18
+ end
19
+
20
+ def red
21
+ colorize(31)
22
+ end
23
+
24
+ def green
25
+ colorize(32)
26
+ end
27
+
28
+ def yellow
29
+ colorize(33)
30
+ end
31
+
32
+ def blue
33
+ colorize(34)
34
+ end
35
+
36
+ def pink
37
+ colorize(35)
38
+ end
39
+
40
+ def light_blue
41
+ colorize(36)
42
+ end
43
+ end
44
+
12
45
  class Error < StandardError; end
13
46
 
14
- def self.install(defined_in_file = nil, profile, &block)
15
- Installer.new(defined_in_file, profile, &block)
47
+ def self.log_red(msg)
48
+ Pod::CoreUI.puts msg.red
49
+ end
50
+
51
+ def self.log_blue(msg)
52
+ Pod::CoreUI.puts msg.blue
53
+ end
54
+
55
+ def self.log_green(msg)
56
+ Pod::CoreUI.puts msg.green
57
+ end
58
+
59
+ def self.log(msg)
60
+ Pod::CoreUI.puts msg
16
61
  end
17
62
 
18
- def self.install_form_spec(profile, spec_path = nil)
19
- return Installer.new(profile).install_form_specs(spec_path)
63
+ # Profile 方法进行拓展
64
+ def pod(name, *requirements)
65
+ Installer.new(self, name, requirements)
20
66
  end
21
67
 
22
68
  end
metadata CHANGED
@@ -1,27 +1,41 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lg_pod_plugin
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - dongzb01
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-09-10 00:00:00.000000000 Z
11
+ date: 2022-09-14 00:00:00.000000000 Z
12
12
  dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: claide
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: 1.1.0
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: 1.1.0
13
27
  - !ruby/object:Gem::Dependency
14
28
  name: sqlite3
15
29
  requirement: !ruby/object:Gem::Requirement
16
30
  requirements:
17
- - - '='
31
+ - - "~>"
18
32
  - !ruby/object:Gem::Version
19
33
  version: 1.4.4
20
34
  type: :development
21
35
  prerelease: false
22
36
  version_requirements: !ruby/object:Gem::Requirement
23
37
  requirements:
24
- - - '='
38
+ - - "~>"
25
39
  - !ruby/object:Gem::Version
26
40
  version: 1.4.4
27
41
  - !ruby/object:Gem::Dependency
@@ -56,58 +70,44 @@ dependencies:
56
70
  name: rake
57
71
  requirement: !ruby/object:Gem::Requirement
58
72
  requirements:
59
- - - '='
73
+ - - "~>"
60
74
  - !ruby/object:Gem::Version
61
75
  version: 13.0.6
62
76
  type: :development
63
77
  prerelease: false
64
78
  version_requirements: !ruby/object:Gem::Requirement
65
79
  requirements:
66
- - - '='
80
+ - - "~>"
67
81
  - !ruby/object:Gem::Version
68
82
  version: 13.0.6
69
83
  - !ruby/object:Gem::Dependency
70
84
  name: git
71
85
  requirement: !ruby/object:Gem::Requirement
72
86
  requirements:
73
- - - '='
87
+ - - "~>"
74
88
  - !ruby/object:Gem::Version
75
89
  version: 1.12.0
76
90
  type: :development
77
91
  prerelease: false
78
92
  version_requirements: !ruby/object:Gem::Requirement
79
93
  requirements:
80
- - - '='
94
+ - - "~>"
81
95
  - !ruby/object:Gem::Version
82
96
  version: 1.12.0
83
97
  - !ruby/object:Gem::Dependency
84
98
  name: cocoapods
85
- requirement: !ruby/object:Gem::Requirement
86
- requirements:
87
- - - '='
88
- - !ruby/object:Gem::Version
89
- version: 1.11.3
90
- type: :development
91
- prerelease: false
92
- version_requirements: !ruby/object:Gem::Requirement
93
- requirements:
94
- - - '='
95
- - !ruby/object:Gem::Version
96
- version: 1.11.3
97
- - !ruby/object:Gem::Dependency
98
- name: rspec
99
99
  requirement: !ruby/object:Gem::Requirement
100
100
  requirements:
101
101
  - - "~>"
102
102
  - !ruby/object:Gem::Version
103
- version: '3.0'
103
+ version: 1.11.3
104
104
  type: :development
105
105
  prerelease: false
106
106
  version_requirements: !ruby/object:Gem::Requirement
107
107
  requirements:
108
108
  - - "~>"
109
109
  - !ruby/object:Gem::Version
110
- version: '3.0'
110
+ version: 1.11.3
111
111
  description: 拦截pod_install 方法, 并设置 pod 方法参数列表
112
112
  email:
113
113
  - 1060545231@qq.com
@@ -117,6 +117,8 @@ extra_rdoc_files: []
117
117
  files:
118
118
  - LICENSE
119
119
  - README.md
120
+ - lib/command/cache.rb
121
+ - lib/command/command.rb
120
122
  - lib/lg_pod_plugin.rb
121
123
  - lib/lg_pod_plugin/cache.rb
122
124
  - lib/lg_pod_plugin/database.rb
@@ -145,7 +147,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
145
147
  - !ruby/object:Gem::Version
146
148
  version: '0'
147
149
  requirements: []
148
- rubygems_version: 3.1.6
150
+ rubygems_version: 3.3.22
149
151
  signing_key:
150
152
  specification_version: 4
151
153
  summary: 封装了自定义podfile 中pod 方法