Sha256: 9b53a0da7445f2a8c8490c20ecbe7e21d7f025085f8fdc5cf0bf4da00038ab58

Contents?: true

Size: 1.34 KB

Versions: 1

Compression:

Stored size: 1.34 KB

Contents

require "yaml"

module Ykxutils
  module_function

  def yaml_load_file_compati(yaml_file_path)
    setting = {}
    valid = false
    begin
      setting = YAML.load_file(yaml_file_path, aliases: true)
      valid = true
    rescue ArgumentError
      # p "yaml_load_file_compat 1"
      # p ex.class
      # p ex.inspect
      # p ex.message
      # p ex.backtrace
      # exit#
    rescue StandardError
      # p "yaml_load_file_compat 1-2"
      # p ex.class
      # p ex.inspect
      # p ex.message
      # p ex.backtrace
    end

    if valid != true
      begin
        setting = YAML.load_file(yaml_file_path)
        # valid = true
      rescue ArgumentError
        # p "yaml_load_file_compat 2"
        # p ex.class
        # p ex.inspect
        # p ex.message
        # p ex.backtrace
        #
      rescue StandardError
        # p "yaml_load_file_compat 2-2"
        # p ex.class
        # p ex.inspect
        # p ex.message
        # p ex.backtrace
      end
    end
    setting
  end

  def yaml_load_compati(content)
    setting = {}
    valid = false
    begin
      setting = YAML.load(content, aliases: true)
      valid = true
    rescue ArgumentError
    rescue StandardError
    end

    if valid != true
      begin
        setting = YAML.load(content)
      rescue ArgumentError
      rescue StandardError
      end
    end
    setting
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
ykxutils-0.1.7 lib/ykxutils/yamlx.rb