Sha256: 66c00a007d474200dcf3dc7ebf9efc5e5a41dc7eea83d2cd25ba956d6906615b

Contents?: true

Size: 888 Bytes

Versions: 28

Compression:

Stored size: 888 Bytes

Contents

# frozen_string_literal: true
module Asciidoctor
# A module that can be used to mix the {#write} method into a {Converter} implementation to allow the converter to
# control how the output is written to disk.
module Writer
  # Public: Writes the output to the specified target file name or stream.
  #
  # output - The output String to write
  # target - The String file name or stream object to which the output should be written.
  #
  # Returns nothing
  def write output, target
    if target.respond_to? :write
      # ensure there's a trailing newline to be nice to terminals
      target.write output.chomp + LF
    else
      # QUESTION shouldn't we ensure a trailing newline here too?
      ::File.write target, output, mode: FILE_WRITE_MODE
    end
    nil
  end
end

module VoidWriter
  include Writer

  # Public: Does not write output
  def write output, target; end
end
end

Version data entries

28 entries across 28 versions & 2 rubygems

Version Path
asciidoctor-2.0.22 lib/asciidoctor/writer.rb
asciidoctor-2.0.21 lib/asciidoctor/writer.rb
asciidoctor-2.0.20 lib/asciidoctor/writer.rb
asciidoctor-2.0.19 lib/asciidoctor/writer.rb
asciidoctor-2.0.18 lib/asciidoctor/writer.rb
asciidoctor-2.0.17 lib/asciidoctor/writer.rb
asciidoctor-2.0.16 lib/asciidoctor/writer.rb
asciidoctor-2.0.15 lib/asciidoctor/writer.rb
asciidoctor-2.0.14 lib/asciidoctor/writer.rb
asciidoctor-2.0.13 lib/asciidoctor/writer.rb
asciidoctor-2.0.12 lib/asciidoctor/writer.rb
asciidoctor-2.0.11 lib/asciidoctor/writer.rb
metanorma-cli-1.3.4 gems/ruby/2.6.0/gems/asciidoctor-2.0.10/lib/asciidoctor/writer.rb
metanorma-cli-1.3.3.1 gems/ruby/2.6.0/gems/asciidoctor-2.0.10/lib/asciidoctor/writer.rb
asciidoctor-2.0.10 lib/asciidoctor/writer.rb
asciidoctor-2.0.9 lib/asciidoctor/writer.rb
asciidoctor-2.0.8 lib/asciidoctor/writer.rb
asciidoctor-2.0.7 lib/asciidoctor/writer.rb
asciidoctor-2.0.6 lib/asciidoctor/writer.rb
asciidoctor-2.0.5 lib/asciidoctor/writer.rb