Class: FileConfigParser
- Inherits:
-
Object
- Object
- FileConfigParser
- Defined in:
- lib/hiptest-publisher/options_parser.rb
Constant Summary collapse
- FALSY_VALUE_PATTERN =
/\A(false|no|0)\Z/i
Class Method Summary collapse
- .falsy?(value) ⇒ Boolean
- .update_options(options, reporter) ⇒ Object
- .update_path!(param, config, options) ⇒ Object
Class Method Details
.falsy?(value) ⇒ Boolean
42 43 44 |
# File 'lib/hiptest-publisher/options_parser.rb', line 42 def self.falsy?(value) FALSY_VALUE_PATTERN.match(value) end |
.update_options(options, reporter) ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/hiptest-publisher/options_parser.rb', line 18 def self.(, reporter) config = ParseConfig.new(.config) config.get_params.each do |param| next if .__cli_args && .__cli_args.include?(param.to_sym) if param.start_with?("no_") value = falsy?(config[param]) ? "true" : "false" param = param.sub("no_", "") else value = config[param] end if falsy?(value) [param] = false else [param] = value end if %w(overriden_templates output_directory).include?(param) update_path!(param, config, ) end .__config_args << param.to_sym if .__config_args end rescue => err reporter.dump_error(err) end |
.update_path!(param, config, options) ⇒ Object
46 47 48 49 50 51 52 53 |
# File 'lib/hiptest-publisher/options_parser.rb', line 46 def self.update_path!(param, config, ) path = Pathname.new(config[param]) return unless path.relative? config_path = Pathname.new(.config) config_absolute_path = config_path.relative? ? Pathname.pwd + config_path : config_path resolved_path = config_absolute_path.cleanpath.dirname + path [param] = resolved_path.cleanpath.to_path end |