From d52a09573e3a3fcaa919e418b5dde19e1ffcd106 Mon Sep 17 00:00:00 2001 From: WU Jun Date: Tue, 16 Oct 2012 21:28:23 +0800 Subject: [PATCH] add support for unknown binary --- README.md | 9 +++++---- lib/rrails/server.rb | 14 ++++++++++++-- 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 17272b7..c23c598 100644 --- a/README.md +++ b/README.md @@ -13,8 +13,8 @@ Without rrails: With rrails: - $ source <(rrails shellrc) - $ rrails start # optionally + $ source <(rrails shellrc) # set aliases for rails and rake + $ rrails start # start the server, optionally $ time ( rails generate >/dev/null ) ( rails generate > /dev/null; ) 0.05s user 0.01s system 6% cpu 0.904 total @@ -28,15 +28,16 @@ With rrails: ## Usage -Run rails/rake commands using rrails: +Run rails/rake and other commands using rrails: $ export RAILS_ENV=development # optionally - $ rrails rails generate model Yakiniku # first command, slow + $ rrails rails generate model Yakiniku # first command, server starts on demand, slow $ rrails rails server # fast $ rrails rails console # fast $ rrails rake db:migrate # fast $ rrails rake routes # fast $ rrails -- rake -T # '--' is needed. Otherwise '-T' will be parsed by rrails + $ rrails annotate # fast. "gem 'annotate'" should exist in Gemfile For more options, run: diff --git a/lib/rrails/server.rb b/lib/rrails/server.rb index c0b40fb..de128ba 100644 --- a/lib/rrails/server.rb +++ b/lib/rrails/server.rb @@ -70,7 +70,7 @@ def status def start # check previous process - raise RuntimeError.new('RRails is already running') if alive? + raise RuntimeError.new('rrails is already running') if alive? if @background pid = Process.fork do @@ -267,7 +267,17 @@ def execute(cmd, *args) $0 = Gem.bin_path('rake') ::Rake.application.run else - STDERR.puts "#{cmd} is not supported in RRails." + # unknown binary, try to locate its location + bin_path = begin + Gem.bin_path(cmd) + rescue + STDERR.puts "rrails: command not found: #{cmd}" + STDERR.puts "Install missing gem executables with `bundle install`" + exit(127) + end + + # then load it + load bin_path end end