Class: Gct::Command::Create::Oc

Inherits:
Gct::Command::Create show all
Defined in:
lib/gct/command/create/oc.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Gct::Command

#auto_add_tag, #check_branch_can_be_update, #config_gitlab, #current_branch, #file_contents, #get_project, #gitlab_error, run

Constructor Details

#initialize(argv) ⇒ Oc

Returns a new instance of Oc.



15
16
17
18
19
# File 'lib/gct/command/create/oc.rb', line 15

def initialize(argv)
  @name = argv.shift_argument
  @push_spec = argv.flag?('push-spec', false)
  super
end

Class Method Details

.optionsObject



21
22
23
24
25
# File 'lib/gct/command/create/oc.rb', line 21

def self.options 
  [
    ['--push-spec', '是否上传到pod私有仓库'],
  ].concat(super)
end

Instance Method Details

#runObject



35
36
37
38
39
40
41
42
# File 'lib/gct/command/create/oc.rb', line 35

def run
  system "pod lib create #{@name} objc --template-url=#{Constant.GitThirdURL}pod-template.git"
  puts "一个新的oc pod创建成功!".green

  Dir.chdir(Dir.pwd + '/' + @name) do
    system "pod repo push iOSCRGTPodSource --sources=#{Constant.GitURL}iOSCRGTPodSource.git --verbose --skip-import-validation --use-libraries --allow-warnings" if @push_spec
  end
end

#validate!Object



27
28
29
30
31
32
33
# File 'lib/gct/command/create/oc.rb', line 27

def validate!
  super
  help! 'A name for the Pod is required.' unless @name
  help! 'The Pod name cannot contain spaces.' if @name =~ /\s/
  help! 'The Pod name cannot contain plusses.' if @name =~ /\+/
  help! "The Pod name cannot begin with a '.'" if @name[0, 1] == '.'
end