Sha256: e201045d1385072e9b81ac2836d74ed2e473f52abcbbb31edf899aa0f0aa2997

Contents?: true

Size: 698 Bytes

Versions: 36

Compression:

Stored size: 698 Bytes

Contents

class Ufo::TaskDefinition::Erb
  class Json < Base
    def data
      text = IO.read(@path)
      JSON.load(text)
    rescue JSON::ParserError => e
      # NOTE: JSON::ParserError e.message is not very useful
      logger.error "ERROR: #{e.class}".color(:red)
      logger.error <<~EOL
        Rendered file contains invalid JSON. For debugging, files available at:

        source:   #{@task_definition.path}
        rendered: #{@path}

      EOL
      logger.error "Contents of the rendered file:\n\n"
      print_code(text)
      if jq_available?
        system "cat #{@path} | jq"
      end
      exit 1
    end

    def jq_available?
      system("type jq > /dev/null 2>&1")
    end
  end
end

Version data entries

36 entries across 36 versions & 1 rubygems

Version Path
ufo-6.3.13 lib/ufo/task_definition/erb/json.rb
ufo-6.3.12 lib/ufo/task_definition/erb/json.rb
ufo-6.3.11 lib/ufo/task_definition/erb/json.rb
ufo-6.3.10 lib/ufo/task_definition/erb/json.rb
ufo-6.3.9 lib/ufo/task_definition/erb/json.rb
ufo-6.3.8 lib/ufo/task_definition/erb/json.rb
ufo-6.3.7 lib/ufo/task_definition/erb/json.rb
ufo-6.3.6 lib/ufo/task_definition/erb/json.rb
ufo-6.3.5 lib/ufo/task_definition/erb/json.rb
ufo-6.3.4 lib/ufo/task_definition/erb/json.rb
ufo-6.3.3 lib/ufo/task_definition/erb/json.rb
ufo-6.3.2 lib/ufo/task_definition/erb/json.rb
ufo-6.3.1 lib/ufo/task_definition/erb/json.rb
ufo-6.3.0 lib/ufo/task_definition/erb/json.rb
ufo-6.2.5 lib/ufo/task_definition/erb/json.rb
ufo-6.2.4 lib/ufo/task_definition/erb/json.rb
ufo-6.2.3 lib/ufo/task_definition/erb/json.rb
ufo-6.2.2 lib/ufo/task_definition/erb/json.rb
ufo-6.2.1 lib/ufo/task_definition/erb/json.rb
ufo-6.2.0 lib/ufo/task_definition/erb/json.rb