lib/spring.rb in spring-0.0.4 vs lib/spring.rb in spring-0.0.5

- old
+ new

@@ -8,12 +8,13 @@ require "spring/commands" class Spring SERVER_COMMAND = [ File.join(*RbConfig::CONFIG.values_at('bindir', 'RUBY_INSTALL_NAME')), - "-r", "bundler/setup", + "-I", File.expand_path("../", __FILE__), "-r", "spring/server", + "-r", "bundler/setup", "-e", "Spring::Server.boot" ] FORWARDED_SIGNALS = %w(INT QUIT USR1 USR2 INFO) @@ -49,10 +50,36 @@ Process.spawn(*SERVER_COMMAND, pgroup: SID.pgid) sleep 0.1 until env.socket_path.exist? end def run(args) + if self.class.command_registered?(args.first) + run_command(args) + else + print_help + end + end + + private + + def print_help + puts <<-EOT +Usage: spring COMMAND [ARGS] + +The most common spring commands are: + rake Run a rake task + console Start the Rails console + runner Execute a command with the Rails runner + generate Trigger a Rails generator + + test Execute a Test::Unit test + rspec Execute an RSpec spec +EOT + false + end + + def run_command(args) boot_server unless server_running? application, client = UNIXSocket.pair server = UNIXSocket.open(env.socket_name) @@ -88,11 +115,9 @@ false ensure application.close if application server.close if server end - - private def rails_env_for(command_name) command = Spring.command(command_name) if command.respond_to?(:env)