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(argv = ARGV) ⇒ Object
- #run_command(argv) ⇒ Object
- #start(options = {}) ⇒ Object
Instance Method Details
#format_error(err) ⇒ Object
54 55 56 |
# File 'lib/ripl/runner.rb', line 54 def format_error(err) "#{err.class}: #{err.}\n #{err.backtrace.join("\n ")}" end |
#load_rc(file) ⇒ Object
48 49 50 51 52 |
# File 'lib/ripl/runner.rb', line 48 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 32 33 |
# File 'lib/ripl/runner.rb', line 14 def (argv) while argv[0] =~ /^-/ case argv.shift when /-I=?(.*)/ $LOAD_PATH.unshift(*($1.empty? ? argv.shift.to_s : $1).split(":")) when /-r=?(.*)/ require $1.empty? ? argv.shift.to_s : $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 when /^--?([^-]+)/ warn "ripl: invalid option `#{$1}'" end end end |
#run(argv = ARGV) ⇒ Object
7 8 9 10 11 12 |
# File 'lib/ripl/runner.rb', line 7 def run(argv=ARGV) load_rc(Ripl.config[:riplrc]) @riplrc = true (argv) argv[0] ? run_command(argv) : start end |
#run_command(argv) ⇒ Object
35 36 37 38 39 40 |
# File 'lib/ripl/runner.rb', line 35 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 |