Class: YKPod::YKGenCreate

Inherits:
Object
  • Object
show all
Includes:
YKExchangeTool, YKLogTool
Defined in:
lib/cocoapods-ykutility/command/gen/yk_gen_create_action.rb

Instance Method Summary collapse

Methods included from YKExchangeTool

#updateFileDirs, #updateFiles

Methods included from YKLogTool

#ykError, #ykMessage, #ykNotice, #ykWarning

Constructor Details

#initialize(conf) ⇒ YKGenCreate

Returns a new instance of YKGenCreate.



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/cocoapods-ykutility/command/gen/yk_gen_create_action.rb', line 17

def initialize(conf)

  @config = YKPod::YKCreatePodConfig
  @config = conf

  # name = conf.start_with?(conf.prefix) ? name : conf.prefix + name
  # @config.name = name

  l_path = @config.path
  @project_dir_dest = File.join(@config.path, @config.prefix_name)
  @example_dir_dest = File.join(@project_dir_dest, "Example")

  @template_pod_path = File.join(CocoapodsYkPodUtility::YK_GEN_TEMPLATE_PATH, @config.language)
  @template_example_path = File.join(CocoapodsYkPodUtility::YK_GEN_TEMPLATE_PATH, "example")
  @gitignore_file_path = File.join(CocoapodsYkPodUtility::YK_GEN_TEMPLATE_PATH, "gitignore")
  @register_pod_path = File.join(CocoapodsYkPodUtility::YK_GEN_BUSINESS_REGISTER_PATH, @config.language)

  time_str = Time.now.strftime("%Y/%m/%d")
  year_str = Time.now.strftime("%Y")
  # 关键字替换
  @keyMap = {
    "YKRPC_POD_NAME" => @config.prefix_name,
    "YKRPC_AUTHOR_NAME" => @config.author,
    "YKRPC_AUTHOR_EMAIL" => @config.author_email,
    "YKRPC_CLASS_PREFIX" => @config.prefix,
    "YKRPC_CREATE_DATE" => time_str,
    "YKRPC_CREATE_YEAR" => year_str,
  }

end

Instance Method Details

#createActionObject



48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
# File 'lib/cocoapods-ykutility/command/gen/yk_gen_create_action.rb', line 48

def createAction()
  ykNotice "create gen project execute: \n name: #{@config.name} \n language: #{@config.language} \n with_demo: #{@config.with_demo} \n path: #{@config.path} \n author: #{@config.author}\n author_email: #{@config.author_email}"
  code = create_path
  exit!(code) unless code == 0

  code = create_pod()
  exit!(code) unless code == 0

  if @config.with_demo
    code = create_example
    exit!(code) unless code == 0

    pod_install
  end

end