class SpringStandalone::Client::Binstub
Constants
- BINSTUB_VARIATIONS
- LOADER
If loading the bin/spring_sa file works, it'll run
SpringStandalone
which will eventually call Kernel.exit. This means that in the client process we will never execute the lines after this block. But if theSpringStandalone
client is not invoked for whatever reason, then the Kernel.exit won't happen, and so we'll fall back to the lines after this block, which should cause the “unsprung” version of the command to run.- OLD_BINSTUB
- SHEBANG
- SPRING
The defined? check ensures these lines don't execute when we load the binstub from the application process. Which means that in the application process we'll execute the lines which come after the
LOADER
block, which is what we want.
Attributes
bindir[R]
items[R]
Public Class Methods
call(args)
click to toggle source
def self.rails_command
@rails_command ||= CommandWrapper.new("rails")
end
Calls superclass method
# File lib/spring_standalone/client/binstub.rb, line 136 def self.call(args) require "spring_standalone/commands" super end
description()
click to toggle source
# File lib/spring_standalone/client/binstub.rb, line 128 def self.description "Generate SpringStandalone based binstubs. Use --all to generate a binstub for all known commands. Use --remove to revert." end
new(args)
click to toggle source
Calls superclass method
# File lib/spring_standalone/client/binstub.rb, line 141 def initialize(args) super @bindir = env.root.join("bin") @all = false @mode = :add @items = args.drop(1) .map { |name| find_commands name } .inject(Set.new, :|) .map { |command| Item.new(command) } end
Public Instance Methods
call()
click to toggle source
# File lib/spring_standalone/client/binstub.rb, line 176 def call case @mode when :add bindir.mkdir unless bindir.exist? File.write(spring_sa_binstub, SPRING) spring_sa_binstub.chmod 0755 items.each(&:add) when :remove spring_sa_binstub.delete if @all items.each(&:remove) else raise ArgumentError end end
find_commands(name)
click to toggle source
# File lib/spring_standalone/client/binstub.rb, line 153 def find_commands(name) case name when "--all" @all = true commands = SpringStandalone.commands.dup commands.values # commands.delete_if { |command_name, _| command_name.start_with?("rails_") } # commands.values + [self.class.rails_command] when "--remove" @mode = :remove [] # when "rails" # [self.class.rails_command] else if command = SpringStandalone.commands[name] [command] else $stderr.puts "The '#{name}' command is not known to spring_standalone." exit 1 end end end
spring_sa_binstub()
click to toggle source
# File lib/spring_standalone/client/binstub.rb, line 193 def spring_sa_binstub bindir.join("spring_sa") end