Class: GitThin::ThinConfig
- Inherits:
-
Object
- Object
- GitThin::ThinConfig
show all
- Includes:
- GitThinUtils
- Defined in:
- lib/git-thin/command/thin_config.rb
Constant Summary
collapse
- DEFAULT =
'default'.freeze
GitThinUtils::LOGA, GitThinUtils::LOGC, GitThinUtils::LOGN, GitThinUtils::LOGNone, GitThinUtils::LOGPRUNE
Class Method Summary
collapse
Instance Method Summary
collapse
#logC, #logE, #logInner, #logN, #logP, #logW, #print_console, #run_shell, #set_progress
Constructor Details
#initialize(name, keys) ⇒ ThinConfig
Returns a new instance of ThinConfig.
9
10
11
12
13
|
# File 'lib/git-thin/command/thin_config.rb', line 9
def initialize(name,keys)
@name = name
@keys = keys
@config = {}
end
|
Class Method Details
.prase_config(configs) ⇒ Object
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
|
# 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'
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) ⇒ Object
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
|
# 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
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) ⇒ Object
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
|
# 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
|
Instance Method Details
#getValue(key = nil) ⇒ Object
33
34
35
36
37
38
39
40
41
42
43
|
# 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 ⇒ Object
18
19
20
|
# File 'lib/git-thin/command/thin_config.rb', line 18
def keys
return @keys
end
|
#name ⇒ Object
15
16
17
|
# File 'lib/git-thin/command/thin_config.rb', line 15
def name
return @name
end
|
#setValue(value, key = nil) ⇒ Object
21
22
23
24
25
26
27
28
29
30
31
|
# 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
|