Class: Pod::Command::Ykutility::Gen

Inherits:
Pod::Command::Ykutility show all
Defined in:
lib/cocoapods-ykutility/command/gen.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(argv) ⇒ Gen

Returns a new instance of Gen.



34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# File 'lib/cocoapods-ykutility/command/gen.rb', line 34

def initialize(argv)
  @config = YKPod::YKCreatePodConfig.new()

  @config.name = argv.shift_argument
  @config.language = (["objc", "oc"].include? argv.option('language', "swift").downcase) ? "objc" : "swift"
  nodemo = argv.flag?('nodemo', false)
  @config.with_demo = !nodemo
  @config.with_register = argv.flag?('business', false)

  author = argv.option('author', open("|git config --global user.name").gets)
  author = author.blank? ?  "defualt_author" :  author
  @config.author = author.strip.gsub('.', '')

  email = argv.option('email', open("|git config --global user.email").gets)
  email = email.blank? ?  "defualt_email" :  email
  @config.author_email = email.strip

  @config.prefix = argv.option('prefix', "ST")
  @config.path = File.expand_path(argv.option('pod-path', Dir.getwd.to_s))
  super
  @additional_args = argv.remainder!
end

Class Method Details

.optionsObject



22
23
24
25
26
27
28
29
30
31
32
# File 'lib/cocoapods-ykutility/command/gen.rb', line 22

def self.options
  [
    ['--language=LANGUAGE', 'Language  [ ObjC / Swift ]'],
    ['--nodemo', 'Without a demo application for your library'],
    ['--author=AUTHOR', 'Author'],
    ['--email=EMAIL', 'Email'],
    ['--prefix=PREFIX', 'Prefix header'],
    ['--pod-path=PATH', 'Pod created at path'],
    ['--business', 'With service/router register template'],
  ].concat(super)
end

Instance Method Details

This method returns an undefined value.

Runs the template configuration utilities.



74
75
76
# File 'lib/cocoapods-ykutility/command/gen.rb', line 74

def print_info
  UI.puts "\nTo learn more about the template see `#{CocoapodsYkPodUtility::YK_POD_TEMPLATE_PATH}`."
end

#runObject



65
66
67
68
# File 'lib/cocoapods-ykutility/command/gen.rb', line 65

def run
  puts("create pod run")
  YKPod::YKGenCreate.new(@config).createAction
end

#validate!Object



57
58
59
60
61
62
63
# File 'lib/cocoapods-ykutility/command/gen.rb', line 57

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