Class: IDL::Backend
- Inherits:
-
Object
show all
- Defined in:
- lib/ridl/backend.rb
Defined Under Namespace
Classes: Configurator, ProcessStop
Constant Summary
collapse
- @@backends =
{}
- @@null_be =
nil
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Constructor Details
#initialize(be_name, root, ttl, cpr, ver) ⇒ Backend
Returns a new instance of Backend.
68
69
70
71
72
73
74
75
|
# File 'lib/ridl/backend.rb', line 68
def initialize(be_name, root, ttl, cpr, ver)
@name = be_name.to_sym
@root = root
@title = ttl
@copyright = cpr
@version = (Hash === ver ? ver : { major: ver.to_i, minor: 0, release: 0 })
@base_backends = []
end
|
Instance Attribute Details
#copyright ⇒ Object
Returns the value of attribute copyright.
77
78
79
|
# File 'lib/ridl/backend.rb', line 77
def copyright
@copyright
end
|
#name ⇒ Object
Returns the value of attribute name.
77
78
79
|
# File 'lib/ridl/backend.rb', line 77
def name
@name
end
|
#root ⇒ Object
Returns the value of attribute root.
77
78
79
|
# File 'lib/ridl/backend.rb', line 77
def root
@root
end
|
#title ⇒ Object
Returns the value of attribute title.
77
78
79
|
# File 'lib/ridl/backend.rb', line 77
def title
@title
end
|
Class Method Details
57
58
59
60
61
|
# File 'lib/ridl/backend.rb', line 57
def self.configure(be_name, root, title, copyright, version, &block)
cfg = Configurator.new(be_name, root, title, copyright, version)
block.call(cfg)
@@backends[cfg.backend.name] = cfg.backend
end
|
.load(be_name) ⇒ Object
42
43
44
45
46
47
48
49
50
51
52
53
54
55
|
# File 'lib/ridl/backend.rb', line 42
def self.load(be_name)
begin
require "ridlbe/#{be_name}/require"
IDL.log(1, "> loaded RIDL backend :#{be_name} from #{@@backends[be_name.to_sym].root}")
return @@backends[be_name.to_sym]
rescue LoadError => e
IDL.error "ERROR: Cannot load RIDL backend [:#{be_name}]"
IDL.error e.inspect
IDL.error(e.backtrace.join("\n")) if IDL.verbose_level.positive?
exit 1
end
end
|
.null_be ⇒ Object
110
111
112
113
114
115
116
117
|
# File 'lib/ridl/backend.rb', line 110
def self.null_be
@@null_be ||= self.configure('null', '.', 'RIDL Null backend', "Copyright (c) 2013-#{Time.now.year} Remedy IT Expertise BV, The Netherlands", 1) do |becfg|
becfg.on_setup do |optlist, params|
IDL.log(0, "Setup called for #{becfg.backend.title}")
end
end
end
|
.stop_processing(msg = '') ⇒ Object
stop processing of current input and skip to next or exit RIDL
64
65
66
|
# File 'lib/ridl/backend.rb', line 64
def self.stop_processing(msg = '')
raise ProcessStop, msg, caller(1).first
end
|
Instance Method Details
#lookup_path ⇒ Object
90
91
92
|
# File 'lib/ridl/backend.rb', line 90
def lookup_path
@base_backends.inject([@root]) { |paths, bbe| paths.concat(bbe.lookup_path) }
end
|
#print_version ⇒ Object
83
84
85
86
87
88
|
# File 'lib/ridl/backend.rb', line 83
def print_version
puts "#{title} #{version}"
puts copyright
@base_backends.each { |be| puts '---'
be.print_version }
end
|
102
103
104
105
106
|
# File 'lib/ridl/backend.rb', line 102
def process_input(parser, params)
@base_backends.reverse.each { |be| be.process_input(parser, params) }
_process_input(parser, params) if self.respond_to?(:_process_input, true)
end
|
#setup_be(optlist, idl_options) ⇒ Object
94
95
96
97
98
99
100
|
# File 'lib/ridl/backend.rb', line 94
def setup_be(optlist, idl_options)
@base_backends.reverse.each { |be| be.setup_be(optlist, idl_options) }
_setup_be(optlist, idl_options) if self.respond_to?(:_setup_be, true)
end
|
#version ⇒ Object
79
80
81
|
# File 'lib/ridl/backend.rb', line 79
def version
"#{@version[:major]}.#{@version[:minor]}.#{@version[:release]}"
end
|