Class: Jmpod::Command::Create::Third
- Inherits:
-
Jmpod::Command::Create
- Object
- CLAide::Command
- Jmpod::Command
- Jmpod::Command::Create
- Jmpod::Command::Create::Third
- Defined in:
- lib/jmpod/command/create/third.rb
Class Method Summary collapse
Instance Method Summary collapse
- #fork_third_pod_to_gitlab ⇒ Object
-
#initialize(argv) ⇒ Third
constructor
A new instance of Third.
- #run ⇒ Object
- #validate! ⇒ Object
Methods inherited from Jmpod::Command
Constructor Details
#initialize(argv) ⇒ Third
Returns a new instance of Third.
22 23 24 25 26 |
# File 'lib/jmpod/command/create/third.rb', line 22 def initialize(argv) @url = argv.shift_argument @branch = argv.shift_argument super end |
Class Method Details
.options ⇒ Object
16 17 18 19 20 |
# File 'lib/jmpod/command/create/third.rb', line 16 def self. [ ['--silent', 'Show nothing'], ].concat(super) end |
Instance Method Details
#fork_third_pod_to_gitlab ⇒ Object
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/jmpod/command/create/third.rb', line 42 def fork_third_pod_to_gitlab reg = /[a-zA-Z|\-|_|0-9]+(?=\.git)/ dir = reg.match(@url) path = "#{Dir.pwd}/#{dir}" if File::exist?(path) puts "#{dir}文件夹已存在!".red else branch = @branch.to_s.empty? ? '' : "-b #{@branch}" push_branch = @branch.to_s.empty? ? "master" : "#{@branch}" `git clone #{branch} #{@url}` puts "git命令为:<-- git clone #{branch} #{@url} -->".green Dir.chdir(path) do git_url = "#{Constant.GitURL}#{dir}" `git init` `git remote set-url origin #{git_url}.git` `git add .` `git commit -m "First commit"` `git push origin #{push_branch}` `git push --tags` # TODO 将podspec上传到私有specs上 puts "fork 第三方库成功!".green puts "git 地址为:#{git_url}".green system "open #{git_url}" end end end |
#run ⇒ Object
33 34 35 36 37 38 39 40 |
# File 'lib/jmpod/command/create/third.rb', line 33 def run if @url.include? '.git' fork_third_pod_to_gitlab else puts "该链接不是一个Git仓库".red end end |
#validate! ⇒ Object
28 29 30 31 |
# File 'lib/jmpod/command/create/third.rb', line 28 def validate! super help! 'A url for the Pod is required.' unless @url end |