Class: RazorRisk::Razor::Connectivity::ClarITe2::ConfigMaker

Inherits:
Object
  • Object
show all
Includes:
Pantheios, Xqsr3::Quality::ParameterChecking
Defined in:
lib/razor_risk/razor/connectivity/clarite_2/config_maker.rb

Overview

######################################################################## # classes

Class Method Summary collapse

Class Method Details

.make(io = nil, **options) ⇒ Object

Makes a ClarITe configuration file

Parameters:

  • io (IO) (defaults to: nil) —

    An instance of a class that has a write method that takes a single string argument, and, unless the option :no_flush is specified, also has the flush method. May be nil, in which case no writing (or flushing) is done

  • options (Hash) —

    Options hash, wherein the keys are symbols, not strings. A regular (string-keyed) hash, such as may be obtained from YAML, may be converted using Xqsr3's deep_transform (e.g. h.deep_transform { |k| ::String === k ? k.to_sym : k }) to be compatible with this function

  • +:razor_server+ (Hash) —

    a customizable set of options

  • +:xml_client+ (Hash) —

    a customizable set of options

  • +:no_flush+ (Hash) —

    a customizable set of options

Returns:

  • The ClarITe configuration file contents



98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
# File 'lib/razor_risk/razor/connectivity/clarite_2/config_maker.rb', line 98

def self.make io = nil, **options

    trace ParamNames[ :io, :options ], io, options

    check_parameter io, 'io', responds_to: [ :write ] + (options[:no_flush] ? [] : [ :flush ]), allow_nil: true

    razor_server    =   check_option options, :razor_server, type: ::Hash

    xml_client      =   check_option options, :xml_client, type: ::Hash

    environment     =   razor_server[:environment] or raise ArgumentError, "'razor_server/environment' option invalid or missing"
    space           =   razor_server[:space] || environment

    root_space      =   xml_client[:root_space] or raise ArgumentError, "'xml_client/root_space' option invalid or missing"

    sns             =   xml_client[:sns] or raise ArgumentError, "'xml_client/sns' option invalid or missing"

    cc_xc_rs_server =   self.obtain_server_or_throw_ root_space, 'xml_client/root_space'

    cc_xc_sp_server =   self.obtain_server_or_throw_ sns, 'xml_client/sns'

    cc = <<END_OF_xml
<clarite_config>
<xml_client>
    <root_space host="#{cc_xc_rs_server[0]}" port="#{cc_xc_rs_server[1]}"/>
    <sns>
        <server host="#{cc_xc_sp_server[0]}" port="#{cc_xc_sp_server[1]}"/>
    </sns>
    <ssl>
        <enabled>false</enabled>
        <isDefault>false</isDefault>
        <authenticateServer>false</authenticateServer>
        <CAFile>ssl/serverCAcert.pem</CAFile>
    </ssl>
    <options>
        <timers>
            <clientPooledSockets>-1</clientPooledSockets>
        </timers>
    </options>
</xml_client>
<razor_server space="#{space}" environment="#{environment}"/>
</clarite_config>
END_OF_xml

    if io

        io.write cc
        io.flush unless options[:no_flush]
    end

    cc
end