Class: Spring::CommandWrapper
- Inherits:
-
Object
- Object
- Spring::CommandWrapper
- Defined in:
- lib/spring/command_wrapper.rb
Instance Attribute Summary collapse
-
#command ⇒ Object
readonly
Returns the value of attribute command.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
- #binstub ⇒ Object
- #binstub_name ⇒ Object
- #call ⇒ Object
- #description ⇒ Object
- #env(args) ⇒ Object
- #exec ⇒ Object
- #exec_name ⇒ Object
- #gem_name ⇒ Object
-
#initialize(name, command = nil) ⇒ CommandWrapper
constructor
A new instance of CommandWrapper.
- #setup ⇒ Object
- #setup? ⇒ Boolean
Constructor Details
#initialize(name, command = nil) ⇒ CommandWrapper
7 8 9 10 11 |
# File 'lib/spring/command_wrapper.rb', line 7 def initialize(name, command = nil) @name = name @command = command @setup = false end |
Instance Attribute Details
#command ⇒ Object (readonly)
Returns the value of attribute command.
5 6 7 |
# File 'lib/spring/command_wrapper.rb', line 5 def command @command end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
5 6 7 |
# File 'lib/spring/command_wrapper.rb', line 5 def name @name end |
Instance Method Details
#binstub ⇒ Object
60 61 62 |
# File 'lib/spring/command_wrapper.rb', line 60 def binstub Spring.application_root_path.join(binstub_name) end |
#binstub_name ⇒ Object
64 65 66 |
# File 'lib/spring/command_wrapper.rb', line 64 def binstub_name "bin/#{name}" end |
#call ⇒ Object
36 37 38 39 40 41 42 |
# File 'lib/spring/command_wrapper.rb', line 36 def call if command.respond_to?(:call) command.call else load exec end end |
#description ⇒ Object
13 14 15 16 17 18 19 |
# File 'lib/spring/command_wrapper.rb', line 13 def description if command.respond_to?(:description) command.description else "Runs the #{name} command" end end |
#env(args) ⇒ Object
76 77 78 79 80 |
# File 'lib/spring/command_wrapper.rb', line 76 def env(args) if command.respond_to?(:env) command.env(args) end end |
#exec ⇒ Object
68 69 70 71 72 73 74 |
# File 'lib/spring/command_wrapper.rb', line 68 def exec if binstub.exist? binstub.to_s else Gem.bin_path(gem_name, exec_name) end end |
#exec_name ⇒ Object
52 53 54 55 56 57 58 |
# File 'lib/spring/command_wrapper.rb', line 52 def exec_name if command.respond_to?(:exec_name) command.exec_name else name end end |
#gem_name ⇒ Object
44 45 46 47 48 49 50 |
# File 'lib/spring/command_wrapper.rb', line 44 def gem_name if command.respond_to?(:gem_name) command.gem_name else exec_name end end |
#setup ⇒ Object
25 26 27 28 29 30 31 32 33 34 |
# File 'lib/spring/command_wrapper.rb', line 25 def setup if !setup? && command.respond_to?(:setup) command.setup @setup = true return true else @setup = true return false end end |
#setup? ⇒ Boolean
21 22 23 |
# File 'lib/spring/command_wrapper.rb', line 21 def setup? @setup end |