Class: Spring::Client::Binstub
- Defined in:
- lib/spring/client/binstub.rb
Instance Attribute Summary collapse
-
#bindir ⇒ Object
readonly
Returns the value of attribute bindir.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Attributes inherited from Command
Class Method Summary collapse
Instance Method Summary collapse
- #call ⇒ Object
- #command_binstub ⇒ Object
- #generate_command_binstub ⇒ Object
- #generate_spring_binstub ⇒ Object
-
#initialize(args) ⇒ Binstub
constructor
A new instance of Binstub.
- #spring_binstub ⇒ Object
Methods inherited from Command
Constructor Details
#initialize(args) ⇒ Binstub
Returns a new instance of Binstub.
10 11 12 13 14 15 |
# File 'lib/spring/client/binstub.rb', line 10 def initialize(args) super @bindir = env.root.join("bin") @name = args[1] end |
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 |
#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
.description ⇒ Object
6 7 8 |
# File 'lib/spring/client/binstub.rb', line 6 def self.description "Generate spring based binstubs." end |
Instance Method Details
#call ⇒ Object
17 18 19 20 21 22 23 24 25 26 |
# File 'lib/spring/client/binstub.rb', line 17 def call if Spring.command?(name) bindir.mkdir unless bindir.exist? generate_spring_binstub generate_command_binstub else STDERR.puts "The '#{name}' command is not known to spring." exit 1 end end |
#command_binstub ⇒ Object
32 33 34 |
# File 'lib/spring/client/binstub.rb', line 32 def command_binstub bindir.join(name) end |
#generate_command_binstub ⇒ Object
61 62 63 64 65 66 67 68 |
# File 'lib/spring/client/binstub.rb', line 61 def generate_command_binstub File.write(command_binstub, <<CODE) #!/usr/bin/env bash exec $(dirname $0)/spring #{name} "$@" CODE command_binstub.chmod 0755 end |
#generate_spring_binstub ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/spring/client/binstub.rb', line 36 def generate_spring_binstub File.write(spring_binstub, <<'CODE') #!/usr/bin/env ruby # This is a special way of invoking the spring gem in order to # work around the performance issue discussed in # https://github.com/rubygems/rubygems/pull/435 glob = "{#{Gem::Specification.dirs.join(",")}}/spring-*.gemspec" candidates = Dir[glob].to_a.sort spec = Gem::Specification.load(candidates.last) if spec spec.activate load spec.bin_file("spring") else STDERR.puts "Could not find spring gem in #{Gem::Specification.dirs.join(", ")}." exit 1 end CODE spring_binstub.chmod 0755 end |
#spring_binstub ⇒ Object
28 29 30 |
# File 'lib/spring/client/binstub.rb', line 28 def spring_binstub bindir.join("spring") end |