Skip to content
This repository has been archived by the owner on Sep 20, 2019. It is now read-only.

Commit

Permalink
add support for unknown binary
Browse files Browse the repository at this point in the history
  • Loading branch information
quark-zju committed Oct 16, 2012
1 parent ca84e9a commit d52a095
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 6 deletions.
9 changes: 5 additions & 4 deletions README.md
Expand Up @@ -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
Expand All @@ -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:

Expand Down
14 changes: 12 additions & 2 deletions lib/rrails/server.rb
Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand Down

0 comments on commit d52a095

Please sign in to comment.