Method: Websitary::Configuration#show_output

Defined in:
lib/websitary/configuration.rb

#show_output(difftext) ⇒ Object

Generate & view the final output.

difftext

Hash



553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
# File 'lib/websitary/configuration.rb', line 553

def show_output(difftext)
    if difftext.empty?
        msg = ['No news is good news']
        msg << "try again in #{@app.format_tdiff(@app.tdiff_min)}" if @app.tdiff_min
        $logger.warn msg.join('; ')
        return 0
    end

    @output_format.each do |outformat|
        meth = "get_output_#{outformat}"

        unless respond_to?(meth)
            $logger.fatal "Unknown output format: #{outformat}"
            exit 5
        end

        out = send(meth, difftext)
        if out
            outfile = get_outfile(outformat)
            case outfile
            when '-'
                puts out
            else
                write_file(outfile) {|io| io.puts out}
                meth = "view_output_#{outformat}"
                self.send(meth, outfile)
            end
        end
    end
    return 1
end