module QCloudHive::Config

Constants

SHARE_CONFIG
USE_FRAMEWORKS

Attributes

bitcodeEnable[RW]
buildFromCommit[RW]
cmdPath[RW]
namespaceID[RW]
runPath[RW]
scriptesDirectory[RW]
team[RW]
templateManifestPath[RW]
templatesPath[RW]
useFrameworks[RW]

Public Class Methods

dumpShareConfig() click to toggle source
# File lib/qcloudhive/config.rb, line 40
    def Config.dumpShareConfig
       conf = "[#{SHARE_CONFIG}]
#{USE_FRAMEWORKS} = #{useFrameworks}"
       file = Pathname(repoRoot()).join("share.conf").to_path
       File.open(file, "w") { |f|
         f.write conf
       }
    end
loadShareConfig() click to toggle source
# File lib/qcloudhive/config.rb, line 48
def Config.loadShareConfig
  configFilePath = Pathname(repoRoot()).join("share.conf").to_path
  if File.exist?(configFilePath) != true
    return
  end
  config = ParseConfig.new(configFilePath)
  L.info("config #{config} #{config.class}")
  if not config.nil?
    shareConfig = config[SHARE_CONFIG]
    L.info("shareConfig #{shareConfig} #{shareConfig.class}")
    if not shareConfig.nil?
      useFramework = config[SHARE_CONFIG][USE_FRAMEWORKS]
      if useFramework == "true"
         Config.useFrameworks = true
      elsif useFramework == "false"
         Config.useFrameworks  = false
      end
      L.info("#{useFramework} #{useFramework.class}")
    end
  end
end
manifest() click to toggle source
# File lib/qcloudhive/config.rb, line 83
def Config.manifest()
  if @@manifest == nil
    manifestPath = repoRoot+ "manifests/default.xml"
    L.debug "manifestPath #{manifestPath}"
    @@manifest = Manifest.new(manifestPath)
  end
  return @@manifest
end
podSource() click to toggle source
# File lib/qcloudhive/config.rb, line 79
def Config.podSource()
    Pod::Config::instance.sources_manager.aggregate
end
projectRootDirectory() click to toggle source
# File lib/qcloudhive/config.rb, line 69
def Config.projectRootDirectory()
    if @@projectRootDirectory.nil?
      @@projectRootDirectory = Pathname(repoRoot).parent.to_path
    end
    return @@projectRootDirectory
end
repoRoot() click to toggle source
# File lib/qcloudhive/config.rb, line 31
def Config.repoRoot()
    if @@reporoot == nil
      @@reporoot = QCloudHive.FindRepoRoot(Dir.pwd)
      if @@reporoot == nil
        Error "当前不再任何项目目录下面,请确认!!!"
      end
    end
    return @@reporoot
end
setup() click to toggle source
# File lib/qcloudhive/config.rb, line 92
def Config.setup()
  if @@setuped == true
    return
  end
  @@setuped = true
  Config.useFrameworks = true
  configFilePath = Pathname("~/.hiveconfig").expand_path
  if File.exist?(configFilePath) != true
    raise "Hive 配置文件不存在,请检查"
  end
  config = ParseConfig.new(configFilePath)
  if config[CODE_OA_GROUDP].nil?
    Error "没有CodeOA的配置信息,请检查"
  end
  private_token = config[CODE_OA_GROUDP][CODE_OA_CONFIG_PRIVATE_TOKEN]
  if private_token == nil
    raise "没有设置CodeOA的private_token请检查并设置"
  end
  team = config[CODE_OA_GROUDP][CODE_OA_TEAM_NAME]
  if team == nil
    raise "没有设置Team Name请设置"
  end
  #log level config
  hiveGroup = config["Hive"]
  if not hiveGroup.nil?
    logLevel = hiveGroup["loglevel"]
    if logLevel.nil?
      L.level = Logger::ERROR
    elsif logLevel == "INFO"
      L.level = Logger::INFO
    elsif logLevel == "DEBUG"
      L.level = Logger::DEBUG
    elsif logLevel == "ERROR"
      L.level = Logger::ERROR
    end
  end

  puts "LogLevel ........ #{L.level} logLevel"
  #code OA
  CodeOA.setup(private_token)
  Config.team = team
  Config.cmdPath = Pathname.new(__FILE__).realpath.parent.parent.parent.to_path+"/"
  Config.runPath = Dir.pwd + "/"
  Config.templatesPath = Config.cmdPath+"resources/templates/"
  Config.templateManifestPath = Config.templatesPath+"manifests/"
  Config.scriptesDirectory = Config.cmdPath+"resources/shellscriptes/"
  L.info "manifest path is #{Config.templateManifestPath}"
  codeGroup = Gitlab.groups.select{|g| g.name == team}.first
  if codeGroup == nil
    Error("您不属于Group #{team}")
  end
  Config.namespaceID = codeGroup.id
  @@reporoot = nil
  @@manifest = nil
  @@projectRootDirectory = nil
  @@bitcodeEnable = false
  @@buildFromCommit = false
end
version() click to toggle source
# File lib/qcloudhive/config.rb, line 75
def Config.version()
  return QCloudHive::VERSION
end