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

Instance Method Summary collapse

Methods inherited from DYAutomate::Command

options, #pp

Constructor Details

#initialize(argv) ⇒ WorkSpace

Returns a new instance of WorkSpace.



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

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

Instance Attribute Details

#nameObject

lib名字



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

def name
  @name
end

#pathObject

当前路径



18
19
20
# File 'lib/DYAutomate/Command/workspace.rb', line 18

def path
  @path
end

#project_pathObject

spec文件路径



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

def project_path
  @project_path
end

#workSpace_pathObject

#查询结果lib信息



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

def workSpace_path
  @workSpace_path
end

Instance Method Details

#dy_update_repoObject

更新repo



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

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)


54
55
56
57
58
59
60
61
62
63
64
65
66
# File 'lib/DYAutomate/Command/workspace.rb', line 54

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)


69
70
71
72
73
74
75
76
77
78
79
# File 'lib/DYAutomate/Command/workspace.rb', line 69

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



48
49
50
51
# File 'lib/DYAutomate/Command/workspace.rb', line 48

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

#validate!Object



32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/DYAutomate/Command/workspace.rb', line 32

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