Module: Commandify::Core
- Included in:
- Command
- Defined in:
- lib/commandify/core.rb
Instance Method Summary collapse
- #command ⇒ Object
-
#goto(path) ⇒ Object
returns shell commands to navigate directories in a rails app.
-
#server_pid(port) ⇒ Object
get the pid of the current ruby process.
Instance Method Details
#command ⇒ Object
23 24 25 |
# File 'lib/commandify/core.rb', line 23 def command @@command ||= [] end |
#goto(path) ⇒ Object
returns shell commands to navigate directories in a rails app
6 7 8 9 10 11 12 13 14 15 16 |
# File 'lib/commandify/core.rb', line 6 def goto path begin raise unless File.exists? 'script/rails' command << "cd #{path}; " if path rescue command << 'cd ..; ' Dir.chdir '..' retry unless Dir.pwd == '/' end STDOUT.puts command.join end |
#server_pid(port) ⇒ Object
get the pid of the current ruby process
19 20 21 |
# File 'lib/commandify/core.rb', line 19 def server_pid port `lsof -i:#{port} | awk '/^ruby/ { print $2 }' `.to_i end |