Class: DYAutomate::DYAutomateConfig
- Defined in:
- lib/DYAutomate/CustomConfig/DYAutomateConfig.rb
Constant Summary collapse
- @@cachePath =
cache相关的路径
File.join(Dir.home(),'Documents','.DYAutomate')
- @@configFilePath =
File.join(@@cachePath, 'DYConfigFile.rb')
- @@configGitClonePath =
File.join(@@cachePath, 'Git')
- @@logsDirPath =
File.join(@@cachePath, 'log')
Instance Attribute Summary collapse
-
#codeSnippsets_git_url ⇒ Object
Returns the value of attribute codeSnippsets_git_url.
-
#detail_git ⇒ Object
Returns the value of attribute detail_git.
-
#detail_git_tag ⇒ Object
Returns the value of attribute detail_git_tag.
-
#detailObj ⇒ Object
Returns the value of attribute detailObj.
-
#templates_cache_path ⇒ Object
Returns the value of attribute templates_cache_path.
-
#templates_git_url ⇒ Object
Returns the value of attribute templates_git_url.
Class Method Summary collapse
- .cachePath ⇒ Object
-
.checkConfigFile? ⇒ Boolean
检测config.rb是否存在.
- .configFilePath ⇒ Object
- .configGitClonePath ⇒ Object
-
.creatConfigFile ⇒ Object
创建一个ConfigFile例子.
-
.loadConfig ⇒ Object
从配置中心读取.
- .logsDirPath ⇒ Object
Instance Method Summary collapse
- #check_git_dir ⇒ Object
- #check_git_version ⇒ Object
- #clone_git ⇒ Object
-
#initialize ⇒ DYAutomateConfig
constructor
A new instance of DYAutomateConfig.
- #loadDetailFromGit ⇒ Object
Methods inherited from DYBaseObj
#doCacheByYAML, fromFile, fromYAML
Constructor Details
#initialize ⇒ DYAutomateConfig
Returns a new instance of DYAutomateConfig.
30 31 32 |
# File 'lib/DYAutomate/CustomConfig/DYAutomateConfig.rb', line 30 def initialize super end |
Instance Attribute Details
#codeSnippsets_git_url ⇒ Object
Returns the value of attribute codeSnippsets_git_url.
26 27 28 |
# File 'lib/DYAutomate/CustomConfig/DYAutomateConfig.rb', line 26 def codeSnippsets_git_url @codeSnippsets_git_url end |
#detail_git ⇒ Object
Returns the value of attribute detail_git.
21 22 23 |
# File 'lib/DYAutomate/CustomConfig/DYAutomateConfig.rb', line 21 def detail_git @detail_git end |
#detail_git_tag ⇒ Object
Returns the value of attribute detail_git_tag.
22 23 24 |
# File 'lib/DYAutomate/CustomConfig/DYAutomateConfig.rb', line 22 def detail_git_tag @detail_git_tag end |
#detailObj ⇒ Object
Returns the value of attribute detailObj.
24 25 26 |
# File 'lib/DYAutomate/CustomConfig/DYAutomateConfig.rb', line 24 def detailObj @detailObj end |
#templates_cache_path ⇒ Object
Returns the value of attribute templates_cache_path.
28 29 30 |
# File 'lib/DYAutomate/CustomConfig/DYAutomateConfig.rb', line 28 def templates_cache_path @templates_cache_path end |
#templates_git_url ⇒ Object
Returns the value of attribute templates_git_url.
25 26 27 |
# File 'lib/DYAutomate/CustomConfig/DYAutomateConfig.rb', line 25 def templates_git_url @templates_git_url end |
Class Method Details
.cachePath ⇒ Object
34 35 36 |
# File 'lib/DYAutomate/CustomConfig/DYAutomateConfig.rb', line 34 def self.cachePath @@cachePath end |
.checkConfigFile? ⇒ Boolean
检测config.rb是否存在
61 62 63 64 65 66 67 68 69 |
# File 'lib/DYAutomate/CustomConfig/DYAutomateConfig.rb', line 61 def self.checkConfigFile? path = File.join(@@configFilePath) unless File.exist?(path) creatConfigFile puts "*** At first ,you should edit the config file at path<#{@@configFilePath}>!!" `open #{@@configFilePath}` end end |
.configFilePath ⇒ Object
38 39 40 |
# File 'lib/DYAutomate/CustomConfig/DYAutomateConfig.rb', line 38 def self.configFilePath @@configFilePath end |
.configGitClonePath ⇒ Object
42 43 44 |
# File 'lib/DYAutomate/CustomConfig/DYAutomateConfig.rb', line 42 def self.configGitClonePath @@configGitClonePath end |
.creatConfigFile ⇒ Object
创建一个ConfigFile例子
72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 |
# File 'lib/DYAutomate/CustomConfig/DYAutomateConfig.rb', line 72 def self.creatConfigFile unless Dir.exist?(@@cachePath) Dir.mkdir(@@cachePath,0777) end File.new(@@configFilePath,'w+') f = File.open(@@configFilePath, "w+") demo = <<-EOF #DYAutomate 配置 DYAutomateConfig.new do |c| # 配置的git地址 c.detail_git = "" # 配置的git tag c.detail_git_tag = "" end EOF f.write(demo) end |
.loadConfig ⇒ Object
从配置中心读取
51 52 53 54 55 56 |
# File 'lib/DYAutomate/CustomConfig/DYAutomateConfig.rb', line 51 def self.loadConfig checkConfigFile? cc = DYAutomateConfig.fromFile(@@configFilePath) cc.loadDetailFromGit if cc cc end |
.logsDirPath ⇒ Object
46 47 48 |
# File 'lib/DYAutomate/CustomConfig/DYAutomateConfig.rb', line 46 def self.logsDirPath @@logsDirPath end |
Instance Method Details
#check_git_dir ⇒ Object
111 112 113 114 115 |
# File 'lib/DYAutomate/CustomConfig/DYAutomateConfig.rb', line 111 def check_git_dir unless Dir.exist?(@@configGitClonePath) Dir.mkdir(@@configGitClonePath,0777) end end |
#check_git_version ⇒ Object
117 118 119 120 121 122 123 124 125 126 127 |
# File 'lib/DYAutomate/CustomConfig/DYAutomateConfig.rb', line 117 def check_git_version versionFile = File.join(@@configGitClonePath,"version") isSame = false if File.exist?(versionFile) versionContent = File.open(versionFile, 'r:utf-8', &:read) if versionContent isSame = versionContent.chomp.eql?(@detail_git_tag.chomp) end end isSame end |
#clone_git ⇒ Object
129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 |
# File 'lib/DYAutomate/CustomConfig/DYAutomateConfig.rb', line 129 def clone_git check_git_dir if @detail_git_tag && @detail_git url = "#{@detail_git} --branch #{@detail_git_tag}" # url = "#{@git} " cloneOk = system "git clone #{url} #{@@configGitClonePath}" if cloneOk puts "clone #{url}成功。。。" else puts "clone #{url}失败!!" end else puts end end |
#loadDetailFromGit ⇒ Object
145 146 147 148 149 150 151 152 153 154 155 |
# File 'lib/DYAutomate/CustomConfig/DYAutomateConfig.rb', line 145 def loadDetailFromGit puts "加载配置。。。" check_git_dir unless check_git_version system("rm -rf #{@@configGitClonePath}") clone_git end path = File.join(@@configGitClonePath,'detailConfig.rb') @detailObj = DYAutomateConfigDetail.fromFile(path) if File.exist?(path) puts "加载配置成功。。。" if @detailObj end |