Class: Mxrb::Dsl::Builder
Instance Attribute Summary collapse
Instance Method Summary
collapse
#connector, #connector_plans, #connector_requests, #validate_connector_requests!
Constructor Details
#initialize(path) ⇒ Builder
Returns a new instance of Builder.
343
344
345
346
347
348
349
350
351
352
353
354
|
# File 'lib/mxrb/dsl/builder.rb', line 343
def initialize(path)
@path = path
@mendix_version = "10.18.0"
@modules = []
@security = nil
@navigation = nil
@design_system = nil
@native_units_path = nil
@native_unit_overrides = []
@project_assets = nil
@ruby_app_sources_path = nil
end
|
Instance Attribute Details
#path ⇒ Object
Returns the value of attribute path.
341
342
343
|
# File 'lib/mxrb/dsl/builder.rb', line 341
def path
@path
end
|
Instance Method Details
#bson_binary(base64, subtype: :generic) ⇒ Object
411
412
413
|
# File 'lib/mxrb/dsl/builder.rb', line 411
def bson_binary(base64, subtype: :generic)
BSON::Binary.new(Base64.strict_decode64(base64), subtype)
end
|
#build! ⇒ Object
425
426
427
428
429
430
|
# File 'lib/mxrb/dsl/builder.rb', line 425
def build!
validate_connector_requests!
validate!
Writer.new(@path, definition).write!
self
end
|
#definition ⇒ Object
445
446
447
448
449
450
451
452
453
454
455
456
457
458
|
# File 'lib/mxrb/dsl/builder.rb', line 445
def definition
{
version: @mendix_version,
modules: @modules.map(&:to_h),
security: @security,
navigation: @navigation,
design_system: @design_system,
connectors: connector_requests.map(&:to_h),
project_assets: @project_assets,
ruby_app_sources_path: @ruby_app_sources_path,
native_units_path: @native_units_path,
native_unit_overrides: @native_unit_overrides
}
end
|
#design_system(&block) ⇒ Object
378
379
380
381
382
|
# File 'lib/mxrb/dsl/builder.rb', line 378
def design_system(&block)
builder = DesignSystemBuilder.new
builder.instance_eval(&block) if block
@design_system = builder.to_h
end
|
#evaluate(path) ⇒ Object
415
416
417
|
# File 'lib/mxrb/dsl/builder.rb', line 415
def evaluate(path)
instance_eval(File.read(path), path, 1)
end
|
#evaluate_dir(dir) ⇒ Object
419
420
421
422
423
|
# File 'lib/mxrb/dsl/builder.rb', line 419
def evaluate_dir(dir)
return unless File.directory?(dir)
Dir[File.join(dir, '*.rb')].sort.each { |path| evaluate(path) }
end
|
#graph ⇒ Object
432
433
434
|
# File 'lib/mxrb/dsl/builder.rb', line 432
def graph
Architecture::Graph.new(definition)
end
|
#mendix_version(v) ⇒ Object
356
357
358
|
# File 'lib/mxrb/dsl/builder.rb', line 356
def mendix_version(v)
@mendix_version = v
end
|
#module(name, &block) ⇒ Object
360
361
362
363
364
|
# File 'lib/mxrb/dsl/builder.rb', line 360
def module(name, &block)
mod = ModuleBuilder.new(name)
mod.instance_eval(&block) if block
@modules << mod
end
|
#native_unit(unit_id, container_id:, containment:, deep_structure:, module_name: nil) ⇒ Object
399
400
401
402
403
404
405
406
407
408
409
|
# File 'lib/mxrb/dsl/builder.rb', line 399
def native_unit(unit_id, container_id:, containment:, deep_structure:, module_name: nil)
raise ArgumentError, "deep_structure requires a Hash" unless deep_structure.is_a?(Hash)
@native_unit_overrides << {
unit_id: unit_id.to_s,
container_id: container_id.to_s,
containment: containment.to_s,
module: module_name&.to_s,
doc: deep_structure
}
end
|
#native_units(path) ⇒ Object
384
385
386
|
# File 'lib/mxrb/dsl/builder.rb', line 384
def native_units(path)
@native_units_path = path
end
|
#navigation(&block) ⇒ Object
372
373
374
375
376
|
# File 'lib/mxrb/dsl/builder.rb', line 372
def navigation(&block)
builder = NavigationBuilder.new
builder.instance_eval(&block) if block
@navigation = builder.to_h
end
|
#project_assets(manifest, root:) ⇒ Object
388
389
390
391
392
393
|
# File 'lib/mxrb/dsl/builder.rb', line 388
def project_assets(manifest, root:)
@project_assets = {
manifest: File.expand_path(manifest),
root: File.expand_path(root)
}
end
|
#ruby_app_sources(path) ⇒ Object
395
396
397
|
# File 'lib/mxrb/dsl/builder.rb', line 395
def ruby_app_sources(path)
@ruby_app_sources_path = File.expand_path(path)
end
|
#security(&block) ⇒ Object
366
367
368
369
370
|
# File 'lib/mxrb/dsl/builder.rb', line 366
def security(&block)
builder = SecurityBuilder.new
builder.instance_eval(&block) if block
@security = builder.to_h
end
|
#validate_security! ⇒ Object