Class: DYAutomate::Command::WorkSpace

Inherits:
DYAutomate::Command show all
Defined in:
lib/DYAutomate/Command/workspace.rb,
lib/DYAutomate/Command/Workspace/update.rb,
lib/DYAutomate/Command/Workspace/install.rb

Direct Known Subclasses

Install, Update

Defined Under Namespace

Classes: Install, Update

Instance Attribute Summary collapse

Attributes inherited from DYAutomate::Command

#config, #env_str, #repo_name

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from DYAutomate::Command

#pp

Constructor Details

#initialize(argv) ⇒ WorkSpace

Returns a new instance of WorkSpace.



34
35
36
37
38
39
40
# File 'lib/DYAutomate/Command/workspace.rb', line 34

def initialize(argv)
  # @path = '/Users/cw/Documents/Dy/Apps/doing/doing'
  super
  @path = Dir.pwd
  @isSilent = argv.flag?("silent")
  puts "env == #{@env_str}"
end

Instance Attribute Details

#isSilentObject

是否静默



32
33
34
# File 'lib/DYAutomate/Command/workspace.rb', line 32

def isSilent
  @isSilent
end

#nameObject

lib名字



22
23
24
# File 'lib/DYAutomate/Command/workspace.rb', line 22

def name
  @name
end

#pathObject

当前路径



24
25
26
# File 'lib/DYAutomate/Command/workspace.rb', line 24

def path
  @path
end

#project_pathObject

spec文件路径



27
28
29
# File 'lib/DYAutomate/Command/workspace.rb', line 27

def project_path
  @project_path
end

#workSpace_pathObject

#查询结果lib信息



29
30
31
# File 'lib/DYAutomate/Command/workspace.rb', line 29

def workSpace_path
  @workSpace_path
end

Class Method Details

.optionsObject



15
16
17
18
19
# File 'lib/DYAutomate/Command/workspace.rb', line 15

def self.options
  [
    ['--silent', 'Show nothing'],
  ].concat(super)
end

Instance Method Details

#dy_update_repoObject

更新repo



92
93
94
95
96
97
98
99
100
101
# File 'lib/DYAutomate/Command/workspace.rb', line 92

def dy_update_repo
  path = File.join(Dir.home,'.cocoapods/repos')
  excludeFiles = [".","..",".DS_Store",'master','trunk']
  Dir.entries(path).each do |subDir|
    puts subDir
    unless excludeFiles.include?(subDir)
      system "#{@env_str} pod repo update #{subDir}"
    end
  end
end

#existProject?Boolean

project文件是否存在

Returns:

  • (Boolean)


64
65
66
67
68
69
70
71
72
73
74
75
76
# File 'lib/DYAutomate/Command/workspace.rb', line 64

def existProject?
  exist = false
  Dir.entries(@path).each{ |d|
    if d.to_s =~ /.xcodeproj/
      exist = true
      @project_path = File.join(@path,d.to_s)
      # @spec_name = d.to_s
      @name = d.to_s.split('.')[0]
      break
    end
  }
  exist
end

#existWorkSpace?Boolean

workspace文件是否存在

Returns:

  • (Boolean)


79
80
81
82
83
84
85
86
87
88
89
# File 'lib/DYAutomate/Command/workspace.rb', line 79

def existWorkSpace?
  exist = false
  Dir.entries(@path).each{ |d|
    if d.to_s =~ /.xcworkspace/
      exist = true
      @workSpace_path = File.join(@path,d.to_s)
      break
    end
  }
  exist
end

#runObject



58
59
60
61
# File 'lib/DYAutomate/Command/workspace.rb', line 58

def run
  pp('WorkSpace run ...',1)
  pp("当前环境变量 #{@env_str}",1)
end

#validate!Object



42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# File 'lib/DYAutomate/Command/workspace.rb', line 42

def validate!
  super
  unless existProject?
    help! "
    error -- >has no project file at -->  #{@path}"
  else
    pp("find project at -->#{@project_path}",1)
  end

  # unless existWorkSpace?
  #   help! "!!! has no xcworkspace file at --> #{@path}"
  # else
  #   pp("find xcworkspace at --> " + "#{@workSpace_path}",1)
  # end
end