remote-terminal 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
data/.document ADDED
@@ -0,0 +1,5 @@
1
+ lib/**/*.rb
2
+ bin/*
3
+ -
4
+ features/**/*.feature
5
+ LICENSE.txt
data/.rspec ADDED
@@ -0,0 +1 @@
1
+ --color
data/Gemfile ADDED
@@ -0,0 +1,15 @@
1
+ source "http://rubygems.org"
2
+ # Add dependencies required to use your gem here.
3
+ # Example:
4
+ # gem "activesupport", ">= 2.3.5"
5
+
6
+ # Add dependencies to develop your gem here.
7
+ # Include everything needed to run rake, tests, features, etc.
8
+ group :development do
9
+ gem "rspec", ">= 2.11.0"
10
+ gem "rdoc", ">= 3.12"
11
+ gem "cucumber", ">= 1.2.1"
12
+ gem "bundler", ">= 1.0.0"
13
+ gem "jeweler", ">= 1.8.4"
14
+ gem "simplecov", ">= 0.6.4"
15
+ end
data/Gemfile.lock ADDED
@@ -0,0 +1,46 @@
1
+ GEM
2
+ remote: http://rubygems.org/
3
+ specs:
4
+ builder (3.1.4)
5
+ cucumber (1.2.1)
6
+ builder (>= 2.1.2)
7
+ diff-lcs (>= 1.1.3)
8
+ gherkin (~> 2.11.0)
9
+ json (>= 1.4.6)
10
+ diff-lcs (1.1.3)
11
+ gherkin (2.11.5)
12
+ json (>= 1.4.6)
13
+ git (1.2.5)
14
+ jeweler (1.8.4)
15
+ bundler (~> 1.0)
16
+ git (>= 1.2.5)
17
+ rake
18
+ rdoc
19
+ json (1.7.6)
20
+ multi_json (1.5.0)
21
+ rake (10.0.3)
22
+ rdoc (3.12)
23
+ json (~> 1.4)
24
+ rspec (2.12.0)
25
+ rspec-core (~> 2.12.0)
26
+ rspec-expectations (~> 2.12.0)
27
+ rspec-mocks (~> 2.12.0)
28
+ rspec-core (2.12.2)
29
+ rspec-expectations (2.12.1)
30
+ diff-lcs (~> 1.1.3)
31
+ rspec-mocks (2.12.2)
32
+ simplecov (0.7.1)
33
+ multi_json (~> 1.0)
34
+ simplecov-html (~> 0.7.1)
35
+ simplecov-html (0.7.1)
36
+
37
+ PLATFORMS
38
+ ruby
39
+
40
+ DEPENDENCIES
41
+ bundler (>= 1.0.0)
42
+ cucumber (>= 1.2.1)
43
+ jeweler (>= 1.8.4)
44
+ rdoc (>= 3.12)
45
+ rspec (>= 2.11.0)
46
+ simplecov (>= 0.6.4)
data/LICENSE.txt ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2013 Ígor Bonadio
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.rdoc ADDED
@@ -0,0 +1,39 @@
1
+ = Remote Terminal v0.1.1
2
+
3
+ Remote Terminal uses SSH and RSync to help you to execute commands remotely as if you were running them locally.
4
+
5
+ For example, imagine that you are working on a C project on your local computer and you want to test it on a remote linux virtual machine. All you need to do is:
6
+
7
+ $ cd my_project
8
+ $ rt-config remote_machine_address username Projects/my_remote_folder
9
+
10
+ And now you can start sending commands:
11
+
12
+ $ rt ./configure
13
+ $ rt make
14
+ $ rt ./run_project
15
+
16
+ == Requirements
17
+
18
+ * rsync (http://rsync.samba.org)
19
+ * ssh (http://www.openssh.com)
20
+
21
+ == Install
22
+
23
+ $ gem install remote-terminal
24
+
25
+ == Contributing to Remote Terminal
26
+
27
+ * Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet.
28
+ * Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it.
29
+ * Fork the project.
30
+ * Start a feature/bugfix branch.
31
+ * Commit and push until you are happy with your contribution.
32
+ * Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
33
+ * Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
34
+
35
+ == Copyright
36
+
37
+ Copyright (c) 2013 Ígor Bonadio. See LICENSE.txt for
38
+ further details.
39
+
data/Rakefile ADDED
@@ -0,0 +1,52 @@
1
+ # encoding: utf-8
2
+
3
+ require 'rubygems'
4
+ require 'bundler'
5
+ begin
6
+ Bundler.setup(:default, :development)
7
+ rescue Bundler::BundlerError => e
8
+ $stderr.puts e.message
9
+ $stderr.puts "Run `bundle install` to install missing gems"
10
+ exit e.status_code
11
+ end
12
+ require 'rake'
13
+
14
+ require 'jeweler'
15
+ Jeweler::Tasks.new do |gem|
16
+ # gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
17
+ gem.name = "remote-terminal"
18
+ gem.homepage = "http://github.com/igorbonadio/remote-terminal"
19
+ gem.license = "MIT"
20
+ gem.summary = %Q{Remote Terminal helps you to execute commands remotely as if you were running them locally}
21
+ gem.description = %Q{Remote Terminal uses SSH and RSync to help you to execute commands remotely as if you were running them locally}
22
+ gem.email = "igorbonadio@gmail.com"
23
+ gem.authors = ["Igor Bonadio"]
24
+ # dependencies defined in Gemfile
25
+ end
26
+ Jeweler::RubygemsDotOrgTasks.new
27
+
28
+ require 'rspec/core'
29
+ require 'rspec/core/rake_task'
30
+ RSpec::Core::RakeTask.new(:spec) do |spec|
31
+ spec.pattern = FileList['spec/**/*_spec.rb']
32
+ end
33
+
34
+ RSpec::Core::RakeTask.new(:rcov) do |spec|
35
+ spec.pattern = 'spec/**/*_spec.rb'
36
+ spec.rcov = true
37
+ end
38
+
39
+ require 'cucumber/rake/task'
40
+ Cucumber::Rake::Task.new(:features)
41
+
42
+ task :default => :spec
43
+
44
+ require 'rdoc/task'
45
+ Rake::RDocTask.new do |rdoc|
46
+ version = File.exist?('VERSION') ? File.read('VERSION') : ""
47
+
48
+ rdoc.rdoc_dir = 'rdoc'
49
+ rdoc.title = "remote-terminal #{version}"
50
+ rdoc.rdoc_files.include('README*')
51
+ rdoc.rdoc_files.include('lib/**/*.rb')
52
+ end
data/TODO ADDED
@@ -0,0 +1,3 @@
1
+ TODO
2
+
3
+ quando eu removo um arquivo, ele devia ser removido!
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.1.1
data/bin/rt ADDED
@@ -0,0 +1,15 @@
1
+ #!/usr/bin/env ruby
2
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
3
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
4
+
5
+ require 'remote-terminal'
6
+ require 'etc'
7
+
8
+ cmd = ARGV.join(' ')
9
+ local_dir = Dir.pwd
10
+
11
+ begin
12
+ puts RemoteTerminal::CLI.execute(cmd, RemoteTerminal::Rsync.new, RemoteTerminal::SSH.new, local_dir)
13
+ rescue Exception => e
14
+ puts e
15
+ end
data/bin/rt-config ADDED
@@ -0,0 +1,18 @@
1
+ #!/usr/bin/env ruby
2
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
3
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
4
+
5
+ require 'remote-terminal'
6
+ require 'etc'
7
+
8
+ addr = ARGV[0]
9
+ user = ARGV[1]
10
+ remote_dir = ARGV[2]
11
+ local_dir = Dir.pwd
12
+
13
+ begin
14
+ RemoteTerminal::CLI.config(addr, user, remote_dir, local_dir)
15
+ puts "done!"
16
+ rescue Exception => e
17
+ puts e
18
+ end
@@ -0,0 +1,11 @@
1
+ Feature: Configuration
2
+ In order to use a remote terminal
3
+ As a user
4
+ I want to configure my remote terminal
5
+
6
+ Scenario: Add configuration
7
+ Given the remote computer's IP is 10.210.123.4
8
+ And my user is "igorbonadio"
9
+ And the working directory is "~/Projects/MyProject"
10
+ When I execute the remote terminal configuration
11
+ Then I should see that a configuration file was created
@@ -0,0 +1,4 @@
1
+ ---
2
+ address: 10.210.123.4
3
+ user: igorbonadio
4
+ remote_directory: ~/Projects/MyProject
@@ -0,0 +1,3 @@
1
+ rsync -raze ssh .. igorbonadio@ubuntu1210:Project
2
+ ssh igorbonadio@ubuntu1210: 'cd Projetos/folder && make'
3
+ rsync -raze ssh igorbonadio@ubuntu1210:Projetos ..
@@ -0,0 +1,4 @@
1
+ # Ignore everything in this directory
2
+ *
3
+ # Except this file
4
+ !.gitignore
@@ -0,0 +1,3 @@
1
+ rsync -raze ssh . igorbonadio@ubuntu1210:Project
2
+ ssh igorbonadio@ubuntu1210: 'cd Projetos && make'
3
+ rsync -raze ssh igorbonadio@ubuntu1210:Projetos .
@@ -0,0 +1,34 @@
1
+ Feature: Project
2
+ In order to use a remote terminal
3
+ As a user
4
+ I want to open and use a project
5
+
6
+ Scenario: Get path from the current location
7
+ Given I am in the "features/data/project" directory
8
+ When I get the path from my location
9
+ Then I should see "."
10
+
11
+ Scenario: Get path from the current location
12
+ Given I am in the "features/data/project/folder" directory
13
+ When I get the path from my location
14
+ Then I should see ".."
15
+
16
+ Scenario: Get path from the current location
17
+ Given I am in the "features/data/project/folder/subfolder" directory
18
+ When I get the path from my location
19
+ Then I should see "../.."
20
+
21
+ Scenario: Get path to the current location
22
+ Given I am in the "features/data/project" directory
23
+ When I get the path to my location
24
+ Then I should see ""
25
+
26
+ Scenario: Get path to the current location
27
+ Given I am in the "features/data/project/folder" directory
28
+ When I get the path to my location
29
+ Then I should see "folder/"
30
+
31
+ Scenario: Get path to the current location
32
+ Given I am in the "features/data/project/folder/subfolder" directory
33
+ When I get the path to my location
34
+ Then I should see "folder/subfolder/"
@@ -0,0 +1,19 @@
1
+ Feature: Remote Terminal
2
+ In order to use a remote terminal
3
+ As a user
4
+ I want to execute some commands
5
+
6
+ Scenario: Root
7
+ Given I am in the "features/data/project" directory
8
+ When I execute "make"
9
+ Then I should see "features/data/project/make" output
10
+
11
+ Scenario: Folder
12
+ Given I am in the "features/data/project/folder" directory
13
+ When I execute "make"
14
+ Then I should see "features/data/project/folder/make" output
15
+
16
+ Scenario: Folder
17
+ Given I am in the "features/data/project/folder/subfolder" directory
18
+ When I execute "make"
19
+ Then I should see "features/data/project/folder/subfolder/make" output
@@ -0,0 +1,23 @@
1
+ Given /^my user is "(.*?)"$/ do |user|
2
+ @user = user
3
+ end
4
+
5
+ Given /^the working directory is "(.*?)"$/ do |dir|
6
+ @dir = dir
7
+ end
8
+
9
+ When /^I execute the remote terminal configuration$/ do
10
+ FileUtils.rm('tmp/.remote-terminal') if Dir.exist?('tmp/.remote-terminal')
11
+ RemoteTerminal::CLI.config(@address, @user, @dir, 'tmp')
12
+ end
13
+
14
+ Then /^I should see that a configuration file was created$/ do
15
+ config = YAML::load(File.open('tmp/.remote-terminal.yml'))
16
+ config['address'].should be == @address
17
+ config['user'].should be == @user
18
+ config['remote_directory'].should be == @dir
19
+ end
20
+
21
+ Given /^the remote computer's IP is (\d+)\.(\d+)\.(\d+)\.(\d+)$/ do |arg1, arg2, arg3, arg4|
22
+ @address = "#{arg1}.#{arg2}.#{arg3}.#{arg4}"
23
+ end
@@ -0,0 +1,16 @@
1
+ Given /^I am in the "(.*?)" directory$/ do |dir|
2
+ @dir = dir
3
+ @project = RemoteTerminal::Project.find(@dir)
4
+ end
5
+
6
+ When /^I get the path from my location$/ do
7
+ @path = @project.path_from(@dir)
8
+ end
9
+
10
+ Then /^I should see "(.*?)"$/ do |path|
11
+ @path.should be == path
12
+ end
13
+
14
+ When /^I get the path to my location$/ do
15
+ @path = @project.path_to(@dir)
16
+ end
@@ -0,0 +1,11 @@
1
+ When /^I execute "(.*?)"$/ do |cmd|
2
+ rsync = double()
3
+ rsync.should_receive(:run).twice.and_return('rsync ')
4
+ ssh = double()
5
+ ssh.should_receive(:run).and_return('ssh ')
6
+ @output = RemoteTerminal::CLI.execute(cmd, rsync, ssh, @dir)
7
+ end
8
+
9
+ Then /^I should see "(.*?)" output$/ do |path|
10
+ @output.should be == "rsync ssh rsync "
11
+ end
@@ -0,0 +1,21 @@
1
+ require 'simplecov'
2
+ SimpleCov.start do
3
+ add_filter "/features/"
4
+ add_filter "/spec/"
5
+ add_filter "/db/"
6
+ end
7
+
8
+ require 'bundler'
9
+ begin
10
+ Bundler.setup(:default, :development)
11
+ rescue Bundler::BundlerError => e
12
+ $stderr.puts e.message
13
+ $stderr.puts "Run `bundle install` to install missing gems"
14
+ exit e.status_code
15
+ end
16
+
17
+ $LOAD_PATH.unshift(File.dirname(__FILE__) + '/../../lib')
18
+ require 'remote-terminal'
19
+
20
+ require 'rspec/expectations'
21
+ require 'cucumber/rspec/doubles'
@@ -0,0 +1,38 @@
1
+ module RemoteTerminal
2
+ module CLI
3
+ def CLI.config(addr, user, remote_dir, local_dir)
4
+ config = Hash.new
5
+ config['address'] = addr
6
+ config['user'] = user
7
+ config['remote_directory'] = remote_dir
8
+ File.open(File.join(local_dir, '.remote-terminal.yml'), "w") do |f|
9
+ f.write(config.to_yaml)
10
+ end
11
+ end
12
+
13
+ def CLI.execute(cmd, rsync, ssh, path)
14
+ puts path
15
+ project = Project.find(path)
16
+ output = rsync.run(project.path_from(path), without_slash("#{project.user}@#{project.address}:#{project.remote_directory}"))
17
+ output += ssh.run("#{project.user}@#{project.address}", File.join(project.remote_directory, project.path_to(path)), cmd)
18
+ output += rsync.run(with_slash("#{project.user}@#{project.address}:#{project.remote_directory}"), project.path_from(path))
19
+ return output
20
+ end
21
+
22
+ def CLI.without_slash(path)
23
+ if path[-1] == '/'
24
+ return path[0..-2]
25
+ else
26
+ return path
27
+ end
28
+ end
29
+
30
+ def CLI.with_slash(path)
31
+ if path[-1] == '/'
32
+ return path
33
+ else
34
+ return "#{path}/"
35
+ end
36
+ end
37
+ end
38
+ end
@@ -0,0 +1,57 @@
1
+ module RemoteTerminal
2
+ class Project
3
+ attr_reader :address
4
+ attr_reader :user
5
+ attr_reader :remote_directory
6
+
7
+ def initialize(dir)
8
+ tmp = []
9
+ dir.split('/').each do |d|
10
+ if d == '..'
11
+ tmp = tmp[0..-2]
12
+ else
13
+ tmp << d
14
+ end
15
+ end
16
+ @dir = tmp.join('/')
17
+ load_config
18
+ end
19
+
20
+ def load_config
21
+ config = YAML::load(File.open(File.join(@dir, '.remote-terminal.yml')))
22
+ @address = config['address']
23
+ @user = config['user']
24
+ @remote_directory = config['remote_directory']
25
+ end
26
+
27
+ def Project.find(dir)
28
+ if File.exist?(File.join(dir, '.remote-terminal.yml'))
29
+ return Project.new(dir)
30
+ else
31
+ return Project.find(File.join(dir, '..'))
32
+ end
33
+ end
34
+
35
+ def path_from(dir)
36
+ path = ''
37
+ d = dir.gsub(@dir, '').split('/').keep_if {|d| d != ''}
38
+ if d == []
39
+ path = './'
40
+ else
41
+ d.each do |x|
42
+ path += '../'
43
+ end
44
+ end
45
+ return path[0..-2]
46
+ end
47
+
48
+ def path_to(dir)
49
+ d = dir.gsub(@dir, '').split('/').keep_if {|d| d != ''}
50
+ if d == []
51
+ return ''
52
+ else
53
+ return "#{d.join('/')}/"
54
+ end
55
+ end
56
+ end
57
+ end
@@ -0,0 +1,9 @@
1
+ module RemoteTerminal
2
+ class Rsync
3
+ def run(orig, dest)
4
+ IO.popen("rsync -raze ssh --delete #{orig} #{dest}") do |f|
5
+ return "#{f.readlines.join()}"
6
+ end
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,9 @@
1
+ module RemoteTerminal
2
+ class SSH
3
+ def run(server, remote_directory, cmd)
4
+ IO.popen("ssh #{server} 'cd #{remote_directory} && #{cmd}'") do |f|
5
+ return "#{f.readlines.join()}"
6
+ end
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,8 @@
1
+ ROOT_PATH = File.expand_path(File.dirname(__FILE__))
2
+
3
+ require 'yaml'
4
+
5
+ require File.join(ROOT_PATH, '/remote-terminal/cli')
6
+ require File.join(ROOT_PATH, '/remote-terminal/project')
7
+ require File.join(ROOT_PATH, '/remote-terminal/rsync')
8
+ require File.join(ROOT_PATH, '/remote-terminal/ssh')
@@ -0,0 +1,89 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
+ # -*- encoding: utf-8 -*-
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = "remote-terminal"
8
+ s.version = "0.1.1"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["Igor Bonadio"]
12
+ s.date = "2013-02-02"
13
+ s.description = "Remote Terminal uses SSH and RSync to help you to execute commands remotely as if you were running them locally"
14
+ s.email = "igorbonadio@gmail.com"
15
+ s.executables = ["rt", "rt-config"]
16
+ s.extra_rdoc_files = [
17
+ "LICENSE.txt",
18
+ "README.rdoc",
19
+ "TODO"
20
+ ]
21
+ s.files = [
22
+ ".document",
23
+ ".rspec",
24
+ "Gemfile",
25
+ "Gemfile.lock",
26
+ "LICENSE.txt",
27
+ "README.rdoc",
28
+ "Rakefile",
29
+ "VERSION",
30
+ "bin/rt",
31
+ "bin/rt-config",
32
+ "features/config.feature",
33
+ "features/data/project/.remote-terminal.yml",
34
+ "features/data/project/folder/make",
35
+ "features/data/project/folder/subfolder/.gitignore",
36
+ "features/data/project/make",
37
+ "features/project.feature",
38
+ "features/remote-terminal.feature",
39
+ "features/step_definitions/config_step.rb",
40
+ "features/step_definitions/project_step.rb",
41
+ "features/step_definitions/remote-terminal_step.rb",
42
+ "features/support/env.rb",
43
+ "lib/remote-terminal.rb",
44
+ "lib/remote-terminal/cli.rb",
45
+ "lib/remote-terminal/project.rb",
46
+ "lib/remote-terminal/rsync.rb",
47
+ "lib/remote-terminal/ssh.rb",
48
+ "remote-terminal.gemspec",
49
+ "spec/cli_spec.rb",
50
+ "spec/project_spec.rb",
51
+ "spec/rsync_spec.rb",
52
+ "spec/spec_helper.rb",
53
+ "spec/ssh_spec.rb",
54
+ "tmp/.gitignore"
55
+ ]
56
+ s.homepage = "http://github.com/igorbonadio/remote-terminal"
57
+ s.licenses = ["MIT"]
58
+ s.require_paths = ["lib"]
59
+ s.rubygems_version = "1.8.25"
60
+ s.summary = "Remote Terminal helps you to execute commands remotely as if you were running them locally"
61
+
62
+ if s.respond_to? :specification_version then
63
+ s.specification_version = 3
64
+
65
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
66
+ s.add_development_dependency(%q<rspec>, [">= 2.11.0"])
67
+ s.add_development_dependency(%q<rdoc>, [">= 3.12"])
68
+ s.add_development_dependency(%q<cucumber>, [">= 1.2.1"])
69
+ s.add_development_dependency(%q<bundler>, [">= 1.0.0"])
70
+ s.add_development_dependency(%q<jeweler>, [">= 1.8.4"])
71
+ s.add_development_dependency(%q<simplecov>, [">= 0.6.4"])
72
+ else
73
+ s.add_dependency(%q<rspec>, [">= 2.11.0"])
74
+ s.add_dependency(%q<rdoc>, [">= 3.12"])
75
+ s.add_dependency(%q<cucumber>, [">= 1.2.1"])
76
+ s.add_dependency(%q<bundler>, [">= 1.0.0"])
77
+ s.add_dependency(%q<jeweler>, [">= 1.8.4"])
78
+ s.add_dependency(%q<simplecov>, [">= 0.6.4"])
79
+ end
80
+ else
81
+ s.add_dependency(%q<rspec>, [">= 2.11.0"])
82
+ s.add_dependency(%q<rdoc>, [">= 3.12"])
83
+ s.add_dependency(%q<cucumber>, [">= 1.2.1"])
84
+ s.add_dependency(%q<bundler>, [">= 1.0.0"])
85
+ s.add_dependency(%q<jeweler>, [">= 1.8.4"])
86
+ s.add_dependency(%q<simplecov>, [">= 0.6.4"])
87
+ end
88
+ end
89
+
data/spec/cli_spec.rb ADDED
@@ -0,0 +1,62 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
+
3
+ module RemoteTerminal
4
+ describe CLI do
5
+ it "should configure a new remote project" do
6
+ FileUtils.rm('tmp/.remote-terminal') if Dir.exist?('tmp/.remote-terminal')
7
+ CLI.config("addr", "user", "remote_dir", "tmp")
8
+ config = YAML::load(File.open('tmp/.remote-terminal.yml'))
9
+ config['address'].should be == "addr"
10
+ config['user'].should be == "user"
11
+ config['remote_directory'].should be == "remote_dir"
12
+ end
13
+
14
+ it "should execute remote commands" do
15
+ rsync = double()
16
+ ssh = double()
17
+
18
+ rsync.should_receive(:run).
19
+ with('.', 'igorbonadio@10.210.123.4:~/Projects/MyProject').
20
+ and_return("rsync ")
21
+
22
+ ssh.should_receive(:run).
23
+ with('igorbonadio@10.210.123.4', '~/Projects/MyProject/', 'make').
24
+ and_return("rsync ")
25
+
26
+ rsync.should_receive(:run).
27
+ with('igorbonadio@10.210.123.4:~/Projects/MyProject/', '.').
28
+ and_return("rsync ")
29
+
30
+ CLI.execute('make', rsync, ssh, 'features/data/project/')
31
+ end
32
+
33
+ it "should execute remote commands in any subfolder" do
34
+ rsync = double()
35
+ ssh = double()
36
+
37
+ rsync.should_receive(:run).
38
+ with('../..', 'igorbonadio@10.210.123.4:~/Projects/MyProject').
39
+ and_return("rsync ")
40
+
41
+ ssh.should_receive(:run).
42
+ with('igorbonadio@10.210.123.4', '~/Projects/MyProject/folder/subfolder/', 'make').
43
+ and_return("rsync ")
44
+
45
+ rsync.should_receive(:run).
46
+ with('igorbonadio@10.210.123.4:~/Projects/MyProject/', '../..').
47
+ and_return("rsync ")
48
+
49
+ CLI.execute('make', rsync, ssh, 'features/data/project/folder/subfolder/')
50
+ end
51
+
52
+ it "should remove the last '/' of a path" do
53
+ CLI.without_slash('path/').should be == 'path'
54
+ CLI.without_slash('path').should be == 'path'
55
+ end
56
+
57
+ it "should put the last '/' in a path" do
58
+ CLI.with_slash('path/').should be == 'path/'
59
+ CLI.with_slash('path').should be == 'path/'
60
+ end
61
+ end
62
+ end
@@ -0,0 +1,33 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
+
3
+ module RemoteTerminal
4
+ describe Project do
5
+ it "should find and load a remote project" do
6
+ config = YAML::load(File.open('features/data/project/.remote-terminal.yml'))
7
+ project = Project.find('features/data/project')
8
+ project.address.should be == config['address']
9
+ project.user.should be == config['user']
10
+ project.remote_directory.should be == config['remote_directory']
11
+ end
12
+
13
+ it "should show a path to the local folder" do
14
+ project = Project.find('features/data/project')
15
+ project.path_to("features/data/project").should be == ""
16
+ project.path_to("features/data/project/folder").should be == "folder/"
17
+ project.path_to("features/data/project/folder/subfolder").should be == "folder/subfolder/"
18
+ project.path_to("features/data/project/").should be == ""
19
+ project.path_to("features/data/project/folder/").should be == "folder/"
20
+ project.path_to("features/data/project/folder/subfolder/").should be == "folder/subfolder/"
21
+ end
22
+
23
+ it "should show a path from the local folder" do
24
+ project = Project.find('features/data/project')
25
+ project.path_from("features/data/project").should be == "."
26
+ project.path_from("features/data/project/folder").should be == ".."
27
+ project.path_from("features/data/project/folder/subfolder").should be == "../.."
28
+ project.path_from("features/data/project/").should be == "."
29
+ project.path_from("features/data/project/folder/").should be == ".."
30
+ project.path_from("features/data/project/folder/subfolder/").should be == "../.."
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,11 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
+
3
+ module RemoteTerminal
4
+ describe Rsync do
5
+ it "should execute the rsync command" do
6
+ IO.should_receive(:popen).with("rsync -raze ssh --delete orig dest")
7
+ rsync = Rsync.new
8
+ rsync.run('orig', 'dest')
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,18 @@
1
+ require 'simplecov'
2
+ SimpleCov.start do
3
+ add_filter "/features/"
4
+ add_filter "/spec/"
5
+ end
6
+
7
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
8
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
9
+ require 'rspec'
10
+ require 'remote-terminal'
11
+
12
+ # Requires supporting files with custom matchers and macros, etc,
13
+ # in ./support/ and its subdirectories.
14
+ Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}
15
+
16
+ RSpec.configure do |config|
17
+
18
+ end
data/spec/ssh_spec.rb ADDED
@@ -0,0 +1,11 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
+
3
+ module RemoteTerminal
4
+ describe SSH do
5
+ it "should execute the ssh command" do
6
+ IO.should_receive(:popen).with("ssh server 'cd remote_directory && cmd'")
7
+ ssh = SSH.new
8
+ ssh.run('server', 'remote_directory', 'cmd')
9
+ end
10
+ end
11
+ end
data/tmp/.gitignore ADDED
@@ -0,0 +1,4 @@
1
+ # Ignore everything in this directory
2
+ *
3
+ # Except this file
4
+ !.gitignore
metadata ADDED
@@ -0,0 +1,185 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: remote-terminal
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Igor Bonadio
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2013-02-02 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: rspec
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: 2.11.0
22
+ type: :development
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: 2.11.0
30
+ - !ruby/object:Gem::Dependency
31
+ name: rdoc
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
37
+ version: '3.12'
38
+ type: :development
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '3.12'
46
+ - !ruby/object:Gem::Dependency
47
+ name: cucumber
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ! '>='
52
+ - !ruby/object:Gem::Version
53
+ version: 1.2.1
54
+ type: :development
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ! '>='
60
+ - !ruby/object:Gem::Version
61
+ version: 1.2.1
62
+ - !ruby/object:Gem::Dependency
63
+ name: bundler
64
+ requirement: !ruby/object:Gem::Requirement
65
+ none: false
66
+ requirements:
67
+ - - ! '>='
68
+ - !ruby/object:Gem::Version
69
+ version: 1.0.0
70
+ type: :development
71
+ prerelease: false
72
+ version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ! '>='
76
+ - !ruby/object:Gem::Version
77
+ version: 1.0.0
78
+ - !ruby/object:Gem::Dependency
79
+ name: jeweler
80
+ requirement: !ruby/object:Gem::Requirement
81
+ none: false
82
+ requirements:
83
+ - - ! '>='
84
+ - !ruby/object:Gem::Version
85
+ version: 1.8.4
86
+ type: :development
87
+ prerelease: false
88
+ version_requirements: !ruby/object:Gem::Requirement
89
+ none: false
90
+ requirements:
91
+ - - ! '>='
92
+ - !ruby/object:Gem::Version
93
+ version: 1.8.4
94
+ - !ruby/object:Gem::Dependency
95
+ name: simplecov
96
+ requirement: !ruby/object:Gem::Requirement
97
+ none: false
98
+ requirements:
99
+ - - ! '>='
100
+ - !ruby/object:Gem::Version
101
+ version: 0.6.4
102
+ type: :development
103
+ prerelease: false
104
+ version_requirements: !ruby/object:Gem::Requirement
105
+ none: false
106
+ requirements:
107
+ - - ! '>='
108
+ - !ruby/object:Gem::Version
109
+ version: 0.6.4
110
+ description: Remote Terminal uses SSH and RSync to help you to execute commands remotely
111
+ as if you were running them locally
112
+ email: igorbonadio@gmail.com
113
+ executables:
114
+ - rt
115
+ - rt-config
116
+ extensions: []
117
+ extra_rdoc_files:
118
+ - LICENSE.txt
119
+ - README.rdoc
120
+ - TODO
121
+ files:
122
+ - .document
123
+ - .rspec
124
+ - Gemfile
125
+ - Gemfile.lock
126
+ - LICENSE.txt
127
+ - README.rdoc
128
+ - Rakefile
129
+ - VERSION
130
+ - bin/rt
131
+ - bin/rt-config
132
+ - features/config.feature
133
+ - features/data/project/.remote-terminal.yml
134
+ - features/data/project/folder/make
135
+ - features/data/project/folder/subfolder/.gitignore
136
+ - features/data/project/make
137
+ - features/project.feature
138
+ - features/remote-terminal.feature
139
+ - features/step_definitions/config_step.rb
140
+ - features/step_definitions/project_step.rb
141
+ - features/step_definitions/remote-terminal_step.rb
142
+ - features/support/env.rb
143
+ - lib/remote-terminal.rb
144
+ - lib/remote-terminal/cli.rb
145
+ - lib/remote-terminal/project.rb
146
+ - lib/remote-terminal/rsync.rb
147
+ - lib/remote-terminal/ssh.rb
148
+ - remote-terminal.gemspec
149
+ - spec/cli_spec.rb
150
+ - spec/project_spec.rb
151
+ - spec/rsync_spec.rb
152
+ - spec/spec_helper.rb
153
+ - spec/ssh_spec.rb
154
+ - tmp/.gitignore
155
+ - TODO
156
+ homepage: http://github.com/igorbonadio/remote-terminal
157
+ licenses:
158
+ - MIT
159
+ post_install_message:
160
+ rdoc_options: []
161
+ require_paths:
162
+ - lib
163
+ required_ruby_version: !ruby/object:Gem::Requirement
164
+ none: false
165
+ requirements:
166
+ - - ! '>='
167
+ - !ruby/object:Gem::Version
168
+ version: '0'
169
+ segments:
170
+ - 0
171
+ hash: -921137321131667278
172
+ required_rubygems_version: !ruby/object:Gem::Requirement
173
+ none: false
174
+ requirements:
175
+ - - ! '>='
176
+ - !ruby/object:Gem::Version
177
+ version: '0'
178
+ requirements: []
179
+ rubyforge_project:
180
+ rubygems_version: 1.8.25
181
+ signing_key:
182
+ specification_version: 3
183
+ summary: Remote Terminal helps you to execute commands remotely as if you were running
184
+ them locally
185
+ test_files: []