Class: Spring::Client::Binstub
- Defined in:
- lib/spring/client/binstub.rb
Instance Attribute Summary collapse
-
#bindir ⇒ Object
readonly
Returns the value of attribute bindir.
-
#command ⇒ Object
readonly
Returns the value of attribute command.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Attributes inherited from Command
Class Method Summary collapse
Instance Method Summary collapse
- #binstub ⇒ Object
- #call ⇒ Object
- #fallback ⇒ Object
- #generate_binstub ⇒ Object
-
#initialize(args) ⇒ Binstub
constructor
A new instance of Binstub.
Constructor Details
Instance Attribute Details
#bindir ⇒ Object (readonly)
Returns the value of attribute bindir.
4 5 6 |
# File 'lib/spring/client/binstub.rb', line 4 def bindir @bindir end |
#command ⇒ Object (readonly)
Returns the value of attribute command.
4 5 6 |
# File 'lib/spring/client/binstub.rb', line 4 def command @command end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
4 5 6 |
# File 'lib/spring/client/binstub.rb', line 4 def name @name end |
Class Method Details
.call(args) ⇒ Object
10 11 12 13 |
# File 'lib/spring/client/binstub.rb', line 10 def self.call(args) require "spring/commands" super end |
.description ⇒ Object
6 7 8 |
# File 'lib/spring/client/binstub.rb', line 6 def self.description "Generate spring based binstubs." end |
Instance Method Details
#binstub ⇒ Object
33 34 35 |
# File 'lib/spring/client/binstub.rb', line 33 def binstub bindir.join(name) end |
#call ⇒ Object
23 24 25 26 27 28 29 30 31 |
# File 'lib/spring/client/binstub.rb', line 23 def call if command || name == "rails" bindir.mkdir unless bindir.exist? generate_binstub else $stderr.puts "The '#{name}' command is not known to spring." exit 1 end end |
#fallback ⇒ Object
52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/spring/client/binstub.rb', line 52 def fallback if command.respond_to?(:fallback) command.fallback elsif name == "rails" <<CODE APP_PATH = File.expand_path('../../config/application', __FILE__) require_relative '../config/boot' require 'rails/commands' CODE else %{exec "bundle", "exec", "#{name}", *ARGV} end end |
#generate_binstub ⇒ Object
37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/spring/client/binstub.rb', line 37 def generate_binstub File.write(binstub, <<CODE) #!/usr/bin/env ruby if !Process.respond_to?(:fork) || Gem::Specification.find_all_by_name("spring").empty? #{fallback.strip.gsub(/^/, " ")} else ARGV.unshift "#{name}" load Gem.bin_path("spring", "spring") end CODE binstub.chmod 0755 end |