Class: DYAutomate::Command::CodeGenerate

Inherits:
DYAutomate::Command show all
Defined in:
lib/DYAutomate/Command/codeGenerate.rb

Instance Attribute Summary collapse

Attributes inherited from DYAutomate::Command

#config, #env_str, #repo_name

Instance Method Summary collapse

Methods inherited from DYAutomate::Command

#pp

Constructor Details

#initialize(argv) ⇒ CodeGenerate

Returns a new instance of CodeGenerate.



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

def initialize(argv)
  @path = Dir.pwd
  super
end

Instance Attribute Details

#pathObject

当前路径



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

def path
  @path
end

Instance Method Details

#clone_templatesObject



43
44
45
46
47
48
49
50
51
52
53
# File 'lib/DYAutomate/Command/codeGenerate.rb', line 43

def clone_templates
  url = @config.templates_git_url
  path = @config.templates_cache_path
  system("rm -rf #{path}")
  unless Dir.exist?(path)
    Dir.mkdir(path,0777)
  end
  UI.puts("Cloning `#{url}` into `#{path}`.")
  system("git clone #{url} --depth 1 #{path}")

end

#runObject



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

def run
    clone_templates
    exulateFile = File.join(@config.templates_cache_path,"ACMain.rb")
    if File.exist?(exulateFile)
      system("ruby #{exulateFile} #{Dir.pwd}")
    else
      UI.puts "cant find templates start file <ACMain.rb>."
    end
end

#validate!Object



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

def validate!
  super
  unless @config.templates_git_url
      help! "
      error -- >!!! Not found <templates_git_url> in the #{DYAutomateConfig.configFilePath}"
  end
end