Class: Lhj::Command::SyncPodCode

Inherits:
Lhj::Command
  • Object
show all
Defined in:
lib/lhj/command/sync_pod_code.rb

Overview

sync code to pod

Instance Method Summary collapse

Methods inherited from Lhj::Command

#auto_spin, #run, #stop

Constructor Details

#initialize(argv) ⇒ SyncPodCode

Returns a new instance of SyncPodCode.



11
12
13
14
# File 'lib/lhj/command/sync_pod_code.rb', line 11

def initialize(argv)
  @cli = HighLine.new
  super
end

Instance Method Details

#begin_titleObject



16
17
18
# File 'lib/lhj/command/sync_pod_code.rb', line 16

def begin_title
  '读取映射文件~/.lhj/pod_config.yml'
end

#handleObject



20
21
22
# File 'lib/lhj/command/sync_pod_code.rb', line 20

def handle
  sync
end

#syncObject



24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/lhj/command/sync_pod_code.rb', line 24

def sync
  config_file = File.join(Lhj::Config.instance.home_dir, 'pod_config.yml')
  arr = YAML.load_file(config_file)
  arr.each_index { |i| puts "#{i}.#{arr[i]['pod']}".yellow }
  idx = @cli.ask('请选择哪一个库同步: '.green).strip.to_i
  src = arr[idx]['main_path']
  dest = arr[idx]['pod_path']
  FileUtils.cp_r(src, dest, remove_destination: true)
  puts '1.从主工程复制代码到pod库成功'.green

  Dir.chdir(dest) do

    Actions.sh('git add .')
    puts '2.git add成功'.green

  end
end