Module: RemoteTerminal::CLI
- Defined in:
- lib/remote-terminal/cli.rb
Class Method Summary collapse
- .config(addr, user, remote_dir, local_dir) ⇒ Object
- .execute(cmd, rsync, ssh, path) ⇒ Object
- .with_slash(path) ⇒ Object
- .without_slash(path) ⇒ Object
Class Method Details
.config(addr, user, remote_dir, local_dir) ⇒ Object
3 4 5 6 7 8 9 10 11 |
# File 'lib/remote-terminal/cli.rb', line 3 def CLI.config(addr, user, remote_dir, local_dir) config = Hash.new config['address'] = addr config['user'] = user config['remote_directory'] = remote_dir File.open(File.join(local_dir, '.remote-terminal.yml'), "w") do |f| f.write(config.to_yaml) end end |
.execute(cmd, rsync, ssh, path) ⇒ Object
13 14 15 16 17 18 19 20 |
# File 'lib/remote-terminal/cli.rb', line 13 def CLI.execute(cmd, rsync, ssh, path) puts path project = Project.find(path) output = rsync.run(project.path_from(path), without_slash("#{project.user}@#{project.address}:#{project.remote_directory}")) output += ssh.run("#{project.user}@#{project.address}", File.join(project.remote_directory, project.path_to(path)), cmd) output += rsync.run(with_slash("#{project.user}@#{project.address}:#{project.remote_directory}"), project.path_from(path)) return output end |
.with_slash(path) ⇒ Object
30 31 32 33 34 35 36 |
# File 'lib/remote-terminal/cli.rb', line 30 def CLI.with_slash(path) if path[-1] == '/' return path else return "#{path}/" end end |
.without_slash(path) ⇒ Object
22 23 24 25 26 27 28 |
# File 'lib/remote-terminal/cli.rb', line 22 def CLI.without_slash(path) if path[-1] == '/' return path[0..-2] else return path end end |