Sha256: 837522dabe759df8477127a5ed6f1e9a6259749c780e35901c2479db61118d2b

Contents?: true

Size: 1.95 KB

Versions: 3

Compression:

Stored size: 1.95 KB

Contents

require "isodoc"
require_relative "./gbcleanup.rb"
require_relative "./metadata.rb"

module IsoDoc
  module Gb
    # A {Converter} implementation that generates GB output, and a document
    # schema encapsulation of the document for validation
    class Common < IsoDoc::Common
      def initialize(options)
        @meta = options[:meta]
      end

      def fileloc(loc)
        File.join(File.dirname(__FILE__), loc)
      end

      def format_agency(agency, format)
        return agency unless agency.is_a?(Array)
        if agency == ["中华人民共和国国家质量监督检验检疫总局", "中国国家标准化管理委员会"]
          logo = "gb-issuer-default.gif"
          system "cp #{fileloc(File.join('html/gb-logos', logo))}  #{logo}"
          return "<img src='#{logo}' alt='#{agency.join(",")}'></img>"
        end
        format_agency1(agency, format)
      end

      def format_agency1(agency, format)
        ret = "<table>"
        agency.each { |a| ret += "<tr><td>#{a}</td></tr>" }
        ret += "</table>"
        ret.gsub!(/<table>/, "<table width='100%'>") if format == :word
        ret
      end

      def format_logo(prefix, scope, _format)
        return "" if %w(enterprise social-group).include? scope
        logo = @meta.standard_logo(prefix)
        if logo.nil?
          "<span style='font-size:36pt;font-weight:bold'>#{prefix}</span>"
        else
          format_logo1(logo, prefix, scope)
        end
      end

      def local_logo_suffix(scope)
        return "" if scope != "local"
        local = @meta.get[:gblocalcode]
        "<span style='font-weight:bold'>#{local}</span>"
      end


      def format_logo1(logo, prefix, scope)
        logo += ".gif"
        system "cp #{fileloc(File.join('html/gb-logos', logo))}  #{logo}"
        local = local_logo_suffix(scope)
        #@files_to_delete << logo
        "<img width='113' height='56' src='#{logo}' alt='#{prefix}'></img>"\
          "#{local}"
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
asciidoctor-gb-0.3.5 lib/isodoc/gb/gbconvert.rb
asciidoctor-gb-0.3.4 lib/isodoc/gb/gbconvert.rb
asciidoctor-gb-0.3.3 lib/isodoc/gb/gbconvert.rb