Class: Boson::ConsoleRunner
- Defined in:
- lib/boson/runners/console_runner.rb
Overview
Class Method Summary collapse
-
.bin_start(repl, libraries) ⇒ Object
Loads libraries and then starts irb (or the configured console) from the commandline.
-
.default_libraries ⇒ Object
:nodoc:.
-
.init ⇒ Object
:nodoc:.
-
.load_repl(repl) ⇒ Object
:nodoc:.
-
.start(options = {}) ⇒ Object
Starts Boson by loading configured libraries.
Methods inherited from Runner
add_load_path, all_libraries, autoload_command, define_autoloader, detected_libraries, in_shell=, in_shell?, load_options, verbose=, verbose?
Class Method Details
.bin_start(repl, libraries) ⇒ Object
Loads libraries and then starts irb (or the configured console) from the commandline.
24 25 26 27 28 29 30 31 32 33 |
# File 'lib/boson/runners/console_runner.rb', line 24 def bin_start(repl, libraries) start :no_defaults=>true, :libraries=>libraries repl = Boson.repo.config[:console] if Boson.repo.config[:console] repl = RUBY_PLATFORM =~ /(:?mswin|mingw)/ ? 'irb.bat' : 'irb' unless repl.is_a?(String) unless repl.index('/') == 0 || (repl = Util.which(repl)) abort "Console not found. Please specify full path in config[:console]." else load_repl(repl) end end |
.default_libraries ⇒ Object
:nodoc:
48 49 50 51 52 53 54 |
# File 'lib/boson/runners/console_runner.rb', line 48 def default_libraries #:nodoc: return [] if @options[:no_defaults] == :all return super if @options[:no_defaults] defaults = super + Boson.repos.map {|e| e.config[:console_defaults] }.flatten defaults += detected_libraries if defaults.empty? defaults.uniq end |
.init ⇒ Object
:nodoc:
42 43 44 45 46 |
# File 'lib/boson/runners/console_runner.rb', line 42 def init #:nodoc: super define_autoloader if @options[:autoload_libraries] @initialized = true end |
.load_repl(repl) ⇒ Object
:nodoc:
35 36 37 38 39 40 |
# File 'lib/boson/runners/console_runner.rb', line 35 def load_repl(repl) #:nodoc: ARGV.replace ['-f'] $progname = $0 alias $0 $progname Kernel.load $0 = repl end |
.start(options = {}) ⇒ Object
Starts Boson by loading configured libraries. If no default libraries are specified in the config, it will load up all detected libraries. Options:
- :libraries
-
Array of libraries to load.
- :verbose
-
Boolean to be verbose about libraries loading. Default is true.
- :no_defaults
-
Boolean or :all which turns off loading default libraries. If set to true, effects loading user’s console default libraries. If set to :all, effects all libraries including boson’s. Default is false.
- :autoload_libraries
-
Boolean which makes any command execution easier. It redefines method_missing on Boson.main_object so that commands with unloaded libraries are automatically loaded. Default is false.
17 18 19 20 21 |
# File 'lib/boson/runners/console_runner.rb', line 17 def start(={}) @options = {:verbose=>true}.merge init unless @initialized Manager.load(@options[:libraries], ) if @options[:libraries] end |