Module: Goodcheck::Commands::ConfigLoading
Instance Attribute Summary collapse
-
#config ⇒ Object
readonly
Returns the value of attribute config.
Instance Method Summary collapse
Instance Attribute Details
#config ⇒ Object (readonly)
Returns the value of attribute config.
4 5 6 |
# File 'lib/goodcheck/commands/config_loading.rb', line 4 def config @config end |
Instance Method Details
#handle_config_errors(stderr) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/goodcheck/commands/config_loading.rb', line 13 def handle_config_errors(stderr) begin yield rescue Psych::Exception => exn stderr.puts "Unexpected error happens while loading YAML file: #{exn.inspect}" exn.backtrace.each do |trace_loc| stderr.puts " #{trace_loc}" end 1 rescue StrongJSON::Type::TypeError, StrongJSON::Type::UnexpectedAttributeError => exn stderr.puts "Invalid config: #{exn.}" stderr.puts StrongJSON::ErrorReporter.new(path: exn.path).to_s 1 rescue Errno::ENOENT => exn stderr.puts "#{exn}" 1 end end |
#load_config!(force_download:, cache_path:) ⇒ Object
6 7 8 9 10 11 |
# File 'lib/goodcheck/commands/config_loading.rb', line 6 def load_config!(force_download:, cache_path:) import_loader = ImportLoader.new(cache_path: cache_path, force_download: force_download, config_path: config_path) content = JSON.parse(JSON.dump(YAML.load(config_path.read, config_path.to_s)), symbolize_names: true) loader = ConfigLoader.new(path: config_path, content: content, stderr: stderr, import_loader: import_loader) @config = loader.load end |