Class: ReplRunner
- Inherits:
-
Object
- Object
- ReplRunner
- Defined in:
- lib/repl_runner.rb,
lib/repl_runner/config.rb,
lib/repl_runner/version.rb,
lib/repl_runner/pty_party.rb,
lib/repl_runner/multi_repl.rb,
lib/repl_runner/multi_command_parser.rb
Defined Under Namespace
Classes: Config, MultiCommandParser, MultiRepl, NoResults, PtyParty, UnregisteredCommand
Constant Summary collapse
- VERSION =
"0.0.1"
Instance Attribute Summary collapse
-
#command ⇒ Object
Returns the value of attribute command.
-
#repl ⇒ Object
Returns the value of attribute repl.
Class Method Summary collapse
- .known_configs ⇒ Object
- .register_command(*commands) {|config| ... } ⇒ Object (also: register_commands)
Instance Method Summary collapse
- #close ⇒ Object
-
#initialize(cmd_type, command = nil, options = {}) ⇒ ReplRunner
constructor
A new instance of ReplRunner.
- #known_configs ⇒ Object
- #run(&block) ⇒ Object
- #start ⇒ Object
Constructor Details
#initialize(cmd_type, command = nil, options = {}) ⇒ ReplRunner
Returns a new instance of ReplRunner.
25 26 27 28 29 30 31 32 33 |
# File 'lib/repl_runner.rb', line 25 def initialize(cmd_type, command = nil, = {}) command = cmd_type.to_s if command.nil? cmd_type = cmd_type.chomp.gsub(/\s/, '_').to_sym if cmd_type.is_a?(String) @command = command @repl = nil @config = known_configs[cmd_type] raise UnregisteredCommand.new(cmd_type) unless @config @options = end |
Instance Attribute Details
#command ⇒ Object
Returns the value of attribute command.
9 10 11 |
# File 'lib/repl_runner.rb', line 9 def command @command end |
#repl ⇒ Object
Returns the value of attribute repl.
9 10 11 |
# File 'lib/repl_runner.rb', line 9 def repl @repl end |
Class Method Details
.known_configs ⇒ Object
40 41 42 |
# File 'lib/repl_runner.rb', line 40 def known_configs @known_configs ||= {} end |
Instance Method Details
#close ⇒ Object
58 59 60 |
# File 'lib/repl_runner.rb', line 58 def close repl.close end |
#known_configs ⇒ Object
35 36 37 |
# File 'lib/repl_runner.rb', line 35 def known_configs self.class.known_configs end |
#run(&block) ⇒ Object
62 63 64 65 66 67 68 |
# File 'lib/repl_runner.rb', line 62 def run(&block) repl = start yield repl repl.execute ensure close if repl end |