Class: Pod::Command::Ykutility::Push

Inherits:
Pod::Command::Ykutility show all
Includes:
Pod::Config::Mixin, YKPod::YKLogTool
Defined in:
lib/cocoapods-ykutility/command/push.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from YKPod::YKLogTool

#ykError, #ykMessage, #ykNotice, #ykWarning

Constructor Details

#initialize(argv) ⇒ Push

Returns a new instance of Push.



30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/cocoapods-ykutility/command/push.rb', line 30

def initialize(argv)
  # 如果有一部分参数是本类特有的,需要在此处优先取出
  argv_map = argv.remainder
  argv_new = CLAide::ARGV.new(argv.remainder)
  @repo_push_cmd = Pod::Command::Repo::Push.new(argv_new)

  # 因为这部分参数是 本类 和 Pod::Command::Repo::Push 共有的, 所以本类用 argv 取参数, Pod::Command::Repo::Push使用 argv_map 取参数
  @repo = argv.shift_argument
  @podspec = argv.shift_argument
  @source = source_for_repo
  @source_urls = argv.option('sources', config.sources_manager.all.map(&:url).append(Pod::TrunkSource::TRUNK_REPO_URL).uniq.join(',')).split(',')
  argv_extra = argv_new.remainder
  argv_extra.append("--help") if argv_map.include?("--help")
  super(CLAide::ARGV.new(argv_extra))
end

Instance Attribute Details

#argv_cacheObject

Returns the value of attribute argv_cache.



22
23
24
# File 'lib/cocoapods-ykutility/command/push.rb', line 22

def argv_cache
  @argv_cache
end

#repo_push_cmdObject

Returns the value of attribute repo_push_cmd.



21
22
23
# File 'lib/cocoapods-ykutility/command/push.rb', line 21

def repo_push_cmd
  @repo_push_cmd
end

Class Method Details

.optionsObject



26
27
28
# File 'lib/cocoapods-ykutility/command/push.rb', line 26

def self.options
  Pod::Command::Repo::Push.options.concat(super)
end

Instance Method Details

#runObject

Raises:

  • (Informative)


57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
# File 'lib/cocoapods-ykutility/command/push.rb', line 57

def run
  gitmanager = YKUtitlityGitModule::YKGitManager.new(Dir.pwd)
  return false unless gitmanager.prepare == true

  ykNotice "pod ykutility push running !"
  self.repo_push_cmd.run # 使用Pod::Command::Repo::Push,发布pod

  ykNotice "pod ykutility analysis create document running !"
  api_analysis = YKApi::YkApiAnalysis.new(podspec_files, @source_urls)
  aanlysis_success = api_analysis.execute
  raise Informative, "Failed to analysis Component api: #{api_analysis.all_pod_names}" unless aanlysis_success == true
  # 解析podspec, 识别出 公共文件, tag
  # 根据公共文件,生成接口文档
  # 检查tag是否存在,删除已有tag, 删除远端已有tag
  # 添加接口文档,并提交,生成对应版本的tag,并对送到远端
  version = api_analysis.version

  gitmanager.commit_for_api("create api document for version: #{version.to_s}")
  gitmanager.update_tag(version.to_s)

end

#validate!Object

此处validate 是复制 Pod::Command::Repo::Push , 因为如果直接用 self.repo_push_cmd.validate! 会导致提示显示的是 Pod::Command::Repo::Push 的使用说明



46
47
48
49
50
51
52
53
54
55
# File 'lib/cocoapods-ykutility/command/push.rb', line 46

def validate! # 此处validate 是复制 Pod::Command::Repo::Push , 因为如果直接用 self.repo_push_cmd.validate! 会导致提示显示的是 Pod::Command::Repo::Push  的使用说明
  super

  help! 'A spec-repo name or url is required.' unless @repo
  unless @source && @source.repo.directory?
    raise Informative,
          "Unable to find the `#{@repo}` repo. " \
          'If it has not yet been cloned, add it via `pod repo add`.'
  end
end