Module: Ripl::Runner::API
- Included in:
- Ripl::Runner
- Defined in:
- lib/ripl/runner.rb
Instance Method Summary collapse
- #format_error(err) ⇒ Object
- #load_rc(file) ⇒ Object
- #parse_options(argv) ⇒ Object
- #run ⇒ Object
- #run_command(argv) ⇒ Object
- #start(options = {}) ⇒ Object
Instance Method Details
#format_error(err) ⇒ Object
52 53 54 |
# File 'lib/ripl/runner.rb', line 52 def format_error(err) "#{err.class}: #{err.}\n #{err.backtrace.join("\n ")}" end |
#load_rc(file) ⇒ Object
46 47 48 49 50 |
# File 'lib/ripl/runner.rb', line 46 def load_rc(file) load file if File.exists?(File.(file)) rescue StandardError, SyntaxError warn "Error while loading #{file}:\n"+ format_error($!) end |
#parse_options(argv) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/ripl/runner.rb', line 14 def (argv) while argv[0] =~ /^-/ case argv.shift when /-I=?(.*)/ $LOAD_PATH.unshift(*$1.split(":")) when /-r=?(.*)/ require $1 when '-d' $DEBUG = true when '-v', '--version' puts Ripl::VERSION; exit when '-f' ENV['RIPL_IRBRC'] = 'false' when '-h', '--help' puts IO.readlines(__FILE__).grep(/^#/).map {|e| e.sub(/^#\s/,'') }; exit end end end |
#run ⇒ Object
7 8 9 10 11 12 |
# File 'lib/ripl/runner.rb', line 7 def run load_rc(Ripl.config[:riplrc]) @riplrc = true (ARGV) ARGV[0] ? run_command(ARGV) : start end |
#run_command(argv) ⇒ Object
33 34 35 36 37 38 |
# File 'lib/ripl/runner.rb', line 33 def run_command(argv) exec "ripl-#{argv.shift}", *argv rescue Errno::ENOENT raise unless $!. =~ /No such file or directory.*ripl-(\w+)/ abort "`#{$1}' is not a ripl command." end |