Sha256: 9ca30460cb6a4fd197cb3fe7497792d65f0689b85e401782753ce2097548f65d

Contents?: true

Size: 537 Bytes

Versions: 13

Compression:

Stored size: 537 Bytes

Contents

# frozen_string_literal: true
module ThemeCheck
  module JsonHelpers
    def format_json_parse_error(error)
      message = error.message[/\d+: (.+)$/, 1] || 'Invalid syntax'
      "#{message} in JSON"
    end

    def pretty_json(hash, start_level: 1, indent: "  ")
      start_indent = indent * start_level

      <<~JSON

        #{start_indent}#{JSON.pretty_generate(
          hash,
          indent: indent,
          array_nl: "\n#{start_indent}",
          object_nl: "\n#{start_indent}",
        )}
      JSON
    end
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
theme-check-1.15.0 lib/theme_check/json_helpers.rb
theme-check-1.14.0 lib/theme_check/json_helpers.rb
theme-check-1.13.0 lib/theme_check/json_helpers.rb
theme-check-1.12.1 lib/theme_check/json_helpers.rb
theme-check-1.12.0 lib/theme_check/json_helpers.rb
theme-check-1.11.0 lib/theme_check/json_helpers.rb
theme-check-1.10.3 lib/theme_check/json_helpers.rb
theme-check-1.10.2 lib/theme_check/json_helpers.rb
theme-check-1.10.1 lib/theme_check/json_helpers.rb
theme-check-1.10.0 lib/theme_check/json_helpers.rb
theme-check-1.9.2 lib/theme_check/json_helpers.rb
theme-check-1.9.1 lib/theme_check/json_helpers.rb
theme-check-1.9.0 lib/theme_check/json_helpers.rb