Class: YKPod::YKCreate

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

Instance Method Summary collapse

Methods included from YKExchangeTool

#updateFileDirs, #updateFiles

Methods included from YKLogTool

#ykError, #ykMessage, #ykNotice, #ykWarning

Constructor Details

#initialize(conf) ⇒ YKCreate

Returns a new instance of YKCreate.



16
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
# File 'lib/cocoapods-ykutility/command/create/yk_create_pod_action.rb', line 16

def initialize(conf)

  @config = YKPod::YKCreatePodConfig
  @config = conf

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

  @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_POD_TEMPLATE_PATH, @config.language)
  @gitignore_file_path = File.join(CocoapodsYkPodUtility::YK_POD_TEMPLATE_PATH, "gitignore")
  @template_example_path = File.join(CocoapodsYkPodUtility::YK_POD_TEMPLATE_PATH, "example")
  @register_pod_path = File.join(CocoapodsYkPodUtility::YK_POD_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



46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# File 'lib/cocoapods-ykutility/command/create/yk_create_pod_action.rb', line 46

def createAction()
  ykNotice "create pod 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