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.
69
70
71
72
73
74
75
76
|
# File 'lib/ridl/backend.rb', line 69
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.
78
79
80
|
# File 'lib/ridl/backend.rb', line 78
def copyright
@copyright
end
|
#name ⇒ Object
Returns the value of attribute name.
78
79
80
|
# File 'lib/ridl/backend.rb', line 78
def name
@name
end
|
#root ⇒ Object
Returns the value of attribute root.
78
79
80
|
# File 'lib/ridl/backend.rb', line 78
def root
@root
end
|
#title ⇒ Object
Returns the value of attribute title.
78
79
80
|
# File 'lib/ridl/backend.rb', line 78
def title
@title
end
|
Class Method Details
59
60
61
62
63
|
# File 'lib/ridl/backend.rb', line 59
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
|
# File 'lib/ridl/backend.rb', line 44
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 => ex
IDL.error "ERROR: Cannot load RIDL backend [:#{be_name}]"
IDL.error ex.inspect
IDL.error(ex.backtrace.join("\n")) if $VERBOSE
exit 1
end
end
|
.null_be ⇒ Object
112
113
114
115
116
117
118
119
120
121
122
|
# File 'lib/ridl/backend.rb', line 112
def self.null_be
@@null_be ||= self.configure('null', '.', 'RIDL Null backend', 'Copyright (c) 2013 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
becfg.on_process_input do |parser, params|
end
end
end
|
.stop_processing ⇒ Object
65
66
67
|
# File 'lib/ridl/backend.rb', line 65
def self.stop_processing
raise ProcessStop, 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
84
85
86
87
88
|
# File 'lib/ridl/backend.rb', line 84
def print_version
puts "#{title} #{version}"
puts copyright
@base_backends.each {|be| puts '---'; be.print_version }
end
|
102
103
104
105
106
107
108
|
# File 'lib/ridl/backend.rb', line 102
def process_input(parser, params)
unless _process_input(parser, params)
return @base_backends.any? {|be| be.process_input(parser, params) }
end
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)
end
|
#version ⇒ Object
80
81
82
|
# File 'lib/ridl/backend.rb', line 80
def version
"#{@version[:major]}.#{@version[:minor]}.#{@version[:release]}"
end
|