Class: Mxrb::DomainDiagram::Server
- Inherits:
-
Object
- Object
- Mxrb::DomainDiagram::Server
- Defined in:
- lib/mxrb/domain_diagram.rb
Overview
Loopback-only server for the standalone editor.
Constant Summary collapse
- MAX_BODY_BYTES =
2_097_152- LOOPBACK_HOSTS =
%w[127.0.0.1 ::1 localhost].freeze
Instance Attribute Summary collapse
-
#host ⇒ Object
readonly
Returns the value of attribute host.
-
#managed_paths ⇒ Object
readonly
Returns the value of attribute managed_paths.
-
#output ⇒ Object
readonly
Returns the value of attribute output.
-
#port ⇒ Object
readonly
Returns the value of attribute port.
-
#source ⇒ Object
readonly
Returns the value of attribute source.
Instance Method Summary collapse
-
#initialize(source, output: nil, modules: [], host: '127.0.0.1', port: 4568, force: false, reuse: false, lifecycle_token: nil) ⇒ Server
constructor
A new instance of Server.
- #shutdown ⇒ Object
- #start ⇒ Object
Constructor Details
#initialize(source, output: nil, modules: [], host: '127.0.0.1', port: 4568, force: false, reuse: false, lifecycle_token: nil) ⇒ Server
Returns a new instance of Server.
269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 |
# File 'lib/mxrb/domain_diagram.rb', line 269 def initialize(source, output: nil, modules: [], host: '127.0.0.1', port: 4568, force: false, reuse: false, lifecycle_token: nil) @source = File.(source) raise ArgumentError, "MPR not found: #{@source}" unless File.file?(@source) @output = File.(output || default_output) raise ArgumentError, 'output must be a safe copy, not the source MPR' if same_file_as_source? raise ArgumentError, "output cannot be a directory: #{@output}" if File.directory?(@output) raise ArgumentError, "output cannot be a symbolic link: #{@output}" if File.symlink?(@output) @host = host.to_s raise ArgumentError, 'domain model server must bind to loopback' unless LOOPBACK_HOSTS.include?(@host) @port = Integer(port) @modules = Array(modules) @token = SecureRandom.hex(24) @lifecycle_token = lifecycle_token @managed_paths = [@output] prepare_output(force:, reuse:) end |
Instance Attribute Details
#host ⇒ Object (readonly)
Returns the value of attribute host.
267 268 269 |
# File 'lib/mxrb/domain_diagram.rb', line 267 def host @host end |
#managed_paths ⇒ Object (readonly)
Returns the value of attribute managed_paths.
267 268 269 |
# File 'lib/mxrb/domain_diagram.rb', line 267 def managed_paths @managed_paths end |
#output ⇒ Object (readonly)
Returns the value of attribute output.
267 268 269 |
# File 'lib/mxrb/domain_diagram.rb', line 267 def output @output end |
#port ⇒ Object (readonly)
Returns the value of attribute port.
267 268 269 |
# File 'lib/mxrb/domain_diagram.rb', line 267 def port @port end |
#source ⇒ Object (readonly)
Returns the value of attribute source.
267 268 269 |
# File 'lib/mxrb/domain_diagram.rb', line 267 def source @source end |
Instance Method Details
#shutdown ⇒ Object
295 |
# File 'lib/mxrb/domain_diagram.rb', line 295 def shutdown = @server&.shutdown |