Module: EacCli::Runner::InstanceMethods
- Defined in:
- lib/eac_cli/runner/instance_methods.rb
Constant Summary
collapse
- PARSER_ERROR_EXIT_CODE =
1
Instance Method Summary
collapse
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args, &block) ⇒ Object
46
47
48
49
50
|
# File 'lib/eac_cli/runner/instance_methods.rb', line 46
def method_missing(method, *args, &block)
return super if runner_context.parent.blank? || !runner_context.parent.respond_to?(method)
runner_context.parent.send(method, *args, &block)
end
|
Instance Method Details
33
34
35
|
# File 'lib/eac_cli/runner/instance_methods.rb', line 33
def parsed
@parsed ||= ::EacCli::Parser.new(self.class.runner_definition, runner_context.argv).parsed
end
|
#program_name ⇒ Object
37
38
39
|
# File 'lib/eac_cli/runner/instance_methods.rb', line 37
def program_name
runner_context.if_present(&:program_name) || $PROGRAM_NAME
end
|
#respond_to_missing?(method, include_all = false) ⇒ Boolean
41
42
43
44
|
# File 'lib/eac_cli/runner/instance_methods.rb', line 41
def respond_to_missing?(method, include_all = false)
runner_context.parent.if_present(false) { |v| v.respond_to?(method, include_all) } ||
super
end
|
#run_parser_error(error) ⇒ Object
17
18
19
20
|
# File 'lib/eac_cli/runner/instance_methods.rb', line 17
def run_parser_error(error)
$stderr.write("#{program_name}: #{error}\n")
::Kernel.exit(PARSER_ERROR_EXIT_CODE)
end
|
8
9
10
11
12
13
14
15
|
# File 'lib/eac_cli/runner/instance_methods.rb', line 8
def run_run
parsed
run_callbacks(:run) { run }
rescue ::EacCli::Parser::Error => e
run_parser_error(e)
rescue ::EacCli::Runner::Exit end
|
#runner_context ⇒ Object
22
23
24
25
26
|
# File 'lib/eac_cli/runner/instance_methods.rb', line 22
def runner_context
return @runner_context if @runner_context
raise 'Context was required, but was not set yet'
end
|
#runner_context=(new_runner_context) ⇒ Object
28
29
30
31
|
# File 'lib/eac_cli/runner/instance_methods.rb', line 28
def runner_context=(new_runner_context)
@runner_context = new_runner_context
@parsed = nil
end
|