method

check_defaults

Importance_0
v7.1.3.2 - Show latest stable - 0 notes - Class: FrameworkDefaults
  • 1.0.0
  • 1.1.6
  • 1.2.6
  • 2.0.3
  • 2.1.0
  • 2.2.1
  • 2.3.8
  • 3.0.0
  • 3.0.9
  • 3.1.0
  • 3.2.1
  • 3.2.8
  • 3.2.13
  • 4.0.2
  • 4.1.8
  • 4.2.1
  • 4.2.7
  • 4.2.9
  • 5.0.0.1
  • 5.1.7
  • 5.2.3
  • 6.0.0
  • 6.1.3.1
  • 6.1.7.7
  • 7.0.0
  • 7.1.3.2 (0)
  • 7.1.3.4 (0)
  • What's this?
check_defaults(defaults) private

No documentation

This method has no description. You can help the Ruby on Rails community by adding new notes.

Hide source
# File tools/rail_inspector/lib/rail_inspector/configuring/check/framework_defaults.rb, line 70
          def check_defaults(defaults)
            header, configs = defaults[0], defaults[2, defaults.length - 3]

            version = header.match(/\d\.\d/)[0]

            generated_doc =
              visitor.config_map[version]
                .map do |config, value|
                  full_config =
                    case config
                    when /^[A-Z]/
                      config
                    when /^self/
                      config.sub("self", "config")
                    else
                      "config.#{config}"
                    end

                  "- [`#{full_config}`](##{full_config.tr("._", "-").downcase}): `#{value}`"
                end
                .sort

            config_diff =
              Tempfile.create("expected") do |doc|
                doc << generated_doc.join("\n")
                doc.flush

                Tempfile.create("actual") do |code|
                  code << configs.join("\n")
                  code.flush

                  `git diff --color --no-index #{doc.path} #{code.path}`
                end
              end

            checker.errors << <<~MESSAGE unless config_diff.empty?
              #{APPLICATION_CONFIGURATION_PATH}: Incorrect load_defaults docs
              --- Expected
              +++ Actual
              #{config_diff.split("\n")[5..].join("\n")}
            MESSAGE

            [header, "", *generated_doc, ""]
          end
Register or log in to add new notes.