razorrisk-razor-connectivity 0.14.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 163162c6e84916a28c9fba50315691d9ae9aeda5
4
+ data.tar.gz: 30d5c2ca917025b0ef4e1defed1ff80ece04a5d0
5
+ SHA512:
6
+ metadata.gz: f80616833e83f7f50eb49873302fddc67a24aace01ea4bd1450110afb966668bed9f59c292094e1d495e941e5ca3426defaedf61b2b4367cfc5e198f50cb7a2d
7
+ data.tar.gz: c76e6ab451b5955e7562f51041bbed9a7c7f249d93be8adf9ce49691f618c95eecf80edd595e055c6dfb8143c25cd866d56b44d6ec05f4c31549fc7ce5f6e9bc
data/Rakefile ADDED
@@ -0,0 +1,89 @@
1
+ # frozen_string_literal: true
2
+
3
+ # ######################################################################## #
4
+ #
5
+ # Copyright (c) 2019 Razor Risk Technologies Pty Limited. All rights reserved.
6
+ #
7
+ # ######################################################################## #
8
+
9
+ $LOAD_PATH.unshift File.join(File.dirname(__FILE__), 'lib')
10
+
11
+ # ##########################################################
12
+ # bundler
13
+
14
+ require 'rubygems'
15
+ require 'bundler/setup'
16
+
17
+ # ######################################################################## #
18
+ # requires
19
+
20
+ require 'razor_risk/razor/control/rake_helpers/diagnostic_tasks'
21
+ require 'razor_risk/razor/control/rake_helpers/gem_tasks'
22
+ require 'razor_risk/razor/control/rake_helpers/task_helpers'
23
+
24
+ require 'rake'
25
+ require 'rake/clean'
26
+
27
+ # ##########################################################
28
+ # includes
29
+
30
+ include ::RazorRisk::Razor::Control # rubocop:todo Style/MixinUsage
31
+ include ::Pantheios # rubocop:todo Style/MixinUsage
32
+
33
+ # ##########################################################
34
+ # Constants
35
+
36
+ Spec = ::Gem::Specification.load(Dir['*.gemspec'].first)
37
+ LogDir = 'log' # rubocop:todo Naming/ConstantName
38
+ # rubocop:todo Naming/ConstantName
39
+ LogThresholds = %i[informational informational].freeze
40
+ # rubocop:enable Naming/ConstantName
41
+
42
+ # ##########################################################
43
+ # clean/clobber
44
+
45
+ Dir[
46
+ 'log',
47
+ 'doc',
48
+ ].each { |f| CLEAN << f }
49
+ Dir[
50
+ '.bundle',
51
+ 'vendor',
52
+ 'GEM_HOME',
53
+ '*.gem',
54
+ ].each { |f| CLOBBER << f }
55
+
56
+ # ##########################################################
57
+ # Tasks
58
+
59
+ desc 'Run tests'
60
+ task test: [:'gem:unit_test']
61
+
62
+ desc 'Build gem'
63
+ task :build_gem, [:path] => :'gem:build'
64
+
65
+ desc 'Builds the Razor EntityConnector Gem'
66
+ task :build, [:path] => [:build_gem]
67
+
68
+ desc 'Push the gem to the gem server.'
69
+ task deploy: :'gem:push'
70
+
71
+ # ##########################################################
72
+ # Hooks
73
+
74
+ task :default do
75
+ puts 'Run \'bundler exec rake --tasks\' to see available tasks'
76
+ end
77
+
78
+ task :first do
79
+ ::Rake::Task[:'diagnostics:init'].execute(
80
+ name: Spec.name,
81
+ version: Spec.version.to_s,
82
+ directory: LogDir,
83
+ thresholds: LogThresholds
84
+ )
85
+ end
86
+
87
+ RakeHelpers::TaskHelpers.add_hooks
88
+
89
+ # ############################## end of file ############################# #
@@ -0,0 +1,162 @@
1
+ # encoding: UTF-8
2
+
3
+ # ######################################################################## #
4
+ # File: lib/razor_risk/razor/connectivity/clarite_2/config_maker.rb
5
+ #
6
+ # Purpose: ::RazorRisk::Razor::Connectivity::Clarite2::ConfigMaker
7
+ # module
8
+ #
9
+ # Created: 22nd December 2017
10
+ # Updated: 27th July 2018
11
+ #
12
+ # Author: Matthew Wilson
13
+ #
14
+ # Copyright (c) 2017-2018, Razor Risk Technologies Pty Ltd
15
+ # All rights reserved.
16
+ #
17
+ # ######################################################################## #
18
+
19
+
20
+ # ######################################################################## #
21
+ # requires
22
+
23
+ require 'pantheios'
24
+ require 'xqsr3/quality/parameter_checking'
25
+
26
+ # ######################################################################## #
27
+ # modules
28
+
29
+ module RazorRisk
30
+ module Razor
31
+ module Connectivity
32
+ module ClarITe2
33
+
34
+ # ######################################################################## #
35
+ # classes
36
+
37
+ class ConfigMaker
38
+
39
+ private
40
+ def self.obtain_server_or_throw_ node, path
41
+
42
+ trace ParamNames[ :node, :path ], node, path
43
+
44
+ case node
45
+ when ::String
46
+ server = node
47
+ when ::Hash
48
+ server = node[:server]
49
+ end
50
+
51
+ if server
52
+
53
+ return [ $1, $2 ] if server =~ /^(.+):([^:]+)$/
54
+ end
55
+
56
+ host = node[:host]
57
+ port = node[:port]
58
+
59
+ if host && port
60
+
61
+ return [ host, port ]
62
+ end
63
+
64
+ raise ArgumentError, "'#{path}' option did not contain 'server' or 'host'+'port' options"
65
+ end
66
+
67
+ include ::Pantheios
68
+ include ::Xqsr3::Quality::ParameterChecking
69
+
70
+ public
71
+
72
+ # Makes a ClarITe configuration file
73
+ #
74
+ # @param io (IO) An instance of a class that has a +write+ method that
75
+ # takes a single string argument, and, unless the option +:no_flush+
76
+ # is specified, also has the +flush+ method. May be +nil+, in which
77
+ # case no writing (or flushing) is done
78
+ # @param options (Hash) Options hash, wherein the keys are symbols, not
79
+ # strings. A regular (string-keyed) hash, such as may be obtained from
80
+ # YAML, may be converted using Xqsr3's deep_transform (e.g.
81
+ # +h.deep_transform { |k| ::String === k ? k.to_sym : k }+) to be
82
+ # compatible with this function
83
+ #
84
+ # @option +:razor_server+ (Hash) Specifies the Razor server dictionary,
85
+ # from which the values of the +:environment+ and +:space+ keys are
86
+ # obtained: the +:environment+ key is mandatory; the +:space+ key is
87
+ # optional, and the value will be taken from the +:environment+ value
88
+ # if not specified
89
+ # @option +:xml_client+ (Hash) Specifies the XML client dictionary, from
90
+ # which the values of the +:root_space+ and +:sns+ keys are obtained.
91
+ # Both keys are mandatory, and must be either of the two forms of: (i)
92
+ # a string that has the format "<host>:<port>" or a Hash with the keys
93
+ # +:host+ and +:port+
94
+ # @option +:no_flush+ (boolean) Determines whether the +io+ will be sent
95
+ # the +flush+ method after writing
96
+ #
97
+ # @return The ClarITe configuration file contents
98
+ def self.make io = nil, **options
99
+
100
+ trace ParamNames[ :io, :options ], io, options
101
+
102
+ check_parameter io, 'io', responds_to: [ :write ] + (options[:no_flush] ? [] : [ :flush ]), allow_nil: true
103
+
104
+ razor_server = check_option options, :razor_server, type: ::Hash
105
+
106
+ xml_client = check_option options, :xml_client, type: ::Hash
107
+
108
+ environment = razor_server[:environment] or raise ArgumentError, "'razor_server/environment' option invalid or missing"
109
+ space = razor_server[:space] || environment
110
+
111
+ root_space = xml_client[:root_space] or raise ArgumentError, "'xml_client/root_space' option invalid or missing"
112
+
113
+ sns = xml_client[:sns] or raise ArgumentError, "'xml_client/sns' option invalid or missing"
114
+
115
+ cc_xc_rs_server = self.obtain_server_or_throw_ root_space, 'xml_client/root_space'
116
+
117
+ cc_xc_sp_server = self.obtain_server_or_throw_ sns, 'xml_client/sns'
118
+
119
+ cc = <<END_OF_xml
120
+ <clarite_config>
121
+ <xml_client>
122
+ <root_space host="#{cc_xc_rs_server[0]}" port="#{cc_xc_rs_server[1]}"/>
123
+ <sns>
124
+ <server host="#{cc_xc_sp_server[0]}" port="#{cc_xc_sp_server[1]}"/>
125
+ </sns>
126
+ <ssl>
127
+ <enabled>false</enabled>
128
+ <isDefault>false</isDefault>
129
+ <authenticateServer>false</authenticateServer>
130
+ <CAFile>ssl/serverCAcert.pem</CAFile>
131
+ </ssl>
132
+ <options>
133
+ <timers>
134
+ <clientPooledSockets>-1</clientPooledSockets>
135
+ </timers>
136
+ </options>
137
+ </xml_client>
138
+ <razor_server space="#{space}" environment="#{environment}"/>
139
+ </clarite_config>
140
+ END_OF_xml
141
+
142
+ if io
143
+
144
+ io.write cc
145
+ io.flush unless options[:no_flush]
146
+ end
147
+
148
+ cc
149
+ end
150
+ end # class ConfigMaker
151
+
152
+ # ######################################################################## #
153
+ # modules
154
+
155
+ end # module ClarITe2
156
+ end # module Connectivity
157
+ end # module Razor
158
+ end # module RazorRisk
159
+
160
+ # ############################## end of file ############################# #
161
+
162
+
@@ -0,0 +1,101 @@
1
+ # encoding: UTF-8
2
+
3
+ # ######################################################################## #
4
+ # File: lib/razor_risk/razor/connectivity/exceptions.rb
5
+ #
6
+ # Purpose: Exceptions
7
+ #
8
+ # Created: 28th July 2018
9
+ # Updated: 28th July 2018
10
+ #
11
+ # Author: Matthew Wilson
12
+ #
13
+ # Copyright (c) 2018, Razor Risk Technologies Pty Ltd
14
+ # All rights reserved.
15
+ #
16
+ # ######################################################################## #
17
+
18
+
19
+ # ##########################################################################
20
+ # requires
21
+
22
+ require 'razor_risk/core/diagnostics/exceptions/rrcs_base_exception'
23
+
24
+ require 'pantheios'
25
+ require 'xqsr3/quality/parameter_checking'
26
+
27
+ =begin
28
+ =end
29
+
30
+ module RazorRisk
31
+ module Razor
32
+ module Connectivity
33
+
34
+ # Module for exceptions for entity-connectors:
35
+ #
36
+ # Exceptions:
37
+ #
38
+ # (::RazorRisk::Core::Diagnostics::Exceptions::RRCSBaseException)
39
+ # |
40
+ # +- ConnectivityException (abstract)
41
+ # |
42
+ # ...
43
+ module Exceptions
44
+
45
+
46
+ # Root exception class for RazorRisk::Razor::Connectivity classes / modules
47
+ #
48
+ # NOTE: this class is abstract
49
+ class ConnectivityException < ::RazorRisk::Core::Diagnostics::Exceptions::RRCSBaseException
50
+
51
+ include ::Pantheios
52
+
53
+ module ConnectivityException_Constants
54
+
55
+ ABSTRACT_CLASSES = %w{
56
+
57
+ ConnectivityException
58
+ }
59
+
60
+ end # module ConnectivityException_Constants
61
+
62
+ def self.new *args
63
+
64
+ if ConnectivityException_Constants::ABSTRACT_CLASSES.include?(self.name.split('::')[-1])
65
+
66
+ raise NoMethodError, "private method `new' called for #{self}:Class"
67
+ end
68
+
69
+ super
70
+ end
71
+
72
+ # Initialises an instance, based on the given message and options
73
+ #
74
+ # === Signature
75
+ #
76
+ # * *Parameters:*
77
+ # @param +message+:: (::String) the exception message
78
+ # @param +options+:: (::Hash) options
79
+ #
80
+ # * *Options:*
81
+ # @option +:cause+:: (::Exception) the cause
82
+ def initialize message, **options
83
+
84
+ trace ParamNames[ :message, :options ], message, options
85
+
86
+ super message, **options
87
+
88
+ @options = {}.merge! options
89
+ end
90
+
91
+ attr_reader :options
92
+ end # class ConnectivityException
93
+
94
+ end # module Exceptions
95
+ end # module Connectivity
96
+ end # module Razor
97
+ end # module RazorRisk
98
+
99
+ # ############################## end of file ############################# #
100
+
101
+
@@ -0,0 +1,126 @@
1
+ # encoding: UTF-8
2
+
3
+ # ######################################################################## #
4
+ # File: lib/razor_risk/razor/connectivity/razor_3/body_maker.rb
5
+ #
6
+ # Purpose: ::RazorRisk::Razor::Connectivity::Razor3::BodyMaker class
7
+ #
8
+ # Created: 7th August 2018
9
+ # Updated: 7th August 2018
10
+ #
11
+ # Author: Matthew Wilson
12
+ #
13
+ # Copyright (c) 2018, Razor Risk Technologies Pty Ltd
14
+ # All rights reserved.
15
+ #
16
+ # ######################################################################## #
17
+
18
+
19
+ # ######################################################################## #
20
+ # requires
21
+
22
+ require 'nokogiri'
23
+ require 'pantheios'
24
+ require 'xqsr3/quality/parameter_checking'
25
+
26
+ =begin
27
+ =end
28
+
29
+ module RazorRisk
30
+ module Razor
31
+ module Connectivity
32
+ module Razor3
33
+
34
+ class BodyMaker
35
+
36
+ include ::Pantheios
37
+
38
+ include ::Xqsr3::Quality::ParameterChecking
39
+
40
+ XML = ::Nokogiri::XML
41
+
42
+ def initialize
43
+
44
+ end
45
+
46
+ def make_condition **options
47
+
48
+
49
+ id = options[:id]
50
+ name = options[:name]
51
+ key_path_elements = check_option(options, :key_path_elements, type: ::Hash, allow_nil: true) || []
52
+ oper = options[:oper]
53
+ values = options[:values] || []
54
+
55
+
56
+ xml = ::Nokogiri.XML '<condition/>'
57
+
58
+ el = xml.children.first
59
+
60
+ el['id'] = id if id
61
+
62
+
63
+ nm = el.add_child("<name>#{name}</name>").first if name
64
+
65
+
66
+ kp = el.add_child('<keyPath/>').first
67
+
68
+ key_path_elements.each do |k, v|
69
+
70
+ kp.add_child(%Q{<keyElement nodeOffset="#{k}">#{v}</keyElement>})
71
+ end
72
+
73
+
74
+ op = el.add_child("<oper>#{oper}</oper>").first if oper
75
+
76
+
77
+ vls = el.add_child('<values/>').first
78
+
79
+ values.each do |k, v|
80
+
81
+ vls.add_child(%Q{<value id="#{k}">#{v}</value>})
82
+ end
83
+
84
+
85
+ el
86
+ end
87
+
88
+ def make_query **options
89
+
90
+ params = options[:params] || {}
91
+
92
+ conditions = options[:conditions] || []
93
+
94
+
95
+ xml = ::Nokogiri.XML '<query/>'
96
+
97
+ el = xml.children.first
98
+
99
+
100
+ params.each do |k, v|
101
+
102
+ el.add_child(%Q{<#{k}>#{v}</#{k}>})
103
+ end
104
+
105
+
106
+ cs = el.add_child('<conditions/>').first
107
+
108
+ conditions.each do |condition|
109
+
110
+ cs.add_child(condition)
111
+ end
112
+
113
+
114
+ el
115
+ end
116
+
117
+ end # class BodyMaker
118
+
119
+ end # module Razor3
120
+ end # module Connectivity
121
+ end # module Razor
122
+ end # module RazorRisk
123
+
124
+ # ############################## end of file ############################# #
125
+
126
+