Sha256: c4ad6f2db781bf93c1e1b5fd63abaf649de1a4db2bba3470bb195c87deac6cbb

Contents?: true

Size: 581 Bytes

Versions: 3

Compression:

Stored size: 581 Bytes

Contents

module RopenPi::Specs
  # concrete
  class Writer
    # strategies
    module Json
      def self.convert(doc)
        JSON.pretty_generate(doc)
      end
    end

    module Yml
      def self.convert(doc)
        JSON.parse(Json.convert(doc)).to_yaml
      end
    end

    def initialize(open_api_output_format)
      @output_format = open_api_output_format
    end

    def write(doc)
      if @output_format == :yaml || @output_format == :yml
        Yml.convert(doc)
      else
        # this is by any means the default
        Json.convert(doc)
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
ropen_pi-0.5.0 lib/ropen_pi/specs/writer.rb
ropen_pi-0.4.0 lib/ropen_pi/specs/writer.rb
ropen_pi-0.3.0 lib/ropen_pi/specs/writer.rb