class GitThin::ThinConfig
Constants
- DEFAULT
Public Class Methods
new(name,keys)
click to toggle source
# File lib/git-thin/command/thin_config.rb, line 9 def initialize(name,keys) @name = name @keys = keys @config = {} end
prase_config(configs)
click to toggle source
# File lib/git-thin/command/thin_config.rb, line 45 def self.prase_config(configs) ret_configs = {} for config in configs items = config.split('=') if items.length != 2 logE 'error thin config:'+config next end name = items[0].strip.downcase value = items[1].strip.split(',') name_items = name.split('.') if name_items.length <= 1 logE 'error thin config:'+config next end if name_items[0] != 'thin' # logE 'error thin config:'+config next end config_name = name_items[1] config = ret_configs[config_name] if not config config = ThinConfig.new config_name,['lfs','path'] ret_configs[config_name] = config end if name_items.length > 2 config_key = name_items[2] config.setValue(value,config_key) else config.setValue value end end return ret_configs end
prase_pwd_config(configs,source_root,pwd)
click to toggle source
# File lib/git-thin/command/thin_config.rb, line 83 def self.prase_pwd_config(configs,source_root,pwd) types = [] if pwd.index(source_root) == 0 # 在git 目录中,判断是否命中path路径 length = source_root.length sub = pwd[length+1..-1] if sub for key in configs.keys paths = configs[key].getValue('path') for path in paths if sub.index(path) == 0 types.push key.downcase end end end end else logW 'You are out of the repo' end return types end
prase_type_config(argv,configs,source_root=nil ,pwd=nil )
click to toggle source
# File lib/git-thin/command/thin_config.rb, line 105 def self.prase_type_config(argv,configs,source_root=nil ,pwd=nil ) types = [] if argv.arguments.length > 0 && argv.arguments[0].index('-')!=0 first_args = argv.arguments[0].split '|' need_shift = false for arg in first_args if configs.keys.include? arg.downcase types.push arg.downcase need_shift = true end end if need_shift argv.shift_argument end elsif pwd && source_root types = types.concat prase_pwd_config(configs,source_root,pwd) end if types.length == 0 types.push(DEFAULT) end return types end
Public Instance Methods
getValue(key = nil )
click to toggle source
# File lib/git-thin/command/thin_config.rb, line 33 def getValue(key = nil ) if key value = @config[key] if value.nil? && key == 'path' value = @config['lfs'] end return value else return @config.values end end
keys()
click to toggle source
# File lib/git-thin/command/thin_config.rb, line 18 def keys return @keys end
name()
click to toggle source
# File lib/git-thin/command/thin_config.rb, line 15 def name return @name end
setValue(value,key = nil )
click to toggle source
# File lib/git-thin/command/thin_config.rb, line 21 def setValue(value,key = nil ) if key if @keys.include? key @config[key] = value end else for key in @keys @config[key] = value end end end