Module: KCommercial::KCPipeline::KimConfig

Defined in:
lib/KCommercialPipeline/core/kim_cfg.rb

Class Method Summary collapse

Class Method Details

.configsObject



30
31
32
# File 'lib/KCommercialPipeline/core/kim_cfg.rb', line 30

def  configs
  @configs ||= readConfig
end

.find_cfg_path(path = Pathname(Dir.pwd)) ⇒ Object



50
51
52
53
54
55
56
57
58
# File 'lib/KCommercialPipeline/core/kim_cfg.rb', line 50

def find_cfg_path(path = Pathname(Dir.pwd))
  find_path = Pathname(path)
  while find_path.parent.to_s != '/' || find_path.to_s != '/'
    aim_path = find_path.join('.pipeline')
    return aim_path if aim_path.exist?
    find_path = find_path.parent
  end
  return nil
end

.readConfigObject



33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/KCommercialPipeline/core/kim_cfg.rb', line 33

def readConfig
  cfg_path= find_cfg_path
  unless  cfg_path
    KCommercial::UI.error("根目录未发现pipeline配置文件\".pipeline\"")
    exit! 1
  end
  KCommercial::UI.debug("读取pipeline配置文件")
  cfg_hash = JSON.parse(File.read(cfg_path))
  KCommercial::UI.debug("pipeline配置#{cfg_hash.to_s}")
  return {} unless cfg_hash
  unless  cfg_hash[Application.instance.app_id]
    KCommercial::UI.error("未配置app=#{Application.instance.app_id}流水线配置 `.pipeline`文件,请检查根目录")
    exit! -1
  end
  cfg_hash[Application.instance.app_id]
end