gluon-core: check-site: support checking "custom" values
The new "value" helper can be used to turn a Lua value into a path that can be passed to need_*() etc.
This commit is contained in:
		
							parent
							
								
									674ec7b64a
								
							
						
					
					
						commit
						d24ae56378
					
				| @ -25,6 +25,7 @@ files["package/**/check_site.lua"] = { | |||||||
| 		"extend", | 		"extend", | ||||||
| 		"in_domain", | 		"in_domain", | ||||||
| 		"in_site", | 		"in_site", | ||||||
|  | 		"value", | ||||||
| 		"need", | 		"need", | ||||||
| 		"need_alphanumeric_key", | 		"need_alphanumeric_key", | ||||||
| 		"need_array", | 		"need_array", | ||||||
|  | |||||||
| @ -57,6 +57,10 @@ end | |||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| local function path_to_string(path) | local function path_to_string(path) | ||||||
|  | 	if path.is_value then | ||||||
|  | 		return path.label | ||||||
|  | 	end | ||||||
|  | 
 | ||||||
| 	return table.concat(path, '.') | 	return table.concat(path, '.') | ||||||
| end | end | ||||||
| 
 | 
 | ||||||
| @ -96,6 +100,10 @@ local function domain_src() | |||||||
| end | end | ||||||
| 
 | 
 | ||||||
| local function conf_src(path) | local function conf_src(path) | ||||||
|  | 	if path.is_value then | ||||||
|  | 		return 'Configuration' | ||||||
|  | 	end | ||||||
|  | 
 | ||||||
| 	local src | 	local src | ||||||
| 
 | 
 | ||||||
| 	if has_domains then | 	if has_domains then | ||||||
| @ -138,6 +146,14 @@ function M.in_domain(path) | |||||||
| 	return path | 	return path | ||||||
| end | end | ||||||
| 
 | 
 | ||||||
|  | function M.value(label, value) | ||||||
|  | 	return { | ||||||
|  | 		is_value = true, | ||||||
|  | 		label = label, | ||||||
|  | 		value = value, | ||||||
|  | 	} | ||||||
|  | end | ||||||
|  | 
 | ||||||
| function M.this_domain() | function M.this_domain() | ||||||
| 	return domain_code | 	return domain_code | ||||||
| end | end | ||||||
| @ -171,6 +187,10 @@ function loadpath(path, base, c, ...) | |||||||
| end | end | ||||||
| 
 | 
 | ||||||
| local function loadvar(path) | local function loadvar(path) | ||||||
|  | 	if path.is_value then | ||||||
|  | 		return path.value | ||||||
|  | 	end | ||||||
|  | 
 | ||||||
| 	return loadpath({}, conf, unpack(path)) | 	return loadpath({}, conf, unpack(path)) | ||||||
| end | end | ||||||
| 
 | 
 | ||||||
|  | |||||||
		Loading…
	
		Reference in New Issue
	
	Block a user