Class: Pod::Command::Module::Push

Inherits:
Pod::Command::Module show all
Includes:
Executable, ProjectDirectory
Defined in:
lib/cocoapods-module/command/module/push.rb

Instance Method Summary collapse

Constructor Details

#initialize(argv) ⇒ Push

Returns a new instance of Push.



18
19
20
21
22
# File 'lib/cocoapods-module/command/module/push.rb', line 18

def initialize(argv)
	@project_name = argv.shift_argument
  @commit_info = argv.shift_argument
  super
end

Instance Method Details

#runObject



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

def run
  UI.puts "Start execute pod module push command..."
	git! ['add', '.']
	git! ['commit', '-m', @commit_info]
	git! ['remote', 'add', 'origin', "git@gitee.com:giraffex/#{@project_name}.git"]
	git! ['push', '-u', 'origin', 'master']
end

#validate!Object



24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/cocoapods-module/command/module/push.rb', line 24

def validate!
  super

  # 判断是否存在.podspec文件
  podspecs = Pathname.glob('*.podspec')
  @podspec_path = podspecs.first if podspecs.size == 1
  help! "you should cd to pod path. check #{Pathname.getwd}" unless @podspec_path

  # 判断是否存在.git文件
  @gits_path = Pathname.getwd + ".git"
  help! ".git dir is requred. check #{Pathname.getwd}" unless @gits_path.exist?

	unless @project_name
		help! 'project name is required.'
	end

  # 判断是否存填写提交信息
  unless @commit_info
  	help! 'commit infomation is required.'
  end
end