From 99c4e73c3118954d37a301c95da3b5cc669d807b Mon Sep 17 00:00:00 2001 From: Martijn Heemels Date: Wed, 23 Nov 2011 16:08:57 +0100 Subject: [PATCH 01/19] Remove leftover submodule directory, which should've been removed in commit 529d6ae5f --- vendor/plugins/exception_notification | 1 - 1 file changed, 1 deletion(-) delete mode 160000 vendor/plugins/exception_notification diff --git a/vendor/plugins/exception_notification b/vendor/plugins/exception_notification deleted file mode 160000 index f9865f54b..000000000 --- a/vendor/plugins/exception_notification +++ /dev/null @@ -1 +0,0 @@ -Subproject commit f9865f54b415e4f87e582f6256a811d5c5f54d7b From ea2f9d2b6bcade6c8b8a95e8a58f597ff2e94cf8 Mon Sep 17 00:00:00 2001 From: Martijn Heemels Date: Thu, 1 Mar 2012 14:18:37 +0100 Subject: [PATCH 02/19] Add 37signals' fast_remote_cache deploy method as submodule --- .gitmodules | 3 +++ lib/fast_remote_cache | 1 + 2 files changed, 4 insertions(+) create mode 100644 .gitmodules create mode 160000 lib/fast_remote_cache diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 000000000..30591459e --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "lib/fast_remote_cache"] + path = lib/fast_remote_cache + url = https://github.com/37signals/fast_remote_cache.git diff --git a/lib/fast_remote_cache b/lib/fast_remote_cache new file mode 160000 index 000000000..6dc16b790 --- /dev/null +++ b/lib/fast_remote_cache @@ -0,0 +1 @@ +Subproject commit 6dc16b790ad3e5cc20b11e429f69b12e24e53cd1 From 37b50dfe93851ccb0bc13d6630d8846ed9361432 Mon Sep 17 00:00:00 2001 From: Brendon Rapp Date: Sat, 12 Nov 2011 11:48:37 +0800 Subject: [PATCH 03/19] Replaced dead peritor.com wiki links with valid Github wiki links --- app/views/projects/dashboard.html.erb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/views/projects/dashboard.html.erb b/app/views/projects/dashboard.html.erb index 9d406a835..123b38b04 100644 --- a/app/views/projects/dashboard.html.erb +++ b/app/views/projects/dashboard.html.erb @@ -10,9 +10,9 @@ For help and more documentation, see

Webistrano is Open Source. Paid support is available by Peritor Consulting. From 4b6dbc87b6330ad26bba9e8e43381bd024060fa6 Mon Sep 17 00:00:00 2001 From: Brendon Rapp Date: Sat, 12 Nov 2011 12:05:27 +0800 Subject: [PATCH 04/19] Replaced screenshot dead link with Github project link --- app/views/projects/dashboard.html.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/projects/dashboard.html.erb b/app/views/projects/dashboard.html.erb index 123b38b04..c149c4803 100644 --- a/app/views/projects/dashboard.html.erb +++ b/app/views/projects/dashboard.html.erb @@ -1,7 +1,7 @@
Introduction and help
Welcome to Webistrano. Your first steps should be to create a project with a stage. From 6a8b5dde8100b6547cf9129f83c9212ae3e4eb1f Mon Sep 17 00:00:00 2001 From: Alex Speller Date: Fri, 10 Jun 2011 21:29:24 +0800 Subject: [PATCH 05/19] fix namespace issue --- config/initializers/capistrano_namespace_rake_fix.rb | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/config/initializers/capistrano_namespace_rake_fix.rb b/config/initializers/capistrano_namespace_rake_fix.rb index 5f72b1599..a50d046d5 100644 --- a/config/initializers/capistrano_namespace_rake_fix.rb +++ b/config/initializers/capistrano_namespace_rake_fix.rb @@ -1,2 +1,5 @@ # see http://groups.google.com/group/capistrano/browse_thread/thread/b5e11c0ebf37a8be -Capistrano::Configuration::Namespaces::Namespace.class_eval { undef :symlink } \ No newline at end of file +Capistrano::Configuration::Namespaces::Namespace.class_eval do + undef :symlink + undef :install +end \ No newline at end of file From 0db94dbbf663e9f0ca6b729aedc7cac787a1c188 Mon Sep 17 00:00:00 2001 From: Alex Speller Date: Fri, 10 Jun 2011 21:31:17 +0800 Subject: [PATCH 06/19] Deployer shouldn't do a local query with mercurial eiter --- lib/webistrano/deployer.rb | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/webistrano/deployer.rb b/lib/webistrano/deployer.rb index 327ef6945..b6d4b66ce 100644 --- a/lib/webistrano/deployer.rb +++ b/lib/webistrano/deployer.rb @@ -63,8 +63,12 @@ def execute! set_webistrano_logger(config) set_up_config(config) - - exchange_real_revision(config) unless (config.fetch(:scm).to_s == 'git') # git cannot do a local query by default + + # git and mercurial cannot do a local query by default + unless %w(git mercurial).include? config.fetch(:scm).to_s + exchange_real_revision(config) + end + save_revision(config) save_pid From 26aeeee191089e6091c157d07fd7cc3d629653a5 Mon Sep 17 00:00:00 2001 From: Alex Speller Date: Thu, 9 Jun 2011 21:44:14 +0800 Subject: [PATCH 07/19] Fix bug with private method being called --- lib/webistrano/deployer.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/webistrano/deployer.rb b/lib/webistrano/deployer.rb index b6d4b66ce..bb9e28f17 100644 --- a/lib/webistrano/deployer.rb +++ b/lib/webistrano/deployer.rb @@ -22,7 +22,7 @@ def initialize(deployment) @deployment = deployment - if(@deployment.task && !@deployment.new_record?) + if(@deployment.send(:task) && !@deployment.new_record?) # a read deployment @logger = Webistrano::Logger.new(deployment) @logger.level = Webistrano::Logger::TRACE From cd80efc303ebc9a7437237313fbf5c1cd3e2d329 Mon Sep 17 00:00:00 2001 From: Martijn Heemels Date: Thu, 1 Mar 2012 16:34:40 +0100 Subject: [PATCH 08/19] Add autogenerated application.css to .gitignore --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 08a043ec2..30d976aed 100644 --- a/.gitignore +++ b/.gitignore @@ -6,3 +6,4 @@ log/* .DS_Store *.tmproj Gemfile.lock +public/stylesheets/application.css From 2c77545953aeef3f25a6c77120dcd37276569af6 Mon Sep 17 00:00:00 2001 From: Martijn Heemels Date: Fri, 2 Mar 2012 17:47:54 +0100 Subject: [PATCH 09/19] Remove submodule from incorrect location --- .gitmodules | 4 ++-- lib/fast_remote_cache | 1 - 2 files changed, 2 insertions(+), 3 deletions(-) delete mode 160000 lib/fast_remote_cache diff --git a/.gitmodules b/.gitmodules index 30591459e..bc7679d05 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,3 +1,3 @@ -[submodule "lib/fast_remote_cache"] - path = lib/fast_remote_cache +[submodule "fast_remote_cache"] + path = vendor/plugins/fast_remote_cache url = https://github.com/37signals/fast_remote_cache.git diff --git a/lib/fast_remote_cache b/lib/fast_remote_cache deleted file mode 160000 index 6dc16b790..000000000 --- a/lib/fast_remote_cache +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 6dc16b790ad3e5cc20b11e429f69b12e24e53cd1 From ca454746d7df582d63a7456c192817bf1dff3cee Mon Sep 17 00:00:00 2001 From: Martijn Heemels Date: Fri, 2 Mar 2012 18:09:22 +0100 Subject: [PATCH 10/19] Recreate fast_remote_cache submodule in correct path --- .gitmodules | 2 +- vendor/plugins/fast_remote_cache | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) create mode 160000 vendor/plugins/fast_remote_cache diff --git a/.gitmodules b/.gitmodules index bc7679d05..ec9d597f8 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,3 +1,3 @@ -[submodule "fast_remote_cache"] +[submodule "vendor/plugins/fast_remote_cache"] path = vendor/plugins/fast_remote_cache url = https://github.com/37signals/fast_remote_cache.git diff --git a/vendor/plugins/fast_remote_cache b/vendor/plugins/fast_remote_cache new file mode 160000 index 000000000..6dc16b790 --- /dev/null +++ b/vendor/plugins/fast_remote_cache @@ -0,0 +1 @@ +Subproject commit 6dc16b790ad3e5cc20b11e429f69b12e24e53cd1 From 576010691b1739c767c9dcf19117022e60e9d6ef Mon Sep 17 00:00:00 2001 From: Martijn Heemels Date: Tue, 6 Mar 2012 11:34:40 +0100 Subject: [PATCH 11/19] Disallow access to spiders --- public/robots.txt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/public/robots.txt b/public/robots.txt index 4ab9e89fe..1f53798bb 100644 --- a/public/robots.txt +++ b/public/robots.txt @@ -1 +1,2 @@ -# See http://www.robotstxt.org/wc/norobots.html for documentation on how to use the robots.txt file \ No newline at end of file +User-agent: * +Disallow: / From 123ba8c5c5f4e4acf9753b642da57ee538641170 Mon Sep 17 00:00:00 2001 From: Martijn Heemels Date: Tue, 6 Mar 2012 14:34:07 +0100 Subject: [PATCH 12/19] Add submodule for encrypted_copy deployment strategy --- .gitmodules | 3 +++ vendor/plugins/encrypted_copy | 1 + 2 files changed, 4 insertions(+) create mode 160000 vendor/plugins/encrypted_copy diff --git a/.gitmodules b/.gitmodules index ec9d597f8..c9d82e4f7 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,3 +1,6 @@ [submodule "vendor/plugins/fast_remote_cache"] path = vendor/plugins/fast_remote_cache url = https://github.com/37signals/fast_remote_cache.git +[submodule "vendor/plugins/encrypted_copy"] + path = vendor/plugins/encrypted_copy + url = git://github.com/Yggdrasil/cap_encrypted_copy.git diff --git a/vendor/plugins/encrypted_copy b/vendor/plugins/encrypted_copy new file mode 160000 index 000000000..a5266112d --- /dev/null +++ b/vendor/plugins/encrypted_copy @@ -0,0 +1 @@ +Subproject commit a5266112da7f0bb8bf42a4d80af1ab849b8374e8 From a6c52dc151584351758653228bc5a7c9a8c6c95b Mon Sep 17 00:00:00 2001 From: Martijn Heemels Date: Tue, 6 Mar 2012 15:42:03 +0100 Subject: [PATCH 13/19] Update encrypted_copy submodule for compatibility with Capistrano 2.6 --- vendor/plugins/encrypted_copy | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vendor/plugins/encrypted_copy b/vendor/plugins/encrypted_copy index a5266112d..1775e3005 160000 --- a/vendor/plugins/encrypted_copy +++ b/vendor/plugins/encrypted_copy @@ -1 +1 @@ -Subproject commit a5266112da7f0bb8bf42a4d80af1ab849b8374e8 +Subproject commit 1775e300585d56cfbcedd7e7bac47f44c4e8d2c6 From 155ce39e1429c1d86ad7ea1d8260329169499fdc Mon Sep 17 00:00:00 2001 From: Martijn Heemels Date: Tue, 6 Mar 2012 15:52:52 +0100 Subject: [PATCH 14/19] Remove old frozen gems, due to switch to Bundler --- vendor/gems/capistrano-2.5.9/.specification | 312 ---- vendor/gems/capistrano-2.5.9/CHANGELOG.rdoc | 791 -------- vendor/gems/capistrano-2.5.9/Manifest | 104 -- vendor/gems/capistrano-2.5.9/README.rdoc | 102 -- vendor/gems/capistrano-2.5.9/Rakefile | 35 - vendor/gems/capistrano-2.5.9/bin/cap | 4 - vendor/gems/capistrano-2.5.9/bin/capify | 86 - .../gems/capistrano-2.5.9/capistrano.gemspec | 48 - .../gems/capistrano-2.5.9/examples/sample.rb | 14 - .../gems/capistrano-2.5.9/lib/capistrano.rb | 2 - .../lib/capistrano/callback.rb | 45 - .../capistrano-2.5.9/lib/capistrano/cli.rb | 47 - .../lib/capistrano/cli/execute.rb | 84 - .../lib/capistrano/cli/help.rb | 125 -- .../lib/capistrano/cli/help.txt | 78 - .../lib/capistrano/cli/options.rb | 239 --- .../capistrano-2.5.9/lib/capistrano/cli/ui.rb | 40 - .../lib/capistrano/command.rb | 283 --- .../lib/capistrano/configuration.rb | 43 - .../configuration/actions/file_transfer.rb | 47 - .../configuration/actions/inspect.rb | 46 - .../configuration/actions/invocation.rb | 293 --- .../lib/capistrano/configuration/callbacks.rb | 148 -- .../capistrano/configuration/connections.rb | 204 --- .../lib/capistrano/configuration/execution.rb | 143 -- .../lib/capistrano/configuration/loading.rb | 197 -- .../capistrano/configuration/namespaces.rb | 197 -- .../lib/capistrano/configuration/roles.rb | 73 - .../lib/capistrano/configuration/servers.rb | 96 - .../lib/capistrano/configuration/variables.rb | 127 -- .../capistrano-2.5.9/lib/capistrano/errors.rb | 15 - .../lib/capistrano/extensions.rb | 57 - .../capistrano-2.5.9/lib/capistrano/logger.rb | 59 - .../lib/capistrano/processable.rb | 53 - .../lib/capistrano/recipes/compat.rb | 32 - .../lib/capistrano/recipes/deploy.rb | 591 ------ .../capistrano/recipes/deploy/dependencies.rb | 44 - .../recipes/deploy/local_dependency.rb | 54 - .../recipes/deploy/remote_dependency.rb | 105 -- .../lib/capistrano/recipes/deploy/scm.rb | 19 - .../capistrano/recipes/deploy/scm/accurev.rb | 169 -- .../lib/capistrano/recipes/deploy/scm/base.rb | 196 -- .../lib/capistrano/recipes/deploy/scm/bzr.rb | 83 - .../lib/capistrano/recipes/deploy/scm/cvs.rb | 152 -- .../capistrano/recipes/deploy/scm/darcs.rb | 85 - .../lib/capistrano/recipes/deploy/scm/git.rb | 278 --- .../recipes/deploy/scm/mercurial.rb | 137 -- .../lib/capistrano/recipes/deploy/scm/none.rb | 44 - .../capistrano/recipes/deploy/scm/perforce.rb | 138 -- .../recipes/deploy/scm/subversion.rb | 121 -- .../lib/capistrano/recipes/deploy/strategy.rb | 19 - .../recipes/deploy/strategy/base.rb | 79 - .../recipes/deploy/strategy/checkout.rb | 20 - .../recipes/deploy/strategy/copy.rb | 213 --- .../recipes/deploy/strategy/export.rb | 20 - .../recipes/deploy/strategy/remote.rb | 52 - .../recipes/deploy/strategy/remote_cache.rb | 56 - .../deploy/templates/maintenance.rhtml | 53 - .../lib/capistrano/recipes/standard.rb | 37 - .../recipes/templates/maintenance.rhtml | 53 - .../lib/capistrano/recipes/upgrade.rb | 33 - .../capistrano-2.5.9/lib/capistrano/role.rb | 102 -- .../lib/capistrano/server_definition.rb | 56 - .../capistrano-2.5.9/lib/capistrano/shell.rb | 260 --- .../capistrano-2.5.9/lib/capistrano/ssh.rb | 99 - .../lib/capistrano/task_definition.rb | 70 - .../lib/capistrano/transfer.rb | 216 --- .../lib/capistrano/version.rb | 18 - vendor/gems/capistrano-2.5.9/setup.rb | 1346 -------------- .../capistrano-2.5.9/test/cli/execute_test.rb | 132 -- .../capistrano-2.5.9/test/cli/help_test.rb | 165 -- .../capistrano-2.5.9/test/cli/options_test.rb | 317 ---- .../gems/capistrano-2.5.9/test/cli/ui_test.rb | 28 - vendor/gems/capistrano-2.5.9/test/cli_test.rb | 17 - .../capistrano-2.5.9/test/command_test.rb | 286 --- .../actions/file_transfer_test.rb | 61 - .../configuration/actions/inspect_test.rb | 65 - .../configuration/actions/invocation_test.rb | 224 --- .../test/configuration/callbacks_test.rb | 220 --- .../test/configuration/connections_test.rb | 349 ---- .../test/configuration/execution_test.rb | 175 -- .../test/configuration/loading_test.rb | 132 -- .../test/configuration/namespace_dsl_test.rb | 311 ---- .../test/configuration/roles_test.rb | 144 -- .../test/configuration/servers_test.rb | 129 -- .../test/configuration/variables_test.rb | 184 -- .../test/configuration_test.rb | 88 - .../test/deploy/local_dependency_test.rb | 76 - .../test/deploy/remote_dependency_test.rb | 114 -- .../test/deploy/scm/accurev_test.rb | 23 - .../test/deploy/scm/base_test.rb | 55 - .../test/deploy/scm/git_test.rb | 184 -- .../test/deploy/scm/mercurial_test.rb | 134 -- .../test/deploy/scm/none_test.rb | 35 - .../test/deploy/scm/subversion_test.rb | 32 - .../test/deploy/strategy/copy_test.rb | 302 ---- .../capistrano-2.5.9/test/extensions_test.rb | 69 - .../test/fixtures/cli_integration.rb | 5 - .../capistrano-2.5.9/test/fixtures/config.rb | 5 - .../capistrano-2.5.9/test/fixtures/custom.rb | 3 - .../gems/capistrano-2.5.9/test/logger_test.rb | 123 -- .../gems/capistrano-2.5.9/test/role_test.rb | 11 - .../test/server_definition_test.rb | 121 -- .../gems/capistrano-2.5.9/test/shell_test.rb | 90 - vendor/gems/capistrano-2.5.9/test/ssh_test.rb | 104 -- .../test/task_definition_test.rb | 101 -- .../capistrano-2.5.9/test/transfer_test.rb | 160 -- vendor/gems/capistrano-2.5.9/test/utils.rb | 38 - vendor/gems/highline-1.5.1/.specification | 91 - vendor/gems/highline-1.5.1/CHANGELOG | 222 --- vendor/gems/highline-1.5.1/INSTALL | 35 - vendor/gems/highline-1.5.1/LICENSE | 7 - vendor/gems/highline-1.5.1/README | 63 - vendor/gems/highline-1.5.1/Rakefile | 82 - vendor/gems/highline-1.5.1/TODO | 6 - .../highline-1.5.1/examples/ansi_colors.rb | 38 - .../examples/asking_for_arrays.rb | 18 - .../highline-1.5.1/examples/basic_usage.rb | 75 - .../highline-1.5.1/examples/color_scheme.rb | 32 - vendor/gems/highline-1.5.1/examples/limit.rb | 12 - vendor/gems/highline-1.5.1/examples/menus.rb | 65 - .../gems/highline-1.5.1/examples/overwrite.rb | 19 - .../highline-1.5.1/examples/page_and_wrap.rb | 322 ---- .../gems/highline-1.5.1/examples/password.rb | 7 - .../highline-1.5.1/examples/trapping_eof.rb | 22 - .../highline-1.5.1/examples/using_readline.rb | 17 - vendor/gems/highline-1.5.1/lib/highline.rb | 758 -------- .../lib/highline/color_scheme.rb | 120 -- .../lib/highline/compatibility.rb | 17 - .../highline-1.5.1/lib/highline/import.rb | 43 - .../gems/highline-1.5.1/lib/highline/menu.rb | 395 ---- .../highline-1.5.1/lib/highline/question.rb | 463 ----- .../lib/highline/system_extensions.rb | 193 -- vendor/gems/highline-1.5.1/setup.rb | 1360 -------------- .../highline-1.5.1/test/tc_color_scheme.rb | 56 - .../gems/highline-1.5.1/test/tc_highline.rb | 823 --------- vendor/gems/highline-1.5.1/test/tc_import.rb | 54 - vendor/gems/highline-1.5.1/test/tc_menu.rb | 429 ----- vendor/gems/highline-1.5.1/test/ts_all.rb | 15 - vendor/gems/net-scp-1.0.2/.specification | 104 -- vendor/gems/net-scp-1.0.2/CHANGELOG.rdoc | 18 - vendor/gems/net-scp-1.0.2/Manifest | 17 - vendor/gems/net-scp-1.0.2/README.rdoc | 98 - vendor/gems/net-scp-1.0.2/Rakefile | 30 - vendor/gems/net-scp-1.0.2/lib/net/scp.rb | 414 ----- .../net-scp-1.0.2/lib/net/scp/download.rb | 150 -- .../gems/net-scp-1.0.2/lib/net/scp/errors.rb | 5 - .../gems/net-scp-1.0.2/lib/net/scp/upload.rb | 142 -- .../gems/net-scp-1.0.2/lib/net/scp/version.rb | 18 - vendor/gems/net-scp-1.0.2/lib/uri/open-scp.rb | 18 - vendor/gems/net-scp-1.0.2/lib/uri/scp.rb | 35 - vendor/gems/net-scp-1.0.2/net-scp.gemspec | 36 - vendor/gems/net-scp-1.0.2/setup.rb | 1331 -------------- vendor/gems/net-scp-1.0.2/test/common.rb | 138 -- vendor/gems/net-scp-1.0.2/test/test_all.rb | 3 - .../gems/net-scp-1.0.2/test/test_download.rb | 156 -- vendor/gems/net-scp-1.0.2/test/test_scp.rb | 60 - vendor/gems/net-scp-1.0.2/test/test_upload.rb | 255 --- vendor/gems/net-sftp-2.0.2/.specification | 161 -- vendor/gems/net-sftp-2.0.2/CHANGELOG.rdoc | 33 - vendor/gems/net-sftp-2.0.2/Manifest | 55 - vendor/gems/net-sftp-2.0.2/README.rdoc | 96 - vendor/gems/net-sftp-2.0.2/Rakefile | 30 - vendor/gems/net-sftp-2.0.2/lib/net/sftp.rb | 70 - .../net-sftp-2.0.2/lib/net/sftp/constants.rb | 187 -- .../net-sftp-2.0.2/lib/net/sftp/errors.rb | 39 - .../lib/net/sftp/operations/dir.rb | 93 - .../lib/net/sftp/operations/download.rb | 364 ---- .../lib/net/sftp/operations/file.rb | 176 -- .../lib/net/sftp/operations/file_factory.rb | 60 - .../lib/net/sftp/operations/upload.rb | 387 ---- .../net-sftp-2.0.2/lib/net/sftp/packet.rb | 21 - .../net-sftp-2.0.2/lib/net/sftp/protocol.rb | 32 - .../lib/net/sftp/protocol/01/attributes.rb | 315 ---- .../lib/net/sftp/protocol/01/base.rb | 268 --- .../lib/net/sftp/protocol/01/name.rb | 43 - .../lib/net/sftp/protocol/02/base.rb | 31 - .../lib/net/sftp/protocol/03/base.rb | 35 - .../lib/net/sftp/protocol/04/attributes.rb | 152 -- .../lib/net/sftp/protocol/04/base.rb | 94 - .../lib/net/sftp/protocol/04/name.rb | 67 - .../lib/net/sftp/protocol/05/base.rb | 66 - .../lib/net/sftp/protocol/06/attributes.rb | 107 -- .../lib/net/sftp/protocol/06/base.rb | 63 - .../lib/net/sftp/protocol/base.rb | 50 - .../net-sftp-2.0.2/lib/net/sftp/request.rb | 91 - .../net-sftp-2.0.2/lib/net/sftp/response.rb | 76 - .../net-sftp-2.0.2/lib/net/sftp/session.rb | 951 ---------- .../net-sftp-2.0.2/lib/net/sftp/version.rb | 18 - vendor/gems/net-sftp-2.0.2/net-sftp.gemspec | 36 - vendor/gems/net-sftp-2.0.2/setup.rb | 1331 -------------- vendor/gems/net-sftp-2.0.2/test/common.rb | 171 -- .../test/protocol/01/test_attributes.rb | 97 - .../test/protocol/01/test_base.rb | 210 --- .../test/protocol/01/test_name.rb | 27 - .../test/protocol/02/test_base.rb | 26 - .../test/protocol/03/test_base.rb | 27 - .../test/protocol/04/test_attributes.rb | 148 -- .../test/protocol/04/test_base.rb | 74 - .../test/protocol/04/test_name.rb | 53 - .../test/protocol/05/test_base.rb | 62 - .../test/protocol/06/test_attributes.rb | 124 -- .../test/protocol/06/test_base.rb | 51 - .../net-sftp-2.0.2/test/protocol/test_base.rb | 42 - vendor/gems/net-sftp-2.0.2/test/test_all.rb | 3 - vendor/gems/net-sftp-2.0.2/test/test_dir.rb | 47 - .../gems/net-sftp-2.0.2/test/test_download.rb | 252 --- vendor/gems/net-sftp-2.0.2/test/test_file.rb | 159 -- .../net-sftp-2.0.2/test/test_file_factory.rb | 48 - .../gems/net-sftp-2.0.2/test/test_packet.rb | 9 - .../gems/net-sftp-2.0.2/test/test_protocol.rb | 17 - .../gems/net-sftp-2.0.2/test/test_request.rb | 71 - .../gems/net-sftp-2.0.2/test/test_response.rb | 53 - .../gems/net-sftp-2.0.2/test/test_session.rb | 741 -------- .../gems/net-sftp-2.0.2/test/test_upload.rb | 219 --- vendor/gems/net-ssh-2.0.15/.specification | 170 -- vendor/gems/net-ssh-2.0.15/CHANGELOG.rdoc | 161 -- vendor/gems/net-ssh-2.0.15/Manifest | 107 -- vendor/gems/net-ssh-2.0.15/README.rdoc | 140 -- vendor/gems/net-ssh-2.0.15/Rakefile | 79 - vendor/gems/net-ssh-2.0.15/Rudyfile | 110 -- vendor/gems/net-ssh-2.0.15/THANKS.rdoc | 16 - vendor/gems/net-ssh-2.0.15/lib/net/ssh.rb | 215 --- .../lib/net/ssh/authentication/agent.rb | 176 -- .../lib/net/ssh/authentication/constants.rb | 18 - .../lib/net/ssh/authentication/key_manager.rb | 193 -- .../ssh/authentication/methods/abstract.rb | 60 - .../ssh/authentication/methods/hostbased.rb | 71 - .../methods/keyboard_interactive.rb | 66 - .../ssh/authentication/methods/password.rb | 39 - .../ssh/authentication/methods/publickey.rb | 92 - .../lib/net/ssh/authentication/pageant.rb | 183 -- .../lib/net/ssh/authentication/session.rb | 134 -- .../gems/net-ssh-2.0.15/lib/net/ssh/buffer.rb | 340 ---- .../net-ssh-2.0.15/lib/net/ssh/buffered_io.rb | 150 -- .../gems/net-ssh-2.0.15/lib/net/ssh/config.rb | 185 -- .../lib/net/ssh/connection/channel.rb | 625 ------- .../lib/net/ssh/connection/constants.rb | 33 - .../lib/net/ssh/connection/session.rb | 597 ------- .../lib/net/ssh/connection/term.rb | 178 -- .../gems/net-ssh-2.0.15/lib/net/ssh/errors.rb | 85 - .../net-ssh-2.0.15/lib/net/ssh/key_factory.rb | 102 -- .../net-ssh-2.0.15/lib/net/ssh/known_hosts.rb | 129 -- .../net-ssh-2.0.15/lib/net/ssh/loggable.rb | 61 - .../gems/net-ssh-2.0.15/lib/net/ssh/packet.rb | 102 -- .../gems/net-ssh-2.0.15/lib/net/ssh/prompt.rb | 93 - .../lib/net/ssh/proxy/errors.rb | 14 - .../net-ssh-2.0.15/lib/net/ssh/proxy/http.rb | 94 - .../lib/net/ssh/proxy/socks4.rb | 70 - .../lib/net/ssh/proxy/socks5.rb | 142 -- .../net-ssh-2.0.15/lib/net/ssh/ruby_compat.rb | 43 - .../lib/net/ssh/service/forward.rb | 267 --- .../gems/net-ssh-2.0.15/lib/net/ssh/test.rb | 89 - .../lib/net/ssh/test/channel.rb | 129 -- .../lib/net/ssh/test/extensions.rb | 152 -- .../net-ssh-2.0.15/lib/net/ssh/test/kex.rb | 44 - .../lib/net/ssh/test/local_packet.rb | 51 - .../net-ssh-2.0.15/lib/net/ssh/test/packet.rb | 81 - .../lib/net/ssh/test/remote_packet.rb | 38 - .../net-ssh-2.0.15/lib/net/ssh/test/script.rb | 157 -- .../net-ssh-2.0.15/lib/net/ssh/test/socket.rb | 59 - .../lib/net/ssh/transport/algorithms.rb | 384 ---- .../lib/net/ssh/transport/cipher_factory.rb | 97 - .../lib/net/ssh/transport/constants.rb | 30 - .../lib/net/ssh/transport/hmac.rb | 31 - .../lib/net/ssh/transport/hmac/abstract.rb | 79 - .../lib/net/ssh/transport/hmac/md5.rb | 12 - .../lib/net/ssh/transport/hmac/md5_96.rb | 11 - .../lib/net/ssh/transport/hmac/none.rb | 15 - .../lib/net/ssh/transport/hmac/sha1.rb | 13 - .../lib/net/ssh/transport/hmac/sha1_96.rb | 11 - .../lib/net/ssh/transport/identity_cipher.rb | 55 - .../lib/net/ssh/transport/kex.rb | 13 - .../kex/diffie_hellman_group1_sha1.rb | 208 --- .../kex/diffie_hellman_group_exchange_sha1.rb | 77 - .../lib/net/ssh/transport/openssl.rb | 128 -- .../lib/net/ssh/transport/packet_stream.rb | 232 --- .../lib/net/ssh/transport/server_version.rb | 70 - .../lib/net/ssh/transport/session.rb | 276 --- .../lib/net/ssh/transport/state.rb | 206 --- .../lib/net/ssh/verifiers/lenient.rb | 30 - .../lib/net/ssh/verifiers/null.rb | 12 - .../lib/net/ssh/verifiers/strict.rb | 53 - .../net-ssh-2.0.15/lib/net/ssh/version.rb | 62 - vendor/gems/net-ssh-2.0.15/net-ssh.gemspec | 131 -- vendor/gems/net-ssh-2.0.15/setup.rb | 1585 ----------------- .../net-ssh-2.0.15/support/arcfour_check.rb | 20 - .../test/authentication/methods/common.rb | 28 - .../authentication/methods/test_abstract.rb | 51 - .../authentication/methods/test_hostbased.rb | 114 -- .../methods/test_keyboard_interactive.rb | 98 - .../authentication/methods/test_password.rb | 50 - .../authentication/methods/test_publickey.rb | 127 -- .../test/authentication/test_agent.rb | 205 --- .../test/authentication/test_key_manager.rb | 105 -- .../test/authentication/test_session.rb | 93 - vendor/gems/net-ssh-2.0.15/test/common.rb | 107 -- .../gems/net-ssh-2.0.15/test/configs/eqsign | 3 - .../net-ssh-2.0.15/test/configs/exact_match | 8 - .../net-ssh-2.0.15/test/configs/multihost | 4 - .../net-ssh-2.0.15/test/configs/wild_cards | 14 - .../test/connection/test_channel.rb | 452 ----- .../test/connection/test_session.rb | 488 ----- vendor/gems/net-ssh-2.0.15/test/test_all.rb | 8 - .../gems/net-ssh-2.0.15/test/test_buffer.rb | 336 ---- .../net-ssh-2.0.15/test/test_buffered_io.rb | 63 - .../gems/net-ssh-2.0.15/test/test_config.rb | 99 - .../net-ssh-2.0.15/test/test_key_factory.rb | 67 - .../test/transport/hmac/test_md5.rb | 39 - .../test/transport/hmac/test_md5_96.rb | 25 - .../test/transport/hmac/test_none.rb | 34 - .../test/transport/hmac/test_sha1.rb | 34 - .../test/transport/hmac/test_sha1_96.rb | 25 - .../kex/test_diffie_hellman_group1_sha1.rb | 146 -- ...test_diffie_hellman_group_exchange_sha1.rb | 92 - .../test/transport/test_algorithms.rb | 302 ---- .../test/transport/test_cipher_factory.rb | 213 --- .../test/transport/test_hmac.rb | 34 - .../test/transport/test_identity_cipher.rb | 40 - .../test/transport/test_packet_stream.rb | 441 ----- .../test/transport/test_server_version.rb | 68 - .../test/transport/test_session.rb | 315 ---- .../test/transport/test_state.rb | 173 -- .../gems/net-ssh-gateway-1.0.1/.specification | 88 - .../gems/net-ssh-gateway-1.0.1/CHANGELOG.rdoc | 11 - vendor/gems/net-ssh-gateway-1.0.1/Manifest | 7 - vendor/gems/net-ssh-gateway-1.0.1/README.rdoc | 70 - vendor/gems/net-ssh-gateway-1.0.1/Rakefile | 28 - .../lib/net/ssh/gateway.rb | 208 --- .../net-ssh-gateway.gemspec | 36 - vendor/gems/net-ssh-gateway-1.0.1/setup.rb | 1585 ----------------- .../test/gateway_test.rb | 122 -- vendor/gems/open4-0.9.3/.specification | 68 - vendor/gems/open4-0.9.3/README | 347 ---- vendor/gems/open4-0.9.3/gemspec.rb | 23 - vendor/gems/open4-0.9.3/install.rb | 201 --- vendor/gems/open4-0.9.3/lib/open4-0.9.3.rb | 381 ---- vendor/gems/open4-0.9.3/lib/open4.rb | 381 ---- vendor/gems/open4-0.9.3/open4-0.9.3.gem | 0 vendor/gems/open4-0.9.3/sample/bg.rb | 21 - vendor/gems/open4-0.9.3/sample/block.rb | 19 - vendor/gems/open4-0.9.3/sample/exception.rb | 3 - vendor/gems/open4-0.9.3/sample/simple.rb | 15 - vendor/gems/open4-0.9.3/sample/spawn.rb | 16 - .../gems/open4-0.9.3/sample/stdin_timeout.rb | 9 - vendor/gems/open4-0.9.3/sample/timeout.rb | 37 - vendor/gems/open4-0.9.3/white_box/leak.rb | 17 - vendor/gems/syntax-1.0.0/.specification | 72 - vendor/gems/syntax-1.0.0/data/ruby.css | 18 - vendor/gems/syntax-1.0.0/data/xml.css | 8 - vendor/gems/syntax-1.0.0/data/yaml.css | 12 - vendor/gems/syntax-1.0.0/lib/syntax.rb | 38 - vendor/gems/syntax-1.0.0/lib/syntax/common.rb | 163 -- .../lib/syntax/convertors/abstract.rb | 27 - .../lib/syntax/convertors/html.rb | 51 - .../gems/syntax-1.0.0/lib/syntax/lang/ruby.rb | 317 ---- .../gems/syntax-1.0.0/lib/syntax/lang/xml.rb | 108 -- .../gems/syntax-1.0.0/lib/syntax/lang/yaml.rb | 105 -- .../gems/syntax-1.0.0/lib/syntax/version.rb | 9 - vendor/gems/syntax-1.0.0/test/ALL-TESTS.rb | 5 - .../gems/syntax-1.0.0/test/syntax/tc_ruby.rb | 871 --------- .../gems/syntax-1.0.0/test/syntax/tc_xml.rb | 202 --- .../gems/syntax-1.0.0/test/syntax/tc_yaml.rb | 228 --- .../test/syntax/tokenizer_testcase.rb | 40 - vendor/gems/syntax-1.0.0/test/tc_syntax.rb | 22 - 365 files changed, 51786 deletions(-) delete mode 100644 vendor/gems/capistrano-2.5.9/.specification delete mode 100644 vendor/gems/capistrano-2.5.9/CHANGELOG.rdoc delete mode 100644 vendor/gems/capistrano-2.5.9/Manifest delete mode 100644 vendor/gems/capistrano-2.5.9/README.rdoc delete mode 100644 vendor/gems/capistrano-2.5.9/Rakefile delete mode 100755 vendor/gems/capistrano-2.5.9/bin/cap delete mode 100755 vendor/gems/capistrano-2.5.9/bin/capify delete mode 100644 vendor/gems/capistrano-2.5.9/capistrano.gemspec delete mode 100644 vendor/gems/capistrano-2.5.9/examples/sample.rb delete mode 100644 vendor/gems/capistrano-2.5.9/lib/capistrano.rb delete mode 100644 vendor/gems/capistrano-2.5.9/lib/capistrano/callback.rb delete mode 100644 vendor/gems/capistrano-2.5.9/lib/capistrano/cli.rb delete mode 100644 vendor/gems/capistrano-2.5.9/lib/capistrano/cli/execute.rb delete mode 100644 vendor/gems/capistrano-2.5.9/lib/capistrano/cli/help.rb delete mode 100644 vendor/gems/capistrano-2.5.9/lib/capistrano/cli/help.txt delete mode 100644 vendor/gems/capistrano-2.5.9/lib/capistrano/cli/options.rb delete mode 100644 vendor/gems/capistrano-2.5.9/lib/capistrano/cli/ui.rb delete mode 100644 vendor/gems/capistrano-2.5.9/lib/capistrano/command.rb delete mode 100644 vendor/gems/capistrano-2.5.9/lib/capistrano/configuration.rb delete mode 100644 vendor/gems/capistrano-2.5.9/lib/capistrano/configuration/actions/file_transfer.rb delete mode 100644 vendor/gems/capistrano-2.5.9/lib/capistrano/configuration/actions/inspect.rb delete mode 100644 vendor/gems/capistrano-2.5.9/lib/capistrano/configuration/actions/invocation.rb delete mode 100644 vendor/gems/capistrano-2.5.9/lib/capistrano/configuration/callbacks.rb delete mode 100644 vendor/gems/capistrano-2.5.9/lib/capistrano/configuration/connections.rb delete mode 100644 vendor/gems/capistrano-2.5.9/lib/capistrano/configuration/execution.rb delete mode 100644 vendor/gems/capistrano-2.5.9/lib/capistrano/configuration/loading.rb delete mode 100644 vendor/gems/capistrano-2.5.9/lib/capistrano/configuration/namespaces.rb delete mode 100644 vendor/gems/capistrano-2.5.9/lib/capistrano/configuration/roles.rb delete mode 100644 vendor/gems/capistrano-2.5.9/lib/capistrano/configuration/servers.rb delete mode 100644 vendor/gems/capistrano-2.5.9/lib/capistrano/configuration/variables.rb delete mode 100644 vendor/gems/capistrano-2.5.9/lib/capistrano/errors.rb delete mode 100644 vendor/gems/capistrano-2.5.9/lib/capistrano/extensions.rb delete mode 100644 vendor/gems/capistrano-2.5.9/lib/capistrano/logger.rb delete mode 100644 vendor/gems/capistrano-2.5.9/lib/capistrano/processable.rb delete mode 100644 vendor/gems/capistrano-2.5.9/lib/capistrano/recipes/compat.rb delete mode 100644 vendor/gems/capistrano-2.5.9/lib/capistrano/recipes/deploy.rb delete mode 100644 vendor/gems/capistrano-2.5.9/lib/capistrano/recipes/deploy/dependencies.rb delete mode 100644 vendor/gems/capistrano-2.5.9/lib/capistrano/recipes/deploy/local_dependency.rb delete mode 100644 vendor/gems/capistrano-2.5.9/lib/capistrano/recipes/deploy/remote_dependency.rb delete mode 100644 vendor/gems/capistrano-2.5.9/lib/capistrano/recipes/deploy/scm.rb delete mode 100644 vendor/gems/capistrano-2.5.9/lib/capistrano/recipes/deploy/scm/accurev.rb delete mode 100644 vendor/gems/capistrano-2.5.9/lib/capistrano/recipes/deploy/scm/base.rb delete mode 100644 vendor/gems/capistrano-2.5.9/lib/capistrano/recipes/deploy/scm/bzr.rb delete mode 100644 vendor/gems/capistrano-2.5.9/lib/capistrano/recipes/deploy/scm/cvs.rb delete mode 100644 vendor/gems/capistrano-2.5.9/lib/capistrano/recipes/deploy/scm/darcs.rb delete mode 100644 vendor/gems/capistrano-2.5.9/lib/capistrano/recipes/deploy/scm/git.rb delete mode 100644 vendor/gems/capistrano-2.5.9/lib/capistrano/recipes/deploy/scm/mercurial.rb delete mode 100644 vendor/gems/capistrano-2.5.9/lib/capistrano/recipes/deploy/scm/none.rb delete mode 100644 vendor/gems/capistrano-2.5.9/lib/capistrano/recipes/deploy/scm/perforce.rb delete mode 100644 vendor/gems/capistrano-2.5.9/lib/capistrano/recipes/deploy/scm/subversion.rb delete mode 100644 vendor/gems/capistrano-2.5.9/lib/capistrano/recipes/deploy/strategy.rb delete mode 100644 vendor/gems/capistrano-2.5.9/lib/capistrano/recipes/deploy/strategy/base.rb delete mode 100644 vendor/gems/capistrano-2.5.9/lib/capistrano/recipes/deploy/strategy/checkout.rb delete mode 100644 vendor/gems/capistrano-2.5.9/lib/capistrano/recipes/deploy/strategy/copy.rb delete mode 100644 vendor/gems/capistrano-2.5.9/lib/capistrano/recipes/deploy/strategy/export.rb delete mode 100644 vendor/gems/capistrano-2.5.9/lib/capistrano/recipes/deploy/strategy/remote.rb delete mode 100644 vendor/gems/capistrano-2.5.9/lib/capistrano/recipes/deploy/strategy/remote_cache.rb delete mode 100644 vendor/gems/capistrano-2.5.9/lib/capistrano/recipes/deploy/templates/maintenance.rhtml delete mode 100644 vendor/gems/capistrano-2.5.9/lib/capistrano/recipes/standard.rb delete mode 100644 vendor/gems/capistrano-2.5.9/lib/capistrano/recipes/templates/maintenance.rhtml delete mode 100644 vendor/gems/capistrano-2.5.9/lib/capistrano/recipes/upgrade.rb delete mode 100644 vendor/gems/capistrano-2.5.9/lib/capistrano/role.rb delete mode 100644 vendor/gems/capistrano-2.5.9/lib/capistrano/server_definition.rb delete mode 100644 vendor/gems/capistrano-2.5.9/lib/capistrano/shell.rb delete mode 100644 vendor/gems/capistrano-2.5.9/lib/capistrano/ssh.rb delete mode 100644 vendor/gems/capistrano-2.5.9/lib/capistrano/task_definition.rb delete mode 100644 vendor/gems/capistrano-2.5.9/lib/capistrano/transfer.rb delete mode 100644 vendor/gems/capistrano-2.5.9/lib/capistrano/version.rb delete mode 100644 vendor/gems/capistrano-2.5.9/setup.rb delete mode 100644 vendor/gems/capistrano-2.5.9/test/cli/execute_test.rb delete mode 100644 vendor/gems/capistrano-2.5.9/test/cli/help_test.rb delete mode 100644 vendor/gems/capistrano-2.5.9/test/cli/options_test.rb delete mode 100644 vendor/gems/capistrano-2.5.9/test/cli/ui_test.rb delete mode 100644 vendor/gems/capistrano-2.5.9/test/cli_test.rb delete mode 100644 vendor/gems/capistrano-2.5.9/test/command_test.rb delete mode 100644 vendor/gems/capistrano-2.5.9/test/configuration/actions/file_transfer_test.rb delete mode 100644 vendor/gems/capistrano-2.5.9/test/configuration/actions/inspect_test.rb delete mode 100644 vendor/gems/capistrano-2.5.9/test/configuration/actions/invocation_test.rb delete mode 100644 vendor/gems/capistrano-2.5.9/test/configuration/callbacks_test.rb delete mode 100644 vendor/gems/capistrano-2.5.9/test/configuration/connections_test.rb delete mode 100644 vendor/gems/capistrano-2.5.9/test/configuration/execution_test.rb delete mode 100644 vendor/gems/capistrano-2.5.9/test/configuration/loading_test.rb delete mode 100644 vendor/gems/capistrano-2.5.9/test/configuration/namespace_dsl_test.rb delete mode 100644 vendor/gems/capistrano-2.5.9/test/configuration/roles_test.rb delete mode 100644 vendor/gems/capistrano-2.5.9/test/configuration/servers_test.rb delete mode 100644 vendor/gems/capistrano-2.5.9/test/configuration/variables_test.rb delete mode 100644 vendor/gems/capistrano-2.5.9/test/configuration_test.rb delete mode 100644 vendor/gems/capistrano-2.5.9/test/deploy/local_dependency_test.rb delete mode 100644 vendor/gems/capistrano-2.5.9/test/deploy/remote_dependency_test.rb delete mode 100644 vendor/gems/capistrano-2.5.9/test/deploy/scm/accurev_test.rb delete mode 100644 vendor/gems/capistrano-2.5.9/test/deploy/scm/base_test.rb delete mode 100644 vendor/gems/capistrano-2.5.9/test/deploy/scm/git_test.rb delete mode 100644 vendor/gems/capistrano-2.5.9/test/deploy/scm/mercurial_test.rb delete mode 100644 vendor/gems/capistrano-2.5.9/test/deploy/scm/none_test.rb delete mode 100644 vendor/gems/capistrano-2.5.9/test/deploy/scm/subversion_test.rb delete mode 100644 vendor/gems/capistrano-2.5.9/test/deploy/strategy/copy_test.rb delete mode 100644 vendor/gems/capistrano-2.5.9/test/extensions_test.rb delete mode 100644 vendor/gems/capistrano-2.5.9/test/fixtures/cli_integration.rb delete mode 100644 vendor/gems/capistrano-2.5.9/test/fixtures/config.rb delete mode 100644 vendor/gems/capistrano-2.5.9/test/fixtures/custom.rb delete mode 100644 vendor/gems/capistrano-2.5.9/test/logger_test.rb delete mode 100644 vendor/gems/capistrano-2.5.9/test/role_test.rb delete mode 100644 vendor/gems/capistrano-2.5.9/test/server_definition_test.rb delete mode 100644 vendor/gems/capistrano-2.5.9/test/shell_test.rb delete mode 100644 vendor/gems/capistrano-2.5.9/test/ssh_test.rb delete mode 100644 vendor/gems/capistrano-2.5.9/test/task_definition_test.rb delete mode 100644 vendor/gems/capistrano-2.5.9/test/transfer_test.rb delete mode 100644 vendor/gems/capistrano-2.5.9/test/utils.rb delete mode 100644 vendor/gems/highline-1.5.1/.specification delete mode 100644 vendor/gems/highline-1.5.1/CHANGELOG delete mode 100644 vendor/gems/highline-1.5.1/INSTALL delete mode 100644 vendor/gems/highline-1.5.1/LICENSE delete mode 100644 vendor/gems/highline-1.5.1/README delete mode 100644 vendor/gems/highline-1.5.1/Rakefile delete mode 100644 vendor/gems/highline-1.5.1/TODO delete mode 100644 vendor/gems/highline-1.5.1/examples/ansi_colors.rb delete mode 100644 vendor/gems/highline-1.5.1/examples/asking_for_arrays.rb delete mode 100644 vendor/gems/highline-1.5.1/examples/basic_usage.rb delete mode 100644 vendor/gems/highline-1.5.1/examples/color_scheme.rb delete mode 100644 vendor/gems/highline-1.5.1/examples/limit.rb delete mode 100644 vendor/gems/highline-1.5.1/examples/menus.rb delete mode 100644 vendor/gems/highline-1.5.1/examples/overwrite.rb delete mode 100644 vendor/gems/highline-1.5.1/examples/page_and_wrap.rb delete mode 100644 vendor/gems/highline-1.5.1/examples/password.rb delete mode 100644 vendor/gems/highline-1.5.1/examples/trapping_eof.rb delete mode 100644 vendor/gems/highline-1.5.1/examples/using_readline.rb delete mode 100644 vendor/gems/highline-1.5.1/lib/highline.rb delete mode 100644 vendor/gems/highline-1.5.1/lib/highline/color_scheme.rb delete mode 100644 vendor/gems/highline-1.5.1/lib/highline/compatibility.rb delete mode 100644 vendor/gems/highline-1.5.1/lib/highline/import.rb delete mode 100644 vendor/gems/highline-1.5.1/lib/highline/menu.rb delete mode 100644 vendor/gems/highline-1.5.1/lib/highline/question.rb delete mode 100644 vendor/gems/highline-1.5.1/lib/highline/system_extensions.rb delete mode 100644 vendor/gems/highline-1.5.1/setup.rb delete mode 100644 vendor/gems/highline-1.5.1/test/tc_color_scheme.rb delete mode 100644 vendor/gems/highline-1.5.1/test/tc_highline.rb delete mode 100644 vendor/gems/highline-1.5.1/test/tc_import.rb delete mode 100644 vendor/gems/highline-1.5.1/test/tc_menu.rb delete mode 100644 vendor/gems/highline-1.5.1/test/ts_all.rb delete mode 100644 vendor/gems/net-scp-1.0.2/.specification delete mode 100644 vendor/gems/net-scp-1.0.2/CHANGELOG.rdoc delete mode 100644 vendor/gems/net-scp-1.0.2/Manifest delete mode 100644 vendor/gems/net-scp-1.0.2/README.rdoc delete mode 100644 vendor/gems/net-scp-1.0.2/Rakefile delete mode 100644 vendor/gems/net-scp-1.0.2/lib/net/scp.rb delete mode 100644 vendor/gems/net-scp-1.0.2/lib/net/scp/download.rb delete mode 100644 vendor/gems/net-scp-1.0.2/lib/net/scp/errors.rb delete mode 100644 vendor/gems/net-scp-1.0.2/lib/net/scp/upload.rb delete mode 100644 vendor/gems/net-scp-1.0.2/lib/net/scp/version.rb delete mode 100644 vendor/gems/net-scp-1.0.2/lib/uri/open-scp.rb delete mode 100644 vendor/gems/net-scp-1.0.2/lib/uri/scp.rb delete mode 100644 vendor/gems/net-scp-1.0.2/net-scp.gemspec delete mode 100644 vendor/gems/net-scp-1.0.2/setup.rb delete mode 100644 vendor/gems/net-scp-1.0.2/test/common.rb delete mode 100644 vendor/gems/net-scp-1.0.2/test/test_all.rb delete mode 100644 vendor/gems/net-scp-1.0.2/test/test_download.rb delete mode 100644 vendor/gems/net-scp-1.0.2/test/test_scp.rb delete mode 100644 vendor/gems/net-scp-1.0.2/test/test_upload.rb delete mode 100644 vendor/gems/net-sftp-2.0.2/.specification delete mode 100644 vendor/gems/net-sftp-2.0.2/CHANGELOG.rdoc delete mode 100644 vendor/gems/net-sftp-2.0.2/Manifest delete mode 100644 vendor/gems/net-sftp-2.0.2/README.rdoc delete mode 100644 vendor/gems/net-sftp-2.0.2/Rakefile delete mode 100644 vendor/gems/net-sftp-2.0.2/lib/net/sftp.rb delete mode 100644 vendor/gems/net-sftp-2.0.2/lib/net/sftp/constants.rb delete mode 100644 vendor/gems/net-sftp-2.0.2/lib/net/sftp/errors.rb delete mode 100644 vendor/gems/net-sftp-2.0.2/lib/net/sftp/operations/dir.rb delete mode 100644 vendor/gems/net-sftp-2.0.2/lib/net/sftp/operations/download.rb delete mode 100644 vendor/gems/net-sftp-2.0.2/lib/net/sftp/operations/file.rb delete mode 100644 vendor/gems/net-sftp-2.0.2/lib/net/sftp/operations/file_factory.rb delete mode 100644 vendor/gems/net-sftp-2.0.2/lib/net/sftp/operations/upload.rb delete mode 100644 vendor/gems/net-sftp-2.0.2/lib/net/sftp/packet.rb delete mode 100644 vendor/gems/net-sftp-2.0.2/lib/net/sftp/protocol.rb delete mode 100644 vendor/gems/net-sftp-2.0.2/lib/net/sftp/protocol/01/attributes.rb delete mode 100644 vendor/gems/net-sftp-2.0.2/lib/net/sftp/protocol/01/base.rb delete mode 100644 vendor/gems/net-sftp-2.0.2/lib/net/sftp/protocol/01/name.rb delete mode 100644 vendor/gems/net-sftp-2.0.2/lib/net/sftp/protocol/02/base.rb delete mode 100644 vendor/gems/net-sftp-2.0.2/lib/net/sftp/protocol/03/base.rb delete mode 100644 vendor/gems/net-sftp-2.0.2/lib/net/sftp/protocol/04/attributes.rb delete mode 100644 vendor/gems/net-sftp-2.0.2/lib/net/sftp/protocol/04/base.rb delete mode 100644 vendor/gems/net-sftp-2.0.2/lib/net/sftp/protocol/04/name.rb delete mode 100644 vendor/gems/net-sftp-2.0.2/lib/net/sftp/protocol/05/base.rb delete mode 100644 vendor/gems/net-sftp-2.0.2/lib/net/sftp/protocol/06/attributes.rb delete mode 100644 vendor/gems/net-sftp-2.0.2/lib/net/sftp/protocol/06/base.rb delete mode 100644 vendor/gems/net-sftp-2.0.2/lib/net/sftp/protocol/base.rb delete mode 100644 vendor/gems/net-sftp-2.0.2/lib/net/sftp/request.rb delete mode 100644 vendor/gems/net-sftp-2.0.2/lib/net/sftp/response.rb delete mode 100644 vendor/gems/net-sftp-2.0.2/lib/net/sftp/session.rb delete mode 100644 vendor/gems/net-sftp-2.0.2/lib/net/sftp/version.rb delete mode 100644 vendor/gems/net-sftp-2.0.2/net-sftp.gemspec delete mode 100644 vendor/gems/net-sftp-2.0.2/setup.rb delete mode 100644 vendor/gems/net-sftp-2.0.2/test/common.rb delete mode 100644 vendor/gems/net-sftp-2.0.2/test/protocol/01/test_attributes.rb delete mode 100644 vendor/gems/net-sftp-2.0.2/test/protocol/01/test_base.rb delete mode 100644 vendor/gems/net-sftp-2.0.2/test/protocol/01/test_name.rb delete mode 100644 vendor/gems/net-sftp-2.0.2/test/protocol/02/test_base.rb delete mode 100644 vendor/gems/net-sftp-2.0.2/test/protocol/03/test_base.rb delete mode 100644 vendor/gems/net-sftp-2.0.2/test/protocol/04/test_attributes.rb delete mode 100644 vendor/gems/net-sftp-2.0.2/test/protocol/04/test_base.rb delete mode 100644 vendor/gems/net-sftp-2.0.2/test/protocol/04/test_name.rb delete mode 100644 vendor/gems/net-sftp-2.0.2/test/protocol/05/test_base.rb delete mode 100644 vendor/gems/net-sftp-2.0.2/test/protocol/06/test_attributes.rb delete mode 100644 vendor/gems/net-sftp-2.0.2/test/protocol/06/test_base.rb delete mode 100644 vendor/gems/net-sftp-2.0.2/test/protocol/test_base.rb delete mode 100644 vendor/gems/net-sftp-2.0.2/test/test_all.rb delete mode 100644 vendor/gems/net-sftp-2.0.2/test/test_dir.rb delete mode 100644 vendor/gems/net-sftp-2.0.2/test/test_download.rb delete mode 100644 vendor/gems/net-sftp-2.0.2/test/test_file.rb delete mode 100644 vendor/gems/net-sftp-2.0.2/test/test_file_factory.rb delete mode 100644 vendor/gems/net-sftp-2.0.2/test/test_packet.rb delete mode 100644 vendor/gems/net-sftp-2.0.2/test/test_protocol.rb delete mode 100644 vendor/gems/net-sftp-2.0.2/test/test_request.rb delete mode 100644 vendor/gems/net-sftp-2.0.2/test/test_response.rb delete mode 100644 vendor/gems/net-sftp-2.0.2/test/test_session.rb delete mode 100644 vendor/gems/net-sftp-2.0.2/test/test_upload.rb delete mode 100644 vendor/gems/net-ssh-2.0.15/.specification delete mode 100644 vendor/gems/net-ssh-2.0.15/CHANGELOG.rdoc delete mode 100644 vendor/gems/net-ssh-2.0.15/Manifest delete mode 100644 vendor/gems/net-ssh-2.0.15/README.rdoc delete mode 100644 vendor/gems/net-ssh-2.0.15/Rakefile delete mode 100644 vendor/gems/net-ssh-2.0.15/Rudyfile delete mode 100644 vendor/gems/net-ssh-2.0.15/THANKS.rdoc delete mode 100644 vendor/gems/net-ssh-2.0.15/lib/net/ssh.rb delete mode 100644 vendor/gems/net-ssh-2.0.15/lib/net/ssh/authentication/agent.rb delete mode 100644 vendor/gems/net-ssh-2.0.15/lib/net/ssh/authentication/constants.rb delete mode 100644 vendor/gems/net-ssh-2.0.15/lib/net/ssh/authentication/key_manager.rb delete mode 100644 vendor/gems/net-ssh-2.0.15/lib/net/ssh/authentication/methods/abstract.rb delete mode 100644 vendor/gems/net-ssh-2.0.15/lib/net/ssh/authentication/methods/hostbased.rb delete mode 100644 vendor/gems/net-ssh-2.0.15/lib/net/ssh/authentication/methods/keyboard_interactive.rb delete mode 100644 vendor/gems/net-ssh-2.0.15/lib/net/ssh/authentication/methods/password.rb delete mode 100644 vendor/gems/net-ssh-2.0.15/lib/net/ssh/authentication/methods/publickey.rb delete mode 100644 vendor/gems/net-ssh-2.0.15/lib/net/ssh/authentication/pageant.rb delete mode 100644 vendor/gems/net-ssh-2.0.15/lib/net/ssh/authentication/session.rb delete mode 100644 vendor/gems/net-ssh-2.0.15/lib/net/ssh/buffer.rb delete mode 100644 vendor/gems/net-ssh-2.0.15/lib/net/ssh/buffered_io.rb delete mode 100644 vendor/gems/net-ssh-2.0.15/lib/net/ssh/config.rb delete mode 100644 vendor/gems/net-ssh-2.0.15/lib/net/ssh/connection/channel.rb delete mode 100644 vendor/gems/net-ssh-2.0.15/lib/net/ssh/connection/constants.rb delete mode 100644 vendor/gems/net-ssh-2.0.15/lib/net/ssh/connection/session.rb delete mode 100644 vendor/gems/net-ssh-2.0.15/lib/net/ssh/connection/term.rb delete mode 100644 vendor/gems/net-ssh-2.0.15/lib/net/ssh/errors.rb delete mode 100644 vendor/gems/net-ssh-2.0.15/lib/net/ssh/key_factory.rb delete mode 100644 vendor/gems/net-ssh-2.0.15/lib/net/ssh/known_hosts.rb delete mode 100644 vendor/gems/net-ssh-2.0.15/lib/net/ssh/loggable.rb delete mode 100644 vendor/gems/net-ssh-2.0.15/lib/net/ssh/packet.rb delete mode 100644 vendor/gems/net-ssh-2.0.15/lib/net/ssh/prompt.rb delete mode 100644 vendor/gems/net-ssh-2.0.15/lib/net/ssh/proxy/errors.rb delete mode 100644 vendor/gems/net-ssh-2.0.15/lib/net/ssh/proxy/http.rb delete mode 100644 vendor/gems/net-ssh-2.0.15/lib/net/ssh/proxy/socks4.rb delete mode 100644 vendor/gems/net-ssh-2.0.15/lib/net/ssh/proxy/socks5.rb delete mode 100644 vendor/gems/net-ssh-2.0.15/lib/net/ssh/ruby_compat.rb delete mode 100644 vendor/gems/net-ssh-2.0.15/lib/net/ssh/service/forward.rb delete mode 100644 vendor/gems/net-ssh-2.0.15/lib/net/ssh/test.rb delete mode 100644 vendor/gems/net-ssh-2.0.15/lib/net/ssh/test/channel.rb delete mode 100644 vendor/gems/net-ssh-2.0.15/lib/net/ssh/test/extensions.rb delete mode 100644 vendor/gems/net-ssh-2.0.15/lib/net/ssh/test/kex.rb delete mode 100644 vendor/gems/net-ssh-2.0.15/lib/net/ssh/test/local_packet.rb delete mode 100644 vendor/gems/net-ssh-2.0.15/lib/net/ssh/test/packet.rb delete mode 100644 vendor/gems/net-ssh-2.0.15/lib/net/ssh/test/remote_packet.rb delete mode 100644 vendor/gems/net-ssh-2.0.15/lib/net/ssh/test/script.rb delete mode 100644 vendor/gems/net-ssh-2.0.15/lib/net/ssh/test/socket.rb delete mode 100644 vendor/gems/net-ssh-2.0.15/lib/net/ssh/transport/algorithms.rb delete mode 100644 vendor/gems/net-ssh-2.0.15/lib/net/ssh/transport/cipher_factory.rb delete mode 100644 vendor/gems/net-ssh-2.0.15/lib/net/ssh/transport/constants.rb delete mode 100644 vendor/gems/net-ssh-2.0.15/lib/net/ssh/transport/hmac.rb delete mode 100644 vendor/gems/net-ssh-2.0.15/lib/net/ssh/transport/hmac/abstract.rb delete mode 100644 vendor/gems/net-ssh-2.0.15/lib/net/ssh/transport/hmac/md5.rb delete mode 100644 vendor/gems/net-ssh-2.0.15/lib/net/ssh/transport/hmac/md5_96.rb delete mode 100644 vendor/gems/net-ssh-2.0.15/lib/net/ssh/transport/hmac/none.rb delete mode 100644 vendor/gems/net-ssh-2.0.15/lib/net/ssh/transport/hmac/sha1.rb delete mode 100644 vendor/gems/net-ssh-2.0.15/lib/net/ssh/transport/hmac/sha1_96.rb delete mode 100644 vendor/gems/net-ssh-2.0.15/lib/net/ssh/transport/identity_cipher.rb delete mode 100644 vendor/gems/net-ssh-2.0.15/lib/net/ssh/transport/kex.rb delete mode 100644 vendor/gems/net-ssh-2.0.15/lib/net/ssh/transport/kex/diffie_hellman_group1_sha1.rb delete mode 100644 vendor/gems/net-ssh-2.0.15/lib/net/ssh/transport/kex/diffie_hellman_group_exchange_sha1.rb delete mode 100644 vendor/gems/net-ssh-2.0.15/lib/net/ssh/transport/openssl.rb delete mode 100644 vendor/gems/net-ssh-2.0.15/lib/net/ssh/transport/packet_stream.rb delete mode 100644 vendor/gems/net-ssh-2.0.15/lib/net/ssh/transport/server_version.rb delete mode 100644 vendor/gems/net-ssh-2.0.15/lib/net/ssh/transport/session.rb delete mode 100644 vendor/gems/net-ssh-2.0.15/lib/net/ssh/transport/state.rb delete mode 100644 vendor/gems/net-ssh-2.0.15/lib/net/ssh/verifiers/lenient.rb delete mode 100644 vendor/gems/net-ssh-2.0.15/lib/net/ssh/verifiers/null.rb delete mode 100644 vendor/gems/net-ssh-2.0.15/lib/net/ssh/verifiers/strict.rb delete mode 100644 vendor/gems/net-ssh-2.0.15/lib/net/ssh/version.rb delete mode 100644 vendor/gems/net-ssh-2.0.15/net-ssh.gemspec delete mode 100644 vendor/gems/net-ssh-2.0.15/setup.rb delete mode 100644 vendor/gems/net-ssh-2.0.15/support/arcfour_check.rb delete mode 100644 vendor/gems/net-ssh-2.0.15/test/authentication/methods/common.rb delete mode 100644 vendor/gems/net-ssh-2.0.15/test/authentication/methods/test_abstract.rb delete mode 100644 vendor/gems/net-ssh-2.0.15/test/authentication/methods/test_hostbased.rb delete mode 100644 vendor/gems/net-ssh-2.0.15/test/authentication/methods/test_keyboard_interactive.rb delete mode 100644 vendor/gems/net-ssh-2.0.15/test/authentication/methods/test_password.rb delete mode 100644 vendor/gems/net-ssh-2.0.15/test/authentication/methods/test_publickey.rb delete mode 100644 vendor/gems/net-ssh-2.0.15/test/authentication/test_agent.rb delete mode 100644 vendor/gems/net-ssh-2.0.15/test/authentication/test_key_manager.rb delete mode 100644 vendor/gems/net-ssh-2.0.15/test/authentication/test_session.rb delete mode 100644 vendor/gems/net-ssh-2.0.15/test/common.rb delete mode 100644 vendor/gems/net-ssh-2.0.15/test/configs/eqsign delete mode 100644 vendor/gems/net-ssh-2.0.15/test/configs/exact_match delete mode 100644 vendor/gems/net-ssh-2.0.15/test/configs/multihost delete mode 100644 vendor/gems/net-ssh-2.0.15/test/configs/wild_cards delete mode 100644 vendor/gems/net-ssh-2.0.15/test/connection/test_channel.rb delete mode 100644 vendor/gems/net-ssh-2.0.15/test/connection/test_session.rb delete mode 100644 vendor/gems/net-ssh-2.0.15/test/test_all.rb delete mode 100644 vendor/gems/net-ssh-2.0.15/test/test_buffer.rb delete mode 100644 vendor/gems/net-ssh-2.0.15/test/test_buffered_io.rb delete mode 100644 vendor/gems/net-ssh-2.0.15/test/test_config.rb delete mode 100644 vendor/gems/net-ssh-2.0.15/test/test_key_factory.rb delete mode 100644 vendor/gems/net-ssh-2.0.15/test/transport/hmac/test_md5.rb delete mode 100644 vendor/gems/net-ssh-2.0.15/test/transport/hmac/test_md5_96.rb delete mode 100644 vendor/gems/net-ssh-2.0.15/test/transport/hmac/test_none.rb delete mode 100644 vendor/gems/net-ssh-2.0.15/test/transport/hmac/test_sha1.rb delete mode 100644 vendor/gems/net-ssh-2.0.15/test/transport/hmac/test_sha1_96.rb delete mode 100644 vendor/gems/net-ssh-2.0.15/test/transport/kex/test_diffie_hellman_group1_sha1.rb delete mode 100644 vendor/gems/net-ssh-2.0.15/test/transport/kex/test_diffie_hellman_group_exchange_sha1.rb delete mode 100644 vendor/gems/net-ssh-2.0.15/test/transport/test_algorithms.rb delete mode 100644 vendor/gems/net-ssh-2.0.15/test/transport/test_cipher_factory.rb delete mode 100644 vendor/gems/net-ssh-2.0.15/test/transport/test_hmac.rb delete mode 100644 vendor/gems/net-ssh-2.0.15/test/transport/test_identity_cipher.rb delete mode 100644 vendor/gems/net-ssh-2.0.15/test/transport/test_packet_stream.rb delete mode 100644 vendor/gems/net-ssh-2.0.15/test/transport/test_server_version.rb delete mode 100644 vendor/gems/net-ssh-2.0.15/test/transport/test_session.rb delete mode 100644 vendor/gems/net-ssh-2.0.15/test/transport/test_state.rb delete mode 100644 vendor/gems/net-ssh-gateway-1.0.1/.specification delete mode 100644 vendor/gems/net-ssh-gateway-1.0.1/CHANGELOG.rdoc delete mode 100644 vendor/gems/net-ssh-gateway-1.0.1/Manifest delete mode 100644 vendor/gems/net-ssh-gateway-1.0.1/README.rdoc delete mode 100644 vendor/gems/net-ssh-gateway-1.0.1/Rakefile delete mode 100644 vendor/gems/net-ssh-gateway-1.0.1/lib/net/ssh/gateway.rb delete mode 100644 vendor/gems/net-ssh-gateway-1.0.1/net-ssh-gateway.gemspec delete mode 100644 vendor/gems/net-ssh-gateway-1.0.1/setup.rb delete mode 100644 vendor/gems/net-ssh-gateway-1.0.1/test/gateway_test.rb delete mode 100644 vendor/gems/open4-0.9.3/.specification delete mode 100644 vendor/gems/open4-0.9.3/README delete mode 100644 vendor/gems/open4-0.9.3/gemspec.rb delete mode 100644 vendor/gems/open4-0.9.3/install.rb delete mode 100644 vendor/gems/open4-0.9.3/lib/open4-0.9.3.rb delete mode 100644 vendor/gems/open4-0.9.3/lib/open4.rb delete mode 100644 vendor/gems/open4-0.9.3/open4-0.9.3.gem delete mode 100644 vendor/gems/open4-0.9.3/sample/bg.rb delete mode 100644 vendor/gems/open4-0.9.3/sample/block.rb delete mode 100644 vendor/gems/open4-0.9.3/sample/exception.rb delete mode 100644 vendor/gems/open4-0.9.3/sample/simple.rb delete mode 100644 vendor/gems/open4-0.9.3/sample/spawn.rb delete mode 100644 vendor/gems/open4-0.9.3/sample/stdin_timeout.rb delete mode 100644 vendor/gems/open4-0.9.3/sample/timeout.rb delete mode 100644 vendor/gems/open4-0.9.3/white_box/leak.rb delete mode 100644 vendor/gems/syntax-1.0.0/.specification delete mode 100644 vendor/gems/syntax-1.0.0/data/ruby.css delete mode 100644 vendor/gems/syntax-1.0.0/data/xml.css delete mode 100644 vendor/gems/syntax-1.0.0/data/yaml.css delete mode 100644 vendor/gems/syntax-1.0.0/lib/syntax.rb delete mode 100644 vendor/gems/syntax-1.0.0/lib/syntax/common.rb delete mode 100644 vendor/gems/syntax-1.0.0/lib/syntax/convertors/abstract.rb delete mode 100644 vendor/gems/syntax-1.0.0/lib/syntax/convertors/html.rb delete mode 100644 vendor/gems/syntax-1.0.0/lib/syntax/lang/ruby.rb delete mode 100644 vendor/gems/syntax-1.0.0/lib/syntax/lang/xml.rb delete mode 100644 vendor/gems/syntax-1.0.0/lib/syntax/lang/yaml.rb delete mode 100644 vendor/gems/syntax-1.0.0/lib/syntax/version.rb delete mode 100644 vendor/gems/syntax-1.0.0/test/ALL-TESTS.rb delete mode 100644 vendor/gems/syntax-1.0.0/test/syntax/tc_ruby.rb delete mode 100644 vendor/gems/syntax-1.0.0/test/syntax/tc_xml.rb delete mode 100644 vendor/gems/syntax-1.0.0/test/syntax/tc_yaml.rb delete mode 100644 vendor/gems/syntax-1.0.0/test/syntax/tokenizer_testcase.rb delete mode 100644 vendor/gems/syntax-1.0.0/test/tc_syntax.rb diff --git a/vendor/gems/capistrano-2.5.9/.specification b/vendor/gems/capistrano-2.5.9/.specification deleted file mode 100644 index 0a846de2e..000000000 --- a/vendor/gems/capistrano-2.5.9/.specification +++ /dev/null @@ -1,312 +0,0 @@ ---- !ruby/object:Gem::Specification -name: capistrano -version: !ruby/object:Gem::Version - version: 2.5.9 -platform: ruby -authors: -- Jamis Buck, Lee Hambley -autorequire: -bindir: bin -cert_chain: [] - -date: 2009-09-12 00:00:00 +00:00 -default_executable: -dependencies: -- !ruby/object:Gem::Dependency - name: net-ssh - type: :runtime - version_requirement: - version_requirements: !ruby/object:Gem::Requirement - requirements: - - - ">=" - - !ruby/object:Gem::Version - version: 2.0.14 - version: -- !ruby/object:Gem::Dependency - name: net-sftp - type: :runtime - version_requirement: - version_requirements: !ruby/object:Gem::Requirement - requirements: - - - ">=" - - !ruby/object:Gem::Version - version: 2.0.0 - version: -- !ruby/object:Gem::Dependency - name: net-scp - type: :runtime - version_requirement: - version_requirements: !ruby/object:Gem::Requirement - requirements: - - - ">=" - - !ruby/object:Gem::Version - version: 1.0.0 - version: -- !ruby/object:Gem::Dependency - name: net-ssh-gateway - type: :runtime - version_requirement: - version_requirements: !ruby/object:Gem::Requirement - requirements: - - - ">=" - - !ruby/object:Gem::Version - version: 1.0.0 - version: -- !ruby/object:Gem::Dependency - name: highline - type: :runtime - version_requirement: - version_requirements: !ruby/object:Gem::Requirement - requirements: - - - ">=" - - !ruby/object:Gem::Version - version: "0" - version: -description: Capistrano is a utility and framework for executing commands in parallel on multiple remote machines, via SSH. -email: -- jamis@jamisbuck.org -- lee.hambley@gmail.com -executables: -- cap -- capify -extensions: [] - -extra_rdoc_files: -- CHANGELOG.rdoc -- lib/capistrano/callback.rb -- lib/capistrano/cli/execute.rb -- lib/capistrano/cli/help.rb -- lib/capistrano/cli/help.txt -- lib/capistrano/cli/options.rb -- lib/capistrano/cli/ui.rb -- lib/capistrano/cli.rb -- lib/capistrano/command.rb -- lib/capistrano/configuration/actions/file_transfer.rb -- lib/capistrano/configuration/actions/inspect.rb -- lib/capistrano/configuration/actions/invocation.rb -- lib/capistrano/configuration/callbacks.rb -- lib/capistrano/configuration/connections.rb -- lib/capistrano/configuration/execution.rb -- lib/capistrano/configuration/loading.rb -- lib/capistrano/configuration/namespaces.rb -- lib/capistrano/configuration/roles.rb -- lib/capistrano/configuration/servers.rb -- lib/capistrano/configuration/variables.rb -- lib/capistrano/configuration.rb -- lib/capistrano/errors.rb -- lib/capistrano/extensions.rb -- lib/capistrano/logger.rb -- lib/capistrano/processable.rb -- lib/capistrano/recipes/compat.rb -- lib/capistrano/recipes/deploy/dependencies.rb -- lib/capistrano/recipes/deploy/local_dependency.rb -- lib/capistrano/recipes/deploy/remote_dependency.rb -- lib/capistrano/recipes/deploy/scm/accurev.rb -- lib/capistrano/recipes/deploy/scm/base.rb -- lib/capistrano/recipes/deploy/scm/bzr.rb -- lib/capistrano/recipes/deploy/scm/cvs.rb -- lib/capistrano/recipes/deploy/scm/darcs.rb -- lib/capistrano/recipes/deploy/scm/git.rb -- lib/capistrano/recipes/deploy/scm/mercurial.rb -- lib/capistrano/recipes/deploy/scm/none.rb -- lib/capistrano/recipes/deploy/scm/perforce.rb -- lib/capistrano/recipes/deploy/scm/subversion.rb -- lib/capistrano/recipes/deploy/scm.rb -- lib/capistrano/recipes/deploy/strategy/base.rb -- lib/capistrano/recipes/deploy/strategy/checkout.rb -- lib/capistrano/recipes/deploy/strategy/copy.rb -- lib/capistrano/recipes/deploy/strategy/export.rb -- lib/capistrano/recipes/deploy/strategy/remote.rb -- lib/capistrano/recipes/deploy/strategy/remote_cache.rb -- lib/capistrano/recipes/deploy/strategy.rb -- lib/capistrano/recipes/deploy/templates/maintenance.rhtml -- lib/capistrano/recipes/deploy.rb -- lib/capistrano/recipes/standard.rb -- lib/capistrano/recipes/templates/maintenance.rhtml -- lib/capistrano/recipes/upgrade.rb -- lib/capistrano/role.rb -- lib/capistrano/server_definition.rb -- lib/capistrano/shell.rb -- lib/capistrano/ssh.rb -- lib/capistrano/task_definition.rb -- lib/capistrano/transfer.rb -- lib/capistrano/version.rb -- lib/capistrano.rb -- README.rdoc -files: -- bin/cap -- bin/capify -- CHANGELOG.rdoc -- examples/sample.rb -- lib/capistrano/callback.rb -- lib/capistrano/cli/execute.rb -- lib/capistrano/cli/help.rb -- lib/capistrano/cli/help.txt -- lib/capistrano/cli/options.rb -- lib/capistrano/cli/ui.rb -- lib/capistrano/cli.rb -- lib/capistrano/command.rb -- lib/capistrano/configuration/actions/file_transfer.rb -- lib/capistrano/configuration/actions/inspect.rb -- lib/capistrano/configuration/actions/invocation.rb -- lib/capistrano/configuration/callbacks.rb -- lib/capistrano/configuration/connections.rb -- lib/capistrano/configuration/execution.rb -- lib/capistrano/configuration/loading.rb -- lib/capistrano/configuration/namespaces.rb -- lib/capistrano/configuration/roles.rb -- lib/capistrano/configuration/servers.rb -- lib/capistrano/configuration/variables.rb -- lib/capistrano/configuration.rb -- lib/capistrano/errors.rb -- lib/capistrano/extensions.rb -- lib/capistrano/logger.rb -- lib/capistrano/processable.rb -- lib/capistrano/recipes/compat.rb -- lib/capistrano/recipes/deploy/dependencies.rb -- lib/capistrano/recipes/deploy/local_dependency.rb -- lib/capistrano/recipes/deploy/remote_dependency.rb -- lib/capistrano/recipes/deploy/scm/accurev.rb -- lib/capistrano/recipes/deploy/scm/base.rb -- lib/capistrano/recipes/deploy/scm/bzr.rb -- lib/capistrano/recipes/deploy/scm/cvs.rb -- lib/capistrano/recipes/deploy/scm/darcs.rb -- lib/capistrano/recipes/deploy/scm/git.rb -- lib/capistrano/recipes/deploy/scm/mercurial.rb -- lib/capistrano/recipes/deploy/scm/none.rb -- lib/capistrano/recipes/deploy/scm/perforce.rb -- lib/capistrano/recipes/deploy/scm/subversion.rb -- lib/capistrano/recipes/deploy/scm.rb -- lib/capistrano/recipes/deploy/strategy/base.rb -- lib/capistrano/recipes/deploy/strategy/checkout.rb -- lib/capistrano/recipes/deploy/strategy/copy.rb -- lib/capistrano/recipes/deploy/strategy/export.rb -- lib/capistrano/recipes/deploy/strategy/remote.rb -- lib/capistrano/recipes/deploy/strategy/remote_cache.rb -- lib/capistrano/recipes/deploy/strategy.rb -- lib/capistrano/recipes/deploy/templates/maintenance.rhtml -- lib/capistrano/recipes/deploy.rb -- lib/capistrano/recipes/standard.rb -- lib/capistrano/recipes/templates/maintenance.rhtml -- lib/capistrano/recipes/upgrade.rb -- lib/capistrano/role.rb -- lib/capistrano/server_definition.rb -- lib/capistrano/shell.rb -- lib/capistrano/ssh.rb -- lib/capistrano/task_definition.rb -- lib/capistrano/transfer.rb -- lib/capistrano/version.rb -- lib/capistrano.rb -- Rakefile -- README.rdoc -- setup.rb -- test/cli/execute_test.rb -- test/cli/help_test.rb -- test/cli/options_test.rb -- test/cli/ui_test.rb -- test/cli_test.rb -- test/command_test.rb -- test/configuration/actions/file_transfer_test.rb -- test/configuration/actions/inspect_test.rb -- test/configuration/actions/invocation_test.rb -- test/configuration/callbacks_test.rb -- test/configuration/connections_test.rb -- test/configuration/execution_test.rb -- test/configuration/loading_test.rb -- test/configuration/namespace_dsl_test.rb -- test/configuration/roles_test.rb -- test/configuration/servers_test.rb -- test/configuration/variables_test.rb -- test/configuration_test.rb -- test/deploy/local_dependency_test.rb -- test/deploy/remote_dependency_test.rb -- test/deploy/scm/accurev_test.rb -- test/deploy/scm/base_test.rb -- test/deploy/scm/git_test.rb -- test/deploy/scm/mercurial_test.rb -- test/deploy/strategy/copy_test.rb -- test/extensions_test.rb -- test/fixtures/cli_integration.rb -- test/fixtures/config.rb -- test/fixtures/custom.rb -- test/logger_test.rb -- test/role_test.rb -- test/server_definition_test.rb -- test/shell_test.rb -- test/ssh_test.rb -- test/task_definition_test.rb -- test/transfer_test.rb -- test/utils.rb -- Manifest -- capistrano.gemspec -- test/deploy/scm/none_test.rb -- test/deploy/scm/subversion_test.rb -has_rdoc: true -homepage: http://www.capify.org -licenses: [] - -post_install_message: -rdoc_options: -- --line-numbers -- --inline-source -- --title -- Capistrano -- --main -- README.rdoc -require_paths: -- lib -required_ruby_version: !ruby/object:Gem::Requirement - requirements: - - - ">=" - - !ruby/object:Gem::Version - version: "0" - version: -required_rubygems_version: !ruby/object:Gem::Requirement - requirements: - - - ">=" - - !ruby/object:Gem::Version - version: "1.2" - version: -requirements: [] - -rubyforge_project: capistrano -rubygems_version: 1.3.4 -signing_key: -specification_version: 2 -summary: Capistrano is a utility and framework for executing commands in parallel on multiple remote machines, via SSH. -test_files: -- test/cli/execute_test.rb -- test/cli/help_test.rb -- test/cli/options_test.rb -- test/cli/ui_test.rb -- test/cli_test.rb -- test/command_test.rb -- test/configuration/actions/file_transfer_test.rb -- test/configuration/actions/inspect_test.rb -- test/configuration/actions/invocation_test.rb -- test/configuration/callbacks_test.rb -- test/configuration/connections_test.rb -- test/configuration/execution_test.rb -- test/configuration/loading_test.rb -- test/configuration/namespace_dsl_test.rb -- test/configuration/roles_test.rb -- test/configuration/servers_test.rb -- test/configuration/variables_test.rb -- test/configuration_test.rb -- test/deploy/local_dependency_test.rb -- test/deploy/remote_dependency_test.rb -- test/deploy/scm/accurev_test.rb -- test/deploy/scm/base_test.rb -- test/deploy/scm/git_test.rb -- test/deploy/scm/mercurial_test.rb -- test/deploy/scm/none_test.rb -- test/deploy/scm/subversion_test.rb -- test/deploy/strategy/copy_test.rb -- test/extensions_test.rb -- test/logger_test.rb -- test/role_test.rb -- test/server_definition_test.rb -- test/shell_test.rb -- test/ssh_test.rb -- test/task_definition_test.rb -- test/transfer_test.rb diff --git a/vendor/gems/capistrano-2.5.9/CHANGELOG.rdoc b/vendor/gems/capistrano-2.5.9/CHANGELOG.rdoc deleted file mode 100644 index 3bd41e7df..000000000 --- a/vendor/gems/capistrano-2.5.9/CHANGELOG.rdoc +++ /dev/null @@ -1,791 +0,0 @@ -== 2.5.9 / 12 September 2009 - - * #105 - Adds skip_hostfilter option to find_servers() [Eric] - * #103 - Fixes Using non-master branch fails with Ruby 1.9 [Suraj Kurapati] - * #96 - Tweak for 1.9 Compatibility - * #79 - Fixes Capistrano hangs on shell command for many computers - * #77 - Fixes Copy command doesn't work on Solaris due to tar/gtar - * #76 - Fixes Invalid Subversion URL - * Improved web:disable task, now suggests a .htaccess block to use suggested by Rafael García - * Includes more logger options (can now select stdout, stderr of a file) [Rafael García] - * Fixes a couple of documentation problems, typos and worse. [Lee Hambley] - -== 2.5.8 / July 2009 - -* Fixes a problem in 2.5.7 where deploy:finalize_update had been badly merged. - -== 2.5.6 & 2.5.7 / July 2009 - -* 2.5.7 masks a broken 2.5.6 release that was accidentally mirrored via Rubyforge. - -* Clean the cached git repository [Graeme Mathieson] - -* Fixes perforce issues reported at http://bit.ly/wt0es [Scott Johnson] - -* Improved back-tick handling code in relation to the above. - -* Fixes a Git issue when submodules update upstream. (via mailing list) [sneakin] - -* Capify now creates the config directory in directories without one. - -== 2.5.5 / 24 Feb 2009 - -* Make sure role(:foo) actually declares an (empty) role for :foo, even without server arguments [Jamis Buck] - - -== 2.5.4 / 4 Feb 2009 - -* When using rsync with the remote_cache strategy include -t switch to preserve file times [Kevin McCarthy] - -* Bump Net::SSH dependency to version 2.0.10 [Jamis Buck] - -* Use 'user' from .ssh/config appropriately [Jamis Buck] - -* Allow respond_to?() method to accept optional second parameter (include_priv) [Matthias Marschall] - -* Make sure sudo prompts are retried correctly even if "try again" and the prompt appear in the same text chunk from the server [Jamis Buck] - -* Add supported environment variables to -H output [François Beausoleil] - - -== 2.5.3 / December 6, 2008 - -* Make previous_release return nil if there is no previous release [Mathias Meyer] - -* Play nice with rubies that don't inspect terminals well (ie. JRuby) by defaulting screen columns to 80 [Bob McWhirter] - -* Rollback of deploy:symlink would explode if there was no previous revision to rollback to [Jamis Buck] - -* Fix bug in transfer.rb that caused get/put/upload/download to ignore blocks passed to them [arika] - -* Fix issue with git SCM that caused "Unable to resolve revision" errors when there was trailing whitespace in git's output [Mark Zuneska, Daniel Berlinger and Evan Closson] - - -== 2.5.2 / November 13, 2008 - -* Fix issue with git SCM that caused "Unable to resolve revision for 'HEAD'" errors on deploy [Jamis Buck] - - -== 2.5.1 / November 7, 2008 - -* Add -t (--tools) switch for better task lists for external tools [Jamis Buck] - -* Make the RemoteDependency#try method use invoke_command instead of run, for sudo-ability [Matthias Marschall] - -* Make locally executed commands in Windows more Windows-friendly [esad@esse.at] - -* Added :scm_arguments variable for custom SCM arguments (subversion-only, currently) [David Abdemoulaie] - -* Don't emit -p for sudo when :sudo_prompt is blank [Matthias Marschall] - -* Copy symlinks when using rsync [Paul Paradise] - -* Make sure git query-revision matches on exact branch name [grant@nightriot.com] - -* Use -T to filter listed tasks by a pattern [Mathias Meyer, Geoffrey Grosenbach] - -* Expose the #scm method on SCM::Base for building custom scm commands [Mathias Meyer] - -* Start logging some locally executed commands [springyweb] - -* Added HOSTFILTER environment variable for constraining tasks so they run only on hosts matching the given list of servers [Walter Smith] - -* Make sure the glob matching for copy excludes does not delete parent directories [Fabio Akita] - -* Ruby 1.9 compatibility [Jamis Buck] - - -== 2.5.0 / August 28, 2008 - -* Allow :gateway to be set to an array, in which case a chain of tunnels is created [Kerry Buckley] - -* Allow HOSTS spec to override even non-existent roles [Mike Bailey] - -* Sort releases via "ls -xt" instead of "ls -x" to allow for custom release names [Yan Pritzker] - -* Convert arguments to -s and -S into integers, booleans, etc. based on whether the arguments appear to be those types [Jamis Buck] - -* Add descriptions of -n and -d to the verbose help text [Jamis Buck] - -* Make rollbacks work with processes that need the current directory to be valid in order to restart properly (e.g. mongrel_rails) [Jamis Buck] - -* Rename deploy:rollback_code to deploy:rollback:code [Jamis Buck] - -* Added parallel() helper for executing multiple different commands in parallel [Jamis Buck] - -* Make sure a task only uses the last on_rollback block, once, on rollback [Jamis Buck] - -* Add :shared_children variable to customize which subdirectories are created by deploy:setup [Jonathan Share] - -* Allow filename globbing in copy_exclude setting for the copy strategy [Jonathan Share] - -* Allow remote_cache strategy to use copy_exclude settings (requires rsync) [Lewis Mackenzie] - -* Make None SCM module work in Windows [Carlos Kozuszko] - -* Recognize mingw as a Windows platform [Carlos Kozuszko] - -* Fixed failing tests in Windows [Carlos Kozuszko] - -* Made :scm_auth_cache control whether password option is emitted in subversion module [Brendan Schwartz] - -* Fixed timestamp bug in CVS module [Jørgen Fjeld] - -* Added -n/--dry-run switch, to display but not execute remote tasks [Paul Gross] - - -== 2.4.3 / June 28, 2008 - -* Fix gem dependencies so gem actually understands them [Jamis Buck] - - -== 2.4.2 / June 27, 2008 - -* Specify gem dependencies in rakefile [Jamis Buck] - - -== 2.4.1 / June 27, 2008 - -* Use Echoe to manage the Rakefile [Jamis Buck] - -* Let Net::SSH manage the default SSH port selection [Ben Lavender] - -* Changed capture() helper to not raise an exception on error, but to warn instead [Jeff Forcier] - - -== 2.4.0 / June 13, 2008 - -* Added :normalize_asset_timestamps option to deployment, defaulting to true, which allows asset timestamping to be disabled [John Trupiano] - - -== 2.4.0 Preview Release #1 (2.3.101) / June 5, 2008 - -* Only make deploy:start, deploy:stop, and deploy:restart try sudo as :runner. The other sudo-enabled tasks (deploy:setup, deploy:cleanup, etc.) will now use the :admin_runner user (which by default is unset). [Jamis Buck] - -* Make sure triggers defined as a block inherit the scope of the task they are attached to, instead of the task they were called from [Jamis Buck] - -* Make deploy:upload use the upload() helper for more efficient directory processing [Jamis Buck] - -* Make deploy:upload accept globs [Mark Imbriaco] - -* Make sure the host is reported with the output from scm_run [Jamis Buck] - -* Make git SCM honor the :scm_verbose option [Jamis Buck] - -* Don't follow symlinks when using :copy_cache [Jamis Buck] - -* If :mode is given to upload() helper, do a chmod after to set the mode [Jamis Buck] - -* Fix load_from_file method for windows users [Neil Wilson] - -* Display a deprecation error if a remote git branch is specified [Tim Harper] - -* Fix deployment recipes to use the updated sudo helper [Jamis Buck] - -* Enhance the sudo helper so it can be used to return the command, instead of executing it [Jamis Buck] - -* Revert "make sudo helper play nicely with complex command chains", since it broke stuff [Jamis Buck] - -* Make set(:default_shell, false) work for not using a shell on a per-command basis [Ryan McGeary] - -* Improved test coverage [Ryan McGeary] - -* Fixed "coverage" take task [Ryan McGeary] - -* Use upload() instead of put() with the copy strategy [Jamis Buck] - -* Revert the "git fetch --tags" change, since it didn't work as expected [Jamis Buck] - -* Fix deploy:pending when using git SCM [Ryan McGeary] - -* Make sure deploy:check works with :none scm (which has no default command) [Jamis Buck] - -* Add debug switch for enabling conditional execution of commands [Mark Imbriaco] - - -== 2.3.0 / May 2, 2008 - -* Make deploy:setup obey the :use_sudo and :runner directives, and generalize the :use_sudo and :runner options into a try_sudo() helper method [Jamis Buck] - -* Make sudo helper play nicely with complex command chains [Jamis Buck] - -* Expand file-transfer options with new upload() and download() helpers. [Jamis Buck] - -* Allow SCP transfers in addition to SFTP. [Jamis Buck] - -* Use Net::SSH v2 and Net::SSH::Gateway. [Jamis Buck] - -* Added #export method for git SCM [Phillip Goldenburg] - -* For query_revision, git SCM used git-rev-parse on the repo hosting the Capfile, which may NOT be the same tree as the actual source reposistory. Use git-ls-remote instead to resolve the revision for checkout. [Robin H. Johnson] - -* Allow :ssh_options hash to be specified per server [Jesse Newland] - -* Added support for depend :remote, :file to test for existence of a specific file [Andrew Carter] - -* Ensure that the default run options are mixed into the command options when executing a command from the cap shell [Ken Collins] - -* Added :none SCM module for deploying a specific directory's contents [Jamis Buck] - -* Improved "copy" strategy supports local caching and pattern exclusion (via :copy_cache and :copy_exclude variables) [Jamis Buck] - - -== 2.2.0 / February 27, 2008 - -* Fix git submodule support to init on sync [halorgium] - -* Add alternative server-centric role definition method [James Duncan Davidson] - -* Add support for password prompts from the Mercurial SCM [ches] - -* Add support for :max_hosts option in task definition or run() [Rob Holland ] - -* Distributed git support for better operability with remote_cache strategy [voidlock] - -* Use a default line length in help text if line length is otherwise too small [Jamis Buck] - -* Fix incorrect reference to the 'setup' task in task documentation [rajeshduggal] - -* Don't try to kill the spawner process on deploy:stop if no spawner process exists [Jamis Buck] - -* Dynamic roles (e.g. role(:app) { "host.name" }) [dmasover] - -* Implement Bzr#next_revision so that pending changes can be reported correctly [casret] - -* Use a proper export command for bzr SCM [drudru] - -* Use checkout instead of merge for git SCM [nuttycom] - -* Fix typo in Subversion SCM module, encountered when an update fails [kemiller] - -* Fix documentation typo in upload.rb [evolving_jerk] - -* Added test case to show that the :scm_command is honored by the git SCM module [grempe] - -* Fail gracefully when double-colons are used to delimit namespaces [richie] - -* Add support for :git_enable_submodules variable, to enable submodules with the git SCM [halorgium] - -* If subversion asks for a password, prompt as a last resort [Jamis Buck] - -* Use checkout --lightweight for bzr checkout, instead of branch [michiels] - -* Make sure bzr SCM works when revision is head (or unspecified) [michiels] - -* Support p4sync_flags and p4client_root variables for Perforce [gseidman] - -* Prepare for Net::SSH v2 by making sure Capistrano only tries to load Net::SSH versions less than 1.99.0 [Jamis Buck] - - -== 2.1.0 / October 14, 2007 - -* Default to 0664 instead of 0660 on upload [Jamis Buck] - -* Fix deploy:pending to query SCM for the subsequent revision so that it does not include the last deployed change [Jamis Buck] - -* Prefer 'Last Changed Rev' over 'Revision' when querying latest revision via Subversion [Jamis Buck] - -* Explicitly require 'stringio' in copy_test [mislav] - -* When Subversion#query_revision fails, give a more sane error [Jamis Buck] - -* Don't run the upgrade:revisions task on non-release servers [Jamis Buck] - -* Fix cap shell to properly recognize sudo prompt [Mark Imbriaco, barnaby, Jamis Buck] - -* Git SCM module [Garry Dolley, Geoffrey Grosenbach, Scott Chacon] - -* Use the --password switch for subversion by default, but add :scm_prefer_prompt variable (defaults to false) [Jamis Buck] - - -== 2.0.100 (2.1 Preview 1) / September 1, 2007 - -* capify-generated Capfile will autoload all recipes from vendor/plugins/*/recipes/*.rb [Graeme Mathieson] - -* Use sudo -p switch to set sudo password prompt to something predictable [Mike Bailey] - -* Allow independent configurations to require the same recipe file [Jamis Buck] - -* Set :shell to false to run a command without wrapping it in "sh -c" [Jamis Buck] - -* Don't request a pty by default [Jamis Buck] - -* Add a "match" remote dependency method [Adam Greene] - -* Allow auth-caching of subversion credentials to be enabled via :scm_auth_cache [tsmith] - -* Don't let a task trigger itself when used as the source for an "on" hook [Jamis Buck] - -* Avoid using the --password switch with subversion for security purposes [sentinel] - -* Add version_dir, current_dir, and shared_dir variables for naming the directories used in deployment [drinkingbird] - -* Use Windows-safe binary reads for reading file contents [Ladislav Martincik] - -* Add Accurev SCM support [Doug Barth] - -* Use the :runner variable to determine who to sudo as for deploy:restart [Graham Ashton] - -* Add Namespaces#top to always return a reference to the topmost namespace [Jamis Buck] - -* Change the "-h" output so that it does not say that "-q" is the default [Jamis Buck] - - -== 2.0.0 / July 21, 2007 - -* Make the "no matching servers" error more sane [halorgium] - -* Make sure the invoke task gives a sane error when the COMMAND value is omitted [halorgium] - -* Make sure variables are conditionally set in the deploy recipes, so as not to clobber values set elsewhere [Jamis Buck] - -* Fix "input stream is empty" errors from HighLine on prompt [Jamis Buck] - -* Added "synchronous_connect" setting to try and work around SFTP hangs for certain users [Jamis Buck] - -* Auto-require the SSH shell service, to avoid race conditions [Jamis Buck] - -* Add a millisecond sleep in upload to reduce CPU impact [Jamis Buck] - -* Allow the logger to be set via Configuration#logger= [Jamis Buck] - -* Allow $CAPISTRANO:HOST$ to be used in filenames to the put command [Jamis Buck] - -* Allow execute_on_servers to be called without a current task again [Jamis Buck] - -* Put $stdout in sync mode, so that Net::SSH prompts are displayed [Jamis Buck] - -* Make sure deploy:check aborts if it fails [Jamis Buck] - -* Spelling corrections in docs [Tim Carey-Smith, Giles Bowkett] - - -== 1.99.3 (2.0 Preview 4) / June 28, 2007 - -* Don't break task descriptions on a period that appears in the middle of a sentence [Jamis Buck] - -* Added support for :on_error => :continue in task definitions, allowing tasks to effectively ignore connection and execution errors that occur as they run [Rob Holland] - -* Use correct parameters for Logger constructor in the SCM and Strategy base initializers [Jamis Buck] - -* Set LC_ALL=C before querying the revision, to make sure the output is in a predictable locale and can be parsed predictably [via Leandro Nunes dos Santos] - -* Add :copy_remote_dir variable for the :copy strategy, to indicate where the archive should be copied to on the remote servers [Jamis Buck] - -* Make the awk use in the dependencies code work with POSIX awk [mcornick] - -* Make variable accesses thread safe [via Adrian Danieli] - -* Make user input for yes/no prompts work correctly in the Mercurial module [Matthew Elder] - -* Use single quotes to escape semicolon in find command, instead of a backslash [via michael.italia@gmail.com] - -* Better quoting of reserved characters in commands [Jamis Buck] - -* Make sure Net::SSH versions prior to 1.1.0 still work [Jamis Buck] - -* Allow the :hosts and :roles keys to accept lambdas, which will be evaluated lazily to allow runtime selection of hosts and roles in tasks [Jamis Buck] - -* Use `which' to test whether a command exists in the remote path, instead of `test -p' [Jamis Buck] - -* Make sure the connection factory is established synchronously, to avoid multiple gateway instances being spawned [Jamis Buck] - -* Make sure symlink and finalize_update tasks reference the most recent release when called by themselves [Jamis Buck] - - -== 1.99.2 (2.0 Preview 3) / June 15, 2007 - -* CVS SCM module [Brian Phillips] - -* Fix typo in Perforce SCM module [Chris Bailey] - -* ssh_options < server options when connecting [Jamis Buck] - -* Logger defaults to $stderr instead of STDERR [lhartley] - -* Use cp -RPp instead of -a in the remote cache strategy - -* Make the UploadError exception include an array of the hosts that failed [rob@inversepath.com] - -* Allow "empty" roles to be declared [Jamis Buck] - -* Mercurial SCM module [Tobias Luetke, Matthew Elder] - -* Invoke all commands via sh (customizable via :default_shell) [Jamis Buck] - -* Make sure all directories exist on each deploy which are necessary for subsequent commands to succeed, since some SCM's won't save empty directories [Matthew Elder] - -* Add :default_environment variable, which is applied to every command - - -== 1.99.1 (2.0 Preview 2) / May 10, 2007 - -* Fix some documentation typos [eventualbuddha] - -* Don't retry failed connections if an explicit auth_methods list is given [Chris Farms] - -* Added support for load and exit callbacks, which get invoked when all recipes have been loaded and when all requested tasks have been executed [Jamis Buck] - -* Added support for start and finish callbacks, which get invoked when any task is called via the command-line [Jamis Buck] - -* Make `capify' understand simple command-line switches [Jamis Buck] - -* Make the server definition itself available to SSH channels, rather than just the host name [Jamis Buck] - -* Identify servers by their complete credentials in logs, rather than simply by hostname [Jamis Buck] - -* Uniquely identify servers based on hostname, port, and username, instead of merely on hostname [Jamis Buck] - -* Allow (e.g.) scm_command and local_scm_command to be set in the event of different paths to the scm command on local vs. remote hosts. [Jamis Buck] - -* Kill the "deploy:app" namespace and move those tasks into deploy, directly. [Jamis Buck] - -* Make sure 'desc' applies to the next defined task, in any namespace. [Jamis Buck] - -* Fix shell so that servers for a task are correctly discovered. [Jamis Buck] - -* Added before(), after(), and on() callback creation methods. [Jamis Buck] - -* Fix broken check! method for some deployment strategies. [Jamis Buck] - -* deploy:cold should also run migrations before starting the app [Jamis Buck] - -* Make the copy strategy check out to a temporary directory [Jamis Buck] - - -== 1.99.0 (2.0 Preview 1) / April 24, 2007 - -* Add `capify' script to make it easier to prepare a project for deployment using cap [Jamis Buck] - -* Make sure the sudo helper understands the SuSE dialect of the sudo password prompt [Steven Wisener] - -* Fix synchronization issue with Gateway initialization [Doug Barth] - -* Added opt-in "compat" and "upgrade" recipes for tasks to aid in the upgrade process to Capistrano 2 [Jamis Buck] - -* The deployment recipes are now opt-in. Just do 'load "deploy"' in your recipe script. [Jamis Buck] - -* Added $CAPISTRANO:HOST$ placeholder in commands, which will be replaced with the name of the host on which the command is executing [Jamis Buck] - -* Added -e switch to explain specific task. Added -X to extend -x. Made -h much briefer. Added -T to list known tasks. [Jamis Buck] - -* Added namespaces for tasks [Jamis Buck] - -* Merged the Configuration and Actor classes, performed various other massive refactorings of the code [Jamis Buck] - - -== 1.4.1 / February 24, 2007 - -* Use the no-auth-cache option with subversion so that username/password tokens do not get cached by capistrano usage [jonathan] - -* Deprecated upper-cased variables [Jamis Buck] - -* Make sure Actor#get does not close the SFTP channel (so subsequent SFTP operations work) [Dov Murik] - -* Add :env option to 'run' (and friends) so that you can specify environment variables to be injected into the new process' environment [Mathieu Lajugie] - - -== 1.4.0 / February 3, 2007 - -* Use the auth info for subversion more consistently [Jamis Buck] - -* Add a "capture" helper, for capturing the stdout of a remote command and returning it as a string [Jamis Buck] - -* Add a "get" helper, to pull a file from a remote server to the localhost [bmihelac] - -* Fix gateway to actually increment local_port if a port is in use, so that multiple capistrano instances can run at the same time [Mark Imbriaco] - -* Refactor the permissions tweaking in update_code to a separate task so that people on shared hosts can override it as necessary [jaw6] - -* Set umask during the setup task, so that intermediate directories are created with the proper permissions [NeilW] - -* Removed -c/--caprc switch, since the new load order renders it meaningless (just use -f now) [Mike Bailey] - -* Make sure the standard recipe loads first, so that .caprc and friends can override what it defines. [Mike Bailey] - -* Add support for a system-wide capistrano config file [Mike Bailey] - -* Make cold_deploy call update instead of deploy (to avoid invoking the restart task). - -* Make the touch command run by update_code set the TZ to UTC, for consistent setting of asset timestamps. [NeilW] - -* Fix off-by-one bug in show_tasks width-computation [NeilW] - - -== 1.3.1 / January 5, 2007 - -* Fix connection problems when using gateways [Ezra Zygmuntowicz] - - -== 1.3.0 / December 23, 2006 - -* Deprecate rake integration in favor of invoking `cap' directly [Jamis Buck] - -* Make sure the CVS module references the repository explicitly in cvs_log [weyus@att.net] - -* Remove trace messages when loading a file [Jamis Buck] - -* Cleaner error messages for authentication failures and command errors [Jamis Buck] - -* Added support for ~/.caprc, also -x and -c switches. [Jamis Buck] - -* Updated migrate action to use db:migrate task in Rails instead of the deprecated migrate task [DHH] - -* Allow SSH user and port to be encoded in the hostname strings [Ezra Zygmuntowicz] - -* Fixed that new checkouts were not group-writable [DHH, Jamis Buck] - -* Fixed that cap setup would use 755 on the deploy_to and shared directory roots instead of 775 [DHH] - -* Don't run the cleanup task on servers marked no_release [Jamis Buck] - -* Fix typo in default_io_proc so it correctly checks the stream parameter to see if it is the error stream [Stephen Haberman] - -* Make sure assets in images, javascripts, and stylesheets are touched after updating the code, to ensure the asset timestamping feature of rails works correctly [Jamis Buck] - -* Added warning if password is prompted for and termios is not installed [John Labovitz] - -* Added :as option to sudo, so you can specify who the command is executed as [Mark Imbriaco] - - -== 1.2.0 / September 14, 2006 - -* Add experimental 'shell' task [Jamis Buck] - -* Display file for external configurations, rather than inspected proc. [Jamis Buck] - -* Connect to multiple servers in parallel, rather than serially. [Jamis Buck] - -* Add SCM module for Mercurial (closes #4150) [Matthew Elder] - -* Remove unused line in SCM::Base (closes #5619) [chris@seagul.co.uk] - -* More efficient "svn log" usage (closes #5620) [Anatol Pomozov] - -* Better support for key passphrases in the SVN module (closes #5920) [llasram@gmail.com] - -* Fix missing default for :local in cvs.rb (closes #3645) [jeremy@hinegardner.org] - -* Fix awkward spacing in gemspec file (closes #3888) [grant@antiflux.org] - -* Add support for :sudo variable to specify path to sudo (closes #4578) [timothee.peignier@tryphon.org] - -* Make previous_release return nil if there are no previous releases (closes #4959) [bdabney@cavoksolutions.com] - -* Uncache releases list after update_code is called so that newly released dir is included (closes #3766) [Jamis Buck] - -* Allow the subversion scm to accept HTTPS certificates (closes #4792) [Jamis Buck] - -* Make sure rollbacks occur within the scope of the task that triggered them [Jamis Buck] - -* Fixed the default recipe to work with setups that haven't yet gone pids [DHH] - -* Symlink and setup for shared/pids to tmp/pids [DHH] - -* Fix some incorrect usage text (closes #4507) [gerry_shaw@yahoo.com] - -* Added Actor#stream method that makes it easy to create cross-server streams [DHH]. Example: - - desc "Run a tail on multiple log files at the same time" - task :tail_fcgi, :roles => :app do - stream "tail -f #{shared_path}/log/fastcgi.crash.log" - end - -* Make update_code and symlink a macro task under the name "update" for easy of deploy to servers that does not run fcgis [DHH] - -* Changed setup, update_code, rollback_code, and symlink to work on all servers instead of only those in the :app, :web, and :db roles. A server can opt out of being part of the release deployment by setting :no_release => true [DHH] - -* Added support for :except on task declarations as the opposite of :only [DHH]. Example: - - role :app, "192.168.0.2" - role :file, "192.168.0.3", :no_release => true - - task :symlink, :except => { :no_release => true } do - on_rollback { run "ln -nfs #{previous_release} #{current_path}" } - run "ln -nfs #{current_release} #{current_path}" - end - - cap symlink # will not run on 192.168.0.3 - -* Deprecate the -r/--recipe switch in favor of -f/--file (for more make/rake-like semantics) [Jamis Buck] - -* Fix gemspec to include a dependency on rake 0.7 [Jamis Buck] - -* Added respect for ENV["HOSTS"] that'll be used instead of the roles specified in the task definition [DHH]. Example: - - HOSTS=192.168.0.1 cap setup # one-off setup for that server, doesn't need to be prespecified in the recipes file - -* Added respect for ENV["ROLES"] that'll be used instead of the roles specified in the task definition [DHH]. Example: - - task :setup, :roles => [ :app, :web, :db ] - # normally this would run every where - end - - ROLES=app cap setup # this will only run for the app role, overwritting the default declaration - -* Added :hosts option to task definition that allows you to specify cross-cutting tasks [DHH]. Example: - - task :setup, :hosts => [ "06.example.com", "01.example.com" ] do - # this task will happen on 06 and 01 regardless of which roles they belong to - end - -* Fix operator precedence problem in script for touching the revisions.log #3223 [jason.garber@emu.edu] - - -== 1.1.0 / March 6th, 2006 - -* Simplify the generated capistrano.rake file, and make it easier to customize - -* Use rake-like command-line semantics ("cap deploy", in addition to "cap -a deploy") - -* Rename to capistrano - -* Make the generated capistrano.rake file use rake namespaces, and include all default tasks - -* Look for config/deploy.rb, capfile, and Capfile by default - - -== 1.0.1 / February 20th, 2006 - -* Fix broken switchtower_invoke function in switchtower.rake (missing require statement) - - -== 1.0.0 / Feburary 18th, 2006 - -* Make CVS module's :local value default to "." - -* Add "invoke" task for executing one-off commands - -* Make port selection smarter for gateway connections - -* Add extension mechanism for custom ST operations and third-party task libraries - -* Make ST rails rake tasks more configurable - -* Add Actor#current_task and simplify Task#servers - -* Add Actor#connect! method for working around lazy connection establishing - -* Make sure IO::TRUNC is specified for Net::SFTP uploads (#3510) - -* Add branch support to CVS [jeremy@hinegardner.org] (#3596) - -* Add bazaar-ng SCM module [Damien Merenne] - -* Add optional :svn_username and :svn_password variables - -* Allow Proc-valued variables to be set more conveniently (set(:foo) { "bar" }) - -* Add perforce SCM module [Richard McMahon] - -* Add bazaar (v1) SCM module [Edd Dumbill] (#3533) - -* Fix stftime format string used in CVS module to be Windows-compatible (fixes #3383) - -* Add an better error when a task is run and no servers match the required conditions - -* Add default spinner and cold_deploy tasks, and spinner_user variable - -* Changed restart_via variable to (boolean) use_sudo - -* Only chmod when the revisions.log file is first created - -* Make UPPERCASE variables work - -* Added rails_env variable (defaults to production) for use by tasks that employ the RAILS_ENV environment variable - -* Added Actor.default_io_proc - -* Set :actor key on SSH channel instances - - -== 0.10.0 / January 2nd, 2006 - -* Handle ssh password prompts like "someone's password:" - -* Make CLI#echo available as a class method. - -* Add CLI#with_echo. - -* Make the default password prompt available as a class method. - -# Add documentation for the CLI class. - -* Add a sanity check to make sure the correct versions of Net::SSH and Net::SFTP are installed. - -* Added a cleanup task to remove unused releases from the deployment directory - -* Allow password to be reentered on sudo if it was entered incorrectly - -* Use && as the command separator for the checkouts, so that errors are caught early. - -* Ping each SSH connection every 1s during command processing so that long-running commands don't cause the connection to timeout. - -* Add a 0.01s sleep during the command loop so that the CPU doesn't go ballistic while ST is doing its thing. - -* Add :restart_via variable for specifying whether restart ought to use :sudo (default, use sudo) - -* Use SFTP for file transfers (if available). - -* Add an "update_current" task that will do an svn up on the current release - -* Use the :checkout variable to determine what operation to use for svn checkouts (instead of co, like "export"). - -* The Rails rake tasks now load ST directly, instead of invoking it via system - -* Added ssh_options variable to configure the SSH connection parameters #2734 [jerrett@bravenet.com] - -* Require Net::SSH 1.0.5 - - -== 0.9.0 / October 18th, 2005 - -* Use process reaper instead of custom reap script for restarting - -* Use -S switch to set variables before reading recipe files #2242 - -* Have setup.rb create a switchtower.cmd file on Win32 platforms #2402 - -* Add diff_from_last_deploy to the rails switchtower rakefile template - -* Add diff_from_last_deploy task (currently only works with subversion) - -* Add deploy_with_migrations task. - -* Make the migrate task more customizable. - -* If no password is given with the -p switch, prompt for password immediately. - -* Do not install a switchtower stub in the script directory. Assume the switchtower executable is in the path. - -* Remove trailing newlines from commands to prevent trailing backslash #2141 - -* Default parameters work correctly with the generator #2218 [Scott Barron] - -* Attempt to require 'rubygems' explicitly when running the switchtower utility #2134 - -* Make default tasks work only on app/db/web roles, so that additional roles may be created for boxes with specific needs without needing to (for instance) deploy the app to those boxes - -* Default the application name to "Application" when using --apply-to - -* Show the help screen instead of an error when no arguments are given - -* Make SwitchTower easier to invoke programmatically via SwitchTower::CLI - -* Specify the revision to release via the :revision variable (defaults to latest revision) - -* Allow variables to be set via the cli using the -s switch - -* Log checkouts to a "revisions.log" file - -* Changed behavior of checkout to use the timestamp as the release name, instead of the revision number - -* Added CVS module (very very experimental!) - -* Works with public keys now, for passwordless deployment - -* Subversion module recognizes the password prompt for HTTP authentication - -* Preserve +x on scripts when using darcs #1929 [Scott Barron] - -* When executing multiline commands, use a backslash to escape the newline diff --git a/vendor/gems/capistrano-2.5.9/Manifest b/vendor/gems/capistrano-2.5.9/Manifest deleted file mode 100644 index 5ffbdf0c0..000000000 --- a/vendor/gems/capistrano-2.5.9/Manifest +++ /dev/null @@ -1,104 +0,0 @@ -bin/cap -bin/capify -CHANGELOG.rdoc -examples/sample.rb -lib/capistrano/callback.rb -lib/capistrano/cli/execute.rb -lib/capistrano/cli/help.rb -lib/capistrano/cli/help.txt -lib/capistrano/cli/options.rb -lib/capistrano/cli/ui.rb -lib/capistrano/cli.rb -lib/capistrano/command.rb -lib/capistrano/configuration/actions/file_transfer.rb -lib/capistrano/configuration/actions/inspect.rb -lib/capistrano/configuration/actions/invocation.rb -lib/capistrano/configuration/callbacks.rb -lib/capistrano/configuration/connections.rb -lib/capistrano/configuration/execution.rb -lib/capistrano/configuration/loading.rb -lib/capistrano/configuration/namespaces.rb -lib/capistrano/configuration/roles.rb -lib/capistrano/configuration/servers.rb -lib/capistrano/configuration/variables.rb -lib/capistrano/configuration.rb -lib/capistrano/errors.rb -lib/capistrano/extensions.rb -lib/capistrano/logger.rb -lib/capistrano/processable.rb -lib/capistrano/recipes/compat.rb -lib/capistrano/recipes/deploy/dependencies.rb -lib/capistrano/recipes/deploy/local_dependency.rb -lib/capistrano/recipes/deploy/remote_dependency.rb -lib/capistrano/recipes/deploy/scm/accurev.rb -lib/capistrano/recipes/deploy/scm/base.rb -lib/capistrano/recipes/deploy/scm/bzr.rb -lib/capistrano/recipes/deploy/scm/cvs.rb -lib/capistrano/recipes/deploy/scm/darcs.rb -lib/capistrano/recipes/deploy/scm/git.rb -lib/capistrano/recipes/deploy/scm/mercurial.rb -lib/capistrano/recipes/deploy/scm/none.rb -lib/capistrano/recipes/deploy/scm/perforce.rb -lib/capistrano/recipes/deploy/scm/subversion.rb -lib/capistrano/recipes/deploy/scm.rb -lib/capistrano/recipes/deploy/strategy/base.rb -lib/capistrano/recipes/deploy/strategy/checkout.rb -lib/capistrano/recipes/deploy/strategy/copy.rb -lib/capistrano/recipes/deploy/strategy/export.rb -lib/capistrano/recipes/deploy/strategy/remote.rb -lib/capistrano/recipes/deploy/strategy/remote_cache.rb -lib/capistrano/recipes/deploy/strategy.rb -lib/capistrano/recipes/deploy/templates/maintenance.rhtml -lib/capistrano/recipes/deploy.rb -lib/capistrano/recipes/standard.rb -lib/capistrano/recipes/templates/maintenance.rhtml -lib/capistrano/recipes/upgrade.rb -lib/capistrano/role.rb -lib/capistrano/server_definition.rb -lib/capistrano/shell.rb -lib/capistrano/ssh.rb -lib/capistrano/task_definition.rb -lib/capistrano/transfer.rb -lib/capistrano/version.rb -lib/capistrano.rb -Rakefile -README.rdoc -setup.rb -test/cli/execute_test.rb -test/cli/help_test.rb -test/cli/options_test.rb -test/cli/ui_test.rb -test/cli_test.rb -test/command_test.rb -test/configuration/actions/file_transfer_test.rb -test/configuration/actions/inspect_test.rb -test/configuration/actions/invocation_test.rb -test/configuration/callbacks_test.rb -test/configuration/connections_test.rb -test/configuration/execution_test.rb -test/configuration/loading_test.rb -test/configuration/namespace_dsl_test.rb -test/configuration/roles_test.rb -test/configuration/servers_test.rb -test/configuration/variables_test.rb -test/configuration_test.rb -test/deploy/local_dependency_test.rb -test/deploy/remote_dependency_test.rb -test/deploy/scm/accurev_test.rb -test/deploy/scm/base_test.rb -test/deploy/scm/git_test.rb -test/deploy/scm/mercurial_test.rb -test/deploy/strategy/copy_test.rb -test/extensions_test.rb -test/fixtures/cli_integration.rb -test/fixtures/config.rb -test/fixtures/custom.rb -test/logger_test.rb -test/role_test.rb -test/server_definition_test.rb -test/shell_test.rb -test/ssh_test.rb -test/task_definition_test.rb -test/transfer_test.rb -test/utils.rb -Manifest diff --git a/vendor/gems/capistrano-2.5.9/README.rdoc b/vendor/gems/capistrano-2.5.9/README.rdoc deleted file mode 100644 index 02b2c9e30..000000000 --- a/vendor/gems/capistrano-2.5.9/README.rdoc +++ /dev/null @@ -1,102 +0,0 @@ -= Capistrano - -Capistrano is a utility and framework for executing commands in parallel on multiple remote machines, via SSH. It uses a simple DSL (borrowed in part from Rake, http://rake.rubyforge.org/) that allows you to define _tasks_, which may be applied to machines in certain roles. It also supports tunneling connections via some gateway machine to allow operations to be performed behind VPN's and firewalls. - -Capistrano was originally designed to simplify and automate deployment of web applications to distributed environments, and originally came bundled with a set of tasks designed for deploying Rails applications. The deployment tasks are now (as of Capistrano 2.0) opt-in and require clients to explicitly put -"load 'deploy'" in their recipes. - -== Documentation - -We know that documentation is something that really lets us down, that's why there is a repository for a handbook below, please open an issue on it if you would like something documented: - -* http://github.com/leehambley/capistrano-handbook - -If you prefer the wiki style of documentation, then please see our wiki - -* http://wiki.capify.org - -Due to a failure of MySQL with PHP, searches shorter than three characters are all but ignored, we're going to rectify this, but in the meantime, please do what you can, tickets opened on the handbook for the wiki will be answered too, so please let us know if you don't find something you needed. - -We take bug reports via lighthouse app, you can find that page here: - -* http://capistrano.lighthouseapp.com - -More documentation is on the way, if in doubt try opening the recipes that ship with capistrano. - -== DEPENDENCIES - -* Net::SSH v2 (http://net-ssh.rubyforge.org) -* Net::SFTP v2 (http://net-ssh.rubyforge.org) -* Net::SCP v1 (http://net-ssh.rubyforge.org) -* Net::SSH::Gateway v1 (http://net-ssh.rubyforge.org) -* HighLine (http://highline.rubyforge.org) - -If you want to run the tests, you'll also need to have the following dependencies installed: - -* Echoe (for the Rakefile) -* Mocha (http://mocha.rubyforge.org) - -== ASSUMPTIONS - -Capistrano is "opinionated software", which means it has very firm ideas about how things ought to be done, and tries to force those ideas on you. Some of the assumptions behind these opinions are: - -* You are using SSH to access the remote servers. -* You either have the same password to all target machines, or you have public keys in place to allow passwordless access to them. - -Do not expect these assumptions to change. - -== USAGE - -In general, you'll use Capistrano as follows: - -* Create a recipe file ("capfile" or "Capfile"). -* Use the +cap+ script to execute your recipe. - -Use the +cap+ script as follows: - - cap sometask - -By default, the script will look for a file called one of +capfile+ or +Capfile+. The +someaction+ text indicates which task to execute. You can do "cap -h" to see all the available options and "cap -T" to see all the available tasks. - -== Capistrano Edge - -If you want to try Capistrano code that hasn't been formerly released yet, this repository now includes a gemspec that should build what you need, here's how to get a copy: - - git clone git://github.com/capistrano/capistrano.git capistrano-capistrano - cd capistrano-capsitrano - rake package - sudo gem install pkg/capistrano-*.gem - -This will install the most recent version of capistrano and make it available for both cap, and capify. - -We recommend that you capify a new test application, as the resulting files are different to previous versions. - -If you have multiple versions of capistrano (or indeed any gem with a binary) installed, you can call `cap` like so to specify which version to use: - - cap _2.5.5_ deploy - cap _2.5.6_ deploy:setup - -== LICENSE: - -(The MIT License) - -Copyright (c) 2005-2008 Jamis Buck - -Permission is hereby granted, free of charge, to any person obtaining -a copy of this software and associated documentation files (the -'Software'), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, sublicense, and/or sell copies of the Software, and to -permit persons to whom the Software is furnished to do so, subject to -the following conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY -CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, -TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/vendor/gems/capistrano-2.5.9/Rakefile b/vendor/gems/capistrano-2.5.9/Rakefile deleted file mode 100644 index 75d5b8e81..000000000 --- a/vendor/gems/capistrano-2.5.9/Rakefile +++ /dev/null @@ -1,35 +0,0 @@ -require "./lib/capistrano/version" - -begin - require 'echoe' -rescue LoadError - abort "You'll need to have `echoe' installed to use Capistrano's Rakefile" -end - -version = Capistrano::Version::STRING.dup -if ENV['SNAPSHOT'].to_i == 1 - version << "." << Time.now.utc.strftime("%Y%m%d%H%M%S") -end - -Echoe.new('capistrano', version) do |p| - p.include_gemspec = true - p.changelog = "CHANGELOG.rdoc" - - p.author = ["Jamis Buck", "Lee Hambley"] - p.email = ["jamis@jamisbuck.org", "lee.hambley@gmail.com"] - - p.summary = <<-DESC.strip.gsub(/\n\s+/, " ") - Capistrano is a utility and framework for executing commands in parallel - on multiple remote machines, via SSH. - DESC - - p.url = "http://www.capify.org" - p.need_zip = true - p.rdoc_pattern = /^(lib|README.rdoc|CHANGELOG.rdoc)/ - - p.dependencies = ["net-ssh >=2.0.14", - "net-sftp >=2.0.0", - "net-scp >=1.0.0", - "net-ssh-gateway >=1.0.0", - "highline"] -end diff --git a/vendor/gems/capistrano-2.5.9/bin/cap b/vendor/gems/capistrano-2.5.9/bin/cap deleted file mode 100755 index 72e64b472..000000000 --- a/vendor/gems/capistrano-2.5.9/bin/cap +++ /dev/null @@ -1,4 +0,0 @@ -#!/usr/bin/env ruby - -require 'capistrano/cli' -Capistrano::CLI.execute diff --git a/vendor/gems/capistrano-2.5.9/bin/capify b/vendor/gems/capistrano-2.5.9/bin/capify deleted file mode 100755 index 38ef2e2d6..000000000 --- a/vendor/gems/capistrano-2.5.9/bin/capify +++ /dev/null @@ -1,86 +0,0 @@ -#!/usr/bin/env ruby - -require 'optparse' -require 'fileutils' - -OptionParser.new do |opts| - opts.banner = "Usage: #{File.basename($0)} [path]" - - opts.on("-h", "--help", "Displays this help info") do - puts opts - exit 0 - end - - begin - opts.parse!(ARGV) - rescue OptionParser::ParseError => e - warn e.message - puts opts - exit 1 - end -end - -if ARGV.empty? - abort "Please specify the directory to capify, e.g. `#{File.basename($0)} .'" -elsif !File.exists?(ARGV.first) - abort "`#{ARGV.first}' does not exist." -elsif !File.directory?(ARGV.first) - abort "`#{ARGV.first}' is not a directory." -elsif ARGV.length > 1 - abort "Too many arguments; please specify only the directory to capify." -end - -def unindent(string) - indentation = string[/\A\s*/] - string.strip.gsub(/^#{indentation}/, "") -end - -files = { - "Capfile" => unindent(<<-FILE), - load 'deploy' if respond_to?(:namespace) # cap2 differentiator - Dir['vendor/plugins/*/recipes/*.rb'].each { |plugin| load(plugin) } - - load 'config/deploy' # remove this line to skip loading any of the default tasks - FILE - - "config/deploy.rb" => 'set :application, "set your application name here" -set :repository, "set your repository location here" - -set :scm, :subversion -# Or: `accurev`, `bzr`, `cvs`, `darcs`, `git`, `mercurial`, `perforce`, `subversion` or `none` - -role :web, "your web-server here" # Your HTTP server, Apache/etc -role :app, "your app-server here" # This may be the same as your `Web` server -role :db, "your primary db-server here", :primary => true # This is where Rails migrations will run -role :db, "your slave db-server here" - -# If you are using Passenger mod_rails uncomment this: -# if you\'re still using the script/reapear helper you will need -# these http://github.com/rails/irs_process_scripts - -# namespace :deploy do -# task :start {} -# task :stop {} -# task :restart, :roles => :app, :except => { :no_release => true } do -# run "#{try_sudo} touch #{File.join(current_path,\'tmp\',\'restart.txt\')}" -# end -# end'} - -base = ARGV.shift -files.each do |file, content| - file = File.join(base, file) - if File.exists?(file) - warn "[skip] '#{file}' already exists" - elsif File.exists?(file.downcase) - warn "[skip] '#{file.downcase}' exists, which could conflict with `#{file}'" - else - unless File.exists?(File.dirname(file)) - puts "[add] making directory '#{File.dirname(file)}'" - FileUtils.mkdir(File.dirname(file)) - end - puts "[add] writing '#{file}'" - File.open(file, "w") { |f| f.write(content) } - end -end - -puts "[done] capified!" diff --git a/vendor/gems/capistrano-2.5.9/capistrano.gemspec b/vendor/gems/capistrano-2.5.9/capistrano.gemspec deleted file mode 100644 index 271c5049b..000000000 --- a/vendor/gems/capistrano-2.5.9/capistrano.gemspec +++ /dev/null @@ -1,48 +0,0 @@ -# -*- encoding: utf-8 -*- - -Gem::Specification.new do |s| - s.name = %q{capistrano} - s.version = "2.5.9" - - s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version= - s.authors = ["Jamis Buck, Lee Hambley"] - s.date = %q{2009-09-12} - s.description = %q{Capistrano is a utility and framework for executing commands in parallel on multiple remote machines, via SSH.} - s.email = ["jamis@jamisbuck.org", "lee.hambley@gmail.com"] - s.executables = ["cap", "capify"] - s.extra_rdoc_files = ["CHANGELOG.rdoc", "lib/capistrano/callback.rb", "lib/capistrano/cli/execute.rb", "lib/capistrano/cli/help.rb", "lib/capistrano/cli/help.txt", "lib/capistrano/cli/options.rb", "lib/capistrano/cli/ui.rb", "lib/capistrano/cli.rb", "lib/capistrano/command.rb", "lib/capistrano/configuration/actions/file_transfer.rb", "lib/capistrano/configuration/actions/inspect.rb", "lib/capistrano/configuration/actions/invocation.rb", "lib/capistrano/configuration/callbacks.rb", "lib/capistrano/configuration/connections.rb", "lib/capistrano/configuration/execution.rb", "lib/capistrano/configuration/loading.rb", "lib/capistrano/configuration/namespaces.rb", "lib/capistrano/configuration/roles.rb", "lib/capistrano/configuration/servers.rb", "lib/capistrano/configuration/variables.rb", "lib/capistrano/configuration.rb", "lib/capistrano/errors.rb", "lib/capistrano/extensions.rb", "lib/capistrano/logger.rb", "lib/capistrano/processable.rb", "lib/capistrano/recipes/compat.rb", "lib/capistrano/recipes/deploy/dependencies.rb", "lib/capistrano/recipes/deploy/local_dependency.rb", "lib/capistrano/recipes/deploy/remote_dependency.rb", "lib/capistrano/recipes/deploy/scm/accurev.rb", "lib/capistrano/recipes/deploy/scm/base.rb", "lib/capistrano/recipes/deploy/scm/bzr.rb", "lib/capistrano/recipes/deploy/scm/cvs.rb", "lib/capistrano/recipes/deploy/scm/darcs.rb", "lib/capistrano/recipes/deploy/scm/git.rb", "lib/capistrano/recipes/deploy/scm/mercurial.rb", "lib/capistrano/recipes/deploy/scm/none.rb", "lib/capistrano/recipes/deploy/scm/perforce.rb", "lib/capistrano/recipes/deploy/scm/subversion.rb", "lib/capistrano/recipes/deploy/scm.rb", "lib/capistrano/recipes/deploy/strategy/base.rb", "lib/capistrano/recipes/deploy/strategy/checkout.rb", "lib/capistrano/recipes/deploy/strategy/copy.rb", "lib/capistrano/recipes/deploy/strategy/export.rb", "lib/capistrano/recipes/deploy/strategy/remote.rb", "lib/capistrano/recipes/deploy/strategy/remote_cache.rb", "lib/capistrano/recipes/deploy/strategy.rb", "lib/capistrano/recipes/deploy/templates/maintenance.rhtml", "lib/capistrano/recipes/deploy.rb", "lib/capistrano/recipes/standard.rb", "lib/capistrano/recipes/templates/maintenance.rhtml", "lib/capistrano/recipes/upgrade.rb", "lib/capistrano/role.rb", "lib/capistrano/server_definition.rb", "lib/capistrano/shell.rb", "lib/capistrano/ssh.rb", "lib/capistrano/task_definition.rb", "lib/capistrano/transfer.rb", "lib/capistrano/version.rb", "lib/capistrano.rb", "README.rdoc"] - s.files = ["bin/cap", "bin/capify", "CHANGELOG.rdoc", "examples/sample.rb", "lib/capistrano/callback.rb", "lib/capistrano/cli/execute.rb", "lib/capistrano/cli/help.rb", "lib/capistrano/cli/help.txt", "lib/capistrano/cli/options.rb", "lib/capistrano/cli/ui.rb", "lib/capistrano/cli.rb", "lib/capistrano/command.rb", "lib/capistrano/configuration/actions/file_transfer.rb", "lib/capistrano/configuration/actions/inspect.rb", "lib/capistrano/configuration/actions/invocation.rb", "lib/capistrano/configuration/callbacks.rb", "lib/capistrano/configuration/connections.rb", "lib/capistrano/configuration/execution.rb", "lib/capistrano/configuration/loading.rb", "lib/capistrano/configuration/namespaces.rb", "lib/capistrano/configuration/roles.rb", "lib/capistrano/configuration/servers.rb", "lib/capistrano/configuration/variables.rb", "lib/capistrano/configuration.rb", "lib/capistrano/errors.rb", "lib/capistrano/extensions.rb", "lib/capistrano/logger.rb", "lib/capistrano/processable.rb", "lib/capistrano/recipes/compat.rb", "lib/capistrano/recipes/deploy/dependencies.rb", "lib/capistrano/recipes/deploy/local_dependency.rb", "lib/capistrano/recipes/deploy/remote_dependency.rb", "lib/capistrano/recipes/deploy/scm/accurev.rb", "lib/capistrano/recipes/deploy/scm/base.rb", "lib/capistrano/recipes/deploy/scm/bzr.rb", "lib/capistrano/recipes/deploy/scm/cvs.rb", "lib/capistrano/recipes/deploy/scm/darcs.rb", "lib/capistrano/recipes/deploy/scm/git.rb", "lib/capistrano/recipes/deploy/scm/mercurial.rb", "lib/capistrano/recipes/deploy/scm/none.rb", "lib/capistrano/recipes/deploy/scm/perforce.rb", "lib/capistrano/recipes/deploy/scm/subversion.rb", "lib/capistrano/recipes/deploy/scm.rb", "lib/capistrano/recipes/deploy/strategy/base.rb", "lib/capistrano/recipes/deploy/strategy/checkout.rb", "lib/capistrano/recipes/deploy/strategy/copy.rb", "lib/capistrano/recipes/deploy/strategy/export.rb", "lib/capistrano/recipes/deploy/strategy/remote.rb", "lib/capistrano/recipes/deploy/strategy/remote_cache.rb", "lib/capistrano/recipes/deploy/strategy.rb", "lib/capistrano/recipes/deploy/templates/maintenance.rhtml", "lib/capistrano/recipes/deploy.rb", "lib/capistrano/recipes/standard.rb", "lib/capistrano/recipes/templates/maintenance.rhtml", "lib/capistrano/recipes/upgrade.rb", "lib/capistrano/role.rb", "lib/capistrano/server_definition.rb", "lib/capistrano/shell.rb", "lib/capistrano/ssh.rb", "lib/capistrano/task_definition.rb", "lib/capistrano/transfer.rb", "lib/capistrano/version.rb", "lib/capistrano.rb", "Rakefile", "README.rdoc", "setup.rb", "test/cli/execute_test.rb", "test/cli/help_test.rb", "test/cli/options_test.rb", "test/cli/ui_test.rb", "test/cli_test.rb", "test/command_test.rb", "test/configuration/actions/file_transfer_test.rb", "test/configuration/actions/inspect_test.rb", "test/configuration/actions/invocation_test.rb", "test/configuration/callbacks_test.rb", "test/configuration/connections_test.rb", "test/configuration/execution_test.rb", "test/configuration/loading_test.rb", "test/configuration/namespace_dsl_test.rb", "test/configuration/roles_test.rb", "test/configuration/servers_test.rb", "test/configuration/variables_test.rb", "test/configuration_test.rb", "test/deploy/local_dependency_test.rb", "test/deploy/remote_dependency_test.rb", "test/deploy/scm/accurev_test.rb", "test/deploy/scm/base_test.rb", "test/deploy/scm/git_test.rb", "test/deploy/scm/mercurial_test.rb", "test/deploy/strategy/copy_test.rb", "test/extensions_test.rb", "test/fixtures/cli_integration.rb", "test/fixtures/config.rb", "test/fixtures/custom.rb", "test/logger_test.rb", "test/role_test.rb", "test/server_definition_test.rb", "test/shell_test.rb", "test/ssh_test.rb", "test/task_definition_test.rb", "test/transfer_test.rb", "test/utils.rb", "Manifest", "capistrano.gemspec", "test/deploy/scm/none_test.rb", "test/deploy/scm/subversion_test.rb"] - s.has_rdoc = true - s.homepage = %q{http://www.capify.org} - s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "Capistrano", "--main", "README.rdoc"] - s.require_paths = ["lib"] - s.rubyforge_project = %q{capistrano} - s.rubygems_version = %q{1.3.1} - s.summary = %q{Capistrano is a utility and framework for executing commands in parallel on multiple remote machines, via SSH.} - s.test_files = ["test/cli/execute_test.rb", "test/cli/help_test.rb", "test/cli/options_test.rb", "test/cli/ui_test.rb", "test/cli_test.rb", "test/command_test.rb", "test/configuration/actions/file_transfer_test.rb", "test/configuration/actions/inspect_test.rb", "test/configuration/actions/invocation_test.rb", "test/configuration/callbacks_test.rb", "test/configuration/connections_test.rb", "test/configuration/execution_test.rb", "test/configuration/loading_test.rb", "test/configuration/namespace_dsl_test.rb", "test/configuration/roles_test.rb", "test/configuration/servers_test.rb", "test/configuration/variables_test.rb", "test/configuration_test.rb", "test/deploy/local_dependency_test.rb", "test/deploy/remote_dependency_test.rb", "test/deploy/scm/accurev_test.rb", "test/deploy/scm/base_test.rb", "test/deploy/scm/git_test.rb", "test/deploy/scm/mercurial_test.rb", "test/deploy/scm/none_test.rb", "test/deploy/scm/subversion_test.rb", "test/deploy/strategy/copy_test.rb", "test/extensions_test.rb", "test/logger_test.rb", "test/role_test.rb", "test/server_definition_test.rb", "test/shell_test.rb", "test/ssh_test.rb", "test/task_definition_test.rb", "test/transfer_test.rb"] - - if s.respond_to? :specification_version then - current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION - s.specification_version = 2 - - if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then - s.add_runtime_dependency(%q, [">= 2.0.14"]) - s.add_runtime_dependency(%q, [">= 2.0.0"]) - s.add_runtime_dependency(%q, [">= 1.0.0"]) - s.add_runtime_dependency(%q, [">= 1.0.0"]) - s.add_runtime_dependency(%q, [">= 0"]) - else - s.add_dependency(%q, [">= 2.0.14"]) - s.add_dependency(%q, [">= 2.0.0"]) - s.add_dependency(%q, [">= 1.0.0"]) - s.add_dependency(%q, [">= 1.0.0"]) - s.add_dependency(%q, [">= 0"]) - end - else - s.add_dependency(%q, [">= 2.0.14"]) - s.add_dependency(%q, [">= 2.0.0"]) - s.add_dependency(%q, [">= 1.0.0"]) - s.add_dependency(%q, [">= 1.0.0"]) - s.add_dependency(%q, [">= 0"]) - end -end diff --git a/vendor/gems/capistrano-2.5.9/examples/sample.rb b/vendor/gems/capistrano-2.5.9/examples/sample.rb deleted file mode 100644 index 1e99e8df2..000000000 --- a/vendor/gems/capistrano-2.5.9/examples/sample.rb +++ /dev/null @@ -1,14 +0,0 @@ -# set :user, "flippy" -# set :password, "hello-flippy" -# set :gateway, "gateway.example.com" - -role :web, "web1.example.com" -role :app, "app1.example.com", "app2.example.com" - -desc <<-DESC -This is a sample task. It is only intended to be used as a demonstration of \ -how you can define your own tasks. -DESC -task :sample_task, :roles => :app do - run "ls -l" -end diff --git a/vendor/gems/capistrano-2.5.9/lib/capistrano.rb b/vendor/gems/capistrano-2.5.9/lib/capistrano.rb deleted file mode 100644 index 5bc32e870..000000000 --- a/vendor/gems/capistrano-2.5.9/lib/capistrano.rb +++ /dev/null @@ -1,2 +0,0 @@ -require 'capistrano/configuration' -require 'capistrano/extensions' \ No newline at end of file diff --git a/vendor/gems/capistrano-2.5.9/lib/capistrano/callback.rb b/vendor/gems/capistrano-2.5.9/lib/capistrano/callback.rb deleted file mode 100644 index deba05bc4..000000000 --- a/vendor/gems/capistrano-2.5.9/lib/capistrano/callback.rb +++ /dev/null @@ -1,45 +0,0 @@ -module Capistrano - class Callback - attr_reader :source, :options, :only, :except - - def initialize(source, options={}) - @source = source - @options = options - @only = Array(options[:only]).map { |v| v.to_s } - @except = Array(options[:except]).map { |v| v.to_s } - end - - def applies_to?(task) - if task && only.any? - return only.include?(task.fully_qualified_name) - elsif task && except.any? - return !except.include?(task.fully_qualified_name) - else - return true - end - end - end - - class ProcCallback < Callback - def call - source.call - end - end - - class TaskCallback < Callback - attr_reader :config - - def initialize(config, source, options={}) - super(source, options) - @config = config - end - - def call - config.find_and_execute_task(source) - end - - def applies_to?(task) - super && (task.nil? || task.fully_qualified_name != source.to_s) - end - end -end \ No newline at end of file diff --git a/vendor/gems/capistrano-2.5.9/lib/capistrano/cli.rb b/vendor/gems/capistrano-2.5.9/lib/capistrano/cli.rb deleted file mode 100644 index 81022b7e0..000000000 --- a/vendor/gems/capistrano-2.5.9/lib/capistrano/cli.rb +++ /dev/null @@ -1,47 +0,0 @@ -require 'capistrano' -require 'capistrano/cli/execute' -require 'capistrano/cli/help' -require 'capistrano/cli/options' -require 'capistrano/cli/ui' - -module Capistrano - # The CLI class encapsulates the behavior of capistrano when it is invoked - # as a command-line utility. This allows other programs to embed Capistrano - # and preserve its command-line semantics. - class CLI - # The array of (unparsed) command-line options - attr_reader :args - - # Create a new CLI instance using the given array of command-line parameters - # to initialize it. By default, +ARGV+ is used, but you can specify a - # different set of parameters (such as when embedded cap in a program): - # - # require 'capistrano/cli' - # Capistrano::CLI.parse(%w(-vvvv -r config/deploy update_code)).execute! - # - # Note that you can also embed cap directly by creating a new Configuration - # instance and setting it up, but you'll often wind up duplicating logic - # defined in the CLI class. The above snippet, redone using the Configuration - # class directly, would look like: - # - # require 'capistrano' - # require 'capistrano/cli' - # config = Capistrano::Configuration.new - # config.logger_level = Capistrano::Logger::TRACE - # config.set(:password) { Capistrano::CLI.password_prompt } - # config.load "config/deploy" - # config.update_code - # - # There may be times that you want/need the additional control offered by - # manipulating the Configuration directly, but generally interfacing with - # the CLI class is recommended. - def initialize(args) - @args = args.dup - $stdout.sync = true # so that Net::SSH prompts show up - end - - # Mix-in the actual behavior - include Execute, Options, UI - include Help # needs to be included last, because it overrides some methods - end -end diff --git a/vendor/gems/capistrano-2.5.9/lib/capistrano/cli/execute.rb b/vendor/gems/capistrano-2.5.9/lib/capistrano/cli/execute.rb deleted file mode 100644 index e78e7b7fa..000000000 --- a/vendor/gems/capistrano-2.5.9/lib/capistrano/cli/execute.rb +++ /dev/null @@ -1,84 +0,0 @@ -require 'capistrano/configuration' - -module Capistrano - class CLI - module Execute - def self.included(base) #:nodoc: - base.extend(ClassMethods) - end - - module ClassMethods - # Invoke capistrano using the ARGV array as the option parameters. This - # is what the command-line capistrano utility does. - def execute - parse(ARGV).execute! - end - end - - # Using the options build when the command-line was parsed, instantiate - # a new Capistrano configuration, initialize it, and execute the - # requested actions. - # - # Returns the Configuration instance used, if successful. - def execute! - config = instantiate_configuration(options) - config.debug = options[:debug] - config.dry_run = options[:dry_run] - config.logger.level = options[:verbose] - - set_pre_vars(config) - load_recipes(config) - - config.trigger(:load) - execute_requested_actions(config) - config.trigger(:exit) - - config - rescue Exception => error - handle_error(error) - end - - def execute_requested_actions(config) - Array(options[:vars]).each { |name, value| config.set(name, value) } - - Array(options[:actions]).each do |action| - config.find_and_execute_task(action, :before => :start, :after => :finish) - end - end - - def set_pre_vars(config) #:nodoc: - config.set :password, options[:password] - Array(options[:pre_vars]).each { |name, value| config.set(name, value) } - end - - def load_recipes(config) #:nodoc: - # load the standard recipe definition - config.load "standard" - - # load systemwide config/recipe definition - config.load(options[:sysconf]) if options[:sysconf] && File.file?(options[:sysconf]) - - # load user config/recipe definition - config.load(options[:dotfile]) if options[:dotfile] && File.file?(options[:dotfile]) - - Array(options[:recipes]).each { |recipe| config.load(recipe) } - end - - # Primarily useful for testing, but subclasses of CLI could conceivably - # override this method to return a Configuration subclass or replacement. - def instantiate_configuration(options={}) #:nodoc: - Capistrano::Configuration.new(options) - end - - def handle_error(error) #:nodoc: - case error - when Net::SSH::AuthenticationFailed - abort "authentication failed for `#{error.message}'" - when Capistrano::Error - abort(error.message) - else raise error - end - end - end - end -end diff --git a/vendor/gems/capistrano-2.5.9/lib/capistrano/cli/help.rb b/vendor/gems/capistrano-2.5.9/lib/capistrano/cli/help.rb deleted file mode 100644 index 647b8a9fc..000000000 --- a/vendor/gems/capistrano-2.5.9/lib/capistrano/cli/help.rb +++ /dev/null @@ -1,125 +0,0 @@ -module Capistrano - class CLI - module Help - LINE_PADDING = 7 - MIN_MAX_LEN = 30 - HEADER_LEN = 60 - - def self.included(base) #:nodoc: - base.send :alias_method, :execute_requested_actions_without_help, :execute_requested_actions - base.send :alias_method, :execute_requested_actions, :execute_requested_actions_with_help - end - - def execute_requested_actions_with_help(config) - if options[:tasks] - task_list(config, options[:tasks]) - elsif options[:explain] - explain_task(config, options[:explain]) - else - execute_requested_actions_without_help(config) - end - end - - def task_list(config, pattern = true) #:nodoc: - tool_output = options[:tool] - - if pattern.is_a?(String) - tasks = config.task_list(:all).select {|t| t.fully_qualified_name =~ /#{pattern}/} - end - if tasks.nil? || tasks.length == 0 - warn "Pattern '#{pattern}' not found. Listing all tasks.\n\n" if !tool_output && !pattern.is_a?(TrueClass) - tasks = config.task_list(:all) - end - - if tasks.empty? - warn "There are no tasks available. Please specify a recipe file to load." unless tool_output - else - all_tasks_length = tasks.length - if options[:verbose].to_i < 1 - tasks = tasks.reject { |t| t.description.empty? || t.description =~ /^\[internal\]/ } - end - - tasks = tasks.sort_by { |task| task.fully_qualified_name } - - longest = tasks.map { |task| task.fully_qualified_name.length }.max - max_length = output_columns - longest - LINE_PADDING - max_length = MIN_MAX_LEN if max_length < MIN_MAX_LEN - - tasks.each do |task| - if tool_output - puts "cap #{task.fully_qualified_name}" - else - puts "cap %-#{longest}s # %s" % [task.fully_qualified_name, task.brief_description(max_length)] - end - end - - unless tool_output - if all_tasks_length > tasks.length - puts - puts "Some tasks were not listed, either because they have no description," - puts "or because they are only used internally by other tasks. To see all" - puts "tasks, type `#{File.basename($0)} -vT'." - end - - puts - puts "Extended help may be available for these tasks." - puts "Type `#{File.basename($0)} -e taskname' to view it." - end - end - end - - def explain_task(config, name) #:nodoc: - task = config.find_task(name) - if task.nil? - warn "The task `#{name}' does not exist." - else - puts "-" * HEADER_LEN - puts "cap #{name}" - puts "-" * HEADER_LEN - - if task.description.empty? - puts "There is no description for this task." - else - puts format_text(task.description) - end - - puts - end - end - - def long_help #:nodoc: - help_text = File.read(File.join(File.dirname(__FILE__), "help.txt")) - self.class.ui.page_at = self.class.ui.output_rows - 2 - self.class.ui.say format_text(help_text) - end - - def format_text(text) #:nodoc: - formatted = "" - text.each_line do |line| - indentation = line[/^\s+/] || "" - indentation_size = indentation.split(//).inject(0) { |c,s| c + (s[0] == ?\t ? 8 : 1) } - line_length = output_columns - indentation_size - line_length = MIN_MAX_LEN if line_length < MIN_MAX_LEN - lines = line.strip.gsub(/(.{1,#{line_length}})(?:\s+|\Z)/, "\\1\n").split(/\n/) - if lines.empty? - formatted << "\n" - else - formatted << lines.map { |l| "#{indentation}#{l}\n" }.join - end - end - formatted - end - - def output_columns #:nodoc: - if ( @output_columns.nil? ) - if ( self.class.ui.output_cols.nil? || self.class.ui.output_cols > 80 ) - @output_columns = 80 - else - @output_columns = self.class.ui.output_cols - end - end - @output_columns - end - end - end -end diff --git a/vendor/gems/capistrano-2.5.9/lib/capistrano/cli/help.txt b/vendor/gems/capistrano-2.5.9/lib/capistrano/cli/help.txt deleted file mode 100644 index 198d7d153..000000000 --- a/vendor/gems/capistrano-2.5.9/lib/capistrano/cli/help.txt +++ /dev/null @@ -1,78 +0,0 @@ ------------------------------ -<%= color('Capistrano', :bold) %> ------------------------------ - -Capistrano is a utility for automating the execution of commands across multiple remote machines. It was originally conceived as an aid to deploy Ruby on Rails web applications, but has since evolved to become a much more general-purpose tool. - -The command-line interface to Capistrano is via the `cap' command. - - cap [ option ] ... action ... - -The following options are understood: - - <%= color '-d, --debug', :bold %> - Causes Capistrano to pause and prompt before executing any remote command, giving the user the option to either execute the command, skip the command, or abort execution entirely. This makes it a great way to troubleshoot tasks, or test custom tasks, by executing commands one at a time and checking the server to make sure they worked as expected before moving on to the next command. (Compare this to the --dry-run command.) - - <%= color '-e, --explain TASK', :bold %> - Displays the extended description of the given task. Not all tasks will have an extended description, but for those that do, this can provide a wealth of additional usage information, such as describing environment variables or settings that can affect the execution of the task. - - <%= color '-F, --default-config', :bold %> - By default, cap will search for a config file named `Capfile' or `capfile' in the current directory, or in any parent directory, and will automatically load it. However, if you specify the -f flag (see below), cap will use that file instead of the default config. If you want to use both the default config, and files loaded via -f, you can specify -F to force cap to search for and load the default config, even if additional files were specified via -f. - - <%= color '-f, --file FILE', :bold %> - Causes the named file to be loaded. Capistrano will search both its own recipe directory, as well as the current directory, looking for the named file. An ".rb" extension is optional. The -f option may be given any number of times, but if it is given, it will take the place of the normal `Capfile' or `capfile' detection. Use -F if you want the default capfile to be loaded when you use -f. - - <%= color '-H, --long-help', :bold %> - Displays this document and exits. - - <%= color '-h, --help', :bold %> - Shows a brief summary of these options and exits. - - <%= color '-l, --logger [STDERR|STDOUT|file]', :bold %> - Change the file used to print the output. It offers three options: standard error(stderr), standard output and file. Options are not case sensitive. By default Capistrano uses stderr. - - <%= color '-n, --dry-run', :bold %> - Causes Capistrano to simply display each remote command, without executing it. In this sense it is similar to --debug, but without the prompt. Note that commands executed locally are still run--only remote commands are skipped. - - <%= color '-p, --password', :bold %> - Normally, cap will prompt for the password on-demand, the first time it is needed. This can make it hard to walk away from Capistrano, since you might not know if it will prompt for a password down the road. In such cases, you can use the -p option to force cap to prompt for the password immediately. - - <%= color '-q, --quiet', :bold %> - Display only critical error messages. All other output is suppressed. - - <%= color '-S, --set-before NAME=VALUE', :bold %> - Sets the given variable to the given value, before loading any recipe files. This is useful if you have a recipe file that depends on a certain variable being set, at the time it is loaded. - - <%= color '-s, --set NAME=VALUE', :bold %> - Sets the given variable to the given value, after loading all recipe files. This is useful when you want to override the value of a variable which is used in a task. Note that this will set the variables too late for them to affect conditions that are executed as the recipes are loaded. - - <%= color '-T, --tasks PATTERN', :bold %> - Displays the list of all tasks (matching optional PATTERN) in all loaded recipe files. If a task has no description, or if the description starts with the [internal] tag, the task will not be listed unless you also specify -v. - - <%= color '-t, --tool', :bold %> - Abbreviates the output of -T for integration with other tools. Without -t, -T will list tasks with their summaries, and may include additional instructive text at the bottom. When integrating with other tools (e.g., bash auto-expansion and the like) that additional text can get in the way. This switch makes it easier for those tools to parse the list of tasks. (The -t switch has no effect if the -T switch is not specified.) - - <%= color '-V, --version', :bold %> - Shows the current Capistrano version number and exits. - - <%= color '-v, --verbose', :bold %> - Increase the verbosity. You can specify this option up to three times to further increase verbosity. By default, cap will use maximum verbosity, but if you specify an explicit verbosity, that will be used instead. See also -q. - - <%= color '-X, --skip-system-config', :bold %> - By default, cap will look for and (if it exists) load the global system configuration file located in /etc/capistrano.conf. If you don't want cap to load that file, give this option. - - <%= color '-x, --skip-user-config', :bold %> - By default, cap will look for and (if it exists) load the user-specific configuration file located in $HOME/.caprc. If you don't want cap to load that file, give this option. - ------------------------------ -<%= color('Environment Variables', :bold) %> ------------------------------ - - <%= color 'HOSTS', :bold %> - Execute the tasks against this comma-separated list of hosts. Effectively, this makes the host(s) part of every roles. - - <%= color 'HOSTFILTER', :bold %> - Execute tasks against this comma-separated list of host, but only if the host has the proper role for the task. - - <%= color 'ROLES', :bold %> - Execute tasks against this comma-separated list of roles. Hosts which do not have the right roles will be skipped. diff --git a/vendor/gems/capistrano-2.5.9/lib/capistrano/cli/options.rb b/vendor/gems/capistrano-2.5.9/lib/capistrano/cli/options.rb deleted file mode 100644 index 2f685173f..000000000 --- a/vendor/gems/capistrano-2.5.9/lib/capistrano/cli/options.rb +++ /dev/null @@ -1,239 +0,0 @@ -require 'optparse' - -module Capistrano - class CLI - module Options - def self.included(base) - base.extend(ClassMethods) - end - - module ClassMethods - # Return a new CLI instance with the given arguments pre-parsed and - # ready for execution. - def parse(args) - cli = new(args) - cli.parse_options! - cli - end - end - - # The hash of (parsed) command-line options - attr_reader :options - - # Return an OptionParser instance that defines the acceptable command - # line switches for Capistrano, and what their corresponding behaviors - # are. - def option_parser #:nodoc: - @logger = Logger.new - @option_parser ||= OptionParser.new do |opts| - opts.banner = "Usage: #{File.basename($0)} [options] action ..." - - opts.on("-d", "--debug", - "Prompts before each remote command execution." - ) { |value| options[:debug] = true } - - opts.on("-e", "--explain TASK", - "Displays help (if available) for the task." - ) { |value| options[:explain] = value } - - opts.on("-F", "--default-config", - "Always use default config, even with -f." - ) { options[:default_config] = true } - - opts.on("-f", "--file FILE", - "A recipe file to load. May be given more than once." - ) { |value| options[:recipes] << value } - - opts.on("-H", "--long-help", "Explain these options and environment variables.") do - long_help - exit - end - - opts.on("-h", "--help", "Display this help message.") do - puts opts - exit - end - - opts.on("-l", "--logger [STDERR|STDOUT|file]", - "Choose logger method. STDERR used by default." - ) do |value| - options[:output] = if value.nil? || value.upcase == 'STDERR' - # Using default logger. - nil - elsif value.upcase == 'STDOUT' - $stdout - else - value - end - end - - opts.on("-n", "--dry-run", - "Prints out commands without running them." - ) { |value| options[:dry_run] = true } - - opts.on("-p", "--password", - "Immediately prompt for the password." - ) { options[:password] = nil } - - opts.on("-q", "--quiet", - "Make the output as quiet as possible." - ) { options[:verbose] = 0 } - - opts.on("-S", "--set-before NAME=VALUE", - "Set a variable before the recipes are loaded." - ) do |pair| - name, value = pair.split(/=/, 2) - options[:pre_vars][name.to_sym] = value - end - - opts.on("-s", "--set NAME=VALUE", - "Set a variable after the recipes are loaded." - ) do |pair| - name, value = pair.split(/=/, 2) - options[:vars][name.to_sym] = value - end - - opts.on("-T", "--tasks [PATTERN]", - "List all tasks (matching optional PATTERN) in the loaded recipe files." - ) do |value| - options[:tasks] = if value - value - else - true - end - options[:verbose] ||= 0 - end - - opts.on("-t", "--tool", - "Abbreviates the output of -T for tool integration." - ) { options[:tool] = true } - - opts.on("-V", "--version", - "Display the Capistrano version, and exit." - ) do - require 'capistrano/version' - puts "Capistrano v#{Capistrano::Version::STRING}" - exit - end - - opts.on("-v", "--verbose", - "Be more verbose. May be given more than once." - ) do - options[:verbose] ||= 0 - options[:verbose] += 1 - end - - opts.on("-X", "--skip-system-config", - "Don't load the system config file (capistrano.conf)" - ) { options.delete(:sysconf) } - - opts.on("-x", "--skip-user-config", - "Don't load the user config file (.caprc)" - ) { options.delete(:dotfile) } - end - end - - # If the arguments to the command are empty, this will print the - # allowed options and exit. Otherwise, it will parse the command - # line and set up any default options. - def parse_options! #:nodoc: - @options = { :recipes => [], :actions => [], - :vars => {}, :pre_vars => {}, - :sysconf => default_sysconf, :dotfile => default_dotfile } - - if args.empty? - warn "Please specify at least one action to execute." - warn option_parser - exit - end - - option_parser.parse!(args) - - coerce_variable_types! - - # if no verbosity has been specified, be verbose - options[:verbose] = 3 if !options.has_key?(:verbose) - - look_for_default_recipe_file! if options[:default_config] || options[:recipes].empty? - extract_environment_variables! - - options[:actions].concat(args) - - password = options.has_key?(:password) - options[:password] = Proc.new { self.class.password_prompt } - options[:password] = options[:password].call if password - end - - # Extracts name=value pairs from the remaining command-line arguments - # and assigns them as environment variables. - def extract_environment_variables! #:nodoc: - args.delete_if do |arg| - next unless arg.match(/^(\w+)=(.*)$/) - ENV[$1] = $2 - end - end - - # Looks for a default recipe file in the current directory. - def look_for_default_recipe_file! #:nodoc: - current = Dir.pwd - - loop do - %w(Capfile capfile).each do |file| - if File.file?(file) - options[:recipes] << file - @logger.info "Using recipes from #{File.join(current,file)}" - return - end - end - - pwd = Dir.pwd - Dir.chdir("..") - break if pwd == Dir.pwd # if changing the directory made no difference, then we're at the top - end - - Dir.chdir(current) - end - - def default_sysconf #:nodoc: - File.join(sysconf_directory, "capistrano.conf") - end - - def default_dotfile #:nodoc: - File.join(home_directory, ".caprc") - end - - def sysconf_directory #:nodoc: - # TODO if anyone cares, feel free to submit a patch that uses a more - # appropriate location for this file in Windows. - ENV["SystemRoot"] || '/etc' - end - - def home_directory #:nodoc: - ENV["HOME"] || - (ENV["HOMEPATH"] && "#{ENV["HOMEDRIVE"]}#{ENV["HOMEPATH"]}") || - "/" - end - - def coerce_variable_types! - [:pre_vars, :vars].each do |collection| - options[collection].keys.each do |key| - options[collection][key] = coerce_variable(options[collection][key]) - end - end - end - - def coerce_variable(value) - case value - when /^"(.*)"$/ then $1 - when /^'(.*)'$/ then $1 - when /^\d+$/ then value.to_i - when /^\d+\.\d*$/ then value.to_f - when "true" then true - when "false" then false - when "nil" then nil - else value - end - end - end - end -end diff --git a/vendor/gems/capistrano-2.5.9/lib/capistrano/cli/ui.rb b/vendor/gems/capistrano-2.5.9/lib/capistrano/cli/ui.rb deleted file mode 100644 index d92e72452..000000000 --- a/vendor/gems/capistrano-2.5.9/lib/capistrano/cli/ui.rb +++ /dev/null @@ -1,40 +0,0 @@ -require 'highline' - -# work around problem where HighLine detects an eof on $stdin and raises an -# error. -HighLine.track_eof = false - -module Capistrano - class CLI - module UI - def self.included(base) #:nodoc: - base.extend(ClassMethods) - end - - module ClassMethods - # Return the object that provides UI-specific methods, such as prompts - # and more. - def ui - @ui ||= HighLine.new - end - - # Prompt for a password using echo suppression. - def password_prompt(prompt="Password: ") - ui.ask(prompt) { |q| q.echo = false } - end - - # Debug mode prompt - def debug_prompt(cmd) - ui.say("Preparing to execute command: #{cmd}") - prompt = "Execute ([Yes], No, Abort) " - ui.ask("#{prompt}? ") do |q| - q.overwrite = false - q.default = 'y' - q.validate = /(y(es)?)|(no?)|(a(bort)?|\n)/i - q.responses[:not_valid] = prompt - end - end - end - end - end -end \ No newline at end of file diff --git a/vendor/gems/capistrano-2.5.9/lib/capistrano/command.rb b/vendor/gems/capistrano-2.5.9/lib/capistrano/command.rb deleted file mode 100644 index 033b097b3..000000000 --- a/vendor/gems/capistrano-2.5.9/lib/capistrano/command.rb +++ /dev/null @@ -1,283 +0,0 @@ -require 'capistrano/errors' -require 'capistrano/processable' - -module Capistrano - - # This class encapsulates a single command to be executed on a set of remote - # machines, in parallel. - class Command - include Processable - - class Tree - attr_reader :configuration - attr_reader :branches - attr_reader :fallback - - include Enumerable - - class Branch - attr_accessor :command, :callback - attr_reader :options - - def initialize(command, options, callback) - @command = command.strip.gsub(/\r?\n/, "\\\n") - @callback = callback || Capistrano::Configuration.default_io_proc - @options = options - @skip = false - end - - def last? - options[:last] - end - - def skip? - @skip - end - - def skip! - @skip = true - end - - def match(server) - true - end - - def to_s - command.inspect - end - end - - class ConditionBranch < Branch - attr_accessor :configuration - attr_accessor :condition - - class Evaluator - attr_reader :configuration, :condition, :server - - def initialize(config, condition, server) - @configuration = config - @condition = condition - @server = server - end - - def in?(role) - configuration.roles[role].include?(server) - end - - def result - eval(condition, binding) - end - - def method_missing(sym, *args, &block) - if server.respond_to?(sym) - server.send(sym, *args, &block) - elsif configuration.respond_to?(sym) - configuration.send(sym, *args, &block) - else - super - end - end - end - - def initialize(configuration, condition, command, options, callback) - @configuration = configuration - @condition = condition - super(command, options, callback) - end - - def match(server) - Evaluator.new(configuration, condition, server).result - end - - def to_s - "#{condition.inspect} :: #{command.inspect}" - end - end - - def initialize(config) - @configuration = config - @branches = [] - yield self if block_given? - end - - def when(condition, command, options={}, &block) - branches << ConditionBranch.new(configuration, condition, command, options, block) - end - - def else(command, &block) - @fallback = Branch.new(command, {}, block) - end - - def branches_for(server) - seen_last = false - matches = branches.select do |branch| - success = !seen_last && !branch.skip? && branch.match(server) - seen_last = success && branch.last? - success - end - - matches << fallback if matches.empty? && fallback - return matches - end - - def each - branches.each { |branch| yield branch } - yield fallback if fallback - return self - end - end - - attr_reader :tree, :sessions, :options - - def self.process(tree, sessions, options={}) - new(tree, sessions, options).process! - end - - # Instantiates a new command object. The +command+ must be a string - # containing the command to execute. +sessions+ is an array of Net::SSH - # session instances, and +options+ must be a hash containing any of the - # following keys: - # - # * +logger+: (optional), a Capistrano::Logger instance - # * +data+: (optional), a string to be sent to the command via it's stdin - # * +env+: (optional), a string or hash to be interpreted as environment - # variables that should be defined for this command invocation. - def initialize(tree, sessions, options={}, &block) - if String === tree - tree = Tree.new(nil) { |t| t.else(tree, &block) } - elsif block - raise ArgumentError, "block given with tree argument" - end - - @tree = tree - @sessions = sessions - @options = options - @channels = open_channels - end - - # Processes the command in parallel on all specified hosts. If the command - # fails (non-zero return code) on any of the hosts, this will raise a - # Capistrano::CommandError. - def process! - loop do - break unless process_iteration { @channels.any? { |ch| !ch[:closed] } } - end - - logger.trace "command finished" if logger - - if (failed = @channels.select { |ch| ch[:status] != 0 }).any? - commands = failed.inject({}) { |map, ch| (map[ch[:command]] ||= []) << ch[:server]; map } - message = commands.map { |command, list| "#{command.inspect} on #{list.join(',')}" }.join("; ") - error = CommandError.new("failed: #{message}") - error.hosts = commands.values.flatten - raise error - end - - self - end - - # Force the command to stop processing, by closing all open channels - # associated with this command. - def stop! - @channels.each do |ch| - ch.close unless ch[:closed] - end - end - - private - - def logger - options[:logger] - end - - def open_channels - sessions.map do |session| - server = session.xserver - tree.branches_for(server).map do |branch| - session.open_channel do |channel| - channel[:server] = server - channel[:host] = server.host - channel[:options] = options - channel[:branch] = branch - - request_pty_if_necessary(channel) do |ch, success| - if success - logger.trace "executing command", ch[:server] if logger - cmd = replace_placeholders(channel[:branch].command, ch) - - if options[:shell] == false - shell = nil - else - shell = "#{options[:shell] || "sh"} -c" - cmd = cmd.gsub(/'/) { |m| "'\\''" } - cmd = "'#{cmd}'" - end - - command_line = [environment, shell, cmd].compact.join(" ") - ch[:command] = command_line - - ch.exec(command_line) - ch.send_data(options[:data]) if options[:data] - else - # just log it, don't actually raise an exception, since the - # process method will see that the status is not zero and will - # raise an exception then. - logger.important "could not open channel", ch[:server] if logger - ch.close - end - end - - channel.on_data do |ch, data| - ch[:branch].callback[ch, :out, data] - end - - channel.on_extended_data do |ch, type, data| - ch[:branch].callback[ch, :err, data] - end - - channel.on_request("exit-status") do |ch, data| - ch[:status] = data.read_long - end - - channel.on_close do |ch| - ch[:closed] = true - end - end - end - end.flatten - end - - def request_pty_if_necessary(channel) - if options[:pty] - channel.request_pty do |ch, success| - yield ch, success - end - else - yield channel, true - end - end - - def replace_placeholders(command, channel) - command.gsub(/\$CAPISTRANO:HOST\$/, channel[:host]) - end - - # prepare a space-separated sequence of variables assignments - # intended to be prepended to a command, so the shell sets - # the environment before running the command. - # i.e.: options[:env] = {'PATH' => '/opt/ruby/bin:$PATH', - # 'TEST' => '( "quoted" )'} - # environment returns: - # "env TEST=(\ \"quoted\"\ ) PATH=/opt/ruby/bin:$PATH" - def environment - return if options[:env].nil? || options[:env].empty? - @environment ||= if String === options[:env] - "env #{options[:env]}" - else - options[:env].inject("env") do |string, (name, value)| - value = value.to_s.gsub(/[ "]/) { |m| "\\#{m}" } - string << " #{name}=#{value}" - end - end - end - end -end diff --git a/vendor/gems/capistrano-2.5.9/lib/capistrano/configuration.rb b/vendor/gems/capistrano-2.5.9/lib/capistrano/configuration.rb deleted file mode 100644 index 861efe092..000000000 --- a/vendor/gems/capistrano-2.5.9/lib/capistrano/configuration.rb +++ /dev/null @@ -1,43 +0,0 @@ -require 'capistrano/logger' - -require 'capistrano/configuration/callbacks' -require 'capistrano/configuration/connections' -require 'capistrano/configuration/execution' -require 'capistrano/configuration/loading' -require 'capistrano/configuration/namespaces' -require 'capistrano/configuration/roles' -require 'capistrano/configuration/servers' -require 'capistrano/configuration/variables' - -require 'capistrano/configuration/actions/file_transfer' -require 'capistrano/configuration/actions/inspect' -require 'capistrano/configuration/actions/invocation' - -module Capistrano - # Represents a specific Capistrano configuration. A Configuration instance - # may be used to load multiple recipe files, define and describe tasks, - # define roles, and set configuration variables. - class Configuration - # The logger instance defined for this configuration. - attr_accessor :debug, :logger, :dry_run - - def initialize(options={}) #:nodoc: - @debug = false - @dry_run = false - @logger = Logger.new(options) - end - - # make the DSL easier to read when using lazy evaluation via lambdas - alias defer lambda - - # The includes must come at the bottom, since they may redefine methods - # defined in the base class. - include Connections, Execution, Loading, Namespaces, Roles, Servers, Variables - - # Mix in the actions - include Actions::FileTransfer, Actions::Inspect, Actions::Invocation - - # Must mix last, because it hooks into previously defined methods - include Callbacks - end -end diff --git a/vendor/gems/capistrano-2.5.9/lib/capistrano/configuration/actions/file_transfer.rb b/vendor/gems/capistrano-2.5.9/lib/capistrano/configuration/actions/file_transfer.rb deleted file mode 100644 index d7717f0c8..000000000 --- a/vendor/gems/capistrano-2.5.9/lib/capistrano/configuration/actions/file_transfer.rb +++ /dev/null @@ -1,47 +0,0 @@ -require 'capistrano/transfer' - -module Capistrano - class Configuration - module Actions - module FileTransfer - - # Store the given data at the given location on all servers targetted - # by the current task. If :mode is specified it is used to - # set the mode on the file. - def put(data, path, options={}) - opts = options.dup - upload(StringIO.new(data), path, opts) - end - - # Get file remote_path from FIRST server targeted by - # the current task and transfer it to local machine as path. - # - # get "#{deploy_to}/current/log/production.log", "log/production.log.web" - def get(remote_path, path, options={}, &block) - download(remote_path, path, options.merge(:once => true), &block) - end - - def upload(from, to, options={}, &block) - mode = options.delete(:mode) - transfer(:up, from, to, options, &block) - if mode - mode = mode.is_a?(Numeric) ? mode.to_s(8) : mode.to_s - run "chmod #{mode} #{to}" - end - end - - def download(from, to, options={}, &block) - transfer(:down, from, to, options, &block) - end - - def transfer(direction, from, to, options={}, &block) - execute_on_servers(options) do |servers| - targets = servers.map { |s| sessions[s] } - Transfer.process(direction, from, to, targets, options.merge(:logger => logger), &block) - end - end - - end - end - end -end diff --git a/vendor/gems/capistrano-2.5.9/lib/capistrano/configuration/actions/inspect.rb b/vendor/gems/capistrano-2.5.9/lib/capistrano/configuration/actions/inspect.rb deleted file mode 100644 index c2ea8c77c..000000000 --- a/vendor/gems/capistrano-2.5.9/lib/capistrano/configuration/actions/inspect.rb +++ /dev/null @@ -1,46 +0,0 @@ -require 'capistrano/errors' - -module Capistrano - class Configuration - module Actions - module Inspect - - # Streams the result of the command from all servers that are the - # target of the current task. All these streams will be joined into a - # single one, so you can, say, watch 10 log files as though they were - # one. Do note that this is quite expensive from a bandwidth - # perspective, so use it with care. - # - # The command is invoked via #invoke_command. - # - # Usage: - # - # desc "Run a tail on multiple log files at the same time" - # task :tail_fcgi, :roles => :app do - # stream "tail -f #{shared_path}/log/fastcgi.crash.log" - # end - def stream(command, options={}) - invoke_command(command, options) do |ch, stream, out| - puts out if stream == :out - warn "[err :: #{ch[:server]}] #{out}" if stream == :err - end - end - - # Executes the given command on the first server targetted by the - # current task, collects it's stdout into a string, and returns the - # string. The command is invoked via #invoke_command. - def capture(command, options={}) - output = "" - invoke_command(command, options.merge(:once => true)) do |ch, stream, data| - case stream - when :out then output << data - when :err then warn "[err :: #{ch[:server]}] #{data}" - end - end - output - end - - end - end - end -end diff --git a/vendor/gems/capistrano-2.5.9/lib/capistrano/configuration/actions/invocation.rb b/vendor/gems/capistrano-2.5.9/lib/capistrano/configuration/actions/invocation.rb deleted file mode 100644 index e43ba9dec..000000000 --- a/vendor/gems/capistrano-2.5.9/lib/capistrano/configuration/actions/invocation.rb +++ /dev/null @@ -1,293 +0,0 @@ -require 'capistrano/command' - -module Capistrano - class Configuration - module Actions - module Invocation - def self.included(base) #:nodoc: - base.extend(ClassMethods) - - base.send :alias_method, :initialize_without_invocation, :initialize - base.send :alias_method, :initialize, :initialize_with_invocation - - base.default_io_proc = Proc.new do |ch, stream, out| - level = stream == :err ? :important : :info - ch[:options][:logger].send(level, out, "#{stream} :: #{ch[:server]}") - end - end - - module ClassMethods - attr_accessor :default_io_proc - end - - def initialize_with_invocation(*args) #:nodoc: - initialize_without_invocation(*args) - set :default_environment, {} - set :default_run_options, {} - end - - # Executes different commands in parallel. This is useful for commands - # that need to be different on different hosts, but which could be - # otherwise run in parallel. - # - # The +options+ parameter is currently unused. - # - # Example: - # - # task :restart_everything do - # parallel do |session| - # session.when "in?(:app)", "/path/to/restart/mongrel" - # session.when "in?(:web)", "/path/to/restart/apache" - # session.when "in?(:db)", "/path/to/restart/mysql" - # end - # end - # - # Each command may have its own callback block, for capturing and - # responding to output, with semantics identical to #run: - # - # session.when "in?(:app)", "/path/to/restart/mongrel" do |ch, stream, data| - # # ch is the SSH channel for this command, used to send data - # # back to the command (e.g. ch.send_data("password\n")) - # # stream is either :out or :err, for which stream the data arrived on - # # data is a string containing data sent from the remote command - # end - # - # Also, you can specify a fallback command, to use when none of the - # conditions match a server: - # - # session.else "/execute/something/else" - # - # The string specified as the first argument to +when+ may be any valid - # Ruby code. It has access to the following variables and methods: - # - # * +in?(role)+ returns true if the server participates in the given role - # * +server+ is the ServerDefinition object for the server. This can be - # used to get the host-name, etc. - # * +configuration+ is the current Capistrano::Configuration object, which - # you can use to get the value of variables, etc. - # - # For example: - # - # session.when "server.host =~ /app/", "/some/command" - # session.when "server.host == configuration[:some_var]", "/another/command" - # session.when "in?(:web) || in?(:app)", "/more/commands" - # - # See #run for a description of the valid +options+. - def parallel(options={}) - raise ArgumentError, "parallel() requires a block" unless block_given? - tree = Command::Tree.new(self) { |t| yield t } - run_tree(tree, options) - end - - # Invokes the given command. If a +via+ key is given, it will be used - # to determine what method to use to invoke the command. It defaults - # to :run, but may be :sudo, or any other method that conforms to the - # same interface as run and sudo. - def invoke_command(cmd, options={}, &block) - options = options.dup - via = options.delete(:via) || :run - send(via, cmd, options, &block) - end - - # Execute the given command on all servers that are the target of the - # current task. If a block is given, it is invoked for all output - # generated by the command, and should accept three parameters: the SSH - # channel (which may be used to send data back to the remote process), - # the stream identifier (:err for stderr, and :out for - # stdout), and the data that was received. - # - # The +options+ hash may include any of the following keys: - # - # * :hosts - this is either a string (for a single target host) or an array - # of strings, indicating which hosts the command should run on. By default, - # the hosts are determined from the task definition. - # * :roles - this is either a string or symbol (for a single target role) or - # an array of strings or symbols, indicating which roles the command should - # run on. If :hosts is specified, :roles will be ignored. - # * :only - specifies a condition limiting which hosts will be selected to - # run the command. This should refer to values set in the role definition. - # For example, if a role is defined with :primary => true, then you could - # select only hosts with :primary true by setting :only => { :primary => true }. - # * :except - specifies a condition limiting which hosts will be selected to - # run the command. This is the inverse of :only (hosts that do _not_ match - # the condition will be selected). - # * :once - if true, only the first matching server will be selected. The default - # is false (all matching servers will be selected). - # * :max_hosts - specifies the maximum number of hosts that should be selected - # at a time. If this value is less than the number of hosts that are selected - # to run, then the hosts will be run in groups of max_hosts. The default is nil, - # which indicates that there is no maximum host limit. - # * :shell - says which shell should be used to invoke commands. This - # defaults to "sh". Setting this to false causes Capistrano to invoke - # the commands directly, without wrapping them in a shell invocation. - # * :data - if not nil (the default), this should be a string that will - # be passed to the command's stdin stream. - # * :pty - if true, a pseudo-tty will be allocated for each command. The - # default is false. Note that there are benefits and drawbacks both ways. - # Empirically, it appears that if a pty is allocated, the SSH server daemon - # will _not_ read user shell start-up scripts (e.g. bashrc, etc.). However, - # if a pty is _not_ allocated, some commands will refuse to run in - # interactive mode and will not prompt for (e.g.) passwords. - # * :env - a hash of environment variable mappings that should be made - # available to the command. The keys should be environment variable names, - # and the values should be their corresponding values. The default is - # empty, but may be modified by changing the +default_environment+ - # Capistrano variable. - # - # Note that if you set these keys in the +default_run_options+ Capistrano - # variable, they will apply for all invocations of #run, #invoke_command, - # and #parallel. - def run(cmd, options={}, &block) - block ||= self.class.default_io_proc - tree = Command::Tree.new(self) { |t| t.else(cmd, &block) } - run_tree(tree, options) - end - - # Executes a Capistrano::Command::Tree object. This is not for direct - # use, but should instead be called indirectly, via #run or #parallel, - # or #invoke_command. - def run_tree(tree, options={}) #:nodoc: - if tree.branches.empty? && tree.fallback - logger.debug "executing #{tree.fallback}" - elsif tree.branches.any? - logger.debug "executing multiple commands in parallel" - tree.each do |branch| - logger.trace "-> #{branch}" - end - else - raise ArgumentError, "attempt to execute without specifying a command" - end - - return if dry_run || (debug && continue_execution(tree) == false) - - options = add_default_command_options(options) - - tree.each do |branch| - if branch.command.include?(sudo) - branch.callback = sudo_behavior_callback(branch.callback) - end - end - - execute_on_servers(options) do |servers| - targets = servers.map { |s| sessions[s] } - Command.process(tree, targets, options.merge(:logger => logger)) - end - end - - # Returns the command string used by capistrano to invoke a comamnd via - # sudo. - # - # run "#{sudo :as => 'bob'} mkdir /path/to/dir" - # - # It can also be invoked like #run, but executing the command via sudo. - # This assumes that the sudo password (if required) is the same as the - # password for logging in to the server. - # - # sudo "mkdir /path/to/dir" - # - # Also, this method understands a :sudo configuration variable, - # which (if specified) will be used as the full path to the sudo - # executable on the remote machine: - # - # set :sudo, "/opt/local/bin/sudo" - # - # If you know what you're doing, you can also set :sudo_prompt, - # which tells capistrano which prompt sudo should use when asking for - # a password. (This is so that capistrano knows what prompt to look for - # in the output.) If you set :sudo_prompt to an empty string, Capistrano - # will not send a preferred prompt. - def sudo(*parameters, &block) - options = parameters.last.is_a?(Hash) ? parameters.pop.dup : {} - command = parameters.first - user = options[:as] && "-u #{options.delete(:as)}" - - sudo_prompt_option = "-p '#{sudo_prompt}'" unless sudo_prompt.empty? - sudo_command = [fetch(:sudo, "sudo"), sudo_prompt_option, user].compact.join(" ") - - if command - command = sudo_command + " " + command - run(command, options, &block) - else - return sudo_command - end - end - - # Returns a Proc object that defines the behavior of the sudo - # callback. The returned Proc will defer to the +fallback+ argument - # (which should also be a Proc) for any output it does not - # explicitly handle. - def sudo_behavior_callback(fallback) #:nodoc: - # in order to prevent _each host_ from prompting when the password - # was wrong, let's track which host prompted first and only allow - # subsequent prompts from that host. - prompt_host = nil - - Proc.new do |ch, stream, out| - if out =~ /^Sorry, try again/ - if prompt_host.nil? || prompt_host == ch[:server] - prompt_host = ch[:server] - logger.important out, "#{stream} :: #{ch[:server]}" - reset! :password - end - end - - if out =~ /^#{Regexp.escape(sudo_prompt)}/ - ch.send_data "#{self[:password]}\n" - elsif fallback - fallback.call(ch, stream, out) - end - end - end - - # Merges the various default command options into the options hash and - # returns the result. The default command options that are understand - # are: - # - # * :default_environment: If the :env key already exists, the :env - # key is merged into default_environment and then added back into - # options. - # * :default_shell: if the :shell key already exists, it will be used. - # Otherwise, if the :default_shell key exists in the configuration, - # it will be used. Otherwise, no :shell key is added. - def add_default_command_options(options) - defaults = self[:default_run_options] - options = defaults.merge(options) - - env = self[:default_environment] - env = env.merge(options[:env]) if options[:env] - options[:env] = env unless env.empty? - - shell = options[:shell] || self[:default_shell] - options[:shell] = shell unless shell.nil? - - options - end - - # Returns the prompt text to use with sudo - def sudo_prompt - fetch(:sudo_prompt, "sudo password: ") - end - - def continue_execution(tree) - if tree.branches.length == 1 - continue_execution_for_branch(tree.branches.first) - else - tree.each { |branch| branch.skip! unless continue_execution_for_branch(branch) } - tree.any? { |branch| !branch.skip? } - end - end - - def continue_execution_for_branch(branch) - case Capistrano::CLI.debug_prompt(branch) - when "y" - true - when "n" - false - when "a" - exit(-1) - end - end - end - end - end -end diff --git a/vendor/gems/capistrano-2.5.9/lib/capistrano/configuration/callbacks.rb b/vendor/gems/capistrano-2.5.9/lib/capistrano/configuration/callbacks.rb deleted file mode 100644 index 2f1eebfd2..000000000 --- a/vendor/gems/capistrano-2.5.9/lib/capistrano/configuration/callbacks.rb +++ /dev/null @@ -1,148 +0,0 @@ -require 'capistrano/callback' - -module Capistrano - class Configuration - module Callbacks - def self.included(base) #:nodoc: - %w(initialize invoke_task_directly).each do |method| - base.send :alias_method, "#{method}_without_callbacks", method - base.send :alias_method, method, "#{method}_with_callbacks" - end - end - - # The hash of callbacks that have been registered for this configuration - attr_reader :callbacks - - def initialize_with_callbacks(*args) #:nodoc: - initialize_without_callbacks(*args) - @callbacks = {} - end - - def invoke_task_directly_with_callbacks(task) #:nodoc: - before = find_hook(task, :before) - execute_task(before) if before - - trigger :before, task - - result = invoke_task_directly_without_callbacks(task) - - trigger :after, task - - after = find_hook(task, :after) - execute_task(after) if after - - return result - end - - # Defines a callback to be invoked before the given task. You must - # specify the fully-qualified task name, both for the primary task, and - # for the task(s) to be executed before. Alternatively, you can pass a - # block to be executed before the given task. - # - # before "deploy:update_code", :record_difference - # before :deploy, "custom:log_deploy" - # before :deploy, :this, "then:this", "and:then:this" - # before :some_task do - # puts "an anonymous hook!" - # end - # - # This just provides a convenient interface to the more general #on method. - def before(task_name, *args, &block) - options = args.last.is_a?(Hash) ? args.pop : {} - args << options.merge(:only => task_name) - on :before, *args, &block - end - - # Defines a callback to be invoked after the given task. You must - # specify the fully-qualified task name, both for the primary task, and - # for the task(s) to be executed after. Alternatively, you can pass a - # block to be executed after the given task. - # - # after "deploy:update_code", :log_difference - # after :deploy, "custom:announce" - # after :deploy, :this, "then:this", "and:then:this" - # after :some_task do - # puts "an anonymous hook!" - # end - # - # This just provides a convenient interface to the more general #on method. - def after(task_name, *args, &block) - options = args.last.is_a?(Hash) ? args.pop : {} - args << options.merge(:only => task_name) - on :after, *args, &block - end - - # Defines one or more callbacks to be invoked in response to some event. - # Capistrano currently understands the following events: - # - # * :before, triggered before a task is invoked - # * :after, triggered after a task is invoked - # * :start, triggered before a top-level task is invoked via the command-line - # * :finish, triggered when a top-level task completes - # * :load, triggered after all recipes have loaded - # * :exit, triggered after all tasks have completed - # - # Specify the (fully-qualified) task names that you want invoked in - # response to the event. Alternatively, you can specify a block to invoke - # when the event is triggered. You can also pass a hash of options as the - # last parameter, which may include either of two keys: - # - # * :only, should specify an array of task names. Restricts this callback - # so that it will only fire when the event applies to those tasks. - # * :except, should specify an array of task names. Restricts this callback - # so that it will never fire when the event applies to those tasks. - # - # Usage: - # - # on :before, "some:hook", "another:hook", :only => "deploy:update" - # on :after, "some:hook", :except => "deploy:symlink" - # on :before, "global:hook" - # on :after, :only => :deploy do - # puts "after deploy here" - # end - def on(event, *args, &block) - options = args.last.is_a?(Hash) ? args.pop : {} - callbacks[event] ||= [] - - if args.empty? && block.nil? - raise ArgumentError, "please specify either a task name or a block to invoke" - elsif args.any? && block - raise ArgumentError, "please specify only a task name or a block, but not both" - elsif block - callbacks[event] << ProcCallback.new(block, options) - else - args.each do |name| - callbacks[event] << TaskCallback.new(self, name, options) - end - end - end - - # Trigger the named event for the named task. All associated callbacks - # will be fired, in the order they were defined. - def trigger(event, task=nil) - pending = Array(callbacks[event]).select { |c| c.applies_to?(task) } - if pending.any? - msg = "triggering #{event} callbacks" - msg << " for `#{task.fully_qualified_name}'" if task - logger.trace(msg) - pending.each { |callback| callback.call } - end - end - - private - - # Looks for before_foo or after_foo tasks. This method of extending tasks - # is now discouraged (though not formally deprecated). You should use the - # before and after methods to declare hooks for such callbacks. - def find_hook(task, hook) - if task == task.namespace.default_task - result = task.namespace.search_task("#{hook}_#{task.namespace.name}") - return result if result - end - - task.namespace.search_task("#{hook}_#{task.name}") - end - - end - end -end \ No newline at end of file diff --git a/vendor/gems/capistrano-2.5.9/lib/capistrano/configuration/connections.rb b/vendor/gems/capistrano-2.5.9/lib/capistrano/configuration/connections.rb deleted file mode 100644 index 994e01b11..000000000 --- a/vendor/gems/capistrano-2.5.9/lib/capistrano/configuration/connections.rb +++ /dev/null @@ -1,204 +0,0 @@ -require 'enumerator' -require 'net/ssh/gateway' -require 'capistrano/ssh' -require 'capistrano/errors' - -module Capistrano - class Configuration - module Connections - def self.included(base) #:nodoc: - base.send :alias_method, :initialize_without_connections, :initialize - base.send :alias_method, :initialize, :initialize_with_connections - end - - class DefaultConnectionFactory #:nodoc: - def initialize(options) - @options = options - end - - def connect_to(server) - SSH.connect(server, @options) - end - end - - class GatewayConnectionFactory #:nodoc: - def initialize(gateway, options) - @options = options - @options[:logger].debug "Creating gateway using #{[*gateway].join(', ')}" if @options[:logger] - Thread.abort_on_exception = true - @gateways = [*gateway].collect { |g| ServerDefinition.new(g) } - tunnel = SSH.connection_strategy(@gateways[0], @options) do |host, user, connect_options| - Net::SSH::Gateway.new(host, user, connect_options) - end - @gateway = (@gateways[1..-1]).inject(tunnel) do |tunnel, destination| - @options[:logger].debug "Creating tunnel to #{destination}" if @options[:logger] - local_host = ServerDefinition.new("127.0.0.1", :user => destination.user, :port => tunnel.open(destination.host, (destination.port || 22))) - SSH.connection_strategy(local_host, @options) do |host, user, connect_options| - Net::SSH::Gateway.new(host, user, connect_options) - end - end - end - - def connect_to(server) - @options[:logger].debug "establishing connection to `#{server}' via gateway" if @options[:logger] - local_host = ServerDefinition.new("127.0.0.1", :user => server.user, :port => @gateway.open(server.host, server.port || 22)) - session = SSH.connect(local_host, @options) - session.xserver = server - session - end - end - - # A hash of the SSH sessions that are currently open and available. - # Because sessions are constructed lazily, this will only contain - # connections to those servers that have been the targets of one or more - # executed tasks. Stored on a per-thread basis to improve thread-safety. - def sessions - Thread.current[:sessions] ||= {} - end - - def initialize_with_connections(*args) #:nodoc: - initialize_without_connections(*args) - Thread.current[:sessions] = {} - Thread.current[:failed_sessions] = [] - end - - # Indicate that the given server could not be connected to. - def failed!(server) - Thread.current[:failed_sessions] << server - end - - # Query whether previous connection attempts to the given server have - # failed. - def has_failed?(server) - Thread.current[:failed_sessions].include?(server) - end - - # Used to force connections to be made to the current task's servers. - # Connections are normally made lazily in Capistrano--you can use this - # to force them open before performing some operation that might be - # time-sensitive. - def connect!(options={}) - execute_on_servers(options) { } - end - - # Returns the object responsible for establishing new SSH connections. - # The factory will respond to #connect_to, which can be used to - # establish connections to servers defined via ServerDefinition objects. - def connection_factory - @connection_factory ||= begin - if exists?(:gateway) - logger.debug "establishing connection to gateway `#{fetch(:gateway)}'" - GatewayConnectionFactory.new(fetch(:gateway), self) - else - DefaultConnectionFactory.new(self) - end - end - end - - # Ensures that there are active sessions for each server in the list. - def establish_connections_to(servers) - failed_servers = [] - - # force the connection factory to be instantiated synchronously, - # otherwise we wind up with multiple gateway instances, because - # each connection is done in parallel. - connection_factory - - threads = Array(servers).map { |server| establish_connection_to(server, failed_servers) } - threads.each { |t| t.join } - - if failed_servers.any? - errors = failed_servers.map { |h| "#{h[:server]} (#{h[:error].class}: #{h[:error].message})" } - error = ConnectionError.new("connection failed for: #{errors.join(', ')}") - error.hosts = failed_servers.map { |h| h[:server] } - raise error - end - end - - # Destroys sessions for each server in the list. - def teardown_connections_to(servers) - servers.each do |server| - sessions[server].close - sessions.delete(server) - end - end - - # Determines the set of servers within the current task's scope and - # establishes connections to them, and then yields that list of - # servers. - def execute_on_servers(options={}) - raise ArgumentError, "expected a block" unless block_given? - - if task = current_task - servers = find_servers_for_task(task, options) - - if servers.empty? - if ENV['HOSTFILTER'] - logger.info "skipping `#{task.fully_qualified_name}' because no servers matched" - return - else - raise Capistrano::NoMatchingServersError, "`#{task.fully_qualified_name}' is only run for servers matching #{task.options.inspect}, but no servers matched" - end - end - - if task.continue_on_error? - servers.delete_if { |s| has_failed?(s) } - return if servers.empty? - end - else - servers = find_servers(options) - raise Capistrano::NoMatchingServersError, "no servers found to match #{options.inspect}" if servers.empty? - end - - servers = [servers.first] if options[:once] - logger.trace "servers: #{servers.map { |s| s.host }.inspect}" - - max_hosts = (options[:max_hosts] || (task && task.max_hosts) || servers.size).to_i - is_subset = max_hosts < servers.size - - # establish connections to those servers in groups of max_hosts, as necessary - servers.each_slice(max_hosts) do |servers_slice| - begin - establish_connections_to(servers_slice) - rescue ConnectionError => error - raise error unless task && task.continue_on_error? - error.hosts.each do |h| - servers_slice.delete(h) - failed!(h) - end - end - - begin - yield servers_slice - rescue RemoteError => error - raise error unless task && task.continue_on_error? - error.hosts.each { |h| failed!(h) } - end - - # if dealing with a subset (e.g., :max_hosts is less than the - # number of servers available) teardown the subset of connections - # that were just made, so that we can make room for the next subset. - teardown_connections_to(servers_slice) if is_subset - end - end - - private - - # We establish the connection by creating a thread in a new method--this - # prevents problems with the thread's scope seeing the wrong 'server' - # variable if the thread just happens to take too long to start up. - def establish_connection_to(server, failures=nil) - current_thread = Thread.current - Thread.new { safely_establish_connection_to(server, current_thread, failures) } - end - - def safely_establish_connection_to(server, thread, failures=nil) - thread[:sessions] ||= {} - thread[:sessions][server] ||= connection_factory.connect_to(server) - rescue Exception => err - raise unless failures - failures << { :server => server, :error => err } - end - end - end -end diff --git a/vendor/gems/capistrano-2.5.9/lib/capistrano/configuration/execution.rb b/vendor/gems/capistrano-2.5.9/lib/capistrano/configuration/execution.rb deleted file mode 100644 index 1a85dd7d0..000000000 --- a/vendor/gems/capistrano-2.5.9/lib/capistrano/configuration/execution.rb +++ /dev/null @@ -1,143 +0,0 @@ -require 'capistrano/errors' - -module Capistrano - class Configuration - module Execution - def self.included(base) #:nodoc: - base.send :alias_method, :initialize_without_execution, :initialize - base.send :alias_method, :initialize, :initialize_with_execution - end - - # A struct for representing a single instance of an invoked task. - TaskCallFrame = Struct.new(:task, :rollback) - - def initialize_with_execution(*args) #:nodoc: - initialize_without_execution(*args) - end - private :initialize_with_execution - - # Returns true if there is a transaction currently active. - def transaction? - !rollback_requests.nil? - end - - # The call stack of the tasks. The currently executing task may inspect - # this to see who its caller was. The current task is always the last - # element of this stack. - def task_call_frames - Thread.current[:task_call_frames] ||= [] - end - - - # The stack of tasks that have registered rollback handlers within the - # current transaction. If this is nil, then there is no transaction - # that is currently active. - def rollback_requests - Thread.current[:rollback_requests] - end - - def rollback_requests=(rollback_requests) - Thread.current[:rollback_requests] = rollback_requests - end - - # Invoke a set of tasks in a transaction. If any task fails (raises an - # exception), all tasks executed within the transaction are inspected to - # see if they have an associated on_rollback hook, and if so, that hook - # is called. - def transaction - raise ArgumentError, "expected a block" unless block_given? - raise ScriptError, "transaction must be called from within a task" if task_call_frames.empty? - - return yield if transaction? - - logger.info "transaction: start" - begin - self.rollback_requests = [] - yield - logger.info "transaction: commit" - rescue Object => e - rollback! - raise - ensure - self.rollback_requests = nil if Thread.main == Thread.current - end - end - - # Specifies an on_rollback hook for the currently executing task. If this - # or any subsequent task then fails, and a transaction is active, this - # hook will be executed. - def on_rollback(&block) - if transaction? - # don't note a new rollback request if one has already been set - rollback_requests << task_call_frames.last unless task_call_frames.last.rollback - task_call_frames.last.rollback = block - end - end - - # Returns the TaskDefinition object for the currently executing task. - # It returns nil if there is no task being executed. - def current_task - return nil if task_call_frames.empty? - task_call_frames.last.task - end - - # Executes the task with the given name, without invoking any associated - # callbacks. - def execute_task(task) - logger.debug "executing `#{task.fully_qualified_name}'" - push_task_call_frame(task) - invoke_task_directly(task) - ensure - pop_task_call_frame - end - - # Attempts to locate the task at the given fully-qualified path, and - # execute it. If no such task exists, a Capistrano::NoSuchTaskError will - # be raised. - def find_and_execute_task(path, hooks={}) - task = find_task(path) or raise NoSuchTaskError, "the task `#{path}' does not exist" - - trigger(hooks[:before], task) if hooks[:before] - result = execute_task(task) - trigger(hooks[:after], task) if hooks[:after] - - result - end - - protected - - def rollback! - return if Thread.current[:rollback_requests].nil? - Thread.current[:rolled_back] = true - - # throw the task back on the stack so that roles are properly - # interpreted in the scope of the task in question. - rollback_requests.reverse.each do |frame| - begin - push_task_call_frame(frame.task) - logger.important "rolling back", frame.task.fully_qualified_name - frame.rollback.call - rescue Object => e - logger.info "exception while rolling back: #{e.class}, #{e.message}", frame.task.fully_qualified_name - ensure - pop_task_call_frame - end - end - end - - def push_task_call_frame(task) - frame = TaskCallFrame.new(task) - task_call_frames.push frame - end - - def pop_task_call_frame - task_call_frames.pop - end - - # Invokes the task's body directly, without setting up the call frame. - def invoke_task_directly(task) - task.namespace.instance_eval(&task.body) - end - end - end -end \ No newline at end of file diff --git a/vendor/gems/capistrano-2.5.9/lib/capistrano/configuration/loading.rb b/vendor/gems/capistrano-2.5.9/lib/capistrano/configuration/loading.rb deleted file mode 100644 index 3482717a2..000000000 --- a/vendor/gems/capistrano-2.5.9/lib/capistrano/configuration/loading.rb +++ /dev/null @@ -1,197 +0,0 @@ -module Capistrano - class Configuration - module Loading - def self.included(base) #:nodoc: - base.send :alias_method, :initialize_without_loading, :initialize - base.send :alias_method, :initialize, :initialize_with_loading - base.extend ClassMethods - end - - module ClassMethods - # Used by third-party task bundles to identify the capistrano - # configuration that is loading them. Its return value is not reliable - # in other contexts. If +require_config+ is not false, an exception - # will be raised if the current configuration is not set. - def instance(require_config=false) - config = Thread.current[:capistrano_configuration] - if require_config && config.nil? - raise LoadError, "Please require this file from within a Capistrano recipe" - end - config - end - - # Used internally by Capistrano to specify the current configuration - # before loading a third-party task bundle. - def instance=(config) - Thread.current[:capistrano_configuration] = config - end - - # Used internally by Capistrano to track which recipes have been loaded - # via require, so that they may be successfully reloaded when require - # is called again. - def recipes_per_feature - @recipes_per_feature ||= {} - end - - # Used internally to determine what the current "feature" being - # required is. This is used to track which files load which recipes - # via require. - def current_feature - Thread.current[:capistrano_current_feature] - end - - # Used internally to specify the current file being required, so that - # any recipes loaded by that file can be remembered. This allows - # recipes loaded via require to be correctly reloaded in different - # Configuration instances in the same Ruby instance. - def current_feature=(feature) - Thread.current[:capistrano_current_feature] = feature - end - end - - # The load paths used for locating recipe files. - attr_reader :load_paths - - def initialize_with_loading(*args) #:nodoc: - initialize_without_loading(*args) - @load_paths = [".", File.expand_path(File.join(File.dirname(__FILE__), "../recipes"))] - @loaded_features = [] - end - private :initialize_with_loading - - # Load a configuration file or string into this configuration. - # - # Usage: - # - # load("recipe"): - # Look for and load the contents of 'recipe.rb' into this - # configuration. - # - # load(:file => "recipe"): - # same as above - # - # load(:string => "set :scm, :subversion"): - # Load the given string as a configuration specification. - # - # load { ... } - # Load the block in the context of the configuration. - def load(*args, &block) - options = args.last.is_a?(Hash) ? args.pop : {} - - if block - raise ArgumentError, "loading a block requires 0 arguments" unless options.empty? && args.empty? - load(:proc => block) - - elsif args.any? - args.each { |arg| load options.merge(:file => arg) } - - elsif options[:file] - load_from_file(options[:file], options[:name]) - - elsif options[:string] - remember_load(options) unless options[:reloading] - instance_eval(options[:string], options[:name] || "") - - elsif options[:proc] - remember_load(options) unless options[:reloading] - instance_eval(&options[:proc]) - - else - raise ArgumentError, "don't know how to load #{options.inspect}" - end - end - - # Require another file. This is identical to the standard require method, - # with the exception that it sets the receiver as the "current" configuration - # so that third-party task bundles can include themselves relative to - # that configuration. - # - # This is a bit more complicated than an initial review would seem to - # necessitate, but the use case that complicates things is this: An - # advanced user wants to embed capistrano, and needs to instantiate - # more than one capistrano configuration at a time. They also want each - # configuration to require a third-party capistrano extension. Using a - # naive require implementation, this would allow the first configuration - # to successfully load the third-party extension, but the require would - # fail for the second configuration because the extension has already - # been loaded. - # - # To work around this, we do a few things: - # - # 1. Each time a 'require' is invoked inside of a capistrano recipe, - # we remember the arguments (see "current_feature"). - # 2. Each time a 'load' is invoked inside of a capistrano recipe, and - # "current_feature" is not nil (meaning we are inside of a pending - # require) we remember the options (see "remember_load" and - # "recipes_per_feature"). - # 3. Each time a 'require' is invoked inside of a capistrano recipe, - # we check to see if this particular configuration has ever seen these - # arguments to require (see @loaded_features), and if not, we proceed - # as if the file had never been required. If the superclass' require - # returns false (meaning, potentially, that the file has already been - # required), then we look in the recipes_per_feature collection and - # load any remembered recipes from there. - # - # It's kind of a bear, but it works, and works transparently. Note that - # a simpler implementation would just muck with $", allowing files to be - # required multiple times, but that will cause warnings (and possibly - # errors) if the file to be required contains constant definitions and - # such, alongside (or instead of) capistrano recipe definitions. - def require(*args) #:nodoc: - # look to see if this specific configuration instance has ever seen - # these arguments to require before - if @loaded_features.include?(args) - return false - end - - @loaded_features << args - begin - original_instance, self.class.instance = self.class.instance, self - original_feature, self.class.current_feature = self.class.current_feature, args - - result = super - if !result # file has been required previously, load up the remembered recipes - list = self.class.recipes_per_feature[args] || [] - list.each { |options| load(options.merge(:reloading => true)) } - end - - return result - ensure - # restore the original, so that require's can be nested - self.class.instance = original_instance - self.class.current_feature = original_feature - end - end - - private - - # Load a recipe from the named file. If +name+ is given, the file will - # be reported using that name. - def load_from_file(file, name=nil) - file = find_file_in_load_path(file) unless File.file?(file) - load :string => File.read(file), :name => name || file - end - - def find_file_in_load_path(file) - load_paths.each do |path| - ["", ".rb"].each do |ext| - name = File.join(path, "#{file}#{ext}") - return name if File.file?(name) - end - end - - raise LoadError, "no such file to load -- #{file}" - end - - # If a file is being required, the options associated with loading a - # recipe are remembered in the recipes_per_feature archive under the - # name of the file currently being required. - def remember_load(options) - if self.class.current_feature - list = (self.class.recipes_per_feature[self.class.current_feature] ||= []) - list << options - end - end - end - end -end diff --git a/vendor/gems/capistrano-2.5.9/lib/capistrano/configuration/namespaces.rb b/vendor/gems/capistrano-2.5.9/lib/capistrano/configuration/namespaces.rb deleted file mode 100644 index c879318eb..000000000 --- a/vendor/gems/capistrano-2.5.9/lib/capistrano/configuration/namespaces.rb +++ /dev/null @@ -1,197 +0,0 @@ -require 'capistrano/task_definition' - -module Capistrano - class Configuration - module Namespaces - DEFAULT_TASK = :default - - def self.included(base) #:nodoc: - base.send :alias_method, :initialize_without_namespaces, :initialize - base.send :alias_method, :initialize, :initialize_with_namespaces - end - - # The name of this namespace. Defaults to +nil+ for the top-level - # namespace. - attr_reader :name - - # The parent namespace of this namespace. Returns +nil+ for the top-level - # namespace. - attr_reader :parent - - # The hash of tasks defined for this namespace. - attr_reader :tasks - - # The hash of namespaces defined for this namespace. - attr_reader :namespaces - - def initialize_with_namespaces(*args) #:nodoc: - @name = @parent = nil - initialize_without_namespaces(*args) - @tasks = {} - @namespaces = {} - end - private :initialize_with_namespaces - - # Returns the top-level namespace (the one with no parent). - def top - return parent.top if parent - return self - end - - # Returns the fully-qualified name of this namespace, or nil if the - # namespace is at the top-level. - def fully_qualified_name - return nil if name.nil? - [parent.fully_qualified_name, name].compact.join(":") - end - - # Describe the next task to be defined. The given text will be attached to - # the next task that is defined and used as its description. - def desc(text) - @next_description = text - end - - # Returns the value set by the last, pending "desc" call. If +reset+ is - # not false, the value will be reset immediately afterwards. - def next_description(reset=false) - @next_description - ensure - @next_description = nil if reset - end - - # Open a namespace in which to define new tasks. If the namespace was - # defined previously, it will be reopened, otherwise a new namespace - # will be created for the given name. - def namespace(name, &block) - name = name.to_sym - raise ArgumentError, "expected a block" unless block_given? - - namespace_already_defined = namespaces.key?(name) - if all_methods.any? { |m| m.to_sym == name } && !namespace_already_defined - thing = tasks.key?(name) ? "task" : "method" - raise ArgumentError, "defining a namespace named `#{name}' would shadow an existing #{thing} with that name" - end - - namespaces[name] ||= Namespace.new(name, self) - namespaces[name].instance_eval(&block) - - # make sure any open description gets terminated - namespaces[name].desc(nil) - - if !namespace_already_defined - metaclass = class << self; self; end - metaclass.send(:define_method, name) { namespaces[name] } - end - end - - # Describe a new task. If a description is active (see #desc), it is added - # to the options under the :desc key. The new task is added to - # the namespace. - def task(name, options={}, &block) - name = name.to_sym - raise ArgumentError, "expected a block" unless block_given? - - task_already_defined = tasks.key?(name) - if all_methods.any? { |m| m.to_sym == name } && !task_already_defined - thing = namespaces.key?(name) ? "namespace" : "method" - raise ArgumentError, "defining a task named `#{name}' would shadow an existing #{thing} with that name" - end - - tasks[name] = TaskDefinition.new(name, self, {:desc => next_description(:reset)}.merge(options), &block) - - if !task_already_defined - metaclass = class << self; self; end - metaclass.send(:define_method, name) { execute_task(tasks[name]) } - end - end - - # Find the task with the given name, where name is the fully-qualified - # name of the task. This will search into the namespaces and return - # the referenced task, or nil if no such task can be found. If the name - # refers to a namespace, the task in that namespace named "default" - # will be returned instead, if one exists. - def find_task(name) - parts = name.to_s.split(/:/) - tail = parts.pop.to_sym - - ns = self - until parts.empty? - next_part = parts.shift - ns = next_part.empty? ? nil : ns.namespaces[next_part.to_sym] - return nil if ns.nil? - end - - if ns.namespaces.key?(tail) - ns = ns.namespaces[tail] - tail = DEFAULT_TASK - end - - ns.tasks[tail] - end - - # Given a task name, this will search the current namespace, and all - # parent namespaces, looking for a task that matches the name, exactly. - # It returns the task, if found, or nil, if not. - def search_task(name) - name = name.to_sym - ns = self - - until ns.nil? - return ns.tasks[name] if ns.tasks.key?(name) - ns = ns.parent - end - - return nil - end - - # Returns the default task for this namespace. This will be +nil+ if - # the namespace is at the top-level, and will otherwise return the - # task named "default". If no such task exists, +nil+ will be returned. - def default_task - return nil if parent.nil? - return tasks[DEFAULT_TASK] - end - - # Returns the tasks in this namespace as an array of TaskDefinition - # objects. If a non-false parameter is given, all tasks in all - # namespaces under this namespace will be returned as well. - def task_list(all=false) - list = tasks.values - namespaces.each { |name,space| list.concat(space.task_list(:all)) } if all - list - end - - private - - def all_methods - public_methods.concat(protected_methods).concat(private_methods) - end - - class Namespace - def initialize(name, parent) - @parent = parent - @name = name - end - - def role(*args) - raise NotImplementedError, "roles cannot be defined in a namespace" - end - - def respond_to?(sym, include_priv=false) - super || parent.respond_to?(sym, include_priv) - end - - def method_missing(sym, *args, &block) - if parent.respond_to?(sym) - parent.send(sym, *args, &block) - else - super - end - end - - include Capistrano::Configuration::Namespaces - undef :desc, :next_description - end - end - end -end \ No newline at end of file diff --git a/vendor/gems/capistrano-2.5.9/lib/capistrano/configuration/roles.rb b/vendor/gems/capistrano-2.5.9/lib/capistrano/configuration/roles.rb deleted file mode 100644 index 0955c9aca..000000000 --- a/vendor/gems/capistrano-2.5.9/lib/capistrano/configuration/roles.rb +++ /dev/null @@ -1,73 +0,0 @@ -require 'capistrano/server_definition' -require 'capistrano/role' - -module Capistrano - class Configuration - module Roles - def self.included(base) #:nodoc: - base.send :alias_method, :initialize_without_roles, :initialize - base.send :alias_method, :initialize, :initialize_with_roles - end - - # The hash of roles defined for this configuration. Each entry in the - # hash points to an array of server definitions that belong in that - # role. - attr_reader :roles - - def initialize_with_roles(*args) #:nodoc: - initialize_without_roles(*args) - @roles = Hash.new { |h,k| h[k] = Role.new } - end - - # Define a new role and its associated servers. You must specify at least - # one host for each role. Also, you can specify additional information - # (in the form of a Hash) which can be used to more uniquely specify the - # subset of servers specified by this specific role definition. - # - # Usage: - # - # role :db, "db1.example.com", "db2.example.com" - # role :db, "master.example.com", :primary => true - # role :app, "app1.example.com", "app2.example.com" - # - # You can also encode the username and port number for each host in the - # server string, if needed: - # - # role :web, "www@web1.example.com" - # role :file, "files.example.com:4144" - # role :db, "admin@db3.example.com:1234" - # - # Lastly, username and port number may be passed as options, if that is - # preferred; note that the options apply to all servers defined in - # that call to "role": - # - # role :web, "web2", "web3", :user => "www", :port => 2345 - def role(which, *args, &block) - options = args.last.is_a?(Hash) ? args.pop : {} - which = which.to_sym - - # The roles Hash is defined so that unrecognized keys always auto-initialize - # to a new Role instance (see the assignment in the initialize_with_roles method, - # above). However, we explicitly assign here so that role declarations will - # vivify the role object even if there are no server arguments. (Otherwise, - # role(:app) won't actually instantiate a Role object for :app.) - roles[which] ||= Role.new - - roles[which].push(block, options) if block_given? - args.each { |host| roles[which] << ServerDefinition.new(host, options) } - end - - # An alternative way to associate servers with roles. If you have a server - # that participates in multiple roles, this can be a DRYer way to describe - # the relationships. Pass the host definition as the first parameter, and - # the roles as the remaining parameters: - # - # server "master.example.com", :web, :app - def server(host, *roles) - options = roles.last.is_a?(Hash) ? roles.pop : {} - raise ArgumentError, "you must associate a server with at least one role" if roles.empty? - roles.each { |name| role(name, host, options) } - end - end - end -end diff --git a/vendor/gems/capistrano-2.5.9/lib/capistrano/configuration/servers.rb b/vendor/gems/capistrano-2.5.9/lib/capistrano/configuration/servers.rb deleted file mode 100644 index 6fe7e9681..000000000 --- a/vendor/gems/capistrano-2.5.9/lib/capistrano/configuration/servers.rb +++ /dev/null @@ -1,96 +0,0 @@ -module Capistrano - class Configuration - module Servers - # Identifies all servers that the given task should be executed on. - # The options hash accepts the same arguments as #find_servers, and any - # preexisting options there will take precedence over the options in - # the task. - def find_servers_for_task(task, options={}) - find_servers(task.options.merge(options)) - end - - # Attempts to find all defined servers that match the given criteria. - # The options hash may include a :hosts option (which should specify - # an array of host names or ServerDefinition instances), a :roles - # option (specifying an array of roles), an :only option (specifying - # a hash of key/value pairs that any matching server must match), - # an :exception option (like :only, but the inverse), and a - # :skip_hostfilter option to ignore the HOSTFILTER environment variable - # described below. - # - # Additionally, if the HOSTS environment variable is set, it will take - # precedence over any other options. Similarly, the ROLES environment - # variable will take precedence over other options. If both HOSTS and - # ROLES are given, HOSTS wins. - # - # Yet additionally, if the HOSTFILTER environment variable is set, it - # will limit the result to hosts found in that (comma-separated) list. - # - # Usage: - # - # # return all known servers - # servers = find_servers - # - # # find all servers in the app role that are not exempted from - # # deployment - # servers = find_servers :roles => :app, - # :except => { :no_release => true } - # - # # returns the given hosts, translated to ServerDefinition objects - # servers = find_servers :hosts => "jamis@example.host.com" - def find_servers(options={}) - hosts = server_list_from(ENV['HOSTS'] || options[:hosts]) - - if hosts.any? - if options[:skip_hostfilter] - hosts.uniq - else - filter_server_list(hosts.uniq) - end - else - roles = role_list_from(ENV['ROLES'] || options[:roles] || self.roles.keys) - only = options[:only] || {} - except = options[:except] || {} - - servers = roles.inject([]) { |list, role| list.concat(self.roles[role]) } - servers = servers.select { |server| only.all? { |key,value| server.options[key] == value } } - servers = servers.reject { |server| except.any? { |key,value| server.options[key] == value } } - - if options[:skip_hostfilter] - servers.uniq - else - filter_server_list(servers.uniq) - end - end - end - - protected - - def filter_server_list(servers) - return servers unless ENV['HOSTFILTER'] - filters = ENV['HOSTFILTER'].split(/,/) - servers.select { |server| filters.include?(server.host) } - end - - def server_list_from(hosts) - hosts = hosts.split(/,/) if String === hosts - hosts = build_list(hosts) - hosts.map { |s| String === s ? ServerDefinition.new(s.strip) : s } - end - - def role_list_from(roles) - roles = roles.split(/,/) if String === roles - roles = build_list(roles) - roles.map do |role| - role = String === role ? role.strip.to_sym : role - raise ArgumentError, "unknown role `#{role}'" unless self.roles.key?(role) - role - end - end - - def build_list(list) - Array(list).map { |item| item.respond_to?(:call) ? item.call : item }.flatten - end - end - end -end \ No newline at end of file diff --git a/vendor/gems/capistrano-2.5.9/lib/capistrano/configuration/variables.rb b/vendor/gems/capistrano-2.5.9/lib/capistrano/configuration/variables.rb deleted file mode 100644 index 43bf18a71..000000000 --- a/vendor/gems/capistrano-2.5.9/lib/capistrano/configuration/variables.rb +++ /dev/null @@ -1,127 +0,0 @@ -require 'thread' - -module Capistrano - class Configuration - module Variables - def self.included(base) #:nodoc: - %w(initialize respond_to? method_missing).each do |m| - base_name = m[/^\w+/] - punct = m[/\W+$/] - base.send :alias_method, "#{base_name}_without_variables#{punct}", m - base.send :alias_method, m, "#{base_name}_with_variables#{punct}" - end - end - - # The hash of variables that have been defined in this configuration - # instance. - attr_reader :variables - - # Set a variable to the given value. - def set(variable, *args, &block) - if variable.to_s !~ /^[_a-z]/ - raise ArgumentError, "invalid variable `#{variable}' (variables must begin with an underscore, or a lower-case letter)" - end - - if !block_given? && args.empty? || block_given? && !args.empty? - raise ArgumentError, "you must specify exactly one of either a value or a block" - end - - if args.length > 1 - raise ArgumentError, "wrong number of arguments (#{args.length} for 1)" - end - - value = args.empty? ? block : args.first - sym = variable.to_sym - protect(sym) { @variables[sym] = value } - end - - alias :[]= :set - - # Removes any trace of the given variable. - def unset(variable) - sym = variable.to_sym - protect(sym) do - @original_procs.delete(sym) - @variables.delete(sym) - end - end - - # Returns true if the variable has been defined, and false otherwise. - def exists?(variable) - @variables.key?(variable.to_sym) - end - - # If the variable was originally a proc value, it will be reset to it's - # original proc value. Otherwise, this method does nothing. It returns - # true if the variable was actually reset. - def reset!(variable) - sym = variable.to_sym - protect(sym) do - if @original_procs.key?(sym) - @variables[sym] = @original_procs.delete(sym) - true - else - false - end - end - end - - # Access a named variable. If the value of the variable responds_to? :call, - # #call will be invoked (without parameters) and the return value cached - # and returned. - def fetch(variable, *args) - if !args.empty? && block_given? - raise ArgumentError, "you must specify either a default value or a block, but not both" - end - - sym = variable.to_sym - protect(sym) do - if !@variables.key?(sym) - return args.first unless args.empty? - return yield(variable) if block_given? - raise IndexError, "`#{variable}' not found" - end - - if @variables[sym].respond_to?(:call) - @original_procs[sym] = @variables[sym] - @variables[sym] = @variables[sym].call - end - end - - @variables[sym] - end - - def [](variable) - fetch(variable, nil) - end - - def initialize_with_variables(*args) #:nodoc: - initialize_without_variables(*args) - @variables = {} - @original_procs = {} - @variable_locks = Hash.new { |h,k| h[k] = Mutex.new } - - set :ssh_options, {} - set :logger, logger - end - private :initialize_with_variables - - def protect(variable) - @variable_locks[variable.to_sym].synchronize { yield } - end - private :protect - - def respond_to_with_variables?(sym, include_priv=false) #:nodoc: - @variables.has_key?(sym) || respond_to_without_variables?(sym, include_priv) - end - - def method_missing_with_variables(sym, *args, &block) #:nodoc: - if args.length == 0 && block.nil? && @variables.has_key?(sym) - self[sym] - else - method_missing_without_variables(sym, *args, &block) - end - end - end - end -end \ No newline at end of file diff --git a/vendor/gems/capistrano-2.5.9/lib/capistrano/errors.rb b/vendor/gems/capistrano-2.5.9/lib/capistrano/errors.rb deleted file mode 100644 index 7c60c9ce9..000000000 --- a/vendor/gems/capistrano-2.5.9/lib/capistrano/errors.rb +++ /dev/null @@ -1,15 +0,0 @@ -module Capistrano - class Error < RuntimeError; end - - class CaptureError < Error; end - class NoSuchTaskError < Error; end - class NoMatchingServersError < Error; end - - class RemoteError < Error - attr_accessor :hosts - end - - class ConnectionError < RemoteError; end - class TransferError < RemoteError; end - class CommandError < RemoteError; end -end diff --git a/vendor/gems/capistrano-2.5.9/lib/capistrano/extensions.rb b/vendor/gems/capistrano-2.5.9/lib/capistrano/extensions.rb deleted file mode 100644 index 650893e19..000000000 --- a/vendor/gems/capistrano-2.5.9/lib/capistrano/extensions.rb +++ /dev/null @@ -1,57 +0,0 @@ -module Capistrano - class ExtensionProxy #:nodoc: - def initialize(config, mod) - @config = config - extend(mod) - end - - def method_missing(sym, *args, &block) - @config.send(sym, *args, &block) - end - end - - # Holds the set of registered plugins, keyed by name (where the name is a - # symbol). - EXTENSIONS = {} - - # Register the given module as a plugin with the given name. It will henceforth - # be available via a proxy object on Configuration instances, accessible by - # a method with the given name. - def self.plugin(name, mod) - name = name.to_sym - return false if EXTENSIONS.has_key?(name) - - methods = Capistrano::Configuration.public_instance_methods + - Capistrano::Configuration.protected_instance_methods + - Capistrano::Configuration.private_instance_methods - - if methods.any? { |m| m.to_sym == name } - raise Capistrano::Error, "registering a plugin named `#{name}' would shadow a method on Capistrano::Configuration with the same name" - end - - Capistrano::Configuration.class_eval <<-STR, __FILE__, __LINE__+1 - def #{name} - @__#{name}_proxy ||= Capistrano::ExtensionProxy.new(self, Capistrano::EXTENSIONS[#{name.inspect}]) - end - STR - - EXTENSIONS[name] = mod - return true - end - - # Unregister the plugin with the given name. - def self.remove_plugin(name) - name = name.to_sym - if EXTENSIONS.delete(name) - Capistrano::Configuration.send(:remove_method, name) - return true - end - - return false - end - - def self.configuration(*args) #:nodoc: - warn "[DEPRECATION] Capistrano.configuration is deprecated. Use Capistrano::Configuration.instance instead" - Capistrano::Configuration.instance(*args) - end -end diff --git a/vendor/gems/capistrano-2.5.9/lib/capistrano/logger.rb b/vendor/gems/capistrano-2.5.9/lib/capistrano/logger.rb deleted file mode 100644 index 0aa9602f2..000000000 --- a/vendor/gems/capistrano-2.5.9/lib/capistrano/logger.rb +++ /dev/null @@ -1,59 +0,0 @@ -module Capistrano - class Logger #:nodoc: - attr_accessor :level - attr_reader :device - - IMPORTANT = 0 - INFO = 1 - DEBUG = 2 - TRACE = 3 - - MAX_LEVEL = 3 - - def initialize(options={}) - output = options[:output] || $stderr - if output.respond_to?(:puts) - @device = output - else - @device = File.open(output.to_str, "a") - @needs_close = true - end - - @options = options - @level = 0 - end - - def close - device.close if @needs_close - end - - def log(level, message, line_prefix=nil) - if level <= self.level - indent = "%*s" % [MAX_LEVEL, "*" * (MAX_LEVEL - level)] - (RUBY_VERSION >= "1.9" ? message.lines : message).each do |line| - if line_prefix - device.puts "#{indent} [#{line_prefix}] #{line.strip}\n" - else - device.puts "#{indent} #{line.strip}\n" - end - end - end - end - - def important(message, line_prefix=nil) - log(IMPORTANT, message, line_prefix) - end - - def info(message, line_prefix=nil) - log(INFO, message, line_prefix) - end - - def debug(message, line_prefix=nil) - log(DEBUG, message, line_prefix) - end - - def trace(message, line_prefix=nil) - log(TRACE, message, line_prefix) - end - end -end diff --git a/vendor/gems/capistrano-2.5.9/lib/capistrano/processable.rb b/vendor/gems/capistrano-2.5.9/lib/capistrano/processable.rb deleted file mode 100644 index b7ff9fc74..000000000 --- a/vendor/gems/capistrano-2.5.9/lib/capistrano/processable.rb +++ /dev/null @@ -1,53 +0,0 @@ -module Capistrano - module Processable - module SessionAssociation - def self.on(exception, session) - unless exception.respond_to?(:session) - exception.extend(self) - exception.session = session - end - - return exception - end - - attr_accessor :session - end - - def process_iteration(wait=nil, &block) - ensure_each_session { |session| session.preprocess } - - return false if block && !block.call(self) - - readers = sessions.map { |session| session.listeners.keys }.flatten.reject { |io| io.closed? } - writers = readers.select { |io| io.respond_to?(:pending_write?) && io.pending_write? } - - if readers.any? || writers.any? - readers, writers, = IO.select(readers, writers, nil, wait) - end - - if readers - ensure_each_session do |session| - ios = session.listeners.keys - session.postprocess(ios & readers, ios & writers) - end - end - - true - end - - def ensure_each_session - errors = [] - - sessions.each do |session| - begin - yield session - rescue Exception => error - errors << SessionAssociation.on(error, session) - end - end - - raise errors.first if errors.any? - sessions - end - end -end \ No newline at end of file diff --git a/vendor/gems/capistrano-2.5.9/lib/capistrano/recipes/compat.rb b/vendor/gems/capistrano-2.5.9/lib/capistrano/recipes/compat.rb deleted file mode 100644 index 12bd24146..000000000 --- a/vendor/gems/capistrano-2.5.9/lib/capistrano/recipes/compat.rb +++ /dev/null @@ -1,32 +0,0 @@ -# A collection of compatibility scripts, to ease the transition between -# Capistrano 1.x and Capistrano 2.x. - -# Depends on the deployment system -load 'deploy' - -map = { "diff_from_last_deploy" => "deploy:pending:diff", - "update" => "deploy:update", - "update_code" => "deploy:update_code", - "symlink" => "deploy:symlink", - "restart" => "deploy:restart", - "rollback" => "deploy:rollback", - "cleanup" => "deploy:cleanup", - "disable_web" => "deploy:web:disable", - "enable_web" => "deploy:web:enable", - "cold_deploy" => "deploy:cold", - "deploy_with_migrations" => "deploy:migrations" } - -map.each do |old, new| - desc "DEPRECATED: See #{new}." - eval "task(#{old.inspect}) do - warn \"[DEPRECATED] `#{old}' is deprecated. Use `#{new}' instead.\" - find_and_execute_task(#{new.inspect}) - end" -end - -desc "DEPRECATED: See deploy:start." -task :spinner do - warn "[DEPRECATED] `spinner' is deprecated. Use `deploy:start' instead." - set :runner, fetch(:spinner_user, "app") - deploy.start -end \ No newline at end of file diff --git a/vendor/gems/capistrano-2.5.9/lib/capistrano/recipes/deploy.rb b/vendor/gems/capistrano-2.5.9/lib/capistrano/recipes/deploy.rb deleted file mode 100644 index 0801a612a..000000000 --- a/vendor/gems/capistrano-2.5.9/lib/capistrano/recipes/deploy.rb +++ /dev/null @@ -1,591 +0,0 @@ -require 'yaml' -require 'capistrano/recipes/deploy/scm' -require 'capistrano/recipes/deploy/strategy' - -def _cset(name, *args, &block) - unless exists?(name) - set(name, *args, &block) - end -end - -# ========================================================================= -# These variables MUST be set in the client capfiles. If they are not set, -# the deploy will fail with an error. -# ========================================================================= - -_cset(:application) { abort "Please specify the name of your application, set :application, 'foo'" } -_cset(:repository) { abort "Please specify the repository that houses your application's code, set :repository, 'foo'" } - -# ========================================================================= -# These variables may be set in the client capfile if their default values -# are not sufficient. -# ========================================================================= - -_cset :scm, :subversion -_cset :deploy_via, :checkout - -_cset(:deploy_to) { "/u/apps/#{application}" } -_cset(:revision) { source.head } - -# ========================================================================= -# These variables should NOT be changed unless you are very confident in -# what you are doing. Make sure you understand all the implications of your -# changes if you do decide to muck with these! -# ========================================================================= - -_cset(:source) { Capistrano::Deploy::SCM.new(scm, self) } -_cset(:real_revision) { source.local.query_revision(revision) { |cmd| with_env("LC_ALL", "C") { run_locally(cmd) } } } - -_cset(:strategy) { Capistrano::Deploy::Strategy.new(deploy_via, self) } - -_cset(:release_name) { set :deploy_timestamped, true; Time.now.utc.strftime("%Y%m%d%H%M%S") } - -_cset :version_dir, "releases" -_cset :shared_dir, "shared" -_cset :shared_children, %w(system log pids) -_cset :current_dir, "current" - -_cset(:releases_path) { File.join(deploy_to, version_dir) } -_cset(:shared_path) { File.join(deploy_to, shared_dir) } -_cset(:current_path) { File.join(deploy_to, current_dir) } -_cset(:release_path) { File.join(releases_path, release_name) } - -_cset(:releases) { capture("ls -xt #{releases_path}").split.reverse } -_cset(:current_release) { File.join(releases_path, releases.last) } -_cset(:previous_release) { releases.length > 1 ? File.join(releases_path, releases[-2]) : nil } - -_cset(:current_revision) { capture("cat #{current_path}/REVISION").chomp } -_cset(:latest_revision) { capture("cat #{current_release}/REVISION").chomp } -_cset(:previous_revision) { capture("cat #{previous_release}/REVISION").chomp } - -_cset(:run_method) { fetch(:use_sudo, true) ? :sudo : :run } - -# some tasks, like symlink, need to always point at the latest release, but -# they can also (occassionally) be called standalone. In the standalone case, -# the timestamped release_path will be inaccurate, since the directory won't -# actually exist. This variable lets tasks like symlink work either in the -# standalone case, or during deployment. -_cset(:latest_release) { exists?(:deploy_timestamped) ? release_path : current_release } - -# ========================================================================= -# These are helper methods that will be available to your recipes. -# ========================================================================= - -# Auxiliary helper method for the `deploy:check' task. Lets you set up your -# own dependencies. -def depend(location, type, *args) - deps = fetch(:dependencies, {}) - deps[location] ||= {} - deps[location][type] ||= [] - deps[location][type] << args - set :dependencies, deps -end - -# Temporarily sets an environment variable, yields to a block, and restores -# the value when it is done. -def with_env(name, value) - saved, ENV[name] = ENV[name], value - yield -ensure - ENV[name] = saved -end - -# logs the command then executes it locally. -# returns the command output as a string -def run_locally(cmd) - logger.trace "executing locally: #{cmd.inspect}" if logger - command_present?(cmd) - `#{cmd}` -end - -# tests if the given command is present on the local system -def command_present?(cmd) - executable = cmd.to_s.split(" ").first - unless system("which #{executable}") - logger.important "executable '#{executable}' not present or not in $PATH on the local system!" - end -end - -# If a command is given, this will try to execute the given command, as -# described below. Otherwise, it will return a string for use in embedding in -# another command, for executing that command as described below. -# -# If :run_method is :sudo (or :use_sudo is true), this executes the given command -# via +sudo+. Otherwise is uses +run+. If :as is given as a key, it will be -# passed as the user to sudo as, if using sudo. If the :as key is not given, -# it will default to whatever the value of the :admin_runner variable is, -# which (by default) is unset. -# -# THUS, if you want to try to run something via sudo, and what to use the -# root user, you'd just to try_sudo('something'). If you wanted to try_sudo as -# someone else, you'd just do try_sudo('something', :as => "bob"). If you -# always wanted sudo to run as a particular user, you could do -# set(:admin_runner, "bob"). -def try_sudo(*args) - options = args.last.is_a?(Hash) ? args.pop : {} - command = args.shift - raise ArgumentError, "too many arguments" if args.any? - - as = options.fetch(:as, fetch(:admin_runner, nil)) - via = fetch(:run_method, :sudo) - if command - invoke_command(command, :via => via, :as => as) - elsif via == :sudo - sudo(:as => as) - else - "" - end -end - -# Same as sudo, but tries sudo with :as set to the value of the :runner -# variable (which defaults to "app"). -def try_runner(*args) - options = args.last.is_a?(Hash) ? args.pop : {} - args << options.merge(:as => fetch(:runner, "app")) - try_sudo(*args) -end - -# ========================================================================= -# These are the tasks that are available to help with deploying web apps, -# and specifically, Rails applications. You can have cap give you a summary -# of them with `cap -T'. -# ========================================================================= - -namespace :deploy do - desc <<-DESC - Deploys your project. This calls both `update' and `restart'. Note that \ - this will generally only work for applications that have already been deployed \ - once. For a "cold" deploy, you'll want to take a look at the `deploy:cold' \ - task, which handles the cold start specifically. - DESC - task :default do - update - restart - end - - desc <<-DESC - Prepares one or more servers for deployment. Before you can use any \ - of the Capistrano deployment tasks with your project, you will need to \ - make sure all of your servers have been prepared with `cap deploy:setup'. When \ - you add a new server to your cluster, you can easily run the setup task \ - on just that server by specifying the HOSTS environment variable: - - $ cap HOSTS=new.server.com deploy:setup - - It is safe to run this task on servers that have already been set up; it \ - will not destroy any deployed revisions or data. - DESC - task :setup, :except => { :no_release => true } do - dirs = [deploy_to, releases_path, shared_path] - dirs += shared_children.map { |d| File.join(shared_path, d) } - run "#{try_sudo} mkdir -p #{dirs.join(' ')} && #{try_sudo} chmod g+w #{dirs.join(' ')}" - end - - desc <<-DESC - Copies your project and updates the symlink. It does this in a \ - transaction, so that if either `update_code' or `symlink' fail, all \ - changes made to the remote servers will be rolled back, leaving your \ - system in the same state it was in before `update' was invoked. Usually, \ - you will want to call `deploy' instead of `update', but `update' can be \ - handy if you want to deploy, but not immediately restart your application. - DESC - task :update do - transaction do - update_code - symlink - end - end - - desc <<-DESC - Copies your project to the remote servers. This is the first stage \ - of any deployment; moving your updated code and assets to the deployment \ - servers. You will rarely call this task directly, however; instead, you \ - should call the `deploy' task (to do a complete deploy) or the `update' \ - task (if you want to perform the `restart' task separately). - - You will need to make sure you set the :scm variable to the source \ - control software you are using (it defaults to :subversion), and the \ - :deploy_via variable to the strategy you want to use to deploy (it \ - defaults to :checkout). - DESC - task :update_code, :except => { :no_release => true } do - on_rollback { run "rm -rf #{release_path}; true" } - strategy.deploy! - finalize_update - end - - desc <<-DESC - [internal] Touches up the released code. This is called by update_code \ - after the basic deploy finishes. It assumes a Rails project was deployed, \ - so if you are deploying something else, you may want to override this \ - task with your own environment's requirements. - - This task will make the release group-writable (if the :group_writable \ - variable is set to true, which is the default). It will then set up \ - symlinks to the shared directory for the log, system, and tmp/pids \ - directories, and will lastly touch all assets in public/images, \ - public/stylesheets, and public/javascripts so that the times are \ - consistent (so that asset timestamping works). This touch process \ - is only carried out if the :normalize_asset_timestamps variable is \ - set to true, which is the default. - DESC - task :finalize_update, :except => { :no_release => true } do - run "chmod -R g+w #{latest_release}" if fetch(:group_writable, true) - - # mkdir -p is making sure that the directories are there for some SCM's that don't - # save empty folders - run <<-CMD - rm -rf #{latest_release}/log #{latest_release}/public/system #{latest_release}/tmp/pids && - mkdir -p #{latest_release}/public && - mkdir -p #{latest_release}/tmp && - ln -s #{shared_path}/log #{latest_release}/log && - ln -s #{shared_path}/system #{latest_release}/public/system && - ln -s #{shared_path}/pids #{latest_release}/tmp/pids - CMD - - if fetch(:normalize_asset_timestamps, true) - stamp = Time.now.utc.strftime("%Y%m%d%H%M.%S") - asset_paths = %w(images stylesheets javascripts).map { |p| "#{latest_release}/public/#{p}" }.join(" ") - run "find #{asset_paths} -exec touch -t #{stamp} {} ';'; true", :env => { "TZ" => "UTC" } - end - end - - desc <<-DESC - Updates the symlink to the most recently deployed version. Capistrano works \ - by putting each new release of your application in its own directory. When \ - you deploy a new version, this task's job is to update the `current' symlink \ - to point at the new version. You will rarely need to call this task \ - directly; instead, use the `deploy' task (which performs a complete \ - deploy, including `restart') or the 'update' task (which does everything \ - except `restart'). - DESC - task :symlink, :except => { :no_release => true } do - on_rollback do - if previous_release - run "rm -f #{current_path}; ln -s #{previous_release} #{current_path}; true" - else - logger.important "no previous release to rollback to, rollback of symlink skipped" - end - end - - run "rm -f #{current_path} && ln -s #{latest_release} #{current_path}" - end - - desc <<-DESC - Copy files to the currently deployed version. This is useful for updating \ - files piecemeal, such as when you need to quickly deploy only a single \ - file. Some files, such as updated templates, images, or stylesheets, \ - might not require a full deploy, and especially in emergency situations \ - it can be handy to just push the updates to production, quickly. - - To use this task, specify the files and directories you want to copy as a \ - comma-delimited list in the FILES environment variable. All directories \ - will be processed recursively, with all files being pushed to the \ - deployment servers. - - $ cap deploy:upload FILES=templates,controller.rb - - Dir globs are also supported: - - $ cap deploy:upload FILES='config/apache/*.conf' - DESC - task :upload, :except => { :no_release => true } do - files = (ENV["FILES"] || "").split(",").map { |f| Dir[f.strip] }.flatten - abort "Please specify at least one file or directory to update (via the FILES environment variable)" if files.empty? - - files.each { |file| top.upload(file, File.join(current_path, file)) } - end - - desc <<-DESC - Restarts your application. This works by calling the script/process/reaper \ - script under the current path. - - If you are deploying a Rails 2.3.x application, you will need to install - these http://github.com/rails/irs_process_scripts (more info about why - on that page.) - - By default, this will be invoked via sudo as the `app' user. If \ - you wish to run it as a different user, set the :runner variable to \ - that user. If you are in an environment where you can't use sudo, set \ - the :use_sudo variable to false: - - set :use_sudo, false - DESC - task :restart, :roles => :app, :except => { :no_release => true } do - warn "[DEPRECATED] `deploy:restart` is going to be changed to Passenger mod_rails' method after 2.5.9 - see http://is.gd/2BPeA" - try_runner "#{current_path}/script/process/reaper" - end - - namespace :rollback do - desc <<-DESC - [internal] Points the current symlink at the previous revision. - This is called by the rollback sequence, and should rarely (if - ever) need to be called directly. - DESC - task :revision, :except => { :no_release => true } do - if previous_release - run "rm #{current_path}; ln -s #{previous_release} #{current_path}" - else - abort "could not rollback the code because there is no prior release" - end - end - - desc <<-DESC - [internal] Removes the most recently deployed release. - This is called by the rollback sequence, and should rarely - (if ever) need to be called directly. - DESC - task :cleanup, :except => { :no_release => true } do - run "if [ `readlink #{current_path}` != #{current_release} ]; then rm -rf #{current_release}; fi" - end - - desc <<-DESC - Rolls back to the previously deployed version. The `current' symlink will \ - be updated to point at the previously deployed version, and then the \ - current release will be removed from the servers. You'll generally want \ - to call `rollback' instead, as it performs a `restart' as well. - DESC - task :code, :except => { :no_release => true } do - revision - cleanup - end - - desc <<-DESC - Rolls back to a previous version and restarts. This is handy if you ever \ - discover that you've deployed a lemon; `cap rollback' and you're right \ - back where you were, on the previously deployed version. - DESC - task :default do - revision - restart - cleanup - end - end - - desc <<-DESC - Run the migrate rake task. By default, it runs this in most recently \ - deployed version of the app. However, you can specify a different release \ - via the migrate_target variable, which must be one of :latest (for the \ - default behavior), or :current (for the release indicated by the \ - `current' symlink). Strings will work for those values instead of symbols, \ - too. You can also specify additional environment variables to pass to rake \ - via the migrate_env variable. Finally, you can specify the full path to the \ - rake executable by setting the rake variable. The defaults are: - - set :rake, "rake" - set :rails_env, "production" - set :migrate_env, "" - set :migrate_target, :latest - DESC - task :migrate, :roles => :db, :only => { :primary => true } do - rake = fetch(:rake, "rake") - rails_env = fetch(:rails_env, "production") - migrate_env = fetch(:migrate_env, "") - migrate_target = fetch(:migrate_target, :latest) - - directory = case migrate_target.to_sym - when :current then current_path - when :latest then current_release - else raise ArgumentError, "unknown migration target #{migrate_target.inspect}" - end - - run "cd #{directory}; #{rake} RAILS_ENV=#{rails_env} #{migrate_env} db:migrate" - end - - desc <<-DESC - Deploy and run pending migrations. This will work similarly to the \ - `deploy' task, but will also run any pending migrations (via the \ - `deploy:migrate' task) prior to updating the symlink. Note that the \ - update in this case it is not atomic, and transactions are not used, \ - because migrations are not guaranteed to be reversible. - DESC - task :migrations do - set :migrate_target, :latest - update_code - migrate - symlink - restart - end - - desc <<-DESC - Clean up old releases. By default, the last 5 releases are kept on each \ - server (though you can change this with the keep_releases variable). All \ - other deployed revisions are removed from the servers. By default, this \ - will use sudo to clean up the old releases, but if sudo is not available \ - for your environment, set the :use_sudo variable to false instead. - DESC - task :cleanup, :except => { :no_release => true } do - count = fetch(:keep_releases, 5).to_i - if count >= releases.length - logger.important "no old releases to clean up" - else - logger.info "keeping #{count} of #{releases.length} deployed releases" - - directories = (releases - releases.last(count)).map { |release| - File.join(releases_path, release) }.join(" ") - - try_sudo "rm -rf #{directories}" - end - end - - desc <<-DESC - Test deployment dependencies. Checks things like directory permissions, \ - necessary utilities, and so forth, reporting on the things that appear to \ - be incorrect or missing. This is good for making sure a deploy has a \ - chance of working before you actually run `cap deploy'. - - You can define your own dependencies, as well, using the `depend' method: - - depend :remote, :gem, "tzinfo", ">=0.3.3" - depend :local, :command, "svn" - depend :remote, :directory, "/u/depot/files" - DESC - task :check, :except => { :no_release => true } do - dependencies = strategy.check! - - other = fetch(:dependencies, {}) - other.each do |location, types| - types.each do |type, calls| - if type == :gem - dependencies.send(location).command(fetch(:gem_command, "gem")).or("`gem' command could not be found. Try setting :gem_command") - end - - calls.each do |args| - dependencies.send(location).send(type, *args) - end - end - end - - if dependencies.pass? - puts "You appear to have all necessary dependencies installed" - else - puts "The following dependencies failed. Please check them and try again:" - dependencies.reject { |d| d.pass? }.each do |d| - puts "--> #{d.message}" - end - abort - end - end - - desc <<-DESC - Deploys and starts a `cold' application. This is useful if you have not \ - deployed your application before, or if your application is (for some \ - other reason) not currently running. It will deploy the code, run any \ - pending migrations, and then instead of invoking `deploy:restart', it will \ - invoke `deploy:start' to fire up the application servers. - DESC - task :cold do - update - migrate - start - end - - desc <<-DESC - Start the application servers. This will attempt to invoke a script \ - in your application called `script/spin', which must know how to start \ - your application listeners. For Rails applications, you might just have \ - that script invoke `script/process/spawner' with the appropriate \ - arguments. - - By default, the script will be executed via sudo as the `app' user. If \ - you wish to run it as a different user, set the :runner variable to \ - that user. If you are in an environment where you can't use sudo, set \ - the :use_sudo variable to false. - DESC - task :start, :roles => :app do - warn "[DEPRECATED] `deploy:start` is going to be removed after 2.5.9 - see http://is.gd/2BPeA" - run "cd #{current_path} && #{try_runner} nohup script/spin" - end - - desc <<-DESC - Stop the application servers. This will call script/process/reaper for \ - both the spawner process, and all of the application processes it has \ - spawned. As such, it is fairly Rails specific and may need to be \ - overridden for other systems. - - By default, the script will be executed via sudo as the `app' user. If \ - you wish to run it as a different user, set the :runner variable to \ - that user. If you are in an environment where you can't use sudo, set \ - the :use_sudo variable to false. - DESC - task :stop, :roles => :app do - warn "[DEPRECATED] `deploy:start` is going to be removed after 2.5.9 - see http://is.gd/2BPeA" - run "if [ -f #{current_path}/tmp/pids/dispatch.spawner.pid ]; then #{try_runner} #{current_path}/script/process/reaper -a kill -r dispatch.spawner.pid; fi" - try_runner "#{current_path}/script/process/reaper -a kill" - end - - namespace :pending do - desc <<-DESC - Displays the `diff' since your last deploy. This is useful if you want \ - to examine what changes are about to be deployed. Note that this might \ - not be supported on all SCM's. - DESC - task :diff, :except => { :no_release => true } do - system(source.local.diff(current_revision)) - end - - desc <<-DESC - Displays the commits since your last deploy. This is good for a summary \ - of the changes that have occurred since the last deploy. Note that this \ - might not be supported on all SCM's. - DESC - task :default, :except => { :no_release => true } do - from = source.next_revision(current_revision) - system(source.local.log(from)) - end - end - - namespace :web do - desc <<-DESC - Present a maintenance page to visitors. Disables your application's web \ - interface by writing a "maintenance.html" file to each web server. The \ - servers must be configured to detect the presence of this file, and if \ - it is present, always display it instead of performing the request. - - By default, the maintenance page will just say the site is down for \ - "maintenance", and will be back "shortly", but you can customize the \ - page by specifying the REASON and UNTIL environment variables: - - $ cap deploy:web:disable \\ - REASON="hardware upgrade" \\ - UNTIL="12pm Central Time" - - Further customization will require that you write your own task. - DESC - task :disable, :roles => :web, :except => { :no_release => true } do - require 'erb' - on_rollback { run "rm #{shared_path}/system/maintenance.html" } - - warn <<-EOHTACCESS - - # Please add something like this to your site's htaccess to redirect users to the maintenance page. - # More Info: http://www.shiftcommathree.com/articles/make-your-rails-maintenance-page-respond-with-a-503 - - ErrorDocument 503 /system/maintenance.html - RewriteEngine On - RewriteCond %{REQUEST_URI} !\.(css|gif|jpg|png)$ - RewriteCond %{DOCUMENT_ROOT}/system/maintenance.html -f - RewriteCond %{SCRIPT_FILENAME} !maintenance.html - RewriteRule ^.*$ - [redirect=503,last] - EOHTACCESS - - reason = ENV['REASON'] - deadline = ENV['UNTIL'] - - template = File.read(File.join(File.dirname(__FILE__), "templates", "maintenance.rhtml")) - result = ERB.new(template).result(binding) - - put result, "#{shared_path}/system/maintenance.html", :mode => 0644 - end - - desc <<-DESC - Makes the application web-accessible again. Removes the \ - "maintenance.html" page generated by deploy:web:disable, which (if your \ - web servers are configured correctly) will make your application \ - web-accessible again. - DESC - task :enable, :roles => :web, :except => { :no_release => true } do - run "rm #{shared_path}/system/maintenance.html" - end - end -end diff --git a/vendor/gems/capistrano-2.5.9/lib/capistrano/recipes/deploy/dependencies.rb b/vendor/gems/capistrano-2.5.9/lib/capistrano/recipes/deploy/dependencies.rb deleted file mode 100644 index 87fc28c4f..000000000 --- a/vendor/gems/capistrano-2.5.9/lib/capistrano/recipes/deploy/dependencies.rb +++ /dev/null @@ -1,44 +0,0 @@ -require 'capistrano/recipes/deploy/local_dependency' -require 'capistrano/recipes/deploy/remote_dependency' - -module Capistrano - module Deploy - class Dependencies - include Enumerable - - attr_reader :configuration - - def initialize(configuration) - @configuration = configuration - @dependencies = [] - yield self if block_given? - end - - def check - yield self - self - end - - def remote - dep = RemoteDependency.new(configuration) - @dependencies << dep - dep - end - - def local - dep = LocalDependency.new(configuration) - @dependencies << dep - dep - end - - def each - @dependencies.each { |d| yield d } - self - end - - def pass? - all? { |d| d.pass? } - end - end - end -end \ No newline at end of file diff --git a/vendor/gems/capistrano-2.5.9/lib/capistrano/recipes/deploy/local_dependency.rb b/vendor/gems/capistrano-2.5.9/lib/capistrano/recipes/deploy/local_dependency.rb deleted file mode 100644 index f8e2abc20..000000000 --- a/vendor/gems/capistrano-2.5.9/lib/capistrano/recipes/deploy/local_dependency.rb +++ /dev/null @@ -1,54 +0,0 @@ -module Capistrano - module Deploy - class LocalDependency - attr_reader :configuration - attr_reader :message - - def initialize(configuration) - @configuration = configuration - @success = true - end - - def command(command) - @message ||= "`#{command}' could not be found in the path on the local host" - @success = find_in_path(command) - self - end - - def or(message) - @message = message - self - end - - def pass? - @success - end - - private - - # Searches the path, looking for the given utility. If an executable - # file is found that matches the parameter, this returns true. - def find_in_path(utility) - path = (ENV['PATH'] || "").split(File::PATH_SEPARATOR) - suffixes = self.class.on_windows? ? self.class.windows_executable_extensions : [""] - - path.each do |dir| - suffixes.each do |sfx| - file = File.join(dir, utility + sfx) - return true if File.executable?(file) - end - end - - false - end - - def self.on_windows? - RUBY_PLATFORM =~ /mswin|mingw/ - end - - def self.windows_executable_extensions - %w(.exe .bat .com .cmd) - end - end - end -end diff --git a/vendor/gems/capistrano-2.5.9/lib/capistrano/recipes/deploy/remote_dependency.rb b/vendor/gems/capistrano-2.5.9/lib/capistrano/recipes/deploy/remote_dependency.rb deleted file mode 100644 index 7e04b16a7..000000000 --- a/vendor/gems/capistrano-2.5.9/lib/capistrano/recipes/deploy/remote_dependency.rb +++ /dev/null @@ -1,105 +0,0 @@ -require 'capistrano/errors' - -module Capistrano - module Deploy - class RemoteDependency - attr_reader :configuration - attr_reader :hosts - - def initialize(configuration) - @configuration = configuration - @success = true - @hosts = nil - end - - def directory(path, options={}) - @message ||= "`#{path}' is not a directory" - try("test -d #{path}", options) - self - end - - def file(path, options={}) - @message ||= "`#{path}' is not a file" - try("test -f #{path}", options) - self - end - - def writable(path, options={}) - @message ||= "`#{path}' is not writable" - try("test -w #{path}", options) - self - end - - def command(command, options={}) - @message ||= "`#{command}' could not be found in the path" - try("which #{command}", options) - self - end - - def gem(name, version, options={}) - @message ||= "gem `#{name}' #{version} could not be found" - gem_cmd = configuration.fetch(:gem_command, "gem") - try("#{gem_cmd} specification --version '#{version}' #{name} 2>&1 | awk 'BEGIN { s = 0 } /^name:/ { s = 1; exit }; END { if(s == 0) exit 1 }'", options) - self - end - - def match(command, expect, options={}) - expect = Regexp.new(Regexp.escape(expect.to_s)) unless expect.is_a?(Regexp) - - output_per_server = {} - try("#{command} ", options) do |ch, stream, out| - output_per_server[ch[:server]] ||= '' - output_per_server[ch[:server]] += out - end - - # It is possible for some of these commands to return a status != 0 - # (for example, rake --version exits with a 1). For this check we - # just care if the output matches, so we reset the success flag. - @success = true - - errored_hosts = [] - output_per_server.each_pair do |server, output| - next if output =~ expect - errored_hosts << server - end - - if errored_hosts.any? - @hosts = errored_hosts.join(', ') - output = output_per_server[errored_hosts.first] - @message = "the output #{output.inspect} from #{command.inspect} did not match #{expect.inspect}" - @success = false - end - - self - end - - def or(message) - @message = message - self - end - - def pass? - @success - end - - def message - s = @message.dup - s << " (#{@hosts})" if @hosts - s - end - - private - - def try(command, options) - return unless @success # short-circuit evaluation - configuration.invoke_command(command, options) do |ch,stream,out| - warn "#{ch[:server]}: #{out}" if stream == :err - yield ch, stream, out if block_given? - end - rescue Capistrano::CommandError => e - @success = false - @hosts = e.hosts.join(', ') - end - end - end -end diff --git a/vendor/gems/capistrano-2.5.9/lib/capistrano/recipes/deploy/scm.rb b/vendor/gems/capistrano-2.5.9/lib/capistrano/recipes/deploy/scm.rb deleted file mode 100644 index 04868b067..000000000 --- a/vendor/gems/capistrano-2.5.9/lib/capistrano/recipes/deploy/scm.rb +++ /dev/null @@ -1,19 +0,0 @@ -module Capistrano - module Deploy - module SCM - def self.new(scm, config={}) - scm_file = "capistrano/recipes/deploy/scm/#{scm}" - require(scm_file) - - scm_const = scm.to_s.capitalize.gsub(/_(.)/) { $1.upcase } - if const_defined?(scm_const) - const_get(scm_const).new(config) - else - raise Capistrano::Error, "could not find `#{name}::#{scm_const}' in `#{scm_file}'" - end - rescue LoadError - raise Capistrano::Error, "could not find any SCM named `#{scm}'" - end - end - end -end \ No newline at end of file diff --git a/vendor/gems/capistrano-2.5.9/lib/capistrano/recipes/deploy/scm/accurev.rb b/vendor/gems/capistrano-2.5.9/lib/capistrano/recipes/deploy/scm/accurev.rb deleted file mode 100644 index 8363deaa1..000000000 --- a/vendor/gems/capistrano-2.5.9/lib/capistrano/recipes/deploy/scm/accurev.rb +++ /dev/null @@ -1,169 +0,0 @@ -require 'capistrano/recipes/deploy/scm/base' -require 'rexml/xpath' -require 'rexml/document' - -module Capistrano - module Deploy - module SCM - # Accurev bridge for use by Capistrano. This implementation does not - # implement all features of a Capistrano SCM module. The ones that are - # left out are either exceedingly difficult to implement with Accurev - # or are considered bad form. - # - # When using this module in a project, the following variables are used: - # * :repository - This should match the depot that code lives in. If your code - # exists in a subdirectory, you can append the path depot. - # eg. foo-depot/bar_dir - # * :stream - The stream in the depot that code should be pulled from. If - # left blank, the depot stream will be used - # * :revision - Should be in the form 'stream/transaction'. - class Accurev < Base - include REXML - default_command 'accurev' - - # Defines pseudo-revision value for the most recent changes to be deployed. - def head - "#{stream}/highest" - end - - # Given an Accurev revision identifier, this method returns an identifier that - # can be used for later SCM calls. This returned identifier will not - # change as a result of further SCM activity. - def query_revision(revision) - internal_revision = InternalRevision.parse(revision) - return revision unless internal_revision.psuedo_revision? - - logger.debug("Querying for real revision for #{internal_revision}") - rev_stream = internal_revision.stream - - logger.debug("Determining what type of stream #{rev_stream} is...") - stream_xml = yield show_streams_for(rev_stream) - stream_doc = Document.new(stream_xml) - type = XPath.first(stream_doc, '//streams/stream/@type').value - - case type - when 'snapshot' - InternalRevision.new(rev_stream, 'highest').to_s - else - logger.debug("Getting latest transaction id in #{rev_stream}") - # Doing another yield for a second Accurev call. Hopefully this is ok. - hist_xml = yield scm(:hist, '-ftx', '-s', rev_stream, '-t', 'now.1') - hist_doc = Document.new(hist_xml) - transaction_id = XPath.first(hist_doc, '//AcResponse/transaction/@id').value - InternalRevision.new(stream, transaction_id).to_s - end - end - - # Pops a copy of the code for the specified Accurev revision identifier. - # The revision identifier is represented as a stream & transaction ID combo. - # Accurev can only pop a particular transaction if a stream is created on the server - # with a time basis of that transaction id. Therefore, we will create a stream with - # the required criteria and pop that. - def export(revision_id, destination) - revision = InternalRevision.parse(revision_id) - logger.debug("Exporting #{revision.stream}/#{revision.transaction_id} to #{destination}") - - commands = [ - change_or_create_stream("#{revision.stream}-capistrano-deploy", revision), - "mkdir -p #{destination}", - scm_quiet(:pop, "-Rv #{stream}", "-L #{destination}", "'/./#{subdir}'") - ] - if subdir - commands.push( - "mv #{destination}/#{subdir}/* #{destination}", - "rm -rf #{File.join(destination, subdir)}" - ) - end - commands.join(' && ') - end - - # Returns the command needed to show the changes that exist between the two revisions. - def log(from, to=head) - logger.info("Getting transactions between #{from} and #{to}") - from_rev = InternalRevision.parse(from) - to_rev = InternalRevision.parse(to) - - [ - scm(:hist, '-s', from_rev.stream, '-t', "#{to_rev.transaction_id}-#{from_rev.transaction_id}"), - "sed -e '/transaction #{from_rev.transaction_id}/ { Q }'" - ].join(' | ') - end - - # Returns the command needed to show the diff between what is deployed and what is - # pending. Because Accurev can not do this task without creating some streams, - # two time basis streams will be created for the purposes of doing the diff. - def diff(from, to=head) - from = InternalRevision.parse(from) - to = InternalRevision.parse(to) - - from_stream = "#{from.stream}-capistrano-diff-from" - to_stream = "#{to.stream}-capistrano-diff-to" - - [ - change_or_create_stream(from_stream, from), - change_or_create_stream(to_stream, to), - scm(:diff, '-v', from_stream, '-V', to_stream, '-a') - ].join(' && ') - end - - private - def depot - repository.split('/')[0] - end - - def stream - variable(:stream) || depot - end - - def subdir - repository.split('/')[1..-1].join('/') unless repository.index('/').nil? - end - - def change_or_create_stream(name, revision) - [ - scm_quiet(:mkstream, '-b', revision.stream, '-s', name, '-t', revision.transaction_id), - scm_quiet(:chstream, '-b', revision.stream, '-s', name, '-t', revision.transaction_id) - ].join('; ') - end - - def show_streams_for(stream) - scm :show, '-fx', '-s', stream, :streams - end - - def scm_quiet(*args) - scm(*args) + (variable(:scm_verbose) ? '' : '&> /dev/null') - end - - class InternalRevision - attr_reader :stream, :transaction_id - - def self.parse(string) - match = /([^\/]+)(\/(.+)){0,1}/.match(string) - raise "Unrecognized revision identifier: #{string}" unless match - - stream = match[1] - transaction_id = match[3] || 'highest' - InternalRevision.new(stream, transaction_id) - end - - def initialize(stream, transaction_id) - @stream = stream - @transaction_id = transaction_id - end - - def psuedo_revision? - @transaction_id == 'highest' - end - - def to_s - "#{stream}/#{transaction_id}" - end - - def ==(other) - (stream == other.stream) && (transaction_id == other.transaction_id) - end - end - end - end - end -end diff --git a/vendor/gems/capistrano-2.5.9/lib/capistrano/recipes/deploy/scm/base.rb b/vendor/gems/capistrano-2.5.9/lib/capistrano/recipes/deploy/scm/base.rb deleted file mode 100644 index 12b3983f2..000000000 --- a/vendor/gems/capistrano-2.5.9/lib/capistrano/recipes/deploy/scm/base.rb +++ /dev/null @@ -1,196 +0,0 @@ -module Capistrano - module Deploy - module SCM - - # The ancestor class for all Capistrano SCM implementations. It provides - # minimal infrastructure for subclasses to build upon and override. - # - # Note that subclasses that implement this abstract class only return - # the commands that need to be executed--they do not execute the commands - # themselves. In this way, the deployment method may execute the commands - # either locally or remotely, as necessary. - class Base - class << self - # If no parameters are given, it returns the current configured - # name of the command-line utility of this SCM. If a parameter is - # given, the defeault command is set to that value. - def default_command(value=nil) - if value - @default_command = value - else - @default_command - end - end - end - - # Wraps an SCM instance and forces all messages sent to it to be - # relayed to the underlying SCM instance, in "local" mode. See - # Base#local. - class LocalProxy - def initialize(scm) - @scm = scm - end - - def method_missing(sym, *args, &block) - @scm.local { return @scm.send(sym, *args, &block) } - end - end - - # The options available for this SCM instance to reference. Should be - # treated like a hash. - attr_reader :configuration - - # Creates a new SCM instance with the given configuration options. - def initialize(configuration={}) - @configuration = configuration - end - - # Returns a proxy that wraps the SCM instance and forces it to operate - # in "local" mode, which changes how variables are looked up in the - # configuration. Normally, if the value of a variable "foo" is needed, - # it is queried for in the configuration as "foo". However, in "local" - # mode, first "local_foo" would be looked for, and only if it is not - # found would "foo" be used. This allows for both (e.g.) "scm_command" - # and "local_scm_command" to be set, if the two differ. - # - # Alternatively, it may be called with a block, and for the duration of - # the block, all requests on this configuration object will be - # considered local. - def local - if block_given? - begin - saved, @local_mode = @local_mode, true - yield - ensure - @local_mode = saved - end - else - LocalProxy.new(self) - end - end - - # Returns true if running in "local" mode. See #local. - def local? - @local_mode - end - - # Returns the string used to identify the latest revision in the - # repository. This will be passed as the "revision" parameter of - # the methods below. - def head - raise NotImplementedError, "`head' is not implemented by #{self.class.name}" - end - - # Checkout a copy of the repository, at the given +revision+, to the - # given +destination+. The checkout is suitable for doing development - # work in, e.g. allowing subsequent commits and updates. - def checkout(revision, destination) - raise NotImplementedError, "`checkout' is not implemented by #{self.class.name}" - end - - # Resynchronize the working copy in +destination+ to the specified - # +revision+. - def sync(revision, destination) - raise NotImplementedError, "`sync' is not implemented by #{self.class.name}" - end - - # Compute the difference between the two revisions, +from+ and +to+. - def diff(from, to=nil) - raise NotImplementedError, "`diff' is not implemented by #{self.class.name}" - end - - # Return a log of all changes between the two specified revisions, - # +from+ and +to+, inclusive. - def log(from, to=nil) - raise NotImplementedError, "`log' is not implemented by #{self.class.name}" - end - - # If the given revision represents a "real" revision, this should - # simply return the revision value. If it represends a pseudo-revision - # (like Subversions "HEAD" identifier), it should yield a string - # containing the commands that, when executed will return a string - # that this method can then extract the real revision from. - def query_revision(revision) - raise NotImplementedError, "`query_revision' is not implemented by #{self.class.name}" - end - - # Returns the revision number immediately following revision, if at - # all possible. A block should always be passed to this method, which - # accepts a command to invoke and returns the result, although a - # particular SCM's implementation is not required to invoke the block. - # - # By default, this method simply returns the revision itself. If a - # particular SCM is able to determine a subsequent revision given a - # revision identifier, it should override this method. - def next_revision(revision) - revision - end - - # Should analyze the given text and determine whether or not a - # response is expected, and if so, return the appropriate response. - # If no response is expected, return nil. The +state+ parameter is a - # hash that may be used to preserve state between calls. This method - # is used to define how Capistrano should respond to common prompts - # and messages from the SCM, like password prompts and such. By - # default, the output is simply displayed. - def handle_data(state, stream, text) - logger.info "[#{stream}] #{text}" - nil - end - - # Returns the name of the command-line utility for this SCM. It first - # looks at the :scm_command variable, and if it does not exist, it - # then falls back to whatever was defined by +default_command+. - # - # If scm_command is set to :default, the default_command will be - # returned. - def command - command = variable(:scm_command) - command = nil if command == :default - command || default_command - end - - # A helper method that can be used to define SCM commands naturally. - # It returns a single string with all arguments joined by spaces, - # with the scm command prefixed onto it. - def scm(*args) - [command, *args].compact.join(" ") - end - - private - - # A helper for accessing variable values, which takes into - # consideration the current mode ("normal" vs. "local"). - def variable(name) - if local? && configuration.exists?("local_#{name}".to_sym) - return configuration["local_#{name}".to_sym] - else - configuration[name] - end - end - - # A reference to a Logger instance that the SCM can use to log - # activity. - def logger - @logger ||= variable(:logger) || Capistrano::Logger.new(:output => STDOUT) - end - - # A helper for accessing the default command name for this SCM. It - # simply delegates to the class' +default_command+ method. - def default_command - self.class.default_command - end - - # A convenience method for accessing the declared repository value. - def repository - variable(:repository) - end - - def arguments - variable(:scm_arguments) - end - end - - end - end -end diff --git a/vendor/gems/capistrano-2.5.9/lib/capistrano/recipes/deploy/scm/bzr.rb b/vendor/gems/capistrano-2.5.9/lib/capistrano/recipes/deploy/scm/bzr.rb deleted file mode 100644 index fe29e8bbb..000000000 --- a/vendor/gems/capistrano-2.5.9/lib/capistrano/recipes/deploy/scm/bzr.rb +++ /dev/null @@ -1,83 +0,0 @@ -require 'capistrano/recipes/deploy/scm/base' - -module Capistrano - module Deploy - module SCM - - # Implements the Capistrano SCM interface for the Bazaar-NG revision - # control system (http://bazaar-vcs.org/). - class Bzr < Base - # Sets the default command name for this SCM. Users may override this - # by setting the :scm_command variable. - default_command "bzr" - - # Bazaar-NG doesn't support any pseudo-id's, so we'll use the convention - # in this adapter that the :head symbol means the most recently - # committed revision. - def head - :head - end - - # Returns the command that will check out the given revision to the - # given destination. - def checkout(revision, destination) - scm :checkout, "--lightweight", revswitch(revision), repository, destination - end - - # The bzr 'update' command does not support updating to a specific - # revision, so this just does update, followed by revert (unless - # updating to head). - def sync(revision, destination) - commands = [scm(:update, destination)] - commands << [scm(:revert, revswitch(revision), destination)] if revision != head - commands.join(" && ") - end - - # The bzr 'export' does an export similar to other SCM systems - def export(revision, destination) - scm :export, revswitch(revision), destination, repository - end - - # The bzr "diff" command doesn't accept a repository argument, so it - # must be run from within a working tree. - def diff(from, to=nil) - switch = "-r#{from}" - switch << "..#{to}" if to - - scm :diff, switch - end - - # Returns a log of changes between the two revisions (inclusive). - def log(from, to=nil) - scm :log, "--short", "-r#{from}..#{to}", repository - end - - # Attempts to translate the given revision identifier to a "real" - # revision. If the identifier is :head, the "bzr revno" command will - # be yielded, and the block must execute the command and return the - # output. The revision will be extracted from the output and returned. - # If the 'revision' argument, on the other hand, is not :head, it is - # simply returned. - def query_revision(revision) - revision - end - - # Increments the given revision number and returns it. - def next_revision(revision) - revision.to_i + 1 - end - - private - - def revswitch(revision) - if revision == :head || revision.nil? - nil - else - "-r #{revision}" - end - end - end - - end - end -end diff --git a/vendor/gems/capistrano-2.5.9/lib/capistrano/recipes/deploy/scm/cvs.rb b/vendor/gems/capistrano-2.5.9/lib/capistrano/recipes/deploy/scm/cvs.rb deleted file mode 100644 index 6424444c3..000000000 --- a/vendor/gems/capistrano-2.5.9/lib/capistrano/recipes/deploy/scm/cvs.rb +++ /dev/null @@ -1,152 +0,0 @@ -require 'capistrano/recipes/deploy/scm/base' - -module Capistrano - module Deploy - module SCM - - # Implements the Capistrano SCM interface for the CVS revision - # control system. - class Cvs < Base - # Sets the default command name for this SCM. Users may override this - # by setting the :scm_command variable. - default_command "cvs" - - # CVS understands 'HEAD' to refer to the latest revision in the - # repository. - def head - "HEAD" - end - - # Returns the command that will check out the given revision to the - # given destination. - def checkout(revision, destination) - [ prep_destination(destination), - scm(verbose, cvs_root, :checkout, cvs_revision(revision), cvs_destination(destination), variable(:scm_module)) - ].join(' && ') - end - - # Returns the command that will do an "cvs update" to the given - # revision, for the working copy at the given destination. - def sync(revision, destination) - [ prep_destination(destination), - scm(verbose, cvs_root, :update, cvs_revision(revision), cvs_destination(destination)) - ].join(' && ') - end - - # Returns the command that will do an "cvs export" of the given revision - # to the given destination. - def export(revision, destination) - [ prep_destination(destination), - scm(verbose, cvs_root, :export, cvs_revision(revision), cvs_destination(destination), variable(:scm_module)) - ].join(' && ') - end - - # Returns the command that will do an "cvs diff" for the two revisions. - def diff(from, to=nil) - rev_type = revision_type(from) - if rev_type == :date - range_args = "-D '#{from}' -D '#{to || 'now'}'" - else - range_args = "-r '#{from}' -r '#{to || head}'" - end - scm cvs_root, :diff, range_args - end - - # Returns an "cvs log" command for the two revisions. - def log(from, to=nil) - rev_type = revision_type(from) - if rev_type == :date - range_arg = "-d '#{from}<#{to || 'now'}'" - else - range_arg = "-r '#{from}:#{to || head}'" - end - scm cvs_root, :log, range_arg - end - - # Unfortunately, cvs doesn't support the concept of a revision number like - # subversion and other SCM's do. For now, we'll rely on getting the timestamp - # of the latest checkin under the revision that's passed to us. - def query_revision(revision) - return revision if revision_type(revision) == :date - revision = yield(scm(cvs_root, :log, "-r#{revision}")). - grep(/^date:/). - map { |line| line[/^date: (.*?);/, 1] }. - sort.last + " UTC" - return revision - end - - # Determines what the response should be for a particular bit of text - # from the SCM. Password prompts, connection requests, passphrases, - # etc. are handled here. - def handle_data(state, stream, text) - logger.info "[#{stream}] #{text}" - case text - when /\bpassword.*:/i - # prompting for a password - "#{variable(:scm_password) || variable(:password)}\n" - when %r{\(yes/no\)} - # let's be agreeable... - "yes\n" - end - end - - private - - # Constructs the CVSROOT command-line option - def cvs_root - root = "" - root << "-d #{repository} " if repository - root - end - - # Constructs the destination dir command-line option - def cvs_destination(destination) - dest = "" - if destination - dest_parts = destination.split(/\//); - dest << "-d #{dest_parts.pop}" - end - dest - end - - # attempts to guess what type of revision we're working with - def revision_type(rev) - return :date if rev =~ /^\d{4}\/\d{2}\/\d{2} \d{2}:\d{2}:\d{2} UTC$/ # i.e 2007-05-15 08:13:25 UTC - return :date if rev =~ /^\d{4}\/\d{2}\/\d{2} \d{2}:\d{2}:\d{2}$/ # i.e 2007-05-15 08:13:25 - return :revision if rev =~ /^\d/ # i.e. 1.2.1 - return :tag # i.e. RELEASE_1_2 - end - - # constructs the appropriate command-line switch for specifying a - # "revision" in CVS. This could be a tag, branch, revision (i.e. 1.3) - # or a date (to be used with -d) - def cvs_revision(rev) - revision = "" - revision << case revision_type(rev) - when :date - "-D \"#{rev}\"" if revision_type(rev) == :date - when :revision - "-r #{rev}" - else - "-r #{head}" - end - return revision - end - - # If verbose output is requested, return nil, otherwise return the - # command-line switch for "quiet" ("-Q"). - def verbose - variable(:scm_verbose) ? nil : "-Q" - end - - def prep_destination(destination) - dest_parts = destination.split(/\//); - checkout_dir = dest_parts.pop - dest = dest_parts.join('/') - "mkdir -p #{ dest } && cd #{ dest }" - end - end - - end - end -end diff --git a/vendor/gems/capistrano-2.5.9/lib/capistrano/recipes/deploy/scm/darcs.rb b/vendor/gems/capistrano-2.5.9/lib/capistrano/recipes/deploy/scm/darcs.rb deleted file mode 100644 index de194a368..000000000 --- a/vendor/gems/capistrano-2.5.9/lib/capistrano/recipes/deploy/scm/darcs.rb +++ /dev/null @@ -1,85 +0,0 @@ -require 'capistrano/recipes/deploy/scm/base' - -module Capistrano - module Deploy - module SCM - - # Implements the Capistrano SCM interface for the darcs revision - # control system (http://www.abridgegame.org/darcs/). - class Darcs < Base - # Sets the default command name for this SCM. Users may override this - # by setting the :scm_command variable. - default_command "darcs" - - # Because darcs does not have any support for pseudo-ids, we'll just - # return something here that we can use in the helpers below for - # determining whether we need to look up the latest revision. - def head - :head - end - - # Returns the command that will check out the given revision to the - # given destination. The 'revision' parameter must be the 'hash' value - # for the revision in question, as given by 'darcs changes --xml-output'. - def checkout(revision, destination) - scm :get, verbose, "--repo-name=#{destination}", "--to-match='hash #{revision}'", repository - end - - # Tries to update the destination repository in-place, to bring it up - # to the given revision. Note that because darcs' "pull" operation - # does not support a "to-match" argument (or similar), this basically - # nukes the destination directory and re-gets it. - def sync(revision, destination) - ["rm -rf #{destination}", checkout(revision, destination)].join(" && ") - end - - # Darcs does not have a real 'export' option; there is 'darcs dist', - # but that presupposes a utility that can untar and ungzip the dist - # file. We'll cheat and just do a get, followed by a deletion of the - # _darcs metadata directory. - def export(revision, destination) - [checkout(revision, destination), "rm -rf #{destination}/_darcs"].join(" && ") - end - - # Returns the command that will do a "darcs diff" for the two revisions. - # Each revision must be the 'hash' identifier of a darcs revision. - def diff(from, to=nil) - scm :diff, "--from-match 'hash #{from}'", to && "--to-match 'hash #{to}'" - end - - # Returns the log of changes between the two revisions. Each revision - # must be the 'hash' identifier of a darcs revision. - def log(from, to=nil) - scm :changes, "--from-match 'hash #{from}'", to && "--to-match 'hash #{to}'", "--repo=#{repository}" - end - - # Attempts to translate the given revision identifier to a "real" - # revision. If the identifier is a symbol, it is assumed to be a - # pseudo-id. Otherwise, it will be immediately returned. If it is a - # pseudo-id, a set of commands to execute will be yielded, and the - # result of executing those commands must be returned by the block. - # This method will then extract the actual revision hash from the - # returned data. - def query_revision(revision) - case revision - when :head - xml = yield(scm(:changes, "--last 1", "--xml-output", "--repo=#{repository}")) - return xml[/hash='(.*?)'/, 1] - else return revision - end - end - - private - - def verbose - case variable(:scm_verbose) - when nil then "-q" - when false then nil - else "-v" - end - end - end - - end - end -end diff --git a/vendor/gems/capistrano-2.5.9/lib/capistrano/recipes/deploy/scm/git.rb b/vendor/gems/capistrano-2.5.9/lib/capistrano/recipes/deploy/scm/git.rb deleted file mode 100644 index 91d1e4819..000000000 --- a/vendor/gems/capistrano-2.5.9/lib/capistrano/recipes/deploy/scm/git.rb +++ /dev/null @@ -1,278 +0,0 @@ -require 'capistrano/recipes/deploy/scm/base' - -module Capistrano - module Deploy - module SCM - - # An SCM module for using Git as your source control tool with Capistrano - # 2.0. If you are using Capistrano 1.x, use this plugin instead: - # - # http://scie.nti.st/2007/3/16/capistrano-with-git-shared-repository - # - # Assumes you are using a shared Git repository. - # - # Parts of this plugin borrowed from Scott Chacon's version, which I - # found on the Capistrano mailing list but failed to be able to get - # working. - # - # FEATURES: - # - # * Very simple, only requiring 2 lines in your deploy.rb. - # * Can deploy different branches, tags, or any SHA1 easily. - # * Supports prompting for password / passphrase upon checkout. - # (I am amazed at how some plugins don't do this) - # * Supports :scm_command, :scm_password, :scm_passphrase Capistrano - # directives. - # - # CONFIGURATION - # ------------- - # - # Use this plugin by adding the following line in your config/deploy.rb: - # - # set :scm, :git - # - # Set :repository to the path of your Git repo: - # - # set :repository, "someuser@somehost:/home/myproject" - # - # The above two options are required to be set, the ones below are - # optional. - # - # You may set :branch, which is the reference to the branch, tag, - # or any SHA1 you are deploying, for example: - # - # set :branch, "master" - # - # Otherwise, HEAD is assumed. I strongly suggest you set this. HEAD is - # not always the best assumption. - # - # You may also set :remote, which will be used as a name for remote - # tracking of repositories. This option is intended for use with the - # :remote_cache strategy in a distributed git environment. - # - # For example in the projects config/deploy.rb: - # - # set :repository, "#{scm_user}@somehost:~/projects/project.git" - # set :remote, "#{scm_user}" - # - # Then each person with deploy priveledges can add the following to their - # local ~/.caprc file: - # - # set :scm_user, 'someuser' - # - # Now any time a person deploys the project, their repository will be - # setup as a remote git repository within the cached repository. - # - # The :scm_command configuration variable, if specified, will - # be used as the full path to the git executable on the *remote* machine: - # - # set :scm_command, "/opt/local/bin/git" - # - # For compatibility with deploy scripts that may have used the 1.x - # version of this plugin before upgrading, :git is still - # recognized as an alias for :scm_command. - # - # Set :scm_password to the password needed to clone your repo - # if you don't have password-less (public key) entry: - # - # set :scm_password, "my_secret' - # - # Otherwise, you will be prompted for a password. - # - # :scm_passphrase is also supported. - # - # The remote cache strategy is also supported. - # - # set :repository_cache, "git_master" - # set :deploy_via, :remote_cache - # - # For faster clone, you can also use shallow cloning. This will set the - # '--depth' flag using the depth specified. This *cannot* be used - # together with the :remote_cache strategy - # - # set :git_shallow_clone, 1 - # - # For those that don't like to leave your entire repository on - # your production server you can: - # - # set :deploy_via, :export - # - # To deploy from a local repository: - # - # set :repository, "file://." - # set :deploy_via, :copy - # - # AUTHORS - # ------- - # - # Garry Dolley http://scie.nti.st - # Contributions by Geoffrey Grosenbach http://topfunky.com - # Scott Chacon http://jointheconversation.org - # Alex Arnell http://twologic.com - # and Phillip Goldenburg - - class Git < Base - # Sets the default command name for this SCM on your *local* machine. - # Users may override this by setting the :scm_command variable. - default_command "git" - - # When referencing "head", use the branch we want to deploy or, by - # default, Git's reference of HEAD (the latest changeset in the default - # branch, usually called "master"). - def head - configuration[:branch] || 'HEAD' - end - - def origin - configuration[:remote] || 'origin' - end - - # Performs a clone on the remote machine, then checkout on the branch - # you want to deploy. - def checkout(revision, destination) - git = command - remote = origin - - args = [] - args << "-o #{remote}" unless remote == 'origin' - if depth = configuration[:git_shallow_clone] - args << "--depth #{depth}" - end - - execute = [] - if args.empty? - execute << "#{git} clone #{verbose} #{configuration[:repository]} #{destination}" - else - execute << "#{git} clone #{verbose} #{args.join(' ')} #{configuration[:repository]} #{destination}" - end - - # checkout into a local branch rather than a detached HEAD - execute << "cd #{destination} && #{git} checkout #{verbose} -b deploy #{revision}" - - if configuration[:git_enable_submodules] - execute << "#{git} submodule #{verbose} init" - execute << "#{git} submodule #{verbose} sync" - execute << "#{git} submodule #{verbose} update" - end - - execute.join(" && ") - end - - # An expensive export. Performs a checkout as above, then - # removes the repo. - def export(revision, destination) - checkout(revision, destination) << " && rm -Rf #{destination}/.git" - end - - # Merges the changes to 'head' since the last fetch, for remote_cache - # deployment strategy - def sync(revision, destination) - git = command - remote = origin - - execute = [] - execute << "cd #{destination}" - - # Use git-config to setup a remote tracking branches. Could use - # git-remote but it complains when a remote of the same name already - # exists, git-config will just silenty overwrite the setting every - # time. This could cause wierd-ness in the remote cache if the url - # changes between calls, but as long as the repositories are all - # based from each other it should still work fine. - if remote != 'origin' - execute << "#{git} config remote.#{remote}.url #{configuration[:repository]}" - execute << "#{git} config remote.#{remote}.fetch +refs/heads/*:refs/remotes/#{remote}/*" - end - - # since we're in a local branch already, just reset to specified revision rather than merge - execute << "#{git} fetch #{verbose} #{remote} && #{git} reset #{verbose} --hard #{revision}" - - if configuration[:git_enable_submodules] - execute << "#{git} submodule #{verbose} init" - execute << "for mod in `#{git} submodule status | awk '{ print $2 }'`; do #{git} config -f .git/config submodule.${mod}.url `#{git} config -f .gitmodules --get submodule.${mod}.url` && echo Synced $mod; done" - execute << "#{git} submodule #{verbose} sync" - execute << "#{git} submodule #{verbose} update" - end - - # Make sure there's nothing else lying around in the repository (for - # example, a submodule that has subsequently been removed). - execute << "#{git} clean #{verbose} -d -x -f" - - execute.join(" && ") - end - - # Returns a string of diffs between two revisions - def diff(from, to=nil) - from << "..#{to}" if to - scm :diff, from - end - - # Returns a log of changes between the two revisions (inclusive). - def log(from, to=nil) - scm :log, "#{from}..#{to}" - end - - # Getting the actual commit id, in case we were passed a tag - # or partial sha or something - it will return the sha if you pass a sha, too - def query_revision(revision) - raise ArgumentError, "Deploying remote branches is no longer supported. Specify the remote branch as a local branch for the git repository you're deploying from (ie: '#{revision.gsub('origin/', '')}' rather than '#{revision}')." if revision =~ /^origin\// - return revision if revision =~ /^[0-9a-f]{40}$/ - command = scm('ls-remote', repository, revision) - result = yield(command) - revdata = result.split(/[\t\n]/) - newrev = nil - revdata.each_slice(2) do |refs| - rev, ref = *refs - if ref.sub(/refs\/.*?\//, '').strip == revision.to_s - newrev = rev - break - end - end - raise "Unable to resolve revision for '#{revision}' on repository '#{repository}'." unless newrev =~ /^[0-9a-f]{40}$/ - return newrev - end - - def command - # For backwards compatibility with 1.x version of this module - configuration[:git] || super - end - - # Determines what the response should be for a particular bit of text - # from the SCM. Password prompts, connection requests, passphrases, - # etc. are handled here. - def handle_data(state, stream, text) - host = state[:channel][:host] - logger.info "[#{host} :: #{stream}] #{text}" - case text - when /\bpassword.*:/i - # git is prompting for a password - unless pass = configuration[:scm_password] - pass = Capistrano::CLI.password_prompt - end - "#{pass}\n" - when %r{\(yes/no\)} - # git is asking whether or not to connect - "yes\n" - when /passphrase/i - # git is asking for the passphrase for the user's key - unless pass = configuration[:scm_passphrase] - pass = Capistrano::CLI.password_prompt - end - "#{pass}\n" - when /accept \(t\)emporarily/ - # git is asking whether to accept the certificate - "t\n" - end - end - - private - - # If verbose output is requested, return nil, otherwise return the - # command-line switch for "quiet" ("-q"). - def verbose - variable(:scm_verbose) ? nil : "-q" - end - end - end - end -end diff --git a/vendor/gems/capistrano-2.5.9/lib/capistrano/recipes/deploy/scm/mercurial.rb b/vendor/gems/capistrano-2.5.9/lib/capistrano/recipes/deploy/scm/mercurial.rb deleted file mode 100644 index e5aeacd28..000000000 --- a/vendor/gems/capistrano-2.5.9/lib/capistrano/recipes/deploy/scm/mercurial.rb +++ /dev/null @@ -1,137 +0,0 @@ -# Copyright 2007 Matthew Elder -# based on work by Tobias Luetke - -require 'capistrano/recipes/deploy/scm/base' - -module Capistrano - module Deploy - module SCM - - # Implements the Capistrano SCM interface for the Mercurial revision - # control system (http://www.selenic.com/mercurial/). - # Latest updates at http://tackletechnology.org/oss/cap2-mercurial - class Mercurial < Base - # Sets the default command name for this SCM. Users may override this - # by setting the :scm_command variable. - default_command "hg" - - # For mercurial HEAD == tip except that it bases this assumption on what - # tip is in the current repository (so push before you deploy) - def head - configuration[:branch] || "tip" - end - - # Clone the repository and update to the specified changeset. - def checkout(changeset, destination) - clone(destination) + " && " + update(changeset, destination) - end - - # Pull from the repository and update to the specified changeset. - def sync(changeset, destination) - pull(destination) + " && " + update(changeset, destination) - end - - # One day we will have hg archive, although i think its not needed - def export(revision, destination) - raise NotImplementedError, "`diff' is not implemented by #{self.class.name}" + - "use checkout strategy" - end - - # Compute the difference between the two changesets +from+ and +to+ - # as a unified diff. - def diff(from, to=nil) - scm :diff, - "--rev #{from}", - (to ? "--rev #{to}" : nil) - end - - # Return a log of all changes between the two specified changesets, - # +from+ and +to+, inclusive or the log for +from+ if +to+ is omitted. - def log(from, to=nil) - scm :log, - verbose, - "--rev #{from}" + - (to ? ":#{to}" : "") - end - - # Translates a tag to a changeset if needed or just returns changeset. - def query_revision(changeset) - cmd = scm :log, - verbose, - "-r #{changeset}", - "--template '{node|short}'" - yield cmd - end - - # Determine response for SCM prompts - # user/pass can come from ssh and http distribution methods - # yes/no is for when ssh asks you about fingerprints - def handle_data(state, stream, text) - host = state[:channel][:host] - logger.info "[#{host} :: #{stream}] #{text}" - case text - when /^user:/mi - # support :scm_user for backwards compatibility of this module - if user = variable(:scm_username) || variable(:scm_user) - "#{user}\n" - else - raise "No variable :scm_username specified and Mercurial asked!\n" + - "Prompt was: #{text}" - end - when /\bpassword:/mi - unless pass = scm_password_or_prompt - # fall back on old behavior of erroring out with msg - raise "No variable :scm_password specified and Mercurial asked!\n" + - "Prompt was: #{text}" - end - "#{pass}\n" - when /yes\/no/i - "yes\n" - end - end - - private - - # Fine grained mercurial commands - def clone(destination) - scm :clone, - verbose, - "--noupdate", # do not update to tip when cloning is done - repository, # clone which repository? - destination # and put the clone where? - end - - def pull(destination) - scm :pull, - verbose, - "--repository #{destination}", # pull changes into what? - repository # and pull the changes from? - end - - def update(changeset, destination) - scm :update, - verbose, - "--repository #{destination}", # update what? - "--clean", # ignore untracked changes - changeset # update to this changeset - end - - # verbosity configuration grokking :) - def verbose - case variable(:scm_verbose) - when nil then nil - when false then "--quiet" - else "--verbose" - end - end - - # honor Cap 2.1+'s :scm_prefer_prompt if present - def scm_password_or_prompt - @scm_password_or_prompt ||= variable(:scm_password) || - (Capistrano::CLI.password_prompt("hg password: ") if variable(:scm_prefer_prompt)) - end - - end - end - end -end diff --git a/vendor/gems/capistrano-2.5.9/lib/capistrano/recipes/deploy/scm/none.rb b/vendor/gems/capistrano-2.5.9/lib/capistrano/recipes/deploy/scm/none.rb deleted file mode 100644 index 42d4d40e1..000000000 --- a/vendor/gems/capistrano-2.5.9/lib/capistrano/recipes/deploy/scm/none.rb +++ /dev/null @@ -1,44 +0,0 @@ -require 'capistrano/recipes/deploy/scm/base' - -module Capistrano - module Deploy - module SCM - - # A trivial SCM wrapper for representing the current working directory - # as a repository. Obviously, not all operations are available for this - # SCM, but it works sufficiently for use with the "copy" deployment - # strategy. - # - # Use of this module is _not_ recommended; in general, it is good - # practice to use some kind of source code management even for anything - # you are wanting to deploy. However, this module is provided in - # acknowledgement of the cases where trivial deployment of your current - # working directory is desired. - # - # set :repository, "." - # set :scm, :none - # set :deploy_via, :copy - class None < Base - # No versioning, thus, no head. Returns the empty string. - def head - "" - end - - # Simply does a copy from the :repository directory to the - # :destination directory. - def checkout(revision, destination) - !Capistrano::Deploy::LocalDependency.on_windows? ? "cp -R #{repository} #{destination}" : "xcopy #{repository} \"#{destination}\" /S/I/Y/Q/E" - end - - alias_method :export, :checkout - - # No versioning, so this just returns the argument, with no - # modification. - def query_revision(revision) - revision - end - end - - end - end -end diff --git a/vendor/gems/capistrano-2.5.9/lib/capistrano/recipes/deploy/scm/perforce.rb b/vendor/gems/capistrano-2.5.9/lib/capistrano/recipes/deploy/scm/perforce.rb deleted file mode 100644 index 2e26d1916..000000000 --- a/vendor/gems/capistrano-2.5.9/lib/capistrano/recipes/deploy/scm/perforce.rb +++ /dev/null @@ -1,138 +0,0 @@ -require 'capistrano/recipes/deploy/scm/base' - -# Notes: -# no global verbose flag for scm_verbose -# sync, checkout and export are just sync in p4 -# -module Capistrano - module Deploy - module SCM - - # Implements the Capistrano SCM interface for the Perforce revision - # control system (http://www.perforce.com). - class Perforce < Base - # Sets the default command name for this SCM. Users may override this - # by setting the :scm_command variable. - default_command "p4" - - # Perforce understands '#head' to refer to the latest revision in the - # depot. - def head - 'head' - end - - # Returns the command that will sync the given revision to the given - # destination directory. The perforce client has a fixed destination so - # the files must be copied from there to their intended resting place. - def checkout(revision, destination) - p4_sync(revision, destination, p4sync_flags) - end - - # Returns the command that will sync the given revision to the given - # destination directory. The perforce client has a fixed destination so - # the files must be copied from there to their intended resting place. - def sync(revision, destination) - p4_sync(revision, destination, p4sync_flags) - end - - # Returns the command that will sync the given revision to the given - # destination directory. The perforce client has a fixed destination so - # the files must be copied from there to their intended resting place. - def export(revision, destination) - p4_sync(revision, destination, p4sync_flags) - end - - # Returns the command that will do an "p4 diff2" for the two revisions. - def diff(from, to=head) - scm authentication, :diff2, "-u -db", "//#{p4client}/...#{rev_no(from)}", "//#{p4client}/...#{rev_no(to)}" - end - - # Returns a "p4 changes" command for the two revisions. - def log(from=1, to=head) - scm authentication, :changes, "-s submitted", "//#{p4client}/...#{rev_no(from)},#{rev_no(to)}" - end - - def query_revision(revision) - return revision if revision.to_s =~ /^\d+$/ - command = scm(authentication, :changes, "-s submitted", "-m 1", "//#{p4client}/...#{rev_no(revision)}") - yield(command)[/Change (\d+) on/, 1] - end - - # Increments the given revision number and returns it. - def next_revision(revision) - revision.to_i + 1 - end - - # Determines what the response should be for a particular bit of text - # from the SCM. Password prompts, connection requests, passphrases, - # etc. are handled here. - def handle_data(state, stream, text) - case text - when /\(P4PASSWD\) invalid or unset\./i - raise Capistrano::Error, "scm_password (or p4passwd) is incorrect or unset" - when /Can.t create a new user.*/i - raise Capistrano::Error, "scm_username (or p4user) is incorrect or unset" - when /Perforce client error\:/i - raise Capistrano::Error, "p4port is incorrect or unset" - when /Client \'[\w\-\_\.]+\' unknown.*/i - raise Capistrano::Error, "p4client is incorrect or unset" - end - end - - private - - # Builds the set of authentication switches that perforce understands. - def authentication - [ p4port && "-p #{p4port}", - p4user && "-u #{p4user}", - p4passwd && "-P #{p4passwd}", - p4client && "-c #{p4client}" ].compact.join(" ") - end - - # Returns the command that will sync the given revision to the given - # destination directory with specific options. The perforce client has - # a fixed destination so the files must be copied from there to their - # intended resting place. - def p4_sync(revision, destination, options="") - scm authentication, :sync, options, "#{rev_no(revision)}", "&& cp -rf #{p4client_root} #{destination}" - end - - def p4client - variable(:p4client) - end - - def p4port - variable(:p4port) - end - - def p4user - variable(:p4user) || variable(:scm_username) - end - - def p4passwd - variable(:p4passwd) || variable(:scm_password) - end - - def p4sync_flags - variable(:p4sync_flags) || "-f" - end - - def p4client_root - variable(:p4client_root) || "`#{command} #{authentication} client -o | grep ^Root | cut -f2`" - end - - def rev_no(revision) - case revision.to_s - when "head" - "#head" - when /^\d+/ - "@#{revision}" - else - revision - end - end - end - - end - end -end diff --git a/vendor/gems/capistrano-2.5.9/lib/capistrano/recipes/deploy/scm/subversion.rb b/vendor/gems/capistrano-2.5.9/lib/capistrano/recipes/deploy/scm/subversion.rb deleted file mode 100644 index 17a4167c3..000000000 --- a/vendor/gems/capistrano-2.5.9/lib/capistrano/recipes/deploy/scm/subversion.rb +++ /dev/null @@ -1,121 +0,0 @@ -require 'capistrano/recipes/deploy/scm/base' -require 'yaml' - -module Capistrano - module Deploy - module SCM - - # Implements the Capistrano SCM interface for the Subversion revision - # control system (http://subversion.tigris.org). - class Subversion < Base - # Sets the default command name for this SCM. Users may override this - # by setting the :scm_command variable. - default_command "svn" - - # Subversion understands 'HEAD' to refer to the latest revision in the - # repository. - def head - "HEAD" - end - - # Returns the command that will check out the given revision to the - # given destination. - def checkout(revision, destination) - scm :checkout, arguments, verbose, authentication, "-r#{revision}", repository, destination - end - - # Returns the command that will do an "svn update" to the given - # revision, for the working copy at the given destination. - def sync(revision, destination) - scm :update, arguments, verbose, authentication, "-r#{revision}", destination - end - - # Returns the command that will do an "svn export" of the given revision - # to the given destination. - def export(revision, destination) - scm :export, arguments, verbose, authentication, "-r#{revision}", repository, destination - end - - # Returns the command that will do an "svn diff" for the two revisions. - def diff(from, to=nil) - scm :diff, repository, authentication, "-r#{from}:#{to || head}" - end - - # Returns an "svn log" command for the two revisions. - def log(from, to=nil) - scm :log, repository, authentication, "-r#{from}:#{to || head}" - end - - # Attempts to translate the given revision identifier to a "real" - # revision. If the identifier is an integer, it will simply be returned. - # Otherwise, this will yield a string of the commands it needs to be - # executed (svn info), and will extract the revision from the response. - def query_revision(revision) - return revision if revision =~ /^\d+$/ - command = scm(:info, repository, authentication, "-r#{revision}") - result = yield(command) - yaml = YAML.load(result) - raise "tried to run `#{command}' and got unexpected result #{result.inspect}" unless Hash === yaml - [ (yaml['Last Changed Rev'] || 0).to_i, (yaml['Revision'] || 0).to_i ].max - end - - # Increments the given revision number and returns it. - def next_revision(revision) - revision.to_i + 1 - end - - # Determines what the response should be for a particular bit of text - # from the SCM. Password prompts, connection requests, passphrases, - # etc. are handled here. - def handle_data(state, stream, text) - host = state[:channel][:host] - logger.info "[#{host} :: #{stream}] #{text}" - case text - when /\bpassword.*:/i - # subversion is prompting for a password - "#{scm_password_prompt}\n" - when %r{\(yes/no\)} - # subversion is asking whether or not to connect - "yes\n" - when /passphrase/i - # subversion is asking for the passphrase for the user's key - "#{variable(:scm_passphrase)}\n" - when /The entry \'(.+?)\' is no longer a directory/ - raise Capistrano::Error, "subversion can't update because directory '#{$1}' was replaced. Please add it to svn:ignore." - when /accept \(t\)emporarily/ - # subversion is asking whether to accept the certificate - "t\n" - end - end - - private - - # If a username is configured for the SCM, return the command-line - # switches for that. Note that we don't need to return the password - # switch, since Capistrano will check for that prompt in the output - # and will respond appropriately. - def authentication - username = variable(:scm_username) - return "" unless username - result = "--username #{variable(:scm_username)} " - result << "--password #{variable(:scm_password)} " unless variable(:scm_auth_cache) || variable(:scm_prefer_prompt) - result << "--no-auth-cache " unless variable(:scm_auth_cache) - result - end - - # If verbose output is requested, return nil, otherwise return the - # command-line switch for "quiet" ("-q"). - def verbose - variable(:scm_verbose) ? nil : "-q" - end - - def scm_password_prompt - @scm_password_prompt ||= variable(:scm_password) || - variable(:password) || - Capistrano::CLI.password_prompt("Subversion password: ") - end - end - - end - end -end diff --git a/vendor/gems/capistrano-2.5.9/lib/capistrano/recipes/deploy/strategy.rb b/vendor/gems/capistrano-2.5.9/lib/capistrano/recipes/deploy/strategy.rb deleted file mode 100644 index f2644457b..000000000 --- a/vendor/gems/capistrano-2.5.9/lib/capistrano/recipes/deploy/strategy.rb +++ /dev/null @@ -1,19 +0,0 @@ -module Capistrano - module Deploy - module Strategy - def self.new(strategy, config={}) - strategy_file = "capistrano/recipes/deploy/strategy/#{strategy}" - require(strategy_file) - - strategy_const = strategy.to_s.capitalize.gsub(/_(.)/) { $1.upcase } - if const_defined?(strategy_const) - const_get(strategy_const).new(config) - else - raise Capistrano::Error, "could not find `#{name}::#{strategy_const}' in `#{strategy_file}'" - end - rescue LoadError - raise Capistrano::Error, "could not find any strategy named `#{strategy}'" - end - end - end -end \ No newline at end of file diff --git a/vendor/gems/capistrano-2.5.9/lib/capistrano/recipes/deploy/strategy/base.rb b/vendor/gems/capistrano-2.5.9/lib/capistrano/recipes/deploy/strategy/base.rb deleted file mode 100644 index 86c178507..000000000 --- a/vendor/gems/capistrano-2.5.9/lib/capistrano/recipes/deploy/strategy/base.rb +++ /dev/null @@ -1,79 +0,0 @@ -require 'capistrano/recipes/deploy/dependencies' - -module Capistrano - module Deploy - module Strategy - - # This class defines the abstract interface for all Capistrano - # deployment strategies. Subclasses must implement at least the - # #deploy! method. - class Base - attr_reader :configuration - - # Instantiates a strategy with a reference to the given configuration. - def initialize(config={}) - @configuration = config - end - - # Executes the necessary commands to deploy the revision of the source - # code identified by the +revision+ variable. Additionally, this - # should write the value of the +revision+ variable to a file called - # REVISION, in the base of the deployed revision. This file is used by - # other tasks, to perform diffs and such. - def deploy! - raise NotImplementedError, "`deploy!' is not implemented by #{self.class.name}" - end - - # Performs a check on the remote hosts to determine whether everything - # is setup such that a deploy could succeed. - def check! - Dependencies.new(configuration) do |d| - d.remote.directory(configuration[:releases_path]).or("`#{configuration[:releases_path]}' does not exist. Please run `cap deploy:setup'.") - d.remote.writable(configuration[:deploy_to]).or("You do not have permissions to write to `#{configuration[:deploy_to]}'.") - d.remote.writable(configuration[:releases_path]).or("You do not have permissions to write to `#{configuration[:releases_path]}'.") - end - end - - protected - - # This is to allow helper methods like "run" and "put" to be more - # easily accessible to strategy implementations. - def method_missing(sym, *args, &block) - if configuration.respond_to?(sym) - configuration.send(sym, *args, &block) - else - super - end - end - - # A wrapper for Kernel#system that logs the command being executed. - def system(*args) - cmd = args.join(' ') - if RUBY_PLATFORM =~ /win32/ - cmd = cmd.split(/\s+/).collect {|w| w.match(/^[\w+]+:\/\//) ? w : w.gsub('/', '\\') }.join(' ') # Split command by spaces, change / by \\ unless element is a some+thing:// - cmd.gsub!(/^cd /,'cd /D ') # Replace cd with cd /D - cmd.gsub!(/&& cd /,'&& cd /D ') # Replace cd with cd /D - logger.trace "executing locally: #{cmd}" - super(cmd) - else - logger.trace "executing locally: #{cmd}" - super - end - end - - private - - def logger - @logger ||= configuration[:logger] || Capistrano::Logger.new(:output => STDOUT) - end - - # The revision to deploy. Must return a real revision identifier, - # and not a pseudo-id. - def revision - configuration[:real_revision] - end - end - - end - end -end diff --git a/vendor/gems/capistrano-2.5.9/lib/capistrano/recipes/deploy/strategy/checkout.rb b/vendor/gems/capistrano-2.5.9/lib/capistrano/recipes/deploy/strategy/checkout.rb deleted file mode 100644 index d29761fd0..000000000 --- a/vendor/gems/capistrano-2.5.9/lib/capistrano/recipes/deploy/strategy/checkout.rb +++ /dev/null @@ -1,20 +0,0 @@ -require 'capistrano/recipes/deploy/strategy/remote' - -module Capistrano - module Deploy - module Strategy - - # Implements the deployment strategy which does an SCM checkout on each - # target host. This is the default deployment strategy for Capistrano. - class Checkout < Remote - protected - - # Returns the SCM's checkout command for the revision to deploy. - def command - @command ||= source.checkout(revision, configuration[:release_path]) - end - end - - end - end -end diff --git a/vendor/gems/capistrano-2.5.9/lib/capistrano/recipes/deploy/strategy/copy.rb b/vendor/gems/capistrano-2.5.9/lib/capistrano/recipes/deploy/strategy/copy.rb deleted file mode 100644 index b4e73528a..000000000 --- a/vendor/gems/capistrano-2.5.9/lib/capistrano/recipes/deploy/strategy/copy.rb +++ /dev/null @@ -1,213 +0,0 @@ -require 'capistrano/recipes/deploy/strategy/base' -require 'fileutils' -require 'tempfile' # Dir.tmpdir - -module Capistrano - module Deploy - module Strategy - - # This class implements the strategy for deployments which work - # by preparing the source code locally, compressing it, copying the - # file to each target host, and uncompressing it to the deployment - # directory. - # - # By default, the SCM checkout command is used to obtain the local copy - # of the source code. If you would rather use the export operation, - # you can set the :copy_strategy variable to :export. - # - # set :copy_strategy, :export - # - # For even faster deployments, you can set the :copy_cache variable to - # true. This will cause deployments to do a new checkout of your - # repository to a new directory, and then copy that checkout. Subsequent - # deploys will just resync that copy, rather than doing an entirely new - # checkout. Additionally, you can specify file patterns to exclude from - # the copy when using :copy_cache; just set the :copy_exclude variable - # to a file glob (or an array of globs). - # - # set :copy_cache, true - # set :copy_exclude, ".git/*" - # - # Note that :copy_strategy is ignored when :copy_cache is set. Also, if - # you want the copy cache put somewhere specific, you can set the variable - # to the path you want, instead of merely 'true': - # - # set :copy_cache, "/tmp/caches/myapp" - # - # This deployment strategy also supports a special variable, - # :copy_compression, which must be one of :gzip, :bz2, or - # :zip, and which specifies how the source should be compressed for - # transmission to each host. - class Copy < Base - # Obtains a copy of the source code locally (via the #command method), - # compresses it to a single file, copies that file to all target - # servers, and uncompresses it on each of them into the deployment - # directory. - def deploy! - if copy_cache - if File.exists?(copy_cache) - logger.debug "refreshing local cache to revision #{revision} at #{copy_cache}" - system(source.sync(revision, copy_cache)) - else - logger.debug "preparing local cache at #{copy_cache}" - system(source.checkout(revision, copy_cache)) - end - - logger.debug "copying cache to deployment staging area #{destination}" - Dir.chdir(copy_cache) do - FileUtils.mkdir_p(destination) - queue = Dir.glob("*", File::FNM_DOTMATCH) - while queue.any? - item = queue.shift - name = File.basename(item) - - next if name == "." || name == ".." - next if copy_exclude.any? { |pattern| File.fnmatch(pattern, item) } - - if File.symlink?(item) - FileUtils.ln_s(File.readlink(File.join(copy_cache, item)), File.join(destination, item)) - elsif File.directory?(item) - queue += Dir.glob("#{item}/*", File::FNM_DOTMATCH) - FileUtils.mkdir(File.join(destination, item)) - else - FileUtils.ln(File.join(copy_cache, item), File.join(destination, item)) - end - end - end - else - logger.debug "getting (via #{copy_strategy}) revision #{revision} to #{destination}" - system(command) - - if copy_exclude.any? - logger.debug "processing exclusions..." - if copy_exclude.any? - copy_exclude.each do |pattern| - delete_list = Dir.glob(File.join(destination, pattern), File::FNM_DOTMATCH) - # avoid the /.. trap that deletes the parent directories - delete_list.delete_if { |dir| dir =~ /\/\.\.$/ } - FileUtils.rm_rf(delete_list.compact) - end - end - end - end - - File.open(File.join(destination, "REVISION"), "w") { |f| f.puts(revision) } - - logger.trace "compressing #{destination} to #{filename}" - Dir.chdir(tmpdir) { system(compress(File.basename(destination), File.basename(filename)).join(" ")) } - - upload(filename, remote_filename) - run "cd #{configuration[:releases_path]} && #{decompress(remote_filename).join(" ")} && rm #{remote_filename}" - ensure - FileUtils.rm filename rescue nil - FileUtils.rm_rf destination rescue nil - end - - def check! - super.check do |d| - d.local.command(source.local.command) if source.local.command - d.local.command(compress(nil, nil).first) - d.remote.command(decompress(nil).first) - end - end - - # Returns the location of the local copy cache, if the strategy should - # use a local cache + copy instead of a new checkout/export every - # time. Returns +nil+ unless :copy_cache has been set. If :copy_cache - # is +true+, a default cache location will be returned. - def copy_cache - @copy_cache ||= configuration[:copy_cache] == true ? - File.join(Dir.tmpdir, configuration[:application]) : - configuration[:copy_cache] - end - - private - - # Specify patterns to exclude from the copy. This is only valid - # when using a local cache. - def copy_exclude - @copy_exclude ||= Array(configuration.fetch(:copy_exclude, [])) - end - - # Returns the basename of the release_path, which will be used to - # name the local copy and archive file. - def destination - @destination ||= File.join(tmpdir, File.basename(configuration[:release_path])) - end - - # Returns the value of the :copy_strategy variable, defaulting to - # :checkout if it has not been set. - def copy_strategy - @copy_strategy ||= configuration.fetch(:copy_strategy, :checkout) - end - - # Should return the command(s) necessary to obtain the source code - # locally. - def command - @command ||= case copy_strategy - when :checkout - source.checkout(revision, destination) - when :export - source.export(revision, destination) - end - end - - # Returns the name of the file that the source code will be - # compressed to. - def filename - @filename ||= File.join(tmpdir, "#{File.basename(destination)}.#{compression.extension}") - end - - # The directory to which the copy should be checked out - def tmpdir - @tmpdir ||= configuration[:copy_dir] || Dir.tmpdir - end - - # The directory on the remote server to which the archive should be - # copied - def remote_dir - @remote_dir ||= configuration[:copy_remote_dir] || "/tmp" - end - - # The location on the remote server where the file should be - # temporarily stored. - def remote_filename - @remote_filename ||= File.join(remote_dir, File.basename(filename)) - end - - # A struct for representing the specifics of a compression type. - # Commands are arrays, where the first element is the utility to be - # used to perform the compression or decompression. - Compression = Struct.new(:extension, :compress_command, :decompress_command) - - # The compression method to use, defaults to :gzip. - def compression - remote_tar = configuration[:copy_remote_tar] || 'tar' - local_tar = configuration[:copy_local_tar] || 'tar' - - type = configuration[:copy_compression] || :gzip - case type - when :gzip, :gz then Compression.new("tar.gz", [local_tar, 'czf'], [remote_tar, 'xzf']) - when :bzip2, :bz2 then Compression.new("tar.bz2", [local_tar, 'cjf'], [remote_tar, 'xjf']) - when :zip then Compression.new("zip", %w(zip -qr), %w(unzip -q)) - else raise ArgumentError, "invalid compression type #{type.inspect}" - end - end - - # Returns the command necessary to compress the given directory - # into the given file. - def compress(directory, file) - compression.compress_command + [file, directory] - end - - # Returns the command necessary to decompress the given file, - # relative to the current working directory. It must also - # preserve the directory structure in the file. - def decompress(file) - compression.decompress_command + [file] - end - end - - end - end -end diff --git a/vendor/gems/capistrano-2.5.9/lib/capistrano/recipes/deploy/strategy/export.rb b/vendor/gems/capistrano-2.5.9/lib/capistrano/recipes/deploy/strategy/export.rb deleted file mode 100644 index 31e7ce68c..000000000 --- a/vendor/gems/capistrano-2.5.9/lib/capistrano/recipes/deploy/strategy/export.rb +++ /dev/null @@ -1,20 +0,0 @@ -require 'capistrano/recipes/deploy/strategy/remote' - -module Capistrano - module Deploy - module Strategy - - # Implements the deployment strategy which does an SCM export on each - # target host. - class Export < Remote - protected - - # Returns the SCM's export command for the revision to deploy. - def command - @command ||= source.export(revision, configuration[:release_path]) - end - end - - end - end -end diff --git a/vendor/gems/capistrano-2.5.9/lib/capistrano/recipes/deploy/strategy/remote.rb b/vendor/gems/capistrano-2.5.9/lib/capistrano/recipes/deploy/strategy/remote.rb deleted file mode 100644 index a5f0365e6..000000000 --- a/vendor/gems/capistrano-2.5.9/lib/capistrano/recipes/deploy/strategy/remote.rb +++ /dev/null @@ -1,52 +0,0 @@ -require 'capistrano/recipes/deploy/strategy/base' - -module Capistrano - module Deploy - module Strategy - - # An abstract superclass, which forms the base for all deployment - # strategies which work by grabbing the code from the repository directly - # from remote host. This includes deploying by checkout (the default), - # and deploying by export. - class Remote < Base - # Executes the SCM command for this strategy and writes the REVISION - # mark file to each host. - def deploy! - scm_run "#{command} && #{mark}" - end - - def check! - super.check do |d| - d.remote.command(source.command) - end - end - - protected - - # Runs the given command, filtering output back through the - # #handle_data filter of the SCM implementation. - def scm_run(command) - run(command) do |ch,stream,text| - ch[:state] ||= { :channel => ch } - output = source.handle_data(ch[:state], stream, text) - ch.send_data(output) if output - end - end - - # An abstract method which must be overridden in subclasses, to - # return the actual SCM command(s) which must be executed on each - # target host in order to perform the deployment. - def command - raise NotImplementedError, "`command' is not implemented by #{self.class.name}" - end - - # Returns the command which will write the identifier of the - # revision being deployed to the REVISION file on each host. - def mark - "(echo #{revision} > #{configuration[:release_path]}/REVISION)" - end - end - - end - end -end diff --git a/vendor/gems/capistrano-2.5.9/lib/capistrano/recipes/deploy/strategy/remote_cache.rb b/vendor/gems/capistrano-2.5.9/lib/capistrano/recipes/deploy/strategy/remote_cache.rb deleted file mode 100644 index f6e0def3b..000000000 --- a/vendor/gems/capistrano-2.5.9/lib/capistrano/recipes/deploy/strategy/remote_cache.rb +++ /dev/null @@ -1,56 +0,0 @@ -require 'capistrano/recipes/deploy/strategy/remote' - -module Capistrano - module Deploy - module Strategy - - # Implements the deployment strategy that keeps a cached checkout of - # the source code on each remote server. Each deploy simply updates the - # cached checkout, and then does a copy from the cached copy to the - # final deployment location. - class RemoteCache < Remote - # Executes the SCM command for this strategy and writes the REVISION - # mark file to each host. - def deploy! - update_repository_cache - copy_repository_cache - end - - def check! - super.check do |d| - d.remote.writable(shared_path) - end - end - - private - - def repository_cache - File.join(shared_path, configuration[:repository_cache] || "cached-copy") - end - - def update_repository_cache - logger.trace "updating the cached checkout on all servers" - command = "if [ -d #{repository_cache} ]; then " + - "#{source.sync(revision, repository_cache)}; " + - "else #{source.checkout(revision, repository_cache)}; fi" - scm_run(command) - end - - def copy_repository_cache - logger.trace "copying the cached version to #{configuration[:release_path]}" - if copy_exclude.empty? - run "cp -RPp #{repository_cache} #{configuration[:release_path]} && #{mark}" - else - exclusions = copy_exclude.map { |e| "--exclude=\"#{e}\"" }.join(' ') - run "rsync -lrpt #{exclusions} #{repository_cache}/* #{configuration[:release_path]} && #{mark}" - end - end - - def copy_exclude - @copy_exclude ||= Array(configuration.fetch(:copy_exclude, [])) - end - end - - end - end -end diff --git a/vendor/gems/capistrano-2.5.9/lib/capistrano/recipes/deploy/templates/maintenance.rhtml b/vendor/gems/capistrano-2.5.9/lib/capistrano/recipes/deploy/templates/maintenance.rhtml deleted file mode 100644 index 924f4c0bb..000000000 --- a/vendor/gems/capistrano-2.5.9/lib/capistrano/recipes/deploy/templates/maintenance.rhtml +++ /dev/null @@ -1,53 +0,0 @@ - - - - - - - - System down for maintenance - - - - - - -
-
-
-

- The system is down for <%= reason ? reason : "maintenance" %> - as of <%= Time.now.strftime("%H:%M %Z") %>. -

-

- It'll be back <%= deadline ? deadline : "shortly" %>. -

-
-
-
- - - diff --git a/vendor/gems/capistrano-2.5.9/lib/capistrano/recipes/standard.rb b/vendor/gems/capistrano-2.5.9/lib/capistrano/recipes/standard.rb deleted file mode 100644 index 35924d6d2..000000000 --- a/vendor/gems/capistrano-2.5.9/lib/capistrano/recipes/standard.rb +++ /dev/null @@ -1,37 +0,0 @@ -desc <<-DESC - Invoke a single command on the remote servers. This is useful for performing \ - one-off commands that may not require a full task to be written for them. \ - Simply specify the command to execute via the COMMAND environment variable. \ - To execute the command only on certain roles, specify the ROLES environment \ - variable as a comma-delimited list of role names. Alternatively, you can \ - specify the HOSTS environment variable as a comma-delimited list of hostnames \ - to execute the task on those hosts, explicitly. Lastly, if you want to \ - execute the command via sudo, specify a non-empty value for the SUDO \ - environment variable. - - Sample usage: - - $ cap COMMAND=uptime HOSTS=foo.capistano.test invoke - $ cap ROLES=app,web SUDO=1 COMMAND="tail -f /var/log/messages" invoke -DESC -task :invoke do - command = ENV["COMMAND"] || "" - abort "Please specify a command to execute on the remote servers (via the COMMAND environment variable)" if command.empty? - method = ENV["SUDO"] ? :sudo : :run - invoke_command(command, :via => method) -end - -desc <<-DESC - Begin an interactive Capistrano session. This gives you an interactive \ - terminal from which to execute tasks and commands on all of your servers. \ - (This is still an experimental feature, and is subject to change without \ - notice!) - - Sample usage: - - $ cap shell -DESC -task :shell do - require 'capistrano/shell' - Capistrano::Shell.run(self) -end \ No newline at end of file diff --git a/vendor/gems/capistrano-2.5.9/lib/capistrano/recipes/templates/maintenance.rhtml b/vendor/gems/capistrano-2.5.9/lib/capistrano/recipes/templates/maintenance.rhtml deleted file mode 100644 index 924f4c0bb..000000000 --- a/vendor/gems/capistrano-2.5.9/lib/capistrano/recipes/templates/maintenance.rhtml +++ /dev/null @@ -1,53 +0,0 @@ - - - - - - - - System down for maintenance - - - - - - -
-
-
-

- The system is down for <%= reason ? reason : "maintenance" %> - as of <%= Time.now.strftime("%H:%M %Z") %>. -

-

- It'll be back <%= deadline ? deadline : "shortly" %>. -

-
-
-
- - - diff --git a/vendor/gems/capistrano-2.5.9/lib/capistrano/recipes/upgrade.rb b/vendor/gems/capistrano-2.5.9/lib/capistrano/recipes/upgrade.rb deleted file mode 100644 index c604cf42e..000000000 --- a/vendor/gems/capistrano-2.5.9/lib/capistrano/recipes/upgrade.rb +++ /dev/null @@ -1,33 +0,0 @@ -# Tasks to aid the migration of an established Capistrano 1.x installation to -# Capistrano 2.x. - -namespace :upgrade do - desc <<-DESC - Migrate from the revisions log to REVISION. Capistrano 1.x recorded each \ - deployment to a revisions.log file. Capistrano 2.x is cleaner, and just \ - puts a REVISION file in the root of the deployed revision. This task \ - migrates from the revisions.log used in Capistrano 1.x, to the REVISION \ - tag file used in Capistrano 2.x. It is non-destructive and may be safely \ - run any number of times. - DESC - task :revisions, :except => { :no_release => true } do - revisions = capture("cat #{deploy_to}/revisions.log") - - mapping = {} - revisions.each do |line| - revision, directory = line.chomp.split[-2,2] - mapping[directory] = revision - end - - commands = mapping.keys.map do |directory| - "echo '.'; test -d #{directory} && echo '#{mapping[directory]}' > #{directory}/REVISION" - end - - command = commands.join(";") - - run "cd #{releases_path}; #{command}; true" do |ch, stream, out| - STDOUT.print(".") - STDOUT.flush - end - end -end diff --git a/vendor/gems/capistrano-2.5.9/lib/capistrano/role.rb b/vendor/gems/capistrano-2.5.9/lib/capistrano/role.rb deleted file mode 100644 index 0e0dcf8e7..000000000 --- a/vendor/gems/capistrano-2.5.9/lib/capistrano/role.rb +++ /dev/null @@ -1,102 +0,0 @@ -module Capistrano - class Role - include Enumerable - - def initialize(*list) - @static_servers = [] - @dynamic_servers = [] - push(*list) - end - - def each(&block) - servers.each &block - end - - def push(*list) - options = list.last.is_a?(Hash) ? list.pop : {} - list.each do |item| - if item.respond_to?(:call) - @dynamic_servers << DynamicServerList.new(item, options) - else - @static_servers << self.class.wrap_server(item, options) - end - end - end - alias_method :<<, :push - - def servers - @static_servers + dynamic_servers - end - alias_method :to_ary, :servers - - def empty? - servers.empty? - end - - def clear - @dynamic_servers.clear - @static_servers.clear - end - - def include?(server) - servers.include?(server) - end - - protected - - # This is the combination of a block, a hash of options, and a cached value. - class DynamicServerList - def initialize (block, options) - @block = block - @options = options - @cached = [] - @is_cached = false - end - - # Convert to a list of ServerDefinitions - def to_ary - unless @is_cached - @cached = Role::wrap_list(@block.call(@options), @options) - @is_cached = true - end - @cached - end - - # Clear the cached value - def reset! - @cached.clear - @is_cached = false - end - end - - # Attribute reader for the cached results of executing the blocks in turn - def dynamic_servers - @dynamic_servers.inject([]) { |list, item| list.concat item } - end - - # Wraps a string in a ServerDefinition, if it isn't already. - # This and wrap_list should probably go in ServerDefinition in some form. - def self.wrap_server (item, options) - item.is_a?(ServerDefinition) ? item : ServerDefinition.new(item, options) - end - - # Turns a list, or something resembling a list, into a properly-formatted - # ServerDefinition list. Keep an eye on this one -- it's entirely too - # magical for its own good. In particular, if ServerDefinition ever inherits - # from Array, this will break. - def self.wrap_list (*list) - options = list.last.is_a?(Hash) ? list.pop : {} - if list.length == 1 - if list.first.nil? - return [] - elsif list.first.is_a?(Array) - list = list.first - end - end - options.merge! list.pop if list.last.is_a?(Hash) - list.map do |item| - self.wrap_server item, options - end - end - end -end diff --git a/vendor/gems/capistrano-2.5.9/lib/capistrano/server_definition.rb b/vendor/gems/capistrano-2.5.9/lib/capistrano/server_definition.rb deleted file mode 100644 index 4c784bb9c..000000000 --- a/vendor/gems/capistrano-2.5.9/lib/capistrano/server_definition.rb +++ /dev/null @@ -1,56 +0,0 @@ -module Capistrano - class ServerDefinition - include Comparable - - attr_reader :host - attr_reader :user - attr_reader :port - attr_reader :options - - # The default user name to use when a user name is not explicitly provided - def self.default_user - ENV['USER'] || ENV['USERNAME'] || "not-specified" - end - - def initialize(string, options={}) - @user, @host, @port = string.match(/^(?:([^;,:=]+)@|)(.*?)(?::(\d+)|)$/)[1,3] - - @options = options.dup - user_opt, port_opt = @options.delete(:user), @options.delete(:port) - - @user ||= user_opt - @port ||= port_opt - - @port = @port.to_i if @port - end - - def <=>(server) - [host, port, user] <=> [server.host, server.port, server.user] - end - - # Redefined, so that Array#uniq will work to remove duplicate server - # definitions, based solely on their host names. - def eql?(server) - host == server.host && - user == server.user && - port == server.port - end - - alias :== :eql? - - # Redefined, so that Array#uniq will work to remove duplicate server - # definitions, based on their connection information. - def hash - @hash ||= [host, user, port].hash - end - - def to_s - @to_s ||= begin - s = host - s = "#{user}@#{s}" if user - s = "#{s}:#{port}" if port && port != 22 - s - end - end - end -end \ No newline at end of file diff --git a/vendor/gems/capistrano-2.5.9/lib/capistrano/shell.rb b/vendor/gems/capistrano-2.5.9/lib/capistrano/shell.rb deleted file mode 100644 index ea8346ea8..000000000 --- a/vendor/gems/capistrano-2.5.9/lib/capistrano/shell.rb +++ /dev/null @@ -1,260 +0,0 @@ -require 'thread' -require 'capistrano/processable' - -module Capistrano - # The Capistrano::Shell class is the guts of the "shell" task. It implements - # an interactive REPL interface that users can employ to execute tasks and - # commands. It makes for a GREAT way to monitor systems, and perform quick - # maintenance on one or more machines. - class Shell - include Processable - - # A Readline replacement for platforms where readline is either - # unavailable, or has not been installed. - class ReadlineFallback #:nodoc: - HISTORY = [] - - def self.readline(prompt) - STDOUT.print(prompt) - STDOUT.flush - STDIN.gets - end - end - - # The configuration instance employed by this shell - attr_reader :configuration - - # Instantiate a new shell and begin executing it immediately. - def self.run(config) - new(config).run! - end - - # Instantiate a new shell - def initialize(config) - @configuration = config - end - - # Start the shell running. This method will block until the shell - # terminates. - def run! - setup - - puts <<-INTRO -==================================================================== -Welcome to the interactive Capistrano shell! This is an experimental -feature, and is liable to change in future releases. Type 'help' for -a summary of how to use the shell. --------------------------------------------------------------------- -INTRO - - loop do - break if !read_and_execute - end - - @bgthread.kill - end - - def read_and_execute - command = read_line - - case command - when "?", "help" then help - when "quit", "exit" then - puts "exiting" - return false - when /^set -(\w)\s*(\S+)/ - set_option($1, $2) - when /^(?:(with|on)\s*(\S+))?\s*(\S.*)?/i - process_command($1, $2, $3) - else - raise "eh?" - end - - return true - end - - private - - # Present the prompt and read a single line from the console. It also - # detects ^D and returns "exit" in that case. Adds the input to the - # history, unless the input is empty. Loops repeatedly until a non-empty - # line is input. - def read_line - loop do - command = reader.readline("cap> ") - - if command.nil? - command = "exit" - puts(command) - else - command.strip! - end - - unless command.empty? - reader::HISTORY << command - return command - end - end - end - - # Display a verbose help message. - def help - puts <<-HELP ---- HELP! --------------------------------------------------- -"Get me out of this thing. I just want to quit." --> Easy enough. Just type "exit", or "quit". Or press ctrl-D. - -"I want to execute a command on all servers." --> Just type the command, and press enter. It will be passed, - verbatim, to all defined servers. - -"What if I only want it to execute on a subset of them?" --> No problem, just specify the list of servers, separated by - commas, before the command, with the `on' keyword: - - cap> on app1.foo.com,app2.foo.com echo ping - -"Nice, but can I specify the servers by role?" --> You sure can. Just use the `with' keyword, followed by the - comma-delimited list of role names: - - cap> with app,db echo ping - -"Can I execute a Capistrano task from within this shell?" --> Yup. Just prefix the task with an exclamation mark: - - cap> !deploy -HELP - end - - # Determine which servers the given task requires a connection to, and - # establish connections to them if necessary. Return the list of - # servers (names). - def connect(task) - servers = configuration.find_servers_for_task(task) - needing_connections = servers - configuration.sessions.keys - unless needing_connections.empty? - puts "[establishing connection(s) to #{needing_connections.join(', ')}]" - configuration.establish_connections_to(needing_connections) - end - servers - end - - # Execute the given command. If the command is prefixed by an exclamation - # mark, it is assumed to refer to another capistrano task, which will - # be invoked. Otherwise, it is executed as a command on all associated - # servers. - def exec(command) - @mutex.synchronize do - if command[0] == ?! - exec_tasks(command[1..-1].split) - else - servers = connect(configuration.current_task) - exec_command(command, servers) - end - end - ensure - STDOUT.flush - end - - # Given an array of task names, invoke them in sequence. - def exec_tasks(list) - list.each do |task_name| - task = configuration.find_task(task_name) - raise Capistrano::NoSuchTaskError, "no such task `#{task_name}'" unless task - connect(task) - configuration.execute_task(task) - end - rescue Capistrano::NoMatchingServersError, Capistrano::NoSuchTaskError => error - warn "error: #{error.message}" - end - - # Execute a command on the given list of servers. - def exec_command(command, servers) - command = command.gsub(/\bsudo\b/, "sudo -p '#{configuration.sudo_prompt}'") - processor = configuration.sudo_behavior_callback(Configuration.default_io_proc) - sessions = servers.map { |server| configuration.sessions[server] } - options = configuration.add_default_command_options({}) - cmd = Command.new(command, sessions, options.merge(:logger => configuration.logger), &processor) - previous = trap("INT") { cmd.stop! } - cmd.process! - rescue Capistrano::Error => error - warn "error: #{error.message}" - ensure - trap("INT", previous) - end - - # Return the object that will be used to query input from the console. - # The returned object will quack (more or less) like Readline. - def reader - @reader ||= begin - require 'readline' - Readline - rescue LoadError - ReadlineFallback - end - end - - # Prepare every little thing for the shell. Starts the background - # thread and generally gets things ready for the REPL. - def setup - configuration.logger.level = Capistrano::Logger::INFO - - @mutex = Mutex.new - @bgthread = Thread.new do - loop do - @mutex.synchronize { process_iteration(0.1) } - end - end - end - - # Set the given option to +value+. - def set_option(opt, value) - case opt - when "v" then - puts "setting log verbosity to #{value.to_i}" - configuration.logger.level = value.to_i - when "o" then - case value - when "vi" then - puts "using vi edit mode" - reader.vi_editing_mode - when "emacs" then - puts "using emacs edit mode" - reader.emacs_editing_mode - else - puts "unknown -o option #{value.inspect}" - end - else - puts "unknown setting #{opt.inspect}" - end - end - - # Process a command. Interprets the scope_type (must be nil, "with", or - # "on") and the command. If no command is given, then the scope is made - # effective for all subsequent commands. If the scope value is "all", - # then the scope is unrestricted. - def process_command(scope_type, scope_value, command) - env_var = case scope_type - when "with" then "ROLES" - when "on" then "HOSTS" - end - - old_var, ENV[env_var] = ENV[env_var], (scope_value == "all" ? nil : scope_value) if env_var - if command - begin - exec(command) - ensure - ENV[env_var] = old_var if env_var - end - else - puts "scoping #{scope_type} #{scope_value}" - end - end - end - - # All open sessions, needed to satisfy the Command::Processable include - def sessions - configuration.sessions.values - end -end diff --git a/vendor/gems/capistrano-2.5.9/lib/capistrano/ssh.rb b/vendor/gems/capistrano-2.5.9/lib/capistrano/ssh.rb deleted file mode 100644 index 1f9540ba7..000000000 --- a/vendor/gems/capistrano-2.5.9/lib/capistrano/ssh.rb +++ /dev/null @@ -1,99 +0,0 @@ -begin - require 'rubygems' - gem 'net-ssh', ">= 2.0.10" -rescue LoadError, NameError -end - -require 'net/ssh' - -module Capistrano - # A helper class for dealing with SSH connections. - class SSH - # Patch an accessor onto an SSH connection so that we can record the server - # definition object that defines the connection. This is useful because - # the gateway returns connections whose "host" is 127.0.0.1, instead of - # the host on the other side of the tunnel. - module Server #:nodoc: - def self.apply_to(connection, server) - connection.extend(Server) - connection.xserver = server - connection - end - - attr_accessor :xserver - end - - # An abstraction to make it possible to connect to the server via public key - # without prompting for the password. If the public key authentication fails - # this will fall back to password authentication. - # - # +server+ must be an instance of ServerDefinition. - # - # If a block is given, the new session is yielded to it, otherwise the new - # session is returned. - # - # If an :ssh_options key exists in +options+, it is passed to the Net::SSH - # constructor. Values in +options+ are then merged into it, and any - # connection information in +server+ is added last, so that +server+ info - # takes precedence over +options+, which takes precendence over ssh_options. - def self.connect(server, options={}) - connection_strategy(server, options) do |host, user, connection_options| - connection = Net::SSH.start(host, user, connection_options) - Server.apply_to(connection, server) - end - end - - # Abstracts the logic for establishing an SSH connection (which includes - # testing for connection failures and retrying with a password, and so forth, - # mostly made complicated because of the fact that some of these variables - # might be lazily evaluated and try to do something like prompt the user, - # which should only happen when absolutely necessary. - # - # This will yield the hostname, username, and a hash of connection options - # to the given block, which should return a new connection. - def self.connection_strategy(server, options={}, &block) - methods = [ %w(publickey hostbased), %w(password keyboard-interactive) ] - password_value = nil - - # construct the hash of ssh options that should be passed more-or-less - # directly to Net::SSH. This will be the general ssh options, merged with - # the server-specific ssh-options. - ssh_options = (options[:ssh_options] || {}).merge(server.options[:ssh_options] || {}) - - # load any SSH configuration files that were specified in the SSH options. This - # will load from ~/.ssh/config and /etc/ssh_config by default (see Net::SSH - # for details). Merge the explicitly given ssh_options over the top of the info - # from the config file. - ssh_options = Net::SSH.configuration_for(server.host, ssh_options.fetch(:config, true)).merge(ssh_options) - - # Once we've loaded the config, we don't need Net::SSH to do it again. - ssh_options[:config] = false - - user = server.user || options[:user] || ssh_options[:username] || - ssh_options[:user] || ServerDefinition.default_user - port = server.port || options[:port] || ssh_options[:port] - - # the .ssh/config file might have changed the host-name on us - host = ssh_options.fetch(:host_name, server.host) - - ssh_options[:port] = port if port - - # delete these, since we've determined which username to use by this point - ssh_options.delete(:username) - ssh_options.delete(:user) - - begin - connection_options = ssh_options.merge( - :password => password_value, - :auth_methods => ssh_options[:auth_methods] || methods.shift - ) - - yield host, user, connection_options - rescue Net::SSH::AuthenticationFailed - raise if methods.empty? || ssh_options[:auth_methods] - password_value = options[:password] - retry - end - end - end -end diff --git a/vendor/gems/capistrano-2.5.9/lib/capistrano/task_definition.rb b/vendor/gems/capistrano-2.5.9/lib/capistrano/task_definition.rb deleted file mode 100644 index 7874dd9dd..000000000 --- a/vendor/gems/capistrano-2.5.9/lib/capistrano/task_definition.rb +++ /dev/null @@ -1,70 +0,0 @@ -require 'capistrano/server_definition' - -module Capistrano - # Represents the definition of a single task. - class TaskDefinition - attr_reader :name, :namespace, :options, :body, :desc, :on_error, :max_hosts - - def initialize(name, namespace, options={}, &block) - @name, @namespace, @options = name, namespace, options - @desc = @options.delete(:desc) - @on_error = options.delete(:on_error) - @max_hosts = options[:max_hosts] && options[:max_hosts].to_i - @body = block or raise ArgumentError, "a task requires a block" - @servers = nil - end - - # Returns the task's fully-qualified name, including the namespace - def fully_qualified_name - @fully_qualified_name ||= begin - if namespace.default_task == self - namespace.fully_qualified_name - else - [namespace.fully_qualified_name, name].compact.join(":") - end - end - end - - # Returns the description for this task, with newlines collapsed and - # whitespace stripped. Returns the empty string if there is no - # description for this task. - def description(rebuild=false) - @description = nil if rebuild - @description ||= begin - description = @desc || "" - - indentation = description[/\A\s+/] - if indentation - reformatted_description = "" - description.strip.each_line do |line| - line = line.chomp.sub(/^#{indentation}/, "") - line = line.gsub(/#{indentation}\s*/, " ") if line[/^\S/] - reformatted_description << line << "\n" - end - description = reformatted_description - end - - description.strip.gsub(/\r\n/, "\n") - end - end - - # Returns the first sentence of the full description. If +max_length+ is - # given, the result will be truncated if it is longer than +max_length+, - # and an ellipsis appended. - def brief_description(max_length=nil) - brief = description[/^.*?\.(?=\s|$)/] || description - - if max_length && brief.length > max_length - brief = brief[0,max_length-3] + "..." - end - - brief - end - - # Indicates whether the task wants to continue, even if a server has failed - # previously - def continue_on_error? - @on_error == :continue - end - end -end \ No newline at end of file diff --git a/vendor/gems/capistrano-2.5.9/lib/capistrano/transfer.rb b/vendor/gems/capistrano-2.5.9/lib/capistrano/transfer.rb deleted file mode 100644 index c1b75e889..000000000 --- a/vendor/gems/capistrano-2.5.9/lib/capistrano/transfer.rb +++ /dev/null @@ -1,216 +0,0 @@ -require 'net/scp' -require 'net/sftp' - -require 'capistrano/processable' - -module Capistrano - class Transfer - include Processable - - def self.process(direction, from, to, sessions, options={}, &block) - new(direction, from, to, sessions, options, &block).process! - end - - attr_reader :sessions - attr_reader :options - attr_reader :callback - - attr_reader :transport - attr_reader :direction - attr_reader :from - attr_reader :to - - attr_reader :logger - attr_reader :transfers - - def initialize(direction, from, to, sessions, options={}, &block) - @direction = direction - @from = from - @to = to - @sessions = sessions - @options = options - @callback = block - - @transport = options.fetch(:via, :sftp) - @logger = options.delete(:logger) - - @session_map = {} - - prepare_transfers - end - - def process! - loop do - begin - break unless process_iteration { active? } - rescue Exception => error - if error.respond_to?(:session) - handle_error(error) - else - raise - end - end - end - - failed = transfers.select { |txfr| txfr[:failed] } - if failed.any? - hosts = failed.map { |txfr| txfr[:server] } - errors = failed.map { |txfr| "#{txfr[:error]} (#{txfr[:error].message})" }.uniq.join(", ") - error = TransferError.new("#{operation} via #{transport} failed on #{hosts.join(',')}: #{errors}") - error.hosts = hosts - - logger.important(error.message) if logger - raise error - end - - logger.debug "#{transport} #{operation} complete" if logger - self - end - - def active? - transfers.any? { |transfer| transfer.active? } - end - - def operation - "#{direction}load" - end - - def sanitized_from - if from.responds_to?(:read) - "#<#{from.class}>" - else - from - end - end - - def sanitized_to - if to.responds_to?(:read) - "#<#{to.class}>" - else - to - end - end - - private - - def session_map - @session_map - end - - def prepare_transfers - logger.info "#{transport} #{operation} #{from} -> #{to}" if logger - - @transfers = sessions.map do |session| - session_from = normalize(from, session) - session_to = normalize(to, session) - - session_map[session] = case transport - when :sftp - prepare_sftp_transfer(session_from, session_to, session) - when :scp - prepare_scp_transfer(session_from, session_to, session) - else - raise ArgumentError, "unsupported transport type: #{transport.inspect}" - end - end - end - - def prepare_scp_transfer(from, to, session) - real_callback = callback || Proc.new do |channel, name, sent, total| - logger.trace "[#{channel[:host]}] #{name}" if logger && sent == 0 - end - - channel = case direction - when :up - session.scp.upload(from, to, options, &real_callback) - when :down - session.scp.download(from, to, options, &real_callback) - else - raise ArgumentError, "unsupported transfer direction: #{direction.inspect}" - end - - channel[:server] = session.xserver - channel[:host] = session.xserver.host - - return channel - end - - class SFTPTransferWrapper - attr_reader :operation - - def initialize(session, &callback) - session.sftp(false).connect do |sftp| - @operation = callback.call(sftp) - end - end - - def active? - @operation.nil? || @operation.active? - end - - def [](key) - @operation[key] - end - - def []=(key, value) - @operation[key] = value - end - - def abort! - @operation.abort! - end - end - - def prepare_sftp_transfer(from, to, session) - SFTPTransferWrapper.new(session) do |sftp| - real_callback = Proc.new do |event, op, *args| - if callback - callback.call(event, op, *args) - elsif event == :open - logger.trace "[#{op[:host]}] #{args[0].remote}" - elsif event == :finish - logger.trace "[#{op[:host]}] done" - end - end - - opts = options.dup - opts[:properties] = (opts[:properties] || {}).merge( - :server => session.xserver, - :host => session.xserver.host) - - case direction - when :up - sftp.upload(from, to, opts, &real_callback) - when :down - sftp.download(from, to, opts, &real_callback) - else - raise ArgumentError, "unsupported transfer direction: #{direction.inspect}" - end - end - end - - def normalize(argument, session) - if argument.is_a?(String) - argument.gsub(/\$CAPISTRANO:HOST\$/, session.xserver.host) - elsif argument.respond_to?(:read) - pos = argument.pos - clone = StringIO.new(argument.read) - clone.pos = argument.pos = pos - clone - else - argument - end - end - - def handle_error(error) - transfer = session_map[error.session] - transfer[:error] = error - transfer[:failed] = true - - case transport - when :sftp then transfer.abort! - when :scp then transfer.close - end - end - end -end diff --git a/vendor/gems/capistrano-2.5.9/lib/capistrano/version.rb b/vendor/gems/capistrano-2.5.9/lib/capistrano/version.rb deleted file mode 100644 index 765bec8eb..000000000 --- a/vendor/gems/capistrano-2.5.9/lib/capistrano/version.rb +++ /dev/null @@ -1,18 +0,0 @@ -require 'net/ssh/version' - -module Capistrano - - # Describes the current version of Capistrano. - class Version < Net::SSH::Version - MAJOR = 2 - MINOR = 5 - TINY = 9 - - # The current version, as a Version instance - CURRENT = new(MAJOR, MINOR, TINY) - - # The current version, as a String instance - STRING = CURRENT.to_s - end - -end diff --git a/vendor/gems/capistrano-2.5.9/setup.rb b/vendor/gems/capistrano-2.5.9/setup.rb deleted file mode 100644 index 72a5bd349..000000000 --- a/vendor/gems/capistrano-2.5.9/setup.rb +++ /dev/null @@ -1,1346 +0,0 @@ -# -# setup.rb -# -# Copyright (c) 2000-2004 Minero Aoki -# -# This program is free software. -# You can distribute/modify this program under the terms of -# the GNU Lesser General Public License version 2.1. -# - -# -# For backward compatibility -# - -unless Enumerable.method_defined?(:map) - module Enumerable - alias map collect - end -end - -unless Enumerable.method_defined?(:detect) - module Enumerable - alias detect find - end -end - -unless Enumerable.method_defined?(:select) - module Enumerable - alias select find_all - end -end - -unless Enumerable.method_defined?(:reject) - module Enumerable - def reject - result = [] - each do |i| - result.push i unless yield(i) - end - result - end - end -end - -unless Enumerable.method_defined?(:inject) - module Enumerable - def inject(result) - each do |i| - result = yield(result, i) - end - result - end - end -end - -unless Enumerable.method_defined?(:any?) - module Enumerable - def any? - each do |i| - return true if yield(i) - end - false - end - end -end - -unless File.respond_to?(:read) - def File.read(fname) - open(fname) {|f| - return f.read - } - end -end - -# -# Application independent utilities -# - -def File.binread(fname) - open(fname, 'rb') {|f| - return f.read - } -end - -# for corrupted windows stat(2) -def File.dir?(path) - File.directory?((path[-1,1] == '/') ? path : path + '/') -end - -# -# Config -# - -if arg = ARGV.detect{|arg| /\A--rbconfig=/ =~ arg } - ARGV.delete(arg) - require arg.split(/=/, 2)[1] - $".push 'rbconfig.rb' -else - require 'rbconfig' -end - -def multipackage_install? - FileTest.directory?(File.dirname($0) + '/packages') -end - - -class ConfigTable - - c = ::Config::CONFIG - - rubypath = c['bindir'] + '/' + c['ruby_install_name'] - - major = c['MAJOR'].to_i - minor = c['MINOR'].to_i - teeny = c['TEENY'].to_i - version = "#{major}.#{minor}" - - # ruby ver. >= 1.4.4? - newpath_p = ((major >= 2) or - ((major == 1) and - ((minor >= 5) or - ((minor == 4) and (teeny >= 4))))) - - subprefix = lambda {|path| - path.sub(/\A#{Regexp.quote(c['prefix'])}/o, '$prefix') - } - - if c['rubylibdir'] - # V < 1.6.3 - stdruby = subprefix.call(c['rubylibdir']) - siteruby = subprefix.call(c['sitedir']) - versite = subprefix.call(c['sitelibdir']) - sodir = subprefix.call(c['sitearchdir']) - elsif newpath_p - # 1.4.4 <= V <= 1.6.3 - stdruby = "$prefix/lib/ruby/#{version}" - siteruby = subprefix.call(c['sitedir']) - versite = siteruby + '/' + version - sodir = "$site-ruby/#{c['arch']}" - else - # V < 1.4.4 - stdruby = "$prefix/lib/ruby/#{version}" - siteruby = "$prefix/lib/ruby/#{version}/site_ruby" - versite = siteruby - sodir = "$site-ruby/#{c['arch']}" - end - - if arg = c['configure_args'].split.detect {|arg| /--with-make-prog=/ =~ arg } - makeprog = arg.sub(/'/, '').split(/=/, 2)[1] - else - makeprog = 'make' - end - - common_descripters = [ - [ 'prefix', [ c['prefix'], - 'path', - 'path prefix of target environment' ] ], - [ 'std-ruby', [ stdruby, - 'path', - 'the directory for standard ruby libraries' ] ], - [ 'site-ruby-common', [ siteruby, - 'path', - 'the directory for version-independent non-standard ruby libraries' ] ], - [ 'site-ruby', [ versite, - 'path', - 'the directory for non-standard ruby libraries' ] ], - [ 'bin-dir', [ '$prefix/bin', - 'path', - 'the directory for commands' ] ], - [ 'rb-dir', [ '$site-ruby', - 'path', - 'the directory for ruby scripts' ] ], - [ 'so-dir', [ sodir, - 'path', - 'the directory for ruby extentions' ] ], - [ 'data-dir', [ '$prefix/share', - 'path', - 'the directory for shared data' ] ], - [ 'ruby-path', [ rubypath, - 'path', - 'path to set to #! line' ] ], - [ 'ruby-prog', [ rubypath, - 'name', - 'the ruby program using for installation' ] ], - [ 'make-prog', [ makeprog, - 'name', - 'the make program to compile ruby extentions' ] ], - [ 'without-ext', [ 'no', - 'yes/no', - 'does not compile/install ruby extentions' ] ] - ] - multipackage_descripters = [ - [ 'with', [ '', - 'name,name...', - 'package names that you want to install', - 'ALL' ] ], - [ 'without', [ '', - 'name,name...', - 'package names that you do not want to install', - 'NONE' ] ] - ] - if multipackage_install? - DESCRIPTER = common_descripters + multipackage_descripters - else - DESCRIPTER = common_descripters - end - - SAVE_FILE = 'config.save' - - def ConfigTable.each_name(&block) - keys().each(&block) - end - - def ConfigTable.keys - DESCRIPTER.map {|name, *dummy| name } - end - - def ConfigTable.each_definition(&block) - DESCRIPTER.each(&block) - end - - def ConfigTable.get_entry(name) - name, ent = DESCRIPTER.assoc(name) - ent - end - - def ConfigTable.get_entry!(name) - get_entry(name) or raise ArgumentError, "no such config: #{name}" - end - - def ConfigTable.add_entry(name, vals) - ConfigTable::DESCRIPTER.push [name,vals] - end - - def ConfigTable.remove_entry(name) - get_entry(name) or raise ArgumentError, "no such config: #{name}" - DESCRIPTER.delete_if {|n, arr| n == name } - end - - def ConfigTable.config_key?(name) - get_entry(name) ? true : false - end - - def ConfigTable.bool_config?(name) - ent = get_entry(name) or return false - ent[1] == 'yes/no' - end - - def ConfigTable.value_config?(name) - ent = get_entry(name) or return false - ent[1] != 'yes/no' - end - - def ConfigTable.path_config?(name) - ent = get_entry(name) or return false - ent[1] == 'path' - end - - - class << self - alias newobj new - end - - def ConfigTable.new - c = newobj() - c.initialize_from_table - c - end - - def ConfigTable.load - c = newobj() - c.initialize_from_file - c - end - - def initialize_from_table - @table = {} - DESCRIPTER.each do |k, (default, vname, desc, default2)| - @table[k] = default - end - end - - def initialize_from_file - raise InstallError, "#{File.basename $0} config first"\ - unless File.file?(SAVE_FILE) - @table = {} - File.foreach(SAVE_FILE) do |line| - k, v = line.split(/=/, 2) - @table[k] = v.strip - end - end - - def save - File.open(SAVE_FILE, 'w') {|f| - @table.each do |k, v| - f.printf "%s=%s\n", k, v if v - end - } - end - - def []=(k, v) - raise InstallError, "unknown config option #{k}"\ - unless ConfigTable.config_key?(k) - @table[k] = v - end - - def [](key) - return nil unless @table[key] - @table[key].gsub(%r<\$([^/]+)>) { self[$1] } - end - - def set_raw(key, val) - @table[key] = val - end - - def get_raw(key) - @table[key] - end - -end - - -module MetaConfigAPI - - def eval_file_ifexist(fname) - instance_eval File.read(fname), fname, 1 if File.file?(fname) - end - - def config_names - ConfigTable.keys - end - - def config?(name) - ConfigTable.config_key?(name) - end - - def bool_config?(name) - ConfigTable.bool_config?(name) - end - - def value_config?(name) - ConfigTable.value_config?(name) - end - - def path_config?(name) - ConfigTable.path_config?(name) - end - - def add_config(name, argname, default, desc) - ConfigTable.add_entry name,[default,argname,desc] - end - - def add_path_config(name, default, desc) - add_config name, 'path', default, desc - end - - def add_bool_config(name, default, desc) - add_config name, 'yes/no', default ? 'yes' : 'no', desc - end - - def set_config_default(name, default) - if bool_config?(name) - ConfigTable.get_entry!(name)[0] = (default ? 'yes' : 'no') - else - ConfigTable.get_entry!(name)[0] = default - end - end - - def remove_config(name) - ent = ConfigTable.get_entry(name) - ConfigTable.remove_entry name - ent - end - -end - -# -# File Operations -# - -module FileOperations - - def mkdir_p(dirname, prefix = nil) - dirname = prefix + dirname if prefix - $stderr.puts "mkdir -p #{dirname}" if verbose? - return if no_harm? - - # does not check '/'... it's too abnormal case - dirs = dirname.split(%r<(?=/)>) - if /\A[a-z]:\z/i =~ dirs[0] - disk = dirs.shift - dirs[0] = disk + dirs[0] - end - dirs.each_index do |idx| - path = dirs[0..idx].join('') - Dir.mkdir path unless File.dir?(path) - end - end - - def rm_f(fname) - $stderr.puts "rm -f #{fname}" if verbose? - return if no_harm? - - if File.exist?(fname) or File.symlink?(fname) - File.chmod 0777, fname - File.unlink fname - end - end - - def rm_rf(dn) - $stderr.puts "rm -rf #{dn}" if verbose? - return if no_harm? - - Dir.chdir dn - Dir.foreach('.') do |fn| - next if fn == '.' - next if fn == '..' - if File.dir?(fn) - verbose_off { - rm_rf fn - } - else - verbose_off { - rm_f fn - } - end - end - Dir.chdir '..' - Dir.rmdir dn - end - - def move_file(src, dest) - File.unlink dest if File.exist?(dest) - begin - File.rename src, dest - rescue - File.open(dest, 'wb') {|f| f.write File.binread(src) } - File.chmod File.stat(src).mode, dest - File.unlink src - end - end - - def install(from, dest, mode, prefix = nil) - $stderr.puts "install #{from} #{dest}" if verbose? - return if no_harm? - - realdest = prefix + dest if prefix - realdest = File.join(realdest, File.basename(from)) if File.dir?(realdest) - str = File.binread(from) - if diff?(str, realdest) - verbose_off { - rm_f realdest if File.exist?(realdest) - } - File.open(realdest, 'wb') {|f| - f.write str - } - File.chmod mode, realdest - - File.open("#{objdir_root()}/InstalledFiles", 'a') {|f| - if prefix - f.puts realdest.sub(prefix, '') - else - f.puts realdest - end - } - end - end - - def diff?(new_content, path) - return true unless File.exist?(path) - new_content != File.binread(path) - end - - def command(str) - $stderr.puts str if verbose? - system str or raise RuntimeError, "'system #{str}' failed" - end - - def ruby(str) - command config('ruby-prog') + ' ' + str - end - - def make(task = '') - command config('make-prog') + ' ' + task - end - - def extdir?(dir) - File.exist?(dir + '/MANIFEST') - end - - def all_files_in(dirname) - Dir.open(dirname) {|d| - return d.select {|ent| File.file?("#{dirname}/#{ent}") } - } - end - - REJECT_DIRS = %w( - CVS SCCS RCS CVS.adm .svn - ) - - def all_dirs_in(dirname) - Dir.open(dirname) {|d| - return d.select {|n| File.dir?("#{dirname}/#{n}") } - %w(. ..) - REJECT_DIRS - } - end - -end - -# -# Main Installer -# - -class InstallError < StandardError; end - - -module HookUtils - - def run_hook(name) - try_run_hook "#{curr_srcdir()}/#{name}" or - try_run_hook "#{curr_srcdir()}/#{name}.rb" - end - - def try_run_hook(fname) - return false unless File.file?(fname) - begin - instance_eval File.read(fname), fname, 1 - rescue - raise InstallError, "hook #{fname} failed:\n" + $!.message - end - true - end - -end - - -module HookScriptAPI - - def get_config(key) - @config[key] - end - - alias config get_config - - def set_config(key, val) - @config[key] = val - end - - # - # srcdir/objdir (works only in the package directory) - # - - #abstract srcdir_root - #abstract objdir_root - #abstract relpath - - def curr_srcdir - "#{srcdir_root()}/#{relpath()}" - end - - def curr_objdir - "#{objdir_root()}/#{relpath()}" - end - - def srcfile(path) - "#{curr_srcdir()}/#{path}" - end - - def srcexist?(path) - File.exist?(srcfile(path)) - end - - def srcdirectory?(path) - File.dir?(srcfile(path)) - end - - def srcfile?(path) - File.file? srcfile(path) - end - - def srcentries(path = '.') - Dir.open("#{curr_srcdir()}/#{path}") {|d| - return d.to_a - %w(. ..) - } - end - - def srcfiles(path = '.') - srcentries(path).select {|fname| - File.file?(File.join(curr_srcdir(), path, fname)) - } - end - - def srcdirectories(path = '.') - srcentries(path).select {|fname| - File.dir?(File.join(curr_srcdir(), path, fname)) - } - end - -end - - -class ToplevelInstaller - - Version = '3.2.4' - Copyright = 'Copyright (c) 2000-2004 Minero Aoki' - - TASKS = [ - [ 'config', 'saves your configurations' ], - [ 'show', 'shows current configuration' ], - [ 'setup', 'compiles ruby extentions and others' ], - [ 'install', 'installs files' ], - [ 'clean', "does `make clean' for each extention" ], - [ 'distclean',"does `make distclean' for each extention" ] - ] - - def ToplevelInstaller.invoke - instance().invoke - end - - @singleton = nil - - def ToplevelInstaller.instance - @singleton ||= new(File.dirname($0)) - @singleton - end - - include MetaConfigAPI - - def initialize(ardir_root) - @config = nil - @options = { 'verbose' => true } - @ardir = File.expand_path(ardir_root) - end - - def inspect - "#<#{self.class} #{__id__()}>" - end - - def invoke - run_metaconfigs - task = parsearg_global() - @config = load_config(task) - __send__ "parsearg_#{task}" - init_installers - __send__ "exec_#{task}" - end - - def run_metaconfigs - eval_file_ifexist "#{@ardir}/metaconfig" - end - - def load_config(task) - case task - when 'config' - ConfigTable.new - when 'clean', 'distclean' - if File.exist?('config.save') - then ConfigTable.load - else ConfigTable.new - end - else - ConfigTable.load - end - end - - def init_installers - @installer = Installer.new(@config, @options, @ardir, File.expand_path('.')) - end - - # - # Hook Script API bases - # - - def srcdir_root - @ardir - end - - def objdir_root - '.' - end - - def relpath - '.' - end - - # - # Option Parsing - # - - def parsearg_global - valid_task = /\A(?:#{TASKS.map {|task,desc| task }.join '|'})\z/ - - while arg = ARGV.shift - case arg - when /\A\w+\z/ - raise InstallError, "invalid task: #{arg}" unless valid_task =~ arg - return arg - - when '-q', '--quiet' - @options['verbose'] = false - - when '--verbose' - @options['verbose'] = true - - when '-h', '--help' - print_usage $stdout - exit 0 - - when '-v', '--version' - puts "#{File.basename($0)} version #{Version}" - exit 0 - - when '--copyright' - puts Copyright - exit 0 - - else - raise InstallError, "unknown global option '#{arg}'" - end - end - - raise InstallError, <" - out.puts " ruby #{File.basename $0} [] []" - - fmt = " %-20s %s\n" - out.puts - out.puts 'Global options:' - out.printf fmt, '-q,--quiet', 'suppress message outputs' - out.printf fmt, ' --verbose', 'output messages verbosely' - out.printf fmt, '-h,--help', 'print this message' - out.printf fmt, '-v,--version', 'print version and quit' - out.printf fmt, ' --copyright', 'print copyright and quit' - - out.puts - out.puts 'Tasks:' - TASKS.each do |name, desc| - out.printf " %-10s %s\n", name, desc - end - - out.puts - out.puts 'Options for config:' - ConfigTable.each_definition do |name, (default, arg, desc, default2)| - out.printf " %-20s %s [%s]\n", - '--'+ name + (ConfigTable.bool_config?(name) ? '' : '='+arg), - desc, - default2 || default - end - out.printf " %-20s %s [%s]\n", - '--rbconfig=path', 'your rbconfig.rb to load', "running ruby's" - - out.puts - out.puts 'Options for install:' - out.printf " %-20s %s [%s]\n", - '--no-harm', 'only display what to do if given', 'off' - out.printf " %-20s %s [%s]\n", - '--prefix', 'install path prefix', '$prefix' - - out.puts - end - - # - # Task Handlers - # - - def exec_config - @installer.exec_config - @config.save # must be final - end - - def exec_setup - @installer.exec_setup - end - - def exec_install - @installer.exec_install - end - - def exec_show - ConfigTable.each_name do |k| - v = @config.get_raw(k) - if not v or v.empty? - v = '(not specified)' - end - printf "%-10s %s\n", k, v - end - end - - def exec_clean - @installer.exec_clean - end - - def exec_distclean - @installer.exec_distclean - end - -end - - -class ToplevelInstallerMulti < ToplevelInstaller - - include HookUtils - include HookScriptAPI - include FileOperations - - def initialize(ardir) - super - @packages = all_dirs_in("#{@ardir}/packages") - raise 'no package exists' if @packages.empty? - end - - def run_metaconfigs - eval_file_ifexist "#{@ardir}/metaconfig" - @packages.each do |name| - eval_file_ifexist "#{@ardir}/packages/#{name}/metaconfig" - end - end - - def init_installers - @installers = {} - @packages.each do |pack| - @installers[pack] = Installer.new(@config, @options, - "#{@ardir}/packages/#{pack}", - "packages/#{pack}") - end - - with = extract_selection(config('with')) - without = extract_selection(config('without')) - @selected = @installers.keys.select {|name| - (with.empty? or with.include?(name)) \ - and not without.include?(name) - } - end - - def extract_selection(list) - a = list.split(/,/) - a.each do |name| - raise InstallError, "no such package: #{name}" \ - unless @installers.key?(name) - end - a - end - - def print_usage(f) - super - f.puts 'Inluded packages:' - f.puts ' ' + @packages.sort.join(' ') - f.puts - end - - # - # multi-package metaconfig API - # - - attr_reader :packages - - def declare_packages(list) - raise 'package list is empty' if list.empty? - list.each do |name| - raise "directory packages/#{name} does not exist"\ - unless File.dir?("#{@ardir}/packages/#{name}") - end - @packages = list - end - - # - # Task Handlers - # - - def exec_config - run_hook 'pre-config' - each_selected_installers {|inst| inst.exec_config } - run_hook 'post-config' - @config.save # must be final - end - - def exec_setup - run_hook 'pre-setup' - each_selected_installers {|inst| inst.exec_setup } - run_hook 'post-setup' - end - - def exec_install - run_hook 'pre-install' - each_selected_installers {|inst| inst.exec_install } - run_hook 'post-install' - end - - def exec_clean - rm_f 'config.save' - run_hook 'pre-clean' - each_selected_installers {|inst| inst.exec_clean } - run_hook 'post-clean' - end - - def exec_distclean - rm_f 'config.save' - run_hook 'pre-distclean' - each_selected_installers {|inst| inst.exec_distclean } - run_hook 'post-distclean' - end - - # - # lib - # - - def each_selected_installers - Dir.mkdir 'packages' unless File.dir?('packages') - @selected.each do |pack| - $stderr.puts "Processing the package `#{pack}' ..." if @options['verbose'] - Dir.mkdir "packages/#{pack}" unless File.dir?("packages/#{pack}") - Dir.chdir "packages/#{pack}" - yield @installers[pack] - Dir.chdir '../..' - end - end - - def verbose? - @options['verbose'] - end - - def no_harm? - @options['no-harm'] - end - -end - - -class Installer - - FILETYPES = %w( bin lib ext data ) - - include HookScriptAPI - include HookUtils - include FileOperations - - def initialize(config, opt, srcroot, objroot) - @config = config - @options = opt - @srcdir = File.expand_path(srcroot) - @objdir = File.expand_path(objroot) - @currdir = '.' - end - - def inspect - "#<#{self.class} #{File.basename(@srcdir)}>" - end - - # - # Hook Script API bases - # - - def srcdir_root - @srcdir - end - - def objdir_root - @objdir - end - - def relpath - @currdir - end - - # - # configs/options - # - - def no_harm? - @options['no-harm'] - end - - def verbose? - @options['verbose'] - end - - def verbose_off - begin - save, @options['verbose'] = @options['verbose'], false - yield - ensure - @options['verbose'] = save - end - end - - # - # TASK config - # - - def exec_config - exec_task_traverse 'config' - end - - def config_dir_bin(rel) - end - - def config_dir_lib(rel) - end - - def config_dir_ext(rel) - extconf if extdir?(curr_srcdir()) - end - - def extconf - opt = @options['config-opt'].join(' ') - command "#{config('ruby-prog')} #{curr_srcdir()}/extconf.rb #{opt}" - end - - def config_dir_data(rel) - end - - # - # TASK setup - # - - def exec_setup - exec_task_traverse 'setup' - end - - def setup_dir_bin(rel) - all_files_in(curr_srcdir()).each do |fname| - adjust_shebang "#{curr_srcdir()}/#{fname}" - end - end - - # modify: #!/usr/bin/ruby - # modify: #! /usr/bin/ruby - # modify: #!ruby - # not modify: #!/usr/bin/env ruby - SHEBANG_RE = /\A\#!\s*\S*ruby\S*/ - - def adjust_shebang(path) - return if no_harm? - - tmpfile = File.basename(path) + '.tmp' - begin - File.open(path, 'rb') {|r| - File.open(tmpfile, 'wb') {|w| - first = r.gets - return unless SHEBANG_RE =~ first - - $stderr.puts "adjusting shebang: #{File.basename path}" if verbose? - w.print first.sub(SHEBANG_RE, '#!' + config('ruby-path')) - w.write r.read - } - } - move_file tmpfile, File.basename(path) - ensure - File.unlink tmpfile if File.exist?(tmpfile) - end - end - - def setup_dir_lib(rel) - end - - def setup_dir_ext(rel) - make if extdir?(curr_srcdir()) - end - - def setup_dir_data(rel) - end - - # - # TASK install - # - - def exec_install - exec_task_traverse 'install' - end - - def install_dir_bin(rel) - list = collect_filenames_auto - install_files list, "#{config('bin-dir')}/#{rel}", 0755 - install_cmd_files list, "#{config('bin-dir')}/#{rel}", 0755 - end - - def install_dir_lib(rel) - install_files ruby_scripts(), "#{config('rb-dir')}/#{rel}", 0644 - end - - def install_dir_ext(rel) - return unless extdir?(curr_srcdir()) - install_files ruby_extentions('.'), - "#{config('so-dir')}/#{File.dirname(rel)}", - 0555 - end - - def install_dir_data(rel) - install_files collect_filenames_auto(), "#{config('data-dir')}/#{rel}", 0644 - end - - def install_cmd_files(list, dest, mode) - if Config::CONFIG["arch"] =~ /dos|win32/i - mkdir_p dest, @options['install-prefix'] - list.each do |fname| - next if no_harm? - File.open(File.join(dest, "#{fname}.cmd"), "w") do |file| - file.puts "@ruby \"#{File.join(dest, fname)}\" %*" - end - File.chmod mode, File.join(dest, "#{fname}.cmd") - end - end - end - - def install_files(list, dest, mode) - mkdir_p dest, @options['install-prefix'] - list.each do |fname| - install fname, dest, mode, @options['install-prefix'] - end - end - - def ruby_scripts - collect_filenames_auto().select {|n| /\.(r(b|html)|txt)\z/ =~ n} - end - - # picked up many entries from cvs-1.11.1/src/ignore.c - reject_patterns = %w( - core RCSLOG tags TAGS .make.state - .nse_depinfo #* .#* cvslog.* ,* .del-* *.olb - *~ *.old *.bak *.BAK *.orig *.rej _$* *$ - - *.org *.in .* - ) - mapping = { - '.' => '\.', - '$' => '\$', - '#' => '\#', - '*' => '.*' - } - REJECT_PATTERNS = Regexp.new('\A(?:' + - reject_patterns.map {|pat| - pat.gsub(/[\.\$\#\*]/) {|ch| mapping[ch] } - }.join('|') + - ')\z') - - def collect_filenames_auto - mapdir((existfiles() - hookfiles()).reject {|fname| - REJECT_PATTERNS =~ fname - }) - end - - def existfiles - all_files_in(curr_srcdir()) | all_files_in('.') - end - - def hookfiles - %w( pre-%s post-%s pre-%s.rb post-%s.rb ).map {|fmt| - %w( config setup install clean ).map {|t| sprintf(fmt, t) } - }.flatten - end - - def mapdir(filelist) - filelist.map {|fname| - if File.exist?(fname) # objdir - fname - else # srcdir - File.join(curr_srcdir(), fname) - end - } - end - - def ruby_extentions(dir) - _ruby_extentions(dir) or - raise InstallError, "no ruby extention exists: 'ruby #{$0} setup' first" - end - - DLEXT = /\.#{ ::Config::CONFIG['DLEXT'] }\z/ - - def _ruby_extentions(dir) - Dir.open(dir) {|d| - return d.select {|fname| DLEXT =~ fname } - } - end - - # - # TASK clean - # - - def exec_clean - exec_task_traverse 'clean' - rm_f 'config.save' - rm_f 'InstalledFiles' - end - - def clean_dir_bin(rel) - end - - def clean_dir_lib(rel) - end - - def clean_dir_ext(rel) - return unless extdir?(curr_srcdir()) - make 'clean' if File.file?('Makefile') - end - - def clean_dir_data(rel) - end - - # - # TASK distclean - # - - def exec_distclean - exec_task_traverse 'distclean' - rm_f 'config.save' - rm_f 'InstalledFiles' - end - - def distclean_dir_bin(rel) - end - - def distclean_dir_lib(rel) - end - - def distclean_dir_ext(rel) - return unless extdir?(curr_srcdir()) - make 'distclean' if File.file?('Makefile') - end - - # - # lib - # - - def exec_task_traverse(task) - run_hook "pre-#{task}" - FILETYPES.each do |type| - if config('without-ext') == 'yes' and type == 'ext' - $stderr.puts 'skipping ext/* by user option' if verbose? - next - end - traverse task, type, "#{task}_dir_#{type}" - end - run_hook "post-#{task}" - end - - def traverse(task, rel, mid) - dive_into(rel) { - run_hook "pre-#{task}" - __send__ mid, rel.sub(%r[\A.*?(?:/|\z)], '') - all_dirs_in(curr_srcdir()).each do |d| - traverse task, "#{rel}/#{d}", mid - end - run_hook "post-#{task}" - } - end - - def dive_into(rel) - return unless File.dir?("#{@srcdir}/#{rel}") - - dir = File.basename(rel) - Dir.mkdir dir unless File.dir?(dir) - prevdir = Dir.pwd - Dir.chdir dir - $stderr.puts '---> ' + rel if verbose? - @currdir = rel - yield - Dir.chdir prevdir - $stderr.puts '<--- ' + rel if verbose? - @currdir = File.dirname(rel) - end - -end - - -if $0 == __FILE__ - begin - if multipackage_install? - ToplevelInstallerMulti.invoke - else - ToplevelInstaller.invoke - end - rescue - raise if $DEBUG - $stderr.puts $!.message - $stderr.puts "Try 'ruby #{$0} --help' for detailed usage." - exit 1 - end -end diff --git a/vendor/gems/capistrano-2.5.9/test/cli/execute_test.rb b/vendor/gems/capistrano-2.5.9/test/cli/execute_test.rb deleted file mode 100644 index 90bbd3968..000000000 --- a/vendor/gems/capistrano-2.5.9/test/cli/execute_test.rb +++ /dev/null @@ -1,132 +0,0 @@ -require "utils" -require 'capistrano/cli/execute' - -class CLIExecuteTest < Test::Unit::TestCase - class MockCLI - attr_reader :options - - def initialize - @options = {} - end - - include Capistrano::CLI::Execute - end - - def setup - @cli = MockCLI.new - @logger = stub_everything - @config = stub(:logger => @logger, :debug= => nil, :dry_run= => nil) - @config.stubs(:set) - @config.stubs(:load) - @config.stubs(:trigger) - @cli.stubs(:instantiate_configuration).returns(@config) - end - - def test_execute_should_set_logger_verbosity - @cli.options[:verbose] = 7 - @logger.expects(:level=).with(7) - @cli.execute! - end - - def test_execute_should_set_password - @cli.options[:password] = "nosoup4u" - @config.expects(:set).with(:password, "nosoup4u") - @cli.execute! - end - - def test_execute_should_set_prevars_before_loading - @config.expects(:load).never - @config.expects(:set).with(:stage, "foobar") - @config.expects(:load).with("standard") - @cli.options[:pre_vars] = { :stage => "foobar" } - @cli.execute! - end - - def test_execute_should_load_sysconf_if_sysconf_set_and_exists - @cli.options[:sysconf] = "/etc/capistrano.conf" - @config.expects(:load).with("/etc/capistrano.conf") - File.expects(:file?).with("/etc/capistrano.conf").returns(true) - @cli.execute! - end - - def test_execute_should_not_load_sysconf_when_sysconf_set_and_not_exists - @cli.options[:sysconf] = "/etc/capistrano.conf" - File.expects(:file?).with("/etc/capistrano.conf").returns(false) - @cli.execute! - end - - def test_execute_should_load_dotfile_if_dotfile_set_and_exists - @cli.options[:dotfile] = "/home/jamis/.caprc" - @config.expects(:load).with("/home/jamis/.caprc") - File.expects(:file?).with("/home/jamis/.caprc").returns(true) - @cli.execute! - end - - def test_execute_should_not_load_dotfile_when_dotfile_set_and_not_exists - @cli.options[:dotfile] = "/home/jamis/.caprc" - File.expects(:file?).with("/home/jamis/.caprc").returns(false) - @cli.execute! - end - - def test_execute_should_load_recipes_when_recipes_are_given - @cli.options[:recipes] = %w(config/deploy path/to/extra) - @config.expects(:load).with("config/deploy") - @config.expects(:load).with("path/to/extra") - @cli.execute! - end - - def test_execute_should_set_vars_and_execute_tasks - @cli.options[:vars] = { :foo => "bar", :baz => "bang" } - @cli.options[:actions] = %w(first second) - @config.expects(:set).with(:foo, "bar") - @config.expects(:set).with(:baz, "bang") - @config.expects(:find_and_execute_task).with("first", :before => :start, :after => :finish) - @config.expects(:find_and_execute_task).with("second", :before => :start, :after => :finish) - @cli.execute! - end - - def test_execute_should_call_load_and_exit_triggers - @cli.options[:actions] = %w(first second) - @config.expects(:find_and_execute_task).with("first", :before => :start, :after => :finish) - @config.expects(:find_and_execute_task).with("second", :before => :start, :after => :finish) - @config.expects(:trigger).never - @config.expects(:trigger).with(:load) - @config.expects(:trigger).with(:exit) - @cli.execute! - end - - def test_execute_should_call_handle_error_when_exceptions_occur - @config.expects(:load).raises(Exception, "boom") - @cli.expects(:handle_error).with { |e,| Exception === e } - @cli.execute! - end - - def test_execute_should_return_config_instance - assert_equal @config, @cli.execute! - end - - def test_instantiate_configuration_should_return_new_configuration_instance - assert_instance_of Capistrano::Configuration, MockCLI.new.instantiate_configuration - end - - def test_handle_error_with_auth_error_should_abort_with_message_including_user_name - @cli.expects(:abort).with { |s| s.include?("jamis") } - @cli.handle_error(Net::SSH::AuthenticationFailed.new("jamis")) - end - - def test_handle_error_with_cap_error_should_abort_with_message - @cli.expects(:abort).with("Wish you were here") - @cli.handle_error(Capistrano::Error.new("Wish you were here")) - end - - def test_handle_error_with_other_errors_should_reraise_error - other_error = Class.new(RuntimeError) - assert_raises(other_error) { @cli.handle_error(other_error.new("boom")) } - end - - def test_class_execute_method_should_call_parse_and_execute_with_ARGV - cli = mock(:execute! => nil) - MockCLI.expects(:parse).with(ARGV).returns(cli) - MockCLI.execute - end -end \ No newline at end of file diff --git a/vendor/gems/capistrano-2.5.9/test/cli/help_test.rb b/vendor/gems/capistrano-2.5.9/test/cli/help_test.rb deleted file mode 100644 index 05c17552e..000000000 --- a/vendor/gems/capistrano-2.5.9/test/cli/help_test.rb +++ /dev/null @@ -1,165 +0,0 @@ -require "utils" -require 'capistrano/cli/help' - -class CLIHelpTest < Test::Unit::TestCase - class MockCLI - attr_reader :options, :called_original - - def initialize - @options = {} - @called_original = false - end - - def execute_requested_actions(config) - @called_original = config - end - - include Capistrano::CLI::Help - end - - def setup - @cli = MockCLI.new - @cli.options[:verbose] = 0 - @ui = stub("ui", :output_cols => 80, :output_rows => 20, :page_at= => nil) - MockCLI.stubs(:ui).returns(@ui) - end - - def test_execute_requested_actions_without_tasks_or_explain_should_call_original - @cli.execute_requested_actions(:config) - @cli.expects(:task_list).never - @cli.expects(:explain_task).never - assert_equal :config, @cli.called_original - end - - def test_execute_requested_actions_with_tasks_should_call_task_list - @cli.options[:tasks] = true - @cli.expects(:task_list).with(:config, true) - @cli.expects(:explain_task).never - @cli.execute_requested_actions(:config) - assert !@cli.called_original - end - - def test_execute_requested_actions_with_explain_should_call_explain_task - @cli.options[:explain] = "deploy_with_niftiness" - @cli.expects(:task_list).never - @cli.expects(:explain_task).with(:config, "deploy_with_niftiness") - @cli.execute_requested_actions(:config) - assert !@cli.called_original - end - - def test_task_list_with_no_tasks_should_emit_warning - config = mock("config", :task_list => []) - @cli.expects(:warn) - @cli.task_list(config) - end - - def test_task_list_should_query_all_tasks_in_all_namespaces - expected_max_len = 80 - 3 - MockCLI::LINE_PADDING - task_list = [task("c"), task("g", "c:g"), task("b", "c:b"), task("a")] - task_list.each { |t| t.expects(:brief_description).with(expected_max_len).returns(t.fully_qualified_name) } - - config = mock("config") - config.expects(:task_list).with(:all).returns(task_list) - @cli.stubs(:puts) - @cli.task_list(config) - end - - def test_task_list_should_query_tasks_with_pattern - expected_max_len = 80 - 3 - MockCLI::LINE_PADDING - task_list = [task("g", "c:g"), task("b", "c:b")] - task_list.each { |t| t.expects(:brief_description).with(expected_max_len).returns(t.fully_qualified_name)} - - config = mock("config") - config.expects(:task_list).with(:all).once.returns(task_list) - - @cli.stubs(:puts) - @cli.task_list(config, "c") - end - - def test_task_list_should_query_for_all_tasks_when_pattern_doesnt_match - expected_max_len = 80 - 3 - MockCLI::LINE_PADDING - task_list = [task("g", "c:g"), task("b", "c:b")] - task_list.each { |t| t.expects(:brief_description).with(expected_max_len).returns(t.fully_qualified_name) } - - config = mock("config") - config.expects(:task_list).with(:all).times(2).returns(task_list) - - @cli.stubs(:warn) - @cli.stubs(:puts) - @cli.task_list(config, "z") - end - - def test_task_list_should_never_use_less_than_MIN_MAX_LEN_chars_for_descriptions - @ui.stubs(:output_cols).returns(20) - t = task("c") - t.expects(:brief_description).with(30).returns("hello") - config = mock("config", :task_list => [t]) - @cli.stubs(:puts) - @cli.task_list(config) - end - - def test_task_list_should_not_include_tasks_with_blank_description_or_internal_by_default - t1 = task("c") - t1.expects(:brief_description).returns("hello") - t2 = task("d", "d", "[internal] howdy") - t2.expects(:brief_description).never - t3 = task("e", "e", "") - t3.expects(:brief_description).never - - config = mock("config", :task_list => [t1, t2, t3]) - @cli.stubs(:puts) - @cli.expects(:puts).never.with { |s,| (s || "").include?("[internal]") || s =~ /#\s*$/ } - @cli.task_list(config) - end - - def test_task_list_should_include_tasks_with_blank_descriptions_and_internal_when_verbose - t1 = task("c") - t1.expects(:brief_description).returns("hello") - t2 = task("d", "d", "[internal] howdy") - t2.expects(:brief_description).returns("[internal] howdy") - t3 = task("e", "e", "") - t3.expects(:brief_description).returns("") - - config = mock("config", :task_list => [t1, t2, t3]) - @cli.options[:verbose] = 1 - @cli.stubs(:puts) - @cli.expects(:puts).with { |s,| (s || "").include?("[internal]") || s =~ /#\s*$/ }.at_least_once - @cli.task_list(config) - end - - def test_explain_task_should_warn_if_task_does_not_exist - config = mock("config", :find_task => nil) - @cli.expects(:warn).with { |s,| s =~ /`deploy_with_niftiness'/ } - @cli.explain_task(config, "deploy_with_niftiness") - end - - def test_explain_task_with_task_that_has_no_description_should_emit_stub - t = mock("task", :description => "") - config = mock("config") - config.expects(:find_task).with("deploy_with_niftiness").returns(t) - @cli.stubs(:puts) - @cli.expects(:puts).with("There is no description for this task.") - @cli.explain_task(config, "deploy_with_niftiness") - end - - def test_explain_task_with_task_should_format_description - t = stub("task", :description => "line1\nline2\n\nline3") - config = mock("config", :find_task => t) - @cli.stubs(:puts) - @cli.explain_task(config, "deploy_with_niftiness") - end - - def test_long_help_should_load_and_format_help_txt_file - File.expects(:dirname).returns "a/b/c" - File.expects(:read).with("a/b/c/help.txt").returns("text") - @ui.expects(:say).with("text\n") - @cli.long_help - end - - private - - def task(name, fqn=name, desc="a description") - stub("task", :name => name, :fully_qualified_name => fqn, :description => desc) - end - -end diff --git a/vendor/gems/capistrano-2.5.9/test/cli/options_test.rb b/vendor/gems/capistrano-2.5.9/test/cli/options_test.rb deleted file mode 100644 index 634d1316d..000000000 --- a/vendor/gems/capistrano-2.5.9/test/cli/options_test.rb +++ /dev/null @@ -1,317 +0,0 @@ -require "utils" -require 'capistrano/cli/options' - -class CLIOptionsTest < Test::Unit::TestCase - class ExitException < Exception; end - - class MockCLI - def initialize - @args = [] - end - - attr_reader :args - - include Capistrano::CLI::Options - end - - def setup - @cli = MockCLI.new - end - - def test_parse_options_should_require_non_empty_args_list - @cli.stubs(:warn) - @cli.expects(:exit).raises(ExitException) - assert_raises(ExitException) { @cli.parse_options! } - end - - def test_parse_options_with_d_should_set_debug_option - @cli.args << "-d" - @cli.parse_options! - assert @cli.options[:debug] - end - - def test_parse_options_with_n_should_set_dry_run_option - @cli.args << "-n" - @cli.parse_options! - assert @cli.options[:dry_run] - end - - def test_parse_options_with_dry_run_should_set_dry_run_option - @cli.args << "--dry-run" - @cli.parse_options! - assert @cli.options[:dry_run] - end - - def test_parse_options_with_e_should_set_explain_option - @cli.args << "-e" << "sample" - @cli.parse_options! - assert_equal "sample", @cli.options[:explain] - end - - def test_parse_options_with_f_should_add_recipe_file - @cli.args << "-f" << "deploy" - @cli.parse_options! - assert_equal %w(deploy), @cli.options[:recipes] - end - - def test_parse_options_with_multiple_f_should_add_each_as_recipe_file - @cli.args << "-f" << "deploy" << "-f" << "monitor" - @cli.parse_options! - assert_equal %w(deploy monitor), @cli.options[:recipes] - end - - def test_parse_options_with_H_should_show_verbose_help_and_exit - @cli.expects(:exit).raises(ExitException) - @cli.expects(:long_help) - @cli.args << "-H" - assert_raises(ExitException) { @cli.parse_options! } - end - - def test_parse_options_with_h_should_show_options_and_exit - @cli.expects(:puts).with(@cli.option_parser) - @cli.expects(:exit).raises(ExitException) - @cli.args << "-h" - assert_raises(ExitException) { @cli.parse_options! } - end - - def test_parse_options_with_p_should_prompt_for_password - MockCLI.expects(:password_prompt).returns(:the_password) - @cli.args << "-p" - @cli.parse_options! - assert_equal :the_password, @cli.options[:password] - end - - def test_parse_options_without_p_should_set_proc_for_password - @cli.args << "-e" << "sample" - @cli.parse_options! - assert_instance_of Proc, @cli.options[:password] - end - - def test_parse_options_with_q_should_set_verbose_to_0 - @cli.args << "-q" - @cli.parse_options! - assert_equal 0, @cli.options[:verbose] - end - - def test_parse_options_with_S_should_set_pre_vars - @cli.args << "-S" << "foo=bar" - @cli.parse_options! - assert_equal "bar", @cli.options[:pre_vars][:foo] - end - - def test_S_should_coerce_digits_to_integers - @cli.args << "-S" << "foo=1234" - @cli.parse_options! - assert_equal 1234, @cli.options[:pre_vars][:foo] - end - - def test_S_should_treat_quoted_integers_as_string - @cli.args << "-S" << "foo=\"1234\"" - @cli.parse_options! - assert_equal "1234", @cli.options[:pre_vars][:foo] - end - - def test_S_should_treat_digits_with_dot_as_floating_point - @cli.args << "-S" << "foo=3.1415" - @cli.parse_options! - assert_equal 3.1415, @cli.options[:pre_vars][:foo] - end - - def test_S_should_treat_true_as_boolean_true - @cli.args << "-S" << "foo=true" - @cli.parse_options! - assert_equal true, @cli.options[:pre_vars][:foo] - end - - def test_S_should_treat_false_as_boolean_false - @cli.args << "-S" << "foo=false" - @cli.parse_options! - assert_equal false, @cli.options[:pre_vars][:foo] - end - - def test_S_should_treat_nil_as_nil - @cli.args << "-S" << "foo=nil" - @cli.parse_options! - assert_equal nil, @cli.options[:pre_vars][:foo] - end - - def test_parse_options_with_s_should_set_vars - @cli.args << "-s" << "foo=bar" - @cli.parse_options! - assert_equal "bar", @cli.options[:vars][:foo] - end - - def test_s_should_coerce_digits_to_integers - @cli.args << "-s" << "foo=1234" - @cli.parse_options! - assert_equal 1234, @cli.options[:vars][:foo] - end - - def test_s_should_treat_quoted_integers_as_string - @cli.args << "-s" << "foo=\"1234\"" - @cli.parse_options! - assert_equal "1234", @cli.options[:vars][:foo] - end - - def test_s_should_treat_digits_with_dot_as_floating_point - @cli.args << "-s" << "foo=3.1415" - @cli.parse_options! - assert_equal 3.1415, @cli.options[:vars][:foo] - end - - def test_s_should_treat_true_as_boolean_true - @cli.args << "-s" << "foo=true" - @cli.parse_options! - assert_equal true, @cli.options[:vars][:foo] - end - - def test_s_should_treat_false_as_boolean_false - @cli.args << "-s" << "foo=false" - @cli.parse_options! - assert_equal false, @cli.options[:vars][:foo] - end - - def test_s_should_treat_nil_as_nil - @cli.args << "-s" << "foo=nil" - @cli.parse_options! - assert_equal nil, @cli.options[:vars][:foo] - end - - def test_parse_options_with_T_should_set_tasks_option_and_set_verbose_off - @cli.args << "-T" - @cli.parse_options! - assert @cli.options[:tasks] - assert_equal 0, @cli.options[:verbose] - end - - def test_parse_options_with_V_should_show_version_and_exit - @cli.args << "-V" - @cli.expects(:puts).with { |s| s.include?(Capistrano::Version::STRING) } - @cli.expects(:exit).raises(ExitException) - assert_raises(ExitException) { @cli.parse_options! } - end - - def test_parse_options_with_v_should_set_verbose_to_1 - @cli.args << "-v" - @cli.parse_options! - assert_equal 1, @cli.options[:verbose] - end - - def test_parse_options_with_multiple_v_should_set_verbose_accordingly - @cli.args << "-vvvvvvv" - @cli.parse_options! - assert_equal 7, @cli.options[:verbose] - end - - def test_parse_options_without_X_should_set_sysconf - @cli.args << "-v" - @cli.parse_options! - assert @cli.options.key?(:sysconf) - end - - def test_parse_options_with_X_should_unset_sysconf - @cli.args << "-X" - @cli.parse_options! - assert !@cli.options.key?(:sysconf) - end - - def test_parse_options_without_x_should_set_dotfile - @cli.args << "-v" - @cli.parse_options! - assert @cli.options.key?(:dotfile) - end - - def test_parse_options_with_x_should_unset_dotfile - @cli.args << "-x" - @cli.parse_options! - assert !@cli.options.key?(:dotfile) - end - - def test_parse_options_without_q_or_v_should_set_verbose_to_3 - @cli.args << "-x" - @cli.parse_options! - assert_equal 3, @cli.options[:verbose] - end - - def test_should_search_for_default_recipes_if_f_not_given - @cli.expects(:look_for_default_recipe_file!) - @cli.args << "-v" - @cli.parse_options! - end - - def test_should_not_search_for_default_recipes_if_f_given - @cli.expects(:look_for_default_recipe_file!).never - @cli.args << "-f" << "hello" - @cli.parse_options! - end - - def test_F_should_search_for_default_recipes_even_if_f_is_given - @cli.expects(:look_for_default_recipe_file!) - @cli.args << "-Ff" << "hello" - @cli.parse_options! - end - - def test_should_extract_env_vars_from_command_line - assert_nil ENV["HELLO"] - assert_nil ENV["ANOTHER"] - - @cli.args << "HELLO=world" << "hello" << "ANOTHER=value" - @cli.parse_options! - - assert_equal "world", ENV["HELLO"] - assert_equal "value", ENV["ANOTHER"] - ensure - ENV.delete("HELLO") - ENV.delete("ANOTHER") - end - - def test_remaining_args_should_be_added_to_actions_list - @cli.args << "-v" << "HELLO=world" << "-f" << "foo" << "something" << "else" - @cli.parse_options! - assert_equal %w(something else), @cli.args - ensure - ENV.delete("HELLO") - end - - def test_search_for_default_recipe_file_should_look_for_Capfile - File.stubs(:file?).returns(false) - File.expects(:file?).with("Capfile").returns(true) - @cli.args << "-v" - @cli.parse_options! - assert_equal %w(Capfile), @cli.options[:recipes] - end - - def test_search_for_default_recipe_file_should_look_for_capfile - File.stubs(:file?).returns(false) - File.expects(:file?).with("capfile").returns(true) - @cli.args << "-v" - @cli.parse_options! - assert_equal %w(capfile), @cli.options[:recipes] - end - - def test_search_for_default_recipe_should_hike_up_the_directory_tree_until_it_finds_default_recipe - File.stubs(:file?).returns(false) - File.expects(:file?).with("capfile").times(2).returns(false,true) - Dir.expects(:pwd).times(3).returns(*%w(/bar/baz /bar/baz /bar)) - Dir.expects(:chdir).with("..") - @cli.args << "-v" - @cli.parse_options! - assert_equal %w(capfile), @cli.options[:recipes] - end - - def test_search_for_default_recipe_should_halt_at_root_directory - File.stubs(:file?).returns(false) - Dir.expects(:pwd).times(7).returns(*%w(/bar/baz /bar/baz /bar /bar / / /)) - Dir.expects(:chdir).with("..").times(3) - Dir.expects(:chdir).with("/bar/baz") - @cli.args << "-v" - @cli.parse_options! - assert @cli.options[:recipes].empty? - end - - def test_parse_should_instantiate_new_cli_and_call_parse_options - cli = mock("cli", :parse_options! => nil) - MockCLI.expects(:new).with(%w(a b c)).returns(cli) - assert_equal cli, MockCLI.parse(%w(a b c)) - end -end diff --git a/vendor/gems/capistrano-2.5.9/test/cli/ui_test.rb b/vendor/gems/capistrano-2.5.9/test/cli/ui_test.rb deleted file mode 100644 index 1999af6ef..000000000 --- a/vendor/gems/capistrano-2.5.9/test/cli/ui_test.rb +++ /dev/null @@ -1,28 +0,0 @@ -require "utils" -require 'capistrano/cli/ui' - -class CLIUITest < Test::Unit::TestCase - class MockCLI - include Capistrano::CLI::UI - end - - def test_ui_should_return_highline_instance - assert_instance_of HighLine, MockCLI.ui - end - - def test_password_prompt_should_have_default_prompt_and_set_echo_false - q = mock("question") - q.expects(:echo=).with(false) - ui = mock("ui") - ui.expects(:ask).with("Password: ").yields(q).returns("sayuncle") - MockCLI.expects(:ui).returns(ui) - assert_equal "sayuncle", MockCLI.password_prompt - end - - def test_password_prompt_with_custom_prompt_should_use_custom_prompt - ui = mock("ui") - ui.expects(:ask).with("Give the passphrase: ").returns("sayuncle") - MockCLI.expects(:ui).returns(ui) - assert_equal "sayuncle", MockCLI.password_prompt("Give the passphrase: ") - end -end \ No newline at end of file diff --git a/vendor/gems/capistrano-2.5.9/test/cli_test.rb b/vendor/gems/capistrano-2.5.9/test/cli_test.rb deleted file mode 100644 index f8de20e2d..000000000 --- a/vendor/gems/capistrano-2.5.9/test/cli_test.rb +++ /dev/null @@ -1,17 +0,0 @@ -require "utils" -require 'capistrano/cli' - -class CLI_Test < Test::Unit::TestCase - def test_options_ui_and_help_modules_should_integrate_successfully_with_configuration - cli = Capistrano::CLI.parse(%w(-T)) - cli.expects(:puts).at_least_once - cli.execute! - end - - def test_options_and_execute_modules_should_integrate_successfully_with_configuration - path = "#{File.dirname(__FILE__)}/fixtures/cli_integration.rb" - cli = Capistrano::CLI.parse(%W(-q -f #{path} testing)) - config = cli.execute! - assert config[:testing_occurred] - end -end diff --git a/vendor/gems/capistrano-2.5.9/test/command_test.rb b/vendor/gems/capistrano-2.5.9/test/command_test.rb deleted file mode 100644 index b41670466..000000000 --- a/vendor/gems/capistrano-2.5.9/test/command_test.rb +++ /dev/null @@ -1,286 +0,0 @@ -require "utils" -require 'capistrano/command' -require 'capistrano/configuration' - -class CommandTest < Test::Unit::TestCase - def test_command_should_open_channels_on_all_sessions - s1, s2, s3 = mock_session, mock_session, mock_session - assert_equal "ls", Capistrano::Command.new("ls", [s1, s2, s3]).tree.fallback.command - end - - def test_command_with_newlines_should_be_properly_escaped - cmd = Capistrano::Command.new("ls\necho", [mock_session]) - assert_equal "ls\\\necho", cmd.tree.fallback.command - end - - def test_command_with_windows_newlines_should_be_properly_escaped - cmd = Capistrano::Command.new("ls\r\necho", [mock_session]) - assert_equal "ls\\\necho", cmd.tree.fallback.command - end - - def test_command_with_pty_should_request_pty_and_register_success_callback - session = setup_for_extracting_channel_action(:request_pty, true) do |ch| - ch.expects(:exec).with(%(sh -c 'ls')) - end - Capistrano::Command.new("ls", [session], :pty => true) - end - - def test_command_with_env_key_should_have_environment_constructed_and_prepended - session = setup_for_extracting_channel_action do |ch| - ch.expects(:request_pty).never - ch.expects(:exec).with(%(env FOO=bar sh -c 'ls')) - end - Capistrano::Command.new("ls", [session], :env => { "FOO" => "bar" }) - end - - def test_env_with_symbolic_key_should_be_accepted_as_a_string - session = setup_for_extracting_channel_action do |ch| - ch.expects(:exec).with(%(env FOO=bar sh -c 'ls')) - end - Capistrano::Command.new("ls", [session], :env => { :FOO => "bar" }) - end - - def test_env_as_string_should_be_substituted_in_directly - session = setup_for_extracting_channel_action do |ch| - ch.expects(:exec).with(%(env HOWDY=there sh -c 'ls')) - end - Capistrano::Command.new("ls", [session], :env => "HOWDY=there") - end - - def test_env_with_symbolic_value_should_be_accepted_as_string - session = setup_for_extracting_channel_action do |ch| - ch.expects(:exec).with(%(env FOO=bar sh -c 'ls')) - end - Capistrano::Command.new("ls", [session], :env => { "FOO" => :bar }) - end - - def test_env_value_should_be_escaped - session = setup_for_extracting_channel_action do |ch| - ch.expects(:exec).with(%(env FOO=(\\ \\\"bar\\\"\\ ) sh -c 'ls')) - end - Capistrano::Command.new("ls", [session], :env => { "FOO" => '( "bar" )' }) - end - - def test_env_with_multiple_keys_should_chain_the_entries_together - session = setup_for_extracting_channel_action do |ch| - ch.expects(:exec).with do |command| - command =~ /^env / && - command =~ /\ba=b\b/ && - command =~ /\bc=d\b/ && - command =~ /\be=f\b/ && - command =~ / sh -c 'ls'$/ - end - end - Capistrano::Command.new("ls", [session], :env => { :a => :b, :c => :d, :e => :f }) - end - - def test_open_channel_should_set_host_key_on_channel - channel = nil - session = setup_for_extracting_channel_action { |ch| channel = ch } - Capistrano::Command.new("ls", [session]) - assert_equal "capistrano", channel[:host] - end - - def test_open_channel_should_set_options_key_on_channel - channel = nil - session = setup_for_extracting_channel_action { |ch| channel = ch } - Capistrano::Command.new("ls", [session], :data => "here we go") - assert_equal({ :data => 'here we go' }, channel[:options]) - end - - def test_successful_channel_should_send_command - session = setup_for_extracting_channel_action do |ch| - ch.expects(:exec).with(%(sh -c 'ls')) - end - Capistrano::Command.new("ls", [session]) - end - - def test_successful_channel_with_shell_option_should_send_command_via_specified_shell - session = setup_for_extracting_channel_action do |ch| - ch.expects(:exec).with(%(/bin/bash -c 'ls')) - end - Capistrano::Command.new("ls", [session], :shell => "/bin/bash") - end - - def test_successful_channel_with_shell_false_should_send_command_without_shell - session = setup_for_extracting_channel_action do |ch| - ch.expects(:exec).with(%(echo `hostname`)) - end - Capistrano::Command.new("echo `hostname`", [session], :shell => false) - end - - def test_successful_channel_should_send_data_if_data_key_is_present - session = setup_for_extracting_channel_action do |ch| - ch.expects(:exec).with(%(sh -c 'ls')) - ch.expects(:send_data).with("here we go") - end - Capistrano::Command.new("ls", [session], :data => "here we go") - end - - def test_unsuccessful_pty_request_should_close_channel - session = setup_for_extracting_channel_action(:request_pty, false) do |ch| - ch.expects(:close) - end - Capistrano::Command.new("ls", [session], :pty => true) - end - - def test_on_data_should_invoke_callback_as_stdout - session = setup_for_extracting_channel_action(:on_data, "hello") - called = false - Capistrano::Command.new("ls", [session]) do |ch, stream, data| - called = true - assert_equal :out, stream - assert_equal "hello", data - end - assert called - end - - def test_on_extended_data_should_invoke_callback_as_stderr - session = setup_for_extracting_channel_action(:on_extended_data, 2, "hello") - called = false - Capistrano::Command.new("ls", [session]) do |ch, stream, data| - called = true - assert_equal :err, stream - assert_equal "hello", data - end - assert called - end - - def test_on_request_should_record_exit_status - data = mock(:read_long => 5) - channel = nil - session = setup_for_extracting_channel_action([:on_request, "exit-status"], data) { |ch| channel = ch } - Capistrano::Command.new("ls", [session]) - assert_equal 5, channel[:status] - end - - def test_on_close_should_set_channel_closed - channel = nil - session = setup_for_extracting_channel_action(:on_close) { |ch| channel = ch } - Capistrano::Command.new("ls", [session]) - assert channel[:closed] - end - - def test_stop_should_close_all_open_channels - sessions = [mock_session(new_channel(false)), - mock_session(new_channel(true)), - mock_session(new_channel(false))] - - cmd = Capistrano::Command.new("ls", sessions) - cmd.stop! - end - - def test_process_should_return_cleanly_if_all_channels_have_zero_exit_status - sessions = [mock_session(new_channel(true, 0)), - mock_session(new_channel(true, 0)), - mock_session(new_channel(true, 0))] - cmd = Capistrano::Command.new("ls", sessions) - assert_nothing_raised { cmd.process! } - end - - def test_process_should_raise_error_if_any_channel_has_non_zero_exit_status - sessions = [mock_session(new_channel(true, 0)), - mock_session(new_channel(true, 0)), - mock_session(new_channel(true, 1))] - cmd = Capistrano::Command.new("ls", sessions) - assert_raises(Capistrano::CommandError) { cmd.process! } - end - - def test_command_error_should_include_accessor_with_host_array - sessions = [mock_session(new_channel(true, 0)), - mock_session(new_channel(true, 0)), - mock_session(new_channel(true, 1))] - cmd = Capistrano::Command.new("ls", sessions) - - begin - cmd.process! - flunk "expected an exception to be raised" - rescue Capistrano::CommandError => e - assert e.respond_to?(:hosts) - assert_equal %w(capistrano), e.hosts.map { |h| h.to_s } - end - end - - def test_process_should_loop_until_all_channels_are_closed - new_channel = Proc.new do |times| - ch = mock("channel") - returns = [false] * (times-1) - ch.stubs(:[]).with(:closed).returns(*(returns + [true])) - ch.expects(:[]).with(:status).returns(0) - ch - end - - sessions = [mock_session(new_channel[5]), - mock_session(new_channel[10]), - mock_session(new_channel[7])] - cmd = Capistrano::Command.new("ls", sessions) - assert_nothing_raised { cmd.process! } - end - - def test_process_should_instantiate_command_and_process! - cmd = mock("command", :process! => nil) - Capistrano::Command.expects(:new).with("ls -l", %w(a b c), {:foo => "bar"}).returns(cmd) - Capistrano::Command.process("ls -l", %w(a b c), :foo => "bar") - end - - def test_process_with_host_placeholder_should_substitute_placeholder_with_each_host - session = setup_for_extracting_channel_action do |ch| - ch.expects(:exec).with(%(sh -c 'echo capistrano')) - end - Capistrano::Command.new("echo $CAPISTRANO:HOST$", [session]) - end - - def test_process_with_unknown_placeholder_should_not_replace_placeholder - session = setup_for_extracting_channel_action do |ch| - ch.expects(:exec).with(%(sh -c 'echo $CAPISTRANO:OTHER$')) - end - Capistrano::Command.new("echo $CAPISTRANO:OTHER$", [session]) - end - - private - - def mock_session(channel=nil) - stub('session', :open_channel => channel, - :preprocess => true, - :postprocess => true, - :listeners => {}, - :xserver => server("capistrano")) - end - - class MockChannel < Hash - def close - end - end - - def new_channel(closed, status=nil) - ch = MockChannel.new - ch.update({ :closed => closed, :host => "capistrano", :server => server("capistrano") }) - ch[:status] = status if status - ch.expects(:close) unless closed - ch - end - - def setup_for_extracting_channel_action(action=nil, *args) - s = server("capistrano") - session = mock("session", :xserver => s) - - channel = {} - session.expects(:open_channel).yields(channel) - - channel.stubs(:on_data) - channel.stubs(:on_extended_data) - channel.stubs(:on_request) - channel.stubs(:on_close) - channel.stubs(:exec) - channel.stubs(:send_data) - - if action - action = Array(action) - channel.expects(action.first).with(*action[1..-1]).yields(channel, *args) - end - - yield channel if block_given? - - session - end -end diff --git a/vendor/gems/capistrano-2.5.9/test/configuration/actions/file_transfer_test.rb b/vendor/gems/capistrano-2.5.9/test/configuration/actions/file_transfer_test.rb deleted file mode 100644 index 8361a6959..000000000 --- a/vendor/gems/capistrano-2.5.9/test/configuration/actions/file_transfer_test.rb +++ /dev/null @@ -1,61 +0,0 @@ -require "utils" -require 'capistrano/configuration/actions/file_transfer' - -class ConfigurationActionsFileTransferTest < Test::Unit::TestCase - class MockConfig - include Capistrano::Configuration::Actions::FileTransfer - attr_accessor :sessions - end - - def setup - @config = MockConfig.new - @config.stubs(:logger).returns(stub_everything) - end - - def test_put_should_delegate_to_upload - @config.expects(:upload).with { |from, to, opts| - from.string == "some data" && to == "test.txt" && opts == { :mode => 0777 } } - @config.expects(:run).never - @config.put("some data", "test.txt", :mode => 0777) - end - - def test_get_should_delegate_to_download_with_once - @config.expects(:download).with("testr.txt", "testl.txt", :foo => "bar", :once => true) - @config.get("testr.txt", "testl.txt", :foo => "bar") - end - - def test_upload_should_delegate_to_transfer - @config.expects(:transfer).with(:up, "testl.txt", "testr.txt", :foo => "bar") - @config.upload("testl.txt", "testr.txt", :foo => "bar") - end - - def test_upload_without_mode_should_not_try_to_chmod - @config.expects(:transfer).with(:up, "testl.txt", "testr.txt", :foo => "bar") - @config.expects(:run).never - @config.upload("testl.txt", "testr.txt", :foo => "bar") - end - - def test_upload_with_mode_should_try_to_chmod - @config.expects(:transfer).with(:up, "testl.txt", "testr.txt", :foo => "bar") - @config.expects(:run).with("chmod 775 testr.txt") - @config.upload("testl.txt", "testr.txt", :mode => 0775, :foo => "bar") - end - - def test_upload_with_symbolic_mode_should_try_to_chmod - @config.expects(:transfer).with(:up, "testl.txt", "testr.txt", :foo => "bar") - @config.expects(:run).with("chmod g+w testr.txt") - @config.upload("testl.txt", "testr.txt", :mode => "g+w", :foo => "bar") - end - - def test_download_should_delegate_to_transfer - @config.expects(:transfer).with(:down, "testr.txt", "testl.txt", :foo => "bar") - @config.download("testr.txt", "testl.txt", :foo => "bar") - end - - def test_transfer_should_invoke_transfer_on_matching_servers - @config.sessions = { :a => 1, :b => 2, :c => 3, :d => 4 } - @config.expects(:execute_on_servers).with(:foo => "bar").yields([:a, :b, :c]) - Capistrano::Transfer.expects(:process).with(:up, "testl.txt", "testr.txt", [1,2,3], {:foo => "bar", :logger => @config.logger}) - @config.transfer(:up, "testl.txt", "testr.txt", :foo => "bar") - end -end \ No newline at end of file diff --git a/vendor/gems/capistrano-2.5.9/test/configuration/actions/inspect_test.rb b/vendor/gems/capistrano-2.5.9/test/configuration/actions/inspect_test.rb deleted file mode 100644 index 5538ce046..000000000 --- a/vendor/gems/capistrano-2.5.9/test/configuration/actions/inspect_test.rb +++ /dev/null @@ -1,65 +0,0 @@ -require "utils" -require 'capistrano/configuration/actions/inspect' - -class ConfigurationActionsInspectTest < Test::Unit::TestCase - class MockConfig - include Capistrano::Configuration::Actions::Inspect - end - - def setup - @config = MockConfig.new - @config.stubs(:logger).returns(stub_everything) - end - - def test_stream_should_pass_options_through_to_run - @config.expects(:invoke_command).with("tail -f foo.log", :once => true) - @config.stream("tail -f foo.log", :once => true) - end - - def test_stream_should_emit_stdout_via_puts - @config.expects(:invoke_command).yields(mock("channel"), :out, "something streamed") - @config.expects(:puts).with("something streamed") - @config.expects(:warn).never - @config.stream("tail -f foo.log") - end - - def test_stream_should_emit_stderr_via_warn - ch = mock("channel") - ch.expects(:[]).with(:server).returns(server("capistrano")) - @config.expects(:invoke_command).yields(ch, :err, "something streamed") - @config.expects(:puts).never - @config.expects(:warn).with("[err :: capistrano] something streamed") - @config.stream("tail -f foo.log") - end - - def test_capture_should_pass_options_merged_with_once_to_run - @config.expects(:invoke_command).with("hostname", :foo => "bar", :once => true) - @config.capture("hostname", :foo => "bar") - end - - def test_capture_with_stderr_should_emit_stderr_via_warn - ch = mock("channel") - ch.expects(:[]).with(:server).returns(server("capistrano")) - @config.expects(:invoke_command).yields(ch, :err, "boom") - @config.expects(:warn).with("[err :: capistrano] boom") - @config.capture("hostname") - end - - def test_capture_with_stdout_should_aggregate_and_return_stdout - config_expects_invoke_command_to_loop_with(mock("channel"), "foo", "bar", "baz") - assert_equal "foobarbaz", @config.capture("hostname") - end - - private - - def config_expects_invoke_command_to_loop_with(channel, *output) - class <<@config - attr_accessor :script, :channel - def invoke_command(*args) - script.each { |item| yield channel, :out, item } - end - end - @config.channel = channel - @config.script = output - end -end diff --git a/vendor/gems/capistrano-2.5.9/test/configuration/actions/invocation_test.rb b/vendor/gems/capistrano-2.5.9/test/configuration/actions/invocation_test.rb deleted file mode 100644 index b64029d85..000000000 --- a/vendor/gems/capistrano-2.5.9/test/configuration/actions/invocation_test.rb +++ /dev/null @@ -1,224 +0,0 @@ -require "utils" -require 'capistrano/configuration/actions/invocation' - -class ConfigurationActionsInvocationTest < Test::Unit::TestCase - class MockConfig - attr_reader :options - attr_accessor :debug - attr_accessor :dry_run - - def initialize - @options = {} - end - - def [](*args) - @options[*args] - end - - def set(name, value) - @options[name] = value - end - - def fetch(*args) - @options.fetch(*args) - end - - include Capistrano::Configuration::Actions::Invocation - end - - def setup - @config = MockConfig.new - @original_io_proc = MockConfig.default_io_proc - @config.stubs(:logger).returns(stub_everything) - end - - def teardown - MockConfig.default_io_proc = @original_io_proc - end - - def test_run_options_should_be_passed_to_execute_on_servers - @config.expects(:execute_on_servers).with(:foo => "bar") - @config.run "ls", :foo => "bar" - end - - def test_run_will_return_if_dry_run - @config.expects(:dry_run).returns(true) - @config.expects(:execute_on_servers).never - @config.run "ls", :foo => "bar" - end - - def test_add_default_command_options_should_return_bare_options_if_there_is_no_env_or_shell_specified - assert_equal({:foo => "bar"}, @config.add_default_command_options(:foo => "bar")) - end - - def test_add_default_command_options_should_merge_default_environment_as_env - @config[:default_environment][:bang] = "baz" - assert_equal({:foo => "bar", :env => { :bang => "baz" }}, @config.add_default_command_options(:foo => "bar")) - end - - def test_add_default_command_options_should_merge_env_with_default_environment - @config[:default_environment][:bang] = "baz" - @config[:default_environment][:bacon] = "crunchy" - assert_equal({:foo => "bar", :env => { :bang => "baz", :bacon => "chunky", :flip => "flop" }}, @config.add_default_command_options(:foo => "bar", :env => {:bacon => "chunky", :flip => "flop"})) - end - - def test_add_default_command_options_should_use_default_shell_if_present - @config.set :default_shell, "/bin/bash" - assert_equal({:foo => "bar", :shell => "/bin/bash"}, @config.add_default_command_options(:foo => "bar")) - end - - def test_add_default_command_options_should_use_default_shell_of_false_if_present - @config.set :default_shell, false - assert_equal({:foo => "bar", :shell => false}, @config.add_default_command_options(:foo => "bar")) - end - - def test_add_default_command_options_should_use_shell_in_preference_of_default_shell - @config.set :default_shell, "/bin/bash" - assert_equal({:foo => "bar", :shell => "/bin/sh"}, @config.add_default_command_options(:foo => "bar", :shell => "/bin/sh")) - end - - def test_default_io_proc_should_log_stdout_arguments_as_info - ch = { :host => "capistrano", - :server => server("capistrano"), - :options => { :logger => mock("logger") } } - ch[:options][:logger].expects(:info).with("data stuff", "out :: capistrano") - MockConfig.default_io_proc[ch, :out, "data stuff"] - end - - def test_default_io_proc_should_log_stderr_arguments_as_important - ch = { :host => "capistrano", - :server => server("capistrano"), - :options => { :logger => mock("logger") } } - ch[:options][:logger].expects(:important).with("data stuff", "err :: capistrano") - MockConfig.default_io_proc[ch, :err, "data stuff"] - end - - def test_sudo_should_default_to_sudo - @config.expects(:run).with("sudo -p 'sudo password: ' ls", {}) - @config.sudo "ls" - end - - def test_sudo_should_use_sudo_variable_definition - @config.expects(:run).with("/opt/local/bin/sudo -p 'sudo password: ' ls", {}) - @config.options[:sudo] = "/opt/local/bin/sudo" - @config.sudo "ls" - end - - def test_sudo_should_interpret_as_option_as_user - @config.expects(:run).with("sudo -p 'sudo password: ' -u app ls", {}) - @config.sudo "ls", :as => "app" - end - - def test_sudo_should_pass_options_through_to_run - @config.expects(:run).with("sudo -p 'sudo password: ' ls", :foo => "bar") - @config.sudo "ls", :foo => "bar" - end - - def test_sudo_should_avoid_minus_p_when_sudo_prompt_is_empty - @config.set :sudo_prompt, "" - @config.expects(:run).with("sudo ls", {}) - @config.sudo "ls" - end - - def test_sudo_should_interpret_sudo_prompt_variable_as_custom_prompt - @config.set :sudo_prompt, "give it to me: " - @config.expects(:run).with("sudo -p 'give it to me: ' ls", {}) - @config.sudo "ls" - end - - def test_sudo_behavior_callback_should_send_password_when_prompted_with_default_sudo_prompt - ch = mock("channel") - ch.expects(:send_data).with("g00b3r\n") - @config.options[:password] = "g00b3r" - @config.sudo_behavior_callback(nil)[ch, nil, "sudo password: "] - end - - def test_sudo_behavior_callback_should_send_password_when_prompted_with_custom_sudo_prompt - ch = mock("channel") - ch.expects(:send_data).with("g00b3r\n") - @config.set :sudo_prompt, "give it to me: " - @config.options[:password] = "g00b3r" - @config.sudo_behavior_callback(nil)[ch, nil, "give it to me: "] - end - - def test_sudo_behavior_callback_with_incorrect_password_on_first_prompt - ch = mock("channel") - ch.stubs(:[]).with(:host).returns("capistrano") - ch.stubs(:[]).with(:server).returns(server("capistrano")) - @config.expects(:reset!).with(:password) - @config.sudo_behavior_callback(nil)[ch, nil, "Sorry, try again."] - end - - def test_sudo_behavior_callback_with_incorrect_password_on_subsequent_prompts - callback = @config.sudo_behavior_callback(nil) - - ch = mock("channel") - ch.stubs(:[]).with(:host).returns("capistrano") - ch.stubs(:[]).with(:server).returns(server("capistrano")) - ch2 = mock("channel") - ch2.stubs(:[]).with(:host).returns("cap2") - ch2.stubs(:[]).with(:server).returns(server("cap2")) - - @config.expects(:reset!).with(:password).times(2) - - callback[ch, nil, "Sorry, try again."] - callback[ch2, nil, "Sorry, try again."] # shouldn't call reset! - callback[ch, nil, "Sorry, try again."] - end - - def test_sudo_behavior_callback_should_reset_password_and_prompt_again_if_output_includes_both_cues - ch = mock("channel") - ch.stubs(:[]).with(:host).returns("capistrano") - ch.stubs(:[]).with(:server).returns(server("capistrano")) - ch.expects(:send_data, "password!\n").times(2) - - @config.set(:password, "password!") - @config.expects(:reset!).with(:password) - - callback = @config.sudo_behavior_callback(nil) - callback[ch, :out, "sudo password: "] - callback[ch, :out, "Sorry, try again.\nsudo password: "] - end - - def test_sudo_behavior_callback_should_defer_to_fallback_for_other_output - callback = @config.sudo_behavior_callback(inspectable_proc) - - a = mock("channel", :called => true) - b = mock("stream", :called => true) - c = mock("data", :called => true) - - callback[a, b, c] - end - - def test_invoke_command_should_default_to_run - @config.expects(:run).with("ls", :once => true) - @config.invoke_command("ls", :once => true) - end - - def test_invoke_command_should_delegate_to_method_identified_by_via - @config.expects(:foobar).with("ls", :once => true) - @config.invoke_command("ls", :once => true, :via => :foobar) - end - - private - - def inspectable_proc - Proc.new do |ch, stream, data| - ch.called - stream.called - data.called - end - end - - def prepare_command(command, sessions, options) - a = mock("channel", :called => true) - b = mock("stream", :called => true) - c = mock("data", :called => true) - - compare_args = Proc.new do |tree, sess, opts| - tree.fallback.command == command && sess == sessions && opts == options - end - - Capistrano::Command.expects(:process).with(&compare_args) - end -end diff --git a/vendor/gems/capistrano-2.5.9/test/configuration/callbacks_test.rb b/vendor/gems/capistrano-2.5.9/test/configuration/callbacks_test.rb deleted file mode 100644 index 7d5b1a648..000000000 --- a/vendor/gems/capistrano-2.5.9/test/configuration/callbacks_test.rb +++ /dev/null @@ -1,220 +0,0 @@ -require "utils" -require 'capistrano/configuration/callbacks' - -class ConfigurationCallbacksTest < Test::Unit::TestCase - class MockConfig - attr_reader :original_initialize_called - attr_reader :called - - def initialize - @original_initialize_called = true - @called = [] - end - - def execute_task(task) - invoke_task_directly(task) - end - - protected - - def invoke_task_directly(task) - @called << task - end - - include Capistrano::Configuration::Callbacks - end - - def setup - @config = MockConfig.new - @config.stubs(:logger).returns(stub_everything("logger")) - end - - def test_initialize_should_initialize_callbacks_collection - assert @config.original_initialize_called - assert @config.callbacks.empty? - end - - def test_before_should_delegate_to_on - @config.expects(:on).with(:before, :foo, "bing:blang", {:only => :bar, :zip => :zing}) - @config.before :bar, :foo, "bing:blang", :zip => :zing - end - - def test_after_should_delegate_to_on - @config.expects(:on).with(:after, :foo, "bing:blang", {:only => :bar, :zip => :zing}) - @config.after :bar, :foo, "bing:blang", :zip => :zing - end - - def test_on_with_single_reference_should_add_task_callback - @config.on :before, :a_test - assert_equal 1, @config.callbacks[:before].length - assert_equal :a_test, @config.callbacks[:before][0].source - @config.expects(:find_and_execute_task).with(:a_test) - @config.callbacks[:before][0].call - end - - def test_on_with_multi_reference_should_add_all_as_task_callback - @config.on :before, :first, :second, :third - assert_equal 3, @config.callbacks[:before].length - assert_equal %w(first second third), @config.callbacks[:before].map { |c| c.source.to_s } - end - - def test_on_with_block_should_add_block_as_proc_callback - called = false - @config.on(:before) { called = true } - assert_equal 1, @config.callbacks[:before].length - assert_instance_of Proc, @config.callbacks[:before][0].source - @config.callbacks[:before][0].call - assert called - end - - def test_on_with_single_only_should_set_only_as_string_array_on_all_references - @config.on :before, :first, "second:third", :only => :primary - assert_equal 2, @config.callbacks[:before].length - assert @config.callbacks[:before].all? { |c| c.only == %w(primary) } - end - - def test_on_with_multi_only_should_set_only_as_string_array_on_all_references - @config.on :before, :first, "second:third", :only => [:primary, "other:one"] - assert_equal 2, @config.callbacks[:before].length - assert @config.callbacks[:before].all? { |c| c.only == %w(primary other:one) } - end - - def test_on_with_single_except_should_set_except_as_string_array_on_all_references - @config.on :before, :first, "second:third", :except => :primary - assert_equal 2, @config.callbacks[:before].length - assert @config.callbacks[:before].all? { |c| c.except == %w(primary) } - end - - def test_on_with_multi_except_should_set_except_as_string_array_on_all_references - @config.on :before, :first, "second:third", :except => [:primary, "other:one"] - assert_equal 2, @config.callbacks[:before].length - assert @config.callbacks[:before].all? { |c| c.except == %w(primary other:one) } - end - - def test_on_with_only_and_block_should_set_only_as_string_array - @config.on(:before, :only => :primary) { blah } - assert_equal 1, @config.callbacks[:before].length - assert_equal %w(primary), @config.callbacks[:before].first.only - end - - def test_on_with_except_and_block_should_set_except_as_string_array - @config.on(:before, :except => :primary) { blah } - assert_equal 1, @config.callbacks[:before].length - assert_equal %w(primary), @config.callbacks[:before].first.except - end - - def test_on_without_tasks_or_block_should_raise_error - assert_raises(ArgumentError) { @config.on(:before) } - end - - def test_on_with_both_tasks_and_block_should_raise_error - assert_raises(ArgumentError) { @config.on(:before, :first) { blah } } - end - - def test_trigger_without_constraints_should_invoke_all_callbacks - task = stub(:fully_qualified_name => "any:old:thing") - @config.on(:before, :first, "second:third") - @config.on(:after, :another, "and:another") - @config.expects(:find_and_execute_task).with(:first) - @config.expects(:find_and_execute_task).with("second:third") - @config.expects(:find_and_execute_task).with(:another).never - @config.expects(:find_and_execute_task).with("and:another").never - @config.trigger(:before, task) - end - - def test_trigger_with_only_constraint_should_invoke_only_matching_callbacks - task = stub(:fully_qualified_name => "any:old:thing") - @config.on(:before, :first) - @config.on(:before, "second:third", :only => "any:old:thing") - @config.on(:before, "this:too", :only => "any:other:thing") - @config.on(:after, :another, "and:another") - @config.expects(:find_and_execute_task).with(:first) - @config.expects(:find_and_execute_task).with("second:third") - @config.expects(:find_and_execute_task).with("this:too").never - @config.expects(:find_and_execute_task).with(:another).never - @config.expects(:find_and_execute_task).with("and:another").never - @config.trigger(:before, task) - end - - def test_trigger_with_except_constraint_should_invoke_anything_but_matching_callbacks - task = stub(:fully_qualified_name => "any:old:thing") - @config.on(:before, :first) - @config.on(:before, "second:third", :except => "any:old:thing") - @config.on(:before, "this:too", :except => "any:other:thing") - @config.on(:after, :another, "and:another") - @config.expects(:find_and_execute_task).with(:first) - @config.expects(:find_and_execute_task).with("second:third").never - @config.expects(:find_and_execute_task).with("this:too") - @config.expects(:find_and_execute_task).with(:another).never - @config.expects(:find_and_execute_task).with("and:another").never - @config.trigger(:before, task) - end - - def test_trigger_without_task_should_invoke_all_callbacks_for_that_event - task = stub(:fully_qualified_name => "any:old:thing") - @config.on(:before, :first) - @config.on(:before, "second:third", :except => "any:old:thing") - @config.on(:before, "this:too", :except => "any:other:thing") - @config.on(:after, :another, "and:another") - @config.expects(:find_and_execute_task).with(:first) - @config.expects(:find_and_execute_task).with("second:third") - @config.expects(:find_and_execute_task).with("this:too") - @config.expects(:find_and_execute_task).with(:another).never - @config.expects(:find_and_execute_task).with("and:another").never - @config.trigger(:before) - end - - def test_execute_task_without_named_hooks_should_just_call_task - ns = stub("namespace", :default_task => nil, :name => "old", :fully_qualified_name => "any:old") - task = stub(:fully_qualified_name => "any:old:thing", :name => "thing", :namespace => ns) - - ns.stubs(:search_task).returns(nil) - - @config.execute_task(task) - assert_equal [task], @config.called - end - - def test_execute_task_with_named_before_hook_should_call_named_before_hook - ns = stub("namespace", :default_task => nil, :name => "old", :fully_qualified_name => "any:old") - task = stub(:fully_qualified_name => "any:old:thing", :name => "thing", :namespace => ns) - before_task = stub(:fully_qualified_name => "any:old:before_thing", :name => "before_thing", :namespace => ns) - - ns.stubs(:search_task).returns(nil) - ns.expects(:search_task).with("before_thing").returns(before_task) - - @config.execute_task(task) - assert_equal [before_task, task], @config.called - end - - def test_execute_task_with_named_after_hook_should_call_named_after_hook - ns = stub("namespace", :default_task => nil, :name => "old", :fully_qualified_name => "any:old") - task = stub(:fully_qualified_name => "any:old:thing", :name => "thing", :namespace => ns) - after_task = stub(:fully_qualified_name => "any:old:after_thing", :name => "after_thing", :namespace => ns) - - ns.stubs(:search_task).returns(nil) - ns.expects(:search_task).with("after_thing").returns(after_task) - - @config.execute_task(task) - assert_equal [task, after_task], @config.called - end - - def test_execute_task_with_on_hooks_should_trigger_hooks_around_task - ns = stub("namespace", :default_task => nil, :name => "old", :fully_qualified_name => "any:old") - task = stub(:fully_qualified_name => "any:old:thing", :name => "thing", :namespace => ns) - before_task = stub(:fully_qualified_name => "any:old:before_thing", :name => "before_thing", :namespace => ns) - after_task = stub(:fully_qualified_name => "any:old:after_thing", :name => "after_thing", :namespace => ns) - - ns.stubs(:search_task).returns(nil) - ns.expects(:search_task).with("before_thing").returns(before_task) - ns.expects(:search_task).with("after_thing").returns(after_task) - - @config.before("any:old:thing", :first_this, :then_this) - @config.after("any:old:thing", :and_then_this, :lastly_this) - - [:first_this, :then_this, :and_then_this, :lastly_this].each do |t| - @config.expects(:find_and_execute_task).with(t) - end - - @config.execute_task(task) - end -end diff --git a/vendor/gems/capistrano-2.5.9/test/configuration/connections_test.rb b/vendor/gems/capistrano-2.5.9/test/configuration/connections_test.rb deleted file mode 100644 index ee99205c7..000000000 --- a/vendor/gems/capistrano-2.5.9/test/configuration/connections_test.rb +++ /dev/null @@ -1,349 +0,0 @@ -require "utils" -require 'capistrano/configuration/connections' - -class ConfigurationConnectionsTest < Test::Unit::TestCase - class MockConfig - attr_reader :original_initialize_called - attr_reader :values - attr_accessor :current_task - - def initialize - @original_initialize_called = true - @values = {} - end - - def fetch(*args) - @values.fetch(*args) - end - - def [](key) - @values[key] - end - - def exists?(key) - @values.key?(key) - end - - include Capistrano::Configuration::Connections - end - - def setup - @config = MockConfig.new - @config.stubs(:logger).returns(stub_everything) - Net::SSH.stubs(:configuration_for).returns({}) - @ssh_options = { - :user => "user", - :port => 8080, - :password => "g00b3r", - :ssh_options => { :debug => :verbose } - } - end - - def test_initialize_should_initialize_collections_and_call_original_initialize - assert @config.original_initialize_called - assert @config.sessions.empty? - end - - def test_connection_factory_should_return_default_connection_factory_instance - factory = @config.connection_factory - assert_instance_of Capistrano::Configuration::Connections::DefaultConnectionFactory, factory - end - - def test_connection_factory_instance_should_be_cached - assert_same @config.connection_factory, @config.connection_factory - end - - def test_default_connection_factory_honors_config_options - server = server("capistrano") - Capistrano::SSH.expects(:connect).with(server, @config).returns(:session) - assert_equal :session, @config.connection_factory.connect_to(server) - end - - def test_should_connect_through_gateway_if_gateway_variable_is_set - @config.values[:gateway] = "j@gateway" - Net::SSH::Gateway.expects(:new).with("gateway", "j", :password => nil, :auth_methods => %w(publickey hostbased), :config => false).returns(stub_everything) - assert_instance_of Capistrano::Configuration::Connections::GatewayConnectionFactory, @config.connection_factory - end - - def test_connection_factory_as_gateway_should_honor_config_options - @config.values[:gateway] = "gateway" - @config.values.update(@ssh_options) - Net::SSH::Gateway.expects(:new).with("gateway", "user", :debug => :verbose, :port => 8080, :password => nil, :auth_methods => %w(publickey hostbased), :config => false).returns(stub_everything) - assert_instance_of Capistrano::Configuration::Connections::GatewayConnectionFactory, @config.connection_factory - end - - def test_connection_factory_as_gateway_should_chain_gateways_if_gateway_variable_is_an_array - @config.values[:gateway] = ["j@gateway1", "k@gateway2"] - gateway1 = mock - Net::SSH::Gateway.expects(:new).with("gateway1", "j", :password => nil, :auth_methods => %w(publickey hostbased), :config => false).returns(gateway1) - gateway1.expects(:open).returns(65535) - Net::SSH::Gateway.expects(:new).with("127.0.0.1", "k", :port => 65535, :password => nil, :auth_methods => %w(publickey hostbased), :config => false).returns(stub_everything) - assert_instance_of Capistrano::Configuration::Connections::GatewayConnectionFactory, @config.connection_factory - end - - def test_connection_factory_as_gateway_should_share_gateway_between_connections - @config.values[:gateway] = "j@gateway" - Net::SSH::Gateway.expects(:new).once.with("gateway", "j", :password => nil, :auth_methods => %w(publickey hostbased), :config => false).returns(stub_everything) - Capistrano::SSH.stubs(:connect).returns(stub_everything) - assert_instance_of Capistrano::Configuration::Connections::GatewayConnectionFactory, @config.connection_factory - @config.establish_connections_to(server("capistrano")) - @config.establish_connections_to(server("another")) - end - - def test_establish_connections_to_should_accept_a_single_nonarray_parameter - Capistrano::SSH.expects(:connect).with { |s,| s.host == "capistrano" }.returns(:success) - assert @config.sessions.empty? - @config.establish_connections_to(server("capistrano")) - assert ["capistrano"], @config.sessions.keys - end - - def test_establish_connections_to_should_accept_an_array - Capistrano::SSH.expects(:connect).times(3).returns(:success) - assert @config.sessions.empty? - @config.establish_connections_to(%w(cap1 cap2 cap3).map { |s| server(s) }) - assert %w(cap1 cap2 cap3), @config.sessions.keys.sort - end - - def test_establish_connections_to_should_not_attempt_to_reestablish_existing_connections - Capistrano::SSH.expects(:connect).times(2).returns(:success) - @config.sessions[server("cap1")] = :ok - @config.establish_connections_to(%w(cap1 cap2 cap3).map { |s| server(s) }) - assert %w(cap1 cap2 cap3), @config.sessions.keys.sort.map { |s| s.host } - end - - def test_establish_connections_to_should_raise_one_connection_error_on_failure - Capistrano::SSH.expects(:connect).times(2).raises(Exception) - assert_raises(Capistrano::ConnectionError) { - @config.establish_connections_to(%w(cap1 cap2).map { |s| server(s) }) - } - end - - def test_connection_error_should_include_accessor_with_host_array - Capistrano::SSH.expects(:connect).times(2).raises(Exception) - - begin - @config.establish_connections_to(%w(cap1 cap2).map { |s| server(s) }) - flunk "expected an exception to be raised" - rescue Capistrano::ConnectionError => e - assert e.respond_to?(:hosts) - assert_equal %w(cap1 cap2), e.hosts.map { |h| h.to_s }.sort - end - end - - def test_connection_error_should_only_include_failed_hosts - Capistrano::SSH.expects(:connect).with(server('cap1'), anything).raises(Exception) - Capistrano::SSH.expects(:connect).with(server('cap2'), anything).returns(:success) - - begin - @config.establish_connections_to(%w(cap1 cap2).map { |s| server(s) }) - flunk "expected an exception to be raised" - rescue Capistrano::ConnectionError => e - assert_equal %w(cap1), e.hosts.map { |h| h.to_s } - end - end - - def test_execute_on_servers_should_require_a_block - assert_raises(ArgumentError) { @config.execute_on_servers } - end - - def test_execute_on_servers_without_current_task_should_call_find_servers - list = [server("first"), server("second")] - @config.expects(:find_servers).with(:a => :b, :c => :d).returns(list) - @config.expects(:establish_connections_to).with(list).returns(:done) - @config.execute_on_servers(:a => :b, :c => :d) do |result| - assert_equal list, result - end - end - - def test_execute_on_servers_without_current_task_should_raise_error_if_no_matching_servers - @config.expects(:find_servers).with(:a => :b, :c => :d).returns([]) - assert_raises(Capistrano::NoMatchingServersError) { @config.execute_on_servers(:a => :b, :c => :d) { |list| } } - end - - def test_execute_on_servers_should_raise_an_error_if_the_current_task_has_no_matching_servers_by_default - @config.current_task = mock_task - @config.expects(:find_servers_for_task).with(@config.current_task, {}).returns([]) - assert_raises(Capistrano::NoMatchingServersError) do - @config.execute_on_servers do - flunk "should not get here" - end - end - end - - def test_execute_on_servers_should_determine_server_list_from_active_task - assert @config.sessions.empty? - @config.current_task = mock_task - @config.expects(:find_servers_for_task).with(@config.current_task, {}).returns([server("cap1"), server("cap2"), server("cap3")]) - Capistrano::SSH.expects(:connect).times(3).returns(:success) - @config.execute_on_servers {} - assert_equal %w(cap1 cap2 cap3), @config.sessions.keys.sort.map { |s| s.host } - end - - def test_execute_on_servers_should_yield_server_list_to_block - assert @config.sessions.empty? - @config.current_task = mock_task - @config.expects(:find_servers_for_task).with(@config.current_task, {}).returns([server("cap1"), server("cap2"), server("cap3")]) - Capistrano::SSH.expects(:connect).times(3).returns(:success) - block_called = false - @config.execute_on_servers do |servers| - block_called = true - assert servers.detect { |s| s.host == "cap1" } - assert servers.detect { |s| s.host == "cap2" } - assert servers.detect { |s| s.host == "cap3" } - assert servers.all? { |s| @config.sessions[s] } - end - assert block_called - end - - def test_execute_on_servers_with_once_option_should_establish_connection_to_and_yield_only_the_first_server - assert @config.sessions.empty? - @config.current_task = mock_task - @config.expects(:find_servers_for_task).with(@config.current_task, :once => true).returns([server("cap1"), server("cap2"), server("cap3")]) - Capistrano::SSH.expects(:connect).returns(:success) - block_called = false - @config.execute_on_servers(:once => true) do |servers| - block_called = true - assert_equal %w(cap1), servers.map { |s| s.host } - end - assert block_called - assert_equal %w(cap1), @config.sessions.keys.sort.map { |s| s.host } - end - - def test_execute_servers_should_raise_connection_error_on_failure_by_default - @config.current_task = mock_task - @config.expects(:find_servers_for_task).with(@config.current_task, {}).returns([server("cap1")]) - Capistrano::SSH.expects(:connect).raises(Exception) - assert_raises(Capistrano::ConnectionError) do - @config.execute_on_servers do - flunk "expected an exception to be raised" - end - end - end - - def test_execute_servers_should_not_raise_connection_error_on_failure_with_on_errors_continue - @config.current_task = mock_task(:on_error => :continue) - @config.expects(:find_servers_for_task).with(@config.current_task, {}).returns([server("cap1"), server("cap2")]) - Capistrano::SSH.expects(:connect).with(server('cap1'), anything).raises(Exception) - Capistrano::SSH.expects(:connect).with(server('cap2'), anything).returns(:success) - assert_nothing_raised { - @config.execute_on_servers do |servers| - assert_equal %w(cap2), servers.map { |s| s.host } - end - } - end - - def test_execute_on_servers_should_not_try_to_connect_to_hosts_with_connection_errors_with_on_errors_continue - list = [server("cap1"), server("cap2")] - @config.current_task = mock_task(:on_error => :continue) - @config.expects(:find_servers_for_task).with(@config.current_task, {}).returns(list) - Capistrano::SSH.expects(:connect).with(server('cap1'), anything).raises(Exception) - Capistrano::SSH.expects(:connect).with(server('cap2'), anything).returns(:success) - @config.execute_on_servers do |servers| - assert_equal %w(cap2), servers.map { |s| s.host } - end - @config.expects(:find_servers_for_task).with(@config.current_task, {}).returns(list) - @config.execute_on_servers do |servers| - assert_equal %w(cap2), servers.map { |s| s.host } - end - end - - def test_execute_on_servers_should_not_try_to_connect_to_hosts_with_command_errors_with_on_errors_continue - cap1 = server("cap1") - cap2 = server("cap2") - @config.current_task = mock_task(:on_error => :continue) - @config.expects(:find_servers_for_task).with(@config.current_task, {}).returns([cap1, cap2]) - Capistrano::SSH.expects(:connect).times(2).returns(:success) - @config.execute_on_servers do |servers| - error = Capistrano::CommandError.new - error.hosts = [cap1] - raise error - end - @config.expects(:find_servers_for_task).with(@config.current_task, {}).returns([cap1, cap2]) - @config.execute_on_servers do |servers| - assert_equal %w(cap2), servers.map { |s| s.host } - end - end - - def test_execute_on_servers_should_not_try_to_connect_to_hosts_with_transfer_errors_with_on_errors_continue - cap1 = server("cap1") - cap2 = server("cap2") - @config.current_task = mock_task(:on_error => :continue) - @config.expects(:find_servers_for_task).with(@config.current_task, {}).returns([cap1, cap2]) - Capistrano::SSH.expects(:connect).times(2).returns(:success) - @config.execute_on_servers do |servers| - error = Capistrano::TransferError.new - error.hosts = [cap1] - raise error - end - @config.expects(:find_servers_for_task).with(@config.current_task, {}).returns([cap1, cap2]) - @config.execute_on_servers do |servers| - assert_equal %w(cap2), servers.map { |s| s.host } - end - end - - def test_connect_should_establish_connections_to_all_servers_in_scope - assert @config.sessions.empty? - @config.current_task = mock_task - @config.expects(:find_servers_for_task).with(@config.current_task, {}).returns([server("cap1"), server("cap2"), server("cap3")]) - Capistrano::SSH.expects(:connect).times(3).returns(:success) - @config.connect! - assert_equal %w(cap1 cap2 cap3), @config.sessions.keys.sort.map { |s| s.host } - end - - def test_execute_on_servers_should_only_run_on_tasks_max_hosts_hosts_at_once - cap1 = server("cap1") - cap2 = server("cap2") - connection1 = mock() - connection2 = mock() - connection1.expects(:close) - connection2.expects(:close) - @config.current_task = mock_task(:max_hosts => 1) - @config.expects(:find_servers_for_task).with(@config.current_task, {}).returns([cap1, cap2]) - Capistrano::SSH.expects(:connect).times(2).returns(connection1).then.returns(connection2) - block_called = 0 - @config.execute_on_servers do |servers| - block_called += 1 - assert_equal 1, servers.size - end - assert_equal 2, block_called - end - - def test_execute_on_servers_should_only_run_on_max_hosts_hosts_at_once - cap1 = server("cap1") - cap2 = server("cap2") - connection1 = mock() - connection2 = mock() - connection1.expects(:close) - connection2.expects(:close) - @config.current_task = mock_task(:max_hosts => 1) - @config.expects(:find_servers_for_task).with(@config.current_task, {}).returns([cap1, cap2]) - Capistrano::SSH.expects(:connect).times(2).returns(connection1).then.returns(connection2) - block_called = 0 - @config.execute_on_servers do |servers| - block_called += 1 - assert_equal 1, servers.size - end - assert_equal 2, block_called - end - - def test_connect_should_honor_once_option - assert @config.sessions.empty? - @config.current_task = mock_task - @config.expects(:find_servers_for_task).with(@config.current_task, :once => true).returns([server("cap1"), server("cap2"), server("cap3")]) - Capistrano::SSH.expects(:connect).returns(:success) - @config.connect! :once => true - assert_equal %w(cap1), @config.sessions.keys.sort.map { |s| s.host } - end - - private - - def mock_task(options={}) - continue_on_error = options[:on_error] == :continue - stub("task", - :fully_qualified_name => "name", - :options => options, - :continue_on_error? => continue_on_error, - :max_hosts => options[:max_hosts] - ) - end -end diff --git a/vendor/gems/capistrano-2.5.9/test/configuration/execution_test.rb b/vendor/gems/capistrano-2.5.9/test/configuration/execution_test.rb deleted file mode 100644 index b7e53eca3..000000000 --- a/vendor/gems/capistrano-2.5.9/test/configuration/execution_test.rb +++ /dev/null @@ -1,175 +0,0 @@ -require "utils" -require 'capistrano/configuration/execution' -require 'capistrano/task_definition' - -class ConfigurationExecutionTest < Test::Unit::TestCase - class MockConfig - attr_reader :tasks, :namespaces, :fully_qualified_name, :parent - attr_reader :state, :original_initialize_called - attr_accessor :logger, :default_task - - def initialize(options={}) - @original_initialize_called = true - @tasks = {} - @namespaces = {} - @state = {} - @fully_qualified_name = options[:fqn] - @parent = options[:parent] - @logger = options.delete(:logger) - end - - include Capistrano::Configuration::Execution - end - - def setup - @config = MockConfig.new(:logger => stub(:debug => nil, :info => nil, :important => nil)) - @config.stubs(:search_task).returns(nil) - end - - def test_initialize_should_initialize_collections - assert_nil @config.rollback_requests - assert @config.original_initialize_called - assert @config.task_call_frames.empty? - end - - def test_execute_task_should_populate_call_stack - task = new_task @config, :testing - assert_nothing_raised { @config.execute_task(task) } - assert_equal %w(testing), @config.state[:testing][:stack] - assert_nil @config.state[:testing][:history] - assert @config.task_call_frames.empty? - end - - def test_nested_execute_task_should_add_to_call_stack - testing = new_task @config, :testing - outer = new_task(@config, :outer) { execute_task(testing) } - - assert_nothing_raised { @config.execute_task(outer) } - assert_equal %w(outer testing), @config.state[:testing][:stack] - assert_nil @config.state[:testing][:history] - assert @config.task_call_frames.empty? - end - - def test_execute_task_should_execute_in_scope_of_tasks_parent - ns = stub("namespace", :tasks => {}, :default_task => nil, :fully_qualified_name => "ns") - ns.expects(:instance_eval) - testing = new_task ns, :testing - @config.execute_task(testing) - end - - def test_transaction_outside_of_task_should_raise_exception - assert_raises(ScriptError) { @config.transaction {} } - end - - def test_transaction_without_block_should_raise_argument_error - testing = new_task(@config, :testing) { transaction } - assert_raises(ArgumentError) { @config.execute_task(testing) } - end - - def test_transaction_should_initialize_transaction_history - @config.state[:inspector] = stack_inspector - testing = new_task(@config, :testing) { transaction { instance_eval(&state[:inspector]) } } - @config.execute_task(testing) - assert_equal [], @config.state[:testing][:history] - end - - def test_transaction_from_within_transaction_should_not_start_new_transaction - third = new_task(@config, :third, &stack_inspector) - second = new_task(@config, :second) { transaction { execute_task(third) } } - first = new_task(@config, :first) { transaction { execute_task(second) } } - # kind of fragile...not sure how else to check that transaction was only - # really run twice...but if the transaction was REALLY run, logger.info - # will be called once when it starts, and once when it finishes. - @config.logger = mock() - @config.logger.stubs(:debug) - @config.logger.expects(:info).times(2) - @config.execute_task(first) - end - - def test_on_rollback_should_have_no_effect_outside_of_transaction - aaa = new_task(@config, :aaa) { on_rollback { state[:rollback] = true }; raise "boom" } - assert_raises(RuntimeError) { @config.execute_task(aaa) } - assert_nil @config.state[:rollback] - end - - def test_exception_raised_in_transaction_should_call_all_registered_rollback_handlers_in_reverse_order - aaa = new_task(@config, :aaa) { on_rollback { (state[:rollback] ||= []) << :aaa } } - bbb = new_task(@config, :bbb) { on_rollback { (state[:rollback] ||= []) << :bbb } } - ccc = new_task(@config, :ccc) {} - ddd = new_task(@config, :ddd) { on_rollback { (state[:rollback] ||= []) << :ddd }; execute_task(bbb); execute_task(ccc) } - eee = new_task(@config, :eee) { transaction { execute_task(ddd); execute_task(aaa); raise "boom" } } - assert_raises(RuntimeError) do - @config.execute_task(eee) - end - assert_equal [:aaa, :bbb, :ddd], @config.state[:rollback] - assert_nil @config.rollback_requests - assert @config.task_call_frames.empty? - end - - def test_exception_during_rollback_should_simply_be_logged_and_ignored - aaa = new_task(@config, :aaa) { on_rollback { state[:aaa] = true; raise LoadError, "ouch" }; execute_task(bbb) } - bbb = new_task(@config, :bbb) { raise MadError, "boom" } - ccc = new_task(@config, :ccc) { transaction { execute_task(aaa) } } - assert_raises(NameError) do - @config.execute_task(ccc) - end - assert @config.state[:aaa] - end - - def test_on_rollback_called_twice_should_result_in_last_rollback_block_being_effective - aaa = new_task(@config, :aaa) do - transaction do - on_rollback { (state[:rollback] ||= []) << :first } - on_rollback { (state[:rollback] ||= []) << :second } - raise "boom" - end - end - - assert_raises(RuntimeError) do - @config.execute_task(aaa) - end - - assert_equal [:second], @config.state[:rollback] - end - - def test_find_and_execute_task_should_raise_error_when_task_cannot_be_found - @config.expects(:find_task).with("path:to:task").returns(nil) - assert_raises(Capistrano::NoSuchTaskError) { @config.find_and_execute_task("path:to:task") } - end - - def test_find_and_execute_task_should_execute_task_when_task_is_found - @config.expects(:find_task).with("path:to:task").returns(:found) - @config.expects(:execute_task).with(:found) - assert_nothing_raised { @config.find_and_execute_task("path:to:task") } - end - - def test_find_and_execute_task_with_before_option_should_trigger_callback - @config.expects(:find_task).with("path:to:task").returns(:found) - @config.expects(:trigger).with(:incoming, :found) - @config.expects(:execute_task).with(:found) - @config.find_and_execute_task("path:to:task", :before => :incoming) - end - - def test_find_and_execute_task_with_after_option_should_trigger_callback - @config.expects(:find_task).with("path:to:task").returns(:found) - @config.expects(:trigger).with(:outgoing, :found) - @config.expects(:execute_task).with(:found) - @config.find_and_execute_task("path:to:task", :after => :outgoing) - end - - private - - def stack_inspector - Proc.new do - (state[:trail] ||= []) << current_task.fully_qualified_name - data = state[current_task.name] = {} - data[:stack] = task_call_frames.map { |frame| frame.task.fully_qualified_name } - data[:history] = rollback_requests && rollback_requests.map { |frame| frame.task.fully_qualified_name } - end - end - - def new_task(namespace, name, options={}, &block) - block ||= stack_inspector - namespace.tasks[name] = Capistrano::TaskDefinition.new(name, namespace, &block) - end -end \ No newline at end of file diff --git a/vendor/gems/capistrano-2.5.9/test/configuration/loading_test.rb b/vendor/gems/capistrano-2.5.9/test/configuration/loading_test.rb deleted file mode 100644 index eb4e2e4bf..000000000 --- a/vendor/gems/capistrano-2.5.9/test/configuration/loading_test.rb +++ /dev/null @@ -1,132 +0,0 @@ -require "utils" -require 'capistrano/configuration/loading' - -class ConfigurationLoadingTest < Test::Unit::TestCase - class MockConfig - attr_accessor :ping - attr_reader :original_initialize_called - - def initialize - @original_initialize_called = true - end - - def ping!(value) - @ping = value - end - - include Capistrano::Configuration::Loading - end - - def setup - @config = MockConfig.new - end - - def teardown - MockConfig.instance = nil - $LOADED_FEATURES.delete_if { |a| a =~ /fixtures\/custom\.rb$/ } - end - - def test_initialize_should_init_collections - assert @config.original_initialize_called - assert @config.load_paths.include?(".") - assert @config.load_paths.detect { |v| v =~ /capistrano\/recipes$/ } - end - - def test_load_with_options_and_block_should_raise_argument_error - assert_raises(ArgumentError) do - @config.load(:string => "foo") { something } - end - end - - def test_load_with_arguments_and_block_should_raise_argument_error - assert_raises(ArgumentError) do - @config.load("foo") { something } - end - end - - def test_load_from_string_should_eval_in_config_scope - @config.load :string => "ping! :here" - assert_equal :here, @config.ping - end - - def test_load_from_file_shoudld_respect_load_path - File.stubs(:file?).returns(false) - File.stubs(:file?).with("custom/path/for/file.rb").returns(true) - File.stubs(:read).with("custom/path/for/file.rb").returns("ping! :here") - - @config.load_paths << "custom/path/for" - @config.load :file => "file.rb" - - assert_equal :here, @config.ping - end - - def test_load_from_file_should_respect_load_path_and_appends_rb - File.stubs(:file?).returns(false) - File.stubs(:file?).with("custom/path/for/file.rb").returns(true) - File.stubs(:read).with("custom/path/for/file.rb").returns("ping! :here") - - @config.load_paths << "custom/path/for" - @config.load :file => "file" - - assert_equal :here, @config.ping - end - - def test_load_from_file_should_raise_load_error_if_file_cannot_be_found - File.stubs(:file?).returns(false) - assert_raises(LoadError) do - @config.load :file => "file" - end - end - - def test_load_from_proc_should_eval_proc_in_config_scope - @config.load :proc => Proc.new { ping! :here } - assert_equal :here, @config.ping - end - - def test_load_with_block_should_treat_block_as_proc_parameter - @config.load { ping! :here } - assert_equal :here, @config.ping - end - - def test_load_with_unrecognized_option_should_raise_argument_error - assert_raises(ArgumentError) do - @config.load :url => "http://www.load-this.test" - end - end - - def test_load_with_arguments_should_treat_arguments_as_files - File.stubs(:file?).returns(false) - File.stubs(:file?).with("./first.rb").returns(true) - File.stubs(:file?).with("./second.rb").returns(true) - File.stubs(:read).with("./first.rb").returns("ping! 'this'") - File.stubs(:read).with("./second.rb").returns("ping << 'that'") - assert_nothing_raised { @config.load "first", "second" } - assert_equal "thisthat", @config.ping - end - - def test_require_from_config_should_load_file_in_config_scope - assert_nothing_raised do - @config.require "#{File.dirname(__FILE__)}/../fixtures/custom" - end - assert_equal :custom, @config.ping - end - - def test_require_without_config_should_raise_load_error - assert_raises(LoadError) do - require "#{File.dirname(__FILE__)}/../fixtures/custom" - end - end - - def test_require_from_config_should_return_false_when_called_a_second_time_with_same_args - assert @config.require("#{File.dirname(__FILE__)}/../fixtures/custom") - assert_equal false, @config.require("#{File.dirname(__FILE__)}/../fixtures/custom") - end - - def test_require_in_multiple_instances_should_load_recipes_in_each_instance - config2 = MockConfig.new - @config.require "#{File.dirname(__FILE__)}/../fixtures/custom" - config2.require "#{File.dirname(__FILE__)}/../fixtures/custom" - assert_equal :custom, @config.ping - assert_equal :custom, config2.ping - end -end diff --git a/vendor/gems/capistrano-2.5.9/test/configuration/namespace_dsl_test.rb b/vendor/gems/capistrano-2.5.9/test/configuration/namespace_dsl_test.rb deleted file mode 100644 index 1a5e2eb8b..000000000 --- a/vendor/gems/capistrano-2.5.9/test/configuration/namespace_dsl_test.rb +++ /dev/null @@ -1,311 +0,0 @@ -require "utils" -require 'capistrano/configuration/namespaces' - -class ConfigurationNamespacesDSLTest < Test::Unit::TestCase - class MockConfig - attr_reader :original_initialize_called, :options - - def initialize - @original_initialize_called = true - @options = {} - end - - include Capistrano::Configuration::Namespaces - end - - def setup - @config = MockConfig.new - end - - def test_initialize_should_initialize_collections - assert @config.original_initialize_called - assert @config.tasks.empty? - assert @config.namespaces.empty? - end - - def test_unqualified_task_should_define_task_at_top_namespace - assert !@config.tasks.key?(:testing) - @config.task(:testing) { puts "something" } - assert @config.tasks.key?(:testing) - end - - def test_qualification_should_define_task_within_namespace - @config.namespace(:testing) do - task(:nested) { puts "nested" } - end - - assert !@config.tasks.key?(:nested) - assert @config.namespaces.key?(:testing) - assert @config.namespaces[:testing].tasks.key?(:nested) - end - - def test_namespace_within_namespace_should_define_task_within_nested_namespace - @config.namespace :outer do - namespace :inner do - task :nested do - puts "nested" - end - end - end - - assert !@config.tasks.key?(:nested) - assert @config.namespaces.key?(:outer) - assert @config.namespaces[:outer].namespaces.key?(:inner) - assert @config.namespaces[:outer].namespaces[:inner].tasks.key?(:nested) - end - - def test_pending_desc_should_apply_only_to_immediately_subsequent_task - @config.desc "A description" - @config.task(:testing) { puts "foo" } - @config.task(:another) { puts "bar" } - assert_equal "A description", @config.tasks[:testing].desc - assert_nil @config.tasks[:another].desc - end - - def test_pending_desc_should_apply_only_to_next_task_in_any_namespace - @config.desc "A description" - @config.namespace(:outer) { task(:testing) { puts "foo" } } - assert_equal "A description", @config.namespaces[:outer].tasks[:testing].desc - end - - def test_defining_task_without_block_should_raise_error - assert_raises(ArgumentError) do - @config.task(:testing) - end - end - - def test_defining_task_that_shadows_existing_method_should_raise_error - assert_raises(ArgumentError) do - @config.task(:sprintf) { puts "foo" } - end - end - - def test_defining_task_that_shadows_existing_namespace_should_raise_error - @config.namespace(:outer) {} - assert_raises(ArgumentError) do - @config.task(:outer) { puts "foo" } - end - end - - def test_defining_namespace_that_shadows_existing_method_should_raise_error - assert_raises(ArgumentError) do - @config.namespace(:sprintf) {} - end - end - - def test_defining_namespace_that_shadows_existing_task_should_raise_error - @config.task(:testing) { puts "foo" } - assert_raises(ArgumentError) do - @config.namespace(:testing) {} - end - end - - def test_defining_task_that_shadows_existing_task_should_not_raise_error - @config.task(:original) { puts "foo" } - assert_nothing_raised do - @config.task(:original) { puts "bar" } - end - end - - def test_defining_ask_should_add_task_as_method - assert !@config.methods.any? { |m| m.to_sym == :original } - @config.task(:original) { puts "foo" } - assert @config.methods.any? { |m| m.to_sym == :original } - end - - def test_calling_defined_task_should_delegate_to_execute_task - @config.task(:original) { puts "foo" } - @config.expects(:execute_task).with(@config.tasks[:original]) - @config.original - end - - def test_role_inside_namespace_should_raise_error - assert_raises(NotImplementedError) do - @config.namespace(:outer) do - role :app, "hello" - end - end - end - - def test_name_for_top_level_should_be_nil - assert_nil @config.name - end - - def test_parent_for_top_level_should_be_nil - assert_nil @config.parent - end - - def test_fqn_for_top_level_should_be_nil - assert_nil @config.fully_qualified_name - end - - def test_fqn_for_namespace_should_be_the_name_of_the_namespace - @config.namespace(:outer) {} - assert_equal "outer", @config.namespaces[:outer].fully_qualified_name - end - - def test_parent_for_namespace_should_be_the_top_level - @config.namespace(:outer) {} - assert_equal @config, @config.namespaces[:outer].parent - end - - def test_fqn_for_nested_namespace_should_be_color_delimited - @config.namespace(:outer) { namespace(:inner) {} } - assert_equal "outer:inner", @config.namespaces[:outer].namespaces[:inner].fully_qualified_name - end - - def test_parent_for_nested_namespace_should_be_the_nesting_namespace - @config.namespace(:outer) { namespace(:inner) {} } - assert_equal @config.namespaces[:outer], @config.namespaces[:outer].namespaces[:inner].parent - end - - def test_find_task_should_dereference_nested_tasks - @config.namespace(:outer) do - namespace(:inner) { task(:nested) { puts "nested" } } - end - - task = @config.find_task("outer:inner:nested") - assert_not_nil task - assert_equal "outer:inner:nested", task.fully_qualified_name - end - - def test_find_task_should_return_nil_if_no_task_matches - assert_nil @config.find_task("outer:inner:nested") - end - - def test_find_task_should_return_default_if_deferences_to_namespace_and_namespace_has_default - @config.namespace(:outer) do - namespace(:inner) { task(:default) { puts "nested" } } - end - - task = @config.find_task("outer:inner") - assert_not_nil task - assert_equal :default, task.name - assert_equal "outer:inner", task.namespace.fully_qualified_name - end - - def test_find_task_should_return_nil_if_deferences_to_namespace_and_namespace_has_no_default - @config.namespace(:outer) do - namespace(:inner) { task(:nested) { puts "nested" } } - end - - assert_nil @config.find_task("outer:inner") - end - - def test_default_task_should_return_nil_for_top_level - @config.task(:default) {} - assert_nil @config.default_task - end - - def test_default_task_should_return_nil_for_namespace_without_default - @config.namespace(:outer) { task(:nested) { puts "nested" } } - assert_nil @config.namespaces[:outer].default_task - end - - def test_default_task_should_return_task_for_namespace_with_default - @config.namespace(:outer) { task(:default) { puts "nested" } } - task = @config.namespaces[:outer].default_task - assert_not_nil task - assert_equal :default, task.name - end - - def test_task_list_should_return_only_tasks_immediately_within_namespace - @config.task(:first) { puts "here" } - @config.namespace(:outer) do - task(:second) { puts "here" } - namespace(:inner) do - task(:third) { puts "here" } - end - end - - assert_equal %w(first), @config.task_list.map { |t| t.fully_qualified_name } - end - - def test_task_list_with_all_should_return_all_tasks_under_this_namespace_recursively - @config.task(:first) { puts "here" } - @config.namespace(:outer) do - task(:second) { puts "here" } - namespace(:inner) do - task(:third) { puts "here" } - end - end - - assert_equal %w(first outer:inner:third outer:second), @config.task_list(:all).map { |t| t.fully_qualified_name }.sort - end - - def test_namespace_should_respond_to_its_parents_methods - @config.namespace(:outer) {} - ns = @config.namespaces[:outer] - assert ns.respond_to?(:original_initialize_called) - end - - def test_namespace_should_accept_respond_to_with_include_priv_parameter - @config.namespace(:outer) {} - ns = @config.namespaces[:outer] - assert ns.respond_to?(:original_initialize_called, true) - end - - def test_namespace_should_delegate_unknown_messages_to_its_parent - @config.namespace(:outer) {} - ns = @config.namespaces[:outer] - assert ns.original_initialize_called - end - - def test_namespace_should_not_understand_messages_that_neither_it_nor_its_parent_understands - @config.namespace(:outer) {} - ns = @config.namespaces[:outer] - assert_raises(NoMethodError) { ns.alskdfjlsf } - end - - def test_search_task_should_find_tasks_in_current_namespace - @config.namespace(:outer) do - namespace(:inner) do - task(:third) { puts "here" } - end - end - - inner = @config.namespaces[:outer].namespaces[:inner] - assert_equal inner.tasks[:third], inner.search_task(:third) - end - - def test_search_task_should_find_tasks_in_parent_namespace - @config.task(:first) { puts "here" } - @config.namespace(:outer) do - task(:second) { puts "here" } - namespace(:inner) do - task(:third) { puts "here" } - end - end - - inner = @config.namespaces[:outer].namespaces[:inner] - assert_equal @config.tasks[:first], inner.search_task(:first) - end - - def test_search_task_should_return_nil_if_no_tasks_are_found - @config.namespace(:outer) { namespace(:inner) {} } - inner = @config.namespaces[:outer].namespaces[:inner] - assert_nil inner.search_task(:first) - end - - def test_top_should_return_self_if_self_is_top - assert_equal @config, @config.top - end - - def test_top_should_return_parent_if_parent_is_top - @config.namespace(:outer) {} - assert_equal @config, @config.namespaces[:outer].top - end - - def test_top_should_return_topmost_parent_if_self_is_deeply_nested - @config.namespace(:outer) { namespace(:middle) { namespace(:inner) {} } } - assert_equal @config, @config.namespaces[:outer].namespaces[:middle].namespaces[:inner].top - end - - def test_find_task_should_return_nil_when_empty_inner_task - @config.namespace :outer do - namespace :inner do - end - end - assert_nil @config.find_task("outer::inner") - end -end \ No newline at end of file diff --git a/vendor/gems/capistrano-2.5.9/test/configuration/roles_test.rb b/vendor/gems/capistrano-2.5.9/test/configuration/roles_test.rb deleted file mode 100644 index 643a7e9c8..000000000 --- a/vendor/gems/capistrano-2.5.9/test/configuration/roles_test.rb +++ /dev/null @@ -1,144 +0,0 @@ -require "utils" -require 'capistrano/configuration/roles' -require 'capistrano/server_definition' - -class ConfigurationRolesTest < Test::Unit::TestCase - class MockConfig - attr_reader :original_initialize_called - - def initialize - @original_initialize_called = true - end - - include Capistrano::Configuration::Roles - end - - def setup - @config = MockConfig.new - end - - def test_initialize_should_initialize_roles_collection - assert @config.original_initialize_called - assert @config.roles.empty? - end - - def test_role_should_allow_empty_list - @config.role :app - assert @config.roles.keys.include?(:app) - assert @config.roles[:app].empty? - end - - def test_role_with_one_argument_should_add_to_roles_collection - @config.role :app, "app1.capistrano.test" - assert_equal [:app], @config.roles.keys - assert_role_equals %w(app1.capistrano.test) - end - - def test_role_block_returning_single_string_is_added_to_roles_collection - @config.role :app do - 'app1.capistrano.test' - end - assert_role_equals %w(app1.capistrano.test) - end - - def test_role_with_multiple_arguments_should_add_each_to_roles_collection - @config.role :app, "app1.capistrano.test", "app2.capistrano.test" - assert_equal [:app], @config.roles.keys - assert_role_equals %w(app1.capistrano.test app2.capistrano.test) - end - - def test_role_with_block_and_strings_should_add_both_to_roles_collection - @config.role :app, 'app1.capistrano.test' do - 'app2.capistrano.test' - end - assert_role_equals %w(app1.capistrano.test app2.capistrano.test) - end - - def test_role_block_returning_array_should_add_each_to_roles_collection - @config.role :app do - ['app1.capistrano.test', 'app2.capistrano.test'] - end - assert_role_equals %w(app1.capistrano.test app2.capistrano.test) - end - - def test_role_with_options_should_apply_options_to_each_argument - @config.role :app, "app1.capistrano.test", "app2.capistrano.test", :extra => :value - @config.roles[:app].each do |server| - assert_equal({:extra => :value}, server.options) - end - end - - def test_role_with_options_should_apply_options_to_block_results - @config.role :app, :extra => :value do - ['app1.capistrano.test', 'app2.capistrano.test'] - end - @config.roles[:app].each do |server| - assert_equal({:extra => :value}, server.options) - end - end - - def test_options_should_apply_only_to_this_argument_set - @config.role :app, 'app1.capistrano.test', 'app2.capistrano.test' do - ['app3.capistrano.test', 'app4.capistrano.test'] - end - @config.role :app, 'app5.capistrano.test', 'app6.capistrano.test', :extra => :value do - ['app7.capistrano.test', 'app8.capistrano.test'] - end - @config.role :app, 'app9.capistrano.test' - - option_hosts = ['app5.capistrano.test', 'app6.capistrano.test', 'app7.capistrano.test', 'app8.capistrano.test'] - @config.roles[:app].each do |server| - if (option_hosts.include? server.host) - assert_equal({:extra => :value}, server.options) - else - assert_not_equal({:extra => :value}, server.options) - end - end - end - - # Here, the source should be more readable than the method name - def test_role_block_returns_options_hash_is_merged_with_role_options_argument - @config.role :app, :first => :one, :second => :two do - ['app1.capistrano.test', 'app2.capistrano.test', {:second => :please, :third => :three}] - end - @config.roles[:app].each do |server| - assert_equal({:first => :one, :second => :please, :third => :three}, server.options) - end - end - - def test_role_block_can_override_role_options_argument - @config.role :app, :value => :wrong do - Capistrano::ServerDefinition.new('app.capistrano.test') - end - @config.roles[:app].servers - @config.roles[:app].servers.each do |server| - assert_not_equal({:value => :wrong}, server.options) - end - end - - def test_role_block_can_return_nil - @config.role :app do - nil - end - assert_role_equals ([]) - end - - def test_role_block_can_return_empty_array - @config.role :app do - [] - end - assert_role_equals ([]) - end - - def test_role_definitions_via_server_should_associate_server_with_roles - @config.server "www.capistrano.test", :web, :app - assert_equal %w(www.capistrano.test), @config.roles[:app].map { |s| s.host } - assert_equal %w(www.capistrano.test), @config.roles[:web].map { |s| s.host } - end - - private - - def assert_role_equals(list) - assert_equal list, @config.roles[:app].map { |s| s.host } - end -end diff --git a/vendor/gems/capistrano-2.5.9/test/configuration/servers_test.rb b/vendor/gems/capistrano-2.5.9/test/configuration/servers_test.rb deleted file mode 100644 index 020550225..000000000 --- a/vendor/gems/capistrano-2.5.9/test/configuration/servers_test.rb +++ /dev/null @@ -1,129 +0,0 @@ -require "utils" -require 'capistrano/task_definition' -require 'capistrano/configuration/servers' - -class ConfigurationServersTest < Test::Unit::TestCase - class MockConfig - attr_reader :roles - - def initialize - @roles = {} - end - - include Capistrano::Configuration::Servers - end - - def setup - @config = MockConfig.new - role(@config, :app, "app1", :primary => true) - role(@config, :app, "app2", "app3") - role(@config, :web, "web1", "web2") - role(@config, :report, "app2", :no_deploy => true) - role(@config, :file, "file", :no_deploy => true) - end - - def test_task_without_roles_should_apply_to_all_defined_hosts - task = new_task(:testing) - assert_equal %w(app1 app2 app3 web1 web2 file).sort, @config.find_servers_for_task(task).map { |s| s.host }.sort - end - - def test_task_with_explicit_role_list_should_apply_only_to_those_roles - task = new_task(:testing, @config, :roles => %w(app web)) - assert_equal %w(app1 app2 app3 web1 web2).sort, @config.find_servers_for_task(task).map { |s| s.host }.sort - end - - def test_task_with_single_role_should_apply_only_to_that_role - task = new_task(:testing, @config, :roles => :web) - assert_equal %w(web1 web2).sort, @config.find_servers_for_task(task).map { |s| s.host }.sort - end - - def test_task_with_unknown_role_should_raise_exception - task = new_task(:testing, @config, :roles => :bogus) - assert_raises(ArgumentError) do - @config.find_servers_for_task(task) - end - end - - def test_task_with_hosts_option_should_apply_only_to_those_hosts - task = new_task(:testing, @config, :hosts => %w(foo bar)) - assert_equal %w(foo bar).sort, @config.find_servers_for_task(task).map { |s| s.host }.sort - end - - def test_task_with_single_hosts_option_should_apply_only_to_that_host - task = new_task(:testing, @config, :hosts => "foo") - assert_equal %w(foo).sort, @config.find_servers_for_task(task).map { |s| s.host }.sort - end - - def test_task_with_roles_as_environment_variable_should_apply_only_to_that_role - ENV['ROLES'] = "app,file" - task = new_task(:testing) - assert_equal %w(app1 app2 app3 file).sort, @config.find_servers_for_task(task).map { |s| s.host }.sort - ensure - ENV.delete('ROLES') - end - - def test_task_with_hosts_as_environment_variable_should_apply_only_to_those_hosts - ENV['HOSTS'] = "foo,bar" - task = new_task(:testing) - assert_equal %w(foo bar).sort, @config.find_servers_for_task(task).map { |s| s.host }.sort - ensure - ENV.delete('HOSTS') - end - - def test_task_with_hosts_as_environment_variable_should_not_inspect_roles_at_all - ENV['HOSTS'] = "foo,bar" - task = new_task(:testing, @config, :roles => :bogus) - assert_equal %w(foo bar).sort, @config.find_servers_for_task(task).map { |s| s.host }.sort - ensure - ENV.delete('HOSTS') - end - - def test_task_with_hostfilter_environment_variable_should_apply_only_to_those_hosts - ENV['HOSTFILTER'] = "app1,web1" - task = new_task(:testing) - assert_equal %w(app1 web1).sort, @config.find_servers_for_task(task).map { |s| s.host }.sort - ensure - ENV.delete('HOSTFILTER') - end - - def test_task_with_hostfilter_environment_variable_should_filter_hosts_option - ENV['HOSTFILTER'] = "foo" - task = new_task(:testing, @config, :hosts => %w(foo bar)) - assert_equal %w(foo).sort, @config.find_servers_for_task(task).map { |s| s.host }.sort - ensure - ENV.delete('HOSTFILTER') - end - - def test_task_with_hostfilter_environment_variable_and_skip_hostfilter_should_not_filter_hosts_option - ENV['HOSTFILTER'] = "foo" - task = new_task(:testing, @config, :hosts => %w(foo bar), :skip_hostfilter => true) - assert_equal %w(foo bar).sort, @config.find_servers_for_task(task).map { |s| s.host }.sort - ensure - ENV.delete('HOSTFILTER') - end - - def test_task_with_only_should_apply_only_to_matching_tasks - task = new_task(:testing, @config, :roles => :app, :only => { :primary => true }) - assert_equal %w(app1), @config.find_servers_for_task(task).map { |s| s.host } - end - - def test_task_with_except_should_apply_only_to_matching_tasks - task = new_task(:testing, @config, :except => { :no_deploy => true }) - assert_equal %w(app1 app2 app3 web1 web2).sort, @config.find_servers_for_task(task).map { |s| s.host }.sort - end - - def test_options_to_find_servers_for_task_should_override_options_in_task - task = new_task(:testing, @config, :roles => :web) - assert_equal %w(app1 app2 app3).sort, @config.find_servers_for_task(task, :roles => :app).map { |s| s.host }.sort - end - - def test_find_servers_with_lambda_for_hosts_should_be_evaluated - assert_equal %w(foo), @config.find_servers(:hosts => lambda { "foo" }).map { |s| s.host }.sort - assert_equal %w(bar foo), @config.find_servers(:hosts => lambda { %w(foo bar) }).map { |s| s.host }.sort - end - - def test_find_servers_with_lambda_for_roles_should_be_evaluated - assert_equal %w(app1 app2 app3), @config.find_servers(:roles => lambda { :app }).map { |s| s.host }.sort - assert_equal %w(app2 file), @config.find_servers(:roles => lambda { [:report, :file] }).map { |s| s.host }.sort - end -end \ No newline at end of file diff --git a/vendor/gems/capistrano-2.5.9/test/configuration/variables_test.rb b/vendor/gems/capistrano-2.5.9/test/configuration/variables_test.rb deleted file mode 100644 index 2c68b3800..000000000 --- a/vendor/gems/capistrano-2.5.9/test/configuration/variables_test.rb +++ /dev/null @@ -1,184 +0,0 @@ -require "utils" -require 'capistrano/configuration/variables' - -class ConfigurationVariablesTest < Test::Unit::TestCase - class MockConfig - attr_reader :original_initialize_called - - def initialize - @original_initialize_called = true - end - - include Capistrano::Configuration::Variables - end - - def setup - MockConfig.any_instance.stubs(:logger).returns(stub_everything) - @config = MockConfig.new - end - - def test_initialize_should_initialize_variables_hash - assert @config.original_initialize_called - assert_equal({:ssh_options => {}, :logger => @config.logger}, @config.variables) - end - - def test_set_should_add_variable_to_hash - @config.set :sample, :value - assert_equal :value, @config.variables[:sample] - end - - def test_set_should_convert_variable_name_to_symbol - @config.set "sample", :value - assert_equal :value, @config.variables[:sample] - end - - def test_set_should_be_aliased_to_square_brackets - @config[:sample] = :value - assert_equal :value, @config.variables[:sample] - end - - def test_variables_should_be_accessible_as_read_accessors - @config[:sample] = :value - assert_equal :value, @config.sample - end - - def test_method_missing_should_raise_error_if_no_variable_matches - assert_raises(NoMethodError) do - @config.sample - end - end - - def test_respond_to_should_look_for_variables - assert !@config.respond_to?(:sample) - @config[:sample] = :value - assert @config.respond_to?(:sample) - end - - def test_respond_to_with_include_priv_paramter - assert !@config.respond_to?(:sample, true) - end - - def test_set_should_require_value - assert_raises(ArgumentError) do - @config.set(:sample) - end - end - - def test_set_should_allow_value_to_be_omitted_if_block_is_given - assert_nothing_raised do - @config.set(:sample) { :value } - end - assert_instance_of Proc, @config.variables[:sample] - end - - def test_set_should_not_allow_multiple_values - assert_raises(ArgumentError) do - @config.set(:sample, :value, :another) - end - end - - def test_set_should_not_allow_both_a_value_and_a_block - assert_raises(ArgumentError) do - @config.set(:sample, :value) { :block } - end - end - - def test_set_should_not_allow_capitalized_variables - assert_raises(ArgumentError) do - @config.set :Sample, :value - end - end - - def test_unset_should_remove_variable_from_hash - @config.set :sample, :value - assert @config.variables.key?(:sample) - @config.unset :sample - assert !@config.variables.key?(:sample) - end - - def test_unset_should_clear_memory_of_original_proc - @config.set(:sample) { :value } - @config.fetch(:sample) - @config.unset(:sample) - assert_equal false, @config.reset!(:sample) - end - - def test_exists_should_report_existance_of_variable_in_hash - assert !@config.exists?(:sample) - @config[:sample] = :value - assert @config.exists?(:sample) - end - - def test_reset_should_do_nothing_if_variable_does_not_exist - assert_equal false, @config.reset!(:sample) - assert !@config.variables.key?(:sample) - end - - def test_reset_should_do_nothing_if_variable_is_not_a_proc - @config.set(:sample, :value) - assert_equal false, @config.reset!(:sample) - assert_equal :value, @config.variables[:sample] - end - - def test_reset_should_do_nothing_if_proc_variable_has_not_been_dereferenced - @config.set(:sample) { :value } - assert_equal false, @config.reset!(:sample) - assert_instance_of Proc, @config.variables[:sample] - end - - def test_reset_should_restore_variable_to_original_proc_value - @config.set(:sample) { :value } - assert_instance_of Proc, @config.variables[:sample] - @config.fetch(:sample) - assert_instance_of Symbol, @config.variables[:sample] - assert @config.reset!(:sample) - assert_instance_of Proc, @config.variables[:sample] - end - - def test_fetch_should_return_stored_non_proc_value - @config.set(:sample, :value) - assert_equal :value, @config.fetch(:sample) - end - - def test_fetch_should_raise_index_error_if_variable_does_not_exist - assert_raises(IndexError) do - @config.fetch(:sample) - end - end - - def test_fetch_should_return_default_if_variable_does_not_exist_and_default_is_given - assert_nothing_raised do - assert_equal :default_value, @config.fetch(:sample, :default_value) - end - end - - def test_fetch_should_invoke_block_if_variable_does_not_exist_and_block_is_given - assert_nothing_raised do - assert_equal :default_value, @config.fetch(:sample) { :default_value } - end - end - - def test_fetch_should_raise_argument_error_if_both_default_and_block_are_given - assert_raises(ArgumentError) do - @config.fetch(:sample, :default1) { :default2 } - end - end - - def test_fetch_should_dereference_proc_values - @config.set(:sample) { :value } - assert_instance_of Proc, @config.variables[:sample] - assert_equal :value, @config.fetch(:sample) - assert_instance_of Symbol, @config.variables[:sample] - end - - def test_square_brackets_should_alias_fetch - @config.set(:sample, :value) - assert_equal :value, @config[:sample] - end - - def test_square_brackets_should_return_nil_for_non_existant_variable - assert_nothing_raised do - assert_nil @config[:sample] - end - end -end \ No newline at end of file diff --git a/vendor/gems/capistrano-2.5.9/test/configuration_test.rb b/vendor/gems/capistrano-2.5.9/test/configuration_test.rb deleted file mode 100644 index d0f88acfe..000000000 --- a/vendor/gems/capistrano-2.5.9/test/configuration_test.rb +++ /dev/null @@ -1,88 +0,0 @@ -require "utils" -require 'capistrano/configuration' - -# These tests are only for testing the integration of the various components -# of the Configuration class. To test specific features, please look at the -# tests under test/configuration. - -class ConfigurationTest < Test::Unit::TestCase - def setup - @config = Capistrano::Configuration.new - end - - def test_connections_execution_loading_namespaces_roles_and_variables_modules_should_integrate_correctly - Capistrano::SSH.expects(:connect).with { |s,c| s.host == "www.capistrano.test" && c == @config }.returns(:session) - - process_args = Proc.new do |tree, session, opts| - tree.fallback.command == "echo 'hello world'" && - session == [:session] && - opts == { :logger => @config.logger } - end - - Capistrano::Command.expects(:process).with(&process_args) - - @config.load do - role :test, "www.capistrano.test" - set :message, "hello world" - namespace :testing do - task :example, :roles => :test do - run "echo '#{message}'" - end - end - end - - @config.testing.example - end - - def test_tasks_in_nested_namespace_should_be_able_to_call_tasks_in_same_namespace - @config.namespace(:outer) do - task(:first) { set :called_first, true } - namespace(:inner) do - task(:first) { set :called_inner_first, true } - task(:second) { first } - end - end - - @config.outer.inner.second - assert !@config[:called_first] - assert @config[:called_inner_first] - end - - def test_tasks_in_nested_namespace_should_be_able_to_call_tasks_in_parent_namespace - @config.namespace(:outer) do - task(:first) { set :called_first, true } - namespace(:inner) do - task(:second) { first } - end - end - - @config.outer.inner.second - assert @config[:called_first] - end - - def test_tasks_in_nested_namespace_should_be_able_to_call_shadowed_tasks_in_parent_namespace - @config.namespace(:outer) do - task(:first) { set :called_first, true } - namespace(:inner) do - task(:first) { set :called_inner_first, true } - task(:second) { parent.first } - end - end - - @config.outer.inner.second - assert @config[:called_first] - assert !@config[:called_inner_first] - end - - def test_hooks_for_default_task_should_be_found_if_named_after_the_namespace - @config.namespace(:outer) do - task(:default) { set :called_default, true } - task(:before_outer) { set :called_before_outer, true } - task(:after_outer) { set :called_after_outer, true } - end - @config.outer.default - assert @config[:called_before_outer] - assert @config[:called_default] - assert @config[:called_after_outer] - end -end diff --git a/vendor/gems/capistrano-2.5.9/test/deploy/local_dependency_test.rb b/vendor/gems/capistrano-2.5.9/test/deploy/local_dependency_test.rb deleted file mode 100644 index c084fb8a1..000000000 --- a/vendor/gems/capistrano-2.5.9/test/deploy/local_dependency_test.rb +++ /dev/null @@ -1,76 +0,0 @@ -require "utils" -require 'capistrano/recipes/deploy/local_dependency' - -class LocalDependencyTest < Test::Unit::TestCase - def setup - @config = { } - @dependency = Capistrano::Deploy::LocalDependency.new(@config) - end - - def test_should_use_standard_error_message - setup_for_one_path_entry(false) - @dependency.command("cat") - assert_equal "`cat' could not be found in the path on the local host", @dependency.message - end - - def test_should_use_alternative_message_if_provided - setup_for_one_path_entry(false) - @dependency.command("cat").or("Sorry") - assert_equal "Sorry", @dependency.message - end - - def test_env_with_no_path_should_never_find_command - ENV.expects(:[]).with("PATH").returns(nil) - assert !@dependency.command("cat").pass? - end - - def test_env_with_one_path_entry_should_fail_if_command_not_found - setup_for_one_path_entry(false) - assert !@dependency.command("cat").pass? - end - - def test_env_with_one_path_entry_should_pass_if_command_found - setup_for_one_path_entry(true) - assert @dependency.command("cat").pass? - end - - def test_env_with_three_path_entries_should_fail_if_command_not_found - setup_for_three_path_entries(false) - assert !@dependency.command("cat").pass? - end - - def test_env_with_three_path_entries_should_pass_if_command_found - setup_for_three_path_entries(true) - assert @dependency.command("cat").pass? - end - - def test_env_with_one_path_entry_on_windows_should_pass_if_command_found_with_extension - setup_for_one_path_entry_on_windows(true) - assert @dependency.command("cat").pass? - end - - private - - def setup_for_one_path_entry(command_found) - Capistrano::Deploy::LocalDependency.expects(:on_windows?).returns(false) - ENV.expects(:[]).with("PATH").returns("/bin") - File.expects(:executable?).with("/bin/cat").returns(command_found) - end - - def setup_for_three_path_entries(command_found) - Capistrano::Deploy::LocalDependency.expects(:on_windows?).returns(false) - path = %w(/bin /usr/bin /usr/local/bin).join(File::PATH_SEPARATOR) - ENV.expects(:[]).with("PATH").returns(path) - File.expects(:executable?).with("/usr/bin/cat").returns(command_found) - File.expects(:executable?).at_most(1).with("/bin/cat").returns(false) - File.expects(:executable?).at_most(1).with("/usr/local/bin/cat").returns(false) - end - - def setup_for_one_path_entry_on_windows(command_found) - Capistrano::Deploy::LocalDependency.expects(:on_windows?).returns(true) - ENV.expects(:[]).with("PATH").returns("/cygwin/bin") - File.stubs(:executable?).returns(false) - first_executable_extension = Capistrano::Deploy::LocalDependency.windows_executable_extensions.first - File.expects(:executable?).with("/cygwin/bin/cat#{first_executable_extension}").returns(command_found) - end -end diff --git a/vendor/gems/capistrano-2.5.9/test/deploy/remote_dependency_test.rb b/vendor/gems/capistrano-2.5.9/test/deploy/remote_dependency_test.rb deleted file mode 100644 index dabb9d5c9..000000000 --- a/vendor/gems/capistrano-2.5.9/test/deploy/remote_dependency_test.rb +++ /dev/null @@ -1,114 +0,0 @@ -require "utils" -require 'capistrano/recipes/deploy/remote_dependency' - -class RemoteDependencyTest < Test::Unit::TestCase - def setup - @config = { } - @dependency = Capistrano::Deploy::RemoteDependency.new(@config) - end - - def test_should_use_standard_error_message_for_directory - setup_for_a_configuration_run("test -d /data", false) - @dependency.directory("/data") - assert_equal "`/data' is not a directory (host)", @dependency.message - end - - def test_should_use_standard_error_message_for_file - setup_for_a_configuration_run("test -f /data/foo.txt", false) - @dependency.file("/data/foo.txt") - assert_equal "`/data/foo.txt' is not a file (host)", @dependency.message - end - - def test_should_use_standard_error_message_for_writable - setup_for_a_configuration_run("test -w /data/foo.txt", false) - @dependency.writable("/data/foo.txt") - assert_equal "`/data/foo.txt' is not writable (host)", @dependency.message - end - - def test_should_use_standard_error_message_for_command - setup_for_a_configuration_run("which cat", false) - @dependency.command("cat") - assert_equal "`cat' could not be found in the path (host)", @dependency.message - end - - def test_should_use_standard_error_message_for_gem - setup_for_a_configuration_gem_run("capistrano", "9.9", false) - @dependency.gem("capistrano", 9.9) - assert_equal "gem `capistrano' 9.9 could not be found (host)", @dependency.message - end - - def test_should_fail_if_directory_not_found - setup_for_a_configuration_run("test -d /data", false) - assert !@dependency.directory("/data").pass? - end - - def test_should_pass_if_directory_found - setup_for_a_configuration_run("test -d /data", true) - assert @dependency.directory("/data").pass? - end - - def test_should_fail_if_file_not_found - setup_for_a_configuration_run("test -f /data/foo.txt", false) - assert !@dependency.file("/data/foo.txt").pass? - end - - def test_should_pas_if_file_found - setup_for_a_configuration_run("test -f /data/foo.txt", true) - assert @dependency.file("/data/foo.txt").pass? - end - - def test_should_fail_if_writable_not_found - setup_for_a_configuration_run("test -w /data/foo.txt", false) - assert !@dependency.writable("/data/foo.txt").pass? - end - - def test_should_pass_if_writable_found - setup_for_a_configuration_run("test -w /data/foo.txt", true) - assert @dependency.writable("/data/foo.txt").pass? - end - - def test_should_fail_if_command_not_found - setup_for_a_configuration_run("which cat", false) - assert !@dependency.command("cat").pass? - end - - def test_should_pass_if_command_found - setup_for_a_configuration_run("which cat", true) - assert @dependency.command("cat").pass? - end - - def test_should_fail_if_gem_not_found - setup_for_a_configuration_gem_run("capistrano", "9.9", false) - assert !@dependency.gem("capistrano", 9.9).pass? - end - - def test_should_pass_if_gem_found - setup_for_a_configuration_gem_run("capistrano", "9.9", true) - assert @dependency.gem("capistrano", 9.9).pass? - end - - def test_should_use_alternative_message_if_provided - setup_for_a_configuration_run("which cat", false) - @dependency.command("cat").or("Sorry") - assert_equal "Sorry (host)", @dependency.message - end - - private - - def setup_for_a_configuration_run(command, passing) - expectation = @config.expects(:invoke_command).with(command, {}) - if passing - expectation.returns(true) - else - error = Capistrano::CommandError.new - error.expects(:hosts).returns(["host"]) - expectation.raises(error) - end - end - - def setup_for_a_configuration_gem_run(name, version, passing) - @config.expects(:fetch).with(:gem_command, "gem").returns("gem") - find_gem_cmd = "gem specification --version '#{version}' #{name} 2>&1 | awk 'BEGIN { s = 0 } /^name:/ { s = 1; exit }; END { if(s == 0) exit 1 }'" - setup_for_a_configuration_run(find_gem_cmd, passing) - end -end diff --git a/vendor/gems/capistrano-2.5.9/test/deploy/scm/accurev_test.rb b/vendor/gems/capistrano-2.5.9/test/deploy/scm/accurev_test.rb deleted file mode 100644 index 7ff6a8e2e..000000000 --- a/vendor/gems/capistrano-2.5.9/test/deploy/scm/accurev_test.rb +++ /dev/null @@ -1,23 +0,0 @@ -require "utils" -require 'capistrano/recipes/deploy/scm/accurev' - -class AccurevTest < Test::Unit::TestCase - include Capistrano::Deploy::SCM - - def test_internal_revision_to_s - assert_equal 'foo/1', Accurev::InternalRevision.new('foo', 1).to_s - assert_equal 'foo/highest', Accurev::InternalRevision.new('foo', 'highest').to_s - end - - def test_internal_revision_parse - revision = Accurev::InternalRevision.parse('foo') - assert_equal 'foo', revision.stream - assert_equal 'highest', revision.transaction_id - assert_equal 'foo/highest', revision.to_s - - revision = Accurev::InternalRevision.parse('foo/1') - assert_equal 'foo', revision.stream - assert_equal '1', revision.transaction_id - assert_equal 'foo/1', revision.to_s - end -end diff --git a/vendor/gems/capistrano-2.5.9/test/deploy/scm/base_test.rb b/vendor/gems/capistrano-2.5.9/test/deploy/scm/base_test.rb deleted file mode 100644 index a4431056b..000000000 --- a/vendor/gems/capistrano-2.5.9/test/deploy/scm/base_test.rb +++ /dev/null @@ -1,55 +0,0 @@ -require "utils" -require 'capistrano/recipes/deploy/scm/base' - -class DeploySCMBaseTest < Test::Unit::TestCase - class TestSCM < Capistrano::Deploy::SCM::Base - default_command "floopy" - end - - def setup - @config = { } - def @config.exists?(name); key?(name); end - - @source = TestSCM.new(@config) - end - - def test_command_should_default_to_default_command - assert_equal "floopy", @source.command - @source.local { assert_equal "floopy", @source.command } - end - - def test_command_should_use_scm_command_if_available - @config[:scm_command] = "/opt/local/bin/floopy" - assert_equal "/opt/local/bin/floopy", @source.command - end - - def test_command_should_use_scm_command_in_local_mode_if_local_scm_command_not_set - @config[:scm_command] = "/opt/local/bin/floopy" - @source.local { assert_equal "/opt/local/bin/floopy", @source.command } - end - - def test_command_should_use_local_scm_command_in_local_mode_if_local_scm_command_is_set - @config[:scm_command] = "/opt/local/bin/floopy" - @config[:local_scm_command] = "/usr/local/bin/floopy" - assert_equal "/opt/local/bin/floopy", @source.command - @source.local { assert_equal "/usr/local/bin/floopy", @source.command } - end - - def test_command_should_use_default_if_scm_command_is_default - @config[:scm_command] = :default - assert_equal "floopy", @source.command - end - - def test_command_should_use_default_in_local_mode_if_local_scm_command_is_default - @config[:scm_command] = "/foo/bar/floopy" - @config[:local_scm_command] = :default - @source.local { assert_equal "floopy", @source.command } - end - - def test_local_mode_proxy_should_treat_messages_as_being_in_local_mode - @config[:scm_command] = "/foo/bar/floopy" - @config[:local_scm_command] = :default - assert_equal "floopy", @source.local.command - assert_equal "/foo/bar/floopy", @source.command - end -end diff --git a/vendor/gems/capistrano-2.5.9/test/deploy/scm/git_test.rb b/vendor/gems/capistrano-2.5.9/test/deploy/scm/git_test.rb deleted file mode 100644 index fd6dc341e..000000000 --- a/vendor/gems/capistrano-2.5.9/test/deploy/scm/git_test.rb +++ /dev/null @@ -1,184 +0,0 @@ -require "utils" -require 'capistrano/recipes/deploy/scm/git' - -class DeploySCMGitTest < Test::Unit::TestCase - class TestSCM < Capistrano::Deploy::SCM::Git - default_command "git" - end - - def setup - @config = { :repository => "." } - def @config.exists?(name); key?(name); end - - @source = TestSCM.new(@config) - end - - def test_head - assert_equal "HEAD", @source.head - - # With :branch - @config[:branch] = "master" - assert_equal "master", @source.head - end - - def test_origin - assert_equal "origin", @source.origin - @config[:remote] = "username" - assert_equal "username", @source.origin - end - - def test_checkout - @config[:repository] = "git@somehost.com:project.git" - dest = "/var/www" - rev = 'c2d9e79' - assert_equal "git clone -q git@somehost.com:project.git /var/www && cd /var/www && git checkout -q -b deploy #{rev}", @source.checkout(rev, dest) - - # With :scm_command - git = "/opt/local/bin/git" - @config[:scm_command] = git - assert_equal "#{git} clone -q git@somehost.com:project.git /var/www && cd /var/www && #{git} checkout -q -b deploy #{rev}", @source.checkout(rev, dest) - - # with submodules - @config[:git_enable_submodules] = true - assert_equal "#{git} clone -q git@somehost.com:project.git /var/www && cd /var/www && #{git} checkout -q -b deploy #{rev} && #{git} submodule -q init && #{git} submodule -q sync && #{git} submodule -q update", @source.checkout(rev, dest) - end - - def test_checkout_with_verbose_should_not_use_q_switch - @config[:repository] = "git@somehost.com:project.git" - @config[:scm_verbose] = true - dest = "/var/www" - rev = 'c2d9e79' - assert_equal "git clone git@somehost.com:project.git /var/www && cd /var/www && git checkout -b deploy #{rev}", @source.checkout(rev, dest) - end - - def test_diff - assert_equal "git diff master", @source.diff('master') - assert_equal "git diff master..branch", @source.diff('master', 'branch') - end - - def test_log - assert_equal "git log master..", @source.log('master') - assert_equal "git log master..branch", @source.log('master', 'branch') - end - - def test_query_revision - revision = @source.query_revision('HEAD') do |o| - assert_equal "git ls-remote . HEAD", o - "d11006102c07c94e5d54dd0ee63dca825c93ed61\tHEAD" - end - assert_equal "d11006102c07c94e5d54dd0ee63dca825c93ed61", revision - end - - def test_query_revision_has_whitespace - revision = @source.query_revision('HEAD') do |o| - assert_equal "git ls-remote . HEAD", o - "d11006102c07c94e5d54dd0ee63dca825c93ed61\tHEAD\r" - end - assert_equal "d11006102c07c94e5d54dd0ee63dca825c93ed61", revision - end - - def test_query_revision_deprecation_error - assert_raise(ArgumentError) do - revision = @source.query_revision('origin/release') {} - end - end - - def test_command_should_be_backwards_compatible - # 1.x version of this module used ":git", not ":scm_command" - @config[:git] = "/srv/bin/git" - assert_equal "/srv/bin/git", @source.command - end - - def test_sync - dest = "/var/www" - rev = 'c2d9e79' - assert_equal "cd #{dest} && git fetch -q origin && git reset -q --hard #{rev} && git clean -q -d -x -f", @source.sync(rev, dest) - - # With :scm_command - git = "/opt/local/bin/git" - @config[:scm_command] = git - assert_equal "cd #{dest} && #{git} fetch -q origin && #{git} reset -q --hard #{rev} && #{git} clean -q -d -x -f", @source.sync(rev, dest) - - # with submodules - @config[:git_enable_submodules] = true - assert_equal "cd #{dest} && #{git} fetch -q origin && #{git} reset -q --hard #{rev} && #{git} submodule -q init && for mod in `#{git} submodule status | awk '{ print $2 }'`; do #{git} config -f .git/config submodule.${mod}.url `#{git} config -f .gitmodules --get submodule.${mod}.url` && echo Synced $mod; done && #{git} submodule -q sync && #{git} submodule -q update && #{git} clean -q -d -x -f", @source.sync(rev, dest) - end - - def test_sync_with_remote - dest = "/var/www" - rev = 'c2d9e79' - remote = "username" - repository = "git@somehost.com:project.git" - - @config[:repository] = repository - @config[:remote] = remote - - assert_equal "cd #{dest} && git config remote.#{remote}.url #{repository} && git config remote.#{remote}.fetch +refs/heads/*:refs/remotes/#{remote}/* && git fetch -q #{remote} && git reset -q --hard #{rev} && git clean -q -d -x -f", @source.sync(rev, dest) - end - - def test_shallow_clone - @config[:repository] = "git@somehost.com:project.git" - @config[:git_shallow_clone] = 1 - dest = "/var/www" - rev = 'c2d9e79' - assert_equal "git clone -q --depth 1 git@somehost.com:project.git /var/www && cd /var/www && git checkout -q -b deploy #{rev}", @source.checkout(rev, dest) - end - - def test_remote_clone - @config[:repository] = "git@somehost.com:project.git" - @config[:remote] = "username" - dest = "/var/www" - rev = 'c2d9e79' - assert_equal "git clone -q -o username git@somehost.com:project.git /var/www && cd /var/www && git checkout -q -b deploy #{rev}", @source.checkout(rev, dest) - end - - def test_remote_clone_with_submodules - @config[:repository] = "git@somehost.com:project.git" - @config[:remote] = "username" - @config[:git_enable_submodules] = true - dest = "/var/www" - rev = 'c2d9e79' - assert_equal "git clone -q -o username git@somehost.com:project.git /var/www && cd /var/www && git checkout -q -b deploy #{rev} && git submodule -q init && git submodule -q sync && git submodule -q update", @source.checkout(rev, dest) - end - - # Tests from base_test.rb, makin' sure we didn't break anything up there! - def test_command_should_default_to_default_command - assert_equal "git", @source.command - @source.local { assert_equal "git", @source.command } - end - - def test_command_should_use_scm_command_if_available - @config[:scm_command] = "/opt/local/bin/git" - assert_equal "/opt/local/bin/git", @source.command - end - - def test_command_should_use_scm_command_in_local_mode_if_local_scm_command_not_set - @config[:scm_command] = "/opt/local/bin/git" - @source.local { assert_equal "/opt/local/bin/git", @source.command } - end - - def test_command_should_use_local_scm_command_in_local_mode_if_local_scm_command_is_set - @config[:scm_command] = "/opt/local/bin/git" - @config[:local_scm_command] = "/usr/local/bin/git" - assert_equal "/opt/local/bin/git", @source.command - @source.local { assert_equal "/usr/local/bin/git", @source.command } - end - - def test_command_should_use_default_if_scm_command_is_default - @config[:scm_command] = :default - assert_equal "git", @source.command - end - - def test_command_should_use_default_in_local_mode_if_local_scm_command_is_default - @config[:scm_command] = "/foo/bar/git" - @config[:local_scm_command] = :default - @source.local { assert_equal "git", @source.command } - end - - def test_local_mode_proxy_should_treat_messages_as_being_in_local_mode - @config[:scm_command] = "/foo/bar/git" - @config[:local_scm_command] = :default - assert_equal "git", @source.local.command - assert_equal "/foo/bar/git", @source.command - end -end diff --git a/vendor/gems/capistrano-2.5.9/test/deploy/scm/mercurial_test.rb b/vendor/gems/capistrano-2.5.9/test/deploy/scm/mercurial_test.rb deleted file mode 100644 index 48f240719..000000000 --- a/vendor/gems/capistrano-2.5.9/test/deploy/scm/mercurial_test.rb +++ /dev/null @@ -1,134 +0,0 @@ -require "utils" -require 'capistrano/recipes/deploy/scm/mercurial' - -class DeploySCMMercurialTest < Test::Unit::TestCase - class TestSCM < Capistrano::Deploy::SCM::Mercurial - default_command "hg" - end - - def setup - @config = { } - def @config.exists?(name); key?(name); end - - @source = TestSCM.new(@config) - end - - def test_head - assert_equal "tip", @source.head - end - - def test_different_head - @config[:branch] = "staging" - assert_equal "staging", @source.head - end - - def test_checkout - @config[:repository] = "http://example.com/project-hg" - dest = "/var/www" - assert_equal "hg clone --noupdate http://example.com/project-hg /var/www && hg update --repository /var/www --clean 8a8e00b8f11b", @source.checkout('8a8e00b8f11b', dest) - end - - def test_diff - assert_equal "hg diff --rev tip", @source.diff('tip') - assert_equal "hg diff --rev 1 --rev 2", @source.diff('1', '2') - end - - def test_log - assert_equal "hg log --rev 8a8e00b8f11b", @source.log('8a8e00b8f11b') - assert_equal "hg log --rev 0:3", @source.log('0', '3') - end - - def test_query_revision - assert_equal "hg log -r 8a8e00b8f11b --template '{node|short}'", @source.query_revision('8a8e00b8f11b') { |o| o } - end - - def test_username_should_be_backwards_compatible - # older versions of this module required :scm_user var instead - # of the currently preferred :scm_username - require 'capistrano/logger' - @config[:scm_user] = "fred" - text = "user:" - assert_equal "fred\n", @source.handle_data(mock_state, :test_stream, text) - # :scm_username takes priority - @config[:scm_username] = "wilma" - assert_equal "wilma\n", @source.handle_data(mock_state, :test_stream, text) - end - - def test_sync - dest = "/var/www" - assert_equal "hg pull --repository /var/www && hg update --repository /var/www --clean 8a8e00b8f11b", @source.sync('8a8e00b8f11b', dest) - - # With :scm_command - @config[:scm_command] = "/opt/local/bin/hg" - assert_equal "/opt/local/bin/hg pull --repository /var/www && /opt/local/bin/hg update --repository /var/www --clean 8a8e00b8f11b", @source.sync('8a8e00b8f11b', dest) - end - - def test_export - dest = "/var/www" - assert_raise(NotImplementedError) { @source.export('8a8e00b8f11b', dest) } - end - - def test_sends_password_if_set - require 'capistrano/logger' - text = "password:" - @config[:scm_password] = "opensesame" - assert_equal "opensesame\n", @source.handle_data(mock_state, :test_stream, text) - end - - def test_prompts_for_password_if_preferred - require 'capistrano/logger' - require 'capistrano/cli' - Capistrano::CLI.stubs(:password_prompt).with("hg password: ").returns("opensesame") - @config[:scm_prefer_prompt] = true - text = "password:" - assert_equal "opensesame\n", @source.handle_data(mock_state, :test_stream, text) - end - - - # Tests from base_test.rb, makin' sure we didn't break anything up there! - def test_command_should_default_to_default_command - assert_equal "hg", @source.command - @source.local { assert_equal "hg", @source.command } - end - - def test_command_should_use_scm_command_if_available - @config[:scm_command] = "/opt/local/bin/hg" - assert_equal "/opt/local/bin/hg", @source.command - end - - def test_command_should_use_scm_command_in_local_mode_if_local_scm_command_not_set - @config[:scm_command] = "/opt/local/bin/hg" - @source.local { assert_equal "/opt/local/bin/hg", @source.command } - end - - def test_command_should_use_local_scm_command_in_local_mode_if_local_scm_command_is_set - @config[:scm_command] = "/opt/local/bin/hg" - @config[:local_scm_command] = "/usr/local/bin/hg" - assert_equal "/opt/local/bin/hg", @source.command - @source.local { assert_equal "/usr/local/bin/hg", @source.command } - end - - def test_command_should_use_default_if_scm_command_is_default - @config[:scm_command] = :default - assert_equal "hg", @source.command - end - - def test_command_should_use_default_in_local_mode_if_local_scm_command_is_default - @config[:scm_command] = "/foo/bar/hg" - @config[:local_scm_command] = :default - @source.local { assert_equal "hg", @source.command } - end - - def test_local_mode_proxy_should_treat_messages_as_being_in_local_mode - @config[:scm_command] = "/foo/bar/hg" - @config[:local_scm_command] = :default - assert_equal "hg", @source.local.command - assert_equal "/foo/bar/hg", @source.command - end - - private - - def mock_state - { :channel => { :host => "abc" } } - end -end diff --git a/vendor/gems/capistrano-2.5.9/test/deploy/scm/none_test.rb b/vendor/gems/capistrano-2.5.9/test/deploy/scm/none_test.rb deleted file mode 100644 index 1aeeb2ae4..000000000 --- a/vendor/gems/capistrano-2.5.9/test/deploy/scm/none_test.rb +++ /dev/null @@ -1,35 +0,0 @@ -require 'utils' -require 'capistrano/recipes/deploy/scm/none' - -class DeploySCMNoneTest < Test::Unit::TestCase - class TestSCM < Capistrano::Deploy::SCM::None - default_command 'none' - end - - def setup - @config = {} - def @config.exists?(name); key?(name); end - @source = TestSCM.new(@config) - end - - def test_the_truth - assert true - end - - def test_checkout_on_linux - Capistrano::Deploy::LocalDependency.stubs(:on_windows?).returns(false) - @config[:repository] = '.' - rev = '' - dest = '/var/www' - assert_equal "cp -R . /var/www", @source.checkout(rev, dest) - end - - def test_checkout_on_windows - Capistrano::Deploy::LocalDependency.stubs(:on_windows?).returns(true) - @config[:repository] = '.' - rev = '' - dest = 'c:/Documents and settings/admin/tmp' - assert_equal "xcopy . \"c:/Documents and settings/admin/tmp\" /S/I/Y/Q/E", @source.checkout(rev, dest) - end - -end diff --git a/vendor/gems/capistrano-2.5.9/test/deploy/scm/subversion_test.rb b/vendor/gems/capistrano-2.5.9/test/deploy/scm/subversion_test.rb deleted file mode 100644 index 26d1047cb..000000000 --- a/vendor/gems/capistrano-2.5.9/test/deploy/scm/subversion_test.rb +++ /dev/null @@ -1,32 +0,0 @@ -require "utils" -require 'capistrano/recipes/deploy/scm/subversion' - -class DeploySCMSubversionTest < Test::Unit::TestCase - class TestSCM < Capistrano::Deploy::SCM::Subversion - default_command "svn" - end - - def setup - @config = { :repository => "." } - def @config.exists?(name); key?(name); end - - @source = TestSCM.new(@config) - end - - def test_query_revision - revision = @source.query_revision('HEAD') do |o| - assert_equal "svn info . -rHEAD", o - %Q{Path: rails_2_3 -URL: svn+ssh://example.com/var/repos/project/branches/rails_2_3 -Repository Root: svn+ssh://example.com/var/repos -Repository UUID: 2d86388d-c40f-0410-ad6a-a69da6a65d20 -Revision: 2095 -Node Kind: directory -Last Changed Author: sw -Last Changed Rev: 2064 -Last Changed Date: 2009-03-11 11:04:25 -0700 (Wed, 11 Mar 2009) -} - end - assert_equal 2095, revision - end -end diff --git a/vendor/gems/capistrano-2.5.9/test/deploy/strategy/copy_test.rb b/vendor/gems/capistrano-2.5.9/test/deploy/strategy/copy_test.rb deleted file mode 100644 index 33ba69617..000000000 --- a/vendor/gems/capistrano-2.5.9/test/deploy/strategy/copy_test.rb +++ /dev/null @@ -1,302 +0,0 @@ -require "utils" -require 'capistrano/logger' -require 'capistrano/recipes/deploy/strategy/copy' -require 'stringio' - -class DeployStrategyCopyTest < Test::Unit::TestCase - def setup - @config = { :application => "captest", - :logger => Capistrano::Logger.new(:output => StringIO.new), - :releases_path => "/u/apps/test/releases", - :release_path => "/u/apps/test/releases/1234567890", - :real_revision => "154" } - @source = mock("source") - @config.stubs(:source).returns(@source) - @strategy = Capistrano::Deploy::Strategy::Copy.new(@config) - end - - def test_deploy_with_defaults_should_use_remote_gtar - @config[:copy_remote_tar] = 'gtar' - - Dir.expects(:tmpdir).returns("/temp/dir") - @source.expects(:checkout).with("154", "/temp/dir/1234567890").returns(:local_checkout) - @strategy.expects(:system).with(:local_checkout) - - Dir.expects(:chdir).with("/temp/dir").yields - @strategy.expects(:system).with("tar czf 1234567890.tar.gz 1234567890") - @strategy.expects(:upload).with("/temp/dir/1234567890.tar.gz", "/tmp/1234567890.tar.gz") - @strategy.expects(:run).with("cd /u/apps/test/releases && gtar xzf /tmp/1234567890.tar.gz && rm /tmp/1234567890.tar.gz") - - mock_file = mock("file") - mock_file.expects(:puts).with("154") - File.expects(:open).with("/temp/dir/1234567890/REVISION", "w").yields(mock_file) - - FileUtils.expects(:rm).with("/temp/dir/1234567890.tar.gz") - FileUtils.expects(:rm_rf).with("/temp/dir/1234567890") - - @strategy.deploy! - end - - def test_deploy_with_defaults_should_use_local_gtar - @config[:copy_local_tar] = 'gtar' - - Dir.expects(:tmpdir).returns("/temp/dir") - @source.expects(:checkout).with("154", "/temp/dir/1234567890").returns(:local_checkout) - @strategy.expects(:system).with(:local_checkout) - - Dir.expects(:chdir).with("/temp/dir").yields - @strategy.expects(:system).with("gtar czf 1234567890.tar.gz 1234567890") - @strategy.expects(:upload).with("/temp/dir/1234567890.tar.gz", "/tmp/1234567890.tar.gz") - @strategy.expects(:run).with("cd /u/apps/test/releases && tar xzf /tmp/1234567890.tar.gz && rm /tmp/1234567890.tar.gz") - - mock_file = mock("file") - mock_file.expects(:puts).with("154") - File.expects(:open).with("/temp/dir/1234567890/REVISION", "w").yields(mock_file) - - FileUtils.expects(:rm).with("/temp/dir/1234567890.tar.gz") - FileUtils.expects(:rm_rf).with("/temp/dir/1234567890") - - @strategy.deploy! - end - - def test_deploy_with_defaults_should_use_tar_gz_and_checkout - Dir.expects(:tmpdir).returns("/temp/dir") - @source.expects(:checkout).with("154", "/temp/dir/1234567890").returns(:local_checkout) - @strategy.expects(:system).with(:local_checkout) - - prepare_standard_compress_and_copy! - @strategy.deploy! - end - - def test_deploy_with_exclusions_should_remove_patterns_from_destination - @config[:copy_exclude] = ".git" - Dir.expects(:tmpdir).returns("/temp/dir") - @source.expects(:checkout).with("154", "/temp/dir/1234567890").returns(:local_checkout) - @strategy.expects(:system).with(:local_checkout) - Dir.expects(:glob).with("/temp/dir/1234567890/.git", File::FNM_DOTMATCH).returns(%w(/temp/dir/1234567890/.git)) - - FileUtils.expects(:rm_rf).with(%w(/temp/dir/1234567890/.git)) - prepare_standard_compress_and_copy! - @strategy.deploy! - end - - def test_deploy_with_exclusions_should_remove_glob_patterns_from_destination - @config[:copy_exclude] = ".gi*" - Dir.expects(:tmpdir).returns("/temp/dir") - @source.expects(:checkout).with("154", "/temp/dir/1234567890").returns(:local_checkout) - @strategy.expects(:system).with(:local_checkout) - Dir.expects(:glob).with("/temp/dir/1234567890/.gi*", File::FNM_DOTMATCH).returns(%w(/temp/dir/1234567890/.git)) - - FileUtils.expects(:rm_rf).with(%w(/temp/dir/1234567890/.git)) - prepare_standard_compress_and_copy! - @strategy.deploy! - end - - def test_deploy_with_export_should_use_tar_gz_and_export - Dir.expects(:tmpdir).returns("/temp/dir") - @config[:copy_strategy] = :export - @source.expects(:export).with("154", "/temp/dir/1234567890").returns(:local_export) - @strategy.expects(:system).with(:local_export) - - prepare_standard_compress_and_copy! - @strategy.deploy! - end - - def test_deploy_with_zip_should_use_zip_and_checkout - Dir.expects(:tmpdir).returns("/temp/dir") - Dir.expects(:chdir).with("/temp/dir").yields - @config[:copy_compression] = :zip - @source.expects(:checkout).with("154", "/temp/dir/1234567890").returns(:local_checkout) - - @strategy.expects(:system).with(:local_checkout) - @strategy.expects(:system).with("zip -qr 1234567890.zip 1234567890") - @strategy.expects(:upload).with("/temp/dir/1234567890.zip", "/tmp/1234567890.zip") - @strategy.expects(:run).with("cd /u/apps/test/releases && unzip -q /tmp/1234567890.zip && rm /tmp/1234567890.zip") - - mock_file = mock("file") - mock_file.expects(:puts).with("154") - File.expects(:open).with("/temp/dir/1234567890/REVISION", "w").yields(mock_file) - - FileUtils.expects(:rm).with("/temp/dir/1234567890.zip") - FileUtils.expects(:rm_rf).with("/temp/dir/1234567890") - - @strategy.deploy! - end - - def test_deploy_with_bzip2_should_use_bz2_and_checkout - Dir.expects(:tmpdir).returns("/temp/dir") - Dir.expects(:chdir).with("/temp/dir").yields - @config[:copy_compression] = :bzip2 - @source.expects(:checkout).with("154", "/temp/dir/1234567890").returns(:local_checkout) - - @strategy.expects(:system).with(:local_checkout) - @strategy.expects(:system).with("tar cjf 1234567890.tar.bz2 1234567890") - @strategy.expects(:upload).with("/temp/dir/1234567890.tar.bz2", "/tmp/1234567890.tar.bz2") - @strategy.expects(:run).with("cd /u/apps/test/releases && tar xjf /tmp/1234567890.tar.bz2 && rm /tmp/1234567890.tar.bz2") - - mock_file = mock("file") - mock_file.expects(:puts).with("154") - File.expects(:open).with("/temp/dir/1234567890/REVISION", "w").yields(mock_file) - - FileUtils.expects(:rm).with("/temp/dir/1234567890.tar.bz2") - FileUtils.expects(:rm_rf).with("/temp/dir/1234567890") - - @strategy.deploy! - end - - def test_deploy_with_unknown_compression_type_should_error - @config[:copy_compression] = :bogus - Dir.expects(:tmpdir).returns("/temp/dir") - @source.expects(:checkout).with("154", "/temp/dir/1234567890").returns(:local_checkout) - @strategy.stubs(:system) - File.stubs(:open) - - assert_raises(ArgumentError) { @strategy.deploy! } - end - - def test_deploy_with_custom_copy_dir_should_use_that_as_tmpdir - Dir.expects(:tmpdir).never - Dir.expects(:chdir).with("/other/path").yields - @config[:copy_dir] = "/other/path" - @source.expects(:checkout).with("154", "/other/path/1234567890").returns(:local_checkout) - - @strategy.expects(:system).with(:local_checkout) - @strategy.expects(:system).with("tar czf 1234567890.tar.gz 1234567890") - @strategy.expects(:upload).with("/other/path/1234567890.tar.gz", "/tmp/1234567890.tar.gz") - @strategy.expects(:run).with("cd /u/apps/test/releases && tar xzf /tmp/1234567890.tar.gz && rm /tmp/1234567890.tar.gz") - - mock_file = mock("file") - mock_file.expects(:puts).with("154") - File.expects(:open).with("/other/path/1234567890/REVISION", "w").yields(mock_file) - - FileUtils.expects(:rm).with("/other/path/1234567890.tar.gz") - FileUtils.expects(:rm_rf).with("/other/path/1234567890") - - @strategy.deploy! - end - - def test_deploy_with_copy_remote_dir_should_copy_to_that_dir - @config[:copy_remote_dir] = "/somewhere/else" - Dir.expects(:tmpdir).returns("/temp/dir") - Dir.expects(:chdir).yields - @source.expects(:checkout).returns(:local_checkout) - - @strategy.expects(:system).with(:local_checkout) - @strategy.expects(:system).with("tar czf 1234567890.tar.gz 1234567890") - @strategy.expects(:upload).with("/temp/dir/1234567890.tar.gz", "/somewhere/else/1234567890.tar.gz") - @strategy.expects(:run).with("cd /u/apps/test/releases && tar xzf /somewhere/else/1234567890.tar.gz && rm /somewhere/else/1234567890.tar.gz") - - mock_file = mock("file") - mock_file.expects(:puts).with("154") - File.expects(:open).with("/temp/dir/1234567890/REVISION", "w").yields(mock_file) - - FileUtils.expects(:rm).with("/temp/dir/1234567890.tar.gz") - FileUtils.expects(:rm_rf).with("/temp/dir/1234567890") - - @strategy.deploy! - end - - def test_with_copy_cache_should_checkout_to_cache_if_cache_does_not_exist_and_then_copy - @config[:copy_cache] = true - - Dir.stubs(:tmpdir).returns("/temp/dir") - File.expects(:exists?).with("/temp/dir/captest").returns(false) - Dir.expects(:chdir).with("/temp/dir/captest").yields - - @source.expects(:checkout).with("154", "/temp/dir/captest").returns(:local_checkout) - @strategy.expects(:system).with(:local_checkout) - - FileUtils.expects(:mkdir_p).with("/temp/dir/1234567890") - - prepare_directory_tree!("/temp/dir/captest") - - prepare_standard_compress_and_copy! - @strategy.deploy! - end - - def test_with_copy_cache_should_update_cache_if_cache_exists_and_then_copy - @config[:copy_cache] = true - - Dir.stubs(:tmpdir).returns("/temp/dir") - File.expects(:exists?).with("/temp/dir/captest").returns(true) - Dir.expects(:chdir).with("/temp/dir/captest").yields - - @source.expects(:sync).with("154", "/temp/dir/captest").returns(:local_sync) - @strategy.expects(:system).with(:local_sync) - - FileUtils.expects(:mkdir_p).with("/temp/dir/1234567890") - - prepare_directory_tree!("/temp/dir/captest") - - prepare_standard_compress_and_copy! - @strategy.deploy! - end - - def test_with_copy_cache_with_custom_cache_dir_should_use_specified_cache_dir - @config[:copy_cache] = "/u/caches/captest" - - Dir.stubs(:tmpdir).returns("/temp/dir") - File.expects(:exists?).with("/u/caches/captest").returns(true) - Dir.expects(:chdir).with("/u/caches/captest").yields - - @source.expects(:sync).with("154", "/u/caches/captest").returns(:local_sync) - @strategy.expects(:system).with(:local_sync) - - FileUtils.expects(:mkdir_p).with("/temp/dir/1234567890") - - prepare_directory_tree!("/u/caches/captest") - - prepare_standard_compress_and_copy! - @strategy.deploy! - end - - def test_with_copy_cache_with_excludes_should_not_copy_excluded_files - @config[:copy_cache] = true - @config[:copy_exclude] = "*/bar.txt" - - Dir.stubs(:tmpdir).returns("/temp/dir") - File.expects(:exists?).with("/temp/dir/captest").returns(true) - Dir.expects(:chdir).with("/temp/dir/captest").yields - - @source.expects(:sync).with("154", "/temp/dir/captest").returns(:local_sync) - @strategy.expects(:system).with(:local_sync) - - FileUtils.expects(:mkdir_p).with("/temp/dir/1234567890") - - prepare_directory_tree!("/temp/dir/captest", true) - - prepare_standard_compress_and_copy! - @strategy.deploy! - end - - private - - def prepare_directory_tree!(cache, exclude=false) - Dir.expects(:glob).with("*", File::FNM_DOTMATCH).returns([".", "..", "app", "foo.txt"]) - File.expects(:directory?).with("app").returns(true) - FileUtils.expects(:mkdir).with("/temp/dir/1234567890/app") - File.expects(:directory?).with("foo.txt").returns(false) - FileUtils.expects(:ln).with("#{cache}/foo.txt", "/temp/dir/1234567890/foo.txt") - - Dir.expects(:glob).with("app/*", File::FNM_DOTMATCH).returns(["app/.", "app/..", "app/bar.txt"]) - - unless exclude - File.expects(:directory?).with("app/bar.txt").returns(false) - FileUtils.expects(:ln).with("#{cache}/app/bar.txt", "/temp/dir/1234567890/app/bar.txt") - end - end - - def prepare_standard_compress_and_copy! - Dir.expects(:chdir).with("/temp/dir").yields - @strategy.expects(:system).with("tar czf 1234567890.tar.gz 1234567890") - @strategy.expects(:upload).with("/temp/dir/1234567890.tar.gz", "/tmp/1234567890.tar.gz") - @strategy.expects(:run).with("cd /u/apps/test/releases && tar xzf /tmp/1234567890.tar.gz && rm /tmp/1234567890.tar.gz") - - mock_file = mock("file") - mock_file.expects(:puts).with("154") - File.expects(:open).with("/temp/dir/1234567890/REVISION", "w").yields(mock_file) - - FileUtils.expects(:rm).with("/temp/dir/1234567890.tar.gz") - FileUtils.expects(:rm_rf).with("/temp/dir/1234567890") - end -end diff --git a/vendor/gems/capistrano-2.5.9/test/extensions_test.rb b/vendor/gems/capistrano-2.5.9/test/extensions_test.rb deleted file mode 100644 index 88992cda2..000000000 --- a/vendor/gems/capistrano-2.5.9/test/extensions_test.rb +++ /dev/null @@ -1,69 +0,0 @@ -require "utils" -require 'capistrano' - -class ExtensionsTest < Test::Unit::TestCase - module CustomExtension - def do_something(command) - run(command) - end - end - - def setup - @config = Capistrano::Configuration.new - end - - def teardown - Capistrano::EXTENSIONS.keys.each { |e| Capistrano.remove_plugin(e) } - end - - def test_register_plugin_should_add_instance_method_on_configuration_and_return_true - assert !@config.respond_to?(:custom_stuff) - assert Capistrano.plugin(:custom_stuff, CustomExtension) - assert @config.respond_to?(:custom_stuff) - end - - def test_register_plugin_that_already_exists_should_return_false - assert Capistrano.plugin(:custom_stuff, CustomExtension) - assert !Capistrano.plugin(:custom_stuff, CustomExtension) - end - - def test_register_plugin_with_public_method_name_should_fail - method = Capistrano::Configuration.public_instance_methods.first - assert_not_nil method, "need a public instance method for testing" - assert_raises(Capistrano::Error) { Capistrano.plugin(method, CustomExtension) } - end - - def test_register_plugin_with_protected_method_name_should_fail - method = Capistrano::Configuration.protected_instance_methods.first - assert_not_nil method, "need a protected instance method for testing" - assert_raises(Capistrano::Error) { Capistrano.plugin(method, CustomExtension) } - end - - def test_register_plugin_with_private_method_name_should_fail - method = Capistrano::Configuration.private_instance_methods.first - assert_not_nil method, "need a private instance method for testing" - assert_raises(Capistrano::Error) { Capistrano.plugin(method, CustomExtension) } - end - - def test_unregister_plugin_that_does_not_exist_should_return_false - assert !Capistrano.remove_plugin(:custom_stuff) - end - - def test_unregister_plugin_should_remove_method_and_return_true - assert Capistrano.plugin(:custom_stuff, CustomExtension) - assert @config.respond_to?(:custom_stuff) - assert Capistrano.remove_plugin(:custom_stuff) - assert !@config.respond_to?(:custom_stuff) - end - - def test_registered_plugin_proxy_should_return_proxy_object - Capistrano.plugin(:custom_stuff, CustomExtension) - assert_instance_of Capistrano::ExtensionProxy, @config.custom_stuff - end - - def test_proxy_object_should_delegate_to_configuration - Capistrano.plugin(:custom_stuff, CustomExtension) - @config.expects(:run).with("hello") - @config.custom_stuff.do_something("hello") - end -end \ No newline at end of file diff --git a/vendor/gems/capistrano-2.5.9/test/fixtures/cli_integration.rb b/vendor/gems/capistrano-2.5.9/test/fixtures/cli_integration.rb deleted file mode 100644 index 1d2108dc4..000000000 --- a/vendor/gems/capistrano-2.5.9/test/fixtures/cli_integration.rb +++ /dev/null @@ -1,5 +0,0 @@ -role :test, "www.capistrano.test" - -task :testing, :roles => :test do - set :testing_occurred, true -end diff --git a/vendor/gems/capistrano-2.5.9/test/fixtures/config.rb b/vendor/gems/capistrano-2.5.9/test/fixtures/config.rb deleted file mode 100644 index 0570980bd..000000000 --- a/vendor/gems/capistrano-2.5.9/test/fixtures/config.rb +++ /dev/null @@ -1,5 +0,0 @@ -set :application, "foo" -set :repository, "1/2/#{application}" -set :gateway, "#{__FILE__}.example.com" - -role :web, "www.example.com", :primary => true diff --git a/vendor/gems/capistrano-2.5.9/test/fixtures/custom.rb b/vendor/gems/capistrano-2.5.9/test/fixtures/custom.rb deleted file mode 100644 index 09fb89441..000000000 --- a/vendor/gems/capistrano-2.5.9/test/fixtures/custom.rb +++ /dev/null @@ -1,3 +0,0 @@ -ConfigurationLoadingTest::MockConfig.instance(:must_exist).load do - ping! :custom -end diff --git a/vendor/gems/capistrano-2.5.9/test/logger_test.rb b/vendor/gems/capistrano-2.5.9/test/logger_test.rb deleted file mode 100644 index 9fac17d1b..000000000 --- a/vendor/gems/capistrano-2.5.9/test/logger_test.rb +++ /dev/null @@ -1,123 +0,0 @@ -require "utils" -require 'capistrano/logger' -require 'stringio' - -class LoggerTest < Test::Unit::TestCase - def setup - @io = StringIO.new - @logger = Capistrano::Logger.new(:output => @io) - end - - def test_logger_should_use_STDERR_by_default - logger = Capistrano::Logger.new - assert_equal STDERR, logger.device - end - - def test_logger_should_use_output_option_if_output_responds_to_puts - logger = Capistrano::Logger.new(:output => STDOUT) - assert_equal STDOUT, logger.device - end - - def test_logger_should_open_file_if_output_does_not_respond_to_puts - File.expects(:open).with("logs/capistrano.log", "a").returns(:mock) - logger = Capistrano::Logger.new(:output => "logs/capistrano.log") - assert_equal :mock, logger.device - end - - def test_close_should_not_close_device_if_device_is_default - logger = Capistrano::Logger.new - logger.device.expects(:close).never - logger.close - end - - def test_close_should_not_close_device_is_device_is_explicitly_given - logger = Capistrano::Logger.new(:output => STDOUT) - STDOUT.expects(:close).never - logger.close - end - - def test_close_should_close_device_when_device_was_implicitly_opened - f = mock("file", :close => nil) - File.expects(:open).with("logs/capistrano.log", "a").returns(f) - logger = Capistrano::Logger.new(:output => "logs/capistrano.log") - logger.close - end - - def test_log_with_level_greater_than_threshold_should_ignore_message - @logger.level = 3 - @logger.log(4, "message") - assert @io.string.empty? - end - - def test_log_with_level_equal_to_threshold_should_log_message - @logger.level = 3 - @logger.log(3, "message") - assert @io.string.include?("message") - end - - def test_log_with_level_less_than_threshold_should_log_message - @logger.level = 3 - @logger.log(2, "message") - assert @io.string.include?("message") - end - - def test_log_with_multiline_message_should_log_each_line_separately - @logger.log(0, "first line\nsecond line") - assert @io.string.include?("*** first line") - assert @io.string.include?("*** second line") - end - - def test_log_with_line_prefix_should_insert_line_prefix_before_message - @logger.log(0, "message", "prefix") - assert @io.string.include?("*** [prefix] message") - end - - def test_log_with_level_0_should_have_strong_indent - @logger.log(0, "message") - assert @io.string.match(/^\*\*\* message/) - end - - def test_log_with_level_1_should_have_weaker_indent - @logger.level = 1 - @logger.log(1, "message") - assert @io.string.match(/^ \*\* message/) - end - - def test_log_with_level_2_should_have_weaker_indent - @logger.level = 2 - @logger.log(2, "message") - assert @io.string.match(/^ \* message/) - end - - def test_log_with_level_3_should_have_weakest_indent - @logger.level = 3 - @logger.log(3, "message") - assert @io.string.match(/^ message/) - end - - def test_important_should_delegate_to_log_with_level_IMPORTANT - @logger.expects(:log).with(Capistrano::Logger::IMPORTANT, "message", "prefix") - @logger.important("message", "prefix") - end - - def test_info_should_delegate_to_log_with_level_INFO - @logger.expects(:log).with(Capistrano::Logger::INFO, "message", "prefix") - @logger.info("message", "prefix") - end - - def test_debug_should_delegate_to_log_with_level_DEBUG - @logger.expects(:log).with(Capistrano::Logger::DEBUG, "message", "prefix") - @logger.debug("message", "prefix") - end - - def test_trace_should_delegate_to_log_with_level_TRACE - @logger.expects(:log).with(Capistrano::Logger::TRACE, "message", "prefix") - @logger.trace("message", "prefix") - end - - def test_ordering_of_levels - assert Capistrano::Logger::IMPORTANT < Capistrano::Logger::INFO - assert Capistrano::Logger::INFO < Capistrano::Logger::DEBUG - assert Capistrano::Logger::DEBUG < Capistrano::Logger::TRACE - end -end diff --git a/vendor/gems/capistrano-2.5.9/test/role_test.rb b/vendor/gems/capistrano-2.5.9/test/role_test.rb deleted file mode 100644 index 98447b4b6..000000000 --- a/vendor/gems/capistrano-2.5.9/test/role_test.rb +++ /dev/null @@ -1,11 +0,0 @@ -require "utils" -require 'capistrano/role' - -class RoleTest < Test::Unit::TestCase - def test_clearing_a_populated_role_should_yield_no_servers - role = Capistrano::Role.new("app1.capistrano.test", lambda { |o| "app2.capistrano.test" }) - assert_equal 2, role.servers.size - role.clear - assert role.servers.empty? - end -end diff --git a/vendor/gems/capistrano-2.5.9/test/server_definition_test.rb b/vendor/gems/capistrano-2.5.9/test/server_definition_test.rb deleted file mode 100644 index a0ed71031..000000000 --- a/vendor/gems/capistrano-2.5.9/test/server_definition_test.rb +++ /dev/null @@ -1,121 +0,0 @@ -require "utils" -require 'capistrano/server_definition' - -class ServerDefinitionTest < Test::Unit::TestCase - def test_new_without_credentials_or_port_should_set_values_to_defaults - server = Capistrano::ServerDefinition.new("www.capistrano.test") - assert_equal "www.capistrano.test", server.host - assert_nil server.user - assert_nil server.port - end - - def test_new_with_encoded_user_should_extract_user_and_use_default_port - server = Capistrano::ServerDefinition.new("jamis@www.capistrano.test") - assert_equal "www.capistrano.test", server.host - assert_equal "jamis", server.user - assert_nil server.port - end - - def test_new_with_encoded_port_should_extract_port_and_use_default_user - server = Capistrano::ServerDefinition.new("www.capistrano.test:8080") - assert_equal "www.capistrano.test", server.host - assert_nil server.user - assert_equal 8080, server.port - end - - def test_new_with_encoded_user_and_port_should_extract_user_and_port - server = Capistrano::ServerDefinition.new("jamis@www.capistrano.test:8080") - assert_equal "www.capistrano.test", server.host - assert_equal "jamis", server.user - assert_equal 8080, server.port - end - - def test_new_with_user_as_option_should_use_given_user - server = Capistrano::ServerDefinition.new("www.capistrano.test", :user => "jamis") - assert_equal "www.capistrano.test", server.host - assert_equal "jamis", server.user - assert_nil server.port - end - - def test_new_with_port_as_option_should_use_given_user - server = Capistrano::ServerDefinition.new("www.capistrano.test", :port => 8080) - assert_equal "www.capistrano.test", server.host - assert_nil server.user - assert_equal 8080, server.port - end - - def test_encoded_value_should_override_hash_option - server = Capistrano::ServerDefinition.new("jamis@www.capistrano.test:8080", :user => "david", :port => 8081) - assert_equal "www.capistrano.test", server.host - assert_equal "jamis", server.user - assert_equal 8080, server.port - assert server.options.empty? - end - - def test_new_with_option_should_dup_option_hash - options = {} - server = Capistrano::ServerDefinition.new("www.capistrano.test", options) - assert_not_equal options.object_id, server.options.object_id - end - - def test_new_with_options_should_keep_options - server = Capistrano::ServerDefinition.new("www.capistrano.test", :primary => true) - assert_equal true, server.options[:primary] - end - - def test_default_user_should_try_to_guess_username - ENV.stubs(:[]).returns(nil) - assert_equal "not-specified", Capistrano::ServerDefinition.default_user - - ENV.stubs(:[]).returns(nil) - ENV.stubs(:[]).with("USERNAME").returns("ryan") - assert_equal "ryan", Capistrano::ServerDefinition.default_user - - ENV.stubs(:[]).returns(nil) - ENV.stubs(:[]).with("USER").returns("jamis") - assert_equal "jamis", Capistrano::ServerDefinition.default_user - end - - def test_comparison_should_match_when_host_user_port_are_same - s1 = server("jamis@www.capistrano.test:8080") - s2 = server("www.capistrano.test", :user => "jamis", :port => 8080) - assert_equal s1, s2 - assert_equal s1.hash, s2.hash - assert s1.eql?(s2) - end - - def test_servers_should_be_comparable - s1 = server("jamis@www.capistrano.test:8080") - s2 = server("www.alphabet.test:1234") - s3 = server("jamis@www.capistrano.test:8075") - s4 = server("billy@www.capistrano.test:8080") - - assert s2 < s1 - assert s3 < s1 - assert s4 < s1 - assert s2 < s3 - assert s2 < s4 - assert s3 < s4 - end - - def test_comparison_should_not_match_when_any_of_host_user_port_differ - s1 = server("jamis@www.capistrano.test:8080") - s2 = server("bob@www.capistrano.test:8080") - s3 = server("jamis@www.capistrano.test:8081") - s4 = server("jamis@app.capistrano.test:8080") - assert_not_equal s1, s2 - assert_not_equal s1, s3 - assert_not_equal s1, s4 - assert_not_equal s2, s3 - assert_not_equal s2, s4 - assert_not_equal s3, s4 - end - - def test_to_s - assert_equal "www.capistrano.test", server("www.capistrano.test").to_s - assert_equal "www.capistrano.test", server("www.capistrano.test:22").to_s - assert_equal "www.capistrano.test:1234", server("www.capistrano.test:1234").to_s - assert_equal "jamis@www.capistrano.test", server("jamis@www.capistrano.test").to_s - assert_equal "jamis@www.capistrano.test:1234", server("jamis@www.capistrano.test:1234").to_s - end -end diff --git a/vendor/gems/capistrano-2.5.9/test/shell_test.rb b/vendor/gems/capistrano-2.5.9/test/shell_test.rb deleted file mode 100644 index f46f4e50f..000000000 --- a/vendor/gems/capistrano-2.5.9/test/shell_test.rb +++ /dev/null @@ -1,90 +0,0 @@ -require "utils" -require 'capistrano/configuration' -require 'capistrano/shell' - -class ShellTest < Test::Unit::TestCase - def setup - @config = Capistrano::Configuration.new - @shell = Capistrano::Shell.new(@config) - @shell.stubs(:puts) - end - - def test_readline_fallback_prompt_should_write_to_stdout_and_read_from_stdin - STDOUT.expects(:print).with("prompt> ") - STDOUT.expects(:flush) - STDIN.expects(:gets).returns("hi\n") - assert_equal "hi\n", Capistrano::Shell::ReadlineFallback.readline("prompt> ") - end - - def test_question_mark_as_input_should_trigger_help - @shell.expects(:read_line).returns("?") - @shell.expects(:help) - assert @shell.read_and_execute - end - - def test_help_as_input_should_trigger_help - @shell.expects(:read_line).returns("help") - @shell.expects(:help) - assert @shell.read_and_execute - end - - def test_quit_as_input_should_cause_read_and_execute_to_return_false - @shell.expects(:read_line).returns("quit") - assert !@shell.read_and_execute - end - - def test_exit_as_input_should_cause_read_and_execute_to_return_false - @shell.expects(:read_line).returns("exit") - assert !@shell.read_and_execute - end - - def test_set_should_parse_flag_and_value_and_call_set_option - @shell.expects(:read_line).returns("set -v 5") - @shell.expects(:set_option).with("v", "5") - assert @shell.read_and_execute - end - - def test_text_without_with_or_on_gets_processed_verbatim - @shell.expects(:read_line).returns("hello world") - @shell.expects(:process_command).with(nil, nil, "hello world") - assert @shell.read_and_execute - end - - def test_text_with_with_gets_processed_with_with # lol - @shell.expects(:read_line).returns("with app,db hello world") - @shell.expects(:process_command).with("with", "app,db", "hello world") - assert @shell.read_and_execute - end - - def test_text_with_on_gets_processed_with_on - @shell.expects(:read_line).returns("on app,db hello world") - @shell.expects(:process_command).with("on", "app,db", "hello world") - assert @shell.read_and_execute - end - - def test_task_command_with_bang_gets_processed_by_exec_tasks - while_testing_post_exec_commands do - @shell.expects(:read_line).returns("!deploy") - @shell.expects(:exec_tasks).with(["deploy"]) - assert @shell.read_and_execute - end - end - - def test_normal_command_gets_processed_by_exec_command - while_testing_post_exec_commands do - @shell.expects(:read_line).returns("uptime") - @shell.expects(:exec_command).with("uptime",nil) - @shell.expects(:connect) - assert @shell.read_and_execute - end - end - - - private - - def while_testing_post_exec_commands(&block) - @shell.instance_variable_set(:@mutex,Mutex.new) - yield - end - -end diff --git a/vendor/gems/capistrano-2.5.9/test/ssh_test.rb b/vendor/gems/capistrano-2.5.9/test/ssh_test.rb deleted file mode 100644 index 774c9a6b8..000000000 --- a/vendor/gems/capistrano-2.5.9/test/ssh_test.rb +++ /dev/null @@ -1,104 +0,0 @@ -require "utils" -require 'capistrano/ssh' - -class SSHTest < Test::Unit::TestCase - def setup - Capistrano::ServerDefinition.stubs(:default_user).returns("default-user") - @options = { :password => nil, - :auth_methods => %w(publickey hostbased), - :config => false } - @server = server("capistrano") - Net::SSH.stubs(:configuration_for).returns({}) - end - - def test_connect_with_bare_server_without_options_or_config_with_public_key_succeeding_should_only_loop_once - Net::SSH.expects(:start).with(@server.host, "default-user", @options).returns(success = Object.new) - assert_equal success, Capistrano::SSH.connect(@server) - end - - def test_connect_with_bare_server_without_options_with_public_key_failing_should_try_password - Net::SSH.expects(:start).with(@server.host, "default-user", @options).raises(Net::SSH::AuthenticationFailed) - Net::SSH.expects(:start).with(@server.host, "default-user", @options.merge(:password => "f4b13n", :auth_methods => %w(password keyboard-interactive))).returns(success = Object.new) - assert_equal success, Capistrano::SSH.connect(@server, :password => "f4b13n") - end - - def test_connect_with_bare_server_without_options_public_key_and_password_failing_should_raise_error - Net::SSH.expects(:start).with(@server.host, "default-user", @options).raises(Net::SSH::AuthenticationFailed) - Net::SSH.expects(:start).with(@server.host, "default-user", @options.merge(:password => "f4b13n", :auth_methods => %w(password keyboard-interactive))).raises(Net::SSH::AuthenticationFailed) - assert_raises(Net::SSH::AuthenticationFailed) do - Capistrano::SSH.connect(@server, :password => "f4b13n") - end - end - - def test_connect_with_bare_server_and_user_via_public_key_should_pass_user_to_net_ssh - Net::SSH.expects(:start).with(@server.host, "jamis", @options).returns(success = Object.new) - assert_equal success, Capistrano::SSH.connect(@server, :user => "jamis") - end - - def test_connect_with_bare_server_and_user_via_password_should_pass_user_to_net_ssh - Net::SSH.expects(:start).with(@server.host, "jamis", @options).raises(Net::SSH::AuthenticationFailed) - Net::SSH.expects(:start).with(@server.host, "jamis", @options.merge(:password => "f4b13n", :auth_methods => %w(password keyboard-interactive))).returns(success = Object.new) - assert_equal success, Capistrano::SSH.connect(@server, :user => "jamis", :password => "f4b13n") - end - - def test_connect_with_bare_server_with_explicit_port_should_pass_port_to_net_ssh - Net::SSH.expects(:start).with(@server.host, "default-user", @options.merge(:port => 1234)).returns(success = Object.new) - assert_equal success, Capistrano::SSH.connect(@server, :port => 1234) - end - - def test_connect_with_server_with_user_should_pass_user_to_net_ssh - server = server("jamis@capistrano") - Net::SSH.expects(:start).with(server.host, "jamis", @options).returns(success = Object.new) - assert_equal success, Capistrano::SSH.connect(server) - end - - def test_connect_with_server_with_port_should_pass_port_to_net_ssh - server = server("capistrano:1235") - Net::SSH.expects(:start).with(server.host, "default-user", @options.merge(:port => 1235)).returns(success = Object.new) - assert_equal success, Capistrano::SSH.connect(server) - end - - def test_connect_with_server_with_user_and_port_should_pass_user_and_port_to_net_ssh - server = server("jamis@capistrano:1235") - Net::SSH.expects(:start).with(server.host, "jamis", @options.merge(:port => 1235)).returns(success = Object.new) - assert_equal success, Capistrano::SSH.connect(server) - end - - def test_connect_with_server_with_other_ssh_options_should_pass_ssh_options_to_net_ssh - server = server("jamis@capistrano:1235", :ssh_options => { :keys => %w(some_valid_key), :auth_methods => %w(a_method), :hmac => 'none' }) - Net::SSH.expects(:start).with(server.host, "jamis", @options.merge(:port => 1235, :keys => %w(some_valid_key), :auth_methods => %w(a_method), :hmac => 'none' )).returns(success = Object.new) - assert_equal success, Capistrano::SSH.connect(server) - end - - def test_connect_with_ssh_options_should_use_ssh_options - ssh_options = { :username => "JamisMan", :port => 8125, :config => false } - Net::SSH.expects(:start).with(@server.host, "JamisMan", @options.merge(:port => 8125, :config => false)).returns(success = Object.new) - assert_equal success, Capistrano::SSH.connect(@server, {:ssh_options => ssh_options}) - end - - def test_connect_with_options_and_ssh_options_should_see_options_override_ssh_options - ssh_options = { :username => "JamisMan", :port => 8125, :forward_agent => true } - Net::SSH.expects(:start).with(@server.host, "jamis", @options.merge(:port => 1235, :forward_agent => true)).returns(success = Object.new) - assert_equal success, Capistrano::SSH.connect(@server, :ssh_options => ssh_options, :user => "jamis", :port => 1235) - end - - def test_connect_with_ssh_options_should_see_server_options_override_ssh_options - ssh_options = { :username => "JamisMan", :port => 8125, :forward_agent => true } - server = server("jamis@capistrano:1235") - Net::SSH.expects(:start).with(server.host, "jamis", @options.merge(:port => 1235, :forward_agent => true, :config => false)).returns(success = Object.new) - assert_equal success, Capistrano::SSH.connect(server, {:ssh_options => ssh_options}) - end - - def test_connect_should_add_xserver_accessor_to_connection - Net::SSH.expects(:start).with(@server.host, "default-user", @options).returns(success = Object.new) - assert_equal success, Capistrano::SSH.connect(@server) - assert success.respond_to?(:xserver) - assert success.respond_to?(:xserver) - assert_equal success.xserver, @server - end - - def test_connect_should_not_retry_if_custom_auth_methods_are_given - Net::SSH.expects(:start).with(@server.host, "default-user", @options.merge(:auth_methods => %w(publickey))).raises(Net::SSH::AuthenticationFailed) - assert_raises(Net::SSH::AuthenticationFailed) { Capistrano::SSH.connect(@server, :ssh_options => { :auth_methods => %w(publickey) }) } - end -end diff --git a/vendor/gems/capistrano-2.5.9/test/task_definition_test.rb b/vendor/gems/capistrano-2.5.9/test/task_definition_test.rb deleted file mode 100644 index d89f97731..000000000 --- a/vendor/gems/capistrano-2.5.9/test/task_definition_test.rb +++ /dev/null @@ -1,101 +0,0 @@ -require "utils" -require 'capistrano/task_definition' - -class TaskDefinitionTest < Test::Unit::TestCase - def setup - @namespace = namespace - end - - def test_fqn_at_top_level_should_be_task_name - task = new_task(:testing) - assert_equal "testing", task.fully_qualified_name - end - - def test_fqn_in_namespace_should_include_namespace_fqn - ns = namespace("outer:inner") - task = new_task(:testing, ns) - assert_equal "outer:inner:testing", task.fully_qualified_name - end - - def test_fqn_at_top_level_when_default_should_be_default - task = new_task(:default) - assert_equal "default", task.fully_qualified_name - end - - def test_fqn_in_namespace_when_default_should_be_namespace_fqn - ns = namespace("outer:inner") - task = new_task(:default, ns) - ns.stubs(:default_task => task) - assert_equal "outer:inner", task.fully_qualified_name - end - - def test_task_should_require_block - assert_raises(ArgumentError) do - Capistrano::TaskDefinition.new(:testing, @namespace) - end - end - - def test_description_should_return_empty_string_if_not_given - assert_equal "", new_task(:testing).description - end - - def test_description_should_return_desc_attribute - assert_equal "something", new_task(:testing, @namespace, :desc => "something").description - end - - def test_description_should_strip_leading_and_trailing_whitespace - assert_equal "something", new_task(:testing, @namespace, :desc => " something ").description - end - - def test_description_should_normalize_newlines - assert_equal "a\nb\nc", new_task(:testing, @namespace, :desc => "a\nb\r\nc").description - end - - def test_description_should_detect_and_remove_indentation - desc = <<-DESC - Here is some indented text \ - and I want all of this to \ - run together on a single line, \ - without any extraneous spaces. - - additional indentation will - be preserved. - DESC - - task = new_task(:testing, @namespace, :desc => desc) - assert_equal "Here is some indented text and I want all of this to run together on a single line, without any extraneous spaces.\n\n additional indentation will\n be preserved.", task.description - end - - def test_description_munging_should_be_sensitive_to_code_blocks - desc = <<-DESC - Here is a line \ - wrapped with spacing in it. - - foo bar - baz bang - DESC - - task = new_task(:testing, @namespace, :desc => desc) - assert_equal "Here is a line wrapped with spacing in it.\n\n foo bar\n baz bang", task.description - end - - def test_brief_description_should_return_first_sentence_in_description - desc = "This is the task. It does all kinds of things." - task = new_task(:testing, @namespace, :desc => desc) - assert_equal "This is the task.", task.brief_description - end - - def test_brief_description_should_truncate_if_length_given - desc = "This is the task that does all kinds of things. And then some." - task = new_task(:testing, @namespace, :desc => desc) - assert_equal "This is the task ...", task.brief_description(20) - end - - def test_brief_description_should_not_break_at_period_in_middle_of_sentence - task = new_task(:testing, @namespace, :desc => "Take file.txt and copy it.") - assert_equal "Take file.txt and copy it.", task.brief_description - - task = new_task(:testing, @namespace, :desc => "Take file.txt and copy it. Then do something else.") - assert_equal "Take file.txt and copy it.", task.brief_description - end -end \ No newline at end of file diff --git a/vendor/gems/capistrano-2.5.9/test/transfer_test.rb b/vendor/gems/capistrano-2.5.9/test/transfer_test.rb deleted file mode 100644 index f98c44b27..000000000 --- a/vendor/gems/capistrano-2.5.9/test/transfer_test.rb +++ /dev/null @@ -1,160 +0,0 @@ -require 'utils' -require 'capistrano/transfer' - -class TransferTest < Test::Unit::TestCase - def test_class_process_should_delegate_to_instance_process - Capistrano::Transfer.expects(:new).with(:up, "from", "to", %w(a b c), {}).returns(mock('transfer', :process! => nil)).yields - yielded = false - Capistrano::Transfer.process(:up, "from", "to", %w(a b c), {}) { yielded = true } - assert yielded - end - - def test_default_transport_is_sftp - transfer = Capistrano::Transfer.new(:up, "from", "to", []) - assert_equal :sftp, transfer.transport - end - - def test_active_is_true_when_any_sftp_transfers_are_active - returns = [false, false, true] - sessions = [session('app1', :sftp), session('app2', :sftp), session('app3', :sftp)].each { |s| s.xsftp.expects(:upload).returns(stub('operation', :active? => returns.shift)) } - transfer = Capistrano::Transfer.new(:up, "from", "to", sessions, :via => :sftp) - assert_equal true, transfer.active? - end - - def test_active_is_false_when_all_sftp_transfers_are_not_active - sessions = [session('app1', :sftp), session('app2', :sftp)].each { |s| s.xsftp.expects(:upload).returns(stub('operation', :active? => false)) } - transfer = Capistrano::Transfer.new(:up, "from", "to", sessions, :via => :sftp) - assert_equal false, transfer.active? - end - - def test_active_is_true_when_any_scp_transfers_are_active - returns = [false, false, true] - sessions = [session('app1', :scp), session('app2', :scp), session('app3', :scp)].each do |s| - channel = stub('channel', :[]= => nil, :active? => returns.shift) - s.scp.expects(:upload).returns(channel) - end - transfer = Capistrano::Transfer.new(:up, "from", "to", sessions, :via => :scp) - assert_equal true, transfer.active? - end - - def test_active_is_false_when_all_scp_transfers_are_not_active - sessions = [session('app1', :scp), session('app2', :scp), session('app3', :scp)].each do |s| - channel = stub('channel', :[]= => nil, :active? => false) - s.scp.expects(:upload).returns(channel) - end - transfer = Capistrano::Transfer.new(:up, "from", "to", sessions, :via => :scp) - assert_equal false, transfer.active? - end - - [:up, :down].each do |direction| - define_method("test_sftp_#{direction}load_from_file_to_file_should_normalize_from_and_to") do - sessions = [session('app1', :sftp), session('app2', :sftp)] - - sessions.each do |session| - session.xsftp.expects("#{direction}load".to_sym).with("from-#{session.xserver.host}", "to-#{session.xserver.host}", - :properties => { :server => session.xserver, :host => session.xserver.host }) - end - - transfer = Capistrano::Transfer.new(direction, "from-$CAPISTRANO:HOST$", "to-$CAPISTRANO:HOST$", sessions) - end - - define_method("test_scp_#{direction}load_from_file_to_file_should_normalize_from_and_to") do - sessions = [session('app1', :scp), session('app2', :scp)] - - sessions.each do |session| - session.scp.expects("#{direction}load".to_sym).returns({}).with("from-#{session.xserver.host}", "to-#{session.xserver.host}", :via => :scp) - end - - transfer = Capistrano::Transfer.new(direction, "from-$CAPISTRANO:HOST$", "to-$CAPISTRANO:HOST$", sessions, :via => :scp) - end - end - - def test_sftp_upload_from_IO_to_file_should_clone_the_IO_for_each_connection - sessions = [session('app1', :sftp), session('app2', :sftp)] - io = StringIO.new("from here") - - sessions.each do |session| - session.xsftp.expects(:upload).with do |from, to, opts| - from != io && from.is_a?(StringIO) && from.string == io.string && - to == "/to/here-#{session.xserver.host}" && - opts[:properties][:server] == session.xserver && - opts[:properties][:host] == session.xserver.host - end - end - - transfer = Capistrano::Transfer.new(:up, StringIO.new("from here"), "/to/here-$CAPISTRANO:HOST$", sessions) - end - - def test_scp_upload_from_IO_to_file_should_clone_the_IO_for_each_connection - sessions = [session('app1', :scp), session('app2', :scp)] - io = StringIO.new("from here") - - sessions.each do |session| - channel = mock('channel') - channel.expects(:[]=).with(:server, session.xserver) - channel.expects(:[]=).with(:host, session.xserver.host) - session.scp.expects(:upload).returns(channel).with do |from, to, opts| - from != io && from.is_a?(StringIO) && from.string == io.string && - to == "/to/here-#{session.xserver.host}" - end - end - - transfer = Capistrano::Transfer.new(:up, StringIO.new("from here"), "/to/here-$CAPISTRANO:HOST$", sessions, :via => :scp) - end - - def test_process_should_block_until_transfer_is_no_longer_active - transfer = Capistrano::Transfer.new(:up, "from", "to", []) - transfer.expects(:process_iteration).times(4).yields.returns(true,true,true,false) - transfer.expects(:active?).times(4) - transfer.process! - end - - def test_errors_raised_for_a_sftp_session_should_abort_session_and_continue_with_remaining_sessions - s = session('app1') - error = ExceptionWithSession.new(s) - transfer = Capistrano::Transfer.new(:up, "from", "to", []) - transfer.expects(:process_iteration).raises(error).times(3).returns(true, false) - txfr = mock('transfer', :abort! => true) - txfr.expects(:[]=).with(:failed, true) - txfr.expects(:[]=).with(:error, error) - transfer.expects(:session_map).returns(s => txfr) - transfer.process! - end - - def test_errors_raised_for_a_scp_session_should_abort_session_and_continue_with_remaining_sessions - s = session('app1') - error = ExceptionWithSession.new(s) - transfer = Capistrano::Transfer.new(:up, "from", "to", [], :via => :scp) - transfer.expects(:process_iteration).raises(error).times(3).returns(true, false) - txfr = mock('channel', :close => true) - txfr.expects(:[]=).with(:failed, true) - txfr.expects(:[]=).with(:error, error) - transfer.expects(:session_map).returns(s => txfr) - transfer.process! - end - - private - - class ExceptionWithSession < ::Exception - attr_reader :session - - def initialize(session) - @session = session - super() - end - end - - def session(host, mode=nil) - session = stub('session', :xserver => stub('server', :host => host)) - case mode - when :sftp - sftp = stub('sftp') - session.expects(:sftp).with(false).returns(sftp) - sftp.expects(:connect).yields(sftp).returns(sftp) - session.stubs(:xsftp).returns(sftp) - when :scp - session.stubs(:scp).returns(stub('scp')) - end - session - end -end \ No newline at end of file diff --git a/vendor/gems/capistrano-2.5.9/test/utils.rb b/vendor/gems/capistrano-2.5.9/test/utils.rb deleted file mode 100644 index 857b7378a..000000000 --- a/vendor/gems/capistrano-2.5.9/test/utils.rb +++ /dev/null @@ -1,38 +0,0 @@ -begin - require 'rubygems' - gem 'mocha' -rescue LoadError -end - -require 'test/unit' -require 'mocha' -require 'capistrano/server_definition' - -module TestExtensions - def server(host, options={}) - Capistrano::ServerDefinition.new(host, options) - end - - def namespace(fqn=nil) - space = stub(:roles => {}, :fully_qualified_name => fqn, :default_task => nil) - yield(space) if block_given? - space - end - - def role(space, name, *args) - opts = args.last.is_a?(Hash) ? args.pop : {} - space.roles[name] ||= [] - space.roles[name].concat(args.map { |h| Capistrano::ServerDefinition.new(h, opts) }) - end - - def new_task(name, namespace=@namespace, options={}, &block) - block ||= Proc.new {} - task = Capistrano::TaskDefinition.new(name, namespace, options, &block) - assert_equal block, task.body - return task - end -end - -class Test::Unit::TestCase - include TestExtensions -end diff --git a/vendor/gems/highline-1.5.1/.specification b/vendor/gems/highline-1.5.1/.specification deleted file mode 100644 index a4b9ffc02..000000000 --- a/vendor/gems/highline-1.5.1/.specification +++ /dev/null @@ -1,91 +0,0 @@ ---- !ruby/object:Gem::Specification -name: highline -version: !ruby/object:Gem::Version - version: 1.5.1 -platform: ruby -authors: -- James Edward Gray II -autorequire: -bindir: bin -cert_chain: [] - -date: 2009-05-07 00:00:00 +00:00 -default_executable: -dependencies: [] - -description: A high-level IO library that provides validation, type conversion, and more for command-line interfaces. HighLine also includes a complete menu system that can crank out anything from simple list selection to complete shells with just minutes of work. -email: james@grayproductions.net -executables: [] - -extensions: [] - -extra_rdoc_files: -- README -- INSTALL -- TODO -- CHANGELOG -- LICENSE -files: -- examples/ansi_colors.rb -- examples/asking_for_arrays.rb -- examples/basic_usage.rb -- examples/color_scheme.rb -- examples/limit.rb -- examples/menus.rb -- examples/overwrite.rb -- examples/page_and_wrap.rb -- examples/password.rb -- examples/trapping_eof.rb -- examples/using_readline.rb -- lib/highline/color_scheme.rb -- lib/highline/compatibility.rb -- lib/highline/import.rb -- lib/highline/menu.rb -- lib/highline/question.rb -- lib/highline/system_extensions.rb -- lib/highline.rb -- test/tc_color_scheme.rb -- test/tc_highline.rb -- test/tc_import.rb -- test/tc_menu.rb -- test/ts_all.rb -- Rakefile -- setup.rb -- README -- INSTALL -- TODO -- CHANGELOG -- LICENSE -has_rdoc: true -homepage: http://highline.rubyforge.org -licenses: [] - -post_install_message: -rdoc_options: -- --title -- HighLine Documentation -- --main -- README -require_paths: -- lib -required_ruby_version: !ruby/object:Gem::Requirement - requirements: - - - ">=" - - !ruby/object:Gem::Version - version: "0" - version: -required_rubygems_version: !ruby/object:Gem::Requirement - requirements: - - - ">=" - - !ruby/object:Gem::Version - version: "0" - version: -requirements: [] - -rubyforge_project: highline -rubygems_version: 1.3.4 -signing_key: -specification_version: 2 -summary: HighLine is a high-level command-line IO library. -test_files: -- test/ts_all.rb diff --git a/vendor/gems/highline-1.5.1/CHANGELOG b/vendor/gems/highline-1.5.1/CHANGELOG deleted file mode 100644 index efb043db9..000000000 --- a/vendor/gems/highline-1.5.1/CHANGELOG +++ /dev/null @@ -1,222 +0,0 @@ -= Change Log - -Below is a complete listing of changes for each revision of HighLine. - -== 1.5.1 - -* Fixed the long standing echo true bug. - (reported by Lauri Tuominen) -* Improved Windows API calls to support the redirection of STDIN. - (patch by Aaron Simmons) -* Updated gem specification to avoid a deprecated call. -* Made a minor documentation clarification about character mode support. -* Worked around some API changes in Ruby's standard library in Ruby 1.9. - (patch by Jake Benilov) - -== 1.5.0 - -* Fixed a bug that would prevent Readline from showing all completions. - (reported by Yaohan Chen) -* Added the ability to pass a block to HighLine#agree(). - (patch by Yaohan Chen) - -== 1.4.0 - -* Made the code grabbing terminal size a little more cross-platform by - adding support for Solaris. (patch by Ronald Braswell and Coey Minear) - -== 1.2.9 - -* Additional work on the backspacing issue. (patch by Jeremy Hinegardner) -* Fixed Readline prompt bug. (patch by Jeremy Hinegardner) - -== 1.2.8 - -* Fixed backspacing past the prompt and interrupting a prompt bugs. - (patch by Jeremy Hinegardner) - -== 1.2.7 - -* Fixed the stty indent bug. -* Fixed the echo backspace bug. -* Added HighLine::track_eof=() setting to work are threaded eof?() calls. - -== 1.2.6 - -Patch by Jeremy Hinegardner: - -* Added ColorScheme support. -* Added HighLine::Question.overwrite mode. -* Various documentation fixes. - -== 1.2.5 - -* Really fixed the bug I tried to fix in 1.2.4. - -== 1.2.4 - -* Fixed a crash causing bug when using menus, reported by Patrick Hof. - -== 1.2.3 - -* Treat Cygwin like a Posix OS, instead of a native Windows environment. - -== 1.2.2 - -* Minor documentation corrections. -* Applied Thomas Werschleiln's patch to fix termio buffering on Solaris. -* Applied Justin Bailey's patch to allow canceling paged output. -* Fixed a documentation bug in the description of character case settings. -* Added a notice about termios in HighLine::Question#echo. -* Finally working around the infamous "fast typing" bug - -== 1.2.1 - -* Applied Justin Bailey's fix for the page_print() infinite loop bug. -* Made a SystemExtensions module to expose OS level functionality other - libraries may want to access. -* Publicly exposed the get_character() method, per user requests. -* Added terminal_size(), output_cols(), and output_rows() methods. -* Added :auto setting for warp_at=() and page_at=(). - -== 1.2.0 - -* Improved RubyForge and gem spec project descriptions. -* Added basic examples to README. -* Added a VERSION constant. -* Added support for hidden menu commands. -* Added Object.or_ask() when using highline/import. - -== 1.0.4 - -* Moved the HighLine project to Subversion. -* HighLine's color escapes can now be disabled. -* Fixed EOF bug introduced in the last release. -* Updated HighLine web page. -* Moved to a forked development/stable version numbering. - -== 1.0.2 - -* Removed old and broken help tests. -* Fixed test case typo found by David A. Black. -* Added ERb escapes processing to lists, for coloring list items. Color escapes - do not add to list element size. -* HighLine now throws EOFError when input is exhausted. - -== 1.0.1 - -* Minor bug fix: Moved help initialization to before response building, so help - would show up in the default responses. - -== 1.0.0 - -* Fixed documentation typo pointed out by Gavin Kistner. -* Added gather = ... option to question for fetching entire Arrays or - Hashes filled with answers. You can set +gather+ to a count of answers to - collect, a String or Regexp matching the end of input, or a Hash where each - key can be used in a new question. -* Added File support to HighLine.ask(). You can specify a _directory_ and a - _glob_ pattern that combine into a list of file choices the user can select - from. You can choose to receive the user's answer as an open filehandle or as - a Pathname object. -* Added Readline support for history and editing. -* Added tab completion for menu and file selection selection (requires - Readline). -* Added an optional character limit for input. -* Added a complete help system to HighLine's shell menu creation tools. - -== 0.6.1 - -* Removed termios dependancy in gem, to fix Windows' install. - -== 0.6.0 - -* Implemented HighLine.choose() for menu handling. - * Provided shortcut choose(item1, item2, ...) for simple menus. - * Allowed Ruby code to be attached to each menu item, to create a complete - menu solution. - * Provided for total customization of the menu layout. - * Allowed for menu selection by index, name or both. - * Added a _shell_ mode to allow menu selection with additional details - following the name. -* Added a list() utility method that can be invoked just like color(). It can - layout Arrays for you in any output in the modes :columns_across, - :columns_down, :inline and :rows -* Added support for echo = "*" style settings. User code can now - choose the echo character this way. -* Modified HighLine to user the "termios" library for character input, if - available. Will return to old behavior (using "stty"), if "termios" cannot be - loaded. -* Improved "stty" state restoring code. -* Fixed "stty" code to handle interrupt signals. -* Improved the default auto-complete error message and exposed this message - through the +responses+ interface as :no_completion. - -== 0.5.0 - -* Implemented echo = false for HighLine::Question objects, primarily to - make fetching passwords trivial. -* Fixed an auto-complete bug that could cause a crash when the user gave an - answer that didn't complete to any valid choice. -* Implemented +case+ for HighLine::Question objects to provide character case - conversions on given answers. Can be set to :up, :down, or - :capitalize. -* Exposed @answer to the response system, to allow response that are - aware of incorrect input. -* Implemented +confirm+ for HighLine::Question objects to allow for verification - for sensitive user choices. If set to +true+, user will have to answer an - "Are you sure? " question. Can also be set to the question to confirm with - the user. - -== 0.4.0 - -* Added @wrap_at and @page_at settings and accessors to - HighLine, to control text flow. -* Implemented line wrapping with adjustable limit. -* Implemented paged printing with adjustable limit. - -== 0.3.0 - -* Added support for installing with setup.rb. -* All output is now treated as an ERb sequence, allowing Ruby code to be - embedded in output strings. -* Added support for ANSI color sequences in say(). (And everything else - by extension.) -* Added whitespace handling for answers. Can be set to :strip, - :chomp, :collapse, :strip_and_collapse, - :chomp_and_collapse, :remove, or :none. -* Exposed question details to ERb completion through @question, to allow for - intelligent responses. -* Simplified HighLine internals using @question. -* Added support for fetching single character input either with getc() or - HighLine's own cross-platform terminal input routine. -* Improved type conversion to handle user defined classes. - -== 0.2.0 - -* Added Unit Tests to cover an already fixed output bug in the future. -* Added Rakefile and setup test action (default). -* Renamed HighLine::Answer to HighLine::Question to better illustrate its role. -* Renamed fetch_line() to get_response() to better define its goal. -* Simplified explain_error in terms of the Question object. -* Renamed accept?() to in_range?() to better define purpose. -* Reworked valid?() into valid_answer?() to better fit Question object. -* Reworked @member into @in, to make it easier to remember and - switched implementation to include?(). -* Added range checks for @above and @below. -* Fixed the bug causing ask() to swallow NoMethodErrors. -* Rolled ask_on_error() into responses. -* Redirected imports to Kernel from Object. -* Added support for validate = lambda { ... }. -* Added default answer support. -* Fixed bug that caused ask() to die with an empty question. -* Added complete documentation. -* Improve the implemetation of agree() to be the intended "yes" or "no" only - question. -* Added Rake tasks for documentation and packaging. -* Moved project to RubyForge. - -== 0.1.0 - -* Initial release as the solution to - {Ruby Quiz #29}[http://www.rubyquiz.com/quiz29.html]. diff --git a/vendor/gems/highline-1.5.1/INSTALL b/vendor/gems/highline-1.5.1/INSTALL deleted file mode 100644 index c22f04143..000000000 --- a/vendor/gems/highline-1.5.1/INSTALL +++ /dev/null @@ -1,35 +0,0 @@ -= Installing HighLine - -RubyGems is the preferred easy install method for HighLine. However, you can -install HighLine manually as described below. - -== Installing the Gem - -HighLine is intended to be installed via the -RubyGems[http://rubyforge.org/projects/rubygems/] system. To get the latest -version, simply enter the following into your command prompt: - - $ sudo gem install highline - -You must have RubyGems[http://rubyforge.org/projects/rubygems/] installed for -the above to work. - -== Installing Manually - -Download the latest version of HighLine from the -{RubyForge project page}[http://rubyforge.org/frs/?group_id=683]. Navigate to -the root project directory and enter: - - $ sudo ruby setup.rb - -== Using termios - -While not a requirement, HighLine will take advantage of the termios library if -installed (on Unix). This slightly improves HighLine's character reading -capabilities and thus is recommended for all Unix users. - -If using the HighLine gem, you should be able to add termios as easily as: - - $ sudo gem install termios - -For manual installs, consult the termios documentation. diff --git a/vendor/gems/highline-1.5.1/LICENSE b/vendor/gems/highline-1.5.1/LICENSE deleted file mode 100644 index ff6f232c8..000000000 --- a/vendor/gems/highline-1.5.1/LICENSE +++ /dev/null @@ -1,7 +0,0 @@ -= License Terms - -Distributed under the user's choice of the {GPL Version 2}[http://www.gnu.org/licenses/old-licenses/gpl-2.0.html] (see COPYING for details) or the -{Ruby software license}[http://www.ruby-lang.org/en/LICENSE.txt] by -James Edward Gray II and Greg Brown. - -Please email James[mailto:james@grayproductions.net] with any questions. diff --git a/vendor/gems/highline-1.5.1/README b/vendor/gems/highline-1.5.1/README deleted file mode 100644 index f28478bb2..000000000 --- a/vendor/gems/highline-1.5.1/README +++ /dev/null @@ -1,63 +0,0 @@ -= Read Me - -by James Edward Gray II - -== Description - -Welcome to HighLine. - -HighLine was designed to ease the tedious tasks of doing console input and -output with low-level methods like gets() and puts(). HighLine provides a -robust system for requesting data from a user, without needing to code all the -error checking and validation rules and without needing to convert the typed -Strings into what your program really needs. Just tell HighLine what you're -after, and let it do all the work. - -== Documentation - -See HighLine and HighLine::Question for documentation. - -== Examples - -Basic usage: - - ask("Company? ") { |q| q.default = "none" } - -Validation: - - ask("Age? ", Integer) { |q| q.in = 0..105 } - ask("Name? (last, first) ") { |q| q.validate = /\A\w+, ?\w+\Z/ } - -Type conversion for answers: - - ask("Birthday? ", Date) - ask("Interests? (comma sep list) ", lambda { |str| str.split(/,\s*/) }) - -Reading passwords: - - ask("Enter your password: ") { |q| q.echo = false } - ask("Enter your password: ") { |q| q.echo = "x" } - -ERb based output (with HighLine's ANSI color tools): - - say("This should be <%= color('bold', BOLD) %>!") - -Menus: - - choose do |menu| - menu.prompt = "Please choose your favorite programming language? " - - menu.choice(:ruby) { say("Good choice!") } - menu.choices(:python, :perl) { say("Not from around here, are you?") } - end - -For more examples see the examples/ directory of this project. - -== Installing - -See the INSTALL file for instructions. - -== Questions and/or Comments - -Feel free to email {James Edward Gray II}[mailto:james@grayproductions.net] or -{Gregory Brown}[mailto:gregory.t.brown@gmail.com] with any questions. diff --git a/vendor/gems/highline-1.5.1/Rakefile b/vendor/gems/highline-1.5.1/Rakefile deleted file mode 100644 index 5c74b161e..000000000 --- a/vendor/gems/highline-1.5.1/Rakefile +++ /dev/null @@ -1,82 +0,0 @@ -require "rake/rdoctask" -require "rake/testtask" -require "rake/gempackagetask" - -require "rubygems" - -dir = File.dirname(__FILE__) -lib = File.join(dir, "lib", "highline.rb") -version = File.read(lib)[/^\s*VERSION\s*=\s*(['"])(\d\.\d\.\d)\1/, 2] - -task :default => [:test] - -Rake::TestTask.new do |test| - test.libs << "test" - test.test_files = [ "test/ts_all.rb" ] - test.verbose = true -end - -Rake::RDocTask.new do |rdoc| - rdoc.rdoc_files.include( "README", "INSTALL", - "TODO", "CHANGELOG", - "AUTHORS", "COPYING", - "LICENSE", "lib/" ) - rdoc.main = "README" - rdoc.rdoc_dir = "doc/html" - rdoc.title = "HighLine Documentation" -end - -desc "Upload current documentation to Rubyforge" -task :upload_docs => [:rdoc] do - sh "scp -r doc/html/* " + - "bbazzarrakk@rubyforge.org:/var/www/gforge-projects/highline/doc/" - sh "scp -r site/* " + - "bbazzarrakk@rubyforge.org:/var/www/gforge-projects/highline/" -end - -spec = Gem::Specification.new do |spec| - spec.name = "highline" - spec.version = version - spec.platform = Gem::Platform::RUBY - spec.summary = "HighLine is a high-level command-line IO library." - spec.files = Dir.glob("{examples,lib,test}/**/*.rb"). - delete_if { |item| item.include?("CVS") } + - ["Rakefile", "setup.rb"] - - spec.test_files = "test/ts_all.rb" - spec.has_rdoc = true - spec.extra_rdoc_files = %w{README INSTALL TODO CHANGELOG LICENSE} - spec.rdoc_options << '--title' << 'HighLine Documentation' << - '--main' << 'README' - - spec.require_path = 'lib' - - spec.author = "James Edward Gray II" - spec.email = "james@grayproductions.net" - spec.rubyforge_project = "highline" - spec.homepage = "http://highline.rubyforge.org" - spec.description = <!") - if i == 0 - say( "This should be " + - "<%= color('white on #{c}', :white, :on_#{c}) %>!") - else - say( "This should be " + - "<%= color( '#{colors[i - 1]} on #{c}', - :#{colors[i - 1]}, :on_#{c} ) %>!") - end -end - -# Using color with constants. -say("This should be <%= color('bold', BOLD) %>!") -say("This should be <%= color('underlined', UNDERLINE) %>!") - -# Using constants only. -say("This might even <%= BLINK %>blink<%= CLEAR %>!") - -# It even works with list wrapping. -erb_digits = %w{Zero One Two Three Four} + - ["<%= color('Five', :blue) %%>"] + - %w{Six Seven Eight Nine} -say("<%= list(#{erb_digits.inspect}, :columns_down, 3) %>") diff --git a/vendor/gems/highline-1.5.1/examples/asking_for_arrays.rb b/vendor/gems/highline-1.5.1/examples/asking_for_arrays.rb deleted file mode 100644 index 6c62a0e4a..000000000 --- a/vendor/gems/highline-1.5.1/examples/asking_for_arrays.rb +++ /dev/null @@ -1,18 +0,0 @@ -#!/usr/local/bin/ruby -w - -# asking_for_arrays.rb -# -# Created by James Edward Gray II on 2005-07-05. -# Copyright 2005 Gray Productions. All rights reserved. - -require "rubygems" -require "highline/import" -require "pp" - -grades = ask( "Enter test scores (or a blank line to quit):", - lambda { |ans| ans =~ /^-?\d+$/ ? Integer(ans) : ans} ) do |q| - q.gather = "" -end - -say("Grades:") -pp grades diff --git a/vendor/gems/highline-1.5.1/examples/basic_usage.rb b/vendor/gems/highline-1.5.1/examples/basic_usage.rb deleted file mode 100644 index 60ecdc180..000000000 --- a/vendor/gems/highline-1.5.1/examples/basic_usage.rb +++ /dev/null @@ -1,75 +0,0 @@ -#!/usr/local/bin/ruby -w - -# basic_usage.rb -# -# Created by James Edward Gray II on 2005-04-28. -# Copyright 2005 Gray Productions. All rights reserved. - -require "rubygems" -require "highline/import" -require "yaml" - -contacts = [ ] - -class NameClass - def self.parse( string ) - if string =~ /^\s*(\w+),\s*(\w+)\s*$/ - self.new($2, $1) - else - raise ArgumentError, "Invalid name format." - end - end - - def initialize(first, last) - @first, @last = first, last - end - - attr_reader :first, :last -end - -begin - entry = Hash.new - - # basic output - say("Enter a contact:") - - # basic input - entry[:name] = ask("Name? (last, first) ", NameClass) do |q| - q.validate = /\A\w+, ?\w+\Z/ - end - entry[:company] = ask("Company? ") { |q| q.default = "none" } - entry[:address] = ask("Address? ") - entry[:city] = ask("City? ") - entry[:state] = ask("State? ") do |q| - q.case = :up - q.validate = /\A[A-Z]{2}\Z/ - end - entry[:zip] = ask("Zip? ") do |q| - q.validate = /\A\d{5}(?:-?\d{4})?\Z/ - end - entry[:phone] = ask( "Phone? ", - lambda { |p| p.delete("^0-9"). - sub(/\A(\d{3})/, '(\1) '). - sub(/(\d{4})\Z/, '-\1') } ) do |q| - q.validate = lambda { |p| p.delete("^0-9").length == 10 } - q.responses[:not_valid] = "Enter a phone numer with area code." - end - entry[:age] = ask("Age? ", Integer) { |q| q.in = 0..105 } - entry[:birthday] = ask("Birthday? ", Date) - entry[:interests] = ask( "Interests? (comma separated list) ", - lambda { |str| str.split(/,\s*/) } ) - entry[:description] = ask("Enter a description for this contact.") do |q| - q.whitespace = :strip_and_collapse - end - - contacts << entry -# shortcut for yes and no questions -end while agree("Enter another contact? ", true) - -if agree("Save these contacts? ", true) - file_name = ask("Enter a file name: ") do |q| - q.validate = /\A\w+\Z/ - q.confirm = true - end - File.open("#{file_name}.yaml", "w") { |file| YAML.dump(contacts, file) } -end diff --git a/vendor/gems/highline-1.5.1/examples/color_scheme.rb b/vendor/gems/highline-1.5.1/examples/color_scheme.rb deleted file mode 100644 index 6d1e0a764..000000000 --- a/vendor/gems/highline-1.5.1/examples/color_scheme.rb +++ /dev/null @@ -1,32 +0,0 @@ -#!/usr/bin/env ruby -w - -# color_scheme.rb -# -# Created by Jeremy Hinegardner on 2007-01-24 -# Copyright 2007 Jeremy Hinegardner. All rights reserved - -require 'rubygems' -require 'highline/import' - -# Create a color scheme, naming color patterns with symbol names. -ft = HighLine::ColorScheme.new do |cs| - cs[:headline] = [ :bold, :yellow, :on_black ] - cs[:horizontal_line] = [ :bold, :white, :on_blue] - cs[:even_row] = [ :green ] - cs[:odd_row] = [ :magenta ] - end - -# Assign that color scheme to HighLine... -HighLine.color_scheme = ft - -# ...and use it. -say("<%= color('Headline', :headline) %>") -say("<%= color('-'*20, :horizontal_line) %>") - -# Setup a toggle for rows. -i = true -("A".."D").each do |row| - row_color = i ? :even_row : :odd_row - say("<%= color('#{row}', '#{row_color}') %>") - i = !i -end diff --git a/vendor/gems/highline-1.5.1/examples/limit.rb b/vendor/gems/highline-1.5.1/examples/limit.rb deleted file mode 100644 index a3813e5d9..000000000 --- a/vendor/gems/highline-1.5.1/examples/limit.rb +++ /dev/null @@ -1,12 +0,0 @@ -#!/usr/bin/env ruby -w - -# limit.rb -# -# Created by James Edward Gray II on 2008-11-12. -# Copyright 2008 Gray Productions. All rights reserved. - -require "rubygems" -require "highline/import" - -text = ask("Enter text (max 10 chars): ") { |q| q.limit = 10 } -puts "You entered: #{text}!" diff --git a/vendor/gems/highline-1.5.1/examples/menus.rb b/vendor/gems/highline-1.5.1/examples/menus.rb deleted file mode 100644 index e31c11df8..000000000 --- a/vendor/gems/highline-1.5.1/examples/menus.rb +++ /dev/null @@ -1,65 +0,0 @@ -#!/usr/local/bin/ruby -w - -require "rubygems" -require "highline/import" - -# The old way, using ask() and say()... -choices = %w{ruby python perl} -say("This is the old way using ask() and say()...") -say("Please choose your favorite programming language:") -say(choices.map { |c| " #{c}\n" }.join) - -case ask("? ", choices) -when "ruby" - say("Good choice!") -else - say("Not from around here, are you?") -end - -# The new and improved choose()... -say("\nThis is the new mode (default)...") -choose do |menu| - menu.prompt = "Please choose your favorite programming language? " - - menu.choice :ruby do say("Good choice!") end - menu.choices(:python, :perl) do say("Not from around here, are you?") end -end - -say("\nThis is letter indexing...") -choose do |menu| - menu.index = :letter - menu.index_suffix = ") " - - menu.prompt = "Please choose your favorite programming language? " - - menu.choice :ruby do say("Good choice!") end - menu.choices(:python, :perl) do say("Not from around here, are you?") end -end - -say("\nThis is with a different layout...") -choose do |menu| - menu.layout = :one_line - - menu.header = "Languages" - menu.prompt = "Favorite? " - - menu.choice :ruby do say("Good choice!") end - menu.choices(:python, :perl) do say("Not from around here, are you?") end -end - -say("\nYou can even build shells...") -loop do - choose do |menu| - menu.layout = :menu_only - - menu.shell = true - - menu.choice(:load, "Load a file.") do |command, details| - say("Loading file with options: #{details}...") - end - menu.choice(:save, "Save a file.") do |command, details| - say("Saving file with options: #{details}...") - end - menu.choice(:quit, "Exit program.") { exit } - end -end diff --git a/vendor/gems/highline-1.5.1/examples/overwrite.rb b/vendor/gems/highline-1.5.1/examples/overwrite.rb deleted file mode 100644 index 1ca2db52c..000000000 --- a/vendor/gems/highline-1.5.1/examples/overwrite.rb +++ /dev/null @@ -1,19 +0,0 @@ -#!/usr/local/bin/ruby -w - -# overwrite.rb -# -# Created by Jeremy Hinegardner on 2007-01-24 -# Copyright 2007 Jeremy Hinegardner. All rights reserved - -require 'rubygems' -require 'highline/import' - -prompt = "here is your password:" -ask( - "#{prompt} <%= color('mypassword', RED, BOLD) %> (Press Any Key to blank) " -) do |q| - q.overwrite = true - q.echo = false # overwrite works best when echo is false. - q.character = true # if this is set to :getc then overwrite does not work -end -say("<%= color('Look! blanked out!', GREEN) %>") diff --git a/vendor/gems/highline-1.5.1/examples/page_and_wrap.rb b/vendor/gems/highline-1.5.1/examples/page_and_wrap.rb deleted file mode 100644 index 3209a4ab1..000000000 --- a/vendor/gems/highline-1.5.1/examples/page_and_wrap.rb +++ /dev/null @@ -1,322 +0,0 @@ -#!/usr/local/bin/ruby -w - -# page_and_wrap.rb -# -# Created by James Edward Gray II on 2005-05-07. -# Copyright 2005 Gray Productions. All rights reserved. - -require "rubygems" -require "highline/import" - -$terminal.wrap_at = 80 -$terminal.page_at = 22 - -say(<@question is set before ask() is called, parameters are - # ignored and that object (must be a HighLine::Question) is used to drive - # the process instead. - # - # Raises EOFError if input is exhausted. - # - def ask( question, answer_type = String, &details ) # :yields: question - @question ||= Question.new(question, answer_type, &details) - - return gather if @question.gather - - # readline() needs to handle it's own output, but readline only supports - # full line reading. Therefore if @question.echo is anything but true, - # the prompt will not be issued. And we have to account for that now. - say(@question) unless (@question.readline and @question.echo == true) - begin - @answer = @question.answer_or_default(get_response) - unless @question.valid_answer?(@answer) - explain_error(:not_valid) - raise QuestionError - end - - @answer = @question.convert(@answer) - - if @question.in_range?(@answer) - if @question.confirm - # need to add a layer of scope to ask a question inside a - # question, without destroying instance data - context_change = self.class.new(@input, @output, @wrap_at, @page_at) - if @question.confirm == true - confirm_question = "Are you sure? " - else - # evaluate ERb under initial scope, so it will have - # access to @question and @answer - template = ERB.new(@question.confirm, nil, "%") - confirm_question = template.result(binding) - end - unless context_change.agree(confirm_question) - explain_error(nil) - raise QuestionError - end - end - - @answer - else - explain_error(:not_in_range) - raise QuestionError - end - rescue QuestionError - retry - rescue ArgumentError, NameError => error - raise if error.is_a?(NoMethodError) - if error.message =~ /ambiguous/ - # the assumption here is that OptionParser::Completion#complete - # (used for ambiguity resolution) throws exceptions containing - # the word 'ambiguous' whenever resolution fails - explain_error(:ambiguous_completion) - else - explain_error(:invalid_type) - end - retry - rescue Question::NoAutoCompleteMatch - explain_error(:no_completion) - retry - ensure - @question = nil # Reset Question object. - end - end - - # - # This method is HighLine's menu handler. For simple usage, you can just - # pass all the menu items you wish to display. At that point, choose() will - # build and display a menu, walk the user through selection, and return - # their choice amoung the provided items. You might use this in a case - # statement for quick and dirty menus. - # - # However, choose() is capable of much more. If provided, a block will be - # passed a HighLine::Menu object to configure. Using this method, you can - # customize all the details of menu handling from index display, to building - # a complete shell-like menuing system. See HighLine::Menu for all the - # methods it responds to. - # - # Raises EOFError if input is exhausted. - # - def choose( *items, &details ) - @menu = @question = Menu.new(&details) - @menu.choices(*items) unless items.empty? - - # Set _answer_type_ so we can double as the Question for ask(). - @menu.answer_type = if @menu.shell - lambda do |command| # shell-style selection - first_word = command.to_s.split.first || "" - - options = @menu.options - options.extend(OptionParser::Completion) - answer = options.complete(first_word) - - if answer.nil? - raise Question::NoAutoCompleteMatch - end - - [answer.last, command.sub(/^\s*#{first_word}\s*/, "")] - end - else - @menu.options # normal menu selection, by index or name - end - - # Provide hooks for ERb layouts. - @header = @menu.header - @prompt = @menu.prompt - - if @menu.shell - selected = ask("Ignored", @menu.answer_type) - @menu.select(self, *selected) - else - selected = ask("Ignored", @menu.answer_type) - @menu.select(self, selected) - end - end - - # - # This method provides easy access to ANSI color sequences, without the user - # needing to remember to CLEAR at the end of each sequence. Just pass the - # _string_ to color, followed by a list of _colors_ you would like it to be - # affected by. The _colors_ can be HighLine class constants, or symbols - # (:blue for BLUE, for example). A CLEAR will automatically be embedded to - # the end of the returned String. - # - # This method returns the original _string_ unchanged if HighLine::use_color? - # is +false+. - # - def color( string, *colors ) - return string unless self.class.use_color? - - colors.map! do |c| - if self.class.using_color_scheme? and self.class.color_scheme.include? c - self.class.color_scheme[c] - elsif c.is_a? Symbol - self.class.const_get(c.to_s.upcase) - else - c - end - end - "#{colors.flatten.join}#{string}#{CLEAR}" - end - - # - # This method is a utility for quickly and easily laying out lists. It can - # be accessed within ERb replacements of any text that will be sent to the - # user. - # - # The only required parameter is _items_, which should be the Array of items - # to list. A specified _mode_ controls how that list is formed and _option_ - # has different effects, depending on the _mode_. Recognized modes are: - # - # :columns_across:: _items_ will be placed in columns, flowing - # from left to right. If given, _option_ is the - # number of columns to be used. When absent, - # columns will be determined based on _wrap_at_ - # or a default of 80 characters. - # :columns_down:: Identical to :columns_across, save - # flow goes down. - # :inline:: All _items_ are placed on a single line. The - # last two _items_ are separated by _option_ or - # a default of " or ". All other _items_ are - # separated by ", ". - # :rows:: The default mode. Each of the _items_ is - # placed on it's own line. The _option_ - # parameter is ignored in this mode. - # - # Each member of the _items_ Array is passed through ERb and thus can contain - # their own expansions. Color escape expansions do not contribute to the - # final field width. - # - def list( items, mode = :rows, option = nil ) - items = items.to_ary.map do |item| - ERB.new(item, nil, "%").result(binding) - end - - case mode - when :inline - option = " or " if option.nil? - - case items.size - when 0 - "" - when 1 - items.first - when 2 - "#{items.first}#{option}#{items.last}" - else - items[0..-2].join(", ") + "#{option}#{items.last}" - end - when :columns_across, :columns_down - max_length = actual_length( - items.max { |a, b| actual_length(a) <=> actual_length(b) } - ) - - if option.nil? - limit = @wrap_at || 80 - option = (limit + 2) / (max_length + 2) - end - - items = items.map do |item| - pad = max_length + (item.length - actual_length(item)) - "%-#{pad}s" % item - end - row_count = (items.size / option.to_f).ceil - - if mode == :columns_across - rows = Array.new(row_count) { Array.new } - items.each_with_index do |item, index| - rows[index / option] << item - end - - rows.map { |row| row.join(" ") + "\n" }.join - else - columns = Array.new(option) { Array.new } - items.each_with_index do |item, index| - columns[index / row_count] << item - end - - list = "" - columns.first.size.times do |index| - list << columns.map { |column| column[index] }. - compact.join(" ") + "\n" - end - list - end - else - items.map { |i| "#{i}\n" }.join - end - end - - # - # The basic output method for HighLine objects. If the provided _statement_ - # ends with a space or tab character, a newline will not be appended (output - # will be flush()ed). All other cases are passed straight to Kernel.puts(). - # - # The _statement_ parameter is processed as an ERb template, supporting - # embedded Ruby code. The template is evaluated with a binding inside - # the HighLine instance, providing easy access to the ANSI color constants - # and the HighLine.color() method. - # - def say( statement ) - statement = statement.to_str - return unless statement.length > 0 - - template = ERB.new(statement, nil, "%") - statement = template.result(binding) - - statement = wrap(statement) unless @wrap_at.nil? - statement = page_print(statement) unless @page_at.nil? - - if statement[-1, 1] == " " or statement[-1, 1] == "\t" - @output.print(statement) - @output.flush - else - @output.puts(statement) - end - end - - # - # Set to an integer value to cause HighLine to wrap output lines at the - # indicated character limit. When +nil+, the default, no wrapping occurs. If - # set to :auto, HighLine will attempt to determing the columns - # available for the @output or use a sensible default. - # - def wrap_at=( setting ) - @wrap_at = setting == :auto ? output_cols : setting - end - - # - # Set to an integer value to cause HighLine to page output lines over the - # indicated line limit. When +nil+, the default, no paging occurs. If - # set to :auto, HighLine will attempt to determing the rows available - # for the @output or use a sensible default. - # - def page_at=( setting ) - @page_at = setting == :auto ? output_rows : setting - end - - # - # Returns the number of columns for the console, or a default it they cannot - # be determined. - # - def output_cols - return 80 unless @output.tty? - terminal_size.first - rescue - return 80 - end - - # - # Returns the number of rows for the console, or a default if they cannot be - # determined. - # - def output_rows - return 24 unless @output.tty? - terminal_size.last - rescue - return 24 - end - - private - - # - # A helper method for sending the output stream and error and repeat - # of the question. - # - def explain_error( error ) - say(@question.responses[error]) unless error.nil? - if @question.responses[:ask_on_error] == :question - say(@question) - elsif @question.responses[:ask_on_error] - say(@question.responses[:ask_on_error]) - end - end - - # - # Collects an Array/Hash full of answers as described in - # HighLine::Question.gather(). - # - # Raises EOFError if input is exhausted. - # - def gather( ) - @gather = @question.gather - @answers = [ ] - original_question = @question - - @question.gather = false - - case @gather - when Integer - @answers << ask(@question) - @gather -= 1 - - original_question.question = "" - until @gather.zero? - @question = original_question - @answers << ask(@question) - @gather -= 1 - end - when String, Regexp - @answers << ask(@question) - - original_question.question = "" - until (@gather.is_a?(String) and @answers.last.to_s == @gather) or - (@gather.is_a?(Regexp) and @answers.last.to_s =~ @gather) - @question = original_question - @answers << ask(@question) - end - - @answers.pop - when Hash - @answers = { } - @gather.keys.sort.each do |key| - @question = original_question - @key = key - @answers[key] = ask(@question) - end - end - - @answers - end - - # - # Read a line of input from the input stream and process whitespace as - # requested by the Question object. - # - # If Question's _readline_ property is set, that library will be used to - # fetch input. *WARNING*: This ignores the currently set input stream. - # - # Raises EOFError if input is exhausted. - # - def get_line( ) - if @question.readline - require "readline" # load only if needed - - # capture say()'s work in a String to feed to readline() - old_output = @output - @output = StringIO.new - say(@question) - question = @output.string - @output = old_output - - # prep auto-completion - Readline.completion_proc = lambda do |string| - @question.selection.grep(/\A#{Regexp.escape(string)}/) - end - - # work-around ugly readline() warnings - old_verbose = $VERBOSE - $VERBOSE = nil - answer = @question.change_case( - @question.remove_whitespace( - Readline.readline(question, true) ) ) - $VERBOSE = old_verbose - - answer - else - raise EOFError, "The input stream is exhausted." if @@track_eof and - @input.eof? - - @question.change_case(@question.remove_whitespace(@input.gets)) - end - end - - # - # Return a line or character of input, as requested for this question. - # Character input will be returned as a single character String, - # not an Integer. - # - # This question's _first_answer_ will be returned instead of input, if set. - # - # Raises EOFError if input is exhausted. - # - def get_response( ) - return @question.first_answer if @question.first_answer? - - if @question.character.nil? - if @question.echo == true and @question.limit.nil? - get_line - else - raw_no_echo_mode if stty = CHARACTER_MODE == "stty" - - line = "" - backspace_limit = 0 - begin - - while character = (stty ? @input.getbyte : get_character(@input)) - # honor backspace and delete - if character == 127 or character == 8 - line.slice!(-1, 1) - backspace_limit -= 1 - else - line << character.chr - backspace_limit = line.size - end - # looking for carriage return (decimal 13) or - # newline (decimal 10) in raw input - break if character == 13 or character == 10 or - (@question.limit and line.size == @question.limit) - if @question.echo != false - if character == 127 or character == 8 - # only backspace if we have characters on the line to - # eliminate, otherwise we'll tromp over the prompt - if backspace_limit >= 0 then - @output.print("\b#{ERASE_CHAR}") - else - # do nothing - end - else - if @question.echo == true - @output.print(character.chr) - else - @output.print(@question.echo) - end - end - @output.flush - end - end - ensure - restore_mode if stty - end - if @question.overwrite - @output.print("\r#{ERASE_LINE}") - @output.flush - else - say("\n") - end - - @question.change_case(@question.remove_whitespace(line)) - end - elsif @question.character == :getc - @question.change_case(@input.getbyte.chr) - else - response = get_character(@input).chr - if @question.overwrite - @output.print("\r#{ERASE_LINE}") - @output.flush - else - echo = if @question.echo == true - response - elsif @question.echo != false - @question.echo - else - "" - end - say("#{echo}\n") - end - @question.change_case(response) - end - end - - # - # Page print a series of at most _page_at_ lines for _output_. After each - # page is printed, HighLine will pause until the user presses enter/return - # then display the next page of data. - # - # Note that the final page of _output_ is *not* printed, but returned - # instead. This is to support any special handling for the final sequence. - # - def page_print( output ) - lines = output.scan(/[^\n]*\n?/) - while lines.size > @page_at - @output.puts lines.slice!(0...@page_at).join - @output.puts - # Return last line if user wants to abort paging - return (["...\n"] + lines.slice(-2,1)).join unless continue_paging? - end - return lines.join - end - - # - # Ask user if they wish to continue paging output. Allows them to type "q" to - # cancel the paging process. - # - def continue_paging? - command = HighLine.new(@input, @output).ask( - "-- press enter/return to continue or q to stop -- " - ) { |q| q.character = true } - command !~ /\A[qQ]\Z/ # Only continue paging if Q was not hit. - end - - # - # Wrap a sequence of _lines_ at _wrap_at_ characters per line. Existing - # newlines will not be affected by this process, but additional newlines - # may be added. - # - def wrap( text ) - wrapped = [ ] - text.each_line do |line| - while line =~ /([^\n]{#{@wrap_at + 1},})/ - search = $1.dup - replace = $1.dup - if index = replace.rindex(" ", @wrap_at) - replace[index, 1] = "\n" - replace.sub!(/\n[ \t]+/, "\n") - line.sub!(search, replace) - else - line[@wrap_at, 0] = "\n" - end - end - wrapped << line - end - return wrapped.join - end - - # - # Returns the length of the passed +string_with_escapes+, minus and color - # sequence escapes. - # - def actual_length( string_with_escapes ) - string_with_escapes.gsub(/\e\[\d{1,2}m/, "").length - end -end diff --git a/vendor/gems/highline-1.5.1/lib/highline/color_scheme.rb b/vendor/gems/highline-1.5.1/lib/highline/color_scheme.rb deleted file mode 100644 index e7cbdf99f..000000000 --- a/vendor/gems/highline-1.5.1/lib/highline/color_scheme.rb +++ /dev/null @@ -1,120 +0,0 @@ -#!/usr/local/bin/ruby -w - -# color_scheme.rb -# -# Created by Jeremy Hinegardner on 2007-01-24 -# Copyright 2007. All rights reserved -# -# This is Free Software. See LICENSE and COPYING for details - -require 'highline' - -class HighLine - # - # ColorScheme objects encapsulate a named set of colors to be used in the - # HighLine.colors() method call. For example, by applying a ColorScheme that - # has a :warning color then the following could be used: - # - # colors("This is a warning", :warning) - # - # A ColorScheme contains named sets of HighLine color constants. - # - # Example: Instantiating a color scheme, applying it to HighLine, - # and using it: - # - # ft = HighLine::ColorScheme.new do |cs| - # cs[:headline] = [ :bold, :yellow, :on_black ] - # cs[:horizontal_line] = [ :bold, :white ] - # cs[:even_row] = [ :green ] - # cs[:odd_row] = [ :magenta ] - # end - # - # HighLine.color_scheme = ft - # say("<%= color('Headline', :headline) %>") - # say("<%= color('-'*20, :horizontal_line) %>") - # i = true - # ("A".."D").each do |row| - # if i then - # say("<%= color('#{row}', :even_row ) %>") - # else - # say("<%= color('#{row}', :odd_row) %>") - # end - # i = !i - # end - # - # - class ColorScheme - # - # Create an instance of HighLine::ColorScheme. The customization can - # happen as a passed in Hash or via the yielded block. Key's are - # converted to :symbols and values are converted to HighLine - # constants. - # - def initialize( h = nil ) - @scheme = Hash.new - load_from_hash(h) unless h.nil? - yield self if block_given? - end - - # Load multiple colors from key/value pairs. - def load_from_hash( h ) - h.each_pair do |color_tag, constants| - self[color_tag] = constants - end - end - - # Does this color scheme include the given tag name? - def include?( color_tag ) - @scheme.keys.include?(to_symbol(color_tag)) - end - - # Allow the scheme to be accessed like a Hash. - def []( color_tag ) - @scheme[to_symbol(color_tag)] - end - - # Allow the scheme to be set like a Hash. - def []=( color_tag, constants ) - @scheme[to_symbol(color_tag)] = constants.map { |c| to_constant(c) } - end - - private - - # Return a normalized representation of a color name. - def to_symbol( t ) - t.to_s.downcase - end - - # Return a normalized representation of a color setting. - def to_constant( v ) - v = v.to_s if v.is_a?(Symbol) - if v.is_a?(String) then - HighLine.const_get(v.upcase) - else - v - end - end - end - - # A sample ColorScheme. - class SampleColorScheme < ColorScheme - # - # Builds the sample scheme with settings for :critical, - # :error, :warning, :notice, :info, - # :debug, :row_even, and :row_odd colors. - # - def initialize( h = nil ) - scheme = { - :critical => [ :yellow, :on_red ], - :error => [ :bold, :red ], - :warning => [ :bold, :yellow ], - :notice => [ :bold, :magenta ], - :info => [ :bold, :cyan ], - :debug => [ :bold, :green ], - :row_even => [ :cyan ], - :row_odd => [ :magenta ] - } - super(scheme) - end - end -end diff --git a/vendor/gems/highline-1.5.1/lib/highline/compatibility.rb b/vendor/gems/highline-1.5.1/lib/highline/compatibility.rb deleted file mode 100644 index ceaac255a..000000000 --- a/vendor/gems/highline-1.5.1/lib/highline/compatibility.rb +++ /dev/null @@ -1,17 +0,0 @@ -unless STDIN.respond_to?(:getbyte) - class IO - alias_method :getbyte, :getc - end - - class StringIO - alias_method :getbyte, :getc - end -end - -unless "".respond_to?(:each_line) - - # Not a perfect translation, but sufficient for our needs. - class String - alias_method :each_line, :each - end -end diff --git a/vendor/gems/highline-1.5.1/lib/highline/import.rb b/vendor/gems/highline-1.5.1/lib/highline/import.rb deleted file mode 100644 index 579a97348..000000000 --- a/vendor/gems/highline-1.5.1/lib/highline/import.rb +++ /dev/null @@ -1,43 +0,0 @@ -#!/usr/local/bin/ruby -w - -# import.rb -# -# Created by James Edward Gray II on 2005-04-26. -# Copyright 2005 Gray Productions. All rights reserved. -# -# This is Free Software. See LICENSE and COPYING for details. - -require "highline" -require "forwardable" - -$terminal = HighLine.new - -# -# require "highline/import" adds shortcut methods to Kernel, making -# agree(), ask(), choose() and say() globally available. This is handy for -# quick and dirty input and output. These methods use the HighLine object in -# the global variable $terminal, which is initialized to used -# $stdin and $stdout (you are free to change this). -# Otherwise, these methods are identical to their HighLine counterparts, see that -# class for detailed explanations. -# -module Kernel - extend Forwardable - def_delegators :$terminal, :agree, :ask, :choose, :say -end - -class Object - # - # Tries this object as a _first_answer_ for a HighLine::Question. See that - # attribute for details. - # - # *Warning*: This Object will be passed to String() before set. - # - def or_ask( *args, &details ) - ask(*args) do |question| - question.first_answer = String(self) unless nil? - - details.call(question) unless details.nil? - end - end -end diff --git a/vendor/gems/highline-1.5.1/lib/highline/menu.rb b/vendor/gems/highline-1.5.1/lib/highline/menu.rb deleted file mode 100644 index ad992ac05..000000000 --- a/vendor/gems/highline-1.5.1/lib/highline/menu.rb +++ /dev/null @@ -1,395 +0,0 @@ -#!/usr/local/bin/ruby -w - -# menu.rb -# -# Created by Gregory Thomas Brown on 2005-05-10. -# Copyright 2005. All rights reserved. -# -# This is Free Software. See LICENSE and COPYING for details. - -require "highline/question" - -class HighLine - # - # Menu objects encapsulate all the details of a call to HighLine.choose(). - # Using the accessors and Menu.choice() and Menu.choices(), the block passed - # to HighLine.choose() can detail all aspects of menu display and control. - # - class Menu < Question - # - # Create an instance of HighLine::Menu. All customization is done - # through the passed block, which should call accessors and choice() and - # choices() as needed to define the Menu. Note that Menus are also - # Questions, so all that functionality is available to the block as - # well. - # - def initialize( ) - # - # Initialize Question objects with ignored values, we'll - # adjust ours as needed. - # - super("Ignored", [ ], &nil) # avoiding passing the block along - - @items = [ ] - @hidden_items = [ ] - @help = Hash.new("There's no help for that topic.") - - @index = :number - @index_suffix = ". " - @select_by = :index_or_name - @flow = :rows - @list_option = nil - @header = nil - @prompt = "? " - @layout = :list - @shell = false - @nil_on_handled = false - - # Override Questions responses, we'll set our own. - @responses = { } - # Context for action code. - @highline = nil - - yield self if block_given? - - init_help if @shell and not @help.empty? - update_responses # rebuild responses based on our settings - end - - # - # An _index_ to append to each menu item in display. See - # Menu.index=() for details. - # - attr_reader :index - # - # The String placed between an _index_ and a menu item. Defaults to - # ". ". Switches to " ", when _index_ is set to a String (like "-"). - # - attr_accessor :index_suffix - # - # The _select_by_ attribute controls how the user is allowed to pick a - # menu item. The available choices are: - # - # :index:: The user is allowed to type the numerical - # or alphetical index for their selection. - # :index_or_name:: Allows both methods from the - # :index option and the - # :name option. - # :name:: Menu items are selected by typing a portion - # of the item name that will be - # auto-completed. - # - attr_accessor :select_by - # - # This attribute is passed directly on as the mode to HighLine.list() by - # all the preset layouts. See that method for appropriate settings. - # - attr_accessor :flow - # - # This setting is passed on as the third parameter to HighLine.list() - # by all the preset layouts. See that method for details of its - # effects. Defaults to +nil+. - # - attr_accessor :list_option - # - # Used by all the preset layouts to display title and/or introductory - # information, when set. Defaults to +nil+. - # - attr_accessor :header - # - # Used by all the preset layouts to ask the actual question to fetch a - # menu selection from the user. Defaults to "? ". - # - attr_accessor :prompt - # - # An ERb _layout_ to use when displaying this Menu object. See - # Menu.layout=() for details. - # - attr_reader :layout - # - # When set to +true+, responses are allowed to be an entire line of - # input, including details beyond the command itself. Only the first - # "word" of input will be matched against the menu choices, but both the - # command selected and the rest of the line will be passed to provided - # action blocks. Defaults to +false+. - # - attr_accessor :shell - # - # When +true+, any selected item handled by provided action code, will - # return +nil+, instead of the results to the action code. This may - # prove handy when dealing with mixed menus where only the names of - # items without any code (and +nil+, of course) will be returned. - # Defaults to +false+. - # - attr_accessor :nil_on_handled - - # - # Adds _name_ to the list of available menu items. Menu items will be - # displayed in the order they are added. - # - # An optional _action_ can be associated with this name and if provided, - # it will be called if the item is selected. The result of the method - # will be returned, unless _nil_on_handled_ is set (when you would get - # +nil+ instead). In _shell_ mode, a provided block will be passed the - # command chosen and any details that followed the command. Otherwise, - # just the command is passed. The @highline variable is set to - # the current HighLine context before the action code is called and can - # thus be used for adding output and the like. - # - def choice( name, help = nil, &action ) - @items << [name, action] - - @help[name.to_s.downcase] = help unless help.nil? - end - - # - # A shortcut for multiple calls to the sister method choice(). Be - # warned: An _action_ set here will apply to *all* provided - # _names_. This is considered to be a feature, so you can easily - # hand-off interface processing to a different chunk of code. - # - def choices( *names, &action ) - names.each { |n| choice(n, &action) } - end - - # Identical to choice(), but the item will not be listed for the user. - def hidden( name, help = nil, &action ) - @hidden_items << [name, action] - - @help[name.to_s.downcase] = help unless help.nil? - end - - # - # Sets the indexing style for this Menu object. Indexes are appended to - # menu items, when displayed in list form. The available settings are: - # - # :number:: Menu items will be indexed numerically, starting - # with 1. This is the default method of indexing. - # :letter:: Items will be indexed alphabetically, starting - # with a. - # :none:: No index will be appended to menu items. - # any String:: Will be used as the literal _index_. - # - # Setting the _index_ to :none a literal String, also adjusts - # _index_suffix_ to a single space and _select_by_ to :none. - # Because of this, you should make a habit of setting the _index_ first. - # - def index=( style ) - @index = style - - # Default settings. - if @index == :none or @index.is_a?(String) - @index_suffix = " " - @select_by = :name - end - end - - # - # Initializes the help system by adding a :help choice, some - # action code, and the default help listing. - # - def init_help( ) - return if @items.include?(:help) - - topics = @help.keys.sort - help_help = @help.include?("help") ? @help["help"] : - "This command will display helpful messages about " + - "functionality, like this one. To see the help for " + - "a specific topic enter:\n\thelp [TOPIC]\nTry asking " + - "for help on any of the following:\n\n" + - "<%= list(#{topics.inspect}, :columns_across) %>" - choice(:help, help_help) do |command, topic| - topic.strip! - topic.downcase! - if topic.empty? - @highline.say(@help["help"]) - else - @highline.say("= #{topic}\n\n#{@help[topic]}") - end - end - end - - # - # Used to set help for arbitrary topics. Use the topic "help" - # to override the default message. - # - def help( topic, help ) - @help[topic] = help - end - - # - # Setting a _layout_ with this method also adjusts some other attributes - # of the Menu object, to ideal defaults for the chosen _layout_. To - # account for that, you probably want to set a _layout_ first in your - # configuration block, if needed. - # - # Accepted settings for _layout_ are: - # - # :list:: The default _layout_. The _header_ if set - # will appear at the top on its own line with - # a trailing colon. Then the list of menu - # items will follow. Finally, the _prompt_ - # will be used as the ask()-like question. - # :one_line:: A shorter _layout_ that fits on one line. - # The _header_ comes first followed by a - # colon and spaces, then the _prompt_ with menu - # items between trailing parenthesis. - # :menu_only:: Just the menu items, followed up by a likely - # short _prompt_. - # any ERb String:: Will be taken as the literal _layout_. This - # String can access @header, - # @menu and @prompt, but is - # otherwise evaluated in the typical HighLine - # context, to provide access to utilities like - # HighLine.list() primarily. - # - # If set to either :one_line, or :menu_only, _index_ - # will default to :none and _flow_ will default to - # :inline. - # - def layout=( new_layout ) - @layout = new_layout - - # Default settings. - case @layout - when :one_line, :menu_only - self.index = :none - @flow = :inline - end - end - - # - # This method returns all possible options for auto-completion, based - # on the settings of _index_ and _select_by_. - # - def options( ) - # add in any hidden menu commands - @items.concat(@hidden_items) - - by_index = if @index == :letter - l_index = "`" - @items.map { "#{l_index.succ!}" } - else - (1 .. @items.size).collect { |s| String(s) } - end - by_name = @items.collect { |c| c.first } - - case @select_by - when :index then - by_index - when :name - by_name - else - by_index + by_name - end - ensure - # make sure the hidden items are removed, before we return - @items.slice!(@items.size - @hidden_items.size, @hidden_items.size) - end - - # - # This method processes the auto-completed user selection, based on the - # rules for this Menu object. If an action was provided for the - # selection, it will be executed as described in Menu.choice(). - # - def select( highline_context, selection, details = nil ) - # add in any hidden menu commands - @items.concat(@hidden_items) - - # Find the selected action. - name, action = if selection =~ /^\d+$/ - @items[selection.to_i - 1] - else - l_index = "`" - index = @items.map { "#{l_index.succ!}" }.index(selection) - @items.find { |c| c.first == selection } or @items[index] - end - - # Run or return it. - if not @nil_on_handled and not action.nil? - @highline = highline_context - if @shell - action.call(name, details) - else - action.call(name) - end - elsif action.nil? - name - else - nil - end - ensure - # make sure the hidden items are removed, before we return - @items.slice!(@items.size - @hidden_items.size, @hidden_items.size) - end - - # - # Allows Menu objects to pass as Arrays, for use with HighLine.list(). - # This method returns all menu items to be displayed, complete with - # indexes. - # - def to_ary( ) - case @index - when :number - @items.map { |c| "#{@items.index(c) + 1}#{@index_suffix}#{c.first}" } - when :letter - l_index = "`" - @items.map { |c| "#{l_index.succ!}#{@index_suffix}#{c.first}" } - when :none - @items.map { |c| "#{c.first}" } - else - @items.map { |c| "#{index}#{@index_suffix}#{c.first}" } - end - end - - # - # Allows Menu to behave as a String, just like Question. Returns the - # _layout_ to be rendered, which is used by HighLine.say(). - # - def to_str( ) - case @layout - when :list - '<%= if @header.nil? then '' else "#{@header}:\n" end %>' + - "<%= list( @menu, #{@flow.inspect}, - #{@list_option.inspect} ) %>" + - "<%= @prompt %>" - when :one_line - '<%= if @header.nil? then '' else "#{@header}: " end %>' + - "<%= @prompt %>" + - "(<%= list( @menu, #{@flow.inspect}, - #{@list_option.inspect} ) %>)" + - "<%= @prompt[/\s*$/] %>" - when :menu_only - "<%= list( @menu, #{@flow.inspect}, - #{@list_option.inspect} ) %><%= @prompt %>" - else - @layout - end - end - - # - # This method will update the intelligent responses to account for - # Menu specific differences. This overrides the work done by - # Question.build_responses(). - # - def update_responses( ) - append_default unless default.nil? - @responses = { :ambiguous_completion => - "Ambiguous choice. " + - "Please choose one of #{options.inspect}.", - :ask_on_error => - "? ", - :invalid_type => - "You must enter a valid #{options}.", - :no_completion => - "You must choose one of " + - "#{options.inspect}.", - :not_in_range => - "Your answer isn't within the expected range " + - "(#{expected_range}).", - :not_valid => - "Your answer isn't valid (must match " + - "#{@validate.inspect})." }.merge(@responses) - end - end -end diff --git a/vendor/gems/highline-1.5.1/lib/highline/question.rb b/vendor/gems/highline-1.5.1/lib/highline/question.rb deleted file mode 100644 index b6cabcecf..000000000 --- a/vendor/gems/highline-1.5.1/lib/highline/question.rb +++ /dev/null @@ -1,463 +0,0 @@ -#!/usr/local/bin/ruby -w - -# question.rb -# -# Created by James Edward Gray II on 2005-04-26. -# Copyright 2005 Gray Productions. All rights reserved. -# -# This is Free Software. See LICENSE and COPYING for details. - -require "optparse" -require "date" -require "pathname" - -class HighLine - # - # Question objects contain all the details of a single invocation of - # HighLine.ask(). The object is initialized by the parameters passed to - # HighLine.ask() and then queried to make sure each step of the input - # process is handled according to the users wishes. - # - class Question - # An internal HighLine error. User code does not need to trap this. - class NoAutoCompleteMatch < StandardError - # do nothing, just creating a unique error type - end - - # - # Create an instance of HighLine::Question. Expects a _question_ to ask - # (can be "") and an _answer_type_ to convert the answer to. - # The _answer_type_ parameter must be a type recongnized by - # Question.convert(). If given, a block is yeilded the new Question - # object to allow custom initializaion. - # - def initialize( question, answer_type ) - # initialize instance data - @question = question - @answer_type = answer_type - - @character = nil - @limit = nil - @echo = true - @readline = false - @whitespace = :strip - @case = nil - @default = nil - @validate = nil - @above = nil - @below = nil - @in = nil - @confirm = nil - @gather = false - @first_answer = nil - @directory = Pathname.new(File.expand_path(File.dirname($0))) - @glob = "*" - @responses = Hash.new - @overwrite = false - - # allow block to override settings - yield self if block_given? - - # finalize responses based on settings - build_responses - end - - # The ERb template of the question to be asked. - attr_accessor :question - # The type that will be used to convert this answer. - attr_accessor :answer_type - # - # Can be set to +true+ to use HighLine's cross-platform character reader - # instead of fetching an entire line of input. (Note: HighLine's - # character reader *ONLY* supports STDIN on Windows and Unix and may not - # work correctly if STDIN is redirected.) Can also be set to :getc - # to use that method on the input stream. - # - # *WARNING*: The _echo_ and _overwrite_ attributes for a question are - # ignored when using the :getc method. - # - attr_accessor :character - # - # Allows you to set a character limit for input. - # - # *WARNING*: This option forces a character by character read. - # - attr_accessor :limit - # - # Can be set to +true+ or +false+ to control whether or not input will - # be echoed back to the user. A setting of +true+ will cause echo to - # match input, but any other true value will be treated as to String to - # echo for each character typed. - # - # This requires HighLine's character reader. See the _character_ - # attribute for details. - # - # *Note*: When using HighLine to manage echo on Unix based systems, we - # recommend installing the termios gem. Without it, it's possible to type - # fast enough to have letters still show up (when reading character by - # character only). - # - attr_accessor :echo - # - # Use the Readline library to fetch input. This allows input editing as - # well as keeping a history. In addition, tab will auto-complete - # within an Array of choices or a file listing. - # - # *WARNING*: This option is incompatible with all of HighLine's - # character reading modes and it causes HighLine to ignore the - # specified _input_ stream. - # - attr_accessor :readline - # - # Used to control whitespace processing for the answer to this question. - # See HighLine::Question.remove_whitespace() for acceptable settings. - # - attr_accessor :whitespace - # - # Used to control character case processing for the answer to this question. - # See HighLine::Question.change_case() for acceptable settings. - # - attr_accessor :case - # Used to provide a default answer to this question. - attr_accessor :default - # - # If set to a Regexp, the answer must match (before type conversion). - # Can also be set to a Proc which will be called with the provided - # answer to validate with a +true+ or +false+ return. - # - attr_accessor :validate - # Used to control range checks for answer. - attr_accessor :above, :below - # If set, answer must pass an include?() check on this object. - attr_accessor :in - # - # Asks a yes or no confirmation question, to ensure a user knows what - # they have just agreed to. If set to +true+ the question will be, - # "Are you sure? " Any other true value for this attribute is assumed - # to be the question to ask. When +false+ or +nil+ (the default), - # answers are not confirmed. - # - attr_accessor :confirm - # - # When set, the user will be prompted for multiple answers which will - # be collected into an Array or Hash and returned as the final answer. - # - # You can set _gather_ to an Integer to have an Array of exactly that - # many answers collected, or a String/Regexp to match an end input which - # will not be returned in the Array. - # - # Optionally _gather_ can be set to a Hash. In this case, the question - # will be asked once for each key and the answers will be returned in a - # Hash, mapped by key. The @key variable is set before each - # question is evaluated, so you can use it in your question. - # - attr_accessor :gather - # - # When set to a non *nil* value, this will be tried as an answer to the - # question. If this answer passes validations, it will become the result - # without the user ever being prompted. Otherwise this value is discarded, - # and this Question is resolved as a normal call to HighLine.ask(). - # - attr_writer :first_answer - # - # The directory from which a user will be allowed to select files, when - # File or Pathname is specified as an _answer_type_. Initially set to - # Pathname.new(File.expand_path(File.dirname($0))). - # - attr_accessor :directory - # - # The glob pattern used to limit file selection when File or Pathname is - # specified as an _answer_type_. Initially set to "*". - # - attr_accessor :glob - # - # A Hash that stores the various responses used by HighLine to notify - # the user. The currently used responses and their purpose are as - # follows: - # - # :ambiguous_completion:: Used to notify the user of an - # ambiguous answer the auto-completion - # system cannot resolve. - # :ask_on_error:: This is the question that will be - # redisplayed to the user in the event - # of an error. Can be set to - # :question to repeat the - # original question. - # :invalid_type:: The error message shown when a type - # conversion fails. - # :no_completion:: Used to notify the user that their - # selection does not have a valid - # auto-completion match. - # :not_in_range:: Used to notify the user that a - # provided answer did not satisfy - # the range requirement tests. - # :not_valid:: The error message shown when - # validation checks fail. - # - attr_reader :responses - # - # When set to +true+ the question is asked, but output does not progress to - # the next line. The Cursor is moved back to the beginning of the question - # line and it is cleared so that all the contents of the line disappear from - # the screen. - # - attr_accessor :overwrite - - # - # Returns the provided _answer_string_ or the default answer for this - # Question if a default was set and the answer is empty. - # - def answer_or_default( answer_string ) - if answer_string.length == 0 and not @default.nil? - @default - else - answer_string - end - end - - # - # Called late in the initialization process to build intelligent - # responses based on the details of this Question object. - # - def build_responses( ) - ### WARNING: This code is quasi-duplicated in ### - ### Menu.update_responses(). Check there too when ### - ### making changes! ### - append_default unless default.nil? - @responses = { :ambiguous_completion => - "Ambiguous choice. " + - "Please choose one of #{@answer_type.inspect}.", - :ask_on_error => - "? ", - :invalid_type => - "You must enter a valid #{@answer_type}.", - :no_completion => - "You must choose one of " + - "#{@answer_type.inspect}.", - :not_in_range => - "Your answer isn't within the expected range " + - "(#{expected_range}).", - :not_valid => - "Your answer isn't valid (must match " + - "#{@validate.inspect})." }.merge(@responses) - ### WARNING: This code is quasi-duplicated in ### - ### Menu.update_responses(). Check there too when ### - ### making changes! ### - end - - # - # Returns the provided _answer_string_ after changing character case by - # the rules of this Question. Valid settings for whitespace are: - # - # +nil+:: Do not alter character case. - # (Default.) - # :up:: Calls upcase(). - # :upcase:: Calls upcase(). - # :down:: Calls downcase(). - # :downcase:: Calls downcase(). - # :capitalize:: Calls capitalize(). - # - # An unrecognized choice (like :none) is treated as +nil+. - # - def change_case( answer_string ) - if [:up, :upcase].include?(@case) - answer_string.upcase - elsif [:down, :downcase].include?(@case) - answer_string.downcase - elsif @case == :capitalize - answer_string.capitalize - else - answer_string - end - end - - # - # Transforms the given _answer_string_ into the expected type for this - # Question. Currently supported conversions are: - # - # [...]:: Answer must be a member of the passed Array. - # Auto-completion is used to expand partial - # answers. - # lambda {...}:: Answer is passed to lambda for conversion. - # Date:: Date.parse() is called with answer. - # DateTime:: DateTime.parse() is called with answer. - # File:: The entered file name is auto-completed in - # terms of _directory_ + _glob_, opened, and - # returned. - # Float:: Answer is converted with Kernel.Float(). - # Integer:: Answer is converted with Kernel.Integer(). - # +nil+:: Answer is left in String format. (Default.) - # Pathname:: Same as File, save that a Pathname object is - # returned. - # String:: Answer is converted with Kernel.String(). - # Regexp:: Answer is fed to Regexp.new(). - # Symbol:: The method to_sym() is called on answer and - # the result returned. - # any other Class:: The answer is passed on to - # Class.parse(). - # - # This method throws ArgumentError, if the conversion cannot be - # completed for any reason. - # - def convert( answer_string ) - if @answer_type.nil? - answer_string - elsif [Float, Integer, String].include?(@answer_type) - Kernel.send(@answer_type.to_s.to_sym, answer_string) - elsif @answer_type == Symbol - answer_string.to_sym - elsif @answer_type == Regexp - Regexp.new(answer_string) - elsif @answer_type.is_a?(Array) or [File, Pathname].include?(@answer_type) - # cheating, using OptionParser's Completion module - choices = selection - choices.extend(OptionParser::Completion) - answer = choices.complete(answer_string) - if answer.nil? - raise NoAutoCompleteMatch - end - if @answer_type.is_a?(Array) - answer.last - elsif @answer_type == File - File.open(File.join(@directory.to_s, answer.last)) - else - Pathname.new(File.join(@directory.to_s, answer.last)) - end - elsif [Date, DateTime].include?(@answer_type) or @answer_type.is_a?(Class) - @answer_type.parse(answer_string) - elsif @answer_type.is_a?(Proc) - @answer_type[answer_string] - end - end - - # Returns a english explination of the current range settings. - def expected_range( ) - expected = [ ] - - expected << "above #{@above}" unless @above.nil? - expected << "below #{@below}" unless @below.nil? - expected << "included in #{@in.inspect}" unless @in.nil? - - case expected.size - when 0 then "" - when 1 then expected.first - when 2 then expected.join(" and ") - else expected[0..-2].join(", ") + ", and #{expected.last}" - end - end - - # Returns _first_answer_, which will be unset following this call. - def first_answer( ) - @first_answer - ensure - @first_answer = nil - end - - # Returns true if _first_answer_ is set. - def first_answer?( ) - not @first_answer.nil? - end - - # - # Returns +true+ if the _answer_object_ is greater than the _above_ - # attribute, less than the _below_ attribute and included?()ed in the - # _in_ attribute. Otherwise, +false+ is returned. Any +nil+ attributes - # are not checked. - # - def in_range?( answer_object ) - (@above.nil? or answer_object > @above) and - (@below.nil? or answer_object < @below) and - (@in.nil? or @in.include?(answer_object)) - end - - # - # Returns the provided _answer_string_ after processing whitespace by - # the rules of this Question. Valid settings for whitespace are: - # - # +nil+:: Do not alter whitespace. - # :strip:: Calls strip(). (Default.) - # :chomp:: Calls chomp(). - # :collapse:: Collapses all whitspace runs to a - # single space. - # :strip_and_collapse:: Calls strip(), then collapses all - # whitspace runs to a single space. - # :chomp_and_collapse:: Calls chomp(), then collapses all - # whitspace runs to a single space. - # :remove:: Removes all whitespace. - # - # An unrecognized choice (like :none) is treated as +nil+. - # - # This process is skipped, for single character input. - # - def remove_whitespace( answer_string ) - if @whitespace.nil? - answer_string - elsif [:strip, :chomp].include?(@whitespace) - answer_string.send(@whitespace) - elsif @whitespace == :collapse - answer_string.gsub(/\s+/, " ") - elsif [:strip_and_collapse, :chomp_and_collapse].include?(@whitespace) - result = answer_string.send(@whitespace.to_s[/^[a-z]+/]) - result.gsub(/\s+/, " ") - elsif @whitespace == :remove - answer_string.gsub(/\s+/, "") - else - answer_string - end - end - - # - # Returns an Array of valid answers to this question. These answers are - # only known when _answer_type_ is set to an Array of choices, File, or - # Pathname. Any other time, this method will return an empty Array. - # - def selection( ) - if @answer_type.is_a?(Array) - @answer_type - elsif [File, Pathname].include?(@answer_type) - Dir[File.join(@directory.to_s, @glob)].map do |file| - File.basename(file) - end - else - [ ] - end - end - - # Stringifies the question to be asked. - def to_str( ) - @question - end - - # - # Returns +true+ if the provided _answer_string_ is accepted by the - # _validate_ attribute or +false+ if it's not. - # - # It's important to realize that an answer is validated after whitespace - # and case handling. - # - def valid_answer?( answer_string ) - @validate.nil? or - (@validate.is_a?(Regexp) and answer_string =~ @validate) or - (@validate.is_a?(Proc) and @validate[answer_string]) - end - - private - - # - # Adds the default choice to the end of question between |...|. - # Trailing whitespace is preserved so the function of HighLine.say() is - # not affected. - # - def append_default( ) - if @question =~ /([\t ]+)\Z/ - @question << "|#{@default}|#{$1}" - elsif @question == "" - @question << "|#{@default}| " - elsif @question[-1, 1] == "\n" - @question[-2, 0] = " |#{@default}|" - else - @question << " |#{@default}|" - end - end - end -end diff --git a/vendor/gems/highline-1.5.1/lib/highline/system_extensions.rb b/vendor/gems/highline-1.5.1/lib/highline/system_extensions.rb deleted file mode 100644 index 60adbf0df..000000000 --- a/vendor/gems/highline-1.5.1/lib/highline/system_extensions.rb +++ /dev/null @@ -1,193 +0,0 @@ -#!/usr/local/bin/ruby -w - -# system_extensions.rb -# -# Created by James Edward Gray II on 2006-06-14. -# Copyright 2006 Gray Productions. All rights reserved. -# -# This is Free Software. See LICENSE and COPYING for details. - -class HighLine - module SystemExtensions - module_function - - # - # This section builds character reading and terminal size functions - # to suit the proper platform we're running on. Be warned: Here be - # dragons! - # - begin - # Cygwin will look like Windows, but we want to treat it like a Posix OS: - raise LoadError, "Cygwin is a Posix OS." if RUBY_PLATFORM =~ /\bcygwin\b/i - - require "Win32API" # See if we're on Windows. - - CHARACTER_MODE = "Win32API" # For Debugging purposes only. - - # - # Windows savvy getc(). - # - # - def get_character( input = STDIN ) - @stdin_handle ||= GetStdHandle(STD_INPUT_HANDLE) - - begin - SetConsoleEcho(@stdin_handle, false) - input.getbyte - ensure - SetConsoleEcho(@stdin_handle, true) - end - end - - # A Windows savvy method to fetch the console columns, and rows. - def terminal_size - stdout_handle = GetStdHandle(STD_OUTPUT_HANDLE) - - bufx, bufy, curx, cury, wattr, left, top, right, bottom, maxx, maxy = - GetConsoleScreenBufferInfo(stdout_handle) - return right - left + 1, bottom - top + 1 - end - - # windows savvy console echo toggler - def SetConsoleEcho( console_handle, on ) - mode = GetConsoleMode(console_handle) - - # toggle the console echo bit - if on - mode |= ENABLE_ECHO_INPUT - else - mode &= ~ENABLE_ECHO_INPUT - end - - ok = SetConsoleMode(console_handle, mode) - end - - # win32 console APIs - - STD_INPUT_HANDLE = -10 - STD_OUTPUT_HANDLE = -11 - STD_ERROR_HANDLE = -12 - - ENABLE_PROCESSED_INPUT = 0x0001 - ENABLE_LINE_INPUT = 0x0002 - ENABLE_WRAP_AT_EOL_OUTPUT = 0x0002 - ENABLE_ECHO_INPUT = 0x0004 - ENABLE_WINDOW_INPUT = 0x0008 - ENABLE_MOUSE_INPUT = 0x0010 - ENABLE_INSERT_MODE = 0x0020 - ENABLE_QUICK_EDIT_MODE = 0x0040 - - @@apiGetStdHandle = nil - @@apiGetConsoleMode = nil - @@apiSetConsoleMode = nil - @@apiGetConsoleScreenBufferInfo = nil - - def GetStdHandle( handle_type ) - @@apiGetStdHandle ||= Win32API.new( "kernel32", "GetStdHandle", - ['L'], 'L' ) - - @@apiGetStdHandle.call( handle_type ) - end - - def GetConsoleMode( console_handle ) - @@apiGetConsoleMode ||= Win32API.new( "kernel32", "GetConsoleMode", - ['L', 'P'], 'I' ) - - mode = ' ' * 4 - @@apiGetConsoleMode.call(console_handle, mode) - mode.unpack('L')[0] - end - - def SetConsoleMode( console_handle, mode ) - @@apiSetConsoleMode ||= Win32API.new( "kernel32", "SetConsoleMode", - ['L', 'L'], 'I' ) - - @@apiSetConsoleMode.call(console_handle, mode) != 0 - end - - def GetConsoleScreenBufferInfo( console_handle ) - @@apiGetConsoleScreenBufferInfo ||= - Win32API.new( "kernel32", "GetConsoleScreenBufferInfo", - ['L', 'P'], 'L' ) - - format = 'SSSSSssssSS' - buf = ([0] * format.size).pack(format) - @@apiGetConsoleScreenBufferInfo.call(console_handle, buf) - buf.unpack(format) - end - - rescue LoadError # If we're not on Windows try... - begin - require "termios" # Unix, first choice. - - CHARACTER_MODE = "termios" # For Debugging purposes only. - - # - # Unix savvy getc(). (First choice.) - # - # *WARNING*: This method requires the "termios" library! - # - def get_character( input = STDIN ) - old_settings = Termios.getattr(input) - - new_settings = old_settings.dup - new_settings.c_lflag &= ~(Termios::ECHO | Termios::ICANON) - new_settings.c_cc[Termios::VMIN] = 1 - - begin - Termios.setattr(input, Termios::TCSANOW, new_settings) - input.getbyte - ensure - Termios.setattr(input, Termios::TCSANOW, old_settings) - end - end - rescue LoadError # If our first choice fails, default. - CHARACTER_MODE = "stty" # For Debugging purposes only. - - # - # Unix savvy getc(). (Second choice.) - # - # *WARNING*: This method requires the external "stty" program! - # - def get_character( input = STDIN ) - raw_no_echo_mode - - begin - input.getbyte - ensure - restore_mode - end - end - - # - # Switched the input mode to raw and disables echo. - # - # *WARNING*: This method requires the external "stty" program! - # - def raw_no_echo_mode - @state = `stty -g` - system "stty raw -echo cbreak isig" - end - - # - # Restores a previously saved input mode. - # - # *WARNING*: This method requires the external "stty" program! - # - def restore_mode - system "stty #{@state}" - end - end - - # A Unix savvy method to fetch the console columns, and rows. - def terminal_size - if /solaris/ =~ RUBY_PLATFORM and - `stty` =~ /\brows = (\d+).*\bcolumns = (\d+)/ - [$2, $1].map { |c| x.to_i } - else - `stty size`.split.map { |x| x.to_i }.reverse - end - end - end - end -end diff --git a/vendor/gems/highline-1.5.1/setup.rb b/vendor/gems/highline-1.5.1/setup.rb deleted file mode 100644 index 0807023db..000000000 --- a/vendor/gems/highline-1.5.1/setup.rb +++ /dev/null @@ -1,1360 +0,0 @@ -# -# setup.rb -# -# Copyright (c) 2000-2004 Minero Aoki -# -# This program is free software. -# You can distribute/modify this program under the terms of -# the GNU LGPL, Lesser General Public License version 2.1. -# - -unless Enumerable.method_defined?(:map) # Ruby 1.4.6 - module Enumerable - alias map collect - end -end - -unless File.respond_to?(:read) # Ruby 1.6 - def File.read(fname) - open(fname) {|f| - return f.read - } - end -end - -def File.binread(fname) - open(fname, 'rb') {|f| - return f.read - } -end - -# for corrupted windows stat(2) -def File.dir?(path) - File.directory?((path[-1,1] == '/') ? path : path + '/') -end - - -class SetupError < StandardError; end - -def setup_rb_error(msg) - raise SetupError, msg -end - -# -# Config -# - -if arg = ARGV.detect {|arg| /\A--rbconfig=/ =~ arg } - ARGV.delete(arg) - require arg.split(/=/, 2)[1] - $".push 'rbconfig.rb' -else - require 'rbconfig' -end - -def multipackage_install? - FileTest.directory?(File.dirname($0) + '/packages') -end - - -class ConfigItem - def initialize(name, template, default, desc) - @name = name.freeze - @template = template - @value = default - @default = default.dup.freeze - @description = desc - end - - attr_reader :name - attr_reader :description - - attr_accessor :default - alias help_default default - - def help_opt - "--#{@name}=#{@template}" - end - - def value - @value - end - - def eval(table) - @value.gsub(%r<\$([^/]+)>) { table[$1] } - end - - def set(val) - @value = check(val) - end - - private - - def check(val) - setup_rb_error "config: --#{name} requires argument" unless val - val - end -end - -class BoolItem < ConfigItem - def config_type - 'bool' - end - - def help_opt - "--#{@name}" - end - - private - - def check(val) - return 'yes' unless val - unless /\A(y(es)?|n(o)?|t(rue)?|f(alse))\z/i =~ val - setup_rb_error "config: --#{@name} accepts only yes/no for argument" - end - (/\Ay(es)?|\At(rue)/i =~ value) ? 'yes' : 'no' - end -end - -class PathItem < ConfigItem - def config_type - 'path' - end - - private - - def check(path) - setup_rb_error "config: --#{@name} requires argument" unless path - path[0,1] == '$' ? path : File.expand_path(path) - end -end - -class ProgramItem < ConfigItem - def config_type - 'program' - end -end - -class SelectItem < ConfigItem - def initialize(name, template, default, desc) - super - @ok = template.split('/') - end - - def config_type - 'select' - end - - private - - def check(val) - unless @ok.include?(val.strip) - setup_rb_error "config: use --#{@name}=#{@template} (#{val})" - end - val.strip - end -end - -class PackageSelectionItem < ConfigItem - def initialize(name, template, default, help_default, desc) - super name, template, default, desc - @help_default = help_default - end - - attr_reader :help_default - - def config_type - 'package' - end - - private - - def check(val) - unless File.dir?("packages/#{val}") - setup_rb_error "config: no such package: #{val}" - end - val - end -end - -class ConfigTable_class - - def initialize(items) - @items = items - @table = {} - items.each do |i| - @table[i.name] = i - end - ALIASES.each do |ali, name| - @table[ali] = @table[name] - end - end - - include Enumerable - - def each(&block) - @items.each(&block) - end - - def key?(name) - @table.key?(name) - end - - def lookup(name) - @table[name] or raise ArgumentError, "no such config item: #{name}" - end - - def add(item) - @items.push item - @table[item.name] = item - end - - def remove(name) - item = lookup(name) - @items.delete_if {|i| i.name == name } - @table.delete_if {|name, i| i.name == name } - item - end - - def new - dup() - end - - def savefile - '.config' - end - - def load - begin - t = dup() - File.foreach(savefile()) do |line| - k, v = *line.split(/=/, 2) - t[k] = v.strip - end - t - rescue Errno::ENOENT - setup_rb_error $!.message + "#{File.basename($0)} config first" - end - end - - def save - @items.each {|i| i.value } - File.open(savefile(), 'w') {|f| - @items.each do |i| - f.printf "%s=%s\n", i.name, i.value if i.value - end - } - end - - def [](key) - lookup(key).eval(self) - end - - def []=(key, val) - lookup(key).set val - end - -end - -c = ::Config::CONFIG - -rubypath = c['bindir'] + '/' + c['ruby_install_name'] - -major = c['MAJOR'].to_i -minor = c['MINOR'].to_i -teeny = c['TEENY'].to_i -version = "#{major}.#{minor}" - -# ruby ver. >= 1.4.4? -newpath_p = ((major >= 2) or - ((major == 1) and - ((minor >= 5) or - ((minor == 4) and (teeny >= 4))))) - -if c['rubylibdir'] - # V < 1.6.3 - _stdruby = c['rubylibdir'] - _siteruby = c['sitedir'] - _siterubyver = c['sitelibdir'] - _siterubyverarch = c['sitearchdir'] -elsif newpath_p - # 1.4.4 <= V <= 1.6.3 - _stdruby = "$prefix/lib/ruby/#{version}" - _siteruby = c['sitedir'] - _siterubyver = "$siteruby/#{version}" - _siterubyverarch = "$siterubyver/#{c['arch']}" -else - # V < 1.4.4 - _stdruby = "$prefix/lib/ruby/#{version}" - _siteruby = "$prefix/lib/ruby/#{version}/site_ruby" - _siterubyver = _siteruby - _siterubyverarch = "$siterubyver/#{c['arch']}" -end -libdir = '-* dummy libdir *-' -stdruby = '-* dummy rubylibdir *-' -siteruby = '-* dummy site_ruby *-' -siterubyver = '-* dummy site_ruby version *-' -parameterize = lambda {|path| - path.sub(/\A#{Regexp.quote(c['prefix'])}/, '$prefix')\ - .sub(/\A#{Regexp.quote(libdir)}/, '$libdir')\ - .sub(/\A#{Regexp.quote(stdruby)}/, '$stdruby')\ - .sub(/\A#{Regexp.quote(siteruby)}/, '$siteruby')\ - .sub(/\A#{Regexp.quote(siterubyver)}/, '$siterubyver') -} -libdir = parameterize.call(c['libdir']) -stdruby = parameterize.call(_stdruby) -siteruby = parameterize.call(_siteruby) -siterubyver = parameterize.call(_siterubyver) -siterubyverarch = parameterize.call(_siterubyverarch) - -if arg = c['configure_args'].split.detect {|arg| /--with-make-prog=/ =~ arg } - makeprog = arg.sub(/'/, '').split(/=/, 2)[1] -else - makeprog = 'make' -end - -common_conf = [ - PathItem.new('prefix', 'path', c['prefix'], - 'path prefix of target environment'), - PathItem.new('bindir', 'path', parameterize.call(c['bindir']), - 'the directory for commands'), - PathItem.new('libdir', 'path', libdir, - 'the directory for libraries'), - PathItem.new('datadir', 'path', parameterize.call(c['datadir']), - 'the directory for shared data'), - PathItem.new('mandir', 'path', parameterize.call(c['mandir']), - 'the directory for man pages'), - PathItem.new('sysconfdir', 'path', parameterize.call(c['sysconfdir']), - 'the directory for man pages'), - PathItem.new('stdruby', 'path', stdruby, - 'the directory for standard ruby libraries'), - PathItem.new('siteruby', 'path', siteruby, - 'the directory for version-independent aux ruby libraries'), - PathItem.new('siterubyver', 'path', siterubyver, - 'the directory for aux ruby libraries'), - PathItem.new('siterubyverarch', 'path', siterubyverarch, - 'the directory for aux ruby binaries'), - PathItem.new('rbdir', 'path', '$siterubyver', - 'the directory for ruby scripts'), - PathItem.new('sodir', 'path', '$siterubyverarch', - 'the directory for ruby extentions'), - PathItem.new('rubypath', 'path', rubypath, - 'the path to set to #! line'), - ProgramItem.new('rubyprog', 'name', rubypath, - 'the ruby program using for installation'), - ProgramItem.new('makeprog', 'name', makeprog, - 'the make program to compile ruby extentions'), - SelectItem.new('shebang', 'all/ruby/never', 'ruby', - 'shebang line (#!) editing mode'), - BoolItem.new('without-ext', 'yes/no', 'no', - 'does not compile/install ruby extentions') -] -class ConfigTable_class # open again - ALIASES = { - 'std-ruby' => 'stdruby', - 'site-ruby-common' => 'siteruby', # For backward compatibility - 'site-ruby' => 'siterubyver', # For backward compatibility - 'bin-dir' => 'bindir', - 'bin-dir' => 'bindir', - 'rb-dir' => 'rbdir', - 'so-dir' => 'sodir', - 'data-dir' => 'datadir', - 'ruby-path' => 'rubypath', - 'ruby-prog' => 'rubyprog', - 'ruby' => 'rubyprog', - 'make-prog' => 'makeprog', - 'make' => 'makeprog' - } -end -multipackage_conf = [ - PackageSelectionItem.new('with', 'name,name...', '', 'ALL', - 'package names that you want to install'), - PackageSelectionItem.new('without', 'name,name...', '', 'NONE', - 'package names that you do not want to install') -] -if multipackage_install? - ConfigTable = ConfigTable_class.new(common_conf + multipackage_conf) -else - ConfigTable = ConfigTable_class.new(common_conf) -end - - -module MetaConfigAPI - - def eval_file_ifexist(fname) - instance_eval File.read(fname), fname, 1 if File.file?(fname) - end - - def config_names - ConfigTable.map {|i| i.name } - end - - def config?(name) - ConfigTable.key?(name) - end - - def bool_config?(name) - ConfigTable.lookup(name).config_type == 'bool' - end - - def path_config?(name) - ConfigTable.lookup(name).config_type == 'path' - end - - def value_config?(name) - case ConfigTable.lookup(name).config_type - when 'bool', 'path' - true - else - false - end - end - - def add_config(item) - ConfigTable.add item - end - - def add_bool_config(name, default, desc) - ConfigTable.add BoolItem.new(name, 'yes/no', default ? 'yes' : 'no', desc) - end - - def add_path_config(name, default, desc) - ConfigTable.add PathItem.new(name, 'path', default, desc) - end - - def set_config_default(name, default) - ConfigTable.lookup(name).default = default - end - - def remove_config(name) - ConfigTable.remove(name) - end - -end - - -# -# File Operations -# - -module FileOperations - - def mkdir_p(dirname, prefix = nil) - dirname = prefix + File.expand_path(dirname) if prefix - $stderr.puts "mkdir -p #{dirname}" if verbose? - return if no_harm? - - # does not check '/'... it's too abnormal case - dirs = File.expand_path(dirname).split(%r<(?=/)>) - if /\A[a-z]:\z/i =~ dirs[0] - disk = dirs.shift - dirs[0] = disk + dirs[0] - end - dirs.each_index do |idx| - path = dirs[0..idx].join('') - Dir.mkdir path unless File.dir?(path) - end - end - - def rm_f(fname) - $stderr.puts "rm -f #{fname}" if verbose? - return if no_harm? - - if File.exist?(fname) or File.symlink?(fname) - File.chmod 0777, fname - File.unlink fname - end - end - - def rm_rf(dn) - $stderr.puts "rm -rf #{dn}" if verbose? - return if no_harm? - - Dir.chdir dn - Dir.foreach('.') do |fn| - next if fn == '.' - next if fn == '..' - if File.dir?(fn) - verbose_off { - rm_rf fn - } - else - verbose_off { - rm_f fn - } - end - end - Dir.chdir '..' - Dir.rmdir dn - end - - def move_file(src, dest) - File.unlink dest if File.exist?(dest) - begin - File.rename src, dest - rescue - File.open(dest, 'wb') {|f| f.write File.binread(src) } - File.chmod File.stat(src).mode, dest - File.unlink src - end - end - - def install(from, dest, mode, prefix = nil) - $stderr.puts "install #{from} #{dest}" if verbose? - return if no_harm? - - realdest = prefix ? prefix + File.expand_path(dest) : dest - realdest = File.join(realdest, File.basename(from)) if File.dir?(realdest) - str = File.binread(from) - if diff?(str, realdest) - verbose_off { - rm_f realdest if File.exist?(realdest) - } - File.open(realdest, 'wb') {|f| - f.write str - } - File.chmod mode, realdest - - File.open("#{objdir_root()}/InstalledFiles", 'a') {|f| - if prefix - f.puts realdest.sub(prefix, '') - else - f.puts realdest - end - } - end - end - - def diff?(new_content, path) - return true unless File.exist?(path) - new_content != File.binread(path) - end - - def command(str) - $stderr.puts str if verbose? - system str or raise RuntimeError, "'system #{str}' failed" - end - - def ruby(str) - command config('rubyprog') + ' ' + str - end - - def make(task = '') - command config('makeprog') + ' ' + task - end - - def extdir?(dir) - File.exist?(dir + '/MANIFEST') - end - - def all_files_in(dirname) - Dir.open(dirname) {|d| - return d.select {|ent| File.file?("#{dirname}/#{ent}") } - } - end - - REJECT_DIRS = %w( - CVS SCCS RCS CVS.adm .svn - ) - - def all_dirs_in(dirname) - Dir.open(dirname) {|d| - return d.select {|n| File.dir?("#{dirname}/#{n}") } - %w(. ..) - REJECT_DIRS - } - end - -end - - -# -# Main Installer -# - -module HookUtils - - def run_hook(name) - try_run_hook "#{curr_srcdir()}/#{name}" or - try_run_hook "#{curr_srcdir()}/#{name}.rb" - end - - def try_run_hook(fname) - return false unless File.file?(fname) - begin - instance_eval File.read(fname), fname, 1 - rescue - setup_rb_error "hook #{fname} failed:\n" + $!.message - end - true - end - -end - - -module HookScriptAPI - - def get_config(key) - @config[key] - end - - alias config get_config - - def set_config(key, val) - @config[key] = val - end - - # - # srcdir/objdir (works only in the package directory) - # - - #abstract srcdir_root - #abstract objdir_root - #abstract relpath - - def curr_srcdir - "#{srcdir_root()}/#{relpath()}" - end - - def curr_objdir - "#{objdir_root()}/#{relpath()}" - end - - def srcfile(path) - "#{curr_srcdir()}/#{path}" - end - - def srcexist?(path) - File.exist?(srcfile(path)) - end - - def srcdirectory?(path) - File.dir?(srcfile(path)) - end - - def srcfile?(path) - File.file? srcfile(path) - end - - def srcentries(path = '.') - Dir.open("#{curr_srcdir()}/#{path}") {|d| - return d.to_a - %w(. ..) - } - end - - def srcfiles(path = '.') - srcentries(path).select {|fname| - File.file?(File.join(curr_srcdir(), path, fname)) - } - end - - def srcdirectories(path = '.') - srcentries(path).select {|fname| - File.dir?(File.join(curr_srcdir(), path, fname)) - } - end - -end - - -class ToplevelInstaller - - Version = '3.3.1' - Copyright = 'Copyright (c) 2000-2004 Minero Aoki' - - TASKS = [ - [ 'all', 'do config, setup, then install' ], - [ 'config', 'saves your configurations' ], - [ 'show', 'shows current configuration' ], - [ 'setup', 'compiles ruby extentions and others' ], - [ 'install', 'installs files' ], - [ 'clean', "does `make clean' for each extention" ], - [ 'distclean',"does `make distclean' for each extention" ] - ] - - def ToplevelInstaller.invoke - instance().invoke - end - - @singleton = nil - - def ToplevelInstaller.instance - @singleton ||= new(File.dirname($0)) - @singleton - end - - include MetaConfigAPI - - def initialize(ardir_root) - @config = nil - @options = { 'verbose' => true } - @ardir = File.expand_path(ardir_root) - end - - def inspect - "#<#{self.class} #{__id__()}>" - end - - def invoke - run_metaconfigs - case task = parsearg_global() - when nil, 'all' - @config = load_config('config') - parsearg_config - init_installers - exec_config - exec_setup - exec_install - else - @config = load_config(task) - __send__ "parsearg_#{task}" - init_installers - __send__ "exec_#{task}" - end - end - - def run_metaconfigs - eval_file_ifexist "#{@ardir}/metaconfig" - end - - def load_config(task) - case task - when 'config' - ConfigTable.new - when 'clean', 'distclean' - if File.exist?(ConfigTable.savefile) - then ConfigTable.load - else ConfigTable.new - end - else - ConfigTable.load - end - end - - def init_installers - @installer = Installer.new(@config, @options, @ardir, File.expand_path('.')) - end - - # - # Hook Script API bases - # - - def srcdir_root - @ardir - end - - def objdir_root - '.' - end - - def relpath - '.' - end - - # - # Option Parsing - # - - def parsearg_global - valid_task = /\A(?:#{TASKS.map {|task,desc| task }.join '|'})\z/ - - while arg = ARGV.shift - case arg - when /\A\w+\z/ - setup_rb_error "invalid task: #{arg}" unless valid_task =~ arg - return arg - - when '-q', '--quiet' - @options['verbose'] = false - - when '--verbose' - @options['verbose'] = true - - when '-h', '--help' - print_usage $stdout - exit 0 - - when '-v', '--version' - puts "#{File.basename($0)} version #{Version}" - exit 0 - - when '--copyright' - puts Copyright - exit 0 - - else - setup_rb_error "unknown global option '#{arg}'" - end - end - - nil - end - - - def parsearg_no_options - unless ARGV.empty? - setup_rb_error "#{task}: unknown options: #{ARGV.join ' '}" - end - end - - alias parsearg_show parsearg_no_options - alias parsearg_setup parsearg_no_options - alias parsearg_clean parsearg_no_options - alias parsearg_distclean parsearg_no_options - - def parsearg_config - re = /\A--(#{ConfigTable.map {|i| i.name }.join('|')})(?:=(.*))?\z/ - @options['config-opt'] = [] - - while i = ARGV.shift - if /\A--?\z/ =~ i - @options['config-opt'] = ARGV.dup - break - end - m = re.match(i) or setup_rb_error "config: unknown option #{i}" - name, value = *m.to_a[1,2] - @config[name] = value - end - end - - def parsearg_install - @options['no-harm'] = false - @options['install-prefix'] = '' - while a = ARGV.shift - case a - when /\A--no-harm\z/ - @options['no-harm'] = true - when /\A--prefix=(.*)\z/ - path = $1 - path = File.expand_path(path) unless path[0,1] == '/' - @options['install-prefix'] = path - else - setup_rb_error "install: unknown option #{a}" - end - end - end - - def print_usage(out) - out.puts 'Typical Installation Procedure:' - out.puts " $ ruby #{File.basename $0} config" - out.puts " $ ruby #{File.basename $0} setup" - out.puts " # ruby #{File.basename $0} install (may require root privilege)" - out.puts - out.puts 'Detailed Usage:' - out.puts " ruby #{File.basename $0} " - out.puts " ruby #{File.basename $0} [] []" - - fmt = " %-24s %s\n" - out.puts - out.puts 'Global options:' - out.printf fmt, '-q,--quiet', 'suppress message outputs' - out.printf fmt, ' --verbose', 'output messages verbosely' - out.printf fmt, '-h,--help', 'print this message' - out.printf fmt, '-v,--version', 'print version and quit' - out.printf fmt, ' --copyright', 'print copyright and quit' - out.puts - out.puts 'Tasks:' - TASKS.each do |name, desc| - out.printf fmt, name, desc - end - - fmt = " %-24s %s [%s]\n" - out.puts - out.puts 'Options for CONFIG or ALL:' - ConfigTable.each do |item| - out.printf fmt, item.help_opt, item.description, item.help_default - end - out.printf fmt, '--rbconfig=path', 'rbconfig.rb to load',"running ruby's" - out.puts - out.puts 'Options for INSTALL:' - out.printf fmt, '--no-harm', 'only display what to do if given', 'off' - out.printf fmt, '--prefix=path', 'install path prefix', '$prefix' - out.puts - end - - # - # Task Handlers - # - - def exec_config - @installer.exec_config - @config.save # must be final - end - - def exec_setup - @installer.exec_setup - end - - def exec_install - @installer.exec_install - end - - def exec_show - ConfigTable.each do |i| - printf "%-20s %s\n", i.name, i.value - end - end - - def exec_clean - @installer.exec_clean - end - - def exec_distclean - @installer.exec_distclean - end - -end - - -class ToplevelInstallerMulti < ToplevelInstaller - - include HookUtils - include HookScriptAPI - include FileOperations - - def initialize(ardir) - super - @packages = all_dirs_in("#{@ardir}/packages") - raise 'no package exists' if @packages.empty? - end - - def run_metaconfigs - eval_file_ifexist "#{@ardir}/metaconfig" - @packages.each do |name| - eval_file_ifexist "#{@ardir}/packages/#{name}/metaconfig" - end - end - - def init_installers - @installers = {} - @packages.each do |pack| - @installers[pack] = Installer.new(@config, @options, - "#{@ardir}/packages/#{pack}", - "packages/#{pack}") - end - - with = extract_selection(config('with')) - without = extract_selection(config('without')) - @selected = @installers.keys.select {|name| - (with.empty? or with.include?(name)) \ - and not without.include?(name) - } - end - - def extract_selection(list) - a = list.split(/,/) - a.each do |name| - setup_rb_error "no such package: #{name}" unless @installers.key?(name) - end - a - end - - def print_usage(f) - super - f.puts 'Inluded packages:' - f.puts ' ' + @packages.sort.join(' ') - f.puts - end - - # - # multi-package metaconfig API - # - - attr_reader :packages - - def declare_packages(list) - raise 'package list is empty' if list.empty? - list.each do |name| - raise "directory packages/#{name} does not exist"\ - unless File.dir?("#{@ardir}/packages/#{name}") - end - @packages = list - end - - # - # Task Handlers - # - - def exec_config - run_hook 'pre-config' - each_selected_installers {|inst| inst.exec_config } - run_hook 'post-config' - @config.save # must be final - end - - def exec_setup - run_hook 'pre-setup' - each_selected_installers {|inst| inst.exec_setup } - run_hook 'post-setup' - end - - def exec_install - run_hook 'pre-install' - each_selected_installers {|inst| inst.exec_install } - run_hook 'post-install' - end - - def exec_clean - rm_f ConfigTable.savefile - run_hook 'pre-clean' - each_selected_installers {|inst| inst.exec_clean } - run_hook 'post-clean' - end - - def exec_distclean - rm_f ConfigTable.savefile - run_hook 'pre-distclean' - each_selected_installers {|inst| inst.exec_distclean } - run_hook 'post-distclean' - end - - # - # lib - # - - def each_selected_installers - Dir.mkdir 'packages' unless File.dir?('packages') - @selected.each do |pack| - $stderr.puts "Processing the package `#{pack}' ..." if @options['verbose'] - Dir.mkdir "packages/#{pack}" unless File.dir?("packages/#{pack}") - Dir.chdir "packages/#{pack}" - yield @installers[pack] - Dir.chdir '../..' - end - end - - def verbose? - @options['verbose'] - end - - def no_harm? - @options['no-harm'] - end - -end - - -class Installer - - FILETYPES = %w( bin lib ext data ) - - include HookScriptAPI - include HookUtils - include FileOperations - - def initialize(config, opt, srcroot, objroot) - @config = config - @options = opt - @srcdir = File.expand_path(srcroot) - @objdir = File.expand_path(objroot) - @currdir = '.' - end - - def inspect - "#<#{self.class} #{File.basename(@srcdir)}>" - end - - # - # Hook Script API base methods - # - - def srcdir_root - @srcdir - end - - def objdir_root - @objdir - end - - def relpath - @currdir - end - - # - # configs/options - # - - def no_harm? - @options['no-harm'] - end - - def verbose? - @options['verbose'] - end - - def verbose_off - begin - save, @options['verbose'] = @options['verbose'], false - yield - ensure - @options['verbose'] = save - end - end - - # - # TASK config - # - - def exec_config - exec_task_traverse 'config' - end - - def config_dir_bin(rel) - end - - def config_dir_lib(rel) - end - - def config_dir_ext(rel) - extconf if extdir?(curr_srcdir()) - end - - def extconf - opt = @options['config-opt'].join(' ') - command "#{config('rubyprog')} #{curr_srcdir()}/extconf.rb #{opt}" - end - - def config_dir_data(rel) - end - - # - # TASK setup - # - - def exec_setup - exec_task_traverse 'setup' - end - - def setup_dir_bin(rel) - all_files_in(curr_srcdir()).each do |fname| - adjust_shebang "#{curr_srcdir()}/#{fname}" - end - end - - def adjust_shebang(path) - return if no_harm? - tmpfile = File.basename(path) + '.tmp' - begin - File.open(path, 'rb') {|r| - first = r.gets - return unless File.basename(config('rubypath')) == 'ruby' - return unless File.basename(first.sub(/\A\#!/, '').split[0]) == 'ruby' - $stderr.puts "adjusting shebang: #{File.basename(path)}" if verbose? - File.open(tmpfile, 'wb') {|w| - w.print first.sub(/\A\#!\s*\S+/, '#! ' + config('rubypath')) - w.write r.read - } - move_file tmpfile, File.basename(path) - } - ensure - File.unlink tmpfile if File.exist?(tmpfile) - end - end - - def setup_dir_lib(rel) - end - - def setup_dir_ext(rel) - make if extdir?(curr_srcdir()) - end - - def setup_dir_data(rel) - end - - # - # TASK install - # - - def exec_install - rm_f 'InstalledFiles' - exec_task_traverse 'install' - end - - def install_dir_bin(rel) - install_files collect_filenames_auto(), "#{config('bindir')}/#{rel}", 0755 - end - - def install_dir_lib(rel) - install_files ruby_scripts(), "#{config('rbdir')}/#{rel}", 0644 - end - - def install_dir_ext(rel) - return unless extdir?(curr_srcdir()) - install_files ruby_extentions('.'), - "#{config('sodir')}/#{File.dirname(rel)}", - 0555 - end - - def install_dir_data(rel) - install_files collect_filenames_auto(), "#{config('datadir')}/#{rel}", 0644 - end - - def install_files(list, dest, mode) - mkdir_p dest, @options['install-prefix'] - list.each do |fname| - install fname, dest, mode, @options['install-prefix'] - end - end - - def ruby_scripts - collect_filenames_auto().select {|n| /\.rb\z/ =~ n } - end - - # picked up many entries from cvs-1.11.1/src/ignore.c - reject_patterns = %w( - core RCSLOG tags TAGS .make.state - .nse_depinfo #* .#* cvslog.* ,* .del-* *.olb - *~ *.old *.bak *.BAK *.orig *.rej _$* *$ - - *.org *.in .* - ) - mapping = { - '.' => '\.', - '$' => '\$', - '#' => '\#', - '*' => '.*' - } - REJECT_PATTERNS = Regexp.new('\A(?:' + - reject_patterns.map {|pat| - pat.gsub(/[\.\$\#\*]/) {|ch| mapping[ch] } - }.join('|') + - ')\z') - - def collect_filenames_auto - mapdir((existfiles() - hookfiles()).reject {|fname| - REJECT_PATTERNS =~ fname - }) - end - - def existfiles - all_files_in(curr_srcdir()) | all_files_in('.') - end - - def hookfiles - %w( pre-%s post-%s pre-%s.rb post-%s.rb ).map {|fmt| - %w( config setup install clean ).map {|t| sprintf(fmt, t) } - }.flatten - end - - def mapdir(filelist) - filelist.map {|fname| - if File.exist?(fname) # objdir - fname - else # srcdir - File.join(curr_srcdir(), fname) - end - } - end - - def ruby_extentions(dir) - Dir.open(dir) {|d| - ents = d.select {|fname| /\.#{::Config::CONFIG['DLEXT']}\z/ =~ fname } - if ents.empty? - setup_rb_error "no ruby extention exists: 'ruby #{$0} setup' first" - end - return ents - } - end - - # - # TASK clean - # - - def exec_clean - exec_task_traverse 'clean' - rm_f ConfigTable.savefile - rm_f 'InstalledFiles' - end - - def clean_dir_bin(rel) - end - - def clean_dir_lib(rel) - end - - def clean_dir_ext(rel) - return unless extdir?(curr_srcdir()) - make 'clean' if File.file?('Makefile') - end - - def clean_dir_data(rel) - end - - # - # TASK distclean - # - - def exec_distclean - exec_task_traverse 'distclean' - rm_f ConfigTable.savefile - rm_f 'InstalledFiles' - end - - def distclean_dir_bin(rel) - end - - def distclean_dir_lib(rel) - end - - def distclean_dir_ext(rel) - return unless extdir?(curr_srcdir()) - make 'distclean' if File.file?('Makefile') - end - - # - # lib - # - - def exec_task_traverse(task) - run_hook "pre-#{task}" - FILETYPES.each do |type| - if config('without-ext') == 'yes' and type == 'ext' - $stderr.puts 'skipping ext/* by user option' if verbose? - next - end - traverse task, type, "#{task}_dir_#{type}" - end - run_hook "post-#{task}" - end - - def traverse(task, rel, mid) - dive_into(rel) { - run_hook "pre-#{task}" - __send__ mid, rel.sub(%r[\A.*?(?:/|\z)], '') - all_dirs_in(curr_srcdir()).each do |d| - traverse task, "#{rel}/#{d}", mid - end - run_hook "post-#{task}" - } - end - - def dive_into(rel) - return unless File.dir?("#{@srcdir}/#{rel}") - - dir = File.basename(rel) - Dir.mkdir dir unless File.dir?(dir) - prevdir = Dir.pwd - Dir.chdir dir - $stderr.puts '---> ' + rel if verbose? - @currdir = rel - yield - Dir.chdir prevdir - $stderr.puts '<--- ' + rel if verbose? - @currdir = File.dirname(rel) - end - -end - - -if $0 == __FILE__ - begin - if multipackage_install? - ToplevelInstallerMulti.invoke - else - ToplevelInstaller.invoke - end - rescue SetupError - raise if $DEBUG - $stderr.puts $!.message - $stderr.puts "Try 'ruby #{$0} --help' for detailed usage." - exit 1 - end -end diff --git a/vendor/gems/highline-1.5.1/test/tc_color_scheme.rb b/vendor/gems/highline-1.5.1/test/tc_color_scheme.rb deleted file mode 100644 index cb5cbd0e8..000000000 --- a/vendor/gems/highline-1.5.1/test/tc_color_scheme.rb +++ /dev/null @@ -1,56 +0,0 @@ -#!/usr/local/bin/ruby -w - -# tc_color_scheme.rb -# -# Created by Jeremy Hinegardner on 2007-01-24. -# Copyright 2007 Jeremy Hinegardner. All rights reserved. -# -# This is Free Software. See LICENSE and COPYING for details. - -require "test/unit" - -require "highline" -require "stringio" - -class TestColorScheme < Test::Unit::TestCase - def setup - @input = StringIO.new - @output = StringIO.new - @terminal = HighLine.new(@input, @output) - - @old_color_scheme = HighLine.color_scheme - end - - def teardown - HighLine.color_scheme = @old_color_scheme - end - - def test_using_color_scheme - assert_equal(false,HighLine.using_color_scheme?) - - HighLine.color_scheme = HighLine::ColorScheme.new - assert_equal(true,HighLine.using_color_scheme?) - end - - def test_scheme - HighLine.color_scheme = HighLine::SampleColorScheme.new - - @terminal.say("This should be <%= color('warning yellow', :warning) %>.") - assert_equal("This should be \e[1m\e[33mwarning yellow\e[0m.\n",@output.string) - @output.rewind - - @terminal.say("This should be <%= color('warning yellow', 'warning') %>.") - assert_equal("This should be \e[1m\e[33mwarning yellow\e[0m.\n",@output.string) - @output.rewind - - @terminal.say("This should be <%= color('warning yellow', 'WarNing') %>.") - assert_equal("This should be \e[1m\e[33mwarning yellow\e[0m.\n",@output.string) - @output.rewind - - # turn it back off, should raise an exception - HighLine.color_scheme = @old_color_scheme - assert_raises(NameError) { - @terminal.say("This should be <%= color('nothing at all', :error) %>.") - } - end -end diff --git a/vendor/gems/highline-1.5.1/test/tc_highline.rb b/vendor/gems/highline-1.5.1/test/tc_highline.rb deleted file mode 100644 index ba4e1778f..000000000 --- a/vendor/gems/highline-1.5.1/test/tc_highline.rb +++ /dev/null @@ -1,823 +0,0 @@ -#!/usr/local/bin/ruby -w - -# tc_highline.rb -# -# Created by James Edward Gray II on 2005-04-26. -# Copyright 2005 Gray Productions. All rights reserved. -# -# This is Free Software. See LICENSE and COPYING for details. - -require "test/unit" - -require "highline" -require "stringio" - -if HighLine::CHARACTER_MODE == "Win32API" - class HighLine - # Override Windows' character reading so it's not tied to STDIN. - def get_character( input = STDIN ) - input.getc - end - end -end - -class TestHighLine < Test::Unit::TestCase - def setup - @input = StringIO.new - @output = StringIO.new - @terminal = HighLine.new(@input, @output) - end - - def test_agree - @input << "y\nyes\nYES\nHell no!\nNo\n" - @input.rewind - - assert_equal(true, @terminal.agree("Yes or no? ")) - assert_equal(true, @terminal.agree("Yes or no? ")) - assert_equal(true, @terminal.agree("Yes or no? ")) - assert_equal(false, @terminal.agree("Yes or no? ")) - - @input.truncate(@input.rewind) - @input << "yellow" - @input.rewind - - assert_equal(true, @terminal.agree("Yes or no? ", :getc)) - end - - def test_agree_with_block - @input << "\n\n" - @input.rewind - - assert_equal(true, @terminal.agree("Yes or no? ") { |q| q.default = "y" }) - assert_equal(false, @terminal.agree("Yes or no? ") { |q| q.default = "n" }) - end - - def test_ask - name = "James Edward Gray II" - @input << name << "\n" - @input.rewind - - assert_equal(name, @terminal.ask("What is your name? ")) - - assert_raise(EOFError) { @terminal.ask("Any input left? ") } - end - - def test_bug_fixes - # auto-complete bug - @input << "ruby\nRuby\n" - @input.rewind - - languages = [:Perl, :Python, :Ruby] - answer = @terminal.ask( "What is your favorite programming language? ", - languages ) - assert_equal(languages.last, answer) - - @input.truncate(@input.rewind) - @input << "ruby\n" - @input.rewind - - answer = @terminal.ask( "What is your favorite programming language? ", - languages ) do |q| - q.case = :capitalize - end - assert_equal(languages.last, answer) - - # poor auto-complete error message - @input.truncate(@input.rewind) - @input << "lisp\nruby\n" - @input.rewind - @output.truncate(@output.rewind) - - answer = @terminal.ask( "What is your favorite programming language? ", - languages ) do |q| - q.case = :capitalize - end - assert_equal(languages.last, answer) - assert_equal( "What is your favorite programming language? " + - "You must choose one of [:Perl, :Python, :Ruby].\n" + - "? ", @output.string ) - end - - def test_case_changes - @input << "jeg2\n" - @input.rewind - - answer = @terminal.ask("Enter your initials ") do |q| - q.case = :up - end - assert_equal("JEG2", answer) - - @input.truncate(@input.rewind) - @input << "cRaZY\n" - @input.rewind - - answer = @terminal.ask("Enter a search string: ") do |q| - q.case = :down - end - assert_equal("crazy", answer) - end - - def test_character_echo - @input << "password\r" - @input.rewind - - answer = @terminal.ask("Please enter your password: ") do |q| - q.echo = "*" - end - assert_equal("password", answer) - assert_equal("Please enter your password: ********\n", @output.string) - - @input.truncate(@input.rewind) - @input << "2" - @input.rewind - @output.truncate(@output.rewind) - - answer = @terminal.ask( "Select an option (1, 2 or 3): ", - Integer ) do |q| - q.echo = "*" - q.character = true - end - assert_equal(2, answer) - assert_equal("Select an option (1, 2 or 3): *\n", @output.string) - end - - def test_backspace_does_not_enter_prompt - @input << "\b\b" - @input.rewind - answer = @terminal.ask("Please enter your password: ") do |q| - q.echo = "*" - end - assert_equal("", answer) - assert_equal("Please enter your password: \n",@output.string) - end - - def test_readline_on_non_echo_question_has_prompt - @input << "you can't see me" - @input.rewind - answer = @terminal.ask("Please enter some hidden text: ") do |q| - q.readline = true - q.echo = "*" - end - assert_equal("you can't see me", answer) - assert_equal("Please enter some hidden text: ****************\n",@output.string) - end - - def test_character_reading - # WARNING: This method does NOT cover Unix and Windows savvy testing! - @input << "12345" - @input.rewind - - answer = @terminal.ask("Enter a single digit: ", Integer) do |q| - q.character = :getc - end - assert_equal(1, answer) - end - - def test_color - @terminal.say("This should be <%= BLUE %>blue<%= CLEAR %>!") - assert_equal("This should be \e[34mblue\e[0m!\n", @output.string) - - @output.truncate(@output.rewind) - - @terminal.say( "This should be " + - "<%= BOLD + ON_WHITE %>bold on white<%= CLEAR %>!" ) - assert_equal( "This should be \e[1m\e[47mbold on white\e[0m!\n", - @output.string ) - - @output.truncate(@output.rewind) - - @terminal.say("This should be <%= color('cyan', CYAN) %>!") - assert_equal("This should be \e[36mcyan\e[0m!\n", @output.string) - - @output.truncate(@output.rewind) - - @terminal.say( "This should be " + - "<%= color('blinking on red', :blink, :on_red) %>!" ) - assert_equal( "This should be \e[5m\e[41mblinking on red\e[0m!\n", - @output.string ) - - @output.truncate(@output.rewind) - - # turn off color - old_setting = HighLine.use_color? - assert_nothing_raised(Exception) { HighLine.use_color = false } - @terminal.say("This should be <%= color('cyan', CYAN) %>!") - assert_equal("This should be cyan!\n", @output.string) - HighLine.use_color = old_setting - end - - def test_confirm - @input << "junk.txt\nno\nsave.txt\ny\n" - @input.rewind - - answer = @terminal.ask("Enter a filename: ") do |q| - q.confirm = "Are you sure you want to overwrite <%= @answer %>? " - q.responses[:ask_on_error] = :question - end - assert_equal("save.txt", answer) - assert_equal( "Enter a filename: " + - "Are you sure you want to overwrite junk.txt? " + - "Enter a filename: " + - "Are you sure you want to overwrite save.txt? ", - @output.string ) - - @input.truncate(@input.rewind) - @input << "junk.txt\nyes\nsave.txt\nn\n" - @input.rewind - @output.truncate(@output.rewind) - - answer = @terminal.ask("Enter a filename: ") do |q| - q.confirm = "Are you sure you want to overwrite <%= @answer %>? " - end - assert_equal("junk.txt", answer) - assert_equal( "Enter a filename: " + - "Are you sure you want to overwrite junk.txt? ", - @output.string ) - end - - def test_defaults - @input << "\nNo Comment\n" - @input.rewind - - answer = @terminal.ask("Are you sexually active? ") do |q| - q.validate = /\Ay(?:es)?|no?|no comment\Z/i - end - assert_equal("No Comment", answer) - - @input.truncate(@input.rewind) - @input << "\nYes\n" - @input.rewind - @output.truncate(@output.rewind) - - answer = @terminal.ask("Are you sexually active? ") do |q| - q.default = "No Comment" - q.validate = /\Ay(?:es)?|no?|no comment\Z/i - end - assert_equal("No Comment", answer) - assert_equal( "Are you sexually active? |No Comment| ", - @output.string ) - end - - def test_empty - @input << "\n" - @input.rewind - - answer = @terminal.ask("") do |q| - q.default = "yes" - q.validate = /\Ay(?:es)?|no?\Z/i - end - assert_equal("yes", answer) - end - - def test_erb - @terminal.say( "The integers from 1 to 10 are:\n" + - "% (1...10).each do |n|\n" + - "\t<%= n %>,\n" + - "% end\n" + - "\tand 10" ) - assert_equal( "The integers from 1 to 10 are:\n" + - "\t1,\n\t2,\n\t3,\n\t4,\n\t5,\n" + - "\t6,\n\t7,\n\t8,\n\t9,\n\tand 10\n", - @output.string ) - end - - def test_files - @input << "#{File.basename(__FILE__)[0, 5]}\n" - @input.rewind - - file = @terminal.ask("Select a file: ", File) do |q| - q.directory = File.expand_path(File.dirname(__FILE__)) - q.glob = "*.rb" - end - assert_instance_of(File, file) - assert_equal("#!/usr/local/bin/ruby -w\n", file.gets) - assert_equal("\n", file.gets) - assert_equal("# tc_highline.rb\n", file.gets) - file.close - - @input.rewind - - pathname = @terminal.ask("Select a file: ", Pathname) do |q| - q.directory = File.expand_path(File.dirname(__FILE__)) - q.glob = "*.rb" - end - assert_instance_of(Pathname, pathname) - assert_equal(File.size(__FILE__), pathname.size) - end - - def test_gather - @input << "James\nDana\nStorm\nGypsy\n\n" - @input.rewind - - answers = @terminal.ask("Enter four names:") do |q| - q.gather = 4 - end - assert_equal(%w{James Dana Storm Gypsy}, answers) - assert_equal("\n", @input.gets) - assert_equal("Enter four names:\n", @output.string) - - @input.rewind - - answers = @terminal.ask("Enter four names:") do |q| - q.gather = "" - end - assert_equal(%w{James Dana Storm Gypsy}, answers) - - @input.rewind - - answers = @terminal.ask("Enter four names:") do |q| - q.gather = /^\s*$/ - end - assert_equal(%w{James Dana Storm Gypsy}, answers) - - @input.truncate(@input.rewind) - @input << "29\n49\n30\n" - @input.rewind - @output.truncate(@output.rewind) - - answers = @terminal.ask("<%= @key %>: ", Integer) do |q| - q.gather = { "Age" => 0, "Wife's Age" => 0, "Father's Age" => 0} - end - assert_equal( { "Age" => 29, "Wife's Age" => 30, "Father's Age" => 49}, - answers ) - assert_equal("Age: Father's Age: Wife's Age: ", @output.string) - end - - def test_lists - digits = %w{Zero One Two Three Four Five Six Seven Eight Nine} - erb_digits = digits.dup - erb_digits[erb_digits.index("Five")] = "<%= color('Five', :blue) %%>" - - @terminal.say("<%= list(#{digits.inspect}) %>") - assert_equal(digits.map { |d| "#{d}\n" }.join, @output.string) - - @output.truncate(@output.rewind) - - @terminal.say("<%= list(#{digits.inspect}, :inline) %>") - assert_equal( digits[0..-2].join(", ") + " or #{digits.last}\n", - @output.string ) - - @output.truncate(@output.rewind) - - @terminal.say("<%= list(#{digits.inspect}, :inline, ' and ') %>") - assert_equal( digits[0..-2].join(", ") + " and #{digits.last}\n", - @output.string ) - - @output.truncate(@output.rewind) - - @terminal.say("<%= list(#{digits.inspect}, :columns_down, 3) %>") - assert_equal( "Zero Four Eight\n" + - "One Five Nine \n" + - "Two Six \n" + - "Three Seven\n", - @output.string ) - - @output.truncate(@output.rewind) - - @terminal.say("<%= list(#{erb_digits.inspect}, :columns_down, 3) %>") - assert_equal( "Zero Four Eight\n" + - "One \e[34mFive\e[0m Nine \n" + - "Two Six \n" + - "Three Seven\n", - @output.string ) - - colums_of_twenty = ["12345678901234567890"] * 5 - - @output.truncate(@output.rewind) - - @terminal.say("<%= list(#{colums_of_twenty.inspect}, :columns_down) %>") - assert_equal( "12345678901234567890 12345678901234567890 " + - "12345678901234567890\n" + - "12345678901234567890 12345678901234567890\n", - @output.string ) - - @output.truncate(@output.rewind) - - @terminal.say("<%= list(#{digits.inspect}, :columns_across, 3) %>") - assert_equal( "Zero One Two \n" + - "Three Four Five \n" + - "Six Seven Eight\n" + - "Nine \n", - @output.string ) - - colums_of_twenty.pop - - @output.truncate(@output.rewind) - - @terminal.say("<%= list( #{colums_of_twenty.inspect}, :columns_across ) %>") - assert_equal( "12345678901234567890 12345678901234567890 " + - "12345678901234567890\n" + - "12345678901234567890\n", - @output.string ) - end - - def test_mode - assert(%w[Win32API termios stty].include?(HighLine::CHARACTER_MODE)) - end - - class NameClass - def self.parse( string ) - if string =~ /^\s*(\w+),\s*(\w+)\s+(\w+)\s*$/ - self.new($2, $3, $1) - else - raise ArgumentError, "Invalid name format." - end - end - - def initialize(first, middle, last) - @first, @middle, @last = first, middle, last - end - - attr_reader :first, :middle, :last - end - - def test_my_class_conversion - @input << "Gray, James Edward\n" - @input.rewind - - answer = @terminal.ask("Your name? ", NameClass) do |q| - q.validate = lambda do |name| - names = name.split(/,\s*/) - return false unless names.size == 2 - return false if names.first =~ /\s/ - names.last.split.size == 2 - end - end - assert_instance_of(NameClass, answer) - assert_equal("Gray", answer.last) - assert_equal("James", answer.first) - assert_equal("Edward", answer.middle) - end - - def test_no_echo - @input << "password\r" - @input.rewind - - answer = @terminal.ask("Please enter your password: ") do |q| - q.echo = false - end - assert_equal("password", answer) - assert_equal("Please enter your password: \n", @output.string) - - @input.rewind - @output.truncate(@output.rewind) - - answer = @terminal.ask("Pick a letter or number: ") do |q| - q.character = true - q.echo = false - end - assert_equal("p", answer) - assert_equal("a", @input.getc.chr) - assert_equal("Pick a letter or number: \n", @output.string) - end - - def test_paging - @terminal.page_at = 22 - - @input << "\n\n" - @input.rewind - - @terminal.say((1..50).map { |n| "This is line #{n}.\n"}.join) - assert_equal( (1..22).map { |n| "This is line #{n}.\n"}.join + - "\n-- press enter/return to continue or q to stop -- \n\n" + - (23..44).map { |n| "This is line #{n}.\n"}.join + - "\n-- press enter/return to continue or q to stop -- \n\n" + - (45..50).map { |n| "This is line #{n}.\n"}.join, - @output.string ) - end - - def test_range_requirements - @input << "112\n-541\n28\n" - @input.rewind - - answer = @terminal.ask("Tell me your age.", Integer) do |q| - q.in = 0..105 - end - assert_equal(28, answer) - assert_equal( "Tell me your age.\n" + - "Your answer isn't within the expected range " + - "(included in 0..105).\n" + - "? " + - "Your answer isn't within the expected range " + - "(included in 0..105).\n" + - "? ", @output.string ) - - @input.truncate(@input.rewind) - @input << "1\n-541\n28\n" - @input.rewind - @output.truncate(@output.rewind) - - answer = @terminal.ask("Tell me your age.", Integer) do |q| - q.above = 3 - end - assert_equal(28, answer) - assert_equal( "Tell me your age.\n" + - "Your answer isn't within the expected range " + - "(above 3).\n" + - "? " + - "Your answer isn't within the expected range " + - "(above 3).\n" + - "? ", @output.string ) - - @input.truncate(@input.rewind) - @input << "1\n28\n-541\n" - @input.rewind - @output.truncate(@output.rewind) - - answer = @terminal.ask("Lowest numer you can think of?", Integer) do |q| - q.below = 0 - end - assert_equal(-541, answer) - assert_equal( "Lowest numer you can think of?\n" + - "Your answer isn't within the expected range " + - "(below 0).\n" + - "? " + - "Your answer isn't within the expected range " + - "(below 0).\n" + - "? ", @output.string ) - - @input.truncate(@input.rewind) - @input << "1\n-541\n6\n" - @input.rewind - @output.truncate(@output.rewind) - - answer = @terminal.ask("Enter a low even number: ", Integer) do |q| - q.above = 0 - q.below = 10 - q.in = [2, 4, 6, 8] - end - assert_equal(6, answer) - assert_equal( "Enter a low even number: " + - "Your answer isn't within the expected range " + - "(above 0, below 10, and included in [2, 4, 6, 8]).\n" + - "? " + - "Your answer isn't within the expected range " + - "(above 0, below 10, and included in [2, 4, 6, 8]).\n" + - "? ", @output.string ) - end - - def test_reask - number = 61676 - @input << "Junk!\n" << number << "\n" - @input.rewind - - answer = @terminal.ask("Favorite number? ", Integer) - assert_kind_of(Integer, number) - assert_instance_of(Fixnum, number) - assert_equal(number, answer) - assert_equal( "Favorite number? " + - "You must enter a valid Integer.\n" + - "? ", @output.string ) - - @input.rewind - @output.truncate(@output.rewind) - - answer = @terminal.ask("Favorite number? ", Integer) do |q| - q.responses[:ask_on_error] = :question - q.responses[:invalid_type] = "Not a valid number!" - end - assert_kind_of(Integer, number) - assert_instance_of(Fixnum, number) - assert_equal(number, answer) - assert_equal( "Favorite number? " + - "Not a valid number!\n" + - "Favorite number? ", @output.string ) - - @input.truncate(@input.rewind) - @input << "gen\ngene\n" - @input.rewind - @output.truncate(@output.rewind) - - answer = @terminal.ask("Select a mode: ", [:generate, :gentle]) - assert_instance_of(Symbol, answer) - assert_equal(:generate, answer) - assert_equal( "Select a mode: " + - "Ambiguous choice. " + - "Please choose one of [:generate, :gentle].\n" + - "? ", @output.string ) - end - - def test_response_embedding - @input << "112\n-541\n28\n" - @input.rewind - - answer = @terminal.ask("Tell me your age.", Integer) do |q| - q.in = 0..105 - q.responses[:not_in_range] = "Need a <%= @question.answer_type %>" + - " <%= @question.expected_range %>." - end - assert_equal(28, answer) - assert_equal( "Tell me your age.\n" + - "Need a Integer included in 0..105.\n" + - "? " + - "Need a Integer included in 0..105.\n" + - "? ", @output.string ) - end - - def test_say - @terminal.say("This will have a newline.") - assert_equal("This will have a newline.\n", @output.string) - - @output.truncate(@output.rewind) - - @terminal.say("This will also have one newline.\n") - assert_equal("This will also have one newline.\n", @output.string) - - @output.truncate(@output.rewind) - - @terminal.say("This will not have a newline. ") - assert_equal("This will not have a newline. ", @output.string) - end - - def test_type_conversion - number = 61676 - @input << number << "\n" - @input.rewind - - answer = @terminal.ask("Favorite number? ", Integer) - assert_kind_of(Integer, answer) - assert_instance_of(Fixnum, answer) - assert_equal(number, answer) - - @input.truncate(@input.rewind) - number = 1_000_000_000_000_000_000_000_000_000_000 - @input << number << "\n" - @input.rewind - - answer = @terminal.ask("Favorite number? ", Integer) - assert_kind_of(Integer, answer) - assert_instance_of(Bignum, answer) - assert_equal(number, answer) - - @input.truncate(@input.rewind) - number = 10.5002 - @input << number << "\n" - @input.rewind - - answer = @terminal.ask( "Favorite number? ", - lambda { |n| n.to_f.abs.round } ) - assert_kind_of(Integer, answer) - assert_instance_of(Fixnum, answer) - assert_equal(11, answer) - - @input.truncate(@input.rewind) - animal = :dog - @input << animal << "\n" - @input.rewind - - answer = @terminal.ask("Favorite animal? ", Symbol) - assert_instance_of(Symbol, answer) - assert_equal(animal, answer) - - @input.truncate(@input.rewind) - @input << "16th June 1976\n" - @input.rewind - - answer = @terminal.ask("Enter your birthday.", Date) - assert_instance_of(Date, answer) - assert_equal(16, answer.day) - assert_equal(6, answer.month) - assert_equal(1976, answer.year) - - @input.truncate(@input.rewind) - pattern = "^yes|no$" - @input << pattern << "\n" - @input.rewind - - answer = @terminal.ask("Give me a pattern to match with: ", Regexp) - assert_instance_of(Regexp, answer) - assert_equal(/#{pattern}/, answer) - - @input.truncate(@input.rewind) - @input << "gen\n" - @input.rewind - - answer = @terminal.ask("Select a mode: ", [:generate, :run]) - assert_instance_of(Symbol, answer) - assert_equal(:generate, answer) - end - - def test_validation - @input << "system 'rm -rf /'\n105\n0b101_001\n" - @input.rewind - - answer = @terminal.ask("Enter a binary number: ") do |q| - q.validate = /\A(?:0b)?[01_]+\Z/ - end - assert_equal("0b101_001", answer) - assert_equal( "Enter a binary number: " + - "Your answer isn't valid " + - "(must match /\\A(?:0b)?[01_]+\\Z/).\n" + - "? " + - "Your answer isn't valid " + - "(must match /\\A(?:0b)?[01_]+\\Z/).\n" + - "? ", @output.string ) - - @input.truncate(@input.rewind) - @input << "Gray II, James Edward\n" + - "Gray, Dana Ann Leslie\n" + - "Gray, James Edward\n" - @input.rewind - - answer = @terminal.ask("Your name? ") do |q| - q.validate = lambda do |name| - names = name.split(/,\s*/) - return false unless names.size == 2 - return false if names.first =~ /\s/ - names.last.split.size == 2 - end - end - assert_equal("Gray, James Edward", answer) - end - - def test_whitespace - @input << " A lot\tof \t space\t \there! \n" - @input.rewind - - answer = @terminal.ask("Enter a whitespace filled string: ") do |q| - q.whitespace = :chomp - end - assert_equal(" A lot\tof \t space\t \there! ", answer) - - @input.rewind - - answer = @terminal.ask("Enter a whitespace filled string: ") - assert_equal("A lot\tof \t space\t \there!", answer) - - @input.rewind - - answer = @terminal.ask("Enter a whitespace filled string: ") do |q| - q.whitespace = :strip_and_collapse - end - assert_equal("A lot of space here!", answer) - - @input.rewind - - answer = @terminal.ask("Enter a whitespace filled string: ") do |q| - q.whitespace = :remove - end - assert_equal("Alotofspacehere!", answer) - - @input.rewind - - answer = @terminal.ask("Enter a whitespace filled string: ") do |q| - q.whitespace = :none - end - assert_equal(" A lot\tof \t space\t \there! \n", answer) - end - - def test_wrap - @terminal.wrap_at = 80 - - @terminal.say("This is a very short line.") - assert_equal("This is a very short line.\n", @output.string) - - @output.truncate(@output.rewind) - - @terminal.say( "This is a long flowing paragraph meant to span " + - "several lines. This text should definitely be " + - "wrapped at the set limit, in the result. Your code " + - "does well with things like this.\n\n" + - " * This is a simple embedded list.\n" + - " * You're code should not mess with this...\n" + - " * Because it's already formatted correctly and " + - "does not\n" + - " exceed the limit!" ) - assert_equal( "This is a long flowing paragraph meant to span " + - "several lines. This text should\n" + - "definitely be wrapped at the set limit, in the " + - "result. Your code does well with\n" + - "things like this.\n\n" + - " * This is a simple embedded list.\n" + - " * You're code should not mess with this...\n" + - " * Because it's already formatted correctly and does " + - "not\n" + - " exceed the limit!\n", @output.string ) - - @output.truncate(@output.rewind) - - @terminal.say("-=" * 50) - assert_equal(("-=" * 40 + "\n") + ("-=" * 10 + "\n"), @output.string) - end - - def test_track_eof - assert_raise(EOFError) { @terminal.ask("Any input left? ") } - - # turn EOF tracking - old_setting = HighLine.track_eof? - assert_nothing_raised(Exception) { HighLine.track_eof = false } - begin - @terminal.ask("And now? ") # this will still blow up, nothing available - rescue - assert_not_equal(EOFError, $!.class) # but HighLine's safe guards are off - end - HighLine.track_eof = old_setting - end - - def test_version - assert_not_nil(HighLine::VERSION) - assert_instance_of(String, HighLine::VERSION) - assert(HighLine::VERSION.frozen?) - assert_match(/\A\d\.\d\.\d\Z/, HighLine::VERSION) - end -end diff --git a/vendor/gems/highline-1.5.1/test/tc_import.rb b/vendor/gems/highline-1.5.1/test/tc_import.rb deleted file mode 100644 index 005d5a928..000000000 --- a/vendor/gems/highline-1.5.1/test/tc_import.rb +++ /dev/null @@ -1,54 +0,0 @@ -#!/usr/local/bin/ruby -w - -# tc_import.rb -# -# Created by James Edward Gray II on 2005-04-26. -# Copyright 2005 Gray Productions. All rights reserved. -# -# This is Free Software. See LICENSE and COPYING for details. - -require "test/unit" - -require "highline/import" -require "stringio" - -class TestImport < Test::Unit::TestCase - def test_import - assert_respond_to(self, :agree) - assert_respond_to(self, :ask) - assert_respond_to(self, :choose) - assert_respond_to(self, :say) - end - - def test_or_ask - old_terminal = $terminal - - input = StringIO.new - output = StringIO.new - $terminal = HighLine.new(input, output) - - input << "10\n" - input.rewind - - assert_equal(10, nil.or_ask("How much? ", Integer)) - - input.rewind - - assert_equal(20, "20".or_ask("How much? ", Integer)) - assert_equal(20, 20.or_ask("How much? ", Integer)) - - assert_equal(10, 20.or_ask("How much? ", Integer) { |q| q.in = 1..10 }) - ensure - $terminal = old_terminal - end - - def test_redirection - old_terminal = $terminal - - $terminal = HighLine.new(nil, (output = StringIO.new)) - say("Testing...") - assert_equal("Testing...\n", output.string) - ensure - $terminal = old_terminal - end -end diff --git a/vendor/gems/highline-1.5.1/test/tc_menu.rb b/vendor/gems/highline-1.5.1/test/tc_menu.rb deleted file mode 100644 index fee187147..000000000 --- a/vendor/gems/highline-1.5.1/test/tc_menu.rb +++ /dev/null @@ -1,429 +0,0 @@ -#!/usr/local/bin/ruby -w - -# tc_menu.rb -# -# Created by Gregory Thomas Brown on 2005-05-10. -# Copyright 2005. All rights reserved. -# -# This is Free Software. See LICENSE and COPYING for details. - -require "test/unit" - -require "highline" -require "stringio" - -class TestMenu < Test::Unit::TestCase - def setup - @input = StringIO.new - @output = StringIO.new - @terminal = HighLine.new(@input, @output) - end - - def test_choices - @input << "2\n" - @input.rewind - - output = @terminal.choose do |menu| - menu.choices("Sample1", "Sample2", "Sample3") - end - assert_equal("Sample2", output) - end - - def test_flow - @input << "Sample1\n" - @input.rewind - - @terminal.choose do |menu| - # Default: menu.flow = :rows - - menu.choice "Sample1" - menu.choice "Sample2" - menu.choice "Sample3" - end - assert_equal("1. Sample1\n2. Sample2\n3. Sample3\n? ", @output.string) - - @output.truncate(@output.rewind) - @input.rewind - - @terminal.choose do |menu| - menu.flow = :columns_across - - menu.choice "Sample1" - menu.choice "Sample2" - menu.choice "Sample3" - end - assert_equal("1. Sample1 2. Sample2 3. Sample3\n? ", @output.string) - - @output.truncate(@output.rewind) - @input.rewind - - @terminal.choose do |menu| - menu.flow = :inline - menu.index = :none - - menu.choice "Sample1" - menu.choice "Sample2" - menu.choice "Sample3" - end - assert_equal("Sample1, Sample2 or Sample3? ", @output.string) - end - - def test_help - @input << "help\nhelp load\nhelp rules\nhelp missing\n" - @input.rewind - - 4.times do - @terminal.choose do |menu| - menu.shell = true - - menu.choice(:load, "Load a file.") - menu.choice(:save, "Save data in file.") - menu.choice(:quit, "Exit program.") - - menu.help("rules", "The rules of this system are as follows...") - end - end - assert_equal( "1. load\n2. save\n3. quit\n4. help\n? " + - "This command will display helpful messages about " + - "functionality, like this one. To see the help for a " + - "specific topic enter:\n" + - "\thelp [TOPIC]\n" + - "Try asking for help on any of the following:\n" + - "\nload quit rules save \n" + - "1. load\n2. save\n3. quit\n4. help\n? " + - "= load\n\n" + - "Load a file.\n" + - "1. load\n2. save\n3. quit\n4. help\n? " + - "= rules\n\n" + - "The rules of this system are as follows...\n" + - "1. load\n2. save\n3. quit\n4. help\n? " + - "= missing\n\n" + - "There's no help for that topic.\n", @output.string ) - end - - def test_index - @input << "Sample1\n" - @input.rewind - - @terminal.choose do |menu| - # Default: menu.index = :number - - menu.choice "Sample1" - menu.choice "Sample2" - menu.choice "Sample3" - end - assert_equal("1. Sample1\n2. Sample2\n3. Sample3\n? ", @output.string) - - @output.truncate(@output.rewind) - @input.rewind - - @terminal.choose do |menu| - menu.index = :letter - menu.index_suffix = ") " - - menu.choice "Sample1" - menu.choice "Sample2" - menu.choice "Sample3" - end - assert_equal("a) Sample1\nb) Sample2\nc) Sample3\n? ", @output.string) - - @output.truncate(@output.rewind) - @input.rewind - - @terminal.choose do |menu| - menu.index = :none - - menu.choice "Sample1" - menu.choice "Sample2" - menu.choice "Sample3" - end - assert_equal("Sample1\nSample2\nSample3\n? ", @output.string) - - @output.truncate(@output.rewind) - @input.rewind - - @terminal.choose do |menu| - menu.index = "*" - - menu.choice "Sample1" - menu.choice "Sample2" - menu.choice "Sample3" - end - assert_equal("* Sample1\n* Sample2\n* Sample3\n? ", @output.string) - end - - def test_layouts - @input << "save\n" - @input.rewind - - @terminal.choose(:load, :save, :quit) # Default: layout = :list - assert_equal("1. load\n2. save\n3. quit\n? ", @output.string) - - @input.rewind - @output.truncate(@output.rewind) - - @terminal.choose(:load, :save, :quit) do |menu| - menu.header = "File Menu" - end - assert_equal( "File Menu:\n" + - "1. load\n2. save\n3. quit\n? ", @output.string ) - - @input.rewind - @output.truncate(@output.rewind) - - @terminal.choose(:load, :save, :quit) do |menu| - menu.layout = :one_line - menu.header = "File Menu" - menu.prompt = "Operation? " - end - assert_equal( "File Menu: Operation? " + - "(load, save or quit) ", @output.string ) - - @input.rewind - @output.truncate(@output.rewind) - - @terminal.choose(:load, :save, :quit) do |menu| - menu.layout = :menu_only - end - assert_equal("load, save or quit? ", @output.string) - - @input.rewind - @output.truncate(@output.rewind) - - @terminal.choose(:load, :save, :quit) do |menu| - menu.layout = '<%= list(@menu) %>File Menu: ' - end - assert_equal("1. load\n2. save\n3. quit\nFile Menu: ", @output.string) - end - - def test_list_option - @input << "l\n" - @input.rewind - - @terminal.choose(:load, :save, :quit) do |menu| - menu.layout = :menu_only - menu.list_option = ", or " - end - assert_equal("load, save, or quit? ", @output.string) - end - - def test_nil_on_handled - @input << "3\n3\n2\n" - @input.rewind - - # Shows that by default proc results are returned. - output = @terminal.choose do |menu| - menu.choice "Sample1" do "output1" end - menu.choice "Sample2" do "output2" end - menu.choice "Sample3" do "output3" end - end - assert_equal("output3", output) - - # - # Shows that they can be replaced with +nil+ by setting - # _nil_on_handled to +true+. - # - output = @terminal.choose do |menu| - menu.nil_on_handled = true - menu.choice "Sample1" do "output1" end - menu.choice "Sample2" do "output2" end - menu.choice "Sample3" do "output3" end - end - assert_equal(nil, output) - - # Shows that a menu item without a proc will be returned no matter what. - output = @terminal.choose do |menu| - menu.choice "Sample1" - menu.choice "Sample2" - menu.choice "Sample3" - end - assert_equal("Sample2", output) - end - - def test_passed_command - @input << "q\n" - @input.rewind - - selected = nil - @terminal.choose do |menu| - menu.choices(:load, :save, :quit) { |command| selected = command } - end - assert_equal(:quit, selected) - end - - def test_question_options - @input << "save\n" - @input.rewind - - answer = @terminal.choose(:Load, :Save, :Quit) do |menu| - menu.case = :capitalize - end - assert_equal(:Save, answer) - - @input.rewind - - answer = @terminal.choose(:Load, :Save, :Quit) do |menu| - menu.case = :capitalize - menu.character = :getc - end - assert_equal(:Save, answer) - assert_equal(?a, @input.getc) - end - - def test_select_by - @input << "Sample1\n2\n" - @input.rewind - - selected = @terminal.choose do |menu| - menu.choice "Sample1" - menu.choice "Sample2" - menu.choice "Sample3" - end - assert_equal("Sample1", selected) - - @input.rewind - - selected = @terminal.choose do |menu| - menu.select_by = :index - - menu.choice "Sample1" - menu.choice "Sample2" - menu.choice "Sample3" - end - assert_equal("Sample2", selected) - - @input.rewind - - selected = @terminal.choose do |menu| - menu.select_by = :name - - menu.choice "Sample1" - menu.choice "Sample2" - menu.choice "Sample3" - end - assert_equal("Sample1", selected) - end - - def test_hidden - @input << "Hidden\n4\n" - @input.rewind - - selected = @terminal.choose do |menu| - menu.choice "Sample1" - menu.choice "Sample2" - menu.choice "Sample3" - menu.hidden "Hidden!" - end - assert_equal("Hidden!", selected) - assert_equal("1. Sample1\n2. Sample2\n3. Sample3\n? ", @output.string) - - @input.rewind - - selected = @terminal.choose do |menu| - menu.select_by = :index - - menu.choice "Sample1" - menu.choice "Sample2" - menu.choice "Sample3" - menu.hidden "Hidden!" - end - assert_equal("Hidden!", selected) - - @input.rewind - - selected = @terminal.choose do |menu| - menu.select_by = :name - - menu.choice "Sample1" - menu.choice "Sample2" - menu.choice "Sample3" - menu.hidden "Hidden!" - end - assert_equal("Hidden!", selected) - - @input.rewind - end - - def test_select_by_letter - @input << "b\n" - @input.rewind - - selected = @terminal.choose do |menu| - menu.index = :letter - menu.choice :save - menu.choice :load - menu.choice :quit - end - assert_equal(:load, selected) - end - - def test_shell - @input << "save --some-option my_file.txt\n" - @input.rewind - - selected = nil - options = nil - answer = @terminal.choose do |menu| - menu.choices(:load, :quit) - menu.choice(:save) do |command, details| - selected = command - options = details - - "Saved!" - end - menu.shell = true - end - assert_equal("Saved!", answer) - assert_equal(:save, selected) - assert_equal("--some-option my_file.txt", options) - end - - def test_simple_menu_shortcut - @input << "3\n" - @input.rewind - - selected = @terminal.choose(:save, :load, :quit) - assert_equal(:quit, selected) - end - - def test_symbols - @input << "3\n" - @input.rewind - - selected = @terminal.choose do |menu| - menu.choices(:save, :load, :quit) - end - assert_equal(:quit, selected) - end - - def test_paged_print_infinite_loop_bug - @terminal.page_at = 5 - # Will page twice, so start with two new lines - @input << "\n\n3\n" - @input.rewind - - # Sadly this goes into an infinite loop without the fix to page_print - selected = @terminal.choose(* 1..10) - assert_equal(selected, 3) - end - - - def test_cancel_paging - # Tests that paging can be cancelled halfway through - @terminal.page_at = 5 - # Will page twice, so stop after first page and make choice 3 - @input << "q\n3\n" - @input.rewind - - selected = @terminal.choose(* 1..10) - assert_equal(selected, 3) - - # Make sure paging message appeared - assert( @output.string.index('press enter/return to continue or q to stop'), - "Paging message did not appear." ) - - # Make sure it only appeared once - assert( @output.string !~ /q to stop.*q to stop/m, - "Paging message appeared more than once." ) - end -end diff --git a/vendor/gems/highline-1.5.1/test/ts_all.rb b/vendor/gems/highline-1.5.1/test/ts_all.rb deleted file mode 100644 index 735dccee5..000000000 --- a/vendor/gems/highline-1.5.1/test/ts_all.rb +++ /dev/null @@ -1,15 +0,0 @@ -#!/usr/local/bin/ruby -w - -# ts_all.rb -# -# Created by James Edward Gray II on 2005-04-26. -# Copyright 2005 Gray Productions. All rights reserved. -# -# This is Free Software. See LICENSE and COPYING for details. - -require "test/unit" - -require "tc_highline" -require "tc_import" -require "tc_menu" -require "tc_color_scheme" diff --git a/vendor/gems/net-scp-1.0.2/.specification b/vendor/gems/net-scp-1.0.2/.specification deleted file mode 100644 index f930a92c5..000000000 --- a/vendor/gems/net-scp-1.0.2/.specification +++ /dev/null @@ -1,104 +0,0 @@ ---- !ruby/object:Gem::Specification -name: net-scp -version: !ruby/object:Gem::Version - version: 1.0.2 -platform: ruby -authors: -- Jamis Buck -autorequire: -bindir: bin -cert_chain: [] - -date: 2009-02-04 00:00:00 +00:00 -default_executable: -dependencies: -- !ruby/object:Gem::Dependency - name: net-ssh - type: :runtime - version_requirement: - version_requirements: !ruby/object:Gem::Requirement - requirements: - - - ">=" - - !ruby/object:Gem::Version - version: 1.99.1 - version: -- !ruby/object:Gem::Dependency - name: echoe - type: :development - version_requirement: - version_requirements: !ruby/object:Gem::Requirement - requirements: - - - ">=" - - !ruby/object:Gem::Version - version: "0" - version: -description: A pure Ruby implementation of the SCP client protocol -email: jamis@jamisbuck.org -executables: [] - -extensions: [] - -extra_rdoc_files: -- CHANGELOG.rdoc -- lib/net/scp/download.rb -- lib/net/scp/errors.rb -- lib/net/scp/upload.rb -- lib/net/scp/version.rb -- lib/net/scp.rb -- lib/uri/open-scp.rb -- lib/uri/scp.rb -- README.rdoc -files: -- CHANGELOG.rdoc -- lib/net/scp/download.rb -- lib/net/scp/errors.rb -- lib/net/scp/upload.rb -- lib/net/scp/version.rb -- lib/net/scp.rb -- lib/uri/open-scp.rb -- lib/uri/scp.rb -- Rakefile -- README.rdoc -- setup.rb -- test/common.rb -- test/test_all.rb -- test/test_download.rb -- test/test_scp.rb -- test/test_upload.rb -- Manifest -- net-scp.gemspec -has_rdoc: true -homepage: http://net-ssh.rubyforge.org/scp -licenses: [] - -post_install_message: -rdoc_options: -- --line-numbers -- --inline-source -- --title -- Net-scp -- --main -- README.rdoc -require_paths: -- lib -required_ruby_version: !ruby/object:Gem::Requirement - requirements: - - - ">=" - - !ruby/object:Gem::Version - version: "0" - version: -required_rubygems_version: !ruby/object:Gem::Requirement - requirements: - - - ">=" - - !ruby/object:Gem::Version - version: "1.2" - version: -requirements: [] - -rubyforge_project: net-ssh -rubygems_version: 1.3.4 -signing_key: -specification_version: 2 -summary: A pure Ruby implementation of the SCP client protocol -test_files: -- test/test_all.rb diff --git a/vendor/gems/net-scp-1.0.2/CHANGELOG.rdoc b/vendor/gems/net-scp-1.0.2/CHANGELOG.rdoc deleted file mode 100644 index 1b5fd66ca..000000000 --- a/vendor/gems/net-scp-1.0.2/CHANGELOG.rdoc +++ /dev/null @@ -1,18 +0,0 @@ -=== 1.0.2 / 4 Feb 2009 - -* Escape spaces in file names on remote server [Jamis Buck] - - -=== 1.0.1 / 29 May 2008 - -* Make sure downloads open the file in binary mode to appease Windows [Jamis Buck] - - -=== 1.0.0 / 1 May 2008 - -* Pass the channel object as the first argument to the progress callback [Jamis Buck] - - -=== 1.0 Preview Release 1 (0.99.0) / 22 Mar 2008 - -* Birthday! diff --git a/vendor/gems/net-scp-1.0.2/Manifest b/vendor/gems/net-scp-1.0.2/Manifest deleted file mode 100644 index 9614d5713..000000000 --- a/vendor/gems/net-scp-1.0.2/Manifest +++ /dev/null @@ -1,17 +0,0 @@ -CHANGELOG.rdoc -lib/net/scp/download.rb -lib/net/scp/errors.rb -lib/net/scp/upload.rb -lib/net/scp/version.rb -lib/net/scp.rb -lib/uri/open-scp.rb -lib/uri/scp.rb -Rakefile -README.rdoc -setup.rb -test/common.rb -test/test_all.rb -test/test_download.rb -test/test_scp.rb -test/test_upload.rb -Manifest diff --git a/vendor/gems/net-scp-1.0.2/README.rdoc b/vendor/gems/net-scp-1.0.2/README.rdoc deleted file mode 100644 index 480690ea4..000000000 --- a/vendor/gems/net-scp-1.0.2/README.rdoc +++ /dev/null @@ -1,98 +0,0 @@ -= Net::SCP - -* http://net-ssh.rubyforge.org/scp - -== DESCRIPTION: - -Net::SCP is a pure-Ruby implementation of the SCP protocol. This operates over SSH (and requires the Net::SSH library), and allows files and directory trees to copied to and from a remote server. - -== FEATURES/PROBLEMS: - -* Transfer files or entire directory trees to or from a remote host via SCP -* Can preserve file attributes across transfers -* Can download files in-memory, or direct-to-disk -* Support for SCP URI's, and OpenURI - -== SYNOPSIS: - -In a nutshell: - - require 'net/scp' - - # upload a file to a remote server - Net::SCP.upload!("remote.host.com", "username", - "/local/path", "/remote/path", - :password => "password") - - # download a file from a remote server - Net::SCP.download!("remote.host.com", "username", - "/remote/path", "/local/path", - :password => password) - - # download a file to an in-memory buffer - data = Net::SCP::download!("remote.host.com", "username", "/remote/path") - - # use a persistent connection to transfer files - Net::SCP.start("remote.host.com", "username", :password => "password") do |scp| - # upload a file to a remote server - scp.upload! "/local/path", "/remote/path" - - # upload from an in-memory buffer - scp.upload! StringIO.new("some data to upload"), "/remote/path" - - # run multiple downloads in parallel - d1 = scp.download("/remote/path", "/local/path") - d2 = scp.download("/remote/path2", "/local/path2") - [d1, d2].each { |d| d.wait } - end - - # You can also use open-uri to grab data via scp: - require 'uri/open-scp' - data = open("scp://user@host/path/to/file.txt").read - -For more information, see Net::SCP. - -== REQUIREMENTS: - -* Net::SSH 2 - -If you wish to run the tests, you'll also need: - -* Echoe (for Rakefile use) -* Mocha (for tests) - -== INSTALL: - -* gem install net-scp (might need sudo privileges) - -Or, you can do it the hard way (without Rubygems): - -* tar xzf net-scp-*.tgz -* cd net-scp-* -* ruby setup.rb config -* ruby setup.rb install (might need sudo privileges) - -== LICENSE: - -(The MIT License) - -Copyright (c) 2008 Jamis Buck - -Permission is hereby granted, free of charge, to any person obtaining -a copy of this software and associated documentation files (the -'Software'), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, sublicense, and/or sell copies of the Software, and to -permit persons to whom the Software is furnished to do so, subject to -the following conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY -CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, -TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/vendor/gems/net-scp-1.0.2/Rakefile b/vendor/gems/net-scp-1.0.2/Rakefile deleted file mode 100644 index ac95f2718..000000000 --- a/vendor/gems/net-scp-1.0.2/Rakefile +++ /dev/null @@ -1,30 +0,0 @@ -$LOAD_PATH.unshift "../net-ssh/lib" -require './lib/net/scp/version' - -begin - require 'echoe' -rescue LoadError - abort "You'll need to have `echoe' installed to use Net::SCP's Rakefile" -end - -version = Net::SCP::Version::STRING.dup -if ENV['SNAPSHOT'].to_i == 1 - version << "." << Time.now.utc.strftime("%Y%m%d%H%M%S") -end - -Echoe.new('net-scp', version) do |p| - p.project = "net-ssh" - p.changelog = "CHANGELOG.rdoc" - - p.author = "Jamis Buck" - p.email = "jamis@jamisbuck.org" - p.summary = "A pure Ruby implementation of the SCP client protocol" - p.url = "http://net-ssh.rubyforge.org/scp" - - p.dependencies = ["net-ssh >=1.99.1"] - - p.need_zip = true - p.include_rakefile = true - - p.rdoc_pattern = /^(lib|README.rdoc|CHANGELOG.rdoc)/ -end \ No newline at end of file diff --git a/vendor/gems/net-scp-1.0.2/lib/net/scp.rb b/vendor/gems/net-scp-1.0.2/lib/net/scp.rb deleted file mode 100644 index 99756f7ca..000000000 --- a/vendor/gems/net-scp-1.0.2/lib/net/scp.rb +++ /dev/null @@ -1,414 +0,0 @@ -require 'stringio' - -require 'net/ssh' -require 'net/scp/errors' -require 'net/scp/upload' -require 'net/scp/download' - -module Net - - # Net::SCP implements the SCP (Secure CoPy) client protocol, allowing Ruby - # programs to securely and programmatically transfer individual files or - # entire directory trees to and from remote servers. It provides support for - # multiple simultaneous SCP copies working in parallel over the same - # connection, as well as for synchronous, serial copies. - # - # Basic usage: - # - # require 'net/scp' - # - # Net::SCP.start("remote.host", "username", :password => "passwd") do |scp| - # # synchronous (blocking) upload; call blocks until upload completes - # scp.upload! "/local/path", "/remote/path" - # - # # asynchronous upload; call returns immediately and requires SSH - # # event loop to run - # channel = scp.upload("/local/path", "/remote/path") - # channel.wait - # end - # - # Net::SCP also provides an open-uri tie-in, so you can use the Kernel#open - # method to open and read a remote file: - # - # # if you just want to parse SCP URL's: - # require 'uri/scp' - # url = URI.parse("scp://user@remote.host/path/to/file") - # - # # if you want to read from a URL voa SCP: - # require 'uri/open-scp' - # puts open("scp://user@remote.host/path/to/file").read - # - # Lastly, Net::SCP adds a method to the Net::SSH::Connection::Session class, - # allowing you to easily grab a Net::SCP reference from an existing Net::SSH - # session: - # - # require 'net/ssh' - # require 'net/scp' - # - # Net::SSH.start("remote.host", "username", :password => "passwd") do |ssh| - # ssh.scp.download! "/remote/path", "/local/path" - # end - # - # == Progress Reporting - # - # By default, uploading and downloading proceed silently, without any - # outword indication of their progress. For long running uploads or downloads - # (and especially in interactive environments) it is desirable to report - # to the user the progress of the current operation. - # - # To receive progress reports for the current operation, just pass a block - # to #upload or #download (or one of their variants): - # - # scp.upload!("/path/to/local", "/path/to/remote") do |ch, name, sent, total| - # puts "#{name}: #{sent}/#{total}" - # end - # - # Whenever a new chunk of data is recieved for or sent to a file, the callback - # will be invoked, indicating the name of the file (local for downloads, - # remote for uploads), the number of bytes that have been sent or received - # so far for the file, and the size of the file. - # - #-- - # = Protocol Description - # - # Although this information has zero relevance to consumers of the Net::SCP - # library, I'm documenting it here so that anyone else looking for documentation - # of the SCP protocol won't be left high-and-dry like I was. The following is - # reversed engineered from the OpenSSH SCP implementation, and so may - # contain errors. You have been warned! - # - # The first step is to invoke the "scp" command on the server. It accepts - # the following parameters, which must be set correctly to avoid errors: - # - # * "-t" -- tells the remote scp process that data will be sent "to" it, - # e.g., that data will be uploaded and it should initialize itself - # accordingly. - # * "-f" -- tells the remote scp process that data should come "from" it, - # e.g., that data will be downloaded and it should initialize itself - # accordingly. - # * "-v" -- verbose mode; the remote scp process should chatter about what - # it is doing via stderr. - # * "-p" -- preserve timestamps. 'T' directives (see below) should be/will - # be sent to indicate the modification and access times of each file. - # * "-r" -- recursive transfers should be allowed. Without this, it is an - # error to upload or download a directory. - # - # After those flags, the name of the remote file/directory should be passed - # as the sole non-switch argument to scp. - # - # Then the fun begins. If you're doing a download, enter the download_start_state. - # Otherwise, look for upload_start_state. - # - # == Net::SCP::Download#download_start_state - # - # This is the start state for downloads. It simply sends a 0-byte to the - # server. The next state is Net::SCP::Download#read_directive_state. - # - # == Net::SCP::Upload#upload_start_state - # - # Sets up the initial upload scaffolding and waits for a 0-byte from the - # server, and then switches to Net::SCP::Upload#upload_current_state. - # - # == Net::SCP::Download#read_directive_state - # - # Reads a directive line from the input. The following directives are - # recognized: - # - # * T%d %d %d %d -- a "times" packet. Indicates that the next file to be - # downloaded must have mtime/usec/atime/usec attributes preserved. - # * D%o %d %s -- a directory change. The process is changing to a directory - # with the given permissions/size/name, and the recipient should create - # a directory with the same name and permissions. Subsequent files and - # directories will be children of this directory, until a matching 'E' - # directive. - # * C%o %d %s -- a file is being sent next. The file will have the given - # permissions/size/name. Immediately following this line, +size+ bytes - # will be sent, raw. - # * E -- terminator directive. Indicates the end of a directory, and subsequent - # files and directories should be received by the parent of the current - # directory. - # - # If a 'C' directive is received, we switch over to - # Net::SCP::Download#read_data_state. If an 'E' directive is received, and - # there is no parent directory, we switch over to Net::SCP#finish_state. - # - # Regardless of what the next state is, we send a 0-byte to the server - # before moving to the next state. - # - # == Net::SCP::Download#read_data_state - # - # Bytes are read to satisfy the size of the incoming file. When all pending - # data has been read, we wait for the server to send a 0-byte, and then we - # switch to the Net::SCP::Download#finish_read_state. - # - # == Net::SCP::Download#finish_read_state - # - # We sent a 0-byte to the server to indicate that the file was successfully - # received. If there is no parent directory, then we're downloading a single - # file and we switch to Net::SCP#finish_state. Otherwise we jump back to the - # Net::SCP::Download#read_directive state to see what we get to download next. - # - # == Net::SCP::Upload#upload_current_state - # - # If the current item is a file, send a file. Sending a file starts with a - # 'T' directive (if :preserve is true), then a wait for the server to respond, - # and then a 'C' directive, and then a wait for the server to respond, and - # then a jump to Net::SCP::Upload#send_data_state. - # - # If current item is a directory, send a 'D' directive, and wait for the - # server to respond with a 0-byte. Then jump to Net::SCP::Upload#next_item_state. - # - # == Net::SCP::Upload#send_data_state - # - # Reads and sends the next chunk of data to the server. The state machine - # remains in this state until all data has been sent, at which point we - # send a 0-byte to the server, and wait for the server to respond with a - # 0-byte of its own. Then we jump back to Net::SCP::Upload#next_item_state. - # - # == Net::SCP::Upload#next_item_state - # - # If there is nothing left to upload, and there is no parent directory, - # jump to Net::SCP#finish_state. - # - # If there is nothing left to upload from the current directory, send an - # 'E' directive and wait for the server to respond with a 0-byte. Then go - # to Net::SCP::Upload#next_item_state. - # - # Otherwise, set the current upload source and go to - # Net::SCP::Upload#upload_current_state. - # - # == Net::SCP#finish_state - # - # Tells the server that no more data is forthcoming from this end of the - # pipe (via Net::SSH::Connection::Channel#eof!) and leaves the pipe to drain. - # It will be terminated when the remote process closes with an exit status - # of zero. - #++ - class SCP - include Net::SSH::Loggable - include Upload, Download - - # Starts up a new SSH connection and instantiates a new SCP session on - # top of it. If a block is given, the SCP session is yielded, and the - # SSH session is closed automatically when the block terminates. If no - # block is given, the SCP session is returned. - def self.start(host, username, options={}) - session = Net::SSH.start(host, username, options) - scp = new(session) - - if block_given? - begin - yield scp - session.loop - ensure - session.close - end - else - return scp - end - end - - # Starts up a new SSH connection using the +host+ and +username+ parameters, - # instantiates a new SCP session on top of it, and then begins an - # upload from +local+ to +remote+. If the +options+ hash includes an - # :ssh key, the value for that will be passed to the SSH connection as - # options (e.g., to set the password, etc.). All other options are passed - # to the #upload! method. If a block is given, it will be used to report - # progress (see "Progress Reporting", under Net::SCP). - def self.upload!(host, username, local, remote, options={}, &progress) - options = options.dup - start(host, username, options.delete(:ssh) || {}) do |scp| - scp.upload!(local, remote, options, &progress) - end - end - - # Starts up a new SSH connection using the +host+ and +username+ parameters, - # instantiates a new SCP session on top of it, and then begins a - # download from +remote+ to +local+. If the +options+ hash includes an - # :ssh key, the value for that will be passed to the SSH connection as - # options (e.g., to set the password, etc.). All other options are passed - # to the #download! method. If a block is given, it will be used to report - # progress (see "Progress Reporting", under Net::SCP). - def self.download!(host, username, remote, local=nil, options={}, &progress) - options = options.dup - start(host, username, options.delete(:ssh) || {}) do |scp| - return scp.download!(remote, local, options, &progress) - end - end - - # The underlying Net::SSH session that acts as transport for the SCP - # packets. - attr_reader :session - - # Creates a new Net::SCP session on top of the given Net::SSH +session+ - # object. - def initialize(session) - @session = session - self.logger = session.logger - end - - # Inititiate a synchronous (non-blocking) upload from +local+ to +remote+. - # The following options are recognized: - # - # * :recursive - the +local+ parameter refers to a local directory, which - # should be uploaded to a new directory named +remote+ on the remote - # server. - # * :preserve - the atime and mtime of the file should be preserved. - # * :verbose - the process should result in verbose output on the server - # end (useful for debugging). - # * :chunk_size - the size of each "chunk" that should be sent. Defaults - # to 2048. Changing this value may improve throughput at the expense - # of decreasing interactivity. - # - # This method will return immediately, returning the Net::SSH::Connection::Channel - # object that will support the upload. To wait for the upload to finish, - # you can either call the #wait method on the channel, or otherwise run - # the Net::SSH event loop until the channel's #active? method returns false. - # - # channel = scp.upload("/local/path", "/remote/path") - # channel.wait - def upload(local, remote, options={}, &progress) - start_command(:upload, local, remote, options, &progress) - end - - # Same as #upload, but blocks until the upload finishes. Identical to - # calling #upload and then calling the #wait method on the channel object - # that is returned. The return value is not defined. - def upload!(local, remote, options={}, &progress) - upload(local, remote, options, &progress).wait - end - - # Inititiate a synchronous (non-blocking) download from +remote+ to +local+. - # The following options are recognized: - # - # * :recursive - the +remote+ parameter refers to a remote directory, which - # should be downloaded to a new directory named +local+ on the local - # machine. - # * :preserve - the atime and mtime of the file should be preserved. - # * :verbose - the process should result in verbose output on the server - # end (useful for debugging). - # - # This method will return immediately, returning the Net::SSH::Connection::Channel - # object that will support the download. To wait for the download to finish, - # you can either call the #wait method on the channel, or otherwise run - # the Net::SSH event loop until the channel's #active? method returns false. - # - # channel = scp.download("/remote/path", "/local/path") - # channel.wait - def download(remote, local, options={}, &progress) - start_command(:download, local, remote, options, &progress) - end - - # Same as #download, but blocks until the download finishes. Identical to - # calling #download and then calling the #wait method on the channel - # object that is returned. - # - # scp.download!("/remote/path", "/local/path") - # - # If +local+ is nil, and the download is not recursive (e.g., it is downloading - # only a single file), the file will be downloaded to an in-memory buffer - # and the resulting string returned. - # - # data = download!("/remote/path") - def download!(remote, local=nil, options={}, &progress) - destination = local ? local : StringIO.new - download(remote, destination, options, &progress).wait - local ? true : destination.string - end - - private - - # Constructs the scp command line needed to initiate and SCP session - # for the given +mode+ (:upload or :download) and with the given options - # (:verbose, :recursive, :preserve). Returns the command-line as a - # string, ready to execute. - def scp_command(mode, options) - command = "scp " - command << (mode == :upload ? "-t" : "-f") - command << " -v" if options[:verbose] - command << " -r" if options[:recursive] - command << " -p" if options[:preserve] - command - end - - # Opens a new SSH channel and executes the necessary SCP command over - # it (see #scp_command). It then sets up the necessary callbacks, and - # sets up a state machine to use to process the upload or download. - # (See Net::SCP::Upload and Net::SCP::Download). - def start_command(mode, local, remote, options={}, &callback) - session.open_channel do |channel| - command = "#{scp_command(mode, options)} #{sanitize_file_name(remote)}" - channel.exec(command) do |ch, success| - if success - channel[:local ] = local - channel[:remote ] = remote - channel[:options ] = options.dup - channel[:callback] = callback - channel[:buffer ] = Net::SSH::Buffer.new - channel[:state ] = "#{mode}_start" - channel[:stack ] = [] - - channel.on_close { |ch| raise Net::SCP::Error, "SCP did not finish successfully (#{ch[:exit]})" if ch[:exit] != 0 } - channel.on_data { |ch, data| channel[:buffer].append(data) } - channel.on_extended_data { |ch, type, data| debug { data.chomp } } - channel.on_request("exit-status") { |ch, data| channel[:exit] = data.read_long } - channel.on_process { send("#{channel[:state]}_state", channel) } - else - channel.close - raise Net::SCP::Error, "could not exec scp on the remote host" - end - end - end - end - - # Causes the state machine to enter the "await response" state, where - # things just pause until the server replies with a 0 (see - # #await_response_state), at which point the state machine will pick up - # at +next_state+ and continue processing. - def await_response(channel, next_state) - channel[:state] = :await_response - channel[:next ] = next_state.to_sym - # check right away, to see if the response is immediately available - await_response_state(channel) - end - - # The action invoked while the state machine remains in the "await - # response" state. As long as there is no data ready to process, the - # machine will remain in this state. As soon as the server replies with - # an integer 0 as the only byte, the state machine is kicked into the - # next state (see +await_response+). If the response is not a 0, an - # exception is raised. - def await_response_state(channel) - return if channel[:buffer].available == 0 - c = channel[:buffer].read_byte - raise "#{c.chr}#{channel[:buffer].read}" if c != 0 - channel[:next], channel[:state] = nil, channel[:next] - send("#{channel[:state]}_state", channel) - end - - # The action invoked when the state machine is in the "finish" state. - # It just tells the server not to expect any more data from this end - # of the pipe, and allows the pipe to drain until the server closes it. - def finish_state(channel) - channel.eof! - end - - # Invoked to report progress back to the client. If a callback was not - # set, this does nothing. - def progress_callback(channel, name, sent, total) - channel[:callback].call(channel, name, sent, total) if channel[:callback] - end - - def sanitize_file_name(file_name) - file_name.gsub(/[ ]/) { |m| "\\#{m}" } - end - end -end - -class Net::SSH::Connection::Session - # Provides a convenient way to initialize a SCP session given a Net::SSH - # session. Returns the Net::SCP instance, ready to use. - def scp - @scp ||= Net::SCP.new(self) - end -end diff --git a/vendor/gems/net-scp-1.0.2/lib/net/scp/download.rb b/vendor/gems/net-scp-1.0.2/lib/net/scp/download.rb deleted file mode 100644 index 3384f456d..000000000 --- a/vendor/gems/net-scp-1.0.2/lib/net/scp/download.rb +++ /dev/null @@ -1,150 +0,0 @@ -require 'net/scp/errors' - -module Net; class SCP - - # This module implements the state machine for downloading information from - # a remote server. It exposes no public methods. See Net::SCP#download for - # a discussion of how to use Net::SCP to download data. - module Download - private - - # This is the starting state for the download state machine. The - # #start_command method puts the state machine into this state the first - # time the channel is processed. This state does some basic error checking - # and scaffolding and then sends a 0-byte to the remote server, indicating - # readiness to proceed. Then, the state machine is placed into the - # "read directive" state (see #read_directive_state). - def download_start_state(channel) - if channel[:local].respond_to?(:write) && channel[:options][:recursive] - raise Net::SCP::Error, "cannot recursively download to an in-memory location" - elsif channel[:local].respond_to?(:write) && channel[:options][:preserve] - lwarn { ":preserve option is ignored when downloading to an in-memory buffer" } - channel[:options].delete(:preserve) - elsif channel[:options][:recursive] && !File.exists?(channel[:local]) - Dir.mkdir(channel[:local]) - end - - channel.send_data("\0") - channel[:state] = :read_directive - end - - # This state parses the next full line (up to a new-line) for the next - # directive. (See the SCP protocol documentation in Net::SCP for the - # possible directives). - def read_directive_state(channel) - return unless line = channel[:buffer].read_to("\n") - channel[:buffer].consume! - - directive = parse_directive(line) - case directive[:type] - when :times then - channel[:times] = directive - when :directory - read_directory(channel, directive) - when :file - read_file(channel, directive) - when :end - channel[:local] = File.dirname(channel[:local]) - channel[:stack].pop - channel[:state] = :finish if channel[:stack].empty? - end - - channel.send_data("\0") - end - - # Reads data from the channel for as long as there is data remaining to - # be read. As soon as there is no more data to read for the current file, - # the state machine switches to #finish_read_state. - def read_data_state(channel) - return if channel[:buffer].empty? - data = channel[:buffer].read!(channel[:remaining]) - channel[:io].write(data) - channel[:remaining] -= data.length - progress_callback(channel, channel[:file][:name], channel[:file][:size] - channel[:remaining], channel[:file][:size]) - await_response(channel, :finish_read) if channel[:remaining] <= 0 - end - - # Finishes off the read, sets the times for the file (if any), and then - # jumps to either #finish_state (for single-file downloads) or - # #read_directive_state (for recursive downloads). A 0-byte is sent to the - # server to indicate that the file was recieved successfully. - def finish_read_state(channel) - channel[:io].close unless channel[:io] == channel[:local] - - if channel[:options][:preserve] && channel[:file][:times] - File.utime(channel[:file][:times][:atime], - channel[:file][:times][:mtime], channel[:file][:name]) - end - - channel[:file] = nil - channel[:state] = channel[:stack].empty? ? :finish : :read_directive - channel.send_data("\0") - end - - # Parses the given +text+ to extract which SCP directive it contains. It - # then returns a hash with at least one key, :type, which describes what - # type of directive it is. The hash may also contain other, directive-specific - # data. - def parse_directive(text) - case type = text[0] - when ?T - parts = text[1..-1].split(/ /, 4).map { |i| i.to_i } - { :type => :times, - :mtime => Time.at(parts[0], parts[1]), - :atime => Time.at(parts[2], parts[3]) } - when ?C, ?D - parts = text[1..-1].split(/ /, 3) - { :type => (type == ?C ? :file : :directory), - :mode => parts[0].to_i(8), - :size => parts[1].to_i, - :name => parts[2].chomp } - when ?E - { :type => :end } - else raise ArgumentError, "unknown directive: #{text.inspect}" - end - end - - # Sets the new directory as the current directory, creates the directory - # if it does not exist, and then falls back into #read_directive_state. - def read_directory(channel, directive) - if !channel[:options][:recursive] - raise Net::SCP::Error, ":recursive not specified for directory download" - end - - channel[:local] = File.join(channel[:local], directive[:name]) - - if File.exists?(channel[:local]) && !File.directory?(channel[:local]) - raise "#{channel[:local]} already exists and is not a directory" - elsif !File.exists?(channel[:local]) - Dir.mkdir(channel[:local], directive[:mode] | 0700) - end - - if channel[:options][:preserve] && channel[:times] - File.utime(channel[:times][:atime], channel[:times][:mtime], channel[:local]) - end - - channel[:stack] << directive - channel[:times] = nil - end - - # Opens the given file locally, and switches to #read_data_state to do the - # actual read. - def read_file(channel, directive) - if !channel[:local].respond_to?(:write) - directive[:name] = (channel[:options][:recursive] || File.directory?(channel[:local])) ? - File.join(channel[:local], directive[:name]) : - channel[:local] - end - - channel[:file] = directive.merge(:times => channel[:times]) - channel[:io] = channel[:local].respond_to?(:write) ? channel[:local] : - File.new(directive[:name], "wb", directive[:mode] | 0600) - channel[:times] = nil - channel[:remaining] = channel[:file][:size] - channel[:state] = :read_data - - progress_callback(channel, channel[:file][:name], 0, channel[:file][:size]) - end - end - -end; end \ No newline at end of file diff --git a/vendor/gems/net-scp-1.0.2/lib/net/scp/errors.rb b/vendor/gems/net-scp-1.0.2/lib/net/scp/errors.rb deleted file mode 100644 index 9687decf9..000000000 --- a/vendor/gems/net-scp-1.0.2/lib/net/scp/errors.rb +++ /dev/null @@ -1,5 +0,0 @@ -module Net; class SCP - - class Error < RuntimeError; end - -end; end \ No newline at end of file diff --git a/vendor/gems/net-scp-1.0.2/lib/net/scp/upload.rb b/vendor/gems/net-scp-1.0.2/lib/net/scp/upload.rb deleted file mode 100644 index 1e62e7d71..000000000 --- a/vendor/gems/net-scp-1.0.2/lib/net/scp/upload.rb +++ /dev/null @@ -1,142 +0,0 @@ -require 'net/scp/errors' - -module Net; class SCP - - # This module implements the state machine for uploading information to - # a remote server. It exposes no public methods. See Net::SCP#upload for - # a discussion of how to use Net::SCP to upload data. - module Upload - private - - # The default read chunk size, if an explicit chunk-size is not specified - # by the client. - DEFAULT_CHUNK_SIZE = 2048 - - # The start state for uploads. Simply sets up the upload scaffolding, - # sets the current item to upload, and jumps to #upload_current_state. - def upload_start_state(channel) - if channel[:local].respond_to?(:read) - channel[:options].delete(:recursive) - channel[:options].delete(:preserve) - end - - channel[:chunk_size] = channel[:options][:chunk_size] || DEFAULT_CHUNK_SIZE - set_current(channel, channel[:local]) - await_response(channel, :upload_current) - end - - # Determines what the next thing to upload is, and branches. If the next - # item is a file, goes to #upload_file_state. If it is a directory, goes - # to #upload_directory_state. - def upload_current_state(channel) - if channel[:current].respond_to?(:read) - upload_file_state(channel) - elsif File.directory?(channel[:current]) - raise Net::SCP::Error, "can't upload directories unless :recursive" unless channel[:options][:recursive] - upload_directory_state(channel) - elsif File.file?(channel[:current]) - upload_file_state(channel) - else - raise Net::SCP::Error, "not a directory or a regular file: #{channel[:current].inspect}" - end - end - - # After transferring attributes (if requested), sends a 'D' directive and - # awaites the server's 0-byte response. Then goes to #next_item_state. - def upload_directory_state(channel) - if preserve_attributes_if_requested(channel) - mode = channel[:stat].mode & 07777 - directive = "D%04o %d %s\n" % [mode, 0, File.basename(channel[:current])] - channel.send_data(directive) - channel[:cwd] = channel[:current] - channel[:stack] << Dir.entries(channel[:current]).reject { |i| i == "." || i == ".." } - await_response(channel, :next_item) - end - end - - # After transferring attributes (if requested), sends a 'C' directive and - # awaits the server's 0-byte response. Then goes to #send_data_state. - def upload_file_state(channel) - if preserve_attributes_if_requested(channel) - mode = channel[:stat] ? channel[:stat].mode & 07777 : channel[:options][:mode] - channel[:name] = channel[:current].respond_to?(:read) ? channel[:remote] : channel[:current] - directive = "C%04o %d %s\n" % [mode || 0640, channel[:size], File.basename(channel[:name])] - channel.send_data(directive) - channel[:io] = channel[:current].respond_to?(:read) ? channel[:current] : File.open(channel[:current], "rb") - channel[:sent] = 0 - progress_callback(channel, channel[:name], channel[:sent], channel[:size]) - await_response(channel, :send_data) - end - end - - # If any data remains to be transferred from the current file, sends it. - # Otherwise, sends a 0-byte and transfers to #next_item_state. - def send_data_state(channel) - data = channel[:io].read(channel[:chunk_size]) - if data.nil? - channel[:io].close unless channel[:local].respond_to?(:read) - channel.send_data("\0") - await_response(channel, :next_item) - else - channel[:sent] += data.length - progress_callback(channel, channel[:name], channel[:sent], channel[:size]) - channel.send_data(data) - end - end - - # Checks the work queue to see what needs to be done next. If there is - # nothing to do, calls Net::SCP#finish_state. If we're at the end of a - # directory, sends an 'E' directive and waits for the server to respond - # before moving to #next_item_state. Otherwise, sets the next thing to - # upload and moves to #upload_current_state. - def next_item_state(channel) - if channel[:stack].empty? - finish_state(channel) - else - next_item = channel[:stack].last.shift - if next_item.nil? - channel[:stack].pop - channel[:cwd] = File.dirname(channel[:cwd]) - channel.send_data("E\n") - await_response(channel, channel[:stack].empty? ? :finish : :next_item) - else - set_current(channel, next_item) - upload_current_state(channel) - end - end - end - - # Sets the given +path+ as the new current item to upload. - def set_current(channel, path) - path = channel[:cwd] ? File.join(channel[:cwd], path) : path - channel[:current] = path - - if channel[:current].respond_to?(:read) - channel[:stat] = channel[:current].stat if channel[:current].respond_to?(:stat) - else - channel[:stat] = File.stat(channel[:current]) - end - - channel[:size] = channel[:stat] ? channel[:stat].size : channel[:current].size - end - - # If the :preserve option is set, send a 'T' directive and wait for the - # server to respond before proceeding to either #upload_file_state or - # #upload_directory_state, depending on what is being uploaded. - def preserve_attributes_if_requested(channel) - if channel[:options][:preserve] && !channel[:preserved] - channel[:preserved] = true - stat = channel[:stat] - directive = "T%d %d %d %d\n" % [stat.mtime.to_i, stat.mtime.usec, stat.atime.to_i, stat.atime.usec] - channel.send_data(directive) - type = stat.directory? ? :directory : :file - await_response(channel, "upload_#{type}") - return false - else - channel[:preserved] = false - return true - end - end - end - -end; end \ No newline at end of file diff --git a/vendor/gems/net-scp-1.0.2/lib/net/scp/version.rb b/vendor/gems/net-scp-1.0.2/lib/net/scp/version.rb deleted file mode 100644 index 75a7c93fc..000000000 --- a/vendor/gems/net-scp-1.0.2/lib/net/scp/version.rb +++ /dev/null @@ -1,18 +0,0 @@ -require 'net/ssh/version' - -module Net; class SCP - - # Describes the current version of the Net::SCP library. - class Version < Net::SSH::Version - MAJOR = 1 - MINOR = 0 - TINY = 2 - - # The current version, as a Version instance - CURRENT = new(MAJOR, MINOR, TINY) - - # The current version, as a String instance - STRING = CURRENT.to_s - end - -end; end diff --git a/vendor/gems/net-scp-1.0.2/lib/uri/open-scp.rb b/vendor/gems/net-scp-1.0.2/lib/uri/open-scp.rb deleted file mode 100644 index af9195508..000000000 --- a/vendor/gems/net-scp-1.0.2/lib/uri/open-scp.rb +++ /dev/null @@ -1,18 +0,0 @@ -require 'open-uri' -require 'uri/scp' -require 'net/scp' - -module URI - - class SCP - def buffer_open(buf, proxy, open_options) - options = open_options.merge(:port => port, :password => password) - progress = options.delete(:progress_proc) - buf << Net::SCP.download!(host, user, path, nil, open_options, &progress) - buf.io.rewind - end - - include OpenURI::OpenRead - end - -end diff --git a/vendor/gems/net-scp-1.0.2/lib/uri/scp.rb b/vendor/gems/net-scp-1.0.2/lib/uri/scp.rb deleted file mode 100644 index 5829bc50f..000000000 --- a/vendor/gems/net-scp-1.0.2/lib/uri/scp.rb +++ /dev/null @@ -1,35 +0,0 @@ -require 'uri/generic' - -module URI - class SCP < Generic - DEFAULT_PORT = 22 - - COMPONENT = [ - :scheme, - :userinfo, - :host, :port, :path, - :query - ].freeze - - attr_reader :options - - def self.new2(user, password, host, port, path, query) - new('scp', [user, password], host, port, nil, path, nil, query) - end - - def initialize(*args) - super(*args) - - @options = Hash.new - (query || "").split(/&/).each do |pair| - name, value = pair.split(/=/, 2) - opt_name = name.to_sym - values = value.split(/,/).map { |v| v.to_i.to_s == v ? v.to_i : v } - values = values.first if values.length == 1 - options[opt_name] = values - end - end - end - - @@schemes['SCP'] = SCP -end \ No newline at end of file diff --git a/vendor/gems/net-scp-1.0.2/net-scp.gemspec b/vendor/gems/net-scp-1.0.2/net-scp.gemspec deleted file mode 100644 index e27db0a60..000000000 --- a/vendor/gems/net-scp-1.0.2/net-scp.gemspec +++ /dev/null @@ -1,36 +0,0 @@ -Gem::Specification.new do |s| - s.name = %q{net-scp} - s.version = "1.0.2" - - s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version= - s.authors = ["Jamis Buck"] - s.date = %q{2009-02-04} - s.description = %q{A pure Ruby implementation of the SCP client protocol} - s.email = %q{jamis@jamisbuck.org} - s.extra_rdoc_files = ["CHANGELOG.rdoc", "lib/net/scp/download.rb", "lib/net/scp/errors.rb", "lib/net/scp/upload.rb", "lib/net/scp/version.rb", "lib/net/scp.rb", "lib/uri/open-scp.rb", "lib/uri/scp.rb", "README.rdoc"] - s.files = ["CHANGELOG.rdoc", "lib/net/scp/download.rb", "lib/net/scp/errors.rb", "lib/net/scp/upload.rb", "lib/net/scp/version.rb", "lib/net/scp.rb", "lib/uri/open-scp.rb", "lib/uri/scp.rb", "Rakefile", "README.rdoc", "setup.rb", "test/common.rb", "test/test_all.rb", "test/test_download.rb", "test/test_scp.rb", "test/test_upload.rb", "Manifest", "net-scp.gemspec"] - s.has_rdoc = true - s.homepage = %q{http://net-ssh.rubyforge.org/scp} - s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "Net-scp", "--main", "README.rdoc"] - s.require_paths = ["lib"] - s.rubyforge_project = %q{net-ssh} - s.rubygems_version = %q{1.2.0} - s.summary = %q{A pure Ruby implementation of the SCP client protocol} - s.test_files = ["test/test_all.rb"] - - if s.respond_to? :specification_version then - current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION - s.specification_version = 2 - - if current_version >= 3 then - s.add_runtime_dependency(%q, [">= 1.99.1"]) - s.add_development_dependency(%q, [">= 0"]) - else - s.add_dependency(%q, [">= 1.99.1"]) - s.add_dependency(%q, [">= 0"]) - end - else - s.add_dependency(%q, [">= 1.99.1"]) - s.add_dependency(%q, [">= 0"]) - end -end diff --git a/vendor/gems/net-scp-1.0.2/setup.rb b/vendor/gems/net-scp-1.0.2/setup.rb deleted file mode 100644 index 1549b3f37..000000000 --- a/vendor/gems/net-scp-1.0.2/setup.rb +++ /dev/null @@ -1,1331 +0,0 @@ -# -# setup.rb -# -# Copyright (c) 2000-2004 Minero Aoki -# -# This program is free software. -# You can distribute/modify this program under the terms of -# the GNU Lesser General Public License version 2.1. -# - -# -# For backward compatibility -# - -unless Enumerable.method_defined?(:map) - module Enumerable - alias map collect - end -end - -unless Enumerable.method_defined?(:detect) - module Enumerable - alias detect find - end -end - -unless Enumerable.method_defined?(:select) - module Enumerable - alias select find_all - end -end - -unless Enumerable.method_defined?(:reject) - module Enumerable - def reject - result = [] - each do |i| - result.push i unless yield(i) - end - result - end - end -end - -unless Enumerable.method_defined?(:inject) - module Enumerable - def inject(result) - each do |i| - result = yield(result, i) - end - result - end - end -end - -unless Enumerable.method_defined?(:any?) - module Enumerable - def any? - each do |i| - return true if yield(i) - end - false - end - end -end - -unless File.respond_to?(:read) - def File.read(fname) - open(fname) {|f| - return f.read - } - end -end - -# -# Application independent utilities -# - -def File.binread(fname) - open(fname, 'rb') {|f| - return f.read - } -end - -# for corrupted windows stat(2) -def File.dir?(path) - File.directory?((path[-1,1] == '/') ? path : path + '/') -end - -# -# Config -# - -if arg = ARGV.detect{|arg| /\A--rbconfig=/ =~ arg } - ARGV.delete(arg) - require arg.split(/=/, 2)[1] - $".push 'rbconfig.rb' -else - require 'rbconfig' -end - -def multipackage_install? - FileTest.directory?(File.dirname($0) + '/packages') -end - - -class ConfigTable - - c = ::Config::CONFIG - - rubypath = c['bindir'] + '/' + c['ruby_install_name'] - - major = c['MAJOR'].to_i - minor = c['MINOR'].to_i - teeny = c['TEENY'].to_i - version = "#{major}.#{minor}" - - # ruby ver. >= 1.4.4? - newpath_p = ((major >= 2) or - ((major == 1) and - ((minor >= 5) or - ((minor == 4) and (teeny >= 4))))) - - subprefix = lambda {|path| - path.sub(/\A#{Regexp.quote(c['prefix'])}/o, '$prefix') - } - - if c['rubylibdir'] - # V < 1.6.3 - stdruby = subprefix.call(c['rubylibdir']) - siteruby = subprefix.call(c['sitedir']) - versite = subprefix.call(c['sitelibdir']) - sodir = subprefix.call(c['sitearchdir']) - elsif newpath_p - # 1.4.4 <= V <= 1.6.3 - stdruby = "$prefix/lib/ruby/#{version}" - siteruby = subprefix.call(c['sitedir']) - versite = siteruby + '/' + version - sodir = "$site-ruby/#{c['arch']}" - else - # V < 1.4.4 - stdruby = "$prefix/lib/ruby/#{version}" - siteruby = "$prefix/lib/ruby/#{version}/site_ruby" - versite = siteruby - sodir = "$site-ruby/#{c['arch']}" - end - - if arg = c['configure_args'].split.detect {|arg| /--with-make-prog=/ =~ arg } - makeprog = arg.sub(/'/, '').split(/=/, 2)[1] - else - makeprog = 'make' - end - - common_descripters = [ - [ 'prefix', [ c['prefix'], - 'path', - 'path prefix of target environment' ] ], - [ 'std-ruby', [ stdruby, - 'path', - 'the directory for standard ruby libraries' ] ], - [ 'site-ruby-common', [ siteruby, - 'path', - 'the directory for version-independent non-standard ruby libraries' ] ], - [ 'site-ruby', [ versite, - 'path', - 'the directory for non-standard ruby libraries' ] ], - [ 'bin-dir', [ '$prefix/bin', - 'path', - 'the directory for commands' ] ], - [ 'rb-dir', [ '$site-ruby', - 'path', - 'the directory for ruby scripts' ] ], - [ 'so-dir', [ sodir, - 'path', - 'the directory for ruby extentions' ] ], - [ 'data-dir', [ '$prefix/share', - 'path', - 'the directory for shared data' ] ], - [ 'ruby-path', [ rubypath, - 'path', - 'path to set to #! line' ] ], - [ 'ruby-prog', [ rubypath, - 'name', - 'the ruby program using for installation' ] ], - [ 'make-prog', [ makeprog, - 'name', - 'the make program to compile ruby extentions' ] ], - [ 'without-ext', [ 'no', - 'yes/no', - 'does not compile/install ruby extentions' ] ] - ] - multipackage_descripters = [ - [ 'with', [ '', - 'name,name...', - 'package names that you want to install', - 'ALL' ] ], - [ 'without', [ '', - 'name,name...', - 'package names that you do not want to install', - 'NONE' ] ] - ] - if multipackage_install? - DESCRIPTER = common_descripters + multipackage_descripters - else - DESCRIPTER = common_descripters - end - - SAVE_FILE = 'config.save' - - def ConfigTable.each_name(&block) - keys().each(&block) - end - - def ConfigTable.keys - DESCRIPTER.map {|name, *dummy| name } - end - - def ConfigTable.each_definition(&block) - DESCRIPTER.each(&block) - end - - def ConfigTable.get_entry(name) - name, ent = DESCRIPTER.assoc(name) - ent - end - - def ConfigTable.get_entry!(name) - get_entry(name) or raise ArgumentError, "no such config: #{name}" - end - - def ConfigTable.add_entry(name, vals) - ConfigTable::DESCRIPTER.push [name,vals] - end - - def ConfigTable.remove_entry(name) - get_entry(name) or raise ArgumentError, "no such config: #{name}" - DESCRIPTER.delete_if {|n, arr| n == name } - end - - def ConfigTable.config_key?(name) - get_entry(name) ? true : false - end - - def ConfigTable.bool_config?(name) - ent = get_entry(name) or return false - ent[1] == 'yes/no' - end - - def ConfigTable.value_config?(name) - ent = get_entry(name) or return false - ent[1] != 'yes/no' - end - - def ConfigTable.path_config?(name) - ent = get_entry(name) or return false - ent[1] == 'path' - end - - - class << self - alias newobj new - end - - def ConfigTable.new - c = newobj() - c.initialize_from_table - c - end - - def ConfigTable.load - c = newobj() - c.initialize_from_file - c - end - - def initialize_from_table - @table = {} - DESCRIPTER.each do |k, (default, vname, desc, default2)| - @table[k] = default - end - end - - def initialize_from_file - raise InstallError, "#{File.basename $0} config first"\ - unless File.file?(SAVE_FILE) - @table = {} - File.foreach(SAVE_FILE) do |line| - k, v = line.split(/=/, 2) - @table[k] = v.strip - end - end - - def save - File.open(SAVE_FILE, 'w') {|f| - @table.each do |k, v| - f.printf "%s=%s\n", k, v if v - end - } - end - - def []=(k, v) - raise InstallError, "unknown config option #{k}"\ - unless ConfigTable.config_key?(k) - @table[k] = v - end - - def [](key) - return nil unless @table[key] - @table[key].gsub(%r<\$([^/]+)>) { self[$1] } - end - - def set_raw(key, val) - @table[key] = val - end - - def get_raw(key) - @table[key] - end - -end - - -module MetaConfigAPI - - def eval_file_ifexist(fname) - instance_eval File.read(fname), fname, 1 if File.file?(fname) - end - - def config_names - ConfigTable.keys - end - - def config?(name) - ConfigTable.config_key?(name) - end - - def bool_config?(name) - ConfigTable.bool_config?(name) - end - - def value_config?(name) - ConfigTable.value_config?(name) - end - - def path_config?(name) - ConfigTable.path_config?(name) - end - - def add_config(name, argname, default, desc) - ConfigTable.add_entry name,[default,argname,desc] - end - - def add_path_config(name, default, desc) - add_config name, 'path', default, desc - end - - def add_bool_config(name, default, desc) - add_config name, 'yes/no', default ? 'yes' : 'no', desc - end - - def set_config_default(name, default) - if bool_config?(name) - ConfigTable.get_entry!(name)[0] = (default ? 'yes' : 'no') - else - ConfigTable.get_entry!(name)[0] = default - end - end - - def remove_config(name) - ent = ConfigTable.get_entry(name) - ConfigTable.remove_entry name - ent - end - -end - -# -# File Operations -# - -module FileOperations - - def mkdir_p(dirname, prefix = nil) - dirname = prefix + dirname if prefix - $stderr.puts "mkdir -p #{dirname}" if verbose? - return if no_harm? - - # does not check '/'... it's too abnormal case - dirs = dirname.split(%r<(?=/)>) - if /\A[a-z]:\z/i =~ dirs[0] - disk = dirs.shift - dirs[0] = disk + dirs[0] - end - dirs.each_index do |idx| - path = dirs[0..idx].join('') - Dir.mkdir path unless File.dir?(path) - end - end - - def rm_f(fname) - $stderr.puts "rm -f #{fname}" if verbose? - return if no_harm? - - if File.exist?(fname) or File.symlink?(fname) - File.chmod 0777, fname - File.unlink fname - end - end - - def rm_rf(dn) - $stderr.puts "rm -rf #{dn}" if verbose? - return if no_harm? - - Dir.chdir dn - Dir.foreach('.') do |fn| - next if fn == '.' - next if fn == '..' - if File.dir?(fn) - verbose_off { - rm_rf fn - } - else - verbose_off { - rm_f fn - } - end - end - Dir.chdir '..' - Dir.rmdir dn - end - - def move_file(src, dest) - File.unlink dest if File.exist?(dest) - begin - File.rename src, dest - rescue - File.open(dest, 'wb') {|f| f.write File.binread(src) } - File.chmod File.stat(src).mode, dest - File.unlink src - end - end - - def install(from, dest, mode, prefix = nil) - $stderr.puts "install #{from} #{dest}" if verbose? - return if no_harm? - - realdest = prefix + dest if prefix - realdest = File.join(realdest, File.basename(from)) if File.dir?(realdest) - str = File.binread(from) - if diff?(str, realdest) - verbose_off { - rm_f realdest if File.exist?(realdest) - } - File.open(realdest, 'wb') {|f| - f.write str - } - File.chmod mode, realdest - - File.open("#{objdir_root()}/InstalledFiles", 'a') {|f| - if prefix - f.puts realdest.sub(prefix, '') - else - f.puts realdest - end - } - end - end - - def diff?(new_content, path) - return true unless File.exist?(path) - new_content != File.binread(path) - end - - def command(str) - $stderr.puts str if verbose? - system str or raise RuntimeError, "'system #{str}' failed" - end - - def ruby(str) - command config('ruby-prog') + ' ' + str - end - - def make(task = '') - command config('make-prog') + ' ' + task - end - - def extdir?(dir) - File.exist?(dir + '/MANIFEST') - end - - def all_files_in(dirname) - Dir.open(dirname) {|d| - return d.select {|ent| File.file?("#{dirname}/#{ent}") } - } - end - - REJECT_DIRS = %w( - CVS SCCS RCS CVS.adm - ) - - def all_dirs_in(dirname) - Dir.open(dirname) {|d| - return d.select {|n| File.dir?("#{dirname}/#{n}") } - %w(. ..) - REJECT_DIRS - } - end - -end - -# -# Main Installer -# - -class InstallError < StandardError; end - - -module HookUtils - - def run_hook(name) - try_run_hook "#{curr_srcdir()}/#{name}" or - try_run_hook "#{curr_srcdir()}/#{name}.rb" - end - - def try_run_hook(fname) - return false unless File.file?(fname) - begin - instance_eval File.read(fname), fname, 1 - rescue - raise InstallError, "hook #{fname} failed:\n" + $!.message - end - true - end - -end - - -module HookScriptAPI - - def get_config(key) - @config[key] - end - - alias config get_config - - def set_config(key, val) - @config[key] = val - end - - # - # srcdir/objdir (works only in the package directory) - # - - #abstract srcdir_root - #abstract objdir_root - #abstract relpath - - def curr_srcdir - "#{srcdir_root()}/#{relpath()}" - end - - def curr_objdir - "#{objdir_root()}/#{relpath()}" - end - - def srcfile(path) - "#{curr_srcdir()}/#{path}" - end - - def srcexist?(path) - File.exist?(srcfile(path)) - end - - def srcdirectory?(path) - File.dir?(srcfile(path)) - end - - def srcfile?(path) - File.file? srcfile(path) - end - - def srcentries(path = '.') - Dir.open("#{curr_srcdir()}/#{path}") {|d| - return d.to_a - %w(. ..) - } - end - - def srcfiles(path = '.') - srcentries(path).select {|fname| - File.file?(File.join(curr_srcdir(), path, fname)) - } - end - - def srcdirectories(path = '.') - srcentries(path).select {|fname| - File.dir?(File.join(curr_srcdir(), path, fname)) - } - end - -end - - -class ToplevelInstaller - - Version = '3.2.4' - Copyright = 'Copyright (c) 2000-2004 Minero Aoki' - - TASKS = [ - [ 'config', 'saves your configurations' ], - [ 'show', 'shows current configuration' ], - [ 'setup', 'compiles ruby extentions and others' ], - [ 'install', 'installs files' ], - [ 'clean', "does `make clean' for each extention" ], - [ 'distclean',"does `make distclean' for each extention" ] - ] - - def ToplevelInstaller.invoke - instance().invoke - end - - @singleton = nil - - def ToplevelInstaller.instance - @singleton ||= new(File.dirname($0)) - @singleton - end - - include MetaConfigAPI - - def initialize(ardir_root) - @config = nil - @options = { 'verbose' => true } - @ardir = File.expand_path(ardir_root) - end - - def inspect - "#<#{self.class} #{__id__()}>" - end - - def invoke - run_metaconfigs - task = parsearg_global() - @config = load_config(task) - __send__ "parsearg_#{task}" - init_installers - __send__ "exec_#{task}" - end - - def run_metaconfigs - eval_file_ifexist "#{@ardir}/metaconfig" - end - - def load_config(task) - case task - when 'config' - ConfigTable.new - when 'clean', 'distclean' - if File.exist?('config.save') - then ConfigTable.load - else ConfigTable.new - end - else - ConfigTable.load - end - end - - def init_installers - @installer = Installer.new(@config, @options, @ardir, File.expand_path('.')) - end - - # - # Hook Script API bases - # - - def srcdir_root - @ardir - end - - def objdir_root - '.' - end - - def relpath - '.' - end - - # - # Option Parsing - # - - def parsearg_global - valid_task = /\A(?:#{TASKS.map {|task,desc| task }.join '|'})\z/ - - while arg = ARGV.shift - case arg - when /\A\w+\z/ - raise InstallError, "invalid task: #{arg}" unless valid_task =~ arg - return arg - - when '-q', '--quiet' - @options['verbose'] = false - - when '--verbose' - @options['verbose'] = true - - when '-h', '--help' - print_usage $stdout - exit 0 - - when '-v', '--version' - puts "#{File.basename($0)} version #{Version}" - exit 0 - - when '--copyright' - puts Copyright - exit 0 - - else - raise InstallError, "unknown global option '#{arg}'" - end - end - - raise InstallError, <" - out.puts " ruby #{File.basename $0} [] []" - - fmt = " %-20s %s\n" - out.puts - out.puts 'Global options:' - out.printf fmt, '-q,--quiet', 'suppress message outputs' - out.printf fmt, ' --verbose', 'output messages verbosely' - out.printf fmt, '-h,--help', 'print this message' - out.printf fmt, '-v,--version', 'print version and quit' - out.printf fmt, ' --copyright', 'print copyright and quit' - - out.puts - out.puts 'Tasks:' - TASKS.each do |name, desc| - out.printf " %-10s %s\n", name, desc - end - - out.puts - out.puts 'Options for config:' - ConfigTable.each_definition do |name, (default, arg, desc, default2)| - out.printf " %-20s %s [%s]\n", - '--'+ name + (ConfigTable.bool_config?(name) ? '' : '='+arg), - desc, - default2 || default - end - out.printf " %-20s %s [%s]\n", - '--rbconfig=path', 'your rbconfig.rb to load', "running ruby's" - - out.puts - out.puts 'Options for install:' - out.printf " %-20s %s [%s]\n", - '--no-harm', 'only display what to do if given', 'off' - out.printf " %-20s %s [%s]\n", - '--prefix', 'install path prefix', '$prefix' - - out.puts - end - - # - # Task Handlers - # - - def exec_config - @installer.exec_config - @config.save # must be final - end - - def exec_setup - @installer.exec_setup - end - - def exec_install - @installer.exec_install - end - - def exec_show - ConfigTable.each_name do |k| - v = @config.get_raw(k) - if not v or v.empty? - v = '(not specified)' - end - printf "%-10s %s\n", k, v - end - end - - def exec_clean - @installer.exec_clean - end - - def exec_distclean - @installer.exec_distclean - end - -end - - -class ToplevelInstallerMulti < ToplevelInstaller - - include HookUtils - include HookScriptAPI - include FileOperations - - def initialize(ardir) - super - @packages = all_dirs_in("#{@ardir}/packages") - raise 'no package exists' if @packages.empty? - end - - def run_metaconfigs - eval_file_ifexist "#{@ardir}/metaconfig" - @packages.each do |name| - eval_file_ifexist "#{@ardir}/packages/#{name}/metaconfig" - end - end - - def init_installers - @installers = {} - @packages.each do |pack| - @installers[pack] = Installer.new(@config, @options, - "#{@ardir}/packages/#{pack}", - "packages/#{pack}") - end - - with = extract_selection(config('with')) - without = extract_selection(config('without')) - @selected = @installers.keys.select {|name| - (with.empty? or with.include?(name)) \ - and not without.include?(name) - } - end - - def extract_selection(list) - a = list.split(/,/) - a.each do |name| - raise InstallError, "no such package: #{name}" \ - unless @installers.key?(name) - end - a - end - - def print_usage(f) - super - f.puts 'Inluded packages:' - f.puts ' ' + @packages.sort.join(' ') - f.puts - end - - # - # multi-package metaconfig API - # - - attr_reader :packages - - def declare_packages(list) - raise 'package list is empty' if list.empty? - list.each do |name| - raise "directory packages/#{name} does not exist"\ - unless File.dir?("#{@ardir}/packages/#{name}") - end - @packages = list - end - - # - # Task Handlers - # - - def exec_config - run_hook 'pre-config' - each_selected_installers {|inst| inst.exec_config } - run_hook 'post-config' - @config.save # must be final - end - - def exec_setup - run_hook 'pre-setup' - each_selected_installers {|inst| inst.exec_setup } - run_hook 'post-setup' - end - - def exec_install - run_hook 'pre-install' - each_selected_installers {|inst| inst.exec_install } - run_hook 'post-install' - end - - def exec_clean - rm_f 'config.save' - run_hook 'pre-clean' - each_selected_installers {|inst| inst.exec_clean } - run_hook 'post-clean' - end - - def exec_distclean - rm_f 'config.save' - run_hook 'pre-distclean' - each_selected_installers {|inst| inst.exec_distclean } - run_hook 'post-distclean' - end - - # - # lib - # - - def each_selected_installers - Dir.mkdir 'packages' unless File.dir?('packages') - @selected.each do |pack| - $stderr.puts "Processing the package `#{pack}' ..." if @options['verbose'] - Dir.mkdir "packages/#{pack}" unless File.dir?("packages/#{pack}") - Dir.chdir "packages/#{pack}" - yield @installers[pack] - Dir.chdir '../..' - end - end - - def verbose? - @options['verbose'] - end - - def no_harm? - @options['no-harm'] - end - -end - - -class Installer - - FILETYPES = %w( bin lib ext data ) - - include HookScriptAPI - include HookUtils - include FileOperations - - def initialize(config, opt, srcroot, objroot) - @config = config - @options = opt - @srcdir = File.expand_path(srcroot) - @objdir = File.expand_path(objroot) - @currdir = '.' - end - - def inspect - "#<#{self.class} #{File.basename(@srcdir)}>" - end - - # - # Hook Script API bases - # - - def srcdir_root - @srcdir - end - - def objdir_root - @objdir - end - - def relpath - @currdir - end - - # - # configs/options - # - - def no_harm? - @options['no-harm'] - end - - def verbose? - @options['verbose'] - end - - def verbose_off - begin - save, @options['verbose'] = @options['verbose'], false - yield - ensure - @options['verbose'] = save - end - end - - # - # TASK config - # - - def exec_config - exec_task_traverse 'config' - end - - def config_dir_bin(rel) - end - - def config_dir_lib(rel) - end - - def config_dir_ext(rel) - extconf if extdir?(curr_srcdir()) - end - - def extconf - opt = @options['config-opt'].join(' ') - command "#{config('ruby-prog')} #{curr_srcdir()}/extconf.rb #{opt}" - end - - def config_dir_data(rel) - end - - # - # TASK setup - # - - def exec_setup - exec_task_traverse 'setup' - end - - def setup_dir_bin(rel) - all_files_in(curr_srcdir()).each do |fname| - adjust_shebang "#{curr_srcdir()}/#{fname}" - end - end - - # modify: #!/usr/bin/ruby - # modify: #! /usr/bin/ruby - # modify: #!ruby - # not modify: #!/usr/bin/env ruby - SHEBANG_RE = /\A\#!\s*\S*ruby\S*/ - - def adjust_shebang(path) - return if no_harm? - - tmpfile = File.basename(path) + '.tmp' - begin - File.open(path, 'rb') {|r| - File.open(tmpfile, 'wb') {|w| - first = r.gets - return unless SHEBANG_RE =~ first - - $stderr.puts "adjusting shebang: #{File.basename path}" if verbose? - w.print first.sub(SHEBANG_RE, '#!' + config('ruby-path')) - w.write r.read - } - } - move_file tmpfile, File.basename(path) - ensure - File.unlink tmpfile if File.exist?(tmpfile) - end - end - - def setup_dir_lib(rel) - end - - def setup_dir_ext(rel) - make if extdir?(curr_srcdir()) - end - - def setup_dir_data(rel) - end - - # - # TASK install - # - - def exec_install - exec_task_traverse 'install' - end - - def install_dir_bin(rel) - install_files collect_filenames_auto(), "#{config('bin-dir')}/#{rel}", 0755 - end - - def install_dir_lib(rel) - install_files ruby_scripts(), "#{config('rb-dir')}/#{rel}", 0644 - end - - def install_dir_ext(rel) - return unless extdir?(curr_srcdir()) - install_files ruby_extentions('.'), - "#{config('so-dir')}/#{File.dirname(rel)}", - 0555 - end - - def install_dir_data(rel) - install_files collect_filenames_auto(), "#{config('data-dir')}/#{rel}", 0644 - end - - def install_files(list, dest, mode) - mkdir_p dest, @options['install-prefix'] - list.each do |fname| - install fname, dest, mode, @options['install-prefix'] - end - end - - def ruby_scripts - collect_filenames_auto().select {|n| /\.rb\z/ =~ n || "module.yml" == n } - end - - # picked up many entries from cvs-1.11.1/src/ignore.c - reject_patterns = %w( - core RCSLOG tags TAGS .make.state - .nse_depinfo #* .#* cvslog.* ,* .del-* *.olb - *~ *.old *.bak *.BAK *.orig *.rej _$* *$ - - *.org *.in .* - ) - mapping = { - '.' => '\.', - '$' => '\$', - '#' => '\#', - '*' => '.*' - } - REJECT_PATTERNS = Regexp.new('\A(?:' + - reject_patterns.map {|pat| - pat.gsub(/[\.\$\#\*]/) {|ch| mapping[ch] } - }.join('|') + - ')\z') - - def collect_filenames_auto - mapdir((existfiles() - hookfiles()).reject {|fname| - REJECT_PATTERNS =~ fname - }) - end - - def existfiles - all_files_in(curr_srcdir()) | all_files_in('.') - end - - def hookfiles - %w( pre-%s post-%s pre-%s.rb post-%s.rb ).map {|fmt| - %w( config setup install clean ).map {|t| sprintf(fmt, t) } - }.flatten - end - - def mapdir(filelist) - filelist.map {|fname| - if File.exist?(fname) # objdir - fname - else # srcdir - File.join(curr_srcdir(), fname) - end - } - end - - def ruby_extentions(dir) - _ruby_extentions(dir) or - raise InstallError, "no ruby extention exists: 'ruby #{$0} setup' first" - end - - DLEXT = /\.#{ ::Config::CONFIG['DLEXT'] }\z/ - - def _ruby_extentions(dir) - Dir.open(dir) {|d| - return d.select {|fname| DLEXT =~ fname } - } - end - - # - # TASK clean - # - - def exec_clean - exec_task_traverse 'clean' - rm_f 'config.save' - rm_f 'InstalledFiles' - end - - def clean_dir_bin(rel) - end - - def clean_dir_lib(rel) - end - - def clean_dir_ext(rel) - return unless extdir?(curr_srcdir()) - make 'clean' if File.file?('Makefile') - end - - def clean_dir_data(rel) - end - - # - # TASK distclean - # - - def exec_distclean - exec_task_traverse 'distclean' - rm_f 'config.save' - rm_f 'InstalledFiles' - end - - def distclean_dir_bin(rel) - end - - def distclean_dir_lib(rel) - end - - def distclean_dir_ext(rel) - return unless extdir?(curr_srcdir()) - make 'distclean' if File.file?('Makefile') - end - - # - # lib - # - - def exec_task_traverse(task) - run_hook "pre-#{task}" - FILETYPES.each do |type| - if config('without-ext') == 'yes' and type == 'ext' - $stderr.puts 'skipping ext/* by user option' if verbose? - next - end - traverse task, type, "#{task}_dir_#{type}" - end - run_hook "post-#{task}" - end - - def traverse(task, rel, mid) - dive_into(rel) { - run_hook "pre-#{task}" - __send__ mid, rel.sub(%r[\A.*?(?:/|\z)], '') - all_dirs_in(curr_srcdir()).each do |d| - traverse task, "#{rel}/#{d}", mid - end - run_hook "post-#{task}" - } - end - - def dive_into(rel) - return unless File.dir?("#{@srcdir}/#{rel}") - - dir = File.basename(rel) - Dir.mkdir dir unless File.dir?(dir) - prevdir = Dir.pwd - Dir.chdir dir - $stderr.puts '---> ' + rel if verbose? - @currdir = rel - yield - Dir.chdir prevdir - $stderr.puts '<--- ' + rel if verbose? - @currdir = File.dirname(rel) - end - -end - - -if $0 == __FILE__ - begin - if multipackage_install? - ToplevelInstallerMulti.invoke - else - ToplevelInstaller.invoke - end - rescue - raise if $DEBUG - $stderr.puts $!.message - $stderr.puts "Try 'ruby #{$0} --help' for detailed usage." - exit 1 - end -end diff --git a/vendor/gems/net-scp-1.0.2/test/common.rb b/vendor/gems/net-scp-1.0.2/test/common.rb deleted file mode 100644 index 107456d75..000000000 --- a/vendor/gems/net-scp-1.0.2/test/common.rb +++ /dev/null @@ -1,138 +0,0 @@ -require 'test/unit' -require 'mocha' - -begin - gem 'net-ssh', ">= 2.0.0" - require 'net/ssh' -rescue LoadError - $LOAD_PATH.unshift "#{File.dirname(__FILE__)}/../../net-ssh/lib" - - begin - require 'net/ssh' - require 'net/ssh/version' - raise LoadError, "wrong version" unless Net::SSH::Version::STRING >= '1.99.0' - rescue LoadError => e - abort "could not load net/ssh v2 (#{e.inspect})" - end -end - -$LOAD_PATH.unshift "#{File.dirname(__FILE__)}/../lib" - -require 'net/scp' -require 'net/ssh/test' - -class Net::SSH::Test::Channel - def gets_ok - gets_data "\0" - end - - def sends_ok - sends_data "\0" - end -end - -class Net::SCP::TestCase < Test::Unit::TestCase - include Net::SSH::Test - - def default_test - # do nothing, this is just a hacky-hack to work around Test::Unit's - # insistence that all TestCase subclasses have at least one test - # method defined. - end - - protected - - def prepare_file(path, contents="", mode=0666, mtime=Time.now, atime=Time.now) - entry = FileEntry.new(path, contents, mode, mtime, atime) - entry.stub! - entry - end - - def prepare_directory(path, mode=0777, mtime=Time.now, atime=Time.now) - directory = DirectoryEntry.new(path, mode, mtime, atime) - yield directory if block_given? - directory.stub! - end - - class FileEntry - attr_reader :path, :contents, :mode, :mtime, :atime, :io - - def initialize(path, contents, mode=0666, mtime=Time.now, atime=Time.now) - @path, @contents, @mode = path, contents, mode - @mtime, @atime = mtime, atime - end - - def name - @name ||= File.basename(path) - end - - def stub! - stat = Mocha::Mock.new("file::stat") - stat.stubs(:size => contents.length, :mode => mode, :mtime => mtime, :atime => atime, :directory? => false) - - File.stubs(:stat).with(path).returns(stat) - File.stubs(:directory?).with(path).returns(false) - File.stubs(:file?).with(path).returns(true) - File.stubs(:open).with(path, "rb").returns(StringIO.new(contents)) - - @io = StringIO.new - File.stubs(:new).with(path, "wb", mode).returns(io) - end - end - - class DirectoryEntry - attr_reader :path, :mode, :mtime, :atime - attr_reader :entries - - def initialize(path, mode=0777, mtime=Time.now, atime=Time.now) - @path, @mode = path, mode - @mtime, @atime = mtime, atime - @entries = [] - end - - def name - @name ||= File.basename(path) - end - - def file(name, *args) - (entries << FileEntry.new(File.join(path, name), *args)).last - end - - def directory(name, *args) - entry = DirectoryEntry.new(File.join(path, name), *args) - yield entry if block_given? - (entries << entry).last - end - - def stub! - Dir.stubs(:mkdir).with { |*a| a.first == path } - - stat = Mocha::Mock.new("file::stat") - stat.stubs(:size => 1024, :mode => mode, :mtime => mtime, :atime => atime, :directory? => true) - - File.stubs(:stat).with(path).returns(stat) - File.stubs(:directory?).with(path).returns(true) - File.stubs(:file?).with(path).returns(false) - Dir.stubs(:entries).with(path).returns(%w(. ..) + entries.map { |e| e.name }.sort) - - entries.each { |e| e.stub! } - end - end - - def expect_scp_session(arguments) - story do |session| - channel = session.opens_channel - channel.sends_exec "scp #{arguments}" - yield channel if block_given? - channel.sends_eof - channel.gets_exit_status - channel.gets_eof - channel.gets_close - channel.sends_close - end - end - - def scp(options={}) - @scp ||= Net::SCP.new(connection(options)) - end -end diff --git a/vendor/gems/net-scp-1.0.2/test/test_all.rb b/vendor/gems/net-scp-1.0.2/test/test_all.rb deleted file mode 100644 index 08485bc9c..000000000 --- a/vendor/gems/net-scp-1.0.2/test/test_all.rb +++ /dev/null @@ -1,3 +0,0 @@ -Dir.chdir(File.dirname(__FILE__)) do - Dir['**/test_*.rb'].each { |file| require(file) } -end \ No newline at end of file diff --git a/vendor/gems/net-scp-1.0.2/test/test_download.rb b/vendor/gems/net-scp-1.0.2/test/test_download.rb deleted file mode 100644 index b909313b9..000000000 --- a/vendor/gems/net-scp-1.0.2/test/test_download.rb +++ /dev/null @@ -1,156 +0,0 @@ -require 'common' - -class TestDownload < Net::SCP::TestCase - def test_download_file_should_transfer_file - file = prepare_file("/path/to/local.txt", "a" * 1234) - - expect_scp_session "-f /path/to/remote.txt" do |channel| - simple_download(channel) - end - - assert_scripted { scp.download!("/path/to/remote.txt", "/path/to/local.txt") } - assert_equal "a" * 1234, file.io.string - end - - def test_download_file_with_spaces_in_name_should_escape_remote_file_name - file = prepare_file("/path/to/local file.txt", "") - - expect_scp_session "-f /path/to/remote\\ file.txt" do |channel| - channel.sends_ok - channel.gets_data "C0666 0 local file.txt\n" - channel.sends_ok - channel.gets_ok - channel.sends_ok - end - - assert_scripted { scp.download!("/path/to/remote file.txt", "/path/to/local file.txt") } - end - - def test_download_with_preserve_should_send_times - file = prepare_file("/path/to/local.txt", "a" * 1234, 0644, Time.at(1234567890, 123456), Time.at(12121212, 232323)) - - expect_scp_session "-f -p /path/to/remote.txt" do |channel| - channel.sends_ok - channel.gets_data "T1234567890 123456 12121212 232323\n" - simple_download(channel, 0644) - end - - File.expects(:utime).with(Time.at(12121212, 232323), Time.at(1234567890, 123456), "/path/to/local.txt") - assert_scripted { scp.download!("/path/to/remote.txt", "/path/to/local.txt", :preserve => true) } - assert_equal "a" * 1234, file.io.string - end - - def test_download_with_progress_callback_should_invoke_callback - prepare_file("/path/to/local.txt", "a" * 3000 + "b" * 3000 + "c" * 3000 + "d" * 3000) - - expect_scp_session "-f /path/to/remote.txt" do |channel| - channel.sends_ok - channel.gets_data "C0666 12000 remote.txt\n" - channel.sends_ok - channel.gets_data "a" * 3000 - channel.inject_remote_delay! - channel.gets_data "b" * 3000 - channel.inject_remote_delay! - channel.gets_data "c" * 3000 - channel.inject_remote_delay! - channel.gets_data "d" * 3000 - channel.gets_ok - channel.sends_ok - end - - calls = [] - progress = Proc.new { |ch, *args| calls << args } - - assert_scripted do - scp.download!("/path/to/remote.txt", "/path/to/local.txt", &progress) - end - - assert_equal ["/path/to/local.txt", 0, 12000], calls.shift - assert_equal ["/path/to/local.txt", 3000, 12000], calls.shift - assert_equal ["/path/to/local.txt", 6000, 12000], calls.shift - assert_equal ["/path/to/local.txt", 9000, 12000], calls.shift - assert_equal ["/path/to/local.txt", 12000, 12000], calls.shift - assert calls.empty? - end - - def test_download_io_with_recursive_should_raise_error - expect_scp_session "-f -r /path/to/remote.txt" - assert_raises(Net::SCP::Error) { scp.download!("/path/to/remote.txt", StringIO.new, :recursive => true) } - end - - def test_download_io_with_preserve_should_ignore_preserve - expect_scp_session "-f -p /path/to/remote.txt" do |channel| - simple_download(channel) - end - - io = StringIO.new - assert_scripted { scp.download!("/path/to/remote.txt", io, :preserve => true) } - assert_equal "a" * 1234, io.string - end - - def test_download_io_should_transfer_data - expect_scp_session "-f /path/to/remote.txt" do |channel| - simple_download(channel) - end - - io = StringIO.new - assert_scripted { scp.download!("/path/to/remote.txt", io) } - assert_equal "a" * 1234, io.string - end - - def test_download_bang_without_target_should_return_string - expect_scp_session "-f /path/to/remote.txt" do |channel| - simple_download(channel) - end - - assert_scripted do - assert_equal "a" * 1234, scp.download!("/path/to/remote.txt") - end - end - - def test_download_directory_without_recursive_should_raise_error - expect_scp_session "-f /path/to/remote" do |channel| - channel.sends_ok - channel.gets_data "D0755 0 remote\n" - end - - assert_raises(Net::SCP::Error) { scp.download!("/path/to/remote") } - end - - def test_download_directory_should_create_directory_and_files_locally - file = nil - prepare_directory "/path/to/local" do |dir| - dir.directory "remote" do |dir2| - dir2.directory "sub" do |dir3| - file = dir3.file "remote.txt", "" - end - end - end - - expect_scp_session "-f -r /path/to/remote" do |channel| - channel.sends_ok - channel.gets_data "D0755 0 remote\n" - channel.sends_ok - channel.gets_data "D0755 0 sub\n" - simple_download(channel) - channel.gets_data "E\n" - channel.sends_ok - channel.gets_data "E\n" - channel.sends_ok - end - - scp.download!("/path/to/remote", "/path/to/local", :recursive => true, :ssh => { :verbose => :debug }) - assert_equal "a" * 1234, file.io.string - end - - private - - def simple_download(channel, mode=0666) - channel.sends_ok - channel.gets_data "C%04o 1234 remote.txt\n" % mode - channel.sends_ok - channel.gets_data "a" * 1234 - channel.gets_ok - channel.sends_ok - end -end diff --git a/vendor/gems/net-scp-1.0.2/test/test_scp.rb b/vendor/gems/net-scp-1.0.2/test/test_scp.rb deleted file mode 100644 index b2809346f..000000000 --- a/vendor/gems/net-scp-1.0.2/test/test_scp.rb +++ /dev/null @@ -1,60 +0,0 @@ -require 'common' - -class TestSCP < Net::SCP::TestCase - def test_start_without_block_should_return_scp_instance - ssh = stub('session', :logger => nil) - Net::SSH.expects(:start). - with("remote.host", "username", :password => "foo"). - returns(ssh) - - ssh.expects(:close).never - scp = Net::SCP.start("remote.host", "username", :password => "foo") - assert_instance_of Net::SCP, scp - assert_equal ssh, scp.session - end - - def test_start_with_block_should_yield_scp_and_close_ssh_session - ssh = stub('session', :logger => nil) - Net::SSH.expects(:start). - with("remote.host", "username", :password => "foo"). - returns(ssh) - - ssh.expects(:loop) - ssh.expects(:close) - - yielded = false - Net::SCP.start("remote.host", "username", :password => "foo") do |scp| - yielded = true - assert_instance_of Net::SCP, scp - assert_equal ssh, scp.session - end - - assert yielded - end - - def test_self_upload_should_instatiate_scp_and_invoke_synchronous_upload - scp = stub('scp') - scp.expects(:upload!).with("/path/to/local", "/path/to/remote", :recursive => true) - - Net::SCP.expects(:start). - with("remote.host", "username", :password => "foo"). - yields(scp) - - Net::SCP.upload!("remote.host", "username", "/path/to/local", "/path/to/remote", - :ssh => { :password => "foo" }, :recursive => true) - end - - def test_self_download_should_instatiate_scp_and_invoke_synchronous_download - scp = stub('scp') - scp.expects(:download!).with("/path/to/remote", "/path/to/local", :recursive => true).returns(:result) - - Net::SCP.expects(:start). - with("remote.host", "username", :password => "foo"). - yields(scp) - - result = Net::SCP.download!("remote.host", "username", "/path/to/remote", "/path/to/local", - :ssh => { :password => "foo" }, :recursive => true) - - assert_equal :result, result - end -end diff --git a/vendor/gems/net-scp-1.0.2/test/test_upload.rb b/vendor/gems/net-scp-1.0.2/test/test_upload.rb deleted file mode 100644 index 00eb30b95..000000000 --- a/vendor/gems/net-scp-1.0.2/test/test_upload.rb +++ /dev/null @@ -1,255 +0,0 @@ -require 'common' - -class TestUpload < Net::SCP::TestCase - def test_upload_file_should_transfer_file - prepare_file("/path/to/local.txt", "a" * 1234) - - expect_scp_session "-t /path/to/remote.txt" do |channel| - channel.gets_ok - channel.sends_data "C0666 1234 local.txt\n" - channel.gets_ok - channel.sends_data "a" * 1234 - channel.sends_ok - channel.gets_ok - end - - assert_scripted { scp.upload!("/path/to/local.txt", "/path/to/remote.txt") } - end - - def test_upload_file_with_spaces_in_name_should_escape_remote_file_name - prepare_file("/path/to/local file.txt", "") - - expect_scp_session "-t /path/to/remote\\ file.txt" do |channel| - channel.gets_ok - channel.sends_data "C0666 0 local file.txt\n" - channel.gets_ok - channel.sends_ok - channel.gets_ok - end - - assert_scripted { scp.upload!("/path/to/local file.txt", "/path/to/remote file.txt") } - end - - def test_upload_file_with_preserve_should_send_times - prepare_file("/path/to/local.txt", "a" * 1234, 0666, Time.at(1234567890, 123456), Time.at(1234543210, 345678)) - - expect_scp_session "-t -p /path/to/remote.txt" do |channel| - channel.gets_ok - channel.sends_data "T1234567890 123456 1234543210 345678\n" - channel.gets_ok - channel.sends_data "C0666 1234 local.txt\n" - channel.gets_ok - channel.sends_data "a" * 1234 - channel.sends_ok - channel.gets_ok - end - - assert_scripted { scp.upload!("/path/to/local.txt", "/path/to/remote.txt", :preserve => true) } - end - - def test_upload_file_with_progress_callback_should_invoke_callback - prepare_file("/path/to/local.txt", "a" * 3000 + "b" * 3000 + "c" * 3000 + "d" * 3000) - - expect_scp_session "-t /path/to/remote.txt" do |channel| - channel.gets_ok - channel.sends_data "C0666 12000 local.txt\n" - channel.gets_ok - channel.sends_data "a" * 3000 - channel.sends_data "b" * 3000 - channel.sends_data "c" * 3000 - channel.sends_data "d" * 3000 - channel.sends_ok - channel.gets_ok - end - - calls = [] - progress = Proc.new do |ch, name, sent, total| - calls << [name, sent, total] - end - - assert_scripted do - scp.upload!("/path/to/local.txt", "/path/to/remote.txt", :chunk_size => 3000, &progress) - end - - assert_equal ["/path/to/local.txt", 0, 12000], calls.shift - assert_equal ["/path/to/local.txt", 3000, 12000], calls.shift - assert_equal ["/path/to/local.txt", 6000, 12000], calls.shift - assert_equal ["/path/to/local.txt", 9000, 12000], calls.shift - assert_equal ["/path/to/local.txt", 12000, 12000], calls.shift - assert calls.empty? - end - - def test_upload_io_with_recursive_should_ignore_recursive - expect_scp_session "-t -r /path/to/remote.txt" do |channel| - channel.gets_ok - channel.sends_data "C0640 1234 remote.txt\n" - channel.gets_ok - channel.sends_data "a" * 1234 - channel.sends_ok - channel.gets_ok - end - - io = StringIO.new("a" * 1234) - assert_scripted { scp.upload!(io, "/path/to/remote.txt", :recursive => true) } - end - - def test_upload_io_with_preserve_should_ignore_preserve - expect_scp_session "-t -p /path/to/remote.txt" do |channel| - channel.gets_ok - channel.sends_data "C0640 1234 remote.txt\n" - channel.gets_ok - channel.sends_data "a" * 1234 - channel.sends_ok - channel.gets_ok - end - - io = StringIO.new("a" * 1234) - assert_scripted { scp.upload!(io, "/path/to/remote.txt", :preserve => true) } - end - - def test_upload_io_should_transfer_data - expect_scp_session "-t /path/to/remote.txt" do |channel| - channel.gets_ok - channel.sends_data "C0640 1234 remote.txt\n" - channel.gets_ok - channel.sends_data "a" * 1234 - channel.sends_ok - channel.gets_ok - end - - io = StringIO.new("a" * 1234) - assert_scripted { scp.upload!(io, "/path/to/remote.txt") } - end - - def test_upload_io_with_mode_should_honor_mode_as_permissions - expect_scp_session "-t /path/to/remote.txt" do |channel| - channel.gets_ok - channel.sends_data "C0666 1234 remote.txt\n" - channel.gets_ok - channel.sends_data "a" * 1234 - channel.sends_ok - channel.gets_ok - end - - io = StringIO.new("a" * 1234) - assert_scripted { scp.upload!(io, "/path/to/remote.txt", :mode => 0666) } - end - - def test_upload_directory_without_recursive_should_error - prepare_directory("/path/to/local") - - expect_scp_session("-t /path/to/remote") do |channel| - channel.gets_ok - end - - assert_raises(Net::SCP::Error) { scp.upload!("/path/to/local", "/path/to/remote") } - end - - def test_upload_empty_directory_should_create_directory_and_finish - prepare_directory("/path/to/local") - - expect_scp_session("-t -r /path/to/remote") do |channel| - channel.gets_ok - channel.sends_data "D0777 0 local\n" - channel.gets_ok - channel.sends_data "E\n" - channel.gets_ok - end - - assert_scripted { scp.upload!("/path/to/local", "/path/to/remote", :recursive => true) } - end - - def test_upload_directory_should_recursively_create_and_upload_items - prepare_directory("/path/to/local") do |d| - d.file "hello.txt", "hello world\n" - d.directory "others" do |d2| - d2.file "data.dat", "abcdefghijklmnopqrstuvwxyz" - end - d.file "zoo.doc", "going to the zoo\n" - end - - expect_scp_session("-t -r /path/to/remote") do |channel| - channel.gets_ok - channel.sends_data "D0777 0 local\n" - channel.gets_ok - channel.sends_data "C0666 12 hello.txt\n" - channel.gets_ok - channel.sends_data "hello world\n" - channel.sends_ok - channel.gets_ok - channel.sends_data "D0777 0 others\n" - channel.gets_ok - channel.sends_data "C0666 26 data.dat\n" - channel.gets_ok - channel.sends_data "abcdefghijklmnopqrstuvwxyz" - channel.sends_ok - channel.gets_ok - channel.sends_data "E\n" - channel.gets_ok - channel.sends_data "C0666 17 zoo.doc\n" - channel.gets_ok - channel.sends_data "going to the zoo\n" - channel.sends_ok - channel.gets_ok - channel.sends_data "E\n" - channel.gets_ok - end - - assert_scripted { scp.upload!("/path/to/local", "/path/to/remote", :recursive => true) } - end - - def test_upload_directory_with_preserve_should_send_times_for_all_items - prepare_directory("/path/to/local", 0755, Time.at(17171717, 191919), Time.at(18181818, 101010)) do |d| - d.file "hello.txt", "hello world\n", 0640, Time.at(12345, 67890), Time.at(234567, 890) - d.directory "others", 0770, Time.at(112233, 4455), Time.at(22334455, 667788) do |d2| - d2.file "data.dat", "abcdefghijklmnopqrstuvwxyz", 0600, Time.at(13579135, 13131), Time.at(7654321, 654321) - end - d.file "zoo.doc", "going to the zoo\n", 0444, Time.at(12121212, 131313), Time.at(23232323, 242424) - end - - expect_scp_session("-t -r -p /path/to/remote") do |channel| - channel.gets_ok - channel.sends_data "T17171717 191919 18181818 101010\n" - channel.gets_ok - channel.sends_data "D0755 0 local\n" - channel.gets_ok - channel.sends_data "T12345 67890 234567 890\n" - channel.gets_ok - channel.sends_data "C0640 12 hello.txt\n" - channel.gets_ok - channel.sends_data "hello world\n" - channel.sends_ok - channel.gets_ok - channel.sends_data "T112233 4455 22334455 667788\n" - channel.gets_ok - channel.sends_data "D0770 0 others\n" - channel.gets_ok - channel.sends_data "T13579135 13131 7654321 654321\n" - channel.gets_ok - channel.sends_data "C0600 26 data.dat\n" - channel.gets_ok - channel.sends_data "abcdefghijklmnopqrstuvwxyz" - channel.sends_ok - channel.gets_ok - channel.sends_data "E\n" - channel.gets_ok - channel.sends_data "T12121212 131313 23232323 242424\n" - channel.gets_ok - channel.sends_data "C0444 17 zoo.doc\n" - channel.gets_ok - channel.sends_data "going to the zoo\n" - channel.sends_ok - channel.gets_ok - channel.sends_data "E\n" - channel.gets_ok - end - - assert_scripted { scp.upload!("/path/to/local", "/path/to/remote", :preserve => true, :recursive => true) } - end - - def test_upload_should_not_block - prepare_file("/path/to/local.txt", "data") - story { |s| s.opens_channel(false) } - assert_scripted { scp.upload("/path/to/local.txt", "/path/to/remote.txt") } - end -end diff --git a/vendor/gems/net-sftp-2.0.2/.specification b/vendor/gems/net-sftp-2.0.2/.specification deleted file mode 100644 index c3b1e602c..000000000 --- a/vendor/gems/net-sftp-2.0.2/.specification +++ /dev/null @@ -1,161 +0,0 @@ ---- !ruby/object:Gem::Specification -name: net-sftp -version: !ruby/object:Gem::Version - version: 2.0.2 -platform: ruby -authors: -- Jamis Buck -autorequire: -bindir: bin -cert_chain: [] - -date: 2009-02-01 00:00:00 +00:00 -default_executable: -dependencies: -- !ruby/object:Gem::Dependency - name: net-ssh - type: :runtime - version_requirement: - version_requirements: !ruby/object:Gem::Requirement - requirements: - - - ">=" - - !ruby/object:Gem::Version - version: 2.0.9 - version: -- !ruby/object:Gem::Dependency - name: echoe - type: :development - version_requirement: - version_requirements: !ruby/object:Gem::Requirement - requirements: - - - ">=" - - !ruby/object:Gem::Version - version: "0" - version: -description: A pure Ruby implementation of the SFTP client protocol -email: jamis@jamisbuck.org -executables: [] - -extensions: [] - -extra_rdoc_files: -- CHANGELOG.rdoc -- lib/net/sftp/constants.rb -- lib/net/sftp/errors.rb -- lib/net/sftp/operations/dir.rb -- lib/net/sftp/operations/download.rb -- lib/net/sftp/operations/file.rb -- lib/net/sftp/operations/file_factory.rb -- lib/net/sftp/operations/upload.rb -- lib/net/sftp/packet.rb -- lib/net/sftp/protocol/01/attributes.rb -- lib/net/sftp/protocol/01/base.rb -- lib/net/sftp/protocol/01/name.rb -- lib/net/sftp/protocol/02/base.rb -- lib/net/sftp/protocol/03/base.rb -- lib/net/sftp/protocol/04/attributes.rb -- lib/net/sftp/protocol/04/base.rb -- lib/net/sftp/protocol/04/name.rb -- lib/net/sftp/protocol/05/base.rb -- lib/net/sftp/protocol/06/attributes.rb -- lib/net/sftp/protocol/06/base.rb -- lib/net/sftp/protocol/base.rb -- lib/net/sftp/protocol.rb -- lib/net/sftp/request.rb -- lib/net/sftp/response.rb -- lib/net/sftp/session.rb -- lib/net/sftp/version.rb -- lib/net/sftp.rb -- README.rdoc -files: -- CHANGELOG.rdoc -- lib/net/sftp/constants.rb -- lib/net/sftp/errors.rb -- lib/net/sftp/operations/dir.rb -- lib/net/sftp/operations/download.rb -- lib/net/sftp/operations/file.rb -- lib/net/sftp/operations/file_factory.rb -- lib/net/sftp/operations/upload.rb -- lib/net/sftp/packet.rb -- lib/net/sftp/protocol/01/attributes.rb -- lib/net/sftp/protocol/01/base.rb -- lib/net/sftp/protocol/01/name.rb -- lib/net/sftp/protocol/02/base.rb -- lib/net/sftp/protocol/03/base.rb -- lib/net/sftp/protocol/04/attributes.rb -- lib/net/sftp/protocol/04/base.rb -- lib/net/sftp/protocol/04/name.rb -- lib/net/sftp/protocol/05/base.rb -- lib/net/sftp/protocol/06/attributes.rb -- lib/net/sftp/protocol/06/base.rb -- lib/net/sftp/protocol/base.rb -- lib/net/sftp/protocol.rb -- lib/net/sftp/request.rb -- lib/net/sftp/response.rb -- lib/net/sftp/session.rb -- lib/net/sftp/version.rb -- lib/net/sftp.rb -- Rakefile -- README.rdoc -- setup.rb -- test/common.rb -- test/protocol/01/test_attributes.rb -- test/protocol/01/test_base.rb -- test/protocol/01/test_name.rb -- test/protocol/02/test_base.rb -- test/protocol/03/test_base.rb -- test/protocol/04/test_attributes.rb -- test/protocol/04/test_base.rb -- test/protocol/04/test_name.rb -- test/protocol/05/test_base.rb -- test/protocol/06/test_attributes.rb -- test/protocol/06/test_base.rb -- test/protocol/test_base.rb -- test/test_all.rb -- test/test_dir.rb -- test/test_download.rb -- test/test_file.rb -- test/test_file_factory.rb -- test/test_packet.rb -- test/test_protocol.rb -- test/test_request.rb -- test/test_response.rb -- test/test_session.rb -- test/test_upload.rb -- Manifest -- net-sftp.gemspec -has_rdoc: true -homepage: http://net-ssh.rubyforge.org/sftp -licenses: [] - -post_install_message: -rdoc_options: -- --line-numbers -- --inline-source -- --title -- Net-sftp -- --main -- README.rdoc -require_paths: -- lib -required_ruby_version: !ruby/object:Gem::Requirement - requirements: - - - ">=" - - !ruby/object:Gem::Version - version: "0" - version: -required_rubygems_version: !ruby/object:Gem::Requirement - requirements: - - - ">=" - - !ruby/object:Gem::Version - version: "1.2" - version: -requirements: [] - -rubyforge_project: net-ssh -rubygems_version: 1.3.4 -signing_key: -specification_version: 2 -summary: A pure Ruby implementation of the SFTP client protocol -test_files: -- test/test_all.rb diff --git a/vendor/gems/net-sftp-2.0.2/CHANGELOG.rdoc b/vendor/gems/net-sftp-2.0.2/CHANGELOG.rdoc deleted file mode 100644 index d96f230cf..000000000 --- a/vendor/gems/net-sftp-2.0.2/CHANGELOG.rdoc +++ /dev/null @@ -1,33 +0,0 @@ -=== 2.0.2 / 1 Feb 2009 - -* Avoid using 'ensure' in Net::SFTP.start since it causes unfriendly behavior when exceptions are raised [Jamis Buck] - - -=== 2.0.1 / 29 May 2008 - -* Open files in binary mode to appease Windows [Jamis Buck] - - -=== 2.0.0 / 1 May 2008 - -* Make Net::SSH::Connection::Session#sftp accept an argument determining whether or not to block while the SFTP subsystem initializes (defaults to true) [Jamis Buck] - -* Allow Session#connect to be useful even in the open/opening states by invoking or queuing the callback block [Jamis Buck] - -* Allow custom properties to be set on upload/download initiation via the :properties option [Jamis Buck] - -* Custom properties on Download instances [Jamis Buck] - -* Add #abort! method to Upload and Download operations [Jamis Buck] - -* More complete support for file-type detection in protocol versions 1-3 [Jamis Buck] - - -=== 2.0 Preview Release 2 (1.99.1) / 10 Apr 2008 - -* Custom properties on Upload instances [Jamis Buck] - - -=== 2.0 Preview Release 1 (1.99.0) / 22 Mar 2008 - -* Rewritten! (Never, ever, do this at home.) New and improved API. diff --git a/vendor/gems/net-sftp-2.0.2/Manifest b/vendor/gems/net-sftp-2.0.2/Manifest deleted file mode 100644 index fcb90f661..000000000 --- a/vendor/gems/net-sftp-2.0.2/Manifest +++ /dev/null @@ -1,55 +0,0 @@ -CHANGELOG.rdoc -lib/net/sftp/constants.rb -lib/net/sftp/errors.rb -lib/net/sftp/operations/dir.rb -lib/net/sftp/operations/download.rb -lib/net/sftp/operations/file.rb -lib/net/sftp/operations/file_factory.rb -lib/net/sftp/operations/upload.rb -lib/net/sftp/packet.rb -lib/net/sftp/protocol/01/attributes.rb -lib/net/sftp/protocol/01/base.rb -lib/net/sftp/protocol/01/name.rb -lib/net/sftp/protocol/02/base.rb -lib/net/sftp/protocol/03/base.rb -lib/net/sftp/protocol/04/attributes.rb -lib/net/sftp/protocol/04/base.rb -lib/net/sftp/protocol/04/name.rb -lib/net/sftp/protocol/05/base.rb -lib/net/sftp/protocol/06/attributes.rb -lib/net/sftp/protocol/06/base.rb -lib/net/sftp/protocol/base.rb -lib/net/sftp/protocol.rb -lib/net/sftp/request.rb -lib/net/sftp/response.rb -lib/net/sftp/session.rb -lib/net/sftp/version.rb -lib/net/sftp.rb -Rakefile -README.rdoc -setup.rb -test/common.rb -test/protocol/01/test_attributes.rb -test/protocol/01/test_base.rb -test/protocol/01/test_name.rb -test/protocol/02/test_base.rb -test/protocol/03/test_base.rb -test/protocol/04/test_attributes.rb -test/protocol/04/test_base.rb -test/protocol/04/test_name.rb -test/protocol/05/test_base.rb -test/protocol/06/test_attributes.rb -test/protocol/06/test_base.rb -test/protocol/test_base.rb -test/test_all.rb -test/test_dir.rb -test/test_download.rb -test/test_file.rb -test/test_file_factory.rb -test/test_packet.rb -test/test_protocol.rb -test/test_request.rb -test/test_response.rb -test/test_session.rb -test/test_upload.rb -Manifest diff --git a/vendor/gems/net-sftp-2.0.2/README.rdoc b/vendor/gems/net-sftp-2.0.2/README.rdoc deleted file mode 100644 index 4197a54fc..000000000 --- a/vendor/gems/net-sftp-2.0.2/README.rdoc +++ /dev/null @@ -1,96 +0,0 @@ -= Net::SFTP - -* http://net-ssh.rubyforge.org/sftp - -== DESCRIPTION: - -Net::SFTP is a pure-Ruby implementation of the SFTP protocol (specifically, versions 1 through 6 of the SFTP protocol). Note that this is the "Secure File Transfer Protocol", typically run over an SSH connection, and has nothing to do with the FTP protocol. - -== FEATURES/PROBLEMS: - -* Transfer files or even entire directory trees to or from a remote host via SFTP -* Completely supports all six protocol versions -* Asynchronous and synchronous operation -* Read and write files using an IO-like interface - -== SYNOPSIS: - -In a nutshell: - - require 'net/sftp' - - Net::SFTP.start('host', 'username', :password => 'password') do |sftp| - # upload a file or directory to the remote host - sftp.upload!("/path/to/local", "/path/to/remote") - - # download a file or directory from the remote host - sftp.download!("/path/to/remote", "/path/to/local") - - # grab data off the remote host directly to a buffer - data = sftp.download!("/path/to/remote") - - # open and write to a pseudo-IO for a remote file - sftp.file.open("/path/to/remote", "w") do |f| - f.puts "Hello, world!\n" - end - - # open and read from a pseudo-IO for a remote file - sftp.file.open("/path/to/remote", "r") do |f| - puts f.gets - end - - # create a directory - sftp.mkdir! "/path/to/directory" - - # list the entries in a directory - sftp.dir.foreach("/path/to/directory") do |entry| - puts entry.longname - end - end - -For the full documentation, start with Net::SFTP::Session. Also see Net::SFTP::Operations::Upload, Net::SFTP::Operations::Download, Net::SFTP::Operations::FileFactory, Net::SFTP::Operations::File, and Net::SFTP::Operations::Dir. - -== REQUIREMENTS: - -* Net::SSH 2 - -If you wish to run the tests, you'll need: - -* Echoe (if you want to use the Rakefile) -* Mocha - -== INSTALL: - -* gem install net-sftp (might need sudo privileges) - -Or, if you prefer to do it the hard way (sans Rubygems): - -* tar xzf net-ssh-*.tgz -* cd net-ssh-* -* ruby setup.rb config -* ruby setup.rb install (might need sudo privileges) - -== LICENSE: - -(The MIT License) - -Copyright (c) 2008 Jamis Buck - -Permission is hereby granted, free of charge, to any person obtaining -a copy of this software and associated documentation files (the -'Software'), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, sublicense, and/or sell copies of the Software, and to -permit persons to whom the Software is furnished to do so, subject to -the following conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY -CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, -TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/vendor/gems/net-sftp-2.0.2/Rakefile b/vendor/gems/net-sftp-2.0.2/Rakefile deleted file mode 100644 index ad1aaa743..000000000 --- a/vendor/gems/net-sftp-2.0.2/Rakefile +++ /dev/null @@ -1,30 +0,0 @@ -$LOAD_PATH.unshift "../net-ssh/lib" -require './lib/net/sftp/version' - -begin - require 'echoe' -rescue LoadError - abort "You'll need to have `echoe' installed to use Net::SFTP's Rakefile" -end - -version = Net::SFTP::Version::STRING.dup -if ENV['SNAPSHOT'].to_i == 1 - version << "." << Time.now.utc.strftime("%Y%m%d%H%M%S") -end - -Echoe.new('net-sftp', version) do |p| - p.project = "net-ssh" - p.changelog = "CHANGELOG.rdoc" - - p.author = "Jamis Buck" - p.email = "jamis@jamisbuck.org" - p.summary = "A pure Ruby implementation of the SFTP client protocol" - p.url = "http://net-ssh.rubyforge.org/sftp" - - p.dependencies = ["net-ssh >=2.0.9"] - - p.need_zip = true - p.include_rakefile = true - - p.rdoc_pattern = /^(lib|README.rdoc|CHANGELOG.rdoc)/ -end diff --git a/vendor/gems/net-sftp-2.0.2/lib/net/sftp.rb b/vendor/gems/net-sftp-2.0.2/lib/net/sftp.rb deleted file mode 100644 index 7ed4d1599..000000000 --- a/vendor/gems/net-sftp-2.0.2/lib/net/sftp.rb +++ /dev/null @@ -1,70 +0,0 @@ -require 'net/ssh' -require 'net/sftp/session' - -module Net - - # Net::SFTP is a pure-Ruby module for programmatically interacting with a - # remote host via the SFTP protocol (that's SFTP as in "Secure File Transfer - # Protocol" produced by the Secure Shell Working Group, not "Secure FTP" - # and certainly not "Simple FTP"). - # - # See Net::SFTP#start for an introduction to the library. Also, see - # Net::SFTP::Session for further documentation. - module SFTP - # A convenience method for starting a standalone SFTP session. It will - # start up an SSH session using the given arguments (see the documentation - # for Net::SSH::Session for details), and will then start a new SFTP session - # with the SSH session. This will block until the new SFTP is fully open - # and initialized before returning it. - # - # sftp = Net::SFTP.start("localhost", "user") - # sftp.upload! "/local/file.tgz", "/remote/file.tgz" - # - # If a block is given, it will be passed to the SFTP session and will be - # called once the SFTP session is fully open and initialized. When the - # block terminates, the new SSH session will automatically be closed. - # - # Net::SFTP.start("localhost", "user") do |sftp| - # sftp.upload! "/local/file.tgz", "/remote/file.tgz" - # end - def self.start(host, user, options={}, &block) - session = Net::SSH.start(host, user, options) - sftp = Net::SFTP::Session.new(session, &block).connect! - - if block_given? - sftp.loop - session.close - return nil - end - - sftp - rescue Object => anything - begin - session.shutdown! - rescue Exception - # swallow exceptions that occur while trying to shutdown - end - - raise anything - end - end - -end - -class Net::SSH::Connection::Session - # A convenience method for starting up a new SFTP connection on the current - # SSH session. Blocks until the SFTP session is fully open, and then - # returns the SFTP session. - # - # Net::SSH.start("localhost", "user", "password") do |ssh| - # ssh.sftp.upload!("/local/file.tgz", "/remote/file.tgz") - # ssh.exec! "cd /some/path && tar xf /remote/file.tgz && rm /remote/file.tgz" - # end - def sftp(wait=true) - @sftp ||= begin - sftp = Net::SFTP::Session.new(self) - sftp.connect! if wait - sftp - end - end -end diff --git a/vendor/gems/net-sftp-2.0.2/lib/net/sftp/constants.rb b/vendor/gems/net-sftp-2.0.2/lib/net/sftp/constants.rb deleted file mode 100644 index e8f137a10..000000000 --- a/vendor/gems/net-sftp-2.0.2/lib/net/sftp/constants.rb +++ /dev/null @@ -1,187 +0,0 @@ -module Net module SFTP - - # The packet types and other general constants used by the SFTP protocol. - # See the specification for the SFTP protocol for a full discussion of their - # meaning and usage. - module Constants - - # The various packet types supported by SFTP protocol versions 1 through 6. - # The FXP_EXTENDED and FXP_EXTENDED_REPLY packet types are not currently - # understood by Net::SFTP. - module PacketTypes - FXP_INIT = 1 - FXP_VERSION = 2 - - FXP_OPEN = 3 - FXP_CLOSE = 4 - FXP_READ = 5 - FXP_WRITE = 6 - FXP_LSTAT = 7 - FXP_FSTAT = 8 - FXP_SETSTAT = 9 - FXP_FSETSTAT = 10 - FXP_OPENDIR = 11 - FXP_READDIR = 12 - FXP_REMOVE = 13 - FXP_MKDIR = 14 - FXP_RMDIR = 15 - FXP_REALPATH = 16 - FXP_STAT = 17 - FXP_RENAME = 18 - FXP_READLINK = 19 - FXP_SYMLINK = 20 - FXP_LINK = 21 - FXP_BLOCK = 22 - FXP_UNBLOCK = 23 - - FXP_STATUS = 101 - FXP_HANDLE = 102 - FXP_DATA = 103 - FXP_NAME = 104 - FXP_ATTRS = 105 - - FXP_EXTENDED = 200 - FXP_EXTENDED_REPLY = 201 - end - - # Beginning in version 5 of the protocol, Net::SFTP::Session#rename accepts - # an optional +flags+ argument that must be either 0 or a combination of - # these constants. - module RenameFlags - OVERWRITE = 0x00000001 - ATOMIC = 0x00000002 - NATIVE = 0x00000004 - end - - # When an FXP_STATUS packet is received from the server, the +code+ will - # be one of the following constants. - module StatusCodes - FX_OK = 0 - FX_EOF = 1 - FX_NO_SUCH_FILE = 2 - FX_PERMISSION_DENIED = 3 - FX_FAILURE = 4 - FX_BAD_MESSAGE = 5 - FX_NO_CONNECTION = 6 - FX_CONNECTION_LOST = 7 - FX_OP_UNSUPPORTED = 8 - FX_INVALID_HANDLE = 9 - FX_NO_SUCH_PATH = 10 - FX_FILE_ALREADY_EXISTS = 11 - FX_WRITE_PROTECT = 12 - FX_NO_MEDIA = 13 - FX_NO_SPACE_ON_FILESYSTEM = 14 - FX_QUOTA_EXCEEDED = 15 - FX_UNKNOWN_PRINCIPLE = 16 - FX_LOCK_CONFlICT = 17 - FX_DIR_NOT_EMPTY = 18 - FX_NOT_A_DIRECTORY = 19 - FX_INVALID_FILENAME = 20 - FX_LINK_LOOP = 21 - end - - # The Net::SFTP::Session#open operation is one of the worst casualties of - # the revisions between SFTP protocol versions. The flags change considerably - # between version 1 and version 6. Net::SFTP tries to shield programmers - # from the differences, so you'll almost never need to use these flags - # directly, but if you ever need to specify some flag that isn't exposed - # by the higher-level API, these are the ones that are available to you. - module OpenFlags - # These are the flags that are understood by versions 1-4 of the the - # open operation. - module FV1 - READ = 0x00000001 - WRITE = 0x00000002 - APPEND = 0x00000004 - CREAT = 0x00000008 - TRUNC = 0x00000010 - EXCL = 0x00000020 - end - - # Version 5 of the open operation totally discarded the flags understood - # by versions 1-4, and replaced them with these. - module FV5 - CREATE_NEW = 0x00000000 - CREATE_TRUNCATE = 0x00000001 - OPEN_EXISTING = 0x00000002 - OPEN_OR_CREATE = 0x00000003 - TRUNCATE_EXISTING = 0x00000004 - - APPEND_DATA = 0x00000008 - APPEND_DATA_ATOMIC = 0x00000010 - TEXT_MODE = 0x00000020 - READ_LOCK = 0x00000040 - WRITE_LOCK = 0x00000080 - DELETE_LOCK = 0x00000100 - end - - # Version 6 of the open operation added these flags, in addition to the - # flags understood by version 5. - module FV6 - ADVISORY_LOCK = 0x00000200 - NOFOLLOW = 0x00000400 - DELETE_ON_CLOSE = 0x00000800 - ACCESS_AUDIT_ALARM_INFO = 0x00001000 - ACCESS_BACKUP = 0x00002000 - BACKUP_STREAM = 0x00004000 - OVERRIDE_OWNER = 0x00008000 - end - end - - # The Net::SFTP::Session#block operation, implemented in version 6 of - # the protocol, understands these constants for the +mask+ parameter. - module LockTypes - READ = OpenFlags::FV5::READ_LOCK - WRITE = OpenFlags::FV5::WRITE_LOCK - DELETE = OpenFlags::FV5::DELETE_LOCK - ADVISORY = OpenFlags::FV6::ADVISORY_LOCK - end - - module ACE - # Access control entry types, used from version 4 of the protocol, - # onward. See Net::SFTP::Protocol::V04::Attributes::ACL. - module Type - ACCESS_ALLOWED = 0x00000000 - ACCESS_DENIED = 0x00000001 - SYSTEM_AUDIT = 0x00000002 - SYSTEM_ALARM = 0x00000003 - end - - # Access control entry flags, used from version 4 of the protocol, - # onward. See Net::SFTP::Protocol::V04::Attributes::ACL. - module Flag - FILE_INHERIT = 0x00000001 - DIRECTORY_INHERIT = 0x00000002 - NO_PROPAGATE_INHERIT = 0x00000004 - INHERIT_ONLY = 0x00000008 - SUCCESSFUL_ACCESS = 0x00000010 - FAILED_ACCESS = 0x00000020 - IDENTIFIER_GROUP = 0x00000040 - end - - # Access control entry masks, used from version 4 of the protocol, - # onward. See Net::SFTP::Protocol::V04::Attributes::ACL. - module Mask - READ_DATA = 0x00000001 - LIST_DIRECTORY = 0x00000001 - WRITE_DATA = 0x00000002 - ADD_FILE = 0x00000002 - APPEND_DATA = 0x00000004 - ADD_SUBDIRECTORY = 0x00000004 - READ_NAMED_ATTRS = 0x00000008 - WRITE_NAMED_ATTRS = 0x00000010 - EXECUTE = 0x00000020 - DELETE_CHILD = 0x00000040 - READ_ATTRIBUTES = 0x00000080 - WRITE_ATTRIBUTES = 0x00000100 - DELETE = 0x00010000 - READ_ACL = 0x00020000 - WRITE_ACL = 0x00040000 - WRITE_OWNER = 0x00080000 - SYNCHRONIZE = 0x00100000 - end - end - - end - -end end diff --git a/vendor/gems/net-sftp-2.0.2/lib/net/sftp/errors.rb b/vendor/gems/net-sftp-2.0.2/lib/net/sftp/errors.rb deleted file mode 100644 index b40cb4d96..000000000 --- a/vendor/gems/net-sftp-2.0.2/lib/net/sftp/errors.rb +++ /dev/null @@ -1,39 +0,0 @@ -module Net; module SFTP - - # The base exception class for the SFTP system. - class Exception < RuntimeError; end - - # A exception class for reporting a non-success result of an operation. - class StatusException < Net::SFTP::Exception - - # The response object that caused the exception. - attr_reader :response - - # The error code (numeric) - attr_reader :code - - # The description of the error - attr_reader :description - - # Any incident-specific text given when the exception was raised - attr_reader :text - - # Create a new status exception that reports the given code and - # description. - def initialize(response, text=nil) - @response, @text = response, text - @code = response.code - @description = response.message - @description = Response::MAP[@code] if @description.nil? || @description.empty? - end - - # Override the default message format, to include the code and - # description. - def message - m = super - m << " #{text}" if text - m << " (#{code}, #{description.inspect})" - end - - end -end; end diff --git a/vendor/gems/net-sftp-2.0.2/lib/net/sftp/operations/dir.rb b/vendor/gems/net-sftp-2.0.2/lib/net/sftp/operations/dir.rb deleted file mode 100644 index 614c78135..000000000 --- a/vendor/gems/net-sftp-2.0.2/lib/net/sftp/operations/dir.rb +++ /dev/null @@ -1,93 +0,0 @@ -require 'net/ssh/loggable' - -module Net; module SFTP; module Operations - - # A convenience class for working with remote directories. It provides methods - # for searching and enumerating directory entries, similarly to the standard - # ::Dir class. - # - # sftp.dir.foreach("/remote/path") do |entry| - # puts entry.name - # end - # - # p sftp.dir.entries("/remote/path").map { |e| e.name } - # - # sftp.dir.glob("/remote/path", "**/*.rb") do |entry| - # puts entry.name - # end - class Dir - # The SFTP session object that drives this directory factory. - attr_reader :sftp - - # Create a new instance on top of the given SFTP session instance. - def initialize(sftp) - @sftp = sftp - end - - # Calls the block once for each entry in the named directory on the - # remote server. Yields a Name object to the block, rather than merely - # the name of the entry. - def foreach(path) - handle = sftp.opendir!(path) - while entries = sftp.readdir!(handle) - entries.each { |entry| yield entry } - end - return nil - ensure - sftp.close!(handle) if handle - end - - # Returns an array of Name objects representing the items in the given - # remote directory, +path+. - def entries(path) - results = [] - foreach(path) { |entry| results << entry } - return results - end - - # Works as ::Dir.glob, matching (possibly recursively) all directory - # entries under +path+ against +pattern+. If a block is given, matches - # will be yielded to the block as they are found; otherwise, they will - # be returned in an array when the method finishes. - # - # Because working over an SFTP connection is always going to be slower than - # working purely locally, don't expect this method to perform with the - # same level of alacrity that ::Dir.glob does; it will work best for - # shallow directory hierarchies with relatively few directories, though - # it should be able to handle modest numbers of files in each directory. - def glob(path, pattern, flags=0) - flags |= ::File::FNM_PATHNAME - path = path.chop if path[-1,1] == "/" - - results = [] unless block_given? - queue = entries(path).reject { |e| e.name == "." || e.name == ".." } - while queue.any? - entry = queue.shift - - if entry.directory? && !%w(. ..).include?(::File.basename(entry.name)) - queue += entries("#{path}/#{entry.name}").map do |e| - e.name.replace("#{entry.name}/#{e.name}") - e - end - end - - if ::File.fnmatch(pattern, entry.name, flags) - if block_given? - yield entry - else - results << entry - end - end - end - - return results unless block_given? - end - - # Identical to calling #glob with a +flags+ parameter of 0 and no block. - # Simply returns the matched entries as an array. - def [](path, pattern) - glob(path, pattern, 0) - end - end - -end; end; end \ No newline at end of file diff --git a/vendor/gems/net-sftp-2.0.2/lib/net/sftp/operations/download.rb b/vendor/gems/net-sftp-2.0.2/lib/net/sftp/operations/download.rb deleted file mode 100644 index 7eb08a312..000000000 --- a/vendor/gems/net-sftp-2.0.2/lib/net/sftp/operations/download.rb +++ /dev/null @@ -1,364 +0,0 @@ -require 'net/ssh/loggable' - -module Net; module SFTP; module Operations - - # A general purpose downloader module for Net::SFTP. It can download files - # into IO objects, or directly to files on the local file system. It can - # even download entire directory trees via SFTP, and provides a flexible - # progress reporting mechanism. - # - # To download a single file from the remote server, simply specify both the - # remote and local paths: - # - # downloader = sftp.download("/path/to/remote.txt", "/path/to/local.txt") - # - # By default, this operates asynchronously, so if you want to block until - # the download finishes, you can use the 'bang' variant: - # - # sftp.download!("/path/to/remote.txt", "/path/to/local.txt") - # - # Or, if you have multiple downloads that you want to run in parallel, you can - # employ the #wait method of the returned object: - # - # dls = %w(file1 file2 file3).map { |f| sftp.download("remote/#{f}", f) } - # dls.each { |d| d.wait } - # - # To download an entire directory tree, recursively, simply specify :recursive => true: - # - # sftp.download!("/path/to/remotedir", "/path/to/local", :recursive => true) - # - # This will download "/path/to/remotedir", it's contents, it's subdirectories, - # and their contents, recursively, to "/path/to/local" on the local host. - # (If you specify :recursive => true and the source is not a directory, - # you'll get an error!) - # - # If you want to pull the contents of a file on the remote server, and store - # the data in memory rather than immediately to disk, you can pass an IO - # object as the destination: - # - # require 'stringio' - # io = StringIO.new - # sftp.download!("/path/to/remote", io) - # - # This will only work for single-file downloads. Trying to do so with - # :recursive => true will cause an error. - # - # The following options are supported: - # - # * :progress - either a block or an object to act as a progress - # callback. See the discussion of "progress monitoring" below. - # * :requests - the number of pending SFTP requests to allow at - # any given time. When downloading an entire directory tree recursively, - # this will default to 16. Setting this higher might improve throughput. - # Reducing it will reduce throughput. - # * :read_size - the maximum number of bytes to read at a time - # from the source. Increasing this value might improve throughput. It - # defaults to 32,000 bytes. - # - # == Progress Monitoring - # - # Sometimes it is desirable to track the progress of a download. There are - # two ways to do this: either using a callback block, or a special custom - # object. - # - # Using a block it's pretty straightforward: - # - # sftp.download!("remote", "local") do |event, downloader, *args| - # case event - # when :open then - # # args[0] : file metadata - # puts "starting download: #{args[0].remote} -> #{args[0].local} (#{args[0].size} bytes}" - # when :get then - # # args[0] : file metadata - # # args[1] : byte offset in remote file - # # args[2] : data that was received - # puts "writing #{args[2].length} bytes to #{args[0].local} starting at #{args[1]}" - # when :close then - # # args[0] : file metadata - # puts "finished with #{args[0].remote}" - # when :mkdir then - # # args[0] : local path name - # puts "creating directory #{args[0]}" - # when :finish then - # puts "all done!" - # end - # - # However, for more complex implementations (e.g., GUI interfaces and such) - # a block can become cumbersome. In those cases, you can create custom - # handler objects that respond to certain methods, and then pass your handler - # to the downloader: - # - # class CustomHandler - # def on_open(downloader, file) - # puts "starting download: #{file.remote} -> #{file.local} (#{file.size} bytes)" - # end - # - # def on_get(downloader, file, offset, data) - # puts "writing #{data.length} bytes to #{file.local} starting at #{offset}" - # end - # - # def on_close(downloader, file) - # puts "finished with #{file.remote}" - # end - # - # def on_mkdir(downloader, path) - # puts "creating directory #{path}" - # end - # - # def on_finish(downloader) - # puts "all done!" - # end - # end - # - # sftp.download!("remote", "local", :progress => CustomHandler.new) - # - # If you omit any of those methods, the progress updates for those missing - # events will be ignored. You can create a catchall method named "call" for - # those, instead. - class Download - include Net::SSH::Loggable - - # The destination of the download (the name of a file or directory on - # the local server, or an IO object) - attr_reader :local - - # The source of the download (the name of a file or directory on the - # remote server) - attr_reader :remote - - # The hash of options that was given to this Download instance. - attr_reader :options - - # The SFTP session instance that drives this download. - attr_reader :sftp - - # The properties hash for this object - attr_reader :properties - - # Instantiates a new downloader process on top of the given SFTP session. - # +local+ is either an IO object that should receive the data, or a string - # identifying the target file or directory on the local host. +remote+ is - # a string identifying the location on the remote host that the download - # should source. - # - # This will return immediately, and requires that the SSH event loop be - # run in order to effect the download. (See #wait.) - def initialize(sftp, local, remote, options={}, &progress) - @sftp = sftp - @local = local - @remote = remote - @progress = progress || options[:progress] - @options = options - @active = 0 - @properties = options[:properties] || {} - - self.logger = sftp.logger - - if recursive? && local.respond_to?(:write) - raise ArgumentError, "cannot download a directory tree in-memory" - end - - @stack = [Entry.new(remote, local, recursive?)] - process_next_entry - end - - # Returns the value of the :recursive key in the options hash that was - # given when the object was instantiated. - def recursive? - options[:recursive] - end - - # Returns true if there are any active requests or pending files or - # directories. - def active? - @active > 0 || stack.any? - end - - # Forces the transfer to stop. - def abort! - @active = 0 - @stack.clear - end - - # Runs the SSH event loop for as long as the downloader is active (see - # #active?). This can be used to block until the download completes. - def wait - sftp.loop { active? } - self - end - - # Returns the property with the given name. This allows Download instances - # to store their own state when used as part of a state machine. - def [](name) - @properties[name.to_sym] - end - - # Sets the given property to the given name. This allows Download instances - # to store their own state when used as part of a state machine. - def []=(name, value) - @properties[name.to_sym] = value - end - - private - - # A simple struct for encapsulating information about a single remote - # file or directory that needs to be downloaded. - Entry = Struct.new(:remote, :local, :directory, :size, :handle, :offset, :sink) - - #-- - # "ruby -w" hates private attributes, so we have to do these longhand - #++ - - # The stack of Entry instances, indicating which files and directories - # on the remote host remain to be downloaded. - def stack; @stack; end - - # The progress handler for this instance. Possibly nil. - def progress; @progress; end - - # The default read size. - DEFAULT_READ_SIZE = 32_000 - - # The number of bytes to read at a time from remote files. - def read_size - options[:read_size] || DEFAULT_READ_SIZE - end - - # The number of simultaneou SFTP requests to use to effect the download. - # Defaults to 16 for recursive downloads. - def requests - options[:requests] || (recursive? ? 16 : 2) - end - - # Enqueues as many files and directories from the stack as possible - # (see #requests). - def process_next_entry - while stack.any? && requests > @active - entry = stack.shift - @active += 1 - - if entry.directory - update_progress(:mkdir, entry.local) - ::Dir.mkdir(entry.local) unless ::File.directory?(entry.local) - request = sftp.opendir(entry.remote, &method(:on_opendir)) - request[:entry] = entry - else - open_file(entry) - end - end - - update_progress(:finish) if !active? - end - - # Called when a remote directory is "opened" for reading, e.g. to - # enumerate its contents. Starts an readdir operation if the opendir - # operation was successful. - def on_opendir(response) - entry = response.request[:entry] - raise "opendir #{entry.remote}: #{response}" unless response.ok? - entry.handle = response[:handle] - request = sftp.readdir(response[:handle], &method(:on_readdir)) - request[:parent] = entry - end - - # Called when the next batch of items is read from a directory on the - # remote server. If any items were read, they are added to the queue - # and #process_next_entry is called. - def on_readdir(response) - entry = response.request[:parent] - if response.eof? - request = sftp.close(entry.handle, &method(:on_closedir)) - request[:parent] = entry - elsif !response.ok? - raise "readdir #{entry.remote}: #{response}" - else - response[:names].each do |item| - next if item.name == "." || item.name == ".." - stack << Entry.new(::File.join(entry.remote, item.name), ::File.join(entry.local, item.name), item.directory?, item.attributes.size) - end - - # take this opportunity to enqueue more requests - process_next_entry - - request = sftp.readdir(entry.handle, &method(:on_readdir)) - request[:parent] = entry - end - end - - # Called when a file is to be opened for reading from the remote server. - def open_file(entry) - update_progress(:open, entry) - request = sftp.open(entry.remote, &method(:on_open)) - request[:entry] = entry - end - - # Called when a directory handle is closed. - def on_closedir(response) - @active -= 1 - entry = response.request[:parent] - raise "close #{entry.remote}: #{response}" unless response.ok? - process_next_entry - end - - # Called when a file has been opened. This will call #download_next_chunk - # to initiate the data transfer. - def on_open(response) - entry = response.request[:entry] - raise "open #{entry.remote}: #{response}" unless response.ok? - - entry.handle = response[:handle] - entry.sink = entry.local.respond_to?(:write) ? entry.local : ::File.open(entry.local, "wb") - entry.offset = 0 - - download_next_chunk(entry) - end - - # Initiates a read of the next #read_size bytes from the file. - def download_next_chunk(entry) - request = sftp.read(entry.handle, entry.offset, read_size, &method(:on_read)) - request[:entry] = entry - request[:offset] = entry.offset - entry.offset += read_size - end - - # Called when a read from a file finishes. If the read was successful - # and returned data, this will call #download_next_chunk to read the - # next bit from the file. Otherwise the file will be closed. - def on_read(response) - entry = response.request[:entry] - - if response.eof? - update_progress(:close, entry) - entry.sink.close - request = sftp.close(entry.handle, &method(:on_close)) - request[:entry] = entry - elsif !response.ok? - raise "read #{entry.remote}: #{response}" - else - update_progress(:get, entry, response.request[:offset], response[:data]) - entry.sink.write(response[:data]) - download_next_chunk(entry) - end - end - - # Called when a file handle is closed. - def on_close(response) - @active -= 1 - entry = response.request[:entry] - raise "close #{entry.remote}: #{response}" unless response.ok? - process_next_entry - end - - # If a progress callback or object has been set, this will report - # the progress to that callback or object. - def update_progress(hook, *args) - on = "on_#{hook}" - if progress.respond_to?(on) - progress.send(on, self, *args) - elsif progress.respond_to?(:call) - progress.call(hook, self, *args) - end - end - end - -end; end; end diff --git a/vendor/gems/net-sftp-2.0.2/lib/net/sftp/operations/file.rb b/vendor/gems/net-sftp-2.0.2/lib/net/sftp/operations/file.rb deleted file mode 100644 index bbc2e0960..000000000 --- a/vendor/gems/net-sftp-2.0.2/lib/net/sftp/operations/file.rb +++ /dev/null @@ -1,176 +0,0 @@ -require 'net/ssh/loggable' -require 'net/sftp/operations/file' - -module Net; module SFTP; module Operations - - # A wrapper around an SFTP file handle, that exposes an IO-like interface - # for interacting with the remote file. All operations are synchronous - # (blocking), making this a very convenient way to deal with remote files. - # - # A wrapper is usually created via the Net::SFTP::Session#file factory: - # - # file = sftp.file.open("/path/to/remote") - # puts file.gets - # file.close - class File - # A reference to the Net::SFTP::Session instance that drives this wrapper - attr_reader :sftp - - # The SFTP file handle object that this object wraps - attr_reader :handle - - # The current position within the remote file - attr_reader :pos - - # Creates a new wrapper that encapsulates the given +handle+ (such as - # would be returned by Net::SFTP::Session#open!). The +sftp+ parameter - # must be the same Net::SFTP::Session instance that opened the file. - def initialize(sftp, handle) - @sftp = sftp - @handle = handle - @pos = 0 - @real_pos = 0 - @real_eof = false - @buffer = "" - end - - # Repositions the file pointer to the given offset (relative to the - # start of the file). This will also reset the EOF flag. - def pos=(offset) - @real_pos = @pos = offset - @buffer = "" - @real_eof = false - end - - # Closes the underlying file and sets the handle to +nil+. Subsequent - # operations on this object will fail. - def close - sftp.close!(handle) - @handle = nil - end - - # Returns true if the end of the file has been encountered by a previous - # read. Setting the current file position via #pos= will reset this - # flag (useful if the file's contents have changed since the EOF was - # encountered). - def eof? - @real_eof && @buffer.empty? - end - - # Reads up to +n+ bytes of data from the stream. Fewer bytes will be - # returned if EOF is encountered before the requested number of bytes - # could be read. Without an argument (or with a nil argument) all data - # to the end of the file will be read and returned. - # - # This will advance the file pointer (#pos). - def read(n=nil) - loop do - break if n && @buffer.length >= n - break unless fill - end - - if n - result, @buffer = @buffer[0,n], (@buffer[n..-1] || "") - else - result, @buffer = @buffer, "" - end - - @pos += result.length - return result - end - - # Reads up to the next instance of +sep_string+ in the stream, and - # returns the bytes read (including +sep_string+). If +sep_string+ is - # omitted, it defaults to +$/+. If EOF is encountered before any data - # could be read, #gets will return +nil+. - def gets(sep_string=$/) - delim = if sep_string.length == 0 - "#{$/}#{$/}" - else - sep_string - end - - loop do - at = @buffer.index(delim) - if at - offset = at + delim.length - @pos += offset - line, @buffer = @buffer[0,offset], @buffer[offset..-1] - return line - elsif !fill - return nil if @buffer.empty? - @pos += @buffer.length - line, @buffer = @buffer, "" - return line - end - end - end - - # Same as #gets, but raises EOFError if EOF is encountered before any - # data could be read. - def readline(sep_string=$/) - line = gets(sep_string) - raise EOFError if line.nil? - return line - end - - # Writes the given data to the stream, incrementing the file position and - # returning the number of bytes written. - def write(data) - data = data.to_s - sftp.write!(handle, @real_pos, data) - @real_pos += data.length - @pos = @real_pos - data.length - end - - # Writes each argument to the stream. If +$\+ is set, it will be written - # after all arguments have been written. - def print(*items) - items.each { |item| write(item) } - write($\) if $\ - nil - end - - # Writes each argument to the stream, appending a newline to any item - # that does not already end in a newline. Array arguments are flattened. - def puts(*items) - items.each do |item| - if Array === item - puts(*item) - else - write(item) - write("\n") unless item[-1] == ?\n - end - end - nil - end - - # Performs an fstat operation on the handle and returns the attribute - # object (Net::SFTP::Protocol::V01::Attributes, Net::SFTP::Protool::V04::Attributes, - # or Net::SFTP::Protocol::V06::Attributes, depending on the SFTP protocol - # version in use). - def stat - sftp.fstat!(handle) - end - - private - - # Fills the buffer. Returns +true+ if it succeeded, and +false+ if - # EOF was encountered before any data was read. - def fill - data = sftp.read!(handle, @real_pos, 8192) - - if data.nil? - @real_eof = true - return false - else - @real_pos += data.length - @buffer << data - end - - !@real_eof - end - end - -end; end; end diff --git a/vendor/gems/net-sftp-2.0.2/lib/net/sftp/operations/file_factory.rb b/vendor/gems/net-sftp-2.0.2/lib/net/sftp/operations/file_factory.rb deleted file mode 100644 index b3d3a8aba..000000000 --- a/vendor/gems/net-sftp-2.0.2/lib/net/sftp/operations/file_factory.rb +++ /dev/null @@ -1,60 +0,0 @@ -require 'net/ssh/loggable' -require 'net/sftp/operations/file' - -module Net; module SFTP; module Operations - - # A factory class for opening files and returning Operations::File instances - # that wrap the SFTP handles that represent them. This is a convenience - # class for use when working with files synchronously. Rather than relying - # on the programmer to provide callbacks that define a state machine that - # describes the behavior of the program, this class (and Operations::File) - # provide an interface where calls will block until they return, mimicking - # the IO class' interface. - class FileFactory - # The SFTP session object that drives this file factory. - attr_reader :sftp - - # Create a new instance on top of the given SFTP session instance. - def initialize(sftp) - @sftp = sftp - end - - # :call-seq: - # open(name, flags="r", mode=nil) -> file - # open(name, flags="r", mode=nil) { |file| ... } - # - # Attempt to open a file on the remote server. The +flags+ parameter - # accepts the same values as the standard Ruby ::File#open method. The - # +mode+ parameter must be an integer describing the permissions to use - # if a new file is being created. - # - # If a block is given, the new Operations::File instance will be yielded - # to it, and closed automatically when the block terminates. Otherwise - # the object will be returned, and it is the caller's responsibility to - # close the file. - # - # sftp.file.open("/tmp/names.txt", "w") do |f| - # # ... - # end - def open(name, flags="r", mode=nil, &block) - handle = sftp.open!(name, flags, :permissions => mode) - file = Operations::File.new(sftp, handle) - - if block_given? - begin - yield file - ensure - file.close - end - else - return file - end - end - - # Returns +true+ if the argument refers to a directory on the remote host. - def directory?(path) - sftp.lstat!(path).directory? - end - end - -end; end; end diff --git a/vendor/gems/net-sftp-2.0.2/lib/net/sftp/operations/upload.rb b/vendor/gems/net-sftp-2.0.2/lib/net/sftp/operations/upload.rb deleted file mode 100644 index 8484fec85..000000000 --- a/vendor/gems/net-sftp-2.0.2/lib/net/sftp/operations/upload.rb +++ /dev/null @@ -1,387 +0,0 @@ -require 'net/ssh/loggable' - -module Net; module SFTP; module Operations - - # A general purpose uploader module for Net::SFTP. It can upload IO objects, - # files, and even entire directory trees via SFTP, and provides a flexible - # progress reporting mechanism. - # - # To upload a single file to the remote server, simply specify both the - # local and remote paths: - # - # uploader = sftp.upload("/path/to/local.txt", "/path/to/remote.txt") - # - # By default, this operates asynchronously, so if you want to block until - # the upload finishes, you can use the 'bang' variant: - # - # sftp.upload!("/path/to/local.txt", "/path/to/remote.txt") - # - # Or, if you have multiple uploads that you want to run in parallel, you can - # employ the #wait method of the returned object: - # - # uploads = %w(file1 file2 file3).map { |f| sftp.upload(f, "remote/#{f}") } - # uploads.each { |u| u.wait } - # - # To upload an entire directory tree, recursively, simply pass the directory - # path as the first parameter: - # - # sftp.upload!("/path/to/directory", "/path/to/remote") - # - # This will upload "/path/to/directory", it's contents, it's subdirectories, - # and their contents, recursively, to "/path/to/remote" on the remote server. - # - # If you want to send data to a file on the remote server, but the data is - # in memory, you can pass an IO object and upload it's contents: - # - # require 'stringio' - # io = StringIO.new(data) - # sftp.upload!(io, "/path/to/remote") - # - # The following options are supported: - # - # * :progress - either a block or an object to act as a progress - # callback. See the discussion of "progress monitoring" below. - # * :requests - the number of pending SFTP requests to allow at - # any given time. When uploading an entire directory tree recursively, - # this will default to 16, otherwise it will default to 2. Setting this - # higher might improve throughput. Reducing it will reduce throughput. - # * :read_size - the maximum number of bytes to read at a time - # from the source. Increasing this value might improve throughput. It - # defaults to 32,000 bytes. - # * :name - the filename to report to the progress monitor when - # an IO object is given as +local+. This defaults to "". - # - # == Progress Monitoring - # - # Sometimes it is desirable to track the progress of an upload. There are - # two ways to do this: either using a callback block, or a special custom - # object. - # - # Using a block it's pretty straightforward: - # - # sftp.upload!("local", "remote") do |event, uploader, *args| - # case event - # when :open then - # # args[0] : file metadata - # puts "starting upload: #{args[0].local} -> #{args[0].remote} (#{args[0].size} bytes}" - # when :put then - # # args[0] : file metadata - # # args[1] : byte offset in remote file - # # args[2] : data being written (as string) - # puts "writing #{args[2].length} bytes to #{args[0].remote} starting at #{args[1]}" - # when :close then - # # args[0] : file metadata - # puts "finished with #{args[0].remote}" - # when :mkdir then - # # args[0] : remote path name - # puts "creating directory #{args[0]}" - # when :finish then - # puts "all done!" - # end - # - # However, for more complex implementations (e.g., GUI interfaces and such) - # a block can become cumbersome. In those cases, you can create custom - # handler objects that respond to certain methods, and then pass your handler - # to the uploader: - # - # class CustomHandler - # def on_open(uploader, file) - # puts "starting upload: #{file.local} -> #{file.remote} (#{file.size} bytes)" - # end - # - # def on_put(uploader, file, offset, data) - # puts "writing #{data.length} bytes to #{file.remote} starting at #{offset}" - # end - # - # def on_close(uploader, file) - # puts "finished with #{file.remote}" - # end - # - # def on_mkdir(uploader, path) - # puts "creating directory #{path}" - # end - # - # def on_finish(uploader) - # puts "all done!" - # end - # end - # - # sftp.upload!("local", "remote", :progress => CustomHandler.new) - # - # If you omit any of those methods, the progress updates for those missing - # events will be ignored. You can create a catchall method named "call" for - # those, instead. - class Upload - include Net::SSH::Loggable - - # The source of the upload (on the local server) - attr_reader :local - - # The destination of the upload (on the remote server) - attr_reader :remote - - # The hash of options that were given when the object was instantiated - attr_reader :options - - # The SFTP session object used by this upload instance - attr_reader :sftp - - # The properties hash for this object - attr_reader :properties - - # Instantiates a new uploader process on top of the given SFTP session. - # +local+ is either an IO object containing data to upload, or a string - # identifying a file or directory on the local host. +remote+ is a string - # identifying the location on the remote host that the upload should - # target. - # - # This will return immediately, and requires that the SSH event loop be - # run in order to effect the upload. (See #wait.) - def initialize(sftp, local, remote, options={}, &progress) #:nodoc: - @sftp = sftp - @local = local - @remote = remote - @progress = progress || options[:progress] - @options = options - @properties = options[:properties] || {} - @active = 0 - - self.logger = sftp.logger - - @uploads = [] - @recursive = local.respond_to?(:read) ? false : ::File.directory?(local) - - if recursive? - @stack = [entries_for(local)] - @local_cwd = local - @remote_cwd = remote - - @active += 1 - sftp.mkdir(remote) do |response| - @active -= 1 - raise StatusException.new(response, "mkdir `#{remote}'") unless response.ok? - (options[:requests] || RECURSIVE_READERS).to_i.times do - break unless process_next_entry - end - end - else - raise ArgumentError, "expected a file to upload" unless local.respond_to?(:read) || ::File.exists?(local) - @stack = [[local]] - process_next_entry - end - end - - # Returns true if a directory tree is being uploaded, and false if only a - # single file is being uploaded. - def recursive? - @recursive - end - - # Returns true if the uploader is currently running. When this is false, - # the uploader has finished processing. - def active? - @active > 0 || @stack.any? - end - - # Forces the transfer to stop. - def abort! - @active = 0 - @stack.clear - @uploads.clear - end - - # Blocks until the upload has completed. - def wait - sftp.loop { active? } - self - end - - # Returns the property with the given name. This allows Upload instances - # to store their own state when used as part of a state machine. - def [](name) - @properties[name.to_sym] - end - - # Sets the given property to the given name. This allows Upload instances - # to store their own state when used as part of a state machine. - def []=(name, value) - @properties[name.to_sym] = value - end - - private - - #-- - # "ruby -w" hates private attributes, so we have to do this longhand. - #++ - - # The progress handler for this instance. Possibly nil. - def progress; @progress; end - - # A simple struct for recording metadata about the file currently being - # uploaded. - LiveFile = Struct.new(:local, :remote, :io, :size, :handle) - - # The default # of bytes to read from disk at a time. - DEFAULT_READ_SIZE = 32_000 - - # The number of readers to use when uploading a single file. - SINGLE_FILE_READERS = 2 - - # The number of readers to use when uploading a directory. - RECURSIVE_READERS = 16 - - # Examines the stack and determines what action to take. This is the - # starting point of the state machine. - def process_next_entry - if @stack.empty? - if @uploads.any? - write_next_chunk(@uploads.first) - elsif !active? - update_progress(:finish) - end - return false - elsif @stack.last.empty? - @stack.pop - @local_cwd = ::File.dirname(@local_cwd) - @remote_cwd = ::File.dirname(@remote_cwd) - process_next_entry - elsif recursive? - entry = @stack.last.shift - lpath = ::File.join(@local_cwd, entry) - rpath = ::File.join(@remote_cwd, entry) - - if ::File.directory?(lpath) - @stack.push(entries_for(lpath)) - @local_cwd = lpath - @remote_cwd = rpath - - @active += 1 - update_progress(:mkdir, rpath) - request = sftp.mkdir(rpath, &method(:on_mkdir)) - request[:dir] = rpath - else - open_file(lpath, rpath) - end - else - open_file(@stack.pop.first, remote) - end - return true - end - - # Prepares to send +local+ to +remote+. - def open_file(local, remote) - @active += 1 - - if local.respond_to?(:read) - file = local - name = options[:name] || "" - else - file = ::File.open(local, "rb") - name = local - end - - if file.respond_to?(:stat) - size = file.stat.size - else - size = file.size - end - - metafile = LiveFile.new(name, remote, file, size) - update_progress(:open, metafile) - - request = sftp.open(remote, "w", &method(:on_open)) - request[:file] = metafile - end - - # Called when a +mkdir+ request finishes, successfully or otherwise. - # If the request failed, this will raise a StatusException, otherwise - # it will call #process_next_entry to continue the state machine. - def on_mkdir(response) - @active -= 1 - dir = response.request[:dir] - raise StatusException.new(response, "mkdir #{dir}") unless response.ok? - - process_next_entry - end - - # Called when an +open+ request finishes. Raises StatusException if the - # open failed, otherwise it calls #write_next_chunk to begin sending - # data to the remote server. - def on_open(response) - @active -= 1 - file = response.request[:file] - raise StatusException.new(response, "open #{file.remote}") unless response.ok? - - file.handle = response[:handle] - - @uploads << file - write_next_chunk(file) - - if !recursive? - (options[:requests] || SINGLE_FILE_READERS).to_i.times { write_next_chunk(file) } - end - end - - # Called when a +write+ request finishes. Raises StatusException if the - # write failed, otherwise it calls #write_next_chunk to continue the - # write. - def on_write(response) - @active -= 1 - file = response.request[:file] - raise StatusException.new(response, "write #{file.remote}") unless response.ok? - write_next_chunk(file) - end - - # Called when a +close+ request finishes. Raises a StatusException if the - # close failed, otherwise it calls #process_next_entry to continue the - # state machine. - def on_close(response) - @active -= 1 - file = response.request[:file] - raise StatusException.new(response, "close #{file.remote}") unless response.ok? - process_next_entry - end - - # Attempts to send the next chunk from the given file (where +file+ is - # a LiveFile instance). - def write_next_chunk(file) - if file.io.nil? - process_next_entry - else - @active += 1 - offset = file.io.pos - data = file.io.read(options[:read_size] || DEFAULT_READ_SIZE) - if data.nil? - update_progress(:close, file) - request = sftp.close(file.handle, &method(:on_close)) - request[:file] = file - file.io.close - file.io = nil - @uploads.delete(file) - else - update_progress(:put, file, offset, data) - request = sftp.write(file.handle, offset, data, &method(:on_write)) - request[:file] = file - end - end - end - - # Returns all directory entries for the given path, removing the '.' - # and '..' relative paths. - def entries_for(local) - ::Dir.entries(local).reject { |v| %w(. ..).include?(v) } - end - - # Attempts to notify the progress monitor (if one was given) about - # progress made for the given event. - def update_progress(event, *args) - on = "on_#{event}" - if progress.respond_to?(on) - progress.send(on, self, *args) - elsif progress.respond_to?(:call) - progress.call(event, self, *args) - end - end - end - -end; end; end diff --git a/vendor/gems/net-sftp-2.0.2/lib/net/sftp/packet.rb b/vendor/gems/net-sftp-2.0.2/lib/net/sftp/packet.rb deleted file mode 100644 index 4f0e40a0c..000000000 --- a/vendor/gems/net-sftp-2.0.2/lib/net/sftp/packet.rb +++ /dev/null @@ -1,21 +0,0 @@ -require 'net/ssh/buffer' - -module Net; module SFTP - - # A specialization of the Net::SSH::Buffer class, which simply auto-reads - # the type byte from the front of every packet it represents. - class Packet < Net::SSH::Buffer - # The (intger) type of this packet. See Net::SFTP::Constants for all - # possible packet types. - attr_reader :type - - # Create a new Packet object that wraps the given +data+ (which should be - # a String). The first byte of the data will be consumed automatically and - # interpreted as the #type of this packet. - def initialize(data) - super - @type = read_byte - end - end - -end; end \ No newline at end of file diff --git a/vendor/gems/net-sftp-2.0.2/lib/net/sftp/protocol.rb b/vendor/gems/net-sftp-2.0.2/lib/net/sftp/protocol.rb deleted file mode 100644 index 382b25d6e..000000000 --- a/vendor/gems/net-sftp-2.0.2/lib/net/sftp/protocol.rb +++ /dev/null @@ -1,32 +0,0 @@ -require 'net/sftp/protocol/01/base' -require 'net/sftp/protocol/02/base' -require 'net/sftp/protocol/03/base' -require 'net/sftp/protocol/04/base' -require 'net/sftp/protocol/05/base' -require 'net/sftp/protocol/06/base' - -module Net; module SFTP - - # The Protocol module contains the definitions for all supported SFTP - # protocol versions. - module Protocol - - # Instantiates and returns a new protocol driver instance for the given - # protocol version. +session+ must be a valid SFTP session object, and - # +version+ must be an integer. If an unsupported version is given, - # an exception will be raised. - def self.load(session, version) - case version - when 1 then V01::Base.new(session) - when 2 then V02::Base.new(session) - when 3 then V03::Base.new(session) - when 4 then V04::Base.new(session) - when 5 then V05::Base.new(session) - when 6 then V06::Base.new(session) - else raise NotImplementedError, "unsupported SFTP version #{version.inspect}" - end - end - - end - -end; end \ No newline at end of file diff --git a/vendor/gems/net-sftp-2.0.2/lib/net/sftp/protocol/01/attributes.rb b/vendor/gems/net-sftp-2.0.2/lib/net/sftp/protocol/01/attributes.rb deleted file mode 100644 index df645daef..000000000 --- a/vendor/gems/net-sftp-2.0.2/lib/net/sftp/protocol/01/attributes.rb +++ /dev/null @@ -1,315 +0,0 @@ -require 'net/ssh/buffer' - -module Net; module SFTP; module Protocol; module V01 - - # A class representing the attributes of a file or directory on the server. - # It may be used to specify new attributes, or to query existing attributes. - # - # To specify new attributes, just pass a hash as the argument to the - # constructor. The following keys are supported: - # - # * :size:: the size of the file - # * :uid:: the user-id that owns the file (integer) - # * :gid:: the group-id that owns the file (integer) - # * :owner:: the name of the user that owns the file (string) - # * :group:: the name of the group that owns the file (string) - # * :permissions:: the permissions on the file (integer, e.g. 0755) - # * :atime:: the access time of the file (integer, seconds since epoch) - # * :mtime:: the modification time of the file (integer, seconds since epoch) - # * :extended:: a hash of name/value pairs identifying extended info - # - # Likewise, when the server sends an Attributes object, all of the - # above attributes are exposed as methods (though not all will be set with - # non-nil values from the server). - class Attributes - - F_SIZE = 0x00000001 - F_UIDGID = 0x00000002 - F_PERMISSIONS = 0x00000004 - F_ACMODTIME = 0x00000008 - F_EXTENDED = 0x80000000 - - T_REGULAR = 1 - T_DIRECTORY = 2 - T_SYMLINK = 3 - T_SPECIAL = 4 - T_UNKNOWN = 5 - T_SOCKET = 6 - T_CHAR_DEVICE = 7 - T_BLOCK_DEVICE = 8 - T_FIFO = 9 - - class < packet.read_string } - end - - # Parses the given FXP_STATUS packet and returns a hash with one key, - # :code, which references the status code returned by the server. - def parse_status_packet(packet) - { :code => packet.read_long } - end - - # Parses the given FXP_DATA packet and returns a hash with one key, - # :data, which references the data returned in the packet. - def parse_data_packet(packet) - { :data => packet.read_string } - end - - # Parses the given FXP_ATTRS packet and returns a hash with one key, - # :attrs, which references an Attributes object. - def parse_attrs_packet(packet) - { :attrs => attribute_factory.from_buffer(packet) } - end - - # Parses the given FXP_NAME packet and returns a hash with one key, :names, - # which references an array of Name objects. - def parse_name_packet(packet) - names = [] - - packet.read_long.times do - filename = packet.read_string - longname = packet.read_string - attrs = attribute_factory.from_buffer(packet) - names << name_factory.new(filename, longname, attrs) - end - - { :names => names } - end - - # Sends a FXP_OPEN packet to the server and returns the packet identifier. - # The +flags+ parameter is either an integer (in which case it must be - # a combination of the IO constants) or a string (in which case it must - # be one of the mode strings that IO::open accepts). The +options+ - # parameter is a hash that is used to construct a new Attribute object, - # to pass as part of the FXP_OPEN request. - def open(path, flags, options) - flags = normalize_open_flags(flags) - - if flags & (IO::WRONLY | IO::RDWR) != 0 - sftp_flags = FV1::WRITE - sftp_flags |= FV1::READ if flags & IO::RDWR != 0 - sftp_flags |= FV1::APPEND if flags & IO::APPEND != 0 - else - sftp_flags = FV1::READ - end - - sftp_flags |= FV1::CREAT if flags & IO::CREAT != 0 - sftp_flags |= FV1::TRUNC if flags & IO::TRUNC != 0 - sftp_flags |= FV1::EXCL if flags & IO::EXCL != 0 - - attributes = attribute_factory.new(options) - - send_request(FXP_OPEN, :string, path, :long, sftp_flags, :raw, attributes.to_s) - end - - # Sends a FXP_CLOSE packet to the server for the given +handle+ (such as - # would be returned via a FXP_HANDLE packet). Returns the new packet id. - def close(handle) - send_request(FXP_CLOSE, :string, handle) - end - - # Sends a FXP_READ packet to the server, requesting that +length+ bytes - # be read from the file identified by +handle+, starting at +offset+ bytes - # within the file. The handle must be one that was returned via a - # FXP_HANDLE packet. Returns the new packet id. - def read(handle, offset, length) - send_request(FXP_READ, :string, handle, :int64, offset, :long, length) - end - - # Sends a FXP_WRITE packet to the server, requesting that +data+ (a string), - # be written to the file identified by +handle+, starting at +offset+ bytes - # from the beginning of the file. The handle must be one that was returned - # via a FXP_HANDLE packet. Returns the new packet id. - def write(handle, offset, data) - send_request(FXP_WRITE, :string, handle, :int64, offset, :string, data) - end - - # Sends a FXP_LSTAT packet to the server, requesting a FXP_ATTR response - # for the file at the given remote +path+ (a string). The +flags+ parameter - # is ignored in this version of the protocol. #lstat will not follow - # symbolic links; see #stat for a version that will. - def lstat(path, flags=nil) - send_request(FXP_LSTAT, :string, path) - end - - # Sends a FXP_FSTAT packet to the server, requesting a FXP_ATTR response - # for the file represented by the given +handle+ (which must have been - # obtained from a FXP_HANDLE packet). The +flags+ parameter is ignored in - # this version of the protocol. - def fstat(handle, flags=nil) - send_request(FXP_FSTAT, :string, handle) - end - - # Sends a FXP_SETSTAT packet to the server, to update the attributes for - # the file at the given remote +path+ (a string). The +attrs+ parameter is - # a hash that defines the attributes to set. - def setstat(path, attrs) - send_request(FXP_SETSTAT, :string, path, :raw, attribute_factory.new(attrs).to_s) - end - - # Sends a FXP_FSETSTAT packet to the server, to update the attributes for - # the file represented by the given +handle+ (which must have been obtained - # from a FXP_HANDLE packet). The +attrs+ parameter is a hash that defines - # the attributes to set. - def fsetstat(handle, attrs) - send_request(FXP_FSETSTAT, :string, handle, :raw, attribute_factory.new(attrs).to_s) - end - - # Sends a FXP_OPENDIR packet to the server, to request a handle for - # manipulating the directory at the given remote +path+. - def opendir(path) - send_request(FXP_OPENDIR, :string, path) - end - - # Sends a FXP_READDIR packet to the server, to request a batch of - # directory name entries in the directory identified by +handle+ (which - # must have been obtained via a FXP_OPENDIR request). - def readdir(handle) - send_request(FXP_READDIR, :string, handle) - end - - # Sends a FXP_REMOTE packet to the server, to request that the given - # file be deleted from the remote server. - def remove(filename) - send_request(FXP_REMOVE, :string, filename) - end - - # Sends a FXP_MKDIR packet to the server, to request that a new directory - # at +path+ on the remote server be created, and with +attrs+ (a hash) - # describing the attributes of the new directory. - def mkdir(path, attrs) - send_request(FXP_MKDIR, :string, path, :raw, attribute_factory.new(attrs).to_s) - end - - # Sends a FXP_RMDIR packet to the server, to request that the directory - # at +path+ on the remote server be deleted. - def rmdir(path) - send_request(FXP_RMDIR, :string, path) - end - - # Sends a FXP_REALPATH packet to the server, to request that the given - # +path+ be canonicalized, taking into account path segments like "..". - def realpath(path) - send_request(FXP_REALPATH, :string, path) - end - - # Sends a FXP_STAT packet to the server, requesting a FXP_ATTR response - # for the file at the given remote +path+ (a string). The +flags+ parameter - # is ignored in this version of the protocol. #stat will follow - # symbolic links; see #lstat for a version that will not. - def stat(path, flags=nil) - send_request(FXP_STAT, :string, path) - end - - # Not implemented in version 1 of the SFTP protocol. Raises a - # NotImplementedError if called. - def rename(name, new_name, flags=nil) - not_implemented! :rename - end - - # Not implemented in version 1 of the SFTP protocol. Raises a - # NotImplementedError if called. - def readlink(path) - not_implemented! :readlink - end - - # Not implemented in version 1 of the SFTP protocol. Raises a - # NotImplementedError if called. - def symlink(path, target) - not_implemented! :symlink - end - - # Not implemented in version 1 of the SFTP protocol. Raises a - # NotImplementedError if called. - def link(*args) - not_implemented! :link - end - - # Not implemented in version 1 of the SFTP protocol. Raises a - # NotImplementedError if called. - def block(handle, offset, length, mask) - not_implemented! :block - end - - # Not implemented in version 1 of the SFTP protocol. Raises a - # NotImplementedError if called. - def unblock(handle, offset, length) - not_implemented! :unblock - end - - protected - - # A helper method for implementing wrappers for operations that are - # not implemented by the current SFTP protocol version. Simply raises - # NotImplementedError with a message based on the given operation name. - def not_implemented!(operation) - raise NotImplementedError, "the #{operation} operation is not available in the version of the SFTP protocol supported by your server" - end - - # Normalizes the given flags parameter, converting it into a combination - # of IO constants. - def normalize_open_flags(flags) - if String === flags - case flags.tr("b", "") - when "r" then IO::RDONLY - when "r+" then IO::RDWR - when "w" then IO::WRONLY | IO::TRUNC | IO::CREAT - when "w+" then IO::RDWR | IO::TRUNC | IO::CREAT - when "a" then IO::APPEND | IO::CREAT | IO::WRONLY - when "a+" then IO::APPEND | IO::CREAT | IO::RDWR - else raise ArgumentError, "unsupported flags: #{flags.inspect}" - end - else - flags.to_i - end - end - - # Returns the Attributes class used by this version of the protocol - # (Net::SFTP::Protocol::V01::Attributes, in this case) - def attribute_factory - V01::Attributes - end - - # Returns the Name class used by this version of the protocol - # (Net::SFTP::Protocol::V01::Name, in this case) - def name_factory - V01::Name - end - end - -end; end; end; end \ No newline at end of file diff --git a/vendor/gems/net-sftp-2.0.2/lib/net/sftp/protocol/01/name.rb b/vendor/gems/net-sftp-2.0.2/lib/net/sftp/protocol/01/name.rb deleted file mode 100644 index b3a866096..000000000 --- a/vendor/gems/net-sftp-2.0.2/lib/net/sftp/protocol/01/name.rb +++ /dev/null @@ -1,43 +0,0 @@ -module Net; module SFTP; module Protocol; module V01 - - # Represents a single named item on the remote server. This includes the - # name, attributes about the item, and the "longname", which is intended - # for use when displaying directory data, and has no specified format. - class Name - # The name of the item on the remote server. - attr_reader :name - - # The display-ready name of the item, possibly with other attributes. - attr_reader :longname - - # The Attributes object describing this item. - attr_reader :attributes - - # Create a new Name object with the given name, longname, and attributes. - def initialize(name, longname, attributes) - @name, @longname, @attributes = name, longname, attributes - end - - # Returns +true+ if the item appears to be a directory. It does this by - # examining the attributes. If there is insufficient information in the - # attributes, this will return nil, rather than a boolean. - def directory? - attributes.directory? - end - - # Returns +true+ if the item appears to be a symlink. It does this by - # examining the attributes. If there is insufficient information in the - # attributes, this will return nil, rather than a boolean. - def symlink? - attributes.symlink? - end - - # Returns +true+ if the item appears to be a regular file. It does this by - # examining the attributes. If there is insufficient information in the - # attributes, this will return nil, rather than a boolean. - def file? - attributes.file? - end - end - -end; end; end; end \ No newline at end of file diff --git a/vendor/gems/net-sftp-2.0.2/lib/net/sftp/protocol/02/base.rb b/vendor/gems/net-sftp-2.0.2/lib/net/sftp/protocol/02/base.rb deleted file mode 100644 index a45aac8d6..000000000 --- a/vendor/gems/net-sftp-2.0.2/lib/net/sftp/protocol/02/base.rb +++ /dev/null @@ -1,31 +0,0 @@ -require 'net/sftp/protocol/01/base' - -module Net; module SFTP; module Protocol; module V02 - - # Wraps the low-level SFTP calls for version 2 of the SFTP protocol. - # - # None of these protocol methods block--all of them return immediately, - # requiring the SSH event loop to be run while the server response is - # pending. - # - # You will almost certainly never need to use this driver directly. Please - # see Net::SFTP::Session for the recommended interface. - class Base < V01::Base - - # Returns the protocol version implemented by this driver. (2, in this - # case) - def version - 2 - end - - # Sends a FXP_RENAME packet to the server to request that the file or - # directory with the given +name+ (must be a full path) be changed to - # +new_name+ (which must also be a path). The +flags+ parameter is - # ignored in this version of the protocol. - def rename(name, new_name, flags=nil) - send_request(FXP_RENAME, :string, name, :string, new_name) - end - - end - -end; end; end; end diff --git a/vendor/gems/net-sftp-2.0.2/lib/net/sftp/protocol/03/base.rb b/vendor/gems/net-sftp-2.0.2/lib/net/sftp/protocol/03/base.rb deleted file mode 100644 index bb93cd76b..000000000 --- a/vendor/gems/net-sftp-2.0.2/lib/net/sftp/protocol/03/base.rb +++ /dev/null @@ -1,35 +0,0 @@ -require 'net/sftp/protocol/02/base' - -module Net; module SFTP; module Protocol; module V03 - - # Wraps the low-level SFTP calls for version 3 of the SFTP protocol. - # - # None of these protocol methods block--all of them return immediately, - # requiring the SSH event loop to be run while the server response is - # pending. - # - # You will almost certainly never need to use this driver directly. Please - # see Net::SFTP::Session for the recommended interface. - class Base < V02::Base - - # Returns the protocol version implemented by this driver. (3, in this - # case) - def version - 3 - end - - # Sends a FXP_READLINK packet to the server to request that the target of - # the given symlink on the remote host (+path+) be returned. - def readlink(path) - send_request(FXP_READLINK, :string, path) - end - - # Sends a FXP_SYMLINK packet to the server to request that a symlink at the - # given +path+ be created, pointing at +target+.. - def symlink(path, target) - send_request(FXP_SYMLINK, :string, path, :string, target) - end - - end - -end; end; end; end \ No newline at end of file diff --git a/vendor/gems/net-sftp-2.0.2/lib/net/sftp/protocol/04/attributes.rb b/vendor/gems/net-sftp-2.0.2/lib/net/sftp/protocol/04/attributes.rb deleted file mode 100644 index 3a943fd7a..000000000 --- a/vendor/gems/net-sftp-2.0.2/lib/net/sftp/protocol/04/attributes.rb +++ /dev/null @@ -1,152 +0,0 @@ -require 'net/sftp/protocol/01/attributes' - -module Net; module SFTP; module Protocol; module V04 - - # A class representing the attributes of a file or directory on the server. - # It may be used to specify new attributes, or to query existing attributes. - # This particular class is specific to versions 4 and 5 of the SFTP - # protocol. - # - # To specify new attributes, just pass a hash as the argument to the - # constructor. The following keys are supported: - # - # * :type:: the type of the item (integer, one of the T_ constants) - # * :size:: the size of the item (integer) - # * :uid:: the user-id that owns the file (integer) - # * :gid:: the group-id that owns the file (integer) - # * :owner:: the name of the user that owns the file (string) - # * :group:: the name of the group that owns the file (string) - # * :permissions:: the permissions on the file (integer, e.g. 0755) - # * :atime:: the access time of the file (integer, seconds since epoch) - # * :atime_nseconds:: the nanosecond component of atime (integer) - # * :createtime:: the time at which the file was created (integer, seconds since epoch) - # * :createtime_nseconds:: the nanosecond component of createtime (integer) - # * :mtime:: the modification time of the file (integer, seconds since epoch) - # * :mtime_nseconds:: the nanosecond component of mtime (integer) - # * :acl:: an array of ACL entries for the item - # * :extended:: a hash of name/value pairs identifying extended info - # - # Likewise, when the server sends an Attributes object, all of the - # above attributes are exposed as methods (though not all will be set with - # non-nil values from the server). - class Attributes < V01::Attributes - - F_ACCESSTIME = 0x00000008 - F_CREATETIME = 0x00000010 - F_MODIFYTIME = 0x00000020 - F_ACL = 0x00000040 - F_OWNERGROUP = 0x00000080 - F_SUBSECOND_TIMES = 0x00000100 - - # A simple struct for representing a single entry in an Access Control - # List. (See Net::SFTP::Constants::ACE) - ACL = Struct.new(:type, :flag, :mask, :who) - - class < names } - end - - # Sends a FXP_STAT packet to the server for the given +path+, and with the - # given +flags+. If +flags+ is nil, it defaults to F_SIZE | F_PERMISSIONS | - # F_ACCESSTIME | F_CREATETIME | F_MODIFYTIME | F_ACL | F_OWNERGROUP | - # F_SUBSECOND_TIMES | F_EXTENDED (see Net::SFTP::Protocol::V04::Attributes - # for those constants). - def stat(path, flags=nil) - send_request(FXP_STAT, :string, path, :long, flags || DEFAULT_FLAGS) - end - - # Sends a FXP_LSTAT packet to the server for the given +path+, and with the - # given +flags+. If +flags+ is nil, it defaults to F_SIZE | F_PERMISSIONS | - # F_ACCESSTIME | F_CREATETIME | F_MODIFYTIME | F_ACL | F_OWNERGROUP | - # F_SUBSECOND_TIMES | F_EXTENDED (see Net::SFTP::Protocol::V04::Attributes - # for those constants). - def lstat(path, flags=nil) - send_request(FXP_LSTAT, :string, path, :long, flags || DEFAULT_FLAGS) - end - - # Sends a FXP_FSTAT packet to the server for the given +path+, and with the - # given +flags+. If +flags+ is nil, it defaults to F_SIZE | F_PERMISSIONS | - # F_ACCESSTIME | F_CREATETIME | F_MODIFYTIME | F_ACL | F_OWNERGROUP | - # F_SUBSECOND_TIMES | F_EXTENDED (see Net::SFTP::Protocol::V04::Attributes - # for those constants). - def fstat(handle, flags=nil) - send_request(FXP_FSTAT, :string, handle, :long, flags || DEFAULT_FLAGS) - end - - protected - - # The default flags used if the +flags+ parameter is nil for any of the - # #stat, #lstat, or #fstat operations. - DEFAULT_FLAGS = Attributes::F_SIZE | - Attributes::F_PERMISSIONS | - Attributes::F_ACCESSTIME | - Attributes::F_CREATETIME | - Attributes::F_MODIFYTIME | - Attributes::F_ACL | - Attributes::F_OWNERGROUP | - Attributes::F_SUBSECOND_TIMES | - Attributes::F_EXTENDED - - # Returns the Attributes class used by this version of the protocol - # (Net::SFTP::Protocol::V04::Attributes, in this case) - def attribute_factory - V04::Attributes - end - - # Returns the Name class used by this version of the protocol - # (Net::SFTP::Protocol::V04::Name, in this case) - def name_factory - V04::Name - end - end - -end; end; end; end \ No newline at end of file diff --git a/vendor/gems/net-sftp-2.0.2/lib/net/sftp/protocol/04/name.rb b/vendor/gems/net-sftp-2.0.2/lib/net/sftp/protocol/04/name.rb deleted file mode 100644 index 3e6044d17..000000000 --- a/vendor/gems/net-sftp-2.0.2/lib/net/sftp/protocol/04/name.rb +++ /dev/null @@ -1,67 +0,0 @@ -module Net; module SFTP; module Protocol; module V04 - - # Represents a single named item on the remote server. This includes the - # name, and attributes about the item, and the "longname". - # - # For backwards compatibility with the format and interface of the Name - # structure from previous protocol versions, this also exposes a #longname - # method, which returns a string that can be used to display this item in - # a directory listing. - class Name - # The name of the item on the remote server. - attr_reader :name - - # Attributes instance describing this item. - attr_reader :attributes - - # Create a new Name object with the given name and attributes. - def initialize(name, attributes) - @name, @attributes = name, attributes - end - - # Returns +true+ if the item is a directory. - def directory? - attributes.directory? - end - - # Returns +true+ if the item is a symlink. - def symlink? - attributes.symlink? - end - - # Returns +true+ if the item is a regular file. - def file? - attributes.file? - end - - # Returns a string representing this file, in a format similar to that - # used by the unix "ls" utility. - def longname - @longname ||= begin - longname = if directory? - "d" - elsif symlink? - "l" - else - "-" - end - - longname << (attributes.permissions & 0400 != 0 ? "r" : "-") - longname << (attributes.permissions & 0200 != 0 ? "w" : "-") - longname << (attributes.permissions & 0100 != 0 ? "x" : "-") - longname << (attributes.permissions & 0040 != 0 ? "r" : "-") - longname << (attributes.permissions & 0020 != 0 ? "w" : "-") - longname << (attributes.permissions & 0010 != 0 ? "x" : "-") - longname << (attributes.permissions & 0004 != 0 ? "r" : "-") - longname << (attributes.permissions & 0002 != 0 ? "w" : "-") - longname << (attributes.permissions & 0001 != 0 ? "x" : "-") - - longname << (" %-8s %-8s %8d " % [attributes.owner, attributes.group, attributes.size]) - - longname << Time.at(attributes.mtime).strftime("%b %e %H:%M ") - longname << name - end - end - end - -end; end; end; end \ No newline at end of file diff --git a/vendor/gems/net-sftp-2.0.2/lib/net/sftp/protocol/05/base.rb b/vendor/gems/net-sftp-2.0.2/lib/net/sftp/protocol/05/base.rb deleted file mode 100644 index 3c40b8f7b..000000000 --- a/vendor/gems/net-sftp-2.0.2/lib/net/sftp/protocol/05/base.rb +++ /dev/null @@ -1,66 +0,0 @@ -require 'net/sftp/protocol/04/base' - -module Net; module SFTP; module Protocol; module V05 - - # Wraps the low-level SFTP calls for version 5 of the SFTP protocol. - # - # None of these protocol methods block--all of them return immediately, - # requiring the SSH event loop to be run while the server response is - # pending. - # - # You will almost certainly never need to use this driver directly. Please - # see Net::SFTP::Session for the recommended interface. - class Base < V04::Base - # Returns the protocol version implemented by this driver. (5, in this - # case) - def version - 5 - end - - # Sends a FXP_RENAME packet to the server to request that the file or - # directory with the given +name+ (must be a full path) be changed to - # +new_name+ (which must also be a path). The +flags+ parameter must be - # either +nil+ or 0 (the default), or some combination of the - # Net::SFTP::Constants::RenameFlags constants. - def rename(name, new_name, flags=nil) - send_request(FXP_RENAME, :string, name, :string, new_name, :long, flags || 0) - end - - # Sends a FXP_OPEN packet to the server and returns the packet identifier. - # The +flags+ parameter is either an integer (in which case it must be - # a combination of the IO constants) or a string (in which case it must - # be one of the mode strings that IO::open accepts). The +options+ - # parameter is a hash that is used to construct a new Attribute object, - # to pass as part of the FXP_OPEN request. - def open(path, flags, options) - flags = normalize_open_flags(flags) - - sftp_flags, desired_access = if flags & (IO::WRONLY | IO::RDWR) != 0 - open = if flags & (IO::CREAT | IO::EXCL) == (IO::CREAT | IO::EXCL) - FV5::CREATE_NEW - elsif flags & (IO::CREAT | IO::TRUNC) == (IO::CREAT | IO::TRUNC) - FV5::CREATE_TRUNCATE - elsif flags & IO::CREAT == IO::CREAT - FV5::OPEN_OR_CREATE - else - FV5::OPEN_EXISTING - end - access = ACE::Mask::WRITE_DATA | ACE::Mask::WRITE_ATTRIBUTES - access |= ACE::Mask::READ_DATA | ACE::Mask::READ_ATTRIBUTES if (flags & IO::RDWR) == IO::RDWR - if flags & IO::APPEND == IO::APPEND - open |= FV5::APPEND_DATA - access |= ACE::Mask::APPEND_DATA - end - [open, access] - else - [FV5::OPEN_EXISTING, ACE::Mask::READ_DATA | ACE::Mask::READ_ATTRIBUTES] - end - - attributes = attribute_factory.new(options) - - send_request(FXP_OPEN, :string, path, :long, desired_access, :long, sftp_flags, :raw, attributes.to_s) - end - - end - -end; end; end; end \ No newline at end of file diff --git a/vendor/gems/net-sftp-2.0.2/lib/net/sftp/protocol/06/attributes.rb b/vendor/gems/net-sftp-2.0.2/lib/net/sftp/protocol/06/attributes.rb deleted file mode 100644 index e23322286..000000000 --- a/vendor/gems/net-sftp-2.0.2/lib/net/sftp/protocol/06/attributes.rb +++ /dev/null @@ -1,107 +0,0 @@ -require 'net/sftp/protocol/04/attributes' - -module Net; module SFTP; module Protocol; module V06 - - # A class representing the attributes of a file or directory on the server. - # It may be used to specify new attributes, or to query existing attributes. - # This particular class is specific to versions 6 and higher of the SFTP - # protocol. - # - # To specify new attributes, just pass a hash as the argument to the - # constructor. The following keys are supported: - # - # * :type:: the type of the item (integer, one of the T_ constants) - # * :size:: the size of the item (integer) - # * :allocation_size:: the actual number of bytes that the item uses on disk (integer) - # * :uid:: the user-id that owns the file (integer) - # * :gid:: the group-id that owns the file (integer) - # * :owner:: the name of the user that owns the file (string) - # * :group:: the name of the group that owns the file (string) - # * :permissions:: the permissions on the file (integer, e.g. 0755) - # * :atime:: the access time of the file (integer, seconds since epoch) - # * :atime_nseconds:: the nanosecond component of atime (integer) - # * :createtime:: the time at which the file was created (integer, seconds since epoch) - # * :createtime_nseconds:: the nanosecond component of createtime (integer) - # * :mtime:: the modification time of the file (integer, seconds since epoch) - # * :mtime_nseconds:: the nanosecond component of mtime (integer) - # * :ctime:: the time that the file's attributes were last changed (integer) - # * :ctime_nseconds:: the nanosecond component of ctime (integer) - # * :acl:: an array of ACL entries for the item - # * :attrib_bits:: other attributes of the file or directory (as a bit field) (integer) - # * :attrib_bits_valid:: a mask describing which bits in attrib_bits are valid (integer) - # * :text_hint:: whether the file may or may not contain textual data (integer) - # * :mime_type:: the mime type of the file (string) - # * :link_count:: the hard link count of the file (integer) - # * :untranslated_name:: the value of the filename before filename translation was attempted (string) - # * :extended:: a hash of name/value pairs identifying extended info - # - # Likewise, when the server sends an Attributes object, all of the - # above attributes are exposed as methods (though not all will be set with - # non-nil values from the server). - class Attributes < V04::Attributes - F_BITS = 0x00000200 - F_ALLOCATION_SIZE = 0x00000400 - F_TEXT_HINT = 0x00000800 - F_MIME_TYPE = 0x00001000 - F_LINK_COUNT = 0x00002000 - F_UNTRANSLATED_NAME = 0x00004000 - F_CTIME = 0x00008000 - - # The array of elements that describe this structure, in order. Used when - # parsing and serializing attribute objects. - def self.elements #:nodoc: - @elements ||= [ - [:type, :byte, 0], - [:size, :int64, F_SIZE], - [:allocation_size, :int64, F_ALLOCATION_SIZE], - [:owner, :string, F_OWNERGROUP], - [:group, :string, F_OWNERGROUP], - [:permissions, :long, F_PERMISSIONS], - [:atime, :int64, F_ACCESSTIME], - [:atime_nseconds, :long, F_ACCESSTIME | F_SUBSECOND_TIMES], - [:createtime, :int64, F_CREATETIME], - [:createtime_nseconds, :long, F_CREATETIME | F_SUBSECOND_TIMES], - [:mtime, :int64, F_MODIFYTIME], - [:mtime_nseconds, :long, F_MODIFYTIME | F_SUBSECOND_TIMES], - [:ctime, :int64, F_CTIME], - [:ctime_nseconds, :long, F_CTIME | F_SUBSECOND_TIMES], - [:acl, :special, F_ACL], - [:attrib_bits, :long, F_BITS], - [:attrib_bits_valid, :long, F_BITS], - [:text_hint, :byte, F_TEXT_HINT], - [:mime_type, :string, F_MIME_TYPE], - [:link_count, :long, F_LINK_COUNT], - [:untranslated_name, :string, F_UNTRANSLATED_NAME], - [:extended, :special, F_EXTENDED] - ] - end - - # The size on-disk of the file - attr_accessor :allocation_size - - # The time at which the file's attributes were last changed - attr_accessor :ctime - - # The nanosecond component of #ctime - attr_accessor :ctime_nseconds - - # Other attributes of this file or directory (as a bit field) - attr_accessor :attrib_bits - - # A bit mask describing which bits in #attrib_bits are valid - attr_accessor :attrib_bits_valid - - # Describes whether the file may or may not contain textual data - attr_accessor :text_hint - - # The mime-type of the file - attr_accessor :mime_type - - # The hard link count for the file - attr_accessor :link_count - - # The value of the file name before filename translation was attempted - attr_accessor :untranslated_name - end - -end; end; end; end \ No newline at end of file diff --git a/vendor/gems/net-sftp-2.0.2/lib/net/sftp/protocol/06/base.rb b/vendor/gems/net-sftp-2.0.2/lib/net/sftp/protocol/06/base.rb deleted file mode 100644 index 54ad86078..000000000 --- a/vendor/gems/net-sftp-2.0.2/lib/net/sftp/protocol/06/base.rb +++ /dev/null @@ -1,63 +0,0 @@ -require 'net/sftp/protocol/05/base' -require 'net/sftp/protocol/06/attributes' - -module Net; module SFTP; module Protocol; module V06 - - # Wraps the low-level SFTP calls for version 6 of the SFTP protocol. - # - # None of these protocol methods block--all of them return immediately, - # requiring the SSH event loop to be run while the server response is - # pending. - # - # You will almost certainly never need to use this driver directly. Please - # see Net::SFTP::Session for the recommended interface. - class Base < V05::Base - - # Returns the protocol version implemented by this driver. (6, in this - # case) - def version - 6 - end - - # Sends a FXP_LINK packet to the server to request that a link be created - # at +new_link_path+, pointing to +existing_path+. If +symlink+ is true, a - # symbolic link will be created; otherwise a hard link will be created. - def link(new_link_path, existing_path, symlink) - send_request(FXP_LINK, :string, new_link_path, :string, existing_path, :bool, symlink) - end - - # Provided for backwards compatibility; v6 of the SFTP protocol removes the - # older FXP_SYMLINK packet type, so this method simply calls the #link - # method. - def symlink(path, target) - link(path, target, true) - end - - # Sends a FXP_BLOCK packet to the server to request that a byte-range lock - # be obtained on the given +handle+, for the given byte +offset+ and - # +length+. The +mask+ parameter is a bitfield indicating what kind of - # lock to acquire, and must be a combination of one or more of the - # Net::SFTP::Constants::LockTypes constants. - def block(handle, offset, length, mask) - send_request(FXP_BLOCK, :string, handle, :int64, offset, :int64, length, :long, mask) - end - - # Sends a FXP_UNBLOCK packet to the server to request that a previously - # acquired byte-range lock be released on the given +handle+, for the - # given byte +offset+ and +length+. The +handle+, +offset+, and +length+ - # must all exactly match the parameters that were given when the lock was - # originally acquired (see #block). - def unblock(handle, offset, length) - send_request(FXP_UNBLOCK, :string, handle, :int64, offset, :int64, length) - end - - protected - - # Returns the Attributes class used by this version of the protocol - # (Net::SFTP::Protocol::V06::Attributes, in this case) - def attribute_factory - V06::Attributes - end - end - -end; end; end; end \ No newline at end of file diff --git a/vendor/gems/net-sftp-2.0.2/lib/net/sftp/protocol/base.rb b/vendor/gems/net-sftp-2.0.2/lib/net/sftp/protocol/base.rb deleted file mode 100644 index 0a5f14972..000000000 --- a/vendor/gems/net-sftp-2.0.2/lib/net/sftp/protocol/base.rb +++ /dev/null @@ -1,50 +0,0 @@ -require 'net/ssh/loggable' -require 'net/sftp/constants' - -module Net; module SFTP; module Protocol - - # The abstract superclass of the specific implementations for each supported - # SFTP protocol version. It implements general packet parsing logic, and - # provides a way for subclasses to send requests. - class Base - include Net::SSH::Loggable - include Net::SFTP::Constants - include Net::SFTP::Constants::PacketTypes - - # The SFTP session object that acts as client to this protocol instance - attr_reader :session - - # Create a new instance of a protocol driver, servicing the given session. - def initialize(session) - @session = session - self.logger = session.logger - @request_id_counter = -1 - end - - # Attept to parse the given packet. If the packet is of an unsupported - # type, an exception will be raised. Returns the parsed data as a hash - # (the keys in the hash are packet-type specific). - def parse(packet) - case packet.type - when FXP_STATUS then parse_status_packet(packet) - when FXP_HANDLE then parse_handle_packet(packet) - when FXP_DATA then parse_data_packet(packet) - when FXP_NAME then parse_name_packet(packet) - when FXP_ATTRS then parse_attrs_packet(packet) - else raise NotImplementedError, "unknown packet type: #{packet.type}" - end - end - - private - - # Send a new packet of the given type, and with the given data arguments. - # A new request identifier will be allocated to this request, and will - # be returned. - def send_request(type, *args) - @request_id_counter += 1 - session.send_packet(type, :long, @request_id_counter, *args) - return @request_id_counter - end - end - -end; end; end \ No newline at end of file diff --git a/vendor/gems/net-sftp-2.0.2/lib/net/sftp/request.rb b/vendor/gems/net-sftp-2.0.2/lib/net/sftp/request.rb deleted file mode 100644 index aa7277b1d..000000000 --- a/vendor/gems/net-sftp-2.0.2/lib/net/sftp/request.rb +++ /dev/null @@ -1,91 +0,0 @@ -require 'net/sftp/constants' -require 'net/sftp/response' - -module Net; module SFTP - - # Encapsulates a single active SFTP request. This is instantiated - # automatically by the Net::SFTP::Session class when an operation is - # executed. - # - # request = sftp.open("/path/to/file") - # puts request.pending? #-> true - # request.wait - # puts request.pending? #-> false - # result = request.response - class Request - include Constants::PacketTypes - - # The Net::SFTP session object that is servicing this request - attr_reader :session - - # The SFTP packet identifier for this request - attr_reader :id - - # The type of this request (e.g., :open, :symlink, etc.) - attr_reader :type - - # The callback (if any) associated with this request. When the response - # is recieved for this request, the callback will be invoked. - attr_reader :callback - - # The hash of properties associated with this request. Properties allow - # programmers to associate arbitrary data with a request, making state - # machines richer. - attr_reader :properties - - # The response that was received for this request (see Net::SFTP::Response) - attr_reader :response - - # Instantiate a new Request object, serviced by the given +session+, and - # being of the given +type+. The +id+ is the packet identifier for this - # request. - def initialize(session, type, id, &callback) #:nodoc: - @session, @id, @type, @callback = session, id, type, callback - @response = nil - @properties = {} - end - - # Returns the value of property with the given +key+. If +key+ is not a - # symbol, it will be converted to a symbol before lookup. - def [](key) - properties[key.to_sym] - end - - # Sets the value of the property with name +key+ to +value+. If +key+ is - # not a symbol, it will be converted to a symbol before lookup. - def []=(key, value) - properties[key.to_sym] = value - end - - # Returns +true+ if the request is still waiting for a response from the - # server, and +false+ otherwise. The SSH event loop must be run in order - # for a request to be processed; see #wait. - def pending? - session.pending_requests.key?(id) - end - - # Waits (blocks) until the server responds to this packet. If prior - # SFTP packets were also pending, they will be processed as well (since - # SFTP packets are processed in the order in which they are received by - # the server). Returns the request object itself. - def wait - session.loop { pending? } - self - end - - public # but not "published". Internal use only - - # When the server responds to this request, the packet is passed to - # this method, which parses the packet and builds a Net::SFTP::Response - # object to encapsulate it. If a #callback has been provided for this - # request, the callback is invoked with the new response object. - def respond_to(packet) #:nodoc: - data = session.protocol.parse(packet) - data[:type] = packet.type - @response = Response.new(self, data) - - callback.call(@response) if callback - end - end - -end; end \ No newline at end of file diff --git a/vendor/gems/net-sftp-2.0.2/lib/net/sftp/response.rb b/vendor/gems/net-sftp-2.0.2/lib/net/sftp/response.rb deleted file mode 100644 index 7c90ad950..000000000 --- a/vendor/gems/net-sftp-2.0.2/lib/net/sftp/response.rb +++ /dev/null @@ -1,76 +0,0 @@ -require 'net/sftp/constants' - -module Net; module SFTP - - # Encapsulates a response from the remote server, to a specific client - # request. Response objects are passed as parameters to callbacks when you - # are performing asynchronous operations; when you call Net::SFTP::Request#wait, - # you can get the corresponding response object via Net::SFTP::Request#response. - # - # sftp.open("/path/to/file") do |response| - # p response.ok? - # p response[:handle] - # end - # - # sftp.loop - class Response - include Net::SFTP::Constants::StatusCodes - - # The request object that this object is in response to - attr_reader :request - - # A hash of request-specific data, such as a file handle or attribute information - attr_reader :data - - # The numeric code, one of the FX_* constants - attr_reader :code - - # The textual message for this response (possibly blank) - attr_reader :message - - # Create a new Response object for the given Net::SFTP::Request instance, - # and with the given data. If there is no :code key in the data, the - # code is assumed to be FX_OK. - def initialize(request, data={}) #:nodoc: - @request, @data = request, data - @code, @message = data[:code] || FX_OK, data[:message] - end - - # Retrieve the data item with the given +key+. The key is converted to a - # symbol before being used to lookup the value. - def [](key) - data[key.to_sym] - end - - # Returns a textual description of this response, including the status - # code and name. - def to_s - if message && !message.empty? && message.downcase != MAP[code] - "#{message} (#{MAP[code]}, #{code})" - else - "#{MAP[code]} (#{code})" - end - end - - alias :to_str :to_s - - # Returns +true+ if the status code is FX_OK; +false+ otherwise. - def ok? - code == FX_OK - end - - # Returns +true+ if the status code is FX_EOF; +false+ otherwise. - def eof? - code == FX_EOF - end - - #-- - MAP = constants.inject({}) do |memo, name| - next memo unless name =~ /^FX_(.*)/ - memo[const_get(name)] = $1.downcase.tr("_", " ") - memo - end - #++ - end - -end; end \ No newline at end of file diff --git a/vendor/gems/net-sftp-2.0.2/lib/net/sftp/session.rb b/vendor/gems/net-sftp-2.0.2/lib/net/sftp/session.rb deleted file mode 100644 index 6a1776eff..000000000 --- a/vendor/gems/net-sftp-2.0.2/lib/net/sftp/session.rb +++ /dev/null @@ -1,951 +0,0 @@ -require 'net/ssh' -require 'net/sftp/constants' -require 'net/sftp/errors' -require 'net/sftp/protocol' -require 'net/sftp/request' -require 'net/sftp/operations/dir' -require 'net/sftp/operations/upload' -require 'net/sftp/operations/download' -require 'net/sftp/operations/file_factory' - -module Net; module SFTP - - # The Session class encapsulates a single SFTP channel on a Net::SSH - # connection. Instances of this class are what most applications will - # interact with most, as it provides access to both low-level (mkdir, - # rename, remove, symlink, etc.) and high-level (upload, download, etc.) - # SFTP operations. - # - # Although Session makes it easy to do SFTP operations serially, you can - # also set up multiple operations to be done in parallel, too, without - # needing to resort to threading. You merely need to fire off the requests, - # and then run the event loop until all of the requests have completed: - # - # handle1 = sftp.open!("/path/to/file1") - # handle2 = sftp.open!("/path/to/file2") - # - # r1 = sftp.read(handle1, 0, 1024) - # r2 = sftp.read(handle2, 0, 1024) - # sftp.loop { [r1, r2].any? { |r| r.pending? } } - # - # puts "chunk #1: #{r1.response[:data]}" - # puts "chunk #2: #{r2.response[:data]}" - # - # By passing blocks to the operations, you can set up powerful state - # machines, to fire off subsequent operations. In fact, the Net::SFTP::Operations::Upload - # and Net::SFTP::Operations::Download classes set up such state machines, so that - # multiple uploads and/or downloads can be running simultaneously. - # - # The convention with the names of the operations is as follows: if the method - # name ends with an exclamation mark, like #read!, it will be synchronous - # (e.g., it will block until the server responds). Methods without an - # exclamation mark (e.g. #read) are asynchronous, and return before the - # server has responded. You will need to make sure the SSH event loop is - # run in order to process these requests. (See #loop.) - class Session - include Net::SSH::Loggable - include Net::SFTP::Constants::PacketTypes - - # The highest protocol version supported by the Net::SFTP library. - HIGHEST_PROTOCOL_VERSION_SUPPORTED = 6 - - # A reference to the Net::SSH session object that powers this SFTP session. - attr_reader :session - - # The Net::SSH::Connection::Channel object that the SFTP session is being - # processed by. - attr_reader :channel - - # The state of the SFTP connection. It will be :opening, :subsystem, :init, - # :open, or :closed. - attr_reader :state - - # The protocol instance being used by this SFTP session. Useful for - # querying the protocol version in effect. - attr_reader :protocol - - # The hash of pending requests. Any requests that have been sent and which - # the server has not yet responded to will be represented here. - attr_reader :pending_requests - - # Creates a new Net::SFTP instance atop the given Net::SSH connection. - # This will return immediately, before the SFTP connection has been properly - # initialized. Once the connection is ready, the given block will be called. - # If you want to block until the connection has been initialized, try this: - # - # sftp = Net::SFTP::Session.new(ssh) - # sftp.loop { sftp.opening? } - def initialize(session, &block) - @session = session - @input = Net::SSH::Buffer.new - self.logger = session.logger - @state = :closed - - connect(&block) - end - - public # high-level SFTP operations - - # Initiates an upload from +local+ to +remote+, asynchronously. This - # method will return a new Net::SFTP::Operations::Upload instance, and requires - # the event loop to be run in order for the upload to progress. See - # Net::SFTP::Operations::Upload for a full discussion of how this method can be - # used. - # - # uploader = sftp.upload("/local/path", "/remote/path") - # uploader.wait - def upload(local, remote, options={}, &block) - Operations::Upload.new(self, local, remote, options, &block) - end - - # Identical to #upload, but blocks until the upload is complete. - def upload!(local, remote, options={}, &block) - upload(local, remote, options, &block).wait - end - - # Initiates a download from +remote+ to +local+, asynchronously. This - # method will return a new Net::SFTP::Operations::Download instance, and requires - # that the event loop be run in order for the download to progress. See - # Net::SFTP::Operations::Download for a full discussion of hos this method can be - # used. - # - # download = sftp.download("/remote/path", "/local/path") - # download.wait - def download(remote, local, options={}, &block) - Operations::Download.new(self, local, remote, options, &block) - end - - # Identical to #download, but blocks until the download is complete. - # If +local+ is omitted, downloads the file to an in-memory buffer - # and returns the result as a string; otherwise, returns the - # Net::SFTP::Operations::Download instance. - def download!(remote, local=nil, options={}, &block) - destination = local || StringIO.new - result = download(remote, destination, options, &block).wait - local ? result : destination.string - end - - # Returns an Net::SFTP::Operations::FileFactory instance, which can be used to - # mimic synchronous, IO-like file operations on a remote file via - # SFTP. - # - # sftp.file.open("/path/to/file") do |file| - # while line = file.gets - # puts line - # end - # end - # - # See Net::SFTP::Operations::FileFactory and Net::SFTP::Operations::File for more details. - def file - @file ||= Operations::FileFactory.new(self) - end - - # Returns a Net::SFTP::Operations::Dir instance, which can be used to - # conveniently iterate over and search directories on the remote server. - # - # sftp.dir.glob("/base/path", "*/**/*.rb") do |entry| - # p entry.name - # end - # - # See Net::SFTP::Operations::Dir for a more detailed discussion of how - # to use this. - def dir - @dir ||= Operations::Dir.new(self) - end - - public # low-level SFTP operations - - # :call-seq: - # open(path, flags="r", options={}) -> request - # open(path, flags="r", options={}) { |response| ... } -> request - # - # Opens a file on the remote server. The +flags+ parameter determines - # how the flag is open, and accepts the same format as IO#open (e.g., - # either a string like "r" or "w", or a combination of the IO constants). - # The +options+ parameter is a hash of attributes to be associated - # with the file, and varies greatly depending on the SFTP protocol - # version in use, but some (like :permissions) are always available. - # - # Returns immediately with a Request object. If a block is given, it will - # be invoked when the server responds, with a Response object as the only - # parameter. The :handle property of the response is the handle of the - # opened file, and may be passed to other methods (like #close, #read, - # #write, and so forth). - # - # sftp.open("/path/to/file") do |response| - # raise "fail!" unless response.ok? - # sftp.close(response[:handle]) - # end - # sftp.loop - def open(path, flags="r", options={}, &callback) - request :open, path, flags, options, &callback - end - - # Identical to #open, but blocks until the server responds. It will raise - # a StatusException if the request was unsuccessful. Otherwise, it will - # return the handle of the newly opened file. - # - # handle = sftp.open!("/path/to/file") - def open!(path, flags="r", options={}, &callback) - wait_for(open(path, flags, options, &callback), :handle) - end - - # :call-seq: - # close(handle) -> request - # close(handle) { |response| ... } -> request - # - # Closes an open handle, whether obtained via #open, or #opendir. Returns - # immediately with a Request object. If a block is given, it will be - # invoked when the server responds. - # - # sftp.open("/path/to/file") do |response| - # raise "fail!" unless response.ok? - # sftp.close(response[:handle]) - # end - # sftp.loop - def close(handle, &callback) - request :close, handle, &callback - end - - # Identical to #close, but blocks until the server responds. It will - # raise a StatusException if the request was unsuccessful. Otherwise, - # it returns the Response object for this request. - # - # sftp.close!(handle) - def close!(handle, &callback) - wait_for(close(handle, &callback)) - end - - # :call-seq: - # read(handle, offset, length) -> request - # read(handle, offset, length) { |response| ... } -> request - # - # Requests that +length+ bytes, starting at +offset+ bytes from the - # beginning of the file, be read from the file identified by - # +handle+. (The +handle+ should be a value obtained via the #open - # method.) Returns immediately with a Request object. If a block is - # given, it will be invoked when the server responds. - # - # The :data property of the response will contain the requested data, - # assuming the call was successful. - # - # request = sftp.read(handle, 0, 1024) do |response| - # if response.eof? - # puts "end of file reached before reading any data" - # elsif !response.ok? - # puts "error (#{response})" - # else - # print(response[:data]) - # end - # end - # request.wait - # - # To read an entire file will usually require multiple calls to #read, - # unless you know in advance how large the file is. - def read(handle, offset, length, &callback) - request :read, handle, offset, length, &callback - end - - # Identical to #read, but blocks until the server responds. It will raise - # a StatusException if the request was unsuccessful. If the end of the file - # was reached, +nil+ will be returned. Otherwise, it returns the data that - # was read, as a String. - # - # data = sftp.read!(handle, 0, 1024) - def read!(handle, offset, length, &callback) - wait_for(read(handle, offset, length, &callback), :data) - end - - # :call-seq: - # write(handle, offset, data) -> request - # write(handle, offset, data) { |response| ... } -> request - # - # Requests that +data+ be written to the file identified by +handle+, - # starting at +offset+ bytes from the start of the file. The file must - # have been opened for writing via #open. Returns immediately with a - # Request object. If a block is given, it will be invoked when the - # server responds. - # - # request = sftp.write(handle, 0, "hello, world!\n") - # request.wait - def write(handle, offset, data, &callback) - request :write, handle, offset, data, &callback - end - - # Identical to #write, but blocks until the server responds. It will raise - # a StatusException if the request was unsuccessful, or the end of the file - # was reached. Otherwise, it returns the Response object for this request. - # - # sftp.write!(handle, 0, "hello, world!\n") - def write!(handle, offset, data, &callback) - wait_for(write(handle, offset, data, &callback)) - end - - # :call-seq: - # lstat(path, flags=nil) -> request - # lstat(path, flags=nil) { |response| ... } -> request - # - # This method is identical to the #stat method, with the exception that - # it will not follow symbolic links (thus allowing you to stat the - # link itself, rather than what it refers to). The +flags+ parameter - # is not used in SFTP protocol versions prior to 4, and will be ignored - # in those versions of the protocol that do not use it. For those that - # do, however, you may provide hints as to which file proprties you wish - # to query (e.g., if all you want is permissions, you could pass the - # Net::SFTP::Protocol::V04::Attributes::F_PERMISSIONS flag as the value - # for the +flags+ parameter). - # - # The method returns immediately with a Request object. If a block is given, - # it will be invoked when the server responds. The :attrs property of - # the response will contain an Attributes instance appropriate for the - # the protocol version (see Protocol::V01::Attributes, Protocol::V04::Attributes, - # and Protocol::V06::Attributes). - # - # request = sftp.lstat("/path/to/file") do |response| - # raise "fail!" unless response.ok? - # puts "permissions: %04o" % response[:attrs].permissions - # end - # request.wait - def lstat(path, flags=nil, &callback) - request :lstat, path, flags, &callback - end - - # Identical to the #lstat method, but blocks until the server responds. - # It will raise a StatusException if the request was unsuccessful. - # Otherwise, it will return the attribute object describing the path. - # - # puts sftp.lstat!("/path/to/file").permissions - def lstat!(path, flags=nil, &callback) - wait_for(lstat(path, flags, &callback), :attrs) - end - - # The fstat method is identical to the #stat and #lstat methods, with - # the exception that it takes a +handle+ as the first parameter, such - # as would be obtained via the #open or #opendir methods. (See the #lstat - # method for full documentation). - def fstat(handle, flags=nil, &callback) - request :fstat, handle, flags, &callback - end - - # Identical to the #fstat method, but blocks until the server responds. - # It will raise a StatusException if the request was unsuccessful. - # Otherwise, it will return the attribute object describing the path. - # - # puts sftp.fstat!(handle).permissions - def fstat!(handle, flags=nil, &callback) - wait_for(fstat(handle, flags, &callback), :attrs) - end - - # :call-seq: - # setstat(path, attrs) -> request - # setstat(path, attrs) { |response| ... } -> request - # - # This method may be used to set file metadata (such as permissions, or - # user/group information) on a remote file. The exact metadata that may - # be tweaked is dependent on the SFTP protocol version in use, but in - # general you may set at least the permissions, user, and group. (See - # Protocol::V01::Attributes, Protocol::V04::Attributes, and Protocol::V06::Attributes - # for the full lists of attributes that may be set for the different - # protocols.) - # - # The +attrs+ parameter is a hash, where the keys are symbols identifying - # the attributes to set. - # - # The method returns immediately with a Request object. If a block is given, - # it will be invoked when the server responds. - # - # request = sftp.setstat("/path/to/file", :permissions => 0644) - # request.wait - # puts "success: #{request.response.ok?}" - def setstat(path, attrs, &callback) - request :setstat, path, attrs, &callback - end - - # Identical to the #setstat method, but blocks until the server responds. - # It will raise a StatusException if the request was unsuccessful. - # Otherwise, it will return the Response object for the request. - # - # sftp.setstat!("/path/to/file", :permissions => 0644) - def setstat!(path, attrs, &callback) - wait_for(setstat(path, attrs, &callback)) - end - - # The fsetstat method is identical to the #setstat method, with the - # exception that it takes a +handle+ as the first parameter, such as - # would be obtained via the #open or #opendir methods. (See the - # #setstat method for full documentation.) - def fsetstat(handle, attrs, &callback) - request :fsetstat, handle, attrs, &callback - end - - # Identical to the #fsetstat method, but blocks until the server responds. - # It will raise a StatusException if the request was unsuccessful. - # Otherwise, it will return the Response object for the request. - # - # sftp.fsetstat!(handle, :permissions => 0644) - def fsetstat!(handle, attrs, &callback) - wait_for(fsetstat(handle, attrs, &callback)) - end - - # :call-seq: - # opendir(path) -> request - # opendir(path) { |response| ... } -> request - # - # Attempts to open a directory on the remote host for reading. Once the - # handle is obtained, directory entries may be retrieved using the - # #readdir method. The method returns immediately with a Request object. - # If a block is given, it will be invoked when the server responds. - # - # sftp.opendir("/path/to/directory") do |response| - # raise "fail!" unless response.ok? - # sftp.close(response[:handle]) - # end - # sftp.loop - def opendir(path, &callback) - request :opendir, path, &callback - end - - # Identical to #opendir, but blocks until the server responds. It will raise - # a StatusException if the request was unsuccessful. Otherwise, it will - # return a handle to the given path. - # - # handle = sftp.opendir!("/path/to/directory") - def opendir!(path, &callback) - wait_for(opendir(path, &callback), :handle) - end - - # :call-seq: - # readdir(handle) -> request - # raeddir(handle) { |response| ... } -> request - # - # Reads a set of entries from the given directory handle (which must - # have been obtained via #opendir). If the response is EOF, then there - # are no more entries in the directory. Otherwise, the entries will be - # in the :names property of the response: - # - # loop do - # request = sftp.readdir(handle).wait - # break if request.response.eof? - # raise "fail!" unless request.response.ok? - # request.response[:names].each do |entry| - # puts entry.name - # end - # end - # - # See also Protocol::V01::Name and Protocol::V04::Name for the specific - # properties of each individual entry (which vary based on the SFTP - # protocol version in use). - def readdir(handle, &callback) - request :readdir, handle, &callback - end - - # Identical to #readdir, but blocks until the server responds. It will raise - # a StatusException if the request was unsuccessful. Otherwise, it will - # return nil if there were no more names to read, or an array of name - # entries. - # - # while (entries = sftp.readdir!(handle)) do - # entries.each { |entry| puts(entry.name) } - # end - def readdir!(handle, &callback) - wait_for(readdir(handle, &callback), :names) - end - - # :call-seq: - # remove(filename) -> request - # remove(filename) { |response| ... } -> request - # - # Attempts to remove the given file from the remote file system. Returns - # immediately with a Request object. If a block is given, the block will - # be invoked when the server responds, and will be passed a Response - # object. - # - # sftp.remove("/path/to/file").wait - def remove(filename, &callback) - request :remove, filename, &callback - end - - # Identical to #remove, but blocks until the server responds. It will raise - # a StatusException if the request was unsuccessful. Otherwise, it will - # return the Response object for the request. - # - # sftp.remove!("/path/to/file") - def remove!(filename, &callback) - wait_for(remove(filename, &callback)) - end - - # :call-seq: - # mkdir(path, attrs={}) -> request - # mkdir(path, attrs={}) { |response| ... } -> request - # - # Creates the named directory on the remote server. If an attribute hash - # is given, it must map to the set of attributes supported by the version - # of the SFTP protocol in use. (See Protocol::V01::Attributes, - # Protocol::V04::Attributes, and Protocol::V06::Attributes.) - # - # sftp.mkdir("/path/to/directory", :permissions => 0550).wait - def mkdir(path, attrs={}, &callback) - request :mkdir, path, attrs, &callback - end - - # Identical to #mkdir, but blocks until the server responds. It will raise - # a StatusException if the request was unsuccessful. Otherwise, it will - # return the Response object for the request. - # - # sftp.mkdir!("/path/to/directory", :permissions => 0550) - def mkdir!(path, attrs={}, &callback) - wait_for(mkdir(path, attrs, &callback)) - end - - # :call-seq: - # rmdir(path) -> request - # rmdir(path) { |response| ... } -> request - # - # Removes the named directory on the remote server. The directory must - # be empty before it can be removed. - # - # sftp.rmdir("/path/to/directory").wait - def rmdir(path, &callback) - request :rmdir, path, &callback - end - - # Identical to #rmdir, but blocks until the server responds. It will raise - # a StatusException if the request was unsuccessful. Otherwise, it will - # return the Response object for the request. - # - # sftp.rmdir!("/path/to/directory") - def rmdir!(path, &callback) - wait_for(rmdir(path, &callback)) - end - - # :call-seq: - # realpath(path) -> request - # realpath(path) { |response| ... } -> request - # - # Tries to canonicalize the given path, turning any given path into an - # absolute path. This is primarily useful for converting a path with - # ".." or "." segments into an identical path without those segments. - # The answer will be in the response's :names attribute, as a - # one-element array. - # - # request = sftp.realpath("/path/../to/../directory").wait - # puts request[:names].first.name - def realpath(path, &callback) - request :realpath, path, &callback - end - - # Identical to #realpath, but blocks until the server responds. It will raise - # a StatusException if the request was unsuccessful. Otherwise, it will - # return a name object identifying the path. - # - # puts(sftp.realpath!("/path/../to/../directory")) - def realpath!(path, &callback) - wait_for(realpath(path, &callback), :names).first - end - - # Identical to the #lstat method, except that it follows symlinks - # (e.g., if you give it the path to a symlink, it will stat the target - # of the symlink rather than the symlink itself). See the #lstat method - # for full documentation. - def stat(path, flags=nil, &callback) - request :stat, path, flags, &callback - end - - # Identical to #stat, but blocks until the server responds. It will raise - # a StatusException if the request was unsuccessful. Otherwise, it will - # return an attribute object for the named path. - # - # attrs = sftp.stat!("/path/to/file") - def stat!(path, flags=nil, &callback) - wait_for(stat(path, flags, &callback), :attrs) - end - - # :call-seq: - # rename(name, new_name, flags=nil) -> request - # rename(name, new_name, flags=nil) { |response| ... } -> request - # - # Renames the given file. This operation is only available in SFTP - # protocol versions two and higher. The +flags+ parameter is ignored - # in versions prior to 5. In versions 5 and higher, the +flags+ - # parameter can be used to specify how the rename should be performed - # (atomically, etc.). - # - # The following flags are defined in protocol version 5: - # - # * 0x0001 - overwrite an existing file if the new name specifies a file - # that already exists. - # * 0x0002 - perform the rewrite atomically. - # * 0x0004 - allow the server to perform the rename as it prefers. - def rename(name, new_name, flags=nil, &callback) - request :rename, name, new_name, flags, &callback - end - - # Identical to #rename, but blocks until the server responds. It will raise - # a StatusException if the request was unsuccessful. Otherwise, it will - # return the Response object for the request. - # - # sftp.rename!("/path/to/old", "/path/to/new") - def rename!(name, new_name, flags=nil, &callback) - wait_for(rename(name, new_name, flags, &callback)) - end - - # :call-seq: - # readlink(path) -> request - # readlink(path) { |response| ... } -> request - # - # Queries the server for the target of the specified symbolic link. - # This operation is only available in protocol versions 3 and higher. - # The response to this request will include a names property, a one-element - # array naming the target of the symlink. - # - # request = sftp.readlink("/path/to/symlink").wait - # puts request.response[:names].first.name - def readlink(path, &callback) - request :readlink, path, &callback - end - - # Identical to #readlink, but blocks until the server responds. It will raise - # a StatusException if the request was unsuccessful. Otherwise, it will - # return the Name object for the path that the symlink targets. - # - # item = sftp.readlink!("/path/to/symlink") - def readlink!(path, &callback) - wait_for(readlink(path, &callback), :names).first - end - - # :call-seq: - # symlink(path, target) -> request - # symlink(path, target) { |response| ... } -> request - # - # Attempts to create a symlink to +path+ at +target+. This operation - # is only available in protocol versions 3, 4, and 5, but the Net::SFTP - # library mimics the symlink behavior in protocol version 6 using the - # #link method, so it is safe to use this method in protocol version 6. - # - # sftp.symlink("/path/to/file", "/path/to/symlink").wait - def symlink(path, target, &callback) - request :symlink, path, target, &callback - end - - # Identical to #symlink, but blocks until the server responds. It will raise - # a StatusException if the request was unsuccessful. Otherwise, it will - # return the Response object for the request. - # - # sftp.symlink!("/path/to/file", "/path/to/symlink") - def symlink!(path, target, &callback) - wait_for(symlink(path, target, &callback)) - end - - # :call-seq: - # link(new_link_path, existing_path, symlink=true) -> request - # link(new_link_path, existing_path, symlink=true) { |response| ... } -> request - # - # Attempts to create a link, either hard or symbolic. This operation is - # only available in SFTP protocol versions 6 and higher. If the +symlink+ - # paramter is true, a symbolic link will be created, otherwise a hard - # link will be created. The link will be named +new_link_path+, and will - # point to the path +existing_path+. - # - # sftp.link("/path/to/symlink", "/path/to/file", true).wait - # - # Note that #link is only available for SFTP protocol 6 and higher. You - # can use #symlink for protocols 3 and higher. - def link(new_link_path, existing_path, symlink=true, &callback) - request :link, new_link_path, existing_path, symlink, &callback - end - - # Identical to #link, but blocks until the server responds. It will raise - # a StatusException if the request was unsuccessful. Otherwise, it will - # return the Response object for the request. - # - # sftp.link!("/path/to/symlink", "/path/to/file", true) - def link!(new_link_path, existing_path, symlink=true, &callback) - wait_for(link(new_link_path, existing_path, symlink, &callback)) - end - - # :call-seq: - # block(handle, offset, length, mask) -> request - # block(handle, offset, length, mask) { |response| ... } -> request - # - # Creates a byte-range lock on the file specified by the given +handle+. - # This operation is only available in SFTP protocol versions 6 and - # higher. The lock may be either mandatory or advisory. - # - # The +handle+ parameter is a file handle, as obtained by the #open method. - # - # The +offset+ and +length+ parameters describe the location and size of - # the byte range. - # - # The +mask+ describes how the lock should be defined, and consists of - # some combination of the following bit masks: - # - # * 0x0040 - Read lock. The byte range may not be accessed for reading - # by via any other handle, though it may be written to. - # * 0x0080 - Write lock. The byte range may not be written to via any - # other handle, though it may be read from. - # * 0x0100 - Delete lock. No other handle may delete this file. - # * 0x0200 - Advisory lock. The server need not honor the lock instruction. - # - # Once created, the lock may be removed via the #unblock method. - def block(handle, offset, length, mask, &callback) - request :block, handle, offset, length, mask, &callback - end - - # Identical to #block, but blocks until the server responds. It will raise - # a StatusException if the request was unsuccessful. Otherwise, it will - # return the Response object for the request. - def block!(handle, offset, length, mask, &callback) - wait_for(block(handle, offset, length, mask, &callback)) - end - - # :call-seq: - # unblock(handle, offset, length) -> request - # unblock(handle, offset, length) { |response| ... } -> request - # - # Removes a previously created byte-range lock. This operation is only - # available in protocol versions 6 and higher. The +offset+ and +length+ - # parameters must exactly match those that were given to #block when the - # lock was acquired. - def unblock(handle, offset, length, &callback) - request :unblock, handle, offset, length, &callback - end - - # Identical to #unblock, but blocks until the server responds. It will raise - # a StatusException if the request was unsuccessful. Otherwise, it will - # return the Response object for the request. - def unblock!(handle, offset, length, &callback) - wait_for(unblock(handle, offset, length, &callback)) - end - - public # miscellaneous methods - - # Closes the SFTP connection, but not the SSH connection. Blocks until the - # session has terminated. Once the session has terminated, further operations - # on this object will result in errors. You can reopen the SFTP session - # via the #connect method. - def close_channel - return unless open? - channel.close - loop { !closed? } - end - - # Returns true if the connection has been initialized. - def open? - state == :open - end - - # Returns true if the connection has been closed. - def closed? - state == :closed - end - - # Returns true if the connection is in the process of being initialized - # (e.g., it is not closed, but is not yet fully open). - def opening? - !(open? || closed?) - end - - # Attempts to establish an SFTP connection over the SSH session given when - # this object was instantiated. If the object is already open, this will - # simply execute the given block (if any), passing the SFTP session itself - # as argument. If the session is currently being opened, this will add - # the given block to the list of callbacks, to be executed when the session - # is fully open. - # - # This method does not block, and will return immediately. If you pass a - # block to it, that block will be invoked when the connection has been - # fully established. Thus, you can do something like this: - # - # sftp.connect do - # puts "open!" - # end - # - # If you just want to block until the connection is ready, see the #connect! - # method. - def connect(&block) - case state - when :open - block.call(self) if block - when :closed - @state = :opening - @channel = session.open_channel(&method(:when_channel_confirmed)) - @packet_length = nil - @protocol = nil - @on_ready = Array(block) - else # opening - @on_ready << block if block - end - - self - end - - # Same as the #connect method, but blocks until the SFTP connection has - # been fully initialized. - def connect!(&block) - connect(&block) - loop { opening? } - self - end - - alias :loop_forever :loop - - # Runs the SSH event loop while the given block returns true. This lets - # you set up a state machine and then "fire it off". If you do not specify - # a block, the event loop will run for as long as there are any pending - # SFTP requests. This makes it easy to do thing like this: - # - # sftp.remove("/path/to/file") - # sftp.loop - def loop(&block) - block ||= Proc.new { pending_requests.any? } - session.loop(&block) - end - - # Formats, constructs, and sends an SFTP packet of the given type and with - # the given data. This does not block, but merely enqueues the packet for - # sending and returns. - # - # You should probably use the operation methods, rather than building and - # sending the packet directly. (See #open, #close, etc.) - def send_packet(type, *args) - data = Net::SSH::Buffer.from(*args) - msg = Net::SSH::Buffer.from(:long, data.length+1, :byte, type, :raw, data) - channel.send_data(msg.to_s) - end - - private - - #-- - # "ruby -w" hates private attributes, so we have to do this longhand - #++ - - # The input buffer used to accumulate packet data - def input; @input; end - - # Create and enqueue a new SFTP request of the given type, with the - # given arguments. Returns a new Request instance that encapsulates the - # request. - def request(type, *args, &callback) - request = Request.new(self, type, protocol.send(type, *args), &callback) - info { "sending #{type} packet (#{request.id})" } - pending_requests[request.id] = request - end - - # Waits for the given request to complete. If the response is - # EOF, nil is returned. If the response was not successful - # (e.g., !response.ok?), a StatusException will be raised. - # If +property+ is given, the corresponding property from the response - # will be returned; otherwise, the response object itself will be - # returned. - def wait_for(request, property=nil) - request.wait - if request.response.eof? - nil - elsif !request.response.ok? - raise StatusException.new(request.response) - elsif property - request.response[property.to_sym] - else - request.response - end - end - - # Called when the SSH channel is confirmed as "open" by the server. - # This is one of the states of the SFTP state machine, and is followed - # by the #when_subsystem_started state. - def when_channel_confirmed(channel) - debug { "requesting sftp subsystem" } - @state = :subsystem - channel.subsystem("sftp", &method(:when_subsystem_started)) - end - - # Called when the SSH server confirms that the SFTP subsystem was - # successfully started. This sets up the appropriate callbacks on the - # SSH channel and then starts the SFTP protocol version negotiation - # process. - def when_subsystem_started(channel, success) - raise Net::SFTP::Exception, "could not start SFTP subsystem" unless success - - debug { "sftp subsystem successfully started" } - @state = :init - - channel.on_data { |c,data| input.append(data) } - channel.on_extended_data { |c,t,data| debug { data } } - - channel.on_close(&method(:when_channel_closed)) - channel.on_process(&method(:when_channel_polled)) - - send_packet(FXP_INIT, :long, HIGHEST_PROTOCOL_VERSION_SUPPORTED) - end - - # Called when the SSH server closes the underlying channel. - def when_channel_closed(channel) - debug { "sftp channel closed" } - @channel = nil - @state = :closed - end - - # Called whenever Net::SSH polls the SFTP channel for pending activity. - # This basically checks the input buffer to see if enough input has been - # accumulated to handle. If there has, the packet is parsed and - # dispatched, according to its type (see #do_version and #dispatch_request). - def when_channel_polled(channel) - while input.length > 0 - if @packet_length.nil? - # make sure we've read enough data to tell how long the packet is - return unless input.length >= 4 - @packet_length = input.read_long - end - - return unless input.length >= @packet_length - packet = Net::SFTP::Packet.new(input.read(@packet_length)) - input.consume! - @packet_length = nil - - debug { "received sftp packet #{packet.type} len #{packet.length}" } - - if packet.type == FXP_VERSION - do_version(packet) - else - dispatch_request(packet) - end - end - end - - # Called to handle FXP_VERSION packets. This performs the SFTP protocol - # version negotiation, instantiating the appropriate Protocol instance - # and invoking the callback given to #connect, if any. - def do_version(packet) - debug { "negotiating sftp protocol version, mine is #{HIGHEST_PROTOCOL_VERSION_SUPPORTED}" } - - server_version = packet.read_long - debug { "server reports sftp version #{server_version}" } - - negotiated_version = [server_version, HIGHEST_PROTOCOL_VERSION_SUPPORTED].min - info { "negotiated version is #{negotiated_version}" } - - extensions = {} - until packet.eof? - name = packet.read_string - data = packet.read_string - extensions[name] = data - end - - @protocol = Protocol.load(self, negotiated_version) - @pending_requests = {} - - @state = :open - @on_ready.each { |callback| callback.call(self) } - @on_ready = nil - end - - # Parses the packet, finds the associated Request instance, and tells - # the Request instance to respond to the packet (see Request#respond_to). - def dispatch_request(packet) - id = packet.read_long - request = pending_requests.delete(id) or raise Net::SFTP::Exception, "no such request `#{id}'" - request.respond_to(packet) - end - end - -end; end \ No newline at end of file diff --git a/vendor/gems/net-sftp-2.0.2/lib/net/sftp/version.rb b/vendor/gems/net-sftp-2.0.2/lib/net/sftp/version.rb deleted file mode 100644 index 13d17ab9e..000000000 --- a/vendor/gems/net-sftp-2.0.2/lib/net/sftp/version.rb +++ /dev/null @@ -1,18 +0,0 @@ -require 'net/ssh/version' - -module Net; module SFTP - - # Describes the current version of the Net::SFTP library. - class Version < Net::SSH::Version - MAJOR = 2 - MINOR = 0 - TINY = 2 - - # The current version, as a Version instance - CURRENT = new(MAJOR, MINOR, TINY) - - # The current version, as a String instance - STRING = CURRENT.to_s - end - -end; end diff --git a/vendor/gems/net-sftp-2.0.2/net-sftp.gemspec b/vendor/gems/net-sftp-2.0.2/net-sftp.gemspec deleted file mode 100644 index 537bf85a9..000000000 --- a/vendor/gems/net-sftp-2.0.2/net-sftp.gemspec +++ /dev/null @@ -1,36 +0,0 @@ -Gem::Specification.new do |s| - s.name = %q{net-sftp} - s.version = "2.0.2" - - s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version= - s.authors = ["Jamis Buck"] - s.date = %q{2009-02-01} - s.description = %q{A pure Ruby implementation of the SFTP client protocol} - s.email = %q{jamis@jamisbuck.org} - s.extra_rdoc_files = ["CHANGELOG.rdoc", "lib/net/sftp/constants.rb", "lib/net/sftp/errors.rb", "lib/net/sftp/operations/dir.rb", "lib/net/sftp/operations/download.rb", "lib/net/sftp/operations/file.rb", "lib/net/sftp/operations/file_factory.rb", "lib/net/sftp/operations/upload.rb", "lib/net/sftp/packet.rb", "lib/net/sftp/protocol/01/attributes.rb", "lib/net/sftp/protocol/01/base.rb", "lib/net/sftp/protocol/01/name.rb", "lib/net/sftp/protocol/02/base.rb", "lib/net/sftp/protocol/03/base.rb", "lib/net/sftp/protocol/04/attributes.rb", "lib/net/sftp/protocol/04/base.rb", "lib/net/sftp/protocol/04/name.rb", "lib/net/sftp/protocol/05/base.rb", "lib/net/sftp/protocol/06/attributes.rb", "lib/net/sftp/protocol/06/base.rb", "lib/net/sftp/protocol/base.rb", "lib/net/sftp/protocol.rb", "lib/net/sftp/request.rb", "lib/net/sftp/response.rb", "lib/net/sftp/session.rb", "lib/net/sftp/version.rb", "lib/net/sftp.rb", "README.rdoc"] - s.files = ["CHANGELOG.rdoc", "lib/net/sftp/constants.rb", "lib/net/sftp/errors.rb", "lib/net/sftp/operations/dir.rb", "lib/net/sftp/operations/download.rb", "lib/net/sftp/operations/file.rb", "lib/net/sftp/operations/file_factory.rb", "lib/net/sftp/operations/upload.rb", "lib/net/sftp/packet.rb", "lib/net/sftp/protocol/01/attributes.rb", "lib/net/sftp/protocol/01/base.rb", "lib/net/sftp/protocol/01/name.rb", "lib/net/sftp/protocol/02/base.rb", "lib/net/sftp/protocol/03/base.rb", "lib/net/sftp/protocol/04/attributes.rb", "lib/net/sftp/protocol/04/base.rb", "lib/net/sftp/protocol/04/name.rb", "lib/net/sftp/protocol/05/base.rb", "lib/net/sftp/protocol/06/attributes.rb", "lib/net/sftp/protocol/06/base.rb", "lib/net/sftp/protocol/base.rb", "lib/net/sftp/protocol.rb", "lib/net/sftp/request.rb", "lib/net/sftp/response.rb", "lib/net/sftp/session.rb", "lib/net/sftp/version.rb", "lib/net/sftp.rb", "Rakefile", "README.rdoc", "setup.rb", "test/common.rb", "test/protocol/01/test_attributes.rb", "test/protocol/01/test_base.rb", "test/protocol/01/test_name.rb", "test/protocol/02/test_base.rb", "test/protocol/03/test_base.rb", "test/protocol/04/test_attributes.rb", "test/protocol/04/test_base.rb", "test/protocol/04/test_name.rb", "test/protocol/05/test_base.rb", "test/protocol/06/test_attributes.rb", "test/protocol/06/test_base.rb", "test/protocol/test_base.rb", "test/test_all.rb", "test/test_dir.rb", "test/test_download.rb", "test/test_file.rb", "test/test_file_factory.rb", "test/test_packet.rb", "test/test_protocol.rb", "test/test_request.rb", "test/test_response.rb", "test/test_session.rb", "test/test_upload.rb", "Manifest", "net-sftp.gemspec"] - s.has_rdoc = true - s.homepage = %q{http://net-ssh.rubyforge.org/sftp} - s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "Net-sftp", "--main", "README.rdoc"] - s.require_paths = ["lib"] - s.rubyforge_project = %q{net-ssh} - s.rubygems_version = %q{1.2.0} - s.summary = %q{A pure Ruby implementation of the SFTP client protocol} - s.test_files = ["test/test_all.rb"] - - if s.respond_to? :specification_version then - current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION - s.specification_version = 2 - - if current_version >= 3 then - s.add_runtime_dependency(%q, [">= 2.0.9"]) - s.add_development_dependency(%q, [">= 0"]) - else - s.add_dependency(%q, [">= 2.0.9"]) - s.add_dependency(%q, [">= 0"]) - end - else - s.add_dependency(%q, [">= 2.0.9"]) - s.add_dependency(%q, [">= 0"]) - end -end diff --git a/vendor/gems/net-sftp-2.0.2/setup.rb b/vendor/gems/net-sftp-2.0.2/setup.rb deleted file mode 100644 index 1549b3f37..000000000 --- a/vendor/gems/net-sftp-2.0.2/setup.rb +++ /dev/null @@ -1,1331 +0,0 @@ -# -# setup.rb -# -# Copyright (c) 2000-2004 Minero Aoki -# -# This program is free software. -# You can distribute/modify this program under the terms of -# the GNU Lesser General Public License version 2.1. -# - -# -# For backward compatibility -# - -unless Enumerable.method_defined?(:map) - module Enumerable - alias map collect - end -end - -unless Enumerable.method_defined?(:detect) - module Enumerable - alias detect find - end -end - -unless Enumerable.method_defined?(:select) - module Enumerable - alias select find_all - end -end - -unless Enumerable.method_defined?(:reject) - module Enumerable - def reject - result = [] - each do |i| - result.push i unless yield(i) - end - result - end - end -end - -unless Enumerable.method_defined?(:inject) - module Enumerable - def inject(result) - each do |i| - result = yield(result, i) - end - result - end - end -end - -unless Enumerable.method_defined?(:any?) - module Enumerable - def any? - each do |i| - return true if yield(i) - end - false - end - end -end - -unless File.respond_to?(:read) - def File.read(fname) - open(fname) {|f| - return f.read - } - end -end - -# -# Application independent utilities -# - -def File.binread(fname) - open(fname, 'rb') {|f| - return f.read - } -end - -# for corrupted windows stat(2) -def File.dir?(path) - File.directory?((path[-1,1] == '/') ? path : path + '/') -end - -# -# Config -# - -if arg = ARGV.detect{|arg| /\A--rbconfig=/ =~ arg } - ARGV.delete(arg) - require arg.split(/=/, 2)[1] - $".push 'rbconfig.rb' -else - require 'rbconfig' -end - -def multipackage_install? - FileTest.directory?(File.dirname($0) + '/packages') -end - - -class ConfigTable - - c = ::Config::CONFIG - - rubypath = c['bindir'] + '/' + c['ruby_install_name'] - - major = c['MAJOR'].to_i - minor = c['MINOR'].to_i - teeny = c['TEENY'].to_i - version = "#{major}.#{minor}" - - # ruby ver. >= 1.4.4? - newpath_p = ((major >= 2) or - ((major == 1) and - ((minor >= 5) or - ((minor == 4) and (teeny >= 4))))) - - subprefix = lambda {|path| - path.sub(/\A#{Regexp.quote(c['prefix'])}/o, '$prefix') - } - - if c['rubylibdir'] - # V < 1.6.3 - stdruby = subprefix.call(c['rubylibdir']) - siteruby = subprefix.call(c['sitedir']) - versite = subprefix.call(c['sitelibdir']) - sodir = subprefix.call(c['sitearchdir']) - elsif newpath_p - # 1.4.4 <= V <= 1.6.3 - stdruby = "$prefix/lib/ruby/#{version}" - siteruby = subprefix.call(c['sitedir']) - versite = siteruby + '/' + version - sodir = "$site-ruby/#{c['arch']}" - else - # V < 1.4.4 - stdruby = "$prefix/lib/ruby/#{version}" - siteruby = "$prefix/lib/ruby/#{version}/site_ruby" - versite = siteruby - sodir = "$site-ruby/#{c['arch']}" - end - - if arg = c['configure_args'].split.detect {|arg| /--with-make-prog=/ =~ arg } - makeprog = arg.sub(/'/, '').split(/=/, 2)[1] - else - makeprog = 'make' - end - - common_descripters = [ - [ 'prefix', [ c['prefix'], - 'path', - 'path prefix of target environment' ] ], - [ 'std-ruby', [ stdruby, - 'path', - 'the directory for standard ruby libraries' ] ], - [ 'site-ruby-common', [ siteruby, - 'path', - 'the directory for version-independent non-standard ruby libraries' ] ], - [ 'site-ruby', [ versite, - 'path', - 'the directory for non-standard ruby libraries' ] ], - [ 'bin-dir', [ '$prefix/bin', - 'path', - 'the directory for commands' ] ], - [ 'rb-dir', [ '$site-ruby', - 'path', - 'the directory for ruby scripts' ] ], - [ 'so-dir', [ sodir, - 'path', - 'the directory for ruby extentions' ] ], - [ 'data-dir', [ '$prefix/share', - 'path', - 'the directory for shared data' ] ], - [ 'ruby-path', [ rubypath, - 'path', - 'path to set to #! line' ] ], - [ 'ruby-prog', [ rubypath, - 'name', - 'the ruby program using for installation' ] ], - [ 'make-prog', [ makeprog, - 'name', - 'the make program to compile ruby extentions' ] ], - [ 'without-ext', [ 'no', - 'yes/no', - 'does not compile/install ruby extentions' ] ] - ] - multipackage_descripters = [ - [ 'with', [ '', - 'name,name...', - 'package names that you want to install', - 'ALL' ] ], - [ 'without', [ '', - 'name,name...', - 'package names that you do not want to install', - 'NONE' ] ] - ] - if multipackage_install? - DESCRIPTER = common_descripters + multipackage_descripters - else - DESCRIPTER = common_descripters - end - - SAVE_FILE = 'config.save' - - def ConfigTable.each_name(&block) - keys().each(&block) - end - - def ConfigTable.keys - DESCRIPTER.map {|name, *dummy| name } - end - - def ConfigTable.each_definition(&block) - DESCRIPTER.each(&block) - end - - def ConfigTable.get_entry(name) - name, ent = DESCRIPTER.assoc(name) - ent - end - - def ConfigTable.get_entry!(name) - get_entry(name) or raise ArgumentError, "no such config: #{name}" - end - - def ConfigTable.add_entry(name, vals) - ConfigTable::DESCRIPTER.push [name,vals] - end - - def ConfigTable.remove_entry(name) - get_entry(name) or raise ArgumentError, "no such config: #{name}" - DESCRIPTER.delete_if {|n, arr| n == name } - end - - def ConfigTable.config_key?(name) - get_entry(name) ? true : false - end - - def ConfigTable.bool_config?(name) - ent = get_entry(name) or return false - ent[1] == 'yes/no' - end - - def ConfigTable.value_config?(name) - ent = get_entry(name) or return false - ent[1] != 'yes/no' - end - - def ConfigTable.path_config?(name) - ent = get_entry(name) or return false - ent[1] == 'path' - end - - - class << self - alias newobj new - end - - def ConfigTable.new - c = newobj() - c.initialize_from_table - c - end - - def ConfigTable.load - c = newobj() - c.initialize_from_file - c - end - - def initialize_from_table - @table = {} - DESCRIPTER.each do |k, (default, vname, desc, default2)| - @table[k] = default - end - end - - def initialize_from_file - raise InstallError, "#{File.basename $0} config first"\ - unless File.file?(SAVE_FILE) - @table = {} - File.foreach(SAVE_FILE) do |line| - k, v = line.split(/=/, 2) - @table[k] = v.strip - end - end - - def save - File.open(SAVE_FILE, 'w') {|f| - @table.each do |k, v| - f.printf "%s=%s\n", k, v if v - end - } - end - - def []=(k, v) - raise InstallError, "unknown config option #{k}"\ - unless ConfigTable.config_key?(k) - @table[k] = v - end - - def [](key) - return nil unless @table[key] - @table[key].gsub(%r<\$([^/]+)>) { self[$1] } - end - - def set_raw(key, val) - @table[key] = val - end - - def get_raw(key) - @table[key] - end - -end - - -module MetaConfigAPI - - def eval_file_ifexist(fname) - instance_eval File.read(fname), fname, 1 if File.file?(fname) - end - - def config_names - ConfigTable.keys - end - - def config?(name) - ConfigTable.config_key?(name) - end - - def bool_config?(name) - ConfigTable.bool_config?(name) - end - - def value_config?(name) - ConfigTable.value_config?(name) - end - - def path_config?(name) - ConfigTable.path_config?(name) - end - - def add_config(name, argname, default, desc) - ConfigTable.add_entry name,[default,argname,desc] - end - - def add_path_config(name, default, desc) - add_config name, 'path', default, desc - end - - def add_bool_config(name, default, desc) - add_config name, 'yes/no', default ? 'yes' : 'no', desc - end - - def set_config_default(name, default) - if bool_config?(name) - ConfigTable.get_entry!(name)[0] = (default ? 'yes' : 'no') - else - ConfigTable.get_entry!(name)[0] = default - end - end - - def remove_config(name) - ent = ConfigTable.get_entry(name) - ConfigTable.remove_entry name - ent - end - -end - -# -# File Operations -# - -module FileOperations - - def mkdir_p(dirname, prefix = nil) - dirname = prefix + dirname if prefix - $stderr.puts "mkdir -p #{dirname}" if verbose? - return if no_harm? - - # does not check '/'... it's too abnormal case - dirs = dirname.split(%r<(?=/)>) - if /\A[a-z]:\z/i =~ dirs[0] - disk = dirs.shift - dirs[0] = disk + dirs[0] - end - dirs.each_index do |idx| - path = dirs[0..idx].join('') - Dir.mkdir path unless File.dir?(path) - end - end - - def rm_f(fname) - $stderr.puts "rm -f #{fname}" if verbose? - return if no_harm? - - if File.exist?(fname) or File.symlink?(fname) - File.chmod 0777, fname - File.unlink fname - end - end - - def rm_rf(dn) - $stderr.puts "rm -rf #{dn}" if verbose? - return if no_harm? - - Dir.chdir dn - Dir.foreach('.') do |fn| - next if fn == '.' - next if fn == '..' - if File.dir?(fn) - verbose_off { - rm_rf fn - } - else - verbose_off { - rm_f fn - } - end - end - Dir.chdir '..' - Dir.rmdir dn - end - - def move_file(src, dest) - File.unlink dest if File.exist?(dest) - begin - File.rename src, dest - rescue - File.open(dest, 'wb') {|f| f.write File.binread(src) } - File.chmod File.stat(src).mode, dest - File.unlink src - end - end - - def install(from, dest, mode, prefix = nil) - $stderr.puts "install #{from} #{dest}" if verbose? - return if no_harm? - - realdest = prefix + dest if prefix - realdest = File.join(realdest, File.basename(from)) if File.dir?(realdest) - str = File.binread(from) - if diff?(str, realdest) - verbose_off { - rm_f realdest if File.exist?(realdest) - } - File.open(realdest, 'wb') {|f| - f.write str - } - File.chmod mode, realdest - - File.open("#{objdir_root()}/InstalledFiles", 'a') {|f| - if prefix - f.puts realdest.sub(prefix, '') - else - f.puts realdest - end - } - end - end - - def diff?(new_content, path) - return true unless File.exist?(path) - new_content != File.binread(path) - end - - def command(str) - $stderr.puts str if verbose? - system str or raise RuntimeError, "'system #{str}' failed" - end - - def ruby(str) - command config('ruby-prog') + ' ' + str - end - - def make(task = '') - command config('make-prog') + ' ' + task - end - - def extdir?(dir) - File.exist?(dir + '/MANIFEST') - end - - def all_files_in(dirname) - Dir.open(dirname) {|d| - return d.select {|ent| File.file?("#{dirname}/#{ent}") } - } - end - - REJECT_DIRS = %w( - CVS SCCS RCS CVS.adm - ) - - def all_dirs_in(dirname) - Dir.open(dirname) {|d| - return d.select {|n| File.dir?("#{dirname}/#{n}") } - %w(. ..) - REJECT_DIRS - } - end - -end - -# -# Main Installer -# - -class InstallError < StandardError; end - - -module HookUtils - - def run_hook(name) - try_run_hook "#{curr_srcdir()}/#{name}" or - try_run_hook "#{curr_srcdir()}/#{name}.rb" - end - - def try_run_hook(fname) - return false unless File.file?(fname) - begin - instance_eval File.read(fname), fname, 1 - rescue - raise InstallError, "hook #{fname} failed:\n" + $!.message - end - true - end - -end - - -module HookScriptAPI - - def get_config(key) - @config[key] - end - - alias config get_config - - def set_config(key, val) - @config[key] = val - end - - # - # srcdir/objdir (works only in the package directory) - # - - #abstract srcdir_root - #abstract objdir_root - #abstract relpath - - def curr_srcdir - "#{srcdir_root()}/#{relpath()}" - end - - def curr_objdir - "#{objdir_root()}/#{relpath()}" - end - - def srcfile(path) - "#{curr_srcdir()}/#{path}" - end - - def srcexist?(path) - File.exist?(srcfile(path)) - end - - def srcdirectory?(path) - File.dir?(srcfile(path)) - end - - def srcfile?(path) - File.file? srcfile(path) - end - - def srcentries(path = '.') - Dir.open("#{curr_srcdir()}/#{path}") {|d| - return d.to_a - %w(. ..) - } - end - - def srcfiles(path = '.') - srcentries(path).select {|fname| - File.file?(File.join(curr_srcdir(), path, fname)) - } - end - - def srcdirectories(path = '.') - srcentries(path).select {|fname| - File.dir?(File.join(curr_srcdir(), path, fname)) - } - end - -end - - -class ToplevelInstaller - - Version = '3.2.4' - Copyright = 'Copyright (c) 2000-2004 Minero Aoki' - - TASKS = [ - [ 'config', 'saves your configurations' ], - [ 'show', 'shows current configuration' ], - [ 'setup', 'compiles ruby extentions and others' ], - [ 'install', 'installs files' ], - [ 'clean', "does `make clean' for each extention" ], - [ 'distclean',"does `make distclean' for each extention" ] - ] - - def ToplevelInstaller.invoke - instance().invoke - end - - @singleton = nil - - def ToplevelInstaller.instance - @singleton ||= new(File.dirname($0)) - @singleton - end - - include MetaConfigAPI - - def initialize(ardir_root) - @config = nil - @options = { 'verbose' => true } - @ardir = File.expand_path(ardir_root) - end - - def inspect - "#<#{self.class} #{__id__()}>" - end - - def invoke - run_metaconfigs - task = parsearg_global() - @config = load_config(task) - __send__ "parsearg_#{task}" - init_installers - __send__ "exec_#{task}" - end - - def run_metaconfigs - eval_file_ifexist "#{@ardir}/metaconfig" - end - - def load_config(task) - case task - when 'config' - ConfigTable.new - when 'clean', 'distclean' - if File.exist?('config.save') - then ConfigTable.load - else ConfigTable.new - end - else - ConfigTable.load - end - end - - def init_installers - @installer = Installer.new(@config, @options, @ardir, File.expand_path('.')) - end - - # - # Hook Script API bases - # - - def srcdir_root - @ardir - end - - def objdir_root - '.' - end - - def relpath - '.' - end - - # - # Option Parsing - # - - def parsearg_global - valid_task = /\A(?:#{TASKS.map {|task,desc| task }.join '|'})\z/ - - while arg = ARGV.shift - case arg - when /\A\w+\z/ - raise InstallError, "invalid task: #{arg}" unless valid_task =~ arg - return arg - - when '-q', '--quiet' - @options['verbose'] = false - - when '--verbose' - @options['verbose'] = true - - when '-h', '--help' - print_usage $stdout - exit 0 - - when '-v', '--version' - puts "#{File.basename($0)} version #{Version}" - exit 0 - - when '--copyright' - puts Copyright - exit 0 - - else - raise InstallError, "unknown global option '#{arg}'" - end - end - - raise InstallError, <" - out.puts " ruby #{File.basename $0} [] []" - - fmt = " %-20s %s\n" - out.puts - out.puts 'Global options:' - out.printf fmt, '-q,--quiet', 'suppress message outputs' - out.printf fmt, ' --verbose', 'output messages verbosely' - out.printf fmt, '-h,--help', 'print this message' - out.printf fmt, '-v,--version', 'print version and quit' - out.printf fmt, ' --copyright', 'print copyright and quit' - - out.puts - out.puts 'Tasks:' - TASKS.each do |name, desc| - out.printf " %-10s %s\n", name, desc - end - - out.puts - out.puts 'Options for config:' - ConfigTable.each_definition do |name, (default, arg, desc, default2)| - out.printf " %-20s %s [%s]\n", - '--'+ name + (ConfigTable.bool_config?(name) ? '' : '='+arg), - desc, - default2 || default - end - out.printf " %-20s %s [%s]\n", - '--rbconfig=path', 'your rbconfig.rb to load', "running ruby's" - - out.puts - out.puts 'Options for install:' - out.printf " %-20s %s [%s]\n", - '--no-harm', 'only display what to do if given', 'off' - out.printf " %-20s %s [%s]\n", - '--prefix', 'install path prefix', '$prefix' - - out.puts - end - - # - # Task Handlers - # - - def exec_config - @installer.exec_config - @config.save # must be final - end - - def exec_setup - @installer.exec_setup - end - - def exec_install - @installer.exec_install - end - - def exec_show - ConfigTable.each_name do |k| - v = @config.get_raw(k) - if not v or v.empty? - v = '(not specified)' - end - printf "%-10s %s\n", k, v - end - end - - def exec_clean - @installer.exec_clean - end - - def exec_distclean - @installer.exec_distclean - end - -end - - -class ToplevelInstallerMulti < ToplevelInstaller - - include HookUtils - include HookScriptAPI - include FileOperations - - def initialize(ardir) - super - @packages = all_dirs_in("#{@ardir}/packages") - raise 'no package exists' if @packages.empty? - end - - def run_metaconfigs - eval_file_ifexist "#{@ardir}/metaconfig" - @packages.each do |name| - eval_file_ifexist "#{@ardir}/packages/#{name}/metaconfig" - end - end - - def init_installers - @installers = {} - @packages.each do |pack| - @installers[pack] = Installer.new(@config, @options, - "#{@ardir}/packages/#{pack}", - "packages/#{pack}") - end - - with = extract_selection(config('with')) - without = extract_selection(config('without')) - @selected = @installers.keys.select {|name| - (with.empty? or with.include?(name)) \ - and not without.include?(name) - } - end - - def extract_selection(list) - a = list.split(/,/) - a.each do |name| - raise InstallError, "no such package: #{name}" \ - unless @installers.key?(name) - end - a - end - - def print_usage(f) - super - f.puts 'Inluded packages:' - f.puts ' ' + @packages.sort.join(' ') - f.puts - end - - # - # multi-package metaconfig API - # - - attr_reader :packages - - def declare_packages(list) - raise 'package list is empty' if list.empty? - list.each do |name| - raise "directory packages/#{name} does not exist"\ - unless File.dir?("#{@ardir}/packages/#{name}") - end - @packages = list - end - - # - # Task Handlers - # - - def exec_config - run_hook 'pre-config' - each_selected_installers {|inst| inst.exec_config } - run_hook 'post-config' - @config.save # must be final - end - - def exec_setup - run_hook 'pre-setup' - each_selected_installers {|inst| inst.exec_setup } - run_hook 'post-setup' - end - - def exec_install - run_hook 'pre-install' - each_selected_installers {|inst| inst.exec_install } - run_hook 'post-install' - end - - def exec_clean - rm_f 'config.save' - run_hook 'pre-clean' - each_selected_installers {|inst| inst.exec_clean } - run_hook 'post-clean' - end - - def exec_distclean - rm_f 'config.save' - run_hook 'pre-distclean' - each_selected_installers {|inst| inst.exec_distclean } - run_hook 'post-distclean' - end - - # - # lib - # - - def each_selected_installers - Dir.mkdir 'packages' unless File.dir?('packages') - @selected.each do |pack| - $stderr.puts "Processing the package `#{pack}' ..." if @options['verbose'] - Dir.mkdir "packages/#{pack}" unless File.dir?("packages/#{pack}") - Dir.chdir "packages/#{pack}" - yield @installers[pack] - Dir.chdir '../..' - end - end - - def verbose? - @options['verbose'] - end - - def no_harm? - @options['no-harm'] - end - -end - - -class Installer - - FILETYPES = %w( bin lib ext data ) - - include HookScriptAPI - include HookUtils - include FileOperations - - def initialize(config, opt, srcroot, objroot) - @config = config - @options = opt - @srcdir = File.expand_path(srcroot) - @objdir = File.expand_path(objroot) - @currdir = '.' - end - - def inspect - "#<#{self.class} #{File.basename(@srcdir)}>" - end - - # - # Hook Script API bases - # - - def srcdir_root - @srcdir - end - - def objdir_root - @objdir - end - - def relpath - @currdir - end - - # - # configs/options - # - - def no_harm? - @options['no-harm'] - end - - def verbose? - @options['verbose'] - end - - def verbose_off - begin - save, @options['verbose'] = @options['verbose'], false - yield - ensure - @options['verbose'] = save - end - end - - # - # TASK config - # - - def exec_config - exec_task_traverse 'config' - end - - def config_dir_bin(rel) - end - - def config_dir_lib(rel) - end - - def config_dir_ext(rel) - extconf if extdir?(curr_srcdir()) - end - - def extconf - opt = @options['config-opt'].join(' ') - command "#{config('ruby-prog')} #{curr_srcdir()}/extconf.rb #{opt}" - end - - def config_dir_data(rel) - end - - # - # TASK setup - # - - def exec_setup - exec_task_traverse 'setup' - end - - def setup_dir_bin(rel) - all_files_in(curr_srcdir()).each do |fname| - adjust_shebang "#{curr_srcdir()}/#{fname}" - end - end - - # modify: #!/usr/bin/ruby - # modify: #! /usr/bin/ruby - # modify: #!ruby - # not modify: #!/usr/bin/env ruby - SHEBANG_RE = /\A\#!\s*\S*ruby\S*/ - - def adjust_shebang(path) - return if no_harm? - - tmpfile = File.basename(path) + '.tmp' - begin - File.open(path, 'rb') {|r| - File.open(tmpfile, 'wb') {|w| - first = r.gets - return unless SHEBANG_RE =~ first - - $stderr.puts "adjusting shebang: #{File.basename path}" if verbose? - w.print first.sub(SHEBANG_RE, '#!' + config('ruby-path')) - w.write r.read - } - } - move_file tmpfile, File.basename(path) - ensure - File.unlink tmpfile if File.exist?(tmpfile) - end - end - - def setup_dir_lib(rel) - end - - def setup_dir_ext(rel) - make if extdir?(curr_srcdir()) - end - - def setup_dir_data(rel) - end - - # - # TASK install - # - - def exec_install - exec_task_traverse 'install' - end - - def install_dir_bin(rel) - install_files collect_filenames_auto(), "#{config('bin-dir')}/#{rel}", 0755 - end - - def install_dir_lib(rel) - install_files ruby_scripts(), "#{config('rb-dir')}/#{rel}", 0644 - end - - def install_dir_ext(rel) - return unless extdir?(curr_srcdir()) - install_files ruby_extentions('.'), - "#{config('so-dir')}/#{File.dirname(rel)}", - 0555 - end - - def install_dir_data(rel) - install_files collect_filenames_auto(), "#{config('data-dir')}/#{rel}", 0644 - end - - def install_files(list, dest, mode) - mkdir_p dest, @options['install-prefix'] - list.each do |fname| - install fname, dest, mode, @options['install-prefix'] - end - end - - def ruby_scripts - collect_filenames_auto().select {|n| /\.rb\z/ =~ n || "module.yml" == n } - end - - # picked up many entries from cvs-1.11.1/src/ignore.c - reject_patterns = %w( - core RCSLOG tags TAGS .make.state - .nse_depinfo #* .#* cvslog.* ,* .del-* *.olb - *~ *.old *.bak *.BAK *.orig *.rej _$* *$ - - *.org *.in .* - ) - mapping = { - '.' => '\.', - '$' => '\$', - '#' => '\#', - '*' => '.*' - } - REJECT_PATTERNS = Regexp.new('\A(?:' + - reject_patterns.map {|pat| - pat.gsub(/[\.\$\#\*]/) {|ch| mapping[ch] } - }.join('|') + - ')\z') - - def collect_filenames_auto - mapdir((existfiles() - hookfiles()).reject {|fname| - REJECT_PATTERNS =~ fname - }) - end - - def existfiles - all_files_in(curr_srcdir()) | all_files_in('.') - end - - def hookfiles - %w( pre-%s post-%s pre-%s.rb post-%s.rb ).map {|fmt| - %w( config setup install clean ).map {|t| sprintf(fmt, t) } - }.flatten - end - - def mapdir(filelist) - filelist.map {|fname| - if File.exist?(fname) # objdir - fname - else # srcdir - File.join(curr_srcdir(), fname) - end - } - end - - def ruby_extentions(dir) - _ruby_extentions(dir) or - raise InstallError, "no ruby extention exists: 'ruby #{$0} setup' first" - end - - DLEXT = /\.#{ ::Config::CONFIG['DLEXT'] }\z/ - - def _ruby_extentions(dir) - Dir.open(dir) {|d| - return d.select {|fname| DLEXT =~ fname } - } - end - - # - # TASK clean - # - - def exec_clean - exec_task_traverse 'clean' - rm_f 'config.save' - rm_f 'InstalledFiles' - end - - def clean_dir_bin(rel) - end - - def clean_dir_lib(rel) - end - - def clean_dir_ext(rel) - return unless extdir?(curr_srcdir()) - make 'clean' if File.file?('Makefile') - end - - def clean_dir_data(rel) - end - - # - # TASK distclean - # - - def exec_distclean - exec_task_traverse 'distclean' - rm_f 'config.save' - rm_f 'InstalledFiles' - end - - def distclean_dir_bin(rel) - end - - def distclean_dir_lib(rel) - end - - def distclean_dir_ext(rel) - return unless extdir?(curr_srcdir()) - make 'distclean' if File.file?('Makefile') - end - - # - # lib - # - - def exec_task_traverse(task) - run_hook "pre-#{task}" - FILETYPES.each do |type| - if config('without-ext') == 'yes' and type == 'ext' - $stderr.puts 'skipping ext/* by user option' if verbose? - next - end - traverse task, type, "#{task}_dir_#{type}" - end - run_hook "post-#{task}" - end - - def traverse(task, rel, mid) - dive_into(rel) { - run_hook "pre-#{task}" - __send__ mid, rel.sub(%r[\A.*?(?:/|\z)], '') - all_dirs_in(curr_srcdir()).each do |d| - traverse task, "#{rel}/#{d}", mid - end - run_hook "post-#{task}" - } - end - - def dive_into(rel) - return unless File.dir?("#{@srcdir}/#{rel}") - - dir = File.basename(rel) - Dir.mkdir dir unless File.dir?(dir) - prevdir = Dir.pwd - Dir.chdir dir - $stderr.puts '---> ' + rel if verbose? - @currdir = rel - yield - Dir.chdir prevdir - $stderr.puts '<--- ' + rel if verbose? - @currdir = File.dirname(rel) - end - -end - - -if $0 == __FILE__ - begin - if multipackage_install? - ToplevelInstallerMulti.invoke - else - ToplevelInstaller.invoke - end - rescue - raise if $DEBUG - $stderr.puts $!.message - $stderr.puts "Try 'ruby #{$0} --help' for detailed usage." - exit 1 - end -end diff --git a/vendor/gems/net-sftp-2.0.2/test/common.rb b/vendor/gems/net-sftp-2.0.2/test/common.rb deleted file mode 100644 index 71850f317..000000000 --- a/vendor/gems/net-sftp-2.0.2/test/common.rb +++ /dev/null @@ -1,171 +0,0 @@ -require 'test/unit' -require 'mocha' - -begin - require 'net/ssh' - require 'net/ssh/version' - raise LoadError, "wrong version" unless Net::SSH::Version::STRING >= '1.99.0' -rescue LoadError - begin - gem 'net-ssh', ">= 2.0.0" - require 'net/ssh' - rescue LoadError => e - abort "could not load net/ssh v2 (#{e.inspect})" - end -end - -$LOAD_PATH.unshift "#{File.dirname(__FILE__)}/../lib" -require 'net/sftp' -require 'net/sftp/constants' -require 'net/ssh/test' - -class Net::SFTP::TestCase < Test::Unit::TestCase - include Net::SFTP::Constants::PacketTypes - include Net::SSH::Test - - def default_test - # do nothing, this is just hacky-hack to work around Test::Unit's - # insistence that all TestCase subclasses have at least one test - # method defined. - end - - protected - - def raw(*args) - Net::SSH::Buffer.from(*args).to_s - end - - def sftp(options={}) - @sftp ||= Net::SFTP::Session.new(connection(options)) - end - - def expect_sftp_session(opts={}) - story do |session| - channel = session.opens_channel - channel.sends_subsystem("sftp") - channel.sends_packet(FXP_INIT, :long, opts[:client_version] || Net::SFTP::Session::HIGHEST_PROTOCOL_VERSION_SUPPORTED) - channel.gets_packet(FXP_VERSION, :long, opts[:server_version] || Net::SFTP::Session::HIGHEST_PROTOCOL_VERSION_SUPPORTED) - yield channel if block_given? - end - end - - def assert_scripted_command - assert_scripted do - sftp.connect! - yield - sftp.loop - end - end - - def assert_progress_reported_open(expect={}) - assert_progress_reported(:open, expect) - end - - def assert_progress_reported_put(offset, data, expect={}) - assert_equal offset, current_event[3] if offset - assert_equal data, current_event[4] if data - assert_progress_reported(:put, expect) - end - - def assert_progress_reported_get(offset, data, expect={}) - assert_equal offset, current_event[3] if offset - if data.is_a?(Fixnum) - assert_equal data, current_event[4].length - elsif data - assert_equal data, current_event[4] - end - assert_progress_reported(:get, expect) - end - - def assert_progress_reported_close(expect={}) - assert_progress_reported(:close, expect) - end - - def assert_progress_reported_mkdir(dir) - assert_equal dir, current_event[2] - assert_progress_reported(:mkdir) - end - - def assert_progress_reported_finish - assert_progress_reported(:finish) - end - - def assert_progress_reported(event, expect={}) - assert_equal event, current_event[0] - expect.each do |key, value| - assert_equal value, current_event[2].send(key) - end - next_event! - end - - def assert_no_more_reported_events - assert @progress.empty?, "expected #{@progress.empty?} to be empty" - end - - def prepare_progress! - @progress = [] - end - - def record_progress(event) - @progress << event - end - - def current_event - @progress.first - end - - def next_event! - @progress.shift - end -end - -class Net::SSH::Test::Channel - def gets_packet(type, *args) - gets_data(sftp_packet(type, *args)) - end - - def sends_packet(type, *args) - sends_data(sftp_packet(type, *args)) - end - - private - - def sftp_packet(type, *args) - data = Net::SSH::Buffer.from(*args) - Net::SSH::Buffer.from(:long, data.length+1, :byte, type, :raw, data).to_s - end -end - -class ProgressHandler - def initialize(progress_ref) - @progress = progress_ref - end - - def on_open(*args) - @progress << [:open, *args] - end - - def on_put(*args) - @progress << [:put, *args] - end - - def on_close(*args) - @progress << [:close, *args] - end - - def on_finish(*args) - @progress << [:finish, *args] - end -end - -# "prime the pump", so to speak: predefine the modules we need so we can -# define the test classes in a more elegant short-hand. - -module Protocol - module V01; end - module V02; end - module V03; end - module V04; end - module V05; end - module V06; end -end diff --git a/vendor/gems/net-sftp-2.0.2/test/protocol/01/test_attributes.rb b/vendor/gems/net-sftp-2.0.2/test/protocol/01/test_attributes.rb deleted file mode 100644 index 2104034db..000000000 --- a/vendor/gems/net-sftp-2.0.2/test/protocol/01/test_attributes.rb +++ /dev/null @@ -1,97 +0,0 @@ -require 'common' - -module Etc; end - -class Protocol::V01::TestAttributes < Net::SFTP::TestCase - def test_from_buffer_should_correctly_parse_buffer_and_return_attribute_object - attributes = attributes_factory.from_buffer(full_buffer) - - assert_equal 1234567890, attributes.size - assert_equal 100, attributes.uid - assert_equal 200, attributes.gid - assert_equal 0755, attributes.permissions - assert_equal 1234567890, attributes.atime - assert_equal 2345678901, attributes.mtime - assert_equal "second", attributes.extended["first"] - end - - def test_from_buffer_should_correctly_parse_buffer_with_attribute_subset_and_return_attribute_object - buffer = Net::SSH::Buffer.from(:long, 0x4, :long, 0755) - - attributes = attributes_factory.from_buffer(buffer) - - assert_equal 0755, attributes.permissions - - assert_nil attributes.size - assert_nil attributes.uid - assert_nil attributes.gid - assert_nil attributes.atime - assert_nil attributes.mtime - assert_nil attributes.extended - end - - def test_attributes_to_s_should_build_binary_representation - attributes = attributes_factory.new( - :size => 1234567890, - :uid => 100, :gid => 200, - :permissions => 0755, - :atime => 1234567890, :mtime => 2345678901, - :extended => { "first" => "second" }) - - assert_equal full_buffer.to_s, attributes.to_s - end - - def test_attributes_to_s_should_build_binary_representation_when_subset_is_present - attributes = attributes_factory.new(:permissions => 0755) - assert_equal Net::SSH::Buffer.from(:long, 0x4, :long, 0755).to_s, attributes.to_s - end - - def test_attributes_to_s_with_owner_and_group_should_translate_to_uid_and_gid - attributes = attributes_factory.new(:owner => "jamis", :group => "sftp") - attributes.expects(:require).with("etc").times(2) - Etc.expects(:getpwnam).with("jamis").returns(mock('user', :uid => 100)) - Etc.expects(:getgrnam).with("sftp").returns(mock('group', :gid => 200)) - assert_equal Net::SSH::Buffer.from(:long, 0x2, :long, 100, :long, 200).to_s, attributes.to_s - end - - def test_owner_should_translate_from_uid - attributes = attributes_factory.new(:uid => 100) - attributes.expects(:require).with("etc") - Etc.expects(:getpwuid).with(100).returns(mock('user', :name => "jamis")) - assert_equal "jamis", attributes.owner - end - - def test_group_should_translate_from_gid - attributes = attributes_factory.new(:gid => 200) - attributes.expects(:require).with("etc") - Etc.expects(:getgrgid).with(200).returns(mock('group', :name => "sftp")) - assert_equal "sftp", attributes.group - end - - def test_type_should_infer_type_from_permissions - assert_equal af::T_SOCKET, af.new(:permissions => 0140755).type - assert_equal af::T_SYMLINK, af.new(:permissions => 0120755).type - assert_equal af::T_REGULAR, af.new(:permissions => 0100755).type - assert_equal af::T_BLOCK_DEVICE, af.new(:permissions => 060755).type - assert_equal af::T_DIRECTORY, af.new(:permissions => 040755).type - assert_equal af::T_CHAR_DEVICE, af.new(:permissions => 020755).type - assert_equal af::T_FIFO, af.new(:permissions => 010755).type - assert_equal af::T_UNKNOWN, af.new(:permissions => 0755).type - assert_equal af::T_UNKNOWN, af.new.type - end - - private - - def full_buffer - Net::SSH::Buffer.from(:long, 0x8000000f, - :int64, 1234567890, :long, 100, :long, 200, - :long, 0755, :long, 1234567890, :long, 2345678901, - :long, 1, :string, "first", :string, "second") - end - - def attributes_factory - Net::SFTP::Protocol::V01::Attributes - end - - alias af attributes_factory -end \ No newline at end of file diff --git a/vendor/gems/net-sftp-2.0.2/test/protocol/01/test_base.rb b/vendor/gems/net-sftp-2.0.2/test/protocol/01/test_base.rb deleted file mode 100644 index b9fb5bfb1..000000000 --- a/vendor/gems/net-sftp-2.0.2/test/protocol/01/test_base.rb +++ /dev/null @@ -1,210 +0,0 @@ -require 'common' - -# NOTE: these tests assume that the interface to Net::SFTP::Session#send_packet -# will remain constant. If that interface ever changes, these tests will need -# to be updated! - -class Protocol::V01::TestBase < Net::SFTP::TestCase - include Net::SFTP::Constants - include Net::SFTP::Constants::PacketTypes - include Net::SFTP::Constants::OpenFlags - - def setup - @session = stub('session', :logger => nil) - @base = driver.new(@session) - end - - def test_version - assert_equal 1, @base.version - end - - def test_parse_handle_packet_should_read_string_from_packet_and_return_handle_in_hash - packet = Net::SSH::Buffer.from(:string, "here is a string") - assert_equal({ :handle => "here is a string" }, @base.parse_handle_packet(packet)) - end - - def test_parse_status_packet_should_read_long_from_packet_and_return_code_in_hash - packet = Net::SSH::Buffer.from(:long, 15) - assert_equal({ :code => 15 }, @base.parse_status_packet(packet)) - end - - def test_parse_data_packet_should_read_string_from_packet_and_return_data_in_hash - packet = Net::SSH::Buffer.from(:string, "here is a string") - assert_equal({ :data => "here is a string" }, @base.parse_data_packet(packet)) - end - - def test_parse_attrs_packet_should_use_correct_attributes_class - Net::SFTP::Protocol::V01::Attributes.expects(:from_buffer).with(:packet).returns(:result) - assert_equal({ :attrs => :result }, @base.parse_attrs_packet(:packet)) - end - - def test_parse_name_packet_should_use_correct_name_class - packet = Net::SSH::Buffer.from(:long, 2, - :string, "name1", :string, "long1", :long, 0x4, :long, 0755, - :string, "name2", :string, "long2", :long, 0x4, :long, 0550) - names = @base.parse_name_packet(packet)[:names] - - assert_not_nil names - assert_equal 2, names.length - assert_instance_of Net::SFTP::Protocol::V01::Name, names.first - - assert_equal "name1", names.first.name - assert_equal "long1", names.first.longname - assert_equal 0755, names.first.attributes.permissions - - assert_equal "name2", names.last.name - assert_equal "long2", names.last.longname - assert_equal 0550, names.last.attributes.permissions - end - - def test_open_with_numeric_flag_should_accept_IO_constants - @session.expects(:send_packet).with(FXP_OPEN, :long, 0, - :string, "/path/to/file", - :long, FV1::READ | FV1::WRITE | FV1::CREAT | FV1::EXCL, - :raw, attributes.new.to_s) - - assert_equal 0, @base.open("/path/to/file", IO::RDWR | IO::CREAT | IO::EXCL, {}) - end - - { "r" => FV1::READ, - "rb" => FV1::READ, - "r+" => FV1::READ | FV1::WRITE, - "w" => FV1::WRITE | FV1::TRUNC | FV1::CREAT, - "w+" => FV1::WRITE | FV1::READ | FV1::TRUNC | FV1::CREAT, - "a" => FV1::APPEND | FV1::WRITE | FV1::CREAT, - "a+" => FV1::APPEND | FV1::WRITE | FV1::READ | FV1::CREAT - }.each do |flags, options| - safe_name = flags.sub(/\+/, "_plus") - define_method("test_open_with_#{safe_name}_should_translate_correctly") do - @session.expects(:send_packet).with(FXP_OPEN, :long, 0, - :string, "/path/to/file", :long, options, :raw, attributes.new.to_s) - - assert_equal 0, @base.open("/path/to/file", flags, {}) - end - end - - def test_open_with_attributes_converts_hash_to_attribute_packet - @session.expects(:send_packet).with(FXP_OPEN, :long, 0, - :string, "/path/to/file", :long, FV1::READ, :raw, attributes.new(:permissions => 0755).to_s) - @base.open("/path/to/file", "r", :permissions => 0755) - end - - def test_close_should_send_close_packet - @session.expects(:send_packet).with(FXP_CLOSE, :long, 0, :string, "handle") - assert_equal 0, @base.close("handle") - end - - def test_read_should_send_read_packet - @session.expects(:send_packet).with(FXP_READ, :long, 0, :string, "handle", :int64, 1234, :long, 5678) - assert_equal 0, @base.read("handle", 1234, 5678) - end - - def test_write_should_send_write_packet - @session.expects(:send_packet).with(FXP_WRITE, :long, 0, :string, "handle", :int64, 1234, :string, "data") - assert_equal 0, @base.write("handle", 1234, "data") - end - - def test_lstat_should_send_lstat_packet - @session.expects(:send_packet).with(FXP_LSTAT, :long, 0, :string, "/path/to/file") - assert_equal 0, @base.lstat("/path/to/file") - end - - def test_lstat_should_ignore_flags_parameter - @session.expects(:send_packet).with(FXP_LSTAT, :long, 0, :string, "/path/to/file") - assert_equal 0, @base.lstat("/path/to/file", 12345) - end - - def test_fstat_should_send_fstat_packet - @session.expects(:send_packet).with(FXP_FSTAT, :long, 0, :string, "handle") - assert_equal 0, @base.fstat("handle") - end - - def test_fstat_should_ignore_flags_parameter - @session.expects(:send_packet).with(FXP_FSTAT, :long, 0, :string, "handle") - assert_equal 0, @base.fstat("handle", 12345) - end - - def test_setstat_should_translate_hash_to_attributes_and_send_setstat_packet - @session.expects(:send_packet).with(FXP_SETSTAT, :long, 0, :string, "/path/to/file", :raw, attributes.new(:atime => 1, :mtime => 2, :permissions => 0755).to_s) - assert_equal 0, @base.setstat("/path/to/file", :atime => 1, :mtime => 2, :permissions => 0755) - end - - def test_fsetstat_should_translate_hash_to_attributes_and_send_fsetstat_packet - @session.expects(:send_packet).with(FXP_FSETSTAT, :long, 0, :string, "handle", :raw, attributes.new(:atime => 1, :mtime => 2, :permissions => 0755).to_s) - assert_equal 0, @base.fsetstat("handle", :atime => 1, :mtime => 2, :permissions => 0755) - end - - def test_opendir_should_send_opendir_packet - @session.expects(:send_packet).with(FXP_OPENDIR, :long, 0, :string, "/path/to/dir") - assert_equal 0, @base.opendir("/path/to/dir") - end - - def test_readdir_should_send_readdir_packet - @session.expects(:send_packet).with(FXP_READDIR, :long, 0, :string, "handle") - assert_equal 0, @base.readdir("handle") - end - - def test_remove_should_send_remove_packet - @session.expects(:send_packet).with(FXP_REMOVE, :long, 0, :string, "/path/to/file") - assert_equal 0, @base.remove("/path/to/file") - end - - def test_mkdir_should_translate_hash_to_attributes_and_send_mkdir_packet - @session.expects(:send_packet).with(FXP_MKDIR, :long, 0, :string, "/path/to/dir", :raw, attributes.new(:atime => 1, :mtime => 2, :permissions => 0755).to_s) - assert_equal 0, @base.mkdir("/path/to/dir", :atime => 1, :mtime => 2, :permissions => 0755) - end - - def test_rmdir_should_send_rmdir_packet - @session.expects(:send_packet).with(FXP_RMDIR, :long, 0, :string, "/path/to/dir") - assert_equal 0, @base.rmdir("/path/to/dir") - end - - def test_realpath_should_send_realpath_packet - @session.expects(:send_packet).with(FXP_REALPATH, :long, 0, :string, "/path/to/file") - assert_equal 0, @base.realpath("/path/to/file") - end - - def test_stat_should_send_stat_packet - @session.expects(:send_packet).with(FXP_STAT, :long, 0, :string, "/path/to/file") - assert_equal 0, @base.stat("/path/to/file") - end - - def test_stat_should_ignore_flags_parameter - @session.expects(:send_packet).with(FXP_STAT, :long, 0, :string, "/path/to/file") - assert_equal 0, @base.stat("/path/to/file", 12345) - end - - def test_rename_should_raise_not_implemented_error - assert_raises(NotImplementedError) { @base.rename("/path/to/old", "/path/to/new") } - end - - def test_readlink_should_raise_not_implemented_error - assert_raises(NotImplementedError) { @base.readlink("/path/to/link") } - end - - def test_symlink_should_raise_not_implemented_error - assert_raises(NotImplementedError) { @base.symlink("/path/to/link", "/path/to/file") } - end - - def test_link_should_raise_not_implemented_error - assert_raises(NotImplementedError) { @base.link("/path/to/link", "/path/to/file", true) } - end - - def test_block_should_raise_not_implemented_error - assert_raises(NotImplementedError) { @base.block("handle", 100, 200, 0) } - end - - def test_unblock_should_raise_not_implemented_error - assert_raises(NotImplementedError) { @base.unblock("handle", 100, 200) } - end - - private - - def driver - Net::SFTP::Protocol::V01::Base - end - - def attributes - Net::SFTP::Protocol::V01::Attributes - end -end \ No newline at end of file diff --git a/vendor/gems/net-sftp-2.0.2/test/protocol/01/test_name.rb b/vendor/gems/net-sftp-2.0.2/test/protocol/01/test_name.rb deleted file mode 100644 index 7eeb42873..000000000 --- a/vendor/gems/net-sftp-2.0.2/test/protocol/01/test_name.rb +++ /dev/null @@ -1,27 +0,0 @@ -require 'common' - -class Protocol::V01::TestName < Net::SFTP::TestCase - def setup - @directory = Net::SFTP::Protocol::V01::Name.new("test", "drwxr-x-r-x 89 test test 3026 Mar 10 17:45 test", Net::SFTP::Protocol::V01::Attributes.new(:permissions => 040755)) - @link = Net::SFTP::Protocol::V01::Name.new("test", "lrwxr-x-r-x 89 test test 3026 Mar 10 17:45 test", Net::SFTP::Protocol::V01::Attributes.new(:permissions => 0120755)) - @file = Net::SFTP::Protocol::V01::Name.new("test", "-rwxr-x-r-x 89 test test 3026 Mar 10 17:45 test", Net::SFTP::Protocol::V01::Attributes.new(:permissions => 0100755)) - end - - def test_directory? - assert @directory.directory? - assert !@link.directory? - assert !@file.directory? - end - - def test_symlink? - assert !@directory.symlink? - assert @link.symlink? - assert !@file.symlink? - end - - def test_file? - assert !@directory.file? - assert !@link.file? - assert @file.file? - end -end \ No newline at end of file diff --git a/vendor/gems/net-sftp-2.0.2/test/protocol/02/test_base.rb b/vendor/gems/net-sftp-2.0.2/test/protocol/02/test_base.rb deleted file mode 100644 index 57e3bdebc..000000000 --- a/vendor/gems/net-sftp-2.0.2/test/protocol/02/test_base.rb +++ /dev/null @@ -1,26 +0,0 @@ -require 'common' -require 'protocol/01/test_base' - -class Protocol::V02::TestBase < Protocol::V01::TestBase - def test_version - assert_equal 2, @base.version - end - - undef test_rename_should_raise_not_implemented_error - - def test_rename_should_send_rename_packet - @session.expects(:send_packet).with(FXP_RENAME, :long, 0, :string, "/old/file", :string, "/new/file") - assert_equal 0, @base.rename("/old/file", "/new/file") - end - - def test_rename_should_ignore_flags_parameter - @session.expects(:send_packet).with(FXP_RENAME, :long, 0, :string, "/old/file", :string, "/new/file") - assert_equal 0, @base.rename("/old/file", "/new/file", 1234) - end - - private - - def driver - Net::SFTP::Protocol::V02::Base - end -end diff --git a/vendor/gems/net-sftp-2.0.2/test/protocol/03/test_base.rb b/vendor/gems/net-sftp-2.0.2/test/protocol/03/test_base.rb deleted file mode 100644 index 5bb2e5eab..000000000 --- a/vendor/gems/net-sftp-2.0.2/test/protocol/03/test_base.rb +++ /dev/null @@ -1,27 +0,0 @@ -require 'common' -require 'protocol/02/test_base' - -class Protocol::V03::TestBase < Protocol::V02::TestBase - def test_version - assert_equal 3, @base.version - end - - undef test_readlink_should_raise_not_implemented_error - undef test_symlink_should_raise_not_implemented_error - - def test_readlink_should_send_readlink_packet - @session.expects(:send_packet).with(FXP_READLINK, :long, 0, :string, "/path/to/link") - assert_equal 0, @base.readlink("/path/to/link") - end - - def test_symlink_should_send_symlink_packet - @session.expects(:send_packet).with(FXP_SYMLINK, :long, 0, :string, "/path/to/link", :string, "/path/to/file") - assert_equal 0, @base.symlink("/path/to/link", "/path/to/file") - end - - private - - def driver - Net::SFTP::Protocol::V03::Base - end -end diff --git a/vendor/gems/net-sftp-2.0.2/test/protocol/04/test_attributes.rb b/vendor/gems/net-sftp-2.0.2/test/protocol/04/test_attributes.rb deleted file mode 100644 index d836b319c..000000000 --- a/vendor/gems/net-sftp-2.0.2/test/protocol/04/test_attributes.rb +++ /dev/null @@ -1,148 +0,0 @@ -require 'common' - -module Etc; end - -class Protocol::V04::TestAttributes < Net::SFTP::TestCase - def setup - @directory = attributes_factory.new(:type => attributes_factory::T_DIRECTORY) - @symlink = attributes_factory.new(:type => attributes_factory::T_SYMLINK) - @file = attributes_factory.new(:type => attributes_factory::T_REGULAR) - end - - def test_from_buffer_should_correctly_parse_buffer_and_return_attribute_object - attributes = attributes_factory.from_buffer(full_buffer) - - assert_equal 9, attributes.type - assert_equal 1234567890, attributes.size - assert_equal "jamis", attributes.owner - assert_equal "users", attributes.group - assert_equal 0755, attributes.permissions - assert_equal 1234567890, attributes.atime - assert_equal 12345, attributes.atime_nseconds - assert_equal 2345678901, attributes.createtime - assert_equal 23456, attributes.createtime_nseconds - assert_equal 3456789012, attributes.mtime - assert_equal 34567, attributes.mtime_nseconds - - assert_equal 2, attributes.acl.length - - assert_equal 1, attributes.acl.first.type - assert_equal 2, attributes.acl.first.flag - assert_equal 3, attributes.acl.first.mask - assert_equal "foo", attributes.acl.first.who - - assert_equal 4, attributes.acl.last.type - assert_equal 5, attributes.acl.last.flag - assert_equal 6, attributes.acl.last.mask - assert_equal "bar", attributes.acl.last.who - - assert_equal "second", attributes.extended["first"] - end - - def test_from_buffer_should_correctly_parse_buffer_with_attribute_subset_and_return_attribute_object - buffer = Net::SSH::Buffer.from(:long, 0x4, :byte, 1, :long, 0755) - - attributes = attributes_factory.from_buffer(buffer) - - assert_equal 1, attributes.type - assert_equal 0755, attributes.permissions - - assert_nil attributes.size - assert_nil attributes.owner - assert_nil attributes.group - assert_nil attributes.atime - assert_nil attributes.atime_nseconds - assert_nil attributes.createtime - assert_nil attributes.createtime_nseconds - assert_nil attributes.mtime - assert_nil attributes.mtime_nseconds - assert_nil attributes.acl - assert_nil attributes.extended - end - - def test_attributes_to_s_should_build_binary_representation - attributes = attributes_factory.new( - :type => 9, - :size => 1234567890, - :owner => "jamis", :group => "users", - :permissions => 0755, - :atime => 1234567890, :atime_nseconds => 12345, - :createtime => 2345678901, :createtime_nseconds => 23456, - :mtime => 3456789012, :mtime_nseconds => 34567, - :acl => [attributes_factory::ACL.new(1,2,3,"foo"), - attributes_factory::ACL.new(4,5,6,"bar")], - :extended => { "first" => "second" }) - - assert_equal full_buffer.to_s, attributes.to_s - end - - def test_attributes_to_s_should_build_binary_representation_when_subset_is_present - attributes = attributes_factory.new(:permissions => 0755) - assert_equal Net::SSH::Buffer.from(:long, 0x4, :byte, 1, :long, 0755).to_s, attributes.to_s - end - - def test_attributes_to_s_with_uid_and_gid_should_translate_to_owner_and_group - attributes = attributes_factory.new(:uid => 100, :gid => 200) - attributes.expects(:require).with("etc").times(2) - Etc.expects(:getpwuid).with(100).returns(mock('user', :name => "jamis")) - Etc.expects(:getgrgid).with(200).returns(mock('group', :name => "sftp")) - assert_equal Net::SSH::Buffer.from(:long, 0x80, :byte, 1, :string, "jamis", :string, "sftp").to_s, attributes.to_s - end - - def test_uid_should_translate_from_owner - attributes = attributes_factory.new(:owner => "jamis") - attributes.expects(:require).with("etc") - Etc.expects(:getpwnam).with("jamis").returns(mock('user', :uid => 100)) - assert_equal 100, attributes.uid - end - - def test_gid_should_translate_from_group - attributes = attributes_factory.new(:group => "sftp") - attributes.expects(:require).with("etc") - Etc.expects(:getgrnam).with("sftp").returns(mock('group', :gid => 200)) - assert_equal 200, attributes.gid - end - - def test_attributes_without_subsecond_times_should_serialize_without_subsecond_times - attributes = attributes_factory.new(:atime => 100) - assert_equal Net::SSH::Buffer.from(:long, 0x8, :byte, 1, :int64, 100).to_s, attributes.to_s - end - - def test_directory_should_be_true_only_when_type_is_directory - assert @directory.directory? - assert !@symlink.directory? - assert !@file.directory? - end - - def test_symlink_should_be_true_only_when_type_is_symlink - assert !@directory.symlink? - assert @symlink.symlink? - assert !@file.symlink? - end - - def test_file_should_be_true_only_when_type_is_file - assert !@directory.file? - assert !@symlink.file? - assert @file.file? - end - - private - - def full_buffer - Net::SSH::Buffer.from(:long, 0x800001fd, - :byte, 9, :int64, 1234567890, - :string, "jamis", :string, "users", - :long, 0755, - :int64, 1234567890, :long, 12345, - :int64, 2345678901, :long, 23456, - :int64, 3456789012, :long, 34567, - :string, raw(:long, 2, - :long, 1, :long, 2, :long, 3, :string, "foo", - :long, 4, :long, 5, :long, 6, :string, "bar"), - :long, 1, :string, "first", :string, "second") - end - - def attributes_factory - Net::SFTP::Protocol::V04::Attributes - end -end \ No newline at end of file diff --git a/vendor/gems/net-sftp-2.0.2/test/protocol/04/test_base.rb b/vendor/gems/net-sftp-2.0.2/test/protocol/04/test_base.rb deleted file mode 100644 index b52a5fc76..000000000 --- a/vendor/gems/net-sftp-2.0.2/test/protocol/04/test_base.rb +++ /dev/null @@ -1,74 +0,0 @@ -require 'common' -require 'protocol/03/test_base' - -class Protocol::V04::TestBase < Protocol::V03::TestBase - def test_version - assert_equal 4, @base.version - end - - def test_parse_attrs_packet_should_use_correct_attributes_class - Net::SFTP::Protocol::V04::Attributes.expects(:from_buffer).with(:packet).returns(:result) - assert_equal({ :attrs => :result }, @base.parse_attrs_packet(:packet)) - end - - def test_parse_name_packet_should_use_correct_name_class - packet = Net::SSH::Buffer.from(:long, 2, - :string, "name1", :long, 0x4, :byte, 1, :long, 0755, - :string, "name2", :long, 0x4, :byte, 1, :long, 0550) - names = @base.parse_name_packet(packet)[:names] - - assert_not_nil names - assert_equal 2, names.length - assert_instance_of Net::SFTP::Protocol::V04::Name, names.first - - assert_equal "name1", names.first.name - assert_equal 0755, names.first.attributes.permissions - - assert_equal "name2", names.last.name - assert_equal 0550, names.last.attributes.permissions - end - - undef test_fstat_should_ignore_flags_parameter - undef test_lstat_should_ignore_flags_parameter - undef test_stat_should_ignore_flags_parameter - - def test_lstat_should_send_lstat_packet - @session.expects(:send_packet).with(FXP_LSTAT, :long, 0, :string, "/path/to/file", :long, 0x800001fd) - assert_equal 0, @base.lstat("/path/to/file") - end - - def test_lstat_with_custom_flags_should_send_lstat_packet_with_given_flags - @session.expects(:send_packet).with(FXP_LSTAT, :long, 0, :string, "/path/to/file", :long, 1234) - assert_equal 0, @base.lstat("/path/to/file", 1234) - end - - def test_fstat_should_send_fstat_packet - @session.expects(:send_packet).with(FXP_FSTAT, :long, 0, :string, "handle", :long, 0x800001fd) - assert_equal 0, @base.fstat("handle") - end - - def test_fstat_with_custom_flags_should_send_fstat_packet_with_given_flags - @session.expects(:send_packet).with(FXP_FSTAT, :long, 0, :string, "handle", :long, 1234) - assert_equal 0, @base.fstat("handle", 1234) - end - - def test_stat_should_send_stat_packet - @session.expects(:send_packet).with(FXP_STAT, :long, 0, :string, "/path/to/file", :long, 0x800001fd) - assert_equal 0, @base.stat("/path/to/file") - end - - def test_stat_with_custom_flags_should_send_stat_packet_with_given_flags - @session.expects(:send_packet).with(FXP_STAT, :long, 0, :string, "/path/to/file", :long, 1234) - assert_equal 0, @base.stat("/path/to/file", 1234) - end - - private - - def driver - Net::SFTP::Protocol::V04::Base - end - - def attributes - Net::SFTP::Protocol::V04::Attributes - end -end diff --git a/vendor/gems/net-sftp-2.0.2/test/protocol/04/test_name.rb b/vendor/gems/net-sftp-2.0.2/test/protocol/04/test_name.rb deleted file mode 100644 index c4b1d34b2..000000000 --- a/vendor/gems/net-sftp-2.0.2/test/protocol/04/test_name.rb +++ /dev/null @@ -1,53 +0,0 @@ -require 'common' - -class Protocol::V04::TestName < Net::SFTP::TestCase - def setup - @save_tz = ENV['TZ'] - ENV['TZ'] = 'UTC' - - @directory = Net::SFTP::Protocol::V04::Name.new("test", Net::SFTP::Protocol::V04::Attributes.new(:type => 2, :mtime => 1205293237, :owner => "jamis", :group => "users", :size => 1024, :permissions => 0755)) - @link = Net::SFTP::Protocol::V04::Name.new("test", Net::SFTP::Protocol::V04::Attributes.new(:type => 3, :mtime => 1205293237, :owner => "jamis", :group => "users", :size => 32, :permissions => 0755)) - @file = Net::SFTP::Protocol::V04::Name.new("test", Net::SFTP::Protocol::V04::Attributes.new(:type => 1, :mtime => 1205293237, :owner => "jamis", :group => "users", :size => 10240, :permissions => 0755)) - end - - def teardown - if @save_tz - ENV['TZ'] = @save_tz - else - ENV.delete('TZ') - end - end - - def test_directory? - assert @directory.directory? - assert !@link.directory? - assert !@file.directory? - end - - def test_symlink? - assert !@directory.symlink? - assert @link.symlink? - assert !@file.symlink? - end - - def test_file? - assert !@directory.file? - assert !@link.file? - assert @file.file? - end - - def test_longname_for_directory_should_format_as_directory - assert_equal "drwxr-xr-x jamis users 1024 Mar 12 03:40 test", - @directory.longname - end - - def test_longname_for_symlink_should_format_as_symlink - assert_equal "lrwxr-xr-x jamis users 32 Mar 12 03:40 test", - @link.longname - end - - def test_longname_for_file_should_format_as_file - assert_equal "-rwxr-xr-x jamis users 10240 Mar 12 03:40 test", - @file.longname - end -end diff --git a/vendor/gems/net-sftp-2.0.2/test/protocol/05/test_base.rb b/vendor/gems/net-sftp-2.0.2/test/protocol/05/test_base.rb deleted file mode 100644 index 690f6c74e..000000000 --- a/vendor/gems/net-sftp-2.0.2/test/protocol/05/test_base.rb +++ /dev/null @@ -1,62 +0,0 @@ -require 'common' -require 'protocol/04/test_base' - -class Protocol::V05::TestBase < Protocol::V04::TestBase - include Net::SFTP::Constants::OpenFlags - include Net::SFTP::Constants - - def test_version - assert_equal 5, @base.version - end - - undef test_rename_should_ignore_flags_parameter - - def test_rename_should_send_rename_packet - @session.expects(:send_packet).with(FXP_RENAME, :long, 0, :string, "/old/file", :string, "/new/file", :long, 0) - assert_equal 0, @base.rename("/old/file", "/new/file") - end - - def test_rename_with_flags_should_send_rename_packet_with_flags - @session.expects(:send_packet).with(FXP_RENAME, :long, 0, :string, "/old/file", :string, "/new/file", :long, RenameFlags::ATOMIC) - assert_equal 0, @base.rename("/old/file", "/new/file", RenameFlags::ATOMIC) - end - - def test_open_with_numeric_flag_should_accept_IO_constants - @session.expects(:send_packet).with(FXP_OPEN, :long, 0, - :string, "/path/to/file", - :long, ACE::Mask::READ_DATA | ACE::Mask::READ_ATTRIBUTES | ACE::Mask::WRITE_DATA | ACE::Mask::WRITE_ATTRIBUTES, - :long, FV5::CREATE_NEW, - :raw, attributes.new.to_s) - - assert_equal 0, @base.open("/path/to/file", IO::RDWR | IO::CREAT | IO::EXCL, {}) - end - - { "r" => [FV5::OPEN_EXISTING, ACE::Mask::READ_DATA | ACE::Mask::READ_ATTRIBUTES], - "rb" => [FV5::OPEN_EXISTING, ACE::Mask::READ_DATA | ACE::Mask::READ_ATTRIBUTES], - "r+" => [FV5::OPEN_EXISTING, ACE::Mask::READ_DATA | ACE::Mask::READ_ATTRIBUTES | ACE::Mask::WRITE_DATA | ACE::Mask::WRITE_ATTRIBUTES], - "w" => [FV5::CREATE_TRUNCATE, ACE::Mask::WRITE_DATA | ACE::Mask::WRITE_ATTRIBUTES], - "w+" => [FV5::CREATE_TRUNCATE, ACE::Mask::READ_DATA | ACE::Mask::READ_ATTRIBUTES | ACE::Mask::WRITE_DATA | ACE::Mask::WRITE_ATTRIBUTES], - "a" => [FV5::OPEN_OR_CREATE | FV5::APPEND_DATA, ACE::Mask::WRITE_DATA | ACE::Mask::WRITE_ATTRIBUTES | ACE::Mask::APPEND_DATA], - "a+" => [FV5::OPEN_OR_CREATE | FV5::APPEND_DATA, ACE::Mask::READ_DATA | ACE::Mask::READ_ATTRIBUTES | ACE::Mask::WRITE_DATA | ACE::Mask::WRITE_ATTRIBUTES | ACE::Mask::APPEND_DATA] - }.each do |mode_string, (flags, access)| - define_method("test_open_with_#{mode_string.sub(/\+/, '_plus')}_should_translate_correctly") do - @session.expects(:send_packet).with(FXP_OPEN, :long, 0, - :string, "/path/to/file", :long, access, :long, flags, :raw, attributes.new.to_s) - - assert_equal 0, @base.open("/path/to/file", mode_string, {}) - end - end - - def test_open_with_attributes_converts_hash_to_attribute_packet - @session.expects(:send_packet).with(FXP_OPEN, :long, 0, - :string, "/path/to/file", :long, ACE::Mask::READ_DATA | ACE::Mask::READ_ATTRIBUTES, - :long, FV5::OPEN_EXISTING, :raw, attributes.new(:permissions => 0755).to_s) - @base.open("/path/to/file", "r", :permissions => 0755) - end - - private - - def driver - Net::SFTP::Protocol::V05::Base - end -end diff --git a/vendor/gems/net-sftp-2.0.2/test/protocol/06/test_attributes.rb b/vendor/gems/net-sftp-2.0.2/test/protocol/06/test_attributes.rb deleted file mode 100644 index ddb218095..000000000 --- a/vendor/gems/net-sftp-2.0.2/test/protocol/06/test_attributes.rb +++ /dev/null @@ -1,124 +0,0 @@ -require 'common' - -module Etc; end - -class Protocol::V06::TestAttributes < Net::SFTP::TestCase - def test_from_buffer_should_correctly_parse_buffer_and_return_attribute_object - attributes = attributes_factory.from_buffer(full_buffer) - - assert_equal 9, attributes.type - assert_equal 1234567890, attributes.size - assert_equal 2345678901, attributes.allocation_size - assert_equal "jamis", attributes.owner - assert_equal "users", attributes.group - assert_equal 0755, attributes.permissions - assert_equal 1234567890, attributes.atime - assert_equal 12345, attributes.atime_nseconds - assert_equal 2345678901, attributes.createtime - assert_equal 23456, attributes.createtime_nseconds - assert_equal 3456789012, attributes.mtime - assert_equal 34567, attributes.mtime_nseconds - assert_equal 4567890123, attributes.ctime - assert_equal 45678, attributes.ctime_nseconds - - assert_equal 2, attributes.acl.length - - assert_equal 1, attributes.acl.first.type - assert_equal 2, attributes.acl.first.flag - assert_equal 3, attributes.acl.first.mask - assert_equal "foo", attributes.acl.first.who - - assert_equal 4, attributes.acl.last.type - assert_equal 5, attributes.acl.last.flag - assert_equal 6, attributes.acl.last.mask - assert_equal "bar", attributes.acl.last.who - - assert_equal 0x12341234, attributes.attrib_bits - assert_equal 0x23452345, attributes.attrib_bits_valid - assert_equal 0x3, attributes.text_hint - assert_equal "text/html", attributes.mime_type - assert_equal 144, attributes.link_count - assert_equal "an untranslated name", attributes.untranslated_name - - assert_equal "second", attributes.extended["first"] - end - - def test_from_buffer_should_correctly_parse_buffer_with_attribute_subset_and_return_attribute_object - buffer = Net::SSH::Buffer.from(:long, 0x4, :byte, 1, :long, 0755) - - attributes = attributes_factory.from_buffer(buffer) - - assert_equal 1, attributes.type - assert_equal 0755, attributes.permissions - - assert_nil attributes.size - assert_nil attributes.allocation_size - assert_nil attributes.owner - assert_nil attributes.group - assert_nil attributes.atime - assert_nil attributes.atime_nseconds - assert_nil attributes.createtime - assert_nil attributes.createtime_nseconds - assert_nil attributes.mtime - assert_nil attributes.mtime_nseconds - assert_nil attributes.ctime - assert_nil attributes.ctime_nseconds - assert_nil attributes.acl - assert_nil attributes.attrib_bits - assert_nil attributes.attrib_bits_valid - assert_nil attributes.text_hint - assert_nil attributes.mime_type - assert_nil attributes.link_count - assert_nil attributes.untranslated_name - assert_nil attributes.extended - end - - def test_attributes_to_s_should_build_binary_representation - attributes = attributes_factory.new( - :type => 9, - :size => 1234567890, :allocation_size => 2345678901, - :owner => "jamis", :group => "users", - :permissions => 0755, - :atime => 1234567890, :atime_nseconds => 12345, - :createtime => 2345678901, :createtime_nseconds => 23456, - :mtime => 3456789012, :mtime_nseconds => 34567, - :ctime => 4567890123, :ctime_nseconds => 45678, - :acl => [attributes_factory::ACL.new(1,2,3,"foo"), - attributes_factory::ACL.new(4,5,6,"bar")], - :attrib_bits => 0x12341234, :attrib_bits_valid => 0x23452345, - :text_hint => 0x3, :mime_type => "text/html", - :link_count => 144, :untranslated_name => "an untranslated name", - :extended => { "first" => "second" }) - - assert_equal full_buffer.to_s, attributes.to_s - end - - def test_attributes_to_s_should_build_binary_representation_when_subset_is_present - attributes = attributes_factory.new(:permissions => 0755) - assert_equal Net::SSH::Buffer.from(:long, 0x4, :byte, 1, :long, 0755).to_s, attributes.to_s - end - - private - - def full_buffer - Net::SSH::Buffer.from(:long, 0x8000fffd, - :byte, 9, :int64, 1234567890, :int64, 2345678901, - :string, "jamis", :string, "users", - :long, 0755, - :int64, 1234567890, :long, 12345, - :int64, 2345678901, :long, 23456, - :int64, 3456789012, :long, 34567, - :int64, 4567890123, :long, 45678, - :string, raw(:long, 2, - :long, 1, :long, 2, :long, 3, :string, "foo", - :long, 4, :long, 5, :long, 6, :string, "bar"), - :long, 0x12341234, :long, 0x23452345, - :byte, 0x3, :string, "text/html", :long, 144, - :string, "an untranslated name", - :long, 1, :string, "first", :string, "second") - end - - def attributes_factory - Net::SFTP::Protocol::V06::Attributes - end -end \ No newline at end of file diff --git a/vendor/gems/net-sftp-2.0.2/test/protocol/06/test_base.rb b/vendor/gems/net-sftp-2.0.2/test/protocol/06/test_base.rb deleted file mode 100644 index 668b32b09..000000000 --- a/vendor/gems/net-sftp-2.0.2/test/protocol/06/test_base.rb +++ /dev/null @@ -1,51 +0,0 @@ -require 'common' -require 'protocol/05/test_base' - -class Protocol::V06::TestBase < Protocol::V05::TestBase - include Net::SFTP::Constants::OpenFlags - include Net::SFTP::Constants - - def test_version - assert_equal 6, @base.version - end - - def test_parse_attrs_packet_should_use_correct_attributes_class - Net::SFTP::Protocol::V06::Attributes.expects(:from_buffer).with(:packet).returns(:result) - assert_equal({ :attrs => :result }, @base.parse_attrs_packet(:packet)) - end - - undef test_link_should_raise_not_implemented_error - undef test_block_should_raise_not_implemented_error - undef test_unblock_should_raise_not_implemented_error - undef test_symlink_should_send_symlink_packet - - def test_link_should_send_link_packet - @session.expects(:send_packet).with(FXP_LINK, :long, 0, :string, "/path/to/link", :string, "/path/to/file", :bool, true) - assert_equal 0, @base.link("/path/to/link", "/path/to/file", true) - end - - def test_symlink_should_send_link_packet_as_symlink - @session.expects(:send_packet).with(FXP_LINK, :long, 0, :string, "/path/to/link", :string, "/path/to/file", :bool, true) - assert_equal 0, @base.symlink("/path/to/link", "/path/to/file") - end - - def test_block_should_send_block_packet - @session.expects(:send_packet).with(FXP_BLOCK, :long, 0, :string, "handle", :int64, 1234, :int64, 4567, :long, 0x40) - assert_equal 0, @base.block("handle", 1234, 4567, 0x40) - end - - def test_unblock_should_send_unblock_packet - @session.expects(:send_packet).with(FXP_UNBLOCK, :long, 0, :string, "handle", :int64, 1234, :int64, 4567) - assert_equal 0, @base.unblock("handle", 1234, 4567) - end - - private - - def driver - Net::SFTP::Protocol::V06::Base - end - - def attributes - Net::SFTP::Protocol::V06::Attributes - end -end diff --git a/vendor/gems/net-sftp-2.0.2/test/protocol/test_base.rb b/vendor/gems/net-sftp-2.0.2/test/protocol/test_base.rb deleted file mode 100644 index fd1103c6d..000000000 --- a/vendor/gems/net-sftp-2.0.2/test/protocol/test_base.rb +++ /dev/null @@ -1,42 +0,0 @@ -require 'common' - -class Protocol::TestBase < Net::SFTP::TestCase - def setup - @base = Net::SFTP::Protocol::Base.new(stub('session', :logger => nil)) - end - - def test_parse_with_status_packet_should_delegate_to_parse_status_packet - packet = stub('packet', :type => FXP_STATUS) - @base.expects(:parse_status_packet).with(packet).returns(:result) - assert_equal :result, @base.parse(packet) - end - - def test_parse_with_handle_packet_should_delegate_to_parse_handle_packet - packet = stub('packet', :type => FXP_HANDLE) - @base.expects(:parse_handle_packet).with(packet).returns(:result) - assert_equal :result, @base.parse(packet) - end - - def test_parse_with_data_packet_should_delegate_to_parse_data_packet - packet = stub('packet', :type => FXP_DATA) - @base.expects(:parse_data_packet).with(packet).returns(:result) - assert_equal :result, @base.parse(packet) - end - - def test_parse_with_name_packet_should_delegate_to_parse_name_packet - packet = stub('packet', :type => FXP_NAME) - @base.expects(:parse_name_packet).with(packet).returns(:result) - assert_equal :result, @base.parse(packet) - end - - def test_parse_with_attrs_packet_should_delegate_to_parse_attrs_packet - packet = stub('packet', :type => FXP_ATTRS) - @base.expects(:parse_attrs_packet).with(packet).returns(:result) - assert_equal :result, @base.parse(packet) - end - - def test_parse_with_unknown_packet_should_raise_exception - packet = stub('packet', :type => FXP_WRITE) - assert_raises(NotImplementedError) { @base.parse(packet) } - end -end \ No newline at end of file diff --git a/vendor/gems/net-sftp-2.0.2/test/test_all.rb b/vendor/gems/net-sftp-2.0.2/test/test_all.rb deleted file mode 100644 index 08485bc9c..000000000 --- a/vendor/gems/net-sftp-2.0.2/test/test_all.rb +++ /dev/null @@ -1,3 +0,0 @@ -Dir.chdir(File.dirname(__FILE__)) do - Dir['**/test_*.rb'].each { |file| require(file) } -end \ No newline at end of file diff --git a/vendor/gems/net-sftp-2.0.2/test/test_dir.rb b/vendor/gems/net-sftp-2.0.2/test/test_dir.rb deleted file mode 100644 index 1612baeb1..000000000 --- a/vendor/gems/net-sftp-2.0.2/test/test_dir.rb +++ /dev/null @@ -1,47 +0,0 @@ -require 'common' - -class DirOperationsTest < Net::SFTP::TestCase - def setup - @sftp = mock("sftp") - @dir = Net::SFTP::Operations::Dir.new(@sftp) - end - - def test_foreach_should_iterate_over_all_entries_in_directory - @sftp.expects(:opendir!).with("/path/to/remote").returns("handle") - @sftp.expects(:readdir!).with("handle").returns([:e1, :e2, :e3], [:e4, :e5], nil).times(3) - @sftp.expects(:close!).with("handle") - - entries = [] - @dir.foreach("/path/to/remote") { |entry| entries << entry } - assert_equal [:e1, :e2, :e3, :e4, :e5], entries - end - - def test_entries_should_return_all_entries_in_a_single_array - @sftp.expects(:opendir!).with("/path/to/remote").returns("handle") - @sftp.expects(:readdir!).with("handle").returns([:e1, :e2, :e3], [:e4, :e5], nil).times(3) - @sftp.expects(:close!).with("handle") - - assert_equal [:e1, :e2, :e3, :e4, :e5], @dir.entries("/path/to/remote") - end - - def test_glob_should_search_under_path_for_matching_entries - @sftp.expects(:opendir!).with("/path/to/remote").returns("handle") - @sftp.expects(:opendir!).with("/path/to/remote/e3").returns("handle-e3") - @sftp.expects(:opendir!).with("/path/to/remote/e5").returns("handle-e5") - @sftp.expects(:readdir!).with("handle").returns([n(".", true), n("..", true), n("e1"), n("e2"), n("e3", true)], [n("e4"), n("e5", true)], nil).times(3) - @sftp.expects(:readdir!).with("handle-e3").returns([n(".", true), n("..", true), n("e3e1"), n("e3e2")], nil).times(2) - @sftp.expects(:readdir!).with("handle-e5").returns([n(".", true), n("..", true), n("e5e1"), n("e5e2"), n("e5e3")], nil).times(2) - @sftp.expects(:close!).with("handle") - @sftp.expects(:close!).with("handle-e3") - @sftp.expects(:close!).with("handle-e5") - - assert_equal %w(e3/e3e2 e5/e5e2), @dir.glob("/path/to/remote", "**/e?e2").map { |e| e.name } - end - - private - - def n(name, directory=false) - Net::SFTP::Protocol::V01::Name.new(name.to_s, "longname for #{name}", - Net::SFTP::Protocol::V01::Attributes.new(:permissions => directory ? 040755 : 0100644)) - end -end \ No newline at end of file diff --git a/vendor/gems/net-sftp-2.0.2/test/test_download.rb b/vendor/gems/net-sftp-2.0.2/test/test_download.rb deleted file mode 100644 index 36126877d..000000000 --- a/vendor/gems/net-sftp-2.0.2/test/test_download.rb +++ /dev/null @@ -1,252 +0,0 @@ -require "common" - -class DownloadTest < Net::SFTP::TestCase - def setup - prepare_progress! - end - - def test_download_file_should_transfer_remote_to_local - local = "/path/to/local" - remote = "/path/to/remote" - text = "this is some text\n" - - expect_file_transfer(remote, text) - - file = StringIO.new - File.stubs(:open).with(local, "wb").returns(file) - - assert_scripted_command { sftp.download(remote, local) } - assert_equal text, file.string - end - - def test_download_large_file_should_transfer_remote_to_local - local = "/path/to/local" - remote = "/path/to/remote" - text = "0123456789" * 1024 - - file = prepare_large_file_download(local, remote, text) - - assert_scripted_command { sftp.download(remote, local, :read_size => 1024) } - assert_equal text, file.string - end - - def test_download_large_file_with_progress_should_report_progress - local = "/path/to/local" - remote = "/path/to/remote" - text = "0123456789" * 1024 - - file = prepare_large_file_download(local, remote, text) - - assert_scripted_command do - sftp.download(remote, local, :read_size => 1024) do |*args| - record_progress(args) - end - end - - assert_equal text, file.string - - assert_progress_reported_open :remote => "/path/to/remote" - assert_progress_reported_get 0, 1024 - assert_progress_reported_get 1024, 1024 - assert_progress_reported_get 2048, 1024 - assert_progress_reported_get 3072, 1024 - assert_progress_reported_get 4096, 1024 - assert_progress_reported_get 5120, 1024 - assert_progress_reported_get 6144, 1024 - assert_progress_reported_get 7168, 1024 - assert_progress_reported_get 8192, 1024 - assert_progress_reported_get 9216, 1024 - assert_progress_reported_close - assert_progress_reported_finish - assert_no_more_reported_events - end - - def test_download_directory_should_mirror_directory_locally - file1, file2 = prepare_directory_tree_download("/path/to/local", "/path/to/remote") - - assert_scripted_command do - sftp.download("/path/to/remote", "/path/to/local", :recursive => true) - end - - assert_equal "contents of file1", file1.string - assert_equal "contents of file2", file2.string - end - - def test_download_directory_with_progress_should_report_progress - file1, file2 = prepare_directory_tree_download("/path/to/local", "/path/to/remote") - - assert_scripted_command do - sftp.download("/path/to/remote", "/path/to/local", :recursive => true) do |*args| - record_progress(args) - end - end - - assert_equal "contents of file1", file1.string - assert_equal "contents of file2", file2.string - - assert_progress_reported_mkdir "/path/to/local" - assert_progress_reported_mkdir "/path/to/local/subdir1" - assert_progress_reported_open :remote => "/path/to/remote/file1" - assert_progress_reported_open :remote => "/path/to/remote/subdir1/file2" - assert_progress_reported_get 0, "contents of file1" - assert_progress_reported_close :remote => "/path/to/remote/file1" - assert_progress_reported_get 0, "contents of file2" - assert_progress_reported_close :remote => "/path/to/remote/subdir1/file2" - assert_progress_reported_finish - assert_no_more_reported_events - end - - def test_download_file_should_transfer_remote_to_local_buffer - remote = "/path/to/remote" - text = "this is some text\n" - - expect_file_transfer(remote, text) - - local = StringIO.new - - assert_scripted_command { sftp.download(remote, local) } - assert_equal text, local.string - end - - def test_download_directory_to_buffer_should_fail - expect_sftp_session :server_version => 3 - assert_raises(ArgumentError) { sftp.download("/path/to/remote", StringIO.new, :recursive => true) } - end - - private - - def expect_file_transfer(remote, text) - expect_sftp_session :server_version => 3 do |channel| - channel.sends_packet(FXP_OPEN, :long, 0, :string, remote, :long, 0x01, :long, 0) - channel.gets_packet(FXP_HANDLE, :long, 0, :string, "handle") - channel.sends_packet(FXP_READ, :long, 1, :string, "handle", :int64, 0, :long, 32_000) - channel.gets_packet(FXP_DATA, :long, 1, :string, text) - channel.sends_packet(FXP_READ, :long, 2, :string, "handle", :int64, 32_000, :long, 32_000) - channel.gets_packet(FXP_STATUS, :long, 2, :long, 1) - channel.sends_packet(FXP_CLOSE, :long, 3, :string, "handle") - channel.gets_packet(FXP_STATUS, :long, 3, :long, 0) - end - end - - def prepare_large_file_download(local, remote, text) - expect_sftp_session :server_version => 3 do |channel| - channel.sends_packet(FXP_OPEN, :long, 0, :string, remote, :long, 0x01, :long, 0) - channel.gets_packet(FXP_HANDLE, :long, 0, :string, "handle") - 10.times do |n| - channel.sends_packet(FXP_READ, :long, n+1, :string, "handle", :int64, n*1024, :long, 1024) - channel.gets_packet(FXP_DATA, :long, n+1, :string, text[n*1024,1024]) - end - channel.sends_packet(FXP_READ, :long, 11, :string, "handle", :int64, 10240, :long, 1024) - channel.gets_packet(FXP_STATUS, :long, 11, :long, 1) - channel.sends_packet(FXP_CLOSE, :long, 12, :string, "handle") - channel.gets_packet(FXP_STATUS, :long, 12, :long, 0) - end - - file = StringIO.new - File.stubs(:open).with(local, "wb").returns(file) - - return file - end - - # 0:OPENDIR(remote) -> - # <- 0:HANDLE("dir1") - # 1:READDIR("dir1") -> - # <- 1:NAME("..", ".", "subdir1", "file1") - # 2:OPENDIR(remote/subdir1) -> - # 3:OPEN(remote/file1) -> - # 4:READDIR("dir1") -> - # <- 2:HANDLE("dir2") - # 5:READDIR("dir2") -> - # <- 3:HANDLE("file1") - # 6:READ("file1", 0, 32k) -> - # <- 4:STATUS(1) - # 7:CLOSE("dir1") -> - # <- 5:NAME("..", ".", "file2") - # 8:OPEN(remote/subdir1/file2) -> - # 9:READDIR("dir2") -> - # <- 6:DATA("blah blah blah") - # 10:READ("file1", n, 32k) - # <- 7:STATUS(0) - # <- 8:HANDLE("file2") - # 11:READ("file2", 0, 32k) -> - # <- 9:STATUS(1) - # 12:CLOSE("dir2") -> - # <- 10:STATUS(1) - # 13:CLOSE("file1") -> - # <- 11:DATA("blah blah blah") - # 14:READ("file2", n, 32k) -> - # <- 12:STATUS(0) - # <- 13:STATUS(0) - # <- 14:STATUS(1) - # 15:CLOSE("file2") -> - # <- 15:STATUS(0) - - def prepare_directory_tree_download(local, remote) - expect_sftp_session :server_version => 3 do |channel| - channel.sends_packet(FXP_OPENDIR, :long, 0, :string, remote) - channel.gets_packet(FXP_HANDLE, :long, 0, :string, "dir1") - - channel.sends_packet(FXP_READDIR, :long, 1, :string, "dir1") - channel.gets_packet(FXP_NAME, :long, 1, :long, 4, - :string, "..", :string, "drwxr-xr-x 4 bob bob 136 Aug 1 ..", :long, 0x04, :long, 040755, - :string, ".", :string, "drwxr-xr-x 4 bob bob 136 Aug 1 .", :long, 0x04, :long, 040755, - :string, "subdir1", :string, "drwxr-xr-x 4 bob bob 136 Aug 1 subdir1", :long, 0x04, :long, 040755, - :string, "file1", :string, "-rw-rw-r-- 1 bob bob 100 Aug 1 file1", :long, 0x04, :long, 0100644) - - channel.sends_packet(FXP_OPENDIR, :long, 2, :string, File.join(remote, "subdir1")) - channel.sends_packet(FXP_OPEN, :long, 3, :string, File.join(remote, "file1"), :long, 0x01, :long, 0) - channel.sends_packet(FXP_READDIR, :long, 4, :string, "dir1") - - channel.gets_packet(FXP_HANDLE, :long, 2, :string, "dir2") - channel.sends_packet(FXP_READDIR, :long, 5, :string, "dir2") - - channel.gets_packet(FXP_HANDLE, :long, 3, :string, "file1") - channel.sends_packet(FXP_READ, :long, 6, :string, "file1", :int64, 0, :long, 32_000) - - channel.gets_packet(FXP_STATUS, :long, 4, :long, 1) - channel.sends_packet(FXP_CLOSE, :long, 7, :string, "dir1") - - channel.gets_packet(FXP_NAME, :long, 5, :long, 3, - :string, "..", :string, "drwxr-xr-x 4 bob bob 136 Aug 1 ..", :long, 0x04, :long, 040755, - :string, ".", :string, "drwxr-xr-x 4 bob bob 136 Aug 1 .", :long, 0x04, :long, 040755, - :string, "file2", :string, "-rw-rw-r-- 1 bob bob 100 Aug 1 file2", :long, 0x04, :long, 0100644) - - channel.sends_packet(FXP_OPEN, :long, 8, :string, File.join(remote, "subdir1", "file2"), :long, 0x01, :long, 0) - channel.sends_packet(FXP_READDIR, :long, 9, :string, "dir2") - - channel.gets_packet(FXP_DATA, :long, 6, :string, "contents of file1") - channel.sends_packet(FXP_READ, :long, 10, :string, "file1", :int64, 32_000, :long, 32_000) - - channel.gets_packet(FXP_STATUS, :long, 7, :long, 0) - channel.gets_packet(FXP_HANDLE, :long, 8, :string, "file2") - channel.sends_packet(FXP_READ, :long, 11, :string, "file2", :int64, 0, :long, 32_000) - - channel.gets_packet(FXP_STATUS, :long, 9, :long, 1) - channel.sends_packet(FXP_CLOSE, :long, 12, :string, "dir2") - - channel.gets_packet(FXP_STATUS, :long, 10, :long, 1) - channel.sends_packet(FXP_CLOSE, :long, 13, :string, "file1") - - channel.gets_packet(FXP_DATA, :long, 11, :string, "contents of file2") - channel.sends_packet(FXP_READ, :long, 14, :string, "file2", :int64, 32_000, :long, 32_000) - - channel.gets_packet(FXP_STATUS, :long, 12, :long, 0) - channel.gets_packet(FXP_STATUS, :long, 13, :long, 0) - channel.gets_packet(FXP_STATUS, :long, 14, :long, 1) - channel.sends_packet(FXP_CLOSE, :long, 15, :string, "file2") - channel.gets_packet(FXP_STATUS, :long, 15, :long, 0) - end - - File.expects(:directory?).with(local).returns(false) - File.expects(:directory?).with(File.join(local, "subdir1")).returns(false) - Dir.expects(:mkdir).with(local) - Dir.expects(:mkdir).with(File.join(local, "subdir1")) - - file1 = StringIO.new - file2 = StringIO.new - File.expects(:open).with(File.join(local, "file1"), "wb").returns(file1) - File.expects(:open).with(File.join(local, "subdir1", "file2"), "wb").returns(file2) - - [file1, file2] - end -end \ No newline at end of file diff --git a/vendor/gems/net-sftp-2.0.2/test/test_file.rb b/vendor/gems/net-sftp-2.0.2/test/test_file.rb deleted file mode 100644 index 1f5f0e964..000000000 --- a/vendor/gems/net-sftp-2.0.2/test/test_file.rb +++ /dev/null @@ -1,159 +0,0 @@ -require 'common' - -class FileOperationsTest < Net::SFTP::TestCase - def setup - @sftp = mock("sftp") - @file = Net::SFTP::Operations::File.new(@sftp, "handle") - @save_dollar_fslash, $/ = $/, "\n" - @save_dollar_bslash, $\ = $\, nil - end - - def teardown - $/ = @save_dollar_fslash - $\ = @save_dollar_bslash - end - - def test_pos_assignment_should_set_position - @file.pos = 15 - assert_equal 15, @file.pos - end - - def test_pos_assignment_should_reset_eof - @sftp.expects(:read!).with("handle", 0, 8192).returns(nil) - assert !@file.eof? - @file.read - assert @file.eof? - @file.pos = 0 - assert !@file.eof? - end - - def test_close_should_close_handle_and_set_handle_to_nil - assert_equal "handle", @file.handle - @sftp.expects(:close!).with("handle") - @file.close - assert_nil @file.handle - end - - def test_eof_should_be_false_if_at_eof_but_data_remains_in_buffer - @sftp.expects(:read!).returns("hello world", nil) - @file.read(1) - assert !@file.eof? - end - - def test_eof_should_be_true_if_at_eof_and_no_data_in_buffer - @sftp.expects(:read!).times(2).returns("hello world", nil) - @file.read - assert @file.eof? - end - - def test_read_without_argument_should_read_and_return_remainder_of_file_and_set_pos - @sftp.expects(:read!).times(2).returns("hello world", nil) - assert_equal "hello world", @file.read - assert_equal 11, @file.pos - end - - def test_read_with_argument_should_read_and_return_n_bytes_and_set_pos - @sftp.expects(:read!).returns("hello world") - assert_equal "hello", @file.read(5) - assert_equal 5, @file.pos - end - - def test_read_after_pos_assignment_should_read_from_specified_position - @sftp.expects(:read!).with("handle", 5, 8192).returns("hello world") - @file.pos = 5 - assert_equal "hello", @file.read(5) - assert_equal 10, @file.pos - end - - def test_gets_without_argument_should_read_until_first_dollar_fslash - @sftp.expects(:read!).returns("hello world\ngoodbye world\n\nfarewell!\n") - assert_equal "\n", $/ - assert_equal "hello world\n", @file.gets - assert_equal 12, @file.pos - end - - def test_gets_with_empty_argument_should_read_until_double_dollar_fslash - @sftp.expects(:read!).returns("hello world\ngoodbye world\n\nfarewell!\n") - assert_equal "\n", $/ - assert_equal "hello world\ngoodbye world\n\n", @file.gets("") - assert_equal 27, @file.pos - end - - def test_gets_with_argument_should_read_until_first_instance_of_argument - @sftp.expects(:read!).returns("hello world\ngoodbye world\n\nfarewell!\n") - assert_equal "hello w", @file.gets("w") - assert_equal 7, @file.pos - end - - def test_gets_when_no_such_delimiter_exists_in_stream_should_read_to_EOF - @sftp.expects(:read!).times(2).returns("hello world\ngoodbye world\n\nfarewell!\n", nil) - assert_equal "hello world\ngoodbye world\n\nfarewell!\n", @file.gets("X") - assert @file.eof? - end - - def test_gets_at_EOF_should_return_nil - @sftp.expects(:read!).returns(nil) - assert_nil @file.gets - assert @file.eof? - end - - def test_readline_should_raise_exception_on_EOF - @sftp.expects(:read!).returns(nil) - assert_raises(EOFError) { @file.readline } - end - - def test_write_should_write_data_and_increment_pos_and_return_data_length - @sftp.expects(:write!).with("handle", 0, "hello world") - assert_equal 11, @file.write("hello world") - assert_equal 11, @file.pos - end - - def test_write_after_pos_assignment_should_write_at_position - @sftp.expects(:write!).with("handle", 15, "hello world") - @file.pos = 15 - assert_equal 11, @file.write("hello world") - assert_equal 26, @file.pos - end - - def test_print_with_no_arguments_should_write_nothing_if_dollar_bslash_is_nil - assert_nil $\ - @sftp.expects(:write!).never - @file.print - end - - def test_print_with_no_arguments_should_write_dollar_bslash_if_dollar_bslash_is_not_nil - $\ = "-" - @sftp.expects(:write!).with("handle", 0, "-") - @file.print - end - - def test_print_with_arguments_should_write_all_arguments - @sftp.expects(:write!).with("handle", 0, "hello") - @sftp.expects(:write!).with("handle", 5, " ") - @sftp.expects(:write!).with("handle", 6, "world") - @file.print("hello", " ", "world") - end - - def test_puts_should_recursively_puts_array_arguments - 10.times do |i| - @sftp.expects(:write!).with("handle", i*2, i.to_s) - @sftp.expects(:write!).with("handle", i*2+1, "\n") - end - @file.puts 0, [1, [2, 3], 4, [5, [6, 7, 8]]], 9 - end - - def test_puts_should_not_append_newline_if_argument_ends_in_newline - @sftp.expects(:write!).with("handle", 0, "a") - @sftp.expects(:write!).with("handle", 1, "\n") - @sftp.expects(:write!).with("handle", 2, "b\n") - @sftp.expects(:write!).with("handle", 4, "c") - @sftp.expects(:write!).with("handle", 5, "\n") - @file.puts "a", "b\n", "c" - end - - def test_stat_should_return_attributes_object_for_handle - stat = stub("stat") - @sftp.expects(:fstat!).with("handle").returns(stat) - assert_equal stat, @file.stat - end -end \ No newline at end of file diff --git a/vendor/gems/net-sftp-2.0.2/test/test_file_factory.rb b/vendor/gems/net-sftp-2.0.2/test/test_file_factory.rb deleted file mode 100644 index c74fe0683..000000000 --- a/vendor/gems/net-sftp-2.0.2/test/test_file_factory.rb +++ /dev/null @@ -1,48 +0,0 @@ -require "common" - -class FileFactoryTest < Net::SFTP::TestCase - def setup - @sftp = stub(:sftp) - @factory = Net::SFTP::Operations::FileFactory.new(@sftp) - end - - def test_open_with_block_should_yield_and_close_handle - @sftp.expects(:open!).with("/path/to/remote", "r", :permissions => nil).returns("handle") - @sftp.expects(:close!).with("handle") - - called = false - @factory.open("/path/to/remote") do |f| - called = true - assert_instance_of Net::SFTP::Operations::File, f - end - - assert called - end - - def test_open_with_block_should_close_file_even_if_exception_is_raised - @sftp.expects(:open!).with("/path/to/remote", "r", :permissions => nil).returns("handle") - @sftp.expects(:close!).with("handle") - - assert_raises(RuntimeError) do - @factory.open("/path/to/remote") { |f| raise RuntimeError, "b00m" } - end - end - - def test_open_without_block_should_return_new_file - @sftp.expects(:open!).with("/path/to/remote", "r", :permissions => nil).returns("handle") - @sftp.expects(:close!).never - - f = @factory.open("/path/to/remote") - assert_instance_of Net::SFTP::Operations::File, f - end - - def test_directory_should_be_true_for_directory - @sftp.expects(:lstat!).with("/path/to/dir").returns(mock('attrs', :directory? => true)) - assert @factory.directory?("/path/to/dir") - end - - def test_directory_should_be_false_for_non_directory - @sftp.expects(:lstat!).with("/path/to/file").returns(mock('attrs', :directory? => false)) - assert !@factory.directory?("/path/to/file") - end -end \ No newline at end of file diff --git a/vendor/gems/net-sftp-2.0.2/test/test_packet.rb b/vendor/gems/net-sftp-2.0.2/test/test_packet.rb deleted file mode 100644 index e7d14d83d..000000000 --- a/vendor/gems/net-sftp-2.0.2/test/test_packet.rb +++ /dev/null @@ -1,9 +0,0 @@ -require 'common' - -class PacketTest < Net::SFTP::TestCase - def test_packet_should_auto_read_type_byte - packet = Net::SFTP::Packet.new("\001rest-of-packet-here") - assert_equal 1, packet.type - assert_equal "rest-of-packet-here", packet.content[packet.position..-1] - end -end \ No newline at end of file diff --git a/vendor/gems/net-sftp-2.0.2/test/test_protocol.rb b/vendor/gems/net-sftp-2.0.2/test/test_protocol.rb deleted file mode 100644 index 8d246bdf2..000000000 --- a/vendor/gems/net-sftp-2.0.2/test/test_protocol.rb +++ /dev/null @@ -1,17 +0,0 @@ -require 'common' - -class ProtocolTest < Net::SFTP::TestCase - 1.upto(6) do |version| - define_method("test_load_version_#{version}_should_return_v#{version}_driver") do - session = stub('session', :logger => nil) - driver = Net::SFTP::Protocol.load(session, version) - assert_instance_of Net::SFTP::Protocol.const_get("V%02d" % version)::Base, driver - end - end - - def test_load_version_7_should_be_unsupported - assert_raises(NotImplementedError) do - Net::SFTP::Protocol.load(stub('session'), 7) - end - end -end \ No newline at end of file diff --git a/vendor/gems/net-sftp-2.0.2/test/test_request.rb b/vendor/gems/net-sftp-2.0.2/test/test_request.rb deleted file mode 100644 index 4a38668b9..000000000 --- a/vendor/gems/net-sftp-2.0.2/test/test_request.rb +++ /dev/null @@ -1,71 +0,0 @@ -require 'common' - -class RequestTest < Net::SFTP::TestCase - def test_property_setter_should_symbolize_key - request = Net::SFTP::Request.new(stub("session"), :open, 1) - request["key"] = :value - assert_equal :value, request['key'] - assert_equal :value, request[:key] - assert_equal :value, request.properties[:key] - assert_nil request.properties['key'] - end - - def test_pending_should_query_pending_requests_of_session - session = stub("session", :pending_requests => {1 => true}) - request = Net::SFTP::Request.new(session, :open, 1) - assert request.pending? - request = Net::SFTP::Request.new(session, :open, 2) - assert !request.pending? - end - - def test_wait_should_run_loop_while_pending_and_return_self - session = MockSession.new - request = Net::SFTP::Request.new(session, :open, 1) - request.expects(:pending?).times(4).returns(true, true, true, false) - assert_equal 0, session.loops - assert_equal request, request.wait - assert_equal 4, session.loops - end - - def test_respond_to_should_set_response_property - packet = stub("packet", :type => 1) - session = stub("session", :protocol => mock("protocol")) - session.protocol.expects(:parse).with(packet).returns({}) - request = Net::SFTP::Request.new(session, :open, 1) - assert_nil request.response - request.respond_to(packet) - assert_instance_of Net::SFTP::Response, request.response - end - - def test_respond_to_with_callback_should_invoke_callback - packet = stub("packet", :type => 1) - session = stub("session", :protocol => mock("protocol")) - session.protocol.expects(:parse).with(packet).returns({}) - - called = false - request = Net::SFTP::Request.new(session, :open, 1) do |response| - called = true - assert_equal request.response, response - end - - request.respond_to(packet) - assert called - end - - private - - class MockSession - attr_reader :loops - - def initialize - @loops = 0 - end - - def loop - while true - @loops += 1 - break unless yield - end - end - end -end \ No newline at end of file diff --git a/vendor/gems/net-sftp-2.0.2/test/test_response.rb b/vendor/gems/net-sftp-2.0.2/test/test_response.rb deleted file mode 100644 index 010f15eb4..000000000 --- a/vendor/gems/net-sftp-2.0.2/test/test_response.rb +++ /dev/null @@ -1,53 +0,0 @@ -require 'common' - -class ResponseTest < Net::SFTP::TestCase - def test_code_should_default_to_FX_OK - response = Net::SFTP::Response.new(mock("response")) - assert_equal Net::SFTP::Response::FX_OK, response.code - end - - def test_brackets_should_symbolize_key - response = Net::SFTP::Response.new(mock("response"), :handle => "foo") - assert_equal "foo", response['handle'] - end - - def test_to_s_with_nil_message_should_show_default_message - response = Net::SFTP::Response.new(mock("response"), :code => 14) - assert_equal "no space on filesystem (14)", response.to_s - end - - def test_to_s_with_empty_message_should_show_default_message - response = Net::SFTP::Response.new(mock("response"), :code => 14, :message => "") - assert_equal "no space on filesystem (14)", response.to_s - end - - def test_to_s_with_default_message_should_show_default_message - response = Net::SFTP::Response.new(mock("response"), :code => 14, :message => "no space on filesystem") - assert_equal "no space on filesystem (14)", response.to_s - end - - def test_to_s_with_explicit_message_should_show_explicit_message - response = Net::SFTP::Response.new(mock("response"), :code => 14, :message => "out of space") - assert_equal "out of space (no space on filesystem, 14)", response.to_s - end - - def test_ok_should_be_true_when_code_is_FX_OK - response = Net::SFTP::Response.new(mock("response")) - assert_equal true, response.ok? - end - - def test_ok_should_be_false_when_code_is_not_FX_OK - response = Net::SFTP::Response.new(mock("response"), :code => 14) - assert_equal false, response.ok? - end - - def test_eof_should_be_true_when_code_is_FX_EOF - response = Net::SFTP::Response.new(mock("response"), :code => 1) - assert_equal true, response.eof? - end - - def test_eof_should_be_false_when_code_is_not_FX_EOF - response = Net::SFTP::Response.new(mock("response"), :code => 14) - assert_equal false, response.eof? - end -end diff --git a/vendor/gems/net-sftp-2.0.2/test/test_session.rb b/vendor/gems/net-sftp-2.0.2/test/test_session.rb deleted file mode 100644 index a59058aff..000000000 --- a/vendor/gems/net-sftp-2.0.2/test/test_session.rb +++ /dev/null @@ -1,741 +0,0 @@ -require "common" - -class SessionTest < Net::SFTP::TestCase - include Net::SFTP::Constants - include Net::SFTP::Constants::OpenFlags - include Net::SFTP::Constants::PacketTypes - - (1..6).each do |version| - define_method("test_server_reporting_version_#{version}_should_cause_version_#{version}_to_be_used") do - expect_sftp_session :server_version => version - assert_scripted { sftp.connect! } - assert_equal version, sftp.protocol.version - end - end - - def test_v1_open_read_only_that_succeeds_should_invoke_callback - expect_open("/path/to/file", "r", nil, :server_version => 1) - assert_successful_open("/path/to/file") - end - - def test_v1_open_read_only_that_fails_should_invoke_callback - expect_open("/path/to/file", "r", nil, :server_version => 1, :fail => 2) - - assert_command_with_callback(:open, "/path/to/file") do |response| - assert !response.ok? - assert_equal 2, response.code - end - end - - def test_v1_open_write_only_that_succeeds_should_invoke_callback - expect_open("/path/to/file", "w", nil, :server_version => 1) - assert_successful_open("/path/to/file", "w") - end - - def test_v1_open_read_write_that_succeeds_should_invoke_callback - expect_open("/path/to/file", "rw", nil, :server_version => 1) - assert_successful_open("/path/to/file", "r+") - end - - def test_v1_open_append_that_succeeds_should_invoke_callback - expect_open("/path/to/file", "a", nil, :server_version => 1) - assert_successful_open("/path/to/file", "a") - end - - def test_v1_open_with_permissions_should_specify_permissions - expect_open("/path/to/file", "r", 0765, :server_version => 1) - assert_successful_open("/path/to/file", "r", :permissions => 0765) - end - - def test_v4_open_with_permissions_should_specify_permissions - expect_open("/path/to/file", "r", 0765, :server_version => 4) - assert_successful_open("/path/to/file", "r", :permissions => 0765) - end - - def test_v5_open_read_only_shuld_invoke_callback - expect_open("/path/to/file", "r", 0765, :server_version => 5) - assert_successful_open("/path/to/file", "r", :permissions => 0765) - end - - def test_v6_open_with_permissions_should_specify_permissions - expect_open("/path/to/file", "r", 0765, :server_version => 6) - assert_successful_open("/path/to/file", "r", :permissions => 0765) - end - - def test_open_bang_should_block_and_return_handle - expect_open("/path/to/file", "r", nil) - handle = assert_synchronous_command(:open!, "/path/to/file", "r") - assert_equal "handle", handle - end - - def test_open_bang_should_block_and_raise_exception_on_error - expect_open("/path/to/file", "r", nil, :fail => 5) - assert_raises(Net::SFTP::StatusException) do - assert_synchronous_command(:open!, "/path/to/file", "r") - end - end - - def test_close_should_send_close_request_and_invoke_callback - expect_sftp_session do |channel| - channel.sends_packet(FXP_CLOSE, :long, 0, :string, "handle") - channel.gets_packet(FXP_STATUS, :long, 0, :long, 0) - end - - assert_command_with_callback(:close, "handle") { |r| assert r.ok? } - end - - def test_close_bang_should_block_and_return_response - expect_sftp_session do |channel| - channel.sends_packet(FXP_CLOSE, :long, 0, :string, "handle") - channel.gets_packet(FXP_STATUS, :long, 0, :long, 0) - end - - response = assert_synchronous_command(:close!, "handle") - assert response.ok? - end - - def test_read_should_send_read_request_and_invoke_callback - expect_sftp_session do |channel| - channel.sends_packet(FXP_READ, :long, 0, :string, "handle", :int64, 512123, :long, 1024) - channel.gets_packet(FXP_DATA, :long, 0, :string, "this is some data!") - end - - assert_command_with_callback(:read, "handle", 512123, 1024) do |response| - assert response.ok? - assert_equal "this is some data!", response[:data] - end - end - - def test_read_bang_should_block_and_return_data - expect_sftp_session do |channel| - channel.sends_packet(FXP_READ, :long, 0, :string, "handle", :int64, 512123, :long, 1024) - channel.gets_packet(FXP_DATA, :long, 0, :string, "this is some data!") - end - - data = assert_synchronous_command(:read!, "handle", 512123, 1024) - assert_equal "this is some data!", data - end - - def test_read_bang_should_block_and_return_nil_on_eof - expect_sftp_session do |channel| - channel.sends_packet(FXP_READ, :long, 0, :string, "handle", :int64, 512123, :long, 1024) - channel.gets_packet(FXP_STATUS, :long, 0, :long, 1) - end - - data = assert_synchronous_command(:read!, "handle", 512123, 1024) - assert_nil data - end - - def test_write_should_send_write_request_and_invoke_callback - expect_sftp_session do |channel| - channel.sends_packet(FXP_WRITE, :long, 0, :string, "handle", :int64, 512123, :string, "this is some data!") - channel.gets_packet(FXP_STATUS, :long, 0, :long, 0) - end - - assert_command_with_callback(:write, "handle", 512123, "this is some data!") do |response| - assert response.ok? - end - end - - def test_write_bang_should_block_and_return_response - expect_sftp_session do |channel| - channel.sends_packet(FXP_WRITE, :long, 0, :string, "handle", :int64, 512123, :string, "this is some data!") - channel.gets_packet(FXP_STATUS, :long, 0, :long, 0) - end - - response = assert_synchronous_command(:write!, "handle", 512123, "this is some data!") - assert response.ok? - end - - def test_v1_lstat_should_send_lstat_request_and_invoke_callback - expect_sftp_session :server_version => 1 do |channel| - channel.sends_packet(FXP_LSTAT, :long, 0, :string, "/path/to/file") - channel.gets_packet(FXP_ATTRS, :long, 0, :long, 0xF, :int64, 123456, :long, 1, :long, 2, :long, 0765, :long, 123456789, :long, 234567890) - end - - assert_command_with_callback(:lstat, "/path/to/file") do |response| - assert response.ok? - assert_equal 123456, response[:attrs].size - assert_equal 1, response[:attrs].uid - assert_equal 2, response[:attrs].gid - assert_equal 0765, response[:attrs].permissions - assert_equal 123456789, response[:attrs].atime - assert_equal 234567890, response[:attrs].mtime - end - end - - def test_v4_lstat_should_send_default_flags_parameter - expect_sftp_session :server_version => 4 do |channel| - channel.sends_packet(FXP_LSTAT, :long, 0, :string, "/path/to/file", :long, 0x800001fd) - channel.gets_packet(FXP_STATUS, :long, 0, :long, 2) - end - - assert_command_with_callback(:lstat, "/path/to/file") - end - - def test_v4_lstat_should_honor_flags_parameter - expect_sftp_session :server_version => 4 do |channel| - channel.sends_packet(FXP_LSTAT, :long, 0, :string, "/path/to/file", :long, 0x1) - channel.gets_packet(FXP_STATUS, :long, 0, :long, 2) - end - - assert_command_with_callback(:lstat, "/path/to/file", 0x1) - end - - def test_lstat_bang_should_block_and_return_attrs - expect_sftp_session :server_version => 1 do |channel| - channel.sends_packet(FXP_LSTAT, :long, 0, :string, "/path/to/file") - channel.gets_packet(FXP_ATTRS, :long, 0, :long, 0xF, :int64, 123456, :long, 1, :long, 2, :long, 0765, :long, 123456789, :long, 234567890) - end - - attrs = assert_synchronous_command(:lstat!, "/path/to/file") - - assert_equal 123456, attrs.size - assert_equal 1, attrs.uid - assert_equal 2, attrs.gid - assert_equal 0765, attrs.permissions - assert_equal 123456789, attrs.atime - assert_equal 234567890, attrs.mtime - end - - def test_v1_fstat_should_send_fstat_request_and_invoke_callback - expect_sftp_session :server_version => 1 do |channel| - channel.sends_packet(FXP_FSTAT, :long, 0, :string, "handle") - channel.gets_packet(FXP_ATTRS, :long, 0, :long, 0xF, :int64, 123456, :long, 1, :long, 2, :long, 0765, :long, 123456789, :long, 234567890) - end - - assert_command_with_callback(:fstat, "handle") do |response| - assert response.ok? - assert_equal 123456, response[:attrs].size - assert_equal 1, response[:attrs].uid - assert_equal 2, response[:attrs].gid - assert_equal 0765, response[:attrs].permissions - assert_equal 123456789, response[:attrs].atime - assert_equal 234567890, response[:attrs].mtime - end - end - - def test_v4_fstat_should_send_default_flags_parameter - expect_sftp_session :server_version => 4 do |channel| - channel.sends_packet(FXP_FSTAT, :long, 0, :string, "handle", :long, 0x800001fd) - channel.gets_packet(FXP_STATUS, :long, 0, :long, 2) - end - - assert_command_with_callback(:fstat, "handle") - end - - def test_v4_fstat_should_honor_flags_parameter - expect_sftp_session :server_version => 4 do |channel| - channel.sends_packet(FXP_FSTAT, :long, 0, :string, "handle", :long, 0x1) - channel.gets_packet(FXP_STATUS, :long, 0, :long, 2) - end - - assert_command_with_callback(:fstat, "handle", 0x1) - end - - def test_fstat_bang_should_block_and_return_attrs - expect_sftp_session :server_version => 1 do |channel| - channel.sends_packet(FXP_FSTAT, :long, 0, :string, "handle") - channel.gets_packet(FXP_ATTRS, :long, 0, :long, 0xF, :int64, 123456, :long, 1, :long, 2, :long, 0765, :long, 123456789, :long, 234567890) - end - - attrs = assert_synchronous_command(:fstat!, "handle") - - assert_equal 123456, attrs.size - assert_equal 1, attrs.uid - assert_equal 2, attrs.gid - assert_equal 0765, attrs.permissions - assert_equal 123456789, attrs.atime - assert_equal 234567890, attrs.mtime - end - - def test_v1_setstat_should_send_v1_attributes - expect_sftp_session :server_version => 1 do |channel| - channel.sends_packet(FXP_SETSTAT, :long, 0, :string, "/path/to/file", :long, 0xc, :long, 0765, :long, 1234567890, :long, 2345678901) - channel.gets_packet(FXP_STATUS, :long, 0, :long, 0) - end - - assert_command_with_callback(:setstat, "/path/to/file", :permissions => 0765, :atime => 1234567890, :mtime => 2345678901) - end - - def test_v4_setstat_should_send_v4_attributes - expect_sftp_session :server_version => 4 do |channel| - channel.sends_packet(FXP_SETSTAT, :long, 0, :string, "/path/to/file", :long, 0x2c, :byte, 1, :long, 0765, :int64, 1234567890, :int64, 2345678901) - channel.gets_packet(FXP_STATUS, :long, 0, :long, 0) - end - - assert_command_with_callback(:setstat, "/path/to/file", :permissions => 0765, :atime => 1234567890, :mtime => 2345678901) - end - - def test_v6_setstat_should_send_v6_attributes - expect_sftp_session :server_version => 6 do |channel| - channel.sends_packet(FXP_SETSTAT, :long, 0, :string, "/path/to/file", :long, 0x102c, :byte, 1, :long, 0765, :int64, 1234567890, :int64, 2345678901, :string, "text/plain") - channel.gets_packet(FXP_STATUS, :long, 0, :long, 0) - end - - assert_command_with_callback(:setstat, "/path/to/file", :permissions => 0765, :atime => 1234567890, :mtime => 2345678901, :mime_type => "text/plain") - end - - def test_setstat_bang_should_block_and_return_response - expect_sftp_session :server_version => 1 do |channel| - channel.sends_packet(FXP_SETSTAT, :long, 0, :string, "/path/to/file", :long, 0xc, :long, 0765, :long, 1234567890, :long, 2345678901) - channel.gets_packet(FXP_STATUS, :long, 0, :long, 0) - end - - response = assert_synchronous_command(:setstat!, "/path/to/file", :permissions => 0765, :atime => 1234567890, :mtime => 2345678901) - assert response.ok? - end - - def test_v1_fsetstat_should_send_v1_attributes - expect_sftp_session :server_version => 1 do |channel| - channel.sends_packet(FXP_FSETSTAT, :long, 0, :string, "handle", :long, 0xc, :long, 0765, :long, 1234567890, :long, 2345678901) - channel.gets_packet(FXP_STATUS, :long, 0, :long, 0) - end - - assert_command_with_callback(:fsetstat, "handle", :permissions => 0765, :atime => 1234567890, :mtime => 2345678901) - end - - def test_v4_fsetstat_should_send_v4_attributes - expect_sftp_session :server_version => 4 do |channel| - channel.sends_packet(FXP_FSETSTAT, :long, 0, :string, "handle", :long, 0x2c, :byte, 1, :long, 0765, :int64, 1234567890, :int64, 2345678901) - channel.gets_packet(FXP_STATUS, :long, 0, :long, 0) - end - - assert_command_with_callback(:fsetstat, "handle", :permissions => 0765, :atime => 1234567890, :mtime => 2345678901) - end - - def test_v6_fsetstat_should_send_v6_attributes - expect_sftp_session :server_version => 6 do |channel| - channel.sends_packet(FXP_FSETSTAT, :long, 0, :string, "handle", :long, 0x102c, :byte, 1, :long, 0765, :int64, 1234567890, :int64, 2345678901, :string, "text/plain") - channel.gets_packet(FXP_STATUS, :long, 0, :long, 0) - end - - assert_command_with_callback(:fsetstat, "handle", :permissions => 0765, :atime => 1234567890, :mtime => 2345678901, :mime_type => "text/plain") - end - - def test_fsetstat_bang_should_block_and_return_response - expect_sftp_session :server_version => 1 do |channel| - channel.sends_packet(FXP_FSETSTAT, :long, 0, :string, "handle", :long, 0xc, :long, 0765, :long, 1234567890, :long, 2345678901) - channel.gets_packet(FXP_STATUS, :long, 0, :long, 0) - end - - response = assert_synchronous_command(:fsetstat!, "handle", :permissions => 0765, :atime => 1234567890, :mtime => 2345678901) - assert response.ok? - end - - def test_opendir_should_send_opendir_request_and_invoke_callback - expect_sftp_session do |channel| - channel.sends_packet(FXP_OPENDIR, :long, 0, :string, "/path/to/dir") - channel.gets_packet(FXP_HANDLE, :long, 0, :string, "handle") - end - - assert_command_with_callback(:opendir, "/path/to/dir") - end - - def test_opendir_bang_should_block_and_return_handle - expect_sftp_session do |channel| - channel.sends_packet(FXP_OPENDIR, :long, 0, :string, "/path/to/dir") - channel.gets_packet(FXP_HANDLE, :long, 0, :string, "handle") - end - - handle = assert_synchronous_command(:opendir!, "/path/to/dir") - assert_equal "handle", handle - end - - def test_readdir_should_send_readdir_request_and_invoke_callback - expect_sftp_session do |channel| - channel.sends_packet(FXP_READDIR, :long, 0, :string, "handle") - channel.gets_packet(FXP_STATUS, :long, 0, :long, 1) - end - - assert_command_with_callback(:readdir, "handle") { |r| assert r.eof? } - end - - def test_readdir_bang_should_block_and_return_names_array - expect_sftp_session :server_version => 1 do |channel| - channel.sends_packet(FXP_READDIR, :long, 0, :string, "handle") - channel.gets_packet(FXP_NAME, :long, 0, :long, 2, - :string, "first", :string, "longfirst", :long, 0x0, - :string, "next", :string, "longnext", :long, 0x0) - end - - names = assert_synchronous_command(:readdir!, "handle") - assert_equal 2, names.length - assert_equal %w(first next), names.map { |n| n.name } - end - - def test_remove_should_send_remove_packet - expect_sftp_session do |channel| - channel.sends_packet(FXP_REMOVE, :long, 0, :string, "/path/to/file") - channel.gets_packet(FXP_STATUS, :long, 0, :long, 0) - end - - assert_command_with_callback(:remove, "/path/to/file") - end - - def test_remove_bang_should_block_and_return_response - expect_sftp_session do |channel| - channel.sends_packet(FXP_REMOVE, :long, 0, :string, "/path/to/file") - channel.gets_packet(FXP_STATUS, :long, 0, :long, 0) - end - - response = assert_synchronous_command(:remove!, "/path/to/file") - assert response.ok? - end - - def test_mkdir_should_send_mkdir_packet - expect_sftp_session do |channel| - channel.sends_packet(FXP_MKDIR, :long, 0, :string, "/path/to/dir", :long, 0x4, :byte, 1, :long, 0765) - channel.gets_packet(FXP_STATUS, :long, 0, :long, 0) - end - - assert_command_with_callback(:mkdir, "/path/to/dir", :permissions => 0765) - end - - def test_mkdir_bang_should_block_and_return_response - expect_sftp_session do |channel| - channel.sends_packet(FXP_MKDIR, :long, 0, :string, "/path/to/dir", :long, 0x4, :byte, 1, :long, 0765) - channel.gets_packet(FXP_STATUS, :long, 0, :long, 0) - end - - response = assert_synchronous_command(:mkdir!, "/path/to/dir", :permissions => 0765) - assert response.ok? - end - - def test_rmdir_should_send_rmdir_packet - expect_sftp_session do |channel| - channel.sends_packet(FXP_RMDIR, :long, 0, :string, "/path/to/dir") - channel.gets_packet(FXP_STATUS, :long, 0, :long, 0) - end - - assert_command_with_callback(:rmdir, "/path/to/dir") - end - - def test_rmdir_bang_should_block_and_return_response - expect_sftp_session do |channel| - channel.sends_packet(FXP_RMDIR, :long, 0, :string, "/path/to/dir") - channel.gets_packet(FXP_STATUS, :long, 0, :long, 0) - end - - response = assert_synchronous_command(:rmdir!, "/path/to/dir") - assert response.ok? - end - - def test_realpath_should_send_realpath_packet - expect_sftp_session do |channel| - channel.sends_packet(FXP_REALPATH, :long, 0, :string, "/path/to/dir") - channel.gets_packet(FXP_STATUS, :long, 0, :long, 2) - end - - assert_command_with_callback(:realpath, "/path/to/dir") - end - - def test_realpath_bang_should_block_and_return_names_item - expect_sftp_session do |channel| - channel.sends_packet(FXP_REALPATH, :long, 0, :string, "/path/to/dir") - channel.gets_packet(FXP_NAME, :long, 0, :long, 1, :string, "dir", :long, 0x0, :long, 2) - end - - name = assert_synchronous_command(:realpath!, "/path/to/dir") - assert_equal "dir", name.name - end - - def test_v1_stat_should_send_stat_request_and_invoke_callback - expect_sftp_session :server_version => 1 do |channel| - channel.sends_packet(FXP_STAT, :long, 0, :string, "/path/to/file") - channel.gets_packet(FXP_ATTRS, :long, 0, :long, 0xF, :int64, 123456, :long, 1, :long, 2, :long, 0765, :long, 123456789, :long, 234567890) - end - - assert_command_with_callback(:stat, "/path/to/file") do |response| - assert response.ok? - assert_equal 123456, response[:attrs].size - assert_equal 1, response[:attrs].uid - assert_equal 2, response[:attrs].gid - assert_equal 0765, response[:attrs].permissions - assert_equal 123456789, response[:attrs].atime - assert_equal 234567890, response[:attrs].mtime - end - end - - def test_v4_stat_should_send_default_flags_parameter - expect_sftp_session :server_version => 4 do |channel| - channel.sends_packet(FXP_STAT, :long, 0, :string, "/path/to/file", :long, 0x800001fd) - channel.gets_packet(FXP_STATUS, :long, 0, :long, 2) - end - - assert_command_with_callback(:stat, "/path/to/file") - end - - def test_v4_stat_should_honor_flags_parameter - expect_sftp_session :server_version => 4 do |channel| - channel.sends_packet(FXP_STAT, :long, 0, :string, "/path/to/file", :long, 0x1) - channel.gets_packet(FXP_STATUS, :long, 0, :long, 2) - end - - assert_command_with_callback(:stat, "/path/to/file", 0x1) - end - - def test_stat_bang_should_block_and_return_attrs - expect_sftp_session :server_version => 1 do |channel| - channel.sends_packet(FXP_STAT, :long, 0, :string, "/path/to/file") - channel.gets_packet(FXP_ATTRS, :long, 0, :long, 0xF, :int64, 123456, :long, 1, :long, 2, :long, 0765, :long, 123456789, :long, 234567890) - end - - attrs = assert_synchronous_command(:stat!, "/path/to/file") - - assert_equal 123456, attrs.size - assert_equal 1, attrs.uid - assert_equal 2, attrs.gid - assert_equal 0765, attrs.permissions - assert_equal 123456789, attrs.atime - assert_equal 234567890, attrs.mtime - end - - def test_v1_rename_should_be_unimplemented - assert_not_implemented 1, :rename, "from", "to" - end - - def test_v2_rename_should_send_rename_packet - expect_sftp_session :server_version => 2 do |channel| - channel.sends_packet(FXP_RENAME, :long, 0, :string, "from", :string, "to") - channel.gets_packet(FXP_STATUS, :long, 0, :long, 0) - end - - assert_command_with_callback(:rename, "from", "to") - end - - def test_v5_rename_should_send_rename_packet_and_default_flags - expect_sftp_session :server_version => 5 do |channel| - channel.sends_packet(FXP_RENAME, :long, 0, :string, "from", :string, "to", :long, 0) - channel.gets_packet(FXP_STATUS, :long, 0, :long, 0) - end - - assert_command_with_callback(:rename, "from", "to") - end - - def test_v5_rename_should_send_rename_packet_and_honor_flags - expect_sftp_session :server_version => 5 do |channel| - channel.sends_packet(FXP_RENAME, :long, 0, :string, "from", :string, "to", :long, 1) - channel.gets_packet(FXP_STATUS, :long, 0, :long, 0) - end - - assert_command_with_callback(:rename, "from", "to", 1) - end - - def test_rename_bang_should_block_and_return_response - expect_sftp_session :server_version => 2 do |channel| - channel.sends_packet(FXP_RENAME, :long, 0, :string, "from", :string, "to") - channel.gets_packet(FXP_STATUS, :long, 0, :long, 0) - end - - response = assert_synchronous_command(:rename!, "from", "to") - assert response.ok? - end - - def test_v2_readlink_should_be_unimplemented - assert_not_implemented 2, :readlink, "/path/to/link" - end - - def test_v3_readlink_should_send_readlink_packet - expect_sftp_session :server_version => 3 do |channel| - channel.sends_packet(FXP_READLINK, :long, 0, :string, "/path/to/link") - channel.gets_packet(FXP_STATUS, :long, 0, :long, 2) - end - - assert_command_with_callback(:readlink, "/path/to/link") - end - - def test_readlink_bang_should_block_and_return_name - expect_sftp_session :server_version => 3 do |channel| - channel.sends_packet(FXP_READLINK, :long, 0, :string, "/path/to/link") - channel.gets_packet(FXP_NAME, :long, 0, :long, 1, :string, "target", :string, "longtarget", :long, 0x0) - end - - name = assert_synchronous_command(:readlink!, "/path/to/link") - assert_equal "target", name.name - end - - def test_v2_symlink_should_be_unimplemented - assert_not_implemented 2, :symlink, "/path/to/source", "/path/to/link" - end - - def test_v3_symlink_should_send_symlink_packet - expect_sftp_session :server_version => 3 do |channel| - channel.sends_packet(FXP_SYMLINK, :long, 0, :string, "/path/to/source", :string, "/path/to/link") - channel.gets_packet(FXP_STATUS, :long, 0, :long, 0) - end - - assert_command_with_callback(:symlink, "/path/to/source", "/path/to/link") - end - - def test_v6_symlink_should_send_link_packet - expect_sftp_session :server_version => 6 do |channel| - channel.sends_packet(FXP_LINK, :long, 0, :string, "/path/to/link", :string, "/path/to/source", :bool, true) - channel.gets_packet(FXP_STATUS, :long, 0, :long, 0) - end - - assert_command_with_callback(:symlink, "/path/to/link", "/path/to/source") - end - - def test_symlink_bang_should_block_and_return_response - expect_sftp_session :server_version => 3 do |channel| - channel.sends_packet(FXP_SYMLINK, :long, 0, :string, "/path/to/source", :string, "/path/to/link") - channel.gets_packet(FXP_STATUS, :long, 0, :long, 0) - end - - response = assert_synchronous_command(:symlink!, "/path/to/source", "/path/to/link") - assert response.ok? - end - - def test_v5_link_should_be_unimplemented - assert_not_implemented 5, :link, "/path/to/source", "/path/to/link", true - end - - def test_v6_link_should_send_link_packet - expect_sftp_session :server_version => 6 do |channel| - channel.sends_packet(FXP_LINK, :long, 0, :string, "/path/to/link", :string, "/path/to/source", :bool, true) - channel.gets_packet(FXP_STATUS, :long, 0, :long, 0) - end - - assert_command_with_callback(:link, "/path/to/link", "/path/to/source", true) - end - - def test_link_bang_should_block_and_return_response - expect_sftp_session :server_version => 6 do |channel| - channel.sends_packet(FXP_LINK, :long, 0, :string, "/path/to/link", :string, "/path/to/source", :bool, true) - channel.gets_packet(FXP_STATUS, :long, 0, :long, 0) - end - - response = assert_synchronous_command(:link!, "/path/to/link", "/path/to/source", true) - assert response.ok? - end - - def test_v5_block_should_be_unimplemented - assert_not_implemented 5, :block, "handle", 12345, 67890, 0xabcd - end - - def test_v6_block_should_send_block_packet - expect_sftp_session :server_version => 6 do |channel| - channel.sends_packet(FXP_BLOCK, :long, 0, :string, "handle", :int64, 12345, :int64, 67890, :long, 0xabcd) - channel.gets_packet(FXP_STATUS, :long, 0, :long, 0) - end - - assert_command_with_callback(:block, "handle", 12345, 67890, 0xabcd) - end - - def test_block_bang_should_block_and_return_response - expect_sftp_session :server_version => 6 do |channel| - channel.sends_packet(FXP_BLOCK, :long, 0, :string, "handle", :int64, 12345, :int64, 67890, :long, 0xabcd) - channel.gets_packet(FXP_STATUS, :long, 0, :long, 0) - end - - response = assert_synchronous_command(:block!, "handle", 12345, 67890, 0xabcd) - assert response.ok? - end - - def test_v5_unblock_should_be_unimplemented - assert_not_implemented 5, :unblock, "handle", 12345, 67890 - end - - def test_v6_unblock_should_send_block_packet - expect_sftp_session :server_version => 6 do |channel| - channel.sends_packet(FXP_UNBLOCK, :long, 0, :string, "handle", :int64, 12345, :int64, 67890) - channel.gets_packet(FXP_STATUS, :long, 0, :long, 0) - end - - assert_command_with_callback(:unblock, "handle", 12345, 67890) - end - - def test_unblock_bang_should_block_and_return_response - expect_sftp_session :server_version => 6 do |channel| - channel.sends_packet(FXP_UNBLOCK, :long, 0, :string, "handle", :int64, 12345, :int64, 67890) - channel.gets_packet(FXP_STATUS, :long, 0, :long, 0) - end - - response = assert_synchronous_command(:unblock!, "handle", 12345, 67890) - assert response.ok? - end - - private - - def assert_not_implemented(server_version, command, *args) - expect_sftp_session :server_version => 1 - sftp.connect! - assert_raises(NotImplementedError) { sftp.send(command, *args) } - end - - def assert_command_with_callback(command, *args) - called = false - assert_scripted_command do - sftp.send(command, *args) do |response| - called = true - yield response if block_given? - end - end - assert called, "expected callback to be invoked, but it wasn't" - end - - def assert_synchronous_command(command, *args) - assert_scripted_command do - sequence = [:start] - result = sftp.send(command, *args) do |response| - sequence << :done - yield response if block_given? - end - sequence << :after - assert_equal [:start, :done, :after], sequence, "expected #{command} to be synchronous" - return result - end - end - - def assert_successful_open(*args) - assert_command_with_callback(:open, *args) do |response| - assert response.ok? - assert_equal "handle", response[:handle] - end - end - - def expect_open(path, mode, perms, options={}) - version = options[:server_version] || 6 - - fail = options.delete(:fail) - - attrs = [:long, perms ? 0x4 : 0] - attrs += [:byte, 1] if version >= 4 - attrs += [:long, perms] if perms - - expect_sftp_session(options) do |channel| - if version >= 5 - flags, access = case mode - when "r" then - [FV5::OPEN_EXISTING, ACE::Mask::READ_DATA | ACE::Mask::READ_ATTRIBUTES] - when "w" then - [FV5::CREATE_TRUNCATE, ACE::Mask::WRITE_DATA | ACE::Mask::WRITE_ATTRIBUTES] - when "rw" then - [FV5::OPEN_OR_CREATE, ACE::Mask::READ_DATA | ACE::Mask::READ_ATTRIBUTES | ACE::Mask::WRITE_DATA | ACE::Mask::WRITE_ATTRIBUTES] - when "a" then - [FV5::OPEN_OR_CREATE | FV5::APPEND_DATA, ACE::Mask::WRITE_DATA | ACE::Mask::WRITE_ATTRIBUTES | ACE::Mask::APPEND_DATA] - else raise ArgumentError, "unsupported mode #{mode.inspect}" - end - - channel.sends_packet(FXP_OPEN, :long, 0, :string, path, :long, access, :long, flags, *attrs) - else - flags = case mode - when "r" then FV1::READ - when "w" then FV1::WRITE | FV1::TRUNC | FV1::CREAT - when "rw" then FV1::WRITE | FV1::READ - when "a" then FV1::APPEND | FV1::WRITE | FV1::CREAT - else raise ArgumentError, "unsupported mode #{mode.inspect}" - end - - channel.sends_packet(FXP_OPEN, :long, 0, :string, path, :long, flags, *attrs) - end - - if fail - channel.gets_packet(FXP_STATUS, :long, 0, :long, fail) - else - channel.gets_packet(FXP_HANDLE, :long, 0, :string, "handle") - end - end - end -end diff --git a/vendor/gems/net-sftp-2.0.2/test/test_upload.rb b/vendor/gems/net-sftp-2.0.2/test/test_upload.rb deleted file mode 100644 index 670a194e5..000000000 --- a/vendor/gems/net-sftp-2.0.2/test/test_upload.rb +++ /dev/null @@ -1,219 +0,0 @@ -require "common" - -class UploadTest < Net::SFTP::TestCase - def setup - prepare_progress! - end - - def test_upload_file_should_send_file_contents - expect_file_transfer("/path/to/local", "/path/to/remote", "here are the contents") - assert_scripted_command { sftp.upload("/path/to/local", "/path/to/remote") } - end - - def test_upload_file_with_progress_should_report_progress - expect_file_transfer("/path/to/local", "/path/to/remote", "here are the contents") - - assert_scripted_command do - sftp.upload("/path/to/local", "/path/to/remote") { |*args| record_progress(args) } - end - - assert_progress_reported_open(:remote => "/path/to/remote") - assert_progress_reported_put(0, "here are the contents", :remote => "/path/to/remote") - assert_progress_reported_close(:remote => "/path/to/remote") - assert_progress_reported_finish - assert_no_more_reported_events - end - - def test_upload_file_with_progress_handler_should_report_progress - expect_file_transfer("/path/to/local", "/path/to/remote", "here are the contents") - - assert_scripted_command do - sftp.upload("/path/to/local", "/path/to/remote", :progress => ProgressHandler.new(@progress)) - end - - assert_progress_reported_open(:remote => "/path/to/remote") - assert_progress_reported_put(0, "here are the contents", :remote => "/path/to/remote") - assert_progress_reported_close(:remote => "/path/to/remote") - assert_progress_reported_finish - assert_no_more_reported_events - end - - def test_upload_file_should_read_chunks_of_size(requested_size=nil) - size = requested_size || Net::SFTP::Operations::Upload::DEFAULT_READ_SIZE - expect_sftp_session :server_version => 3 do |channel| - channel.sends_packet(FXP_OPEN, :long, 0, :string, "/path/to/remote", :long, 0x1A, :long, 0) - channel.gets_packet(FXP_HANDLE, :long, 0, :string, "handle") - channel.sends_packet(FXP_WRITE, :long, 1, :string, "handle", :int64, 0, :string, "a" * size) - channel.sends_packet(FXP_WRITE, :long, 2, :string, "handle", :int64, size, :string, "b" * size) - channel.sends_packet(FXP_WRITE, :long, 3, :string, "handle", :int64, size*2, :string, "c" * size) - channel.gets_packet(FXP_STATUS, :long, 1, :long, 0) - channel.sends_packet(FXP_WRITE, :long, 4, :string, "handle", :int64, size*3, :string, "d" * size) - channel.gets_packet(FXP_STATUS, :long, 2, :long, 0) - channel.sends_packet(FXP_CLOSE, :long, 5, :string, "handle") - channel.gets_packet(FXP_STATUS, :long, 3, :long, 0) - channel.gets_packet(FXP_STATUS, :long, 4, :long, 0) - channel.gets_packet(FXP_STATUS, :long, 5, :long, 0) - end - - expect_file("/path/to/local", "a" * size + "b" * size + "c" * size + "d" * size) - - assert_scripted_command do - opts = {} - opts[:read_size] = size if requested_size - sftp.upload("/path/to/local", "/path/to/remote", opts) - end - end - - def test_upload_file_with_custom_read_size_should_read_chunks_of_that_size - test_upload_file_should_read_chunks_of_size(100) - end - - def test_upload_file_with_custom_requests_should_start_that_many_writes - size = Net::SFTP::Operations::Upload::DEFAULT_READ_SIZE - expect_sftp_session :server_version => 3 do |channel| - channel.sends_packet(FXP_OPEN, :long, 0, :string, "/path/to/remote", :long, 0x1A, :long, 0) - channel.gets_packet(FXP_HANDLE, :long, 0, :string, "handle") - channel.sends_packet(FXP_WRITE, :long, 1, :string, "handle", :int64, 0, :string, "a" * size) - channel.sends_packet(FXP_WRITE, :long, 2, :string, "handle", :int64, size, :string, "b" * size) - channel.sends_packet(FXP_WRITE, :long, 3, :string, "handle", :int64, size*2, :string, "c" * size) - channel.sends_packet(FXP_WRITE, :long, 4, :string, "handle", :int64, size*3, :string, "d" * size) - channel.gets_packet(FXP_STATUS, :long, 1, :long, 0) - channel.sends_packet(FXP_CLOSE, :long, 5, :string, "handle") - channel.gets_packet(FXP_STATUS, :long, 2, :long, 0) - channel.gets_packet(FXP_STATUS, :long, 3, :long, 0) - channel.gets_packet(FXP_STATUS, :long, 4, :long, 0) - channel.gets_packet(FXP_STATUS, :long, 5, :long, 0) - end - - expect_file("/path/to/local", "a" * size + "b" * size + "c" * size + "d" * size) - - assert_scripted_command do - sftp.upload("/path/to/local", "/path/to/remote", :requests => 3) - end - end - - def test_upload_directory_should_mirror_directory_structure_remotely - prepare_directory - - assert_scripted_command do - sftp.upload("/path/to/local", "/path/to/remote") - end - end - - def test_upload_directory_with_handler_should_report_progress - prepare_directory - - assert_scripted_command do - sftp.upload("/path/to/local", "/path/to/remote") { |*args| record_progress(args) } - end - - assert_progress_reported_open(:remote => "/path/to/remote/file1") - assert_progress_reported_open(:remote => "/path/to/remote/file2") - assert_progress_reported_open(:remote => "/path/to/remote/file3") - assert_progress_reported_mkdir("/path/to/remote/subdir") - assert_progress_reported_open(:remote => "/path/to/remote/subdir/other1") - assert_progress_reported_open(:remote => "/path/to/remote/subdir/other2") - assert_progress_reported_put(0, "contents of file1", :remote => "/path/to/remote/file1") - assert_progress_reported_put(0, "contents of file2", :remote => "/path/to/remote/file2") - assert_progress_reported_put(0, "contents of file3", :remote => "/path/to/remote/file3") - assert_progress_reported_close(:remote => "/path/to/remote/file1") - assert_progress_reported_put(0, "contents of other1", :remote => "/path/to/remote/subdir/other1") - assert_progress_reported_put(0, "contents of other2", :remote => "/path/to/remote/subdir/other2") - assert_progress_reported_close(:remote => "/path/to/remote/file2") - assert_progress_reported_close(:remote => "/path/to/remote/file3") - assert_progress_reported_close(:remote => "/path/to/remote/subdir/other1") - assert_progress_reported_close(:remote => "/path/to/remote/subdir/other2") - assert_progress_reported_finish - assert_no_more_reported_events - end - - def test_upload_io_should_send_io_as_file - expect_sftp_session :server_version => 3 do |channel| - channel.sends_packet(FXP_OPEN, :long, 0, :string, "/path/to/remote", :long, 0x1A, :long, 0) - channel.gets_packet(FXP_HANDLE, :long, 0, :string, "handle") - channel.sends_packet(FXP_WRITE, :long, 1, :string, "handle", :int64, 0, :string, "this is some text") - channel.sends_packet(FXP_CLOSE, :long, 2, :string, "handle") - channel.gets_packet(FXP_STATUS, :long, 1, :long, 0) - channel.gets_packet(FXP_STATUS, :long, 2, :long, 0) - end - - assert_scripted_command do - sftp.upload(StringIO.new("this is some text"), "/path/to/remote") - end - end - - private - - def prepare_directory - expect_directory("/path/to/local", %w(. .. file1 file2 file3 subdir)) - expect_directory("/path/to/local/subdir", %w(. .. other1 other2)) - expect_file("/path/to/local/file1", "contents of file1") - expect_file("/path/to/local/file2", "contents of file2") - expect_file("/path/to/local/file3", "contents of file3") - expect_file("/path/to/local/subdir/other1", "contents of other1") - expect_file("/path/to/local/subdir/other2", "contents of other2") - - expect_sftp_session :server_version => 3 do |ch| - ch.sends_packet(FXP_MKDIR, :long, 0, :string, "/path/to/remote", :long, 0) - ch.gets_packet(FXP_STATUS, :long, 0, :long, 0) - ch.sends_packet(FXP_OPEN, :long, 1, :string, "/path/to/remote/file1", :long, 0x1A, :long, 0) - ch.sends_packet(FXP_OPEN, :long, 2, :string, "/path/to/remote/file2", :long, 0x1A, :long, 0) - ch.sends_packet(FXP_OPEN, :long, 3, :string, "/path/to/remote/file3", :long, 0x1A, :long, 0) - ch.sends_packet(FXP_MKDIR, :long, 4, :string, "/path/to/remote/subdir", :long, 0) - ch.sends_packet(FXP_OPEN, :long, 5, :string, "/path/to/remote/subdir/other1", :long, 0x1A, :long, 0) - ch.sends_packet(FXP_OPEN, :long, 6, :string, "/path/to/remote/subdir/other2", :long, 0x1A, :long, 0) - ch.gets_packet(FXP_HANDLE, :long, 1, :string, "hfile1") - ch.sends_packet(FXP_WRITE, :long, 7, :string, "hfile1", :int64, 0, :string, "contents of file1") - ch.gets_packet(FXP_HANDLE, :long, 2, :string, "hfile2") - ch.sends_packet(FXP_WRITE, :long, 8, :string, "hfile2", :int64, 0, :string, "contents of file2") - ch.gets_packet(FXP_HANDLE, :long, 3, :string, "hfile3") - ch.sends_packet(FXP_WRITE, :long, 9, :string, "hfile3", :int64, 0, :string, "contents of file3") - ch.gets_packet(FXP_STATUS, :long, 4, :long, 0) - ch.gets_packet(FXP_HANDLE, :long, 5, :string, "hother1") - ch.sends_packet(FXP_CLOSE, :long, 10, :string, "hfile1") - ch.sends_packet(FXP_WRITE, :long, 11, :string, "hother1", :int64, 0, :string, "contents of other1") - ch.gets_packet(FXP_HANDLE, :long, 6, :string, "hother2") - ch.sends_packet(FXP_WRITE, :long, 12, :string, "hother2", :int64, 0, :string, "contents of other2") - ch.gets_packet(FXP_STATUS, :long, 7, :long, 0) - ch.sends_packet(FXP_CLOSE, :long, 13, :string, "hfile2") - ch.gets_packet(FXP_STATUS, :long, 8, :long, 0) - ch.sends_packet(FXP_CLOSE, :long, 14, :string, "hfile3") - ch.gets_packet(FXP_STATUS, :long, 9, :long, 0) - ch.sends_packet(FXP_CLOSE, :long, 15, :string, "hother1") - ch.gets_packet(FXP_STATUS, :long, 10, :long, 0) - ch.sends_packet(FXP_CLOSE, :long, 16, :string, "hother2") - ch.gets_packet(FXP_STATUS, :long, 11, :long, 0) - ch.gets_packet(FXP_STATUS, :long, 12, :long, 0) - ch.gets_packet(FXP_STATUS, :long, 13, :long, 0) - ch.gets_packet(FXP_STATUS, :long, 14, :long, 0) - ch.gets_packet(FXP_STATUS, :long, 15, :long, 0) - ch.gets_packet(FXP_STATUS, :long, 16, :long, 0) - end - end - - def expect_file(path, data) - File.stubs(:directory?).with(path).returns(false) - File.stubs(:exists?).with(path).returns(true) - file = StringIO.new(data) - file.stubs(:stat).returns(stub("stat", :size => data.length)) - File.stubs(:open).with(path, "rb").returns(file) - end - - def expect_directory(path, entries) - Dir.stubs(:entries).with(path).returns(entries) - File.stubs(:directory?).with(path).returns(true) - end - - def expect_file_transfer(local, remote, data) - expect_sftp_session :server_version => 3 do |channel| - channel.sends_packet(FXP_OPEN, :long, 0, :string, remote, :long, 0x1A, :long, 0) - channel.gets_packet(FXP_HANDLE, :long, 0, :string, "handle") - channel.sends_packet(FXP_WRITE, :long, 1, :string, "handle", :int64, 0, :string, data) - channel.sends_packet(FXP_CLOSE, :long, 2, :string, "handle") - channel.gets_packet(FXP_STATUS, :long, 1, :long, 0) - channel.gets_packet(FXP_STATUS, :long, 2, :long, 0) - end - - expect_file(local, data) - end -end \ No newline at end of file diff --git a/vendor/gems/net-ssh-2.0.15/.specification b/vendor/gems/net-ssh-2.0.15/.specification deleted file mode 100644 index 18fb0a503..000000000 --- a/vendor/gems/net-ssh-2.0.15/.specification +++ /dev/null @@ -1,170 +0,0 @@ ---- !ruby/object:Gem::Specification -name: net-ssh -version: !ruby/object:Gem::Version - version: 2.0.15 -platform: ruby -authors: -- Jamis Buck -- Delano Mandelbaum -autorequire: -bindir: bin -cert_chain: [] - -date: 2009-09-03 00:00:00 +00:00 -default_executable: -dependencies: [] - -description: "Net::SSH: a pure-Ruby implementation of the SSH2 client protocol." -email: -- net-ssh@solutious.com -- net-ssh@solutious.com -executables: [] - -extensions: [] - -extra_rdoc_files: -- README.rdoc -- THANKS.rdoc -- CHANGELOG.rdoc -files: -- CHANGELOG.rdoc -- Manifest -- README.rdoc -- Rakefile -- Rudyfile -- THANKS.rdoc -- lib/net/ssh.rb -- lib/net/ssh/authentication/agent.rb -- lib/net/ssh/authentication/constants.rb -- lib/net/ssh/authentication/key_manager.rb -- lib/net/ssh/authentication/methods/abstract.rb -- lib/net/ssh/authentication/methods/hostbased.rb -- lib/net/ssh/authentication/methods/keyboard_interactive.rb -- lib/net/ssh/authentication/methods/password.rb -- lib/net/ssh/authentication/methods/publickey.rb -- lib/net/ssh/authentication/pageant.rb -- lib/net/ssh/authentication/session.rb -- lib/net/ssh/buffer.rb -- lib/net/ssh/buffered_io.rb -- lib/net/ssh/config.rb -- lib/net/ssh/connection/channel.rb -- lib/net/ssh/connection/constants.rb -- lib/net/ssh/connection/session.rb -- lib/net/ssh/connection/term.rb -- lib/net/ssh/errors.rb -- lib/net/ssh/key_factory.rb -- lib/net/ssh/known_hosts.rb -- lib/net/ssh/loggable.rb -- lib/net/ssh/packet.rb -- lib/net/ssh/prompt.rb -- lib/net/ssh/proxy/errors.rb -- lib/net/ssh/proxy/http.rb -- lib/net/ssh/proxy/socks4.rb -- lib/net/ssh/proxy/socks5.rb -- lib/net/ssh/ruby_compat.rb -- lib/net/ssh/service/forward.rb -- lib/net/ssh/test.rb -- lib/net/ssh/test/channel.rb -- lib/net/ssh/test/extensions.rb -- lib/net/ssh/test/kex.rb -- lib/net/ssh/test/local_packet.rb -- lib/net/ssh/test/packet.rb -- lib/net/ssh/test/remote_packet.rb -- lib/net/ssh/test/script.rb -- lib/net/ssh/test/socket.rb -- lib/net/ssh/transport/algorithms.rb -- lib/net/ssh/transport/cipher_factory.rb -- lib/net/ssh/transport/constants.rb -- lib/net/ssh/transport/hmac.rb -- lib/net/ssh/transport/hmac/abstract.rb -- lib/net/ssh/transport/hmac/md5.rb -- lib/net/ssh/transport/hmac/md5_96.rb -- lib/net/ssh/transport/hmac/none.rb -- lib/net/ssh/transport/hmac/sha1.rb -- lib/net/ssh/transport/hmac/sha1_96.rb -- lib/net/ssh/transport/identity_cipher.rb -- lib/net/ssh/transport/kex.rb -- lib/net/ssh/transport/kex/diffie_hellman_group1_sha1.rb -- lib/net/ssh/transport/kex/diffie_hellman_group_exchange_sha1.rb -- lib/net/ssh/transport/openssl.rb -- lib/net/ssh/transport/packet_stream.rb -- lib/net/ssh/transport/server_version.rb -- lib/net/ssh/transport/session.rb -- lib/net/ssh/transport/state.rb -- lib/net/ssh/verifiers/lenient.rb -- lib/net/ssh/verifiers/null.rb -- lib/net/ssh/verifiers/strict.rb -- lib/net/ssh/version.rb -- net-ssh.gemspec -- setup.rb -- support/arcfour_check.rb -- test/authentication/methods/common.rb -- test/authentication/methods/test_abstract.rb -- test/authentication/methods/test_hostbased.rb -- test/authentication/methods/test_keyboard_interactive.rb -- test/authentication/methods/test_password.rb -- test/authentication/methods/test_publickey.rb -- test/authentication/test_agent.rb -- test/authentication/test_key_manager.rb -- test/authentication/test_session.rb -- test/common.rb -- test/configs/eqsign -- test/configs/exact_match -- test/configs/multihost -- test/configs/wild_cards -- test/connection/test_channel.rb -- test/connection/test_session.rb -- test/test_all.rb -- test/test_buffer.rb -- test/test_buffered_io.rb -- test/test_config.rb -- test/test_key_factory.rb -- test/transport/hmac/test_md5.rb -- test/transport/hmac/test_md5_96.rb -- test/transport/hmac/test_none.rb -- test/transport/hmac/test_sha1.rb -- test/transport/hmac/test_sha1_96.rb -- test/transport/kex/test_diffie_hellman_group1_sha1.rb -- test/transport/kex/test_diffie_hellman_group_exchange_sha1.rb -- test/transport/test_algorithms.rb -- test/transport/test_cipher_factory.rb -- test/transport/test_hmac.rb -- test/transport/test_identity_cipher.rb -- test/transport/test_packet_stream.rb -- test/transport/test_server_version.rb -- test/transport/test_session.rb -- test/transport/test_state.rb -has_rdoc: true -homepage: http://rubyforge.org/projects/net-ssh/ -licenses: [] - -post_install_message: -rdoc_options: -- --line-numbers -- --title -- "Net::SSH: a pure-Ruby implementation of the SSH2 client protocol." -- --main -- README.rdoc -require_paths: -- lib -required_ruby_version: !ruby/object:Gem::Requirement - requirements: - - - ">=" - - !ruby/object:Gem::Version - version: "0" - version: -required_rubygems_version: !ruby/object:Gem::Requirement - requirements: - - - ">=" - - !ruby/object:Gem::Version - version: "0" - version: -requirements: [] - -rubyforge_project: net-ssh -rubygems_version: 1.3.4 -signing_key: -specification_version: 3 -summary: "Net::SSH: a pure-Ruby implementation of the SSH2 client protocol." -test_files: [] - diff --git a/vendor/gems/net-ssh-2.0.15/CHANGELOG.rdoc b/vendor/gems/net-ssh-2.0.15/CHANGELOG.rdoc deleted file mode 100644 index 5b905780e..000000000 --- a/vendor/gems/net-ssh-2.0.15/CHANGELOG.rdoc +++ /dev/null @@ -1,161 +0,0 @@ - - -=== 2.0.15 / 03 Sep 2009 - -* Scale back IO#select patch so it mutexes only zero-timeout calls [Daniel Azuma, Will Bryant] - - -=== 2.0.14 / 28 Aug 2009 - -* Fix for IO#select threading bug in Ruby 1.8 (LH-1) [Daniel Azuma] - -* Fix for "uninitialized constant OpenSSL::Digest::MD5" exception in Net::SFTP [DL Redden] - - -=== 2.0.13 / 17 Aug 2009 - -* Added fix for hanging in ServerVersion#negotiate! when using SOCKS5 proxy (GH-9) [Gerald Talton] - -* Added support for specifying a list of hosts in .ssh/config, with tests (GH-6) [ckoehler, Delano Mandelbaum] - -* Added tests for arcfour128/256/512 lengths, encryption, and decryption [Delano Mandelbaum] - -* Skip packet stream tests for arcfour128/256/512 [Delano Mandelbaum] - -* Fix for OpenSSL cipher key length because it always returns 16, even when 32 byte keys are required, e.g. for arcfour256 and arcfour512 ciphers [Karl Varga] - - -=== 2.0.12 / 08 Jun 2009 - -* Applied patch for arcfour128 and arcfour256 support [Denis Bernard] - -* Use unbuffered reads when negotiating the protocol version [Steven Hazel] - - -=== 2.0.11 / 24 Feb 2009 - -* Add :key_data option for specifying raw private keys in PEM format [Alex Holems, Andrew Babkin] - - -=== 2.0.10 / 4 Feb 2009 - -* Added Net::SSH.configuration_for to make it easier to query the SSH configuration file(s) [Jamis Buck] - - -=== 2.0.9 / 1 Feb 2009 - -* Specifying non-nil user argument overrides user in .ssh/config [Jamis Buck] - -* Ignore requests for non-existent channels (workaround ssh server bug) [Jamis Buck] - -* Add terminate! method for hard shutdown scenarios [Jamis Buck] - -* Revert to pre-2.0.7 key-loading behavior by default, but load private-key if public-key doesn't exist [Jamis Buck] - -* Make sure :passphrase option gets passed to key manager [Bob Cotton] - - -=== 2.0.8 / 29 December 2008 - -* Fix private key change from 2.0.7 so that keys are loaded just-in-time, avoiding unecessary prompts from encrypted keys. [Jamis Buck] - - -=== 2.0.7 / 29 December 2008 - -* Make key manager use private keys instead of requiring public key to exist [arilerner@mac.com] - -* Fix failing tests [arilerner@mac.com] - -* Don't include pageant when running under JRuby [Angel N. Sciortino] - - -=== 2.0.6 / 6 December 2008 - -* Update the Manifest file so that the gem includes all necessary files [Jamis Buck] - - -=== 2.0.5 / 6 December 2008 - -* Make the Pageant interface comply with more of the Socket interface to avoid related errors [Jamis Buck] - -* Don't busy-wait on session close for remaining channels to close [Will Bryant] - -* Ruby 1.9 compatibility [Jamis Buck] - -* Fix Cipher#final to correctly flag a need for a cipher reset [Jamis Buck] - - -=== 2.0.4 / 27 Aug 2008 - -* Added Connection::Session#closed? and Transport::Session#closed? [Jamis Buck] - -* Numeric host names in .ssh/config are now parsed correct [Yanko Ivanov] - -* Make sure the error raised when a public key file is malformed is more informative than a MethodMissing error [Jamis Buck] - -* Cipher#reset is now called after Cipher#final, with the last n bytes used as the next initialization vector [Jamis Buck] - - -=== 2.0.3 / 27 Jun 2008 - -* Make Net::SSH::Version comparable [Brian Candler] - -* Fix errors in port forwarding when a channel could not be opened due to a typo in the exception name [Matthew Todd] - -* Use #chomp instead of #strip when cleaning the version string reported by the remote host, so that trailing whitespace is preserved (this is to play nice with servers like Mocana SSH) [Timo Gatsonides] - -* Correctly parse ssh_config entries with eq-sign delimiters [Jamis Buck] - -* Ignore malformed ssh_config entries [Jamis Buck] - -=== 2.0.2 / 29 May 2008 - -* Make sure the agent client understands both RSA "identities answers" [Jamis Buck] - -* Fixed key truncation bug that caused hmacs other than SHA1 to fail with "corrupt hmac" errors [Jamis Buck] - -* Fix detection and loading of public keys when the keys don't actually exist [David Dollar] - - -=== 2.0.1 / 5 May 2008 - -* Teach Net::SSH about a handful of default key names [Jamis Buck] - - -=== 2.0.0 / 1 May 2008 - -* Allow the :verbose argument to accept symbols (:debug, etc.) as well as Logger level constants (Logger::DEBUG, etc.) [Jamis Buck] - - -=== 2.0 Preview Release 4 (1.99.3) / 19 Apr 2008 - -* Make sure HOME is set to something sane, even on OS's that don't set it by default [Jamis Buck] - -* Add a :passphrase option to specify the passphrase to use with private keys [Francis Sullivan] - -* Open a new auth agent connection for every auth-agent channel request [Jamis Buck] - - -=== 2.0 Preview Release 3 (1.99.2) / 10 Apr 2008 - -* Session properties [Jamis Buck] - -* Make channel open failure work with a callback so that failures can be handled similarly to successes [Jamis Buck] - - -=== 2.0 Preview Release 2 (1.99.1) / 22 Mar 2008 - -* Partial support for ~/.ssh/config (and related) SSH configuration files [Daniel J. Berger, Jamis Buck] - -* Added Net::SSH::Test to facilitate testing complex SSH state machines [Jamis Buck] - -* Reworked Net::SSH::Prompt to use conditionally-selected modules [Jamis Buck, suggested by James Rosen] - -* Added Channel#eof? and Channel#eof! [Jamis Buck] - -* Fixed bug in strict host key verifier on cache miss [Mike Timm] - - -=== 2.0 Preview Release 1 (1.99.0) / 21 Aug 2007 - -* First preview release of Net::SSH v2 diff --git a/vendor/gems/net-ssh-2.0.15/Manifest b/vendor/gems/net-ssh-2.0.15/Manifest deleted file mode 100644 index 27018a4a0..000000000 --- a/vendor/gems/net-ssh-2.0.15/Manifest +++ /dev/null @@ -1,107 +0,0 @@ -CHANGELOG.rdoc -Manifest -README.rdoc -Rakefile -Rudyfile -THANKS.rdoc -lib/net/ssh.rb -lib/net/ssh/authentication/agent.rb -lib/net/ssh/authentication/constants.rb -lib/net/ssh/authentication/key_manager.rb -lib/net/ssh/authentication/methods/abstract.rb -lib/net/ssh/authentication/methods/hostbased.rb -lib/net/ssh/authentication/methods/keyboard_interactive.rb -lib/net/ssh/authentication/methods/password.rb -lib/net/ssh/authentication/methods/publickey.rb -lib/net/ssh/authentication/pageant.rb -lib/net/ssh/authentication/session.rb -lib/net/ssh/buffer.rb -lib/net/ssh/buffered_io.rb -lib/net/ssh/config.rb -lib/net/ssh/connection/channel.rb -lib/net/ssh/connection/constants.rb -lib/net/ssh/connection/session.rb -lib/net/ssh/connection/term.rb -lib/net/ssh/errors.rb -lib/net/ssh/key_factory.rb -lib/net/ssh/known_hosts.rb -lib/net/ssh/loggable.rb -lib/net/ssh/packet.rb -lib/net/ssh/prompt.rb -lib/net/ssh/proxy/errors.rb -lib/net/ssh/proxy/http.rb -lib/net/ssh/proxy/socks4.rb -lib/net/ssh/proxy/socks5.rb -lib/net/ssh/ruby_compat.rb -lib/net/ssh/service/forward.rb -lib/net/ssh/test.rb -lib/net/ssh/test/channel.rb -lib/net/ssh/test/extensions.rb -lib/net/ssh/test/kex.rb -lib/net/ssh/test/local_packet.rb -lib/net/ssh/test/packet.rb -lib/net/ssh/test/remote_packet.rb -lib/net/ssh/test/script.rb -lib/net/ssh/test/socket.rb -lib/net/ssh/transport/algorithms.rb -lib/net/ssh/transport/cipher_factory.rb -lib/net/ssh/transport/constants.rb -lib/net/ssh/transport/hmac.rb -lib/net/ssh/transport/hmac/abstract.rb -lib/net/ssh/transport/hmac/md5.rb -lib/net/ssh/transport/hmac/md5_96.rb -lib/net/ssh/transport/hmac/none.rb -lib/net/ssh/transport/hmac/sha1.rb -lib/net/ssh/transport/hmac/sha1_96.rb -lib/net/ssh/transport/identity_cipher.rb -lib/net/ssh/transport/kex.rb -lib/net/ssh/transport/kex/diffie_hellman_group1_sha1.rb -lib/net/ssh/transport/kex/diffie_hellman_group_exchange_sha1.rb -lib/net/ssh/transport/openssl.rb -lib/net/ssh/transport/packet_stream.rb -lib/net/ssh/transport/server_version.rb -lib/net/ssh/transport/session.rb -lib/net/ssh/transport/state.rb -lib/net/ssh/verifiers/lenient.rb -lib/net/ssh/verifiers/null.rb -lib/net/ssh/verifiers/strict.rb -lib/net/ssh/version.rb -net-ssh.gemspec -setup.rb -support/arcfour_check.rb -test/authentication/methods/common.rb -test/authentication/methods/test_abstract.rb -test/authentication/methods/test_hostbased.rb -test/authentication/methods/test_keyboard_interactive.rb -test/authentication/methods/test_password.rb -test/authentication/methods/test_publickey.rb -test/authentication/test_agent.rb -test/authentication/test_key_manager.rb -test/authentication/test_session.rb -test/common.rb -test/configs/eqsign -test/configs/exact_match -test/configs/multihost -test/configs/wild_cards -test/connection/test_channel.rb -test/connection/test_session.rb -test/test_all.rb -test/test_buffer.rb -test/test_buffered_io.rb -test/test_config.rb -test/test_key_factory.rb -test/transport/hmac/test_md5.rb -test/transport/hmac/test_md5_96.rb -test/transport/hmac/test_none.rb -test/transport/hmac/test_sha1.rb -test/transport/hmac/test_sha1_96.rb -test/transport/kex/test_diffie_hellman_group1_sha1.rb -test/transport/kex/test_diffie_hellman_group_exchange_sha1.rb -test/transport/test_algorithms.rb -test/transport/test_cipher_factory.rb -test/transport/test_hmac.rb -test/transport/test_identity_cipher.rb -test/transport/test_packet_stream.rb -test/transport/test_server_version.rb -test/transport/test_session.rb -test/transport/test_state.rb diff --git a/vendor/gems/net-ssh-2.0.15/README.rdoc b/vendor/gems/net-ssh-2.0.15/README.rdoc deleted file mode 100644 index ff49d7838..000000000 --- a/vendor/gems/net-ssh-2.0.15/README.rdoc +++ /dev/null @@ -1,140 +0,0 @@ -= Net::SSH - -* http://net-ssh.rubyforge.org/ssh - -== DESCRIPTION: - -Net::SSH is a pure-Ruby implementation of the SSH2 client protocol. It allows you to write programs that invoke and interact with processes on remote servers, via SSH2. - -== FEATURES: - -* Execute processes on remote servers and capture their output -* Run multiple processes in parallel over a single SSH connection -* Support for SSH subsystems -* Forward local and remote ports via an SSH connection - -== SYNOPSIS: - -In a nutshell: - - require 'net/ssh' - - Net::SSH.start('host', 'user', :password => "password") do |ssh| - # capture all stderr and stdout output from a remote process - output = ssh.exec!("hostname") - - # capture only stdout matching a particular pattern - stdout = "" - ssh.exec!("ls -l /home/jamis") do |channel, stream, data| - stdout << data if stream == :stdout - end - puts stdout - - # run multiple processes in parallel to completion - ssh.exec "sed ..." - ssh.exec "awk ..." - ssh.exec "rm -rf ..." - ssh.loop - - # open a new channel and configure a minimal set of callbacks, then run - # the event loop until the channel finishes (closes) - channel = ssh.open_channel do |ch| - ch.exec "/usr/local/bin/ruby /path/to/file.rb" do |ch, success| - raise "could not execute command" unless success - - # "on_data" is called when the process writes something to stdout - ch.on_data do |c, data| - $STDOUT.print data - end - - # "on_extended_data" is called when the process writes something to stderr - ch.on_extended_data do |c, type, data| - $STDERR.print data - end - - ch.on_close { puts "done!" } - end - end - - channel.wait - - # forward connections on local port 1234 to port 80 of www.capify.org - ssh.forward.local(1234, "www.capify.org", 80) - ssh.loop { true } - end - -See Net::SSH for more documentation, and links to further information. - -== REQUIREMENTS: - -The only requirement you might be missing is the OpenSSL bindings for Ruby. These are built by default on most platforms, but you can verify that they're built and installed on your system by running the following command line: - - ruby -ropenssl -e 'puts OpenSSL::OPENSSL_VERSION' - -If that spits out something like "OpenSSL 0.9.8g 19 Oct 2007", then you're set. If you get an error, then you'll need to see about rebuilding ruby with OpenSSL support, or (if your platform supports it) installing the OpenSSL bindings separately. - -Additionally: if you are going to be having Net::SSH prompt you for things like passwords or certificate passphrases, you'll want to have either the Highline (recommended) or Termios (unix systems only) gem installed, so that the passwords don't echo in clear text. - -Lastly, if you want to run the tests or use any of the Rake tasks, you'll need: - -* Echoe (for the Rakefile) -* Mocha (for the tests) - - -== INSTALL: - -* gem install net-ssh (might need sudo privileges) - - -== ARCFOUR SUPPORT: - -from Karl Varga: - -Ruby's OpenSSL bindings always return a key length of 16 for RC4 ciphers, which means that when we try to use ARCFOUR256 or higher, Net::SSH generates keys which are consistently too short - 16 bytes as opposed to 32 bytes - resulting in the following error: - - OpenSSL::CipherError: key length too short - -My patch simply instructs Net::SSH to build keys of the the proper length, regardless of the required key length reported by OpenSSL. - -You should also be aware that your OpenSSL C libraries may also contain this bug. I've updated to 0.9.8k, but according to this thread[https://bugzilla.mindrot.org/show_bug.cgi?id=1291], the bug existed as recently as 0.9.8e! I've manually taken a look at my header files and they look ok, which is what makes me think it's a bug in the Ruby implementation. - -To see your OpenSSL version: - - $ openssl version - OpenSSL 0.9.8k 25 Mar 2009 - -After installing this gem, verify that Net::SSH is generating keys of the correct length by running the script support/arcfour_check.rb: - - $ ruby arcfour_support.rb - -which should produce the following: - - arcfour128: [16, 8] OpenSSL::Cipher::Cipher - arcfour256: [32, 8] OpenSSL::Cipher::Cipher - arcfour512: [64, 8] OpenSSL::Cipher::Cipher - - -== LICENSE: - -(The MIT License) - -Copyright (c) 2008 Jamis Buck - -Permission is hereby granted, free of charge, to any person obtaining -a copy of this software and associated documentation files (the -'Software'), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, sublicense, and/or sell copies of the Software, and to -permit persons to whom the Software is furnished to do so, subject to -the following conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY -CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, -TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/vendor/gems/net-ssh-2.0.15/Rakefile b/vendor/gems/net-ssh-2.0.15/Rakefile deleted file mode 100644 index 478db1209..000000000 --- a/vendor/gems/net-ssh-2.0.15/Rakefile +++ /dev/null @@ -1,79 +0,0 @@ -require 'rubygems' -require 'rake/clean' -require 'rake/gempackagetask' -require 'hanna/rdoctask' -require 'fileutils' -include FileUtils - -task :default => :package - -# CONFIG ============================================================= - -# Change the following according to your needs -README = "README.rdoc" -CHANGES = "CHANGELOG.rdoc" -THANKS = 'THANKS.rdoc' - -# Files and directories to be deleted when you run "rake clean" -CLEAN.include [ 'pkg', '*.gem', '.config', 'doc'] - -# Virginia assumes your project and gemspec have the same name -name = 'net-ssh' -load "#{name}.gemspec" -version = @spec.version - -# That's it! The following defaults should allow you to get started -# on other things. - - -# TESTS/SPECS ========================================================= - - - -# INSTALL ============================================================= - -Rake::GemPackageTask.new(@spec) do |p| - p.need_tar = true if RUBY_PLATFORM !~ /mswin/ -end - -task :release => [ :rdoc, :package ] -task :install => [ :rdoc, :package ] do - sh %{sudo gem install pkg/#{name}-#{version}.gem} -end -task :uninstall => [ :clean ] do - sh %{sudo gem uninstall #{name}} -end - - -# RUBYFORGE RELEASE / PUBLISH TASKS ================================== - -if @spec.rubyforge_project - desc 'Publish website to rubyforge' - task 'publish:rdoc' => 'doc/index.html' do - sh "scp -rp doc/* rubyforge.org:/var/www/gforge-projects/#{name}/ssh/v2/api/" - end - - desc 'Public release to rubyforge' - task 'publish:gem' => [:package] do |t| - sh <<-end - rubyforge add_release -o Any -a #{CHANGES} -f -n #{README} #{name} #{name} #{@spec.version} pkg/#{name}-#{@spec.version}.gem && - rubyforge add_file -o Any -a #{CHANGES} -f -n #{README} #{name} #{name} #{@spec.version} pkg/#{name}-#{@spec.version}.tgz - end - end -end - - - -# RUBY DOCS TASK ================================== - -Rake::RDocTask.new do |t| - t.rdoc_dir = 'doc' - t.title = @spec.summary - t.options << '--line-numbers' << '-A cattr_accessor=object' - t.options << '--charset' << 'utf-8' - t.rdoc_files.include(README) - t.rdoc_files.include(CHANGES) - t.rdoc_files.include(THANKS) - t.rdoc_files.include('lib/**/*.rb') -end - diff --git a/vendor/gems/net-ssh-2.0.15/Rudyfile b/vendor/gems/net-ssh-2.0.15/Rudyfile deleted file mode 100644 index 2028574e9..000000000 --- a/vendor/gems/net-ssh-2.0.15/Rudyfile +++ /dev/null @@ -1,110 +0,0 @@ -# Rudyfile -# -# This configuration is used to test installing -# and running net-ssh on a clean machine. -# -# Usage: -# -# $ rudy -vv startup -# $ rudy -vv testsuite -# $ rudy -vv shutdown -# -# Requires: Rudy 0.9 (http://code.google.com/p/rudy/) -# - -defaults do - color true - environment :test - role :netssh -end - -machines do - region :'us-east-1' do - ami 'ami-e348af8a' # Alestic Debian 5.0, 32-bit (US) - end - env :test do - role :netssh do - user :root - end - end -end - -commands do - allow :apt_get, "apt-get", :y, :q - allow :gem_install, "/usr/bin/gem", "install", :n, '/usr/bin', :y, :V, "--no-rdoc", "--no-ri" - allow :gem_sources, "/usr/bin/gem", "sources" - allow :gem_uninstall, "/usr/bin/gem", "uninstall", :V - allow :update_rubygems - allow :rm -end - -routines do - - testsuite do - before :sysupdate, :installdeps, :install_gem - - remote :root do - directory_upload 'test', '/tmp/' - cd '/tmp' - ruby :I, 'lib/', :I, 'test/', :r, 'rubygems', 'test/test_all.rb' - end - - after :install_rubyforge, :install_github - end - - install_rubyforge do - remote :root do - gem_install 'net-ssh', '--version', '2.0.7' - gem_install 'net-ssh' - end - end - - install_github do - remote :root do - gem_sources :a, "http://gems.github.com" - gem_install 'net-ssh-net-ssh' - end - end - - install_gem do - before :package_gem - remote :root do - disable_safe_mode - file_upload "pkg/net-ssh-*.gem", "/tmp/" - gem_install "/tmp/net-ssh-*.gem" - end - end - - package_gem do - local do - rm :r, :f, 'pkg' - rake 'package' - end - end - - remove do - remote :root do - gem_uninstall 'net-ssh' - end - end - - installdeps do - remote :root do - gem_install "rye", "test-unit", "mocha" - rye 'authorize-local' - end - end - - sysupdate do - remote :root do - apt_get "update" - apt_get "install", "build-essential", "git-core" - apt_get "install", "ruby1.8-dev", "rdoc", "libzlib-ruby", "rubygems" - mkdir :p, "/var/lib/gems/1.8/bin" # Doesn't get created, but causes Rubygems to fail - gem_install "builder", "session" - gem_install 'rubygems-update', "-v=1.3.4" # circular issue with 1.3.5 and hoe - update_rubygems - end - end -end - diff --git a/vendor/gems/net-ssh-2.0.15/THANKS.rdoc b/vendor/gems/net-ssh-2.0.15/THANKS.rdoc deleted file mode 100644 index d060dce6d..000000000 --- a/vendor/gems/net-ssh-2.0.15/THANKS.rdoc +++ /dev/null @@ -1,16 +0,0 @@ -Net::SSH was originally written by Jamis Buck . In -addition, the following individuals are gratefully acknowledged for their -contributions: - -GOTOU Yuuzou - * help and code related to OpenSSL - -Guillaume Marçais - * support for communicating with the the PuTTY "pageant" process - -Daniel Berger - * help getting unit tests in earlier Net::SSH versions to pass in Windows - * initial version of Net::SSH::Config provided inspiration and encouragement - -Chris Andrews and Lee Jensen - * support for ssh agent forwarding diff --git a/vendor/gems/net-ssh-2.0.15/lib/net/ssh.rb b/vendor/gems/net-ssh-2.0.15/lib/net/ssh.rb deleted file mode 100644 index c752c71b6..000000000 --- a/vendor/gems/net-ssh-2.0.15/lib/net/ssh.rb +++ /dev/null @@ -1,215 +0,0 @@ -# Make sure HOME is set, regardless of OS, so that File.expand_path works -# as expected with tilde characters. -ENV['HOME'] ||= ENV['HOMEPATH'] ? "#{ENV['HOMEDRIVE']}#{ENV['HOMEPATH']}" : "." - -require 'logger' - -require 'net/ssh/config' -require 'net/ssh/errors' -require 'net/ssh/loggable' -require 'net/ssh/transport/session' -require 'net/ssh/authentication/session' -require 'net/ssh/connection/session' - -module Net - - # Net::SSH is a library for interacting, programmatically, with remote - # processes via the SSH2 protocol. Sessions are always initiated via - # Net::SSH.start. From there, a program interacts with the new SSH session - # via the convenience methods on Net::SSH::Connection::Session, by opening - # and interacting with new channels (Net::SSH::Connection:Session#open_channel - # and Net::SSH::Connection::Channel), or by forwarding local and/or - # remote ports through the connection (Net::SSH::Service::Forward). - # - # The SSH protocol is very event-oriented. Requests are sent from the client - # to the server, and are answered asynchronously. This gives great flexibility - # (since clients can have multiple requests pending at a time), but it also - # adds complexity. Net::SSH tries to manage this complexity by providing - # some simpler methods of synchronous communication (see Net::SSH::Connection::Session#exec!). - # - # In general, though, and if you want to do anything more complicated than - # simply executing commands and capturing their output, you'll need to use - # channels (Net::SSH::Connection::Channel) to build state machines that are - # executed while the event loop runs (Net::SSH::Connection::Session#loop). - # - # Net::SSH::Connection::Session and Net::SSH::Connection::Channel have more - # information about this technique. - # - # = "Um, all I want to do is X, just show me how!" - # - # == X == "execute a command and capture the output" - # - # Net::SSH.start("host", "user", :password => "password") do |ssh| - # result = ssh.exec!("ls -l") - # puts result - # end - # - # == X == "forward connections on a local port to a remote host" - # - # Net::SSH.start("host", "user", :password => "password") do |ssh| - # ssh.forward.local(1234, "www.google.com", 80) - # ssh.loop { true } - # end - # - # == X == "forward connections on a remote port to the local host" - # - # Net::SSH.start("host", "user", :password => "password") do |ssh| - # ssh.forward.remote(80, "www.google.com", 1234) - # ssh.loop { true } - # end - module SSH - # This is the set of options that Net::SSH.start recognizes. See - # Net::SSH.start for a description of each option. - VALID_OPTIONS = [ - :auth_methods, :compression, :compression_level, :config, :encryption, - :forward_agent, :hmac, :host_key, :kex, :keys, :key_data, :languages, - :logger, :paranoid, :password, :port, :proxy, :rekey_blocks_limit, - :rekey_limit, :rekey_packet_limit, :timeout, :verbose, - :global_known_hosts_file, :user_known_hosts_file, :host_key_alias, - :host_name, :user, :properties, :passphrase - ] - - # The standard means of starting a new SSH connection. When used with a - # block, the connection will be closed when the block terminates, otherwise - # the connection will just be returned. The yielded (or returned) value - # will be an instance of Net::SSH::Connection::Session (q.v.). (See also - # Net::SSH::Connection::Channel and Net::SSH::Service::Forward.) - # - # Net::SSH.start("host", "user") do |ssh| - # ssh.exec! "cp /some/file /another/location" - # hostname = ssh.exec!("hostname") - # - # ssh.open_channel do |ch| - # ch.exec "sudo -p 'sudo password: ' ls" do |ch, success| - # abort "could not execute sudo ls" unless success - # - # ch.on_data do |ch, data| - # print data - # if data =~ /sudo password: / - # ch.send_data("password\n") - # end - # end - # end - # end - # - # ssh.loop - # end - # - # This method accepts the following options (all are optional): - # - # * :auth_methods => an array of authentication methods to try - # * :compression => the compression algorithm to use, or +true+ to use - # whatever is supported. - # * :compression_level => the compression level to use when sending data - # * :config => set to +true+ to load the default OpenSSH config files - # (~/.ssh/config, /etc/ssh_config), or to +false+ to not load them, or to - # a file-name (or array of file-names) to load those specific configuration - # files. Defaults to +true+. - # * :encryption => the encryption cipher (or ciphers) to use - # * :forward_agent => set to true if you want the SSH agent connection to - # be forwarded - # * :global_known_hosts_file => the location of the global known hosts - # file. Set to an array if you want to specify multiple global known - # hosts files. Defaults to %w(/etc/ssh/known_hosts /etc/ssh/known_hosts2). - # * :hmac => the hmac algorithm (or algorithms) to use - # * :host_key => the host key algorithm (or algorithms) to use - # * :host_key_alias => the host name to use when looking up or adding a - # host to a known_hosts dictionary file - # * :host_name => the real host name or IP to log into. This is used - # instead of the +host+ parameter, and is primarily only useful when - # specified in an SSH configuration file. It lets you specify an - # "alias", similarly to adding an entry in /etc/hosts but without needing - # to modify /etc/hosts. - # * :kex => the key exchange algorithm (or algorithms) to use - # * :keys => an array of file names of private keys to use for publickey - # and hostbased authentication - # * :key_data => an array of strings, with each element of the array being - # a raw private key in PEM format. - # * :logger => the logger instance to use when logging - # * :paranoid => either true, false, or :very, specifying how strict - # host-key verification should be - # * :passphrase => the passphrase to use when loading a private key (default - # is +nil+, for no passphrase) - # * :password => the password to use to login - # * :port => the port to use when connecting to the remote host - # * :properties => a hash of key/value pairs to add to the new connection's - # properties (see Net::SSH::Connection::Session#properties) - # * :proxy => a proxy instance (see Proxy) to use when connecting - # * :rekey_blocks_limit => the max number of blocks to process before rekeying - # * :rekey_limit => the max number of bytes to process before rekeying - # * :rekey_packet_limit => the max number of packets to process before rekeying - # * :timeout => how long to wait for the initial connection to be made - # * :user => the user name to log in as; this overrides the +user+ - # parameter, and is primarily only useful when provided via an SSH - # configuration file. - # * :user_known_hosts_file => the location of the user known hosts file. - # Set to an array to specify multiple user known hosts files. - # Defaults to %w(~/.ssh/known_hosts ~/.ssh/known_hosts2). - # * :verbose => how verbose to be (Logger verbosity constants, Logger::DEBUG - # is very verbose, Logger::FATAL is all but silent). Logger::FATAL is the - # default. The symbols :debug, :info, :warn, :error, and :fatal are also - # supported and are translated to the corresponding Logger constant. - def self.start(host, user, options={}, &block) - invalid_options = options.keys - VALID_OPTIONS - if invalid_options.any? - raise ArgumentError, "invalid option(s): #{invalid_options.join(', ')}" - end - - options[:user] = user if user - options = configuration_for(host, options.fetch(:config, true)).merge(options) - host = options.fetch(:host_name, host) - - if !options.key?(:logger) - options[:logger] = Logger.new(STDERR) - options[:logger].level = Logger::FATAL - end - - if options[:verbose] - options[:logger].level = case options[:verbose] - when Fixnum then options[:verbose] - when :debug then Logger::DEBUG - when :info then Logger::INFO - when :warn then Logger::WARN - when :error then Logger::ERROR - when :fatal then Logger::FATAL - else raise ArgumentError, "can't convert #{options[:verbose].inspect} to any of the Logger level constants" - end - end - - transport = Transport::Session.new(host, options) - auth = Authentication::Session.new(transport, options) - - user = options.fetch(:user, user) - if auth.authenticate("ssh-connection", user, options[:password]) - connection = Connection::Session.new(transport, options) - if block_given? - yield connection - connection.close - else - return connection - end - else - raise AuthenticationFailed, user - end - end - - # Returns a hash of the configuration options for the given host, as read - # from the SSH configuration file(s). If +use_ssh_config+ is true (the - # default), this will load configuration from both ~/.ssh/config and - # /etc/ssh_config. If +use_ssh_config+ is nil or false, nothing will be - # loaded (and an empty hash returned). Otherwise, +use_ssh_config+ may - # be a file name (or array of file names) of SSH configuration file(s) - # to read. - # - # See Net::SSH::Config for the full description of all supported options. - def self.configuration_for(host, use_ssh_config=true) - files = case use_ssh_config - when true then Net::SSH::Config.default_files - when false, nil then return {} - else Array(use_ssh_config) - end - - Net::SSH::Config.for(host, files) - end - end -end diff --git a/vendor/gems/net-ssh-2.0.15/lib/net/ssh/authentication/agent.rb b/vendor/gems/net-ssh-2.0.15/lib/net/ssh/authentication/agent.rb deleted file mode 100644 index 2915cce97..000000000 --- a/vendor/gems/net-ssh-2.0.15/lib/net/ssh/authentication/agent.rb +++ /dev/null @@ -1,176 +0,0 @@ -require 'net/ssh/buffer' -require 'net/ssh/errors' -require 'net/ssh/loggable' -require 'net/ssh/transport/server_version' - -require 'net/ssh/authentication/pageant' if File::ALT_SEPARATOR && !(RUBY_PLATFORM =~ /java/) - -module Net; module SSH; module Authentication - - # A trivial exception class for representing agent-specific errors. - class AgentError < Net::SSH::Exception; end - - # An exception for indicating that the SSH agent is not available. - class AgentNotAvailable < AgentError; end - - # This class implements a simple client for the ssh-agent protocol. It - # does not implement any specific protocol, but instead copies the - # behavior of the ssh-agent functions in the OpenSSH library (3.8). - # - # This means that although it behaves like a SSH1 client, it also has - # some SSH2 functionality (like signing data). - class Agent - include Loggable - - # A simple module for extending keys, to allow comments to be specified - # for them. - module Comment - attr_accessor :comment - end - - SSH2_AGENT_REQUEST_VERSION = 1 - SSH2_AGENT_REQUEST_IDENTITIES = 11 - SSH2_AGENT_IDENTITIES_ANSWER = 12 - SSH2_AGENT_SIGN_REQUEST = 13 - SSH2_AGENT_SIGN_RESPONSE = 14 - SSH2_AGENT_FAILURE = 30 - SSH2_AGENT_VERSION_RESPONSE = 103 - - SSH_COM_AGENT2_FAILURE = 102 - - SSH_AGENT_REQUEST_RSA_IDENTITIES = 1 - SSH_AGENT_RSA_IDENTITIES_ANSWER1 = 2 - SSH_AGENT_RSA_IDENTITIES_ANSWER2 = 5 - SSH_AGENT_FAILURE = 5 - - # The underlying socket being used to communicate with the SSH agent. - attr_reader :socket - - # Instantiates a new agent object, connects to a running SSH agent, - # negotiates the agent protocol version, and returns the agent object. - def self.connect(logger=nil) - agent = new(logger) - agent.connect! - agent.negotiate! - agent - end - - # Creates a new Agent object, using the optional logger instance to - # report status. - def initialize(logger=nil) - self.logger = logger - end - - # Connect to the agent process using the socket factory and socket name - # given by the attribute writers. If the agent on the other end of the - # socket reports that it is an SSH2-compatible agent, this will fail - # (it only supports the ssh-agent distributed by OpenSSH). - def connect! - begin - debug { "connecting to ssh-agent" } - @socket = agent_socket_factory.open(ENV['SSH_AUTH_SOCK']) - rescue - error { "could not connect to ssh-agent" } - raise AgentNotAvailable, $!.message - end - end - - # Attempts to negotiate the SSH agent protocol version. Raises an error - # if the version could not be negotiated successfully. - def negotiate! - # determine what type of agent we're communicating with - type, body = send_and_wait(SSH2_AGENT_REQUEST_VERSION, :string, Transport::ServerVersion::PROTO_VERSION) - - if type == SSH2_AGENT_VERSION_RESPONSE - raise NotImplementedError, "SSH2 agents are not yet supported" - elsif type != SSH_AGENT_RSA_IDENTITIES_ANSWER1 && type != SSH_AGENT_RSA_IDENTITIES_ANSWER2 - raise AgentError, "unknown response from agent: #{type}, #{body.to_s.inspect}" - end - end - - # Return an array of all identities (public keys) known to the agent. - # Each key returned is augmented with a +comment+ property which is set - # to the comment returned by the agent for that key. - def identities - type, body = send_and_wait(SSH2_AGENT_REQUEST_IDENTITIES) - raise AgentError, "could not get identity count" if agent_failed(type) - raise AgentError, "bad authentication reply: #{type}" if type != SSH2_AGENT_IDENTITIES_ANSWER - - identities = [] - body.read_long.times do - key = Buffer.new(body.read_string).read_key - key.extend(Comment) - key.comment = body.read_string - identities.push key - end - - return identities - end - - # Closes this socket. This agent reference is no longer able to - # query the agent. - def close - @socket.close - end - - # Using the agent and the given public key, sign the given data. The - # signature is returned in SSH2 format. - def sign(key, data) - type, reply = send_and_wait(SSH2_AGENT_SIGN_REQUEST, :string, Buffer.from(:key, key), :string, data, :long, 0) - - if agent_failed(type) - raise AgentError, "agent could not sign data with requested identity" - elsif type != SSH2_AGENT_SIGN_RESPONSE - raise AgentError, "bad authentication response #{type}" - end - - return reply.read_string - end - - private - - # Returns the agent socket factory to use. - def agent_socket_factory - if File::ALT_SEPARATOR - Pageant::Socket - else - UNIXSocket - end - end - - # Send a new packet of the given type, with the associated data. - def send_packet(type, *args) - buffer = Buffer.from(*args) - data = [buffer.length + 1, type.to_i, buffer.to_s].pack("NCA*") - debug { "sending agent request #{type} len #{buffer.length}" } - @socket.send data, 0 - end - - # Read the next packet from the agent. This will return a two-part - # tuple consisting of the packet type, and the packet's body (which - # is returned as a Net::SSH::Buffer). - def read_packet - buffer = Net::SSH::Buffer.new(@socket.read(4)) - buffer.append(@socket.read(buffer.read_long)) - type = buffer.read_byte - debug { "received agent packet #{type} len #{buffer.length-4}" } - return type, buffer - end - - # Send the given packet and return the subsequent reply from the agent. - # (See #send_packet and #read_packet). - def send_and_wait(type, *args) - send_packet(type, *args) - read_packet - end - - # Returns +true+ if the parameter indicates a "failure" response from - # the agent, and +false+ otherwise. - def agent_failed(type) - type == SSH_AGENT_FAILURE || - type == SSH2_AGENT_FAILURE || - type == SSH_COM_AGENT2_FAILURE - end - end - -end; end; end diff --git a/vendor/gems/net-ssh-2.0.15/lib/net/ssh/authentication/constants.rb b/vendor/gems/net-ssh-2.0.15/lib/net/ssh/authentication/constants.rb deleted file mode 100644 index 911b9ca44..000000000 --- a/vendor/gems/net-ssh-2.0.15/lib/net/ssh/authentication/constants.rb +++ /dev/null @@ -1,18 +0,0 @@ -module Net; module SSH; module Authentication - - # Describes the constants used by the Net::SSH::Authentication components - # of the Net::SSH library. Individual authentication method implemenations - # may define yet more constants that are specific to their implementation. - module Constants - USERAUTH_REQUEST = 50 - USERAUTH_FAILURE = 51 - USERAUTH_SUCCESS = 52 - USERAUTH_BANNER = 53 - - USERAUTH_PASSWD_CHANGEREQ = 60 - USERAUTH_PK_OK = 60 - - USERAUTH_METHOD_RANGE = 60..79 - end - -end; end; end \ No newline at end of file diff --git a/vendor/gems/net-ssh-2.0.15/lib/net/ssh/authentication/key_manager.rb b/vendor/gems/net-ssh-2.0.15/lib/net/ssh/authentication/key_manager.rb deleted file mode 100644 index 1a2f386e3..000000000 --- a/vendor/gems/net-ssh-2.0.15/lib/net/ssh/authentication/key_manager.rb +++ /dev/null @@ -1,193 +0,0 @@ -require 'net/ssh/errors' -require 'net/ssh/key_factory' -require 'net/ssh/loggable' -require 'net/ssh/authentication/agent' - -module Net - module SSH - module Authentication - - # A trivial exception class used to report errors in the key manager. - class KeyManagerError < Net::SSH::Exception; end - - # This class encapsulates all operations done by clients on a user's - # private keys. In practice, the client should never need a reference - # to a private key; instead, they grab a list of "identities" (public - # keys) that are available from the KeyManager, and then use - # the KeyManager to do various private key operations using those - # identities. - # - # The KeyManager also uses the Agent class to encapsulate the - # ssh-agent. Thus, from a client's perspective it is completely - # hidden whether an identity comes from the ssh-agent or from a file - # on disk. - class KeyManager - include Loggable - - # The list of user key files that will be examined - attr_reader :key_files - - # The list of user key data that will be examined - attr_reader :key_data - - # The map of loaded identities - attr_reader :known_identities - - # The map of options that were passed to the key-manager - attr_reader :options - - # Create a new KeyManager. By default, the manager will - # use the ssh-agent (if it is running). - def initialize(logger, options={}) - self.logger = logger - @key_files = [] - @key_data = [] - @use_agent = true - @known_identities = {} - @agent = nil - @options = options - end - - # Clear all knowledge of any loaded user keys. This also clears the list - # of default identity files that are to be loaded, thus making it - # appropriate to use if a client wishes to NOT use the default identity - # files. - def clear! - key_files.clear - key_data.clear - known_identities.clear - self - end - - # Add the given key_file to the list of key files that will be used. - def add(key_file) - key_files.push(File.expand_path(key_file)).uniq! - self - end - - # Add the given key_file to the list of keys that will be used. - def add_key_data(key_data_) - key_data.push(key_data_).uniq! - self - end - - # This is used as a hint to the KeyManager indicating that the agent - # connection is no longer needed. Any other open resources may be closed - # at this time. - # - # Calling this does NOT indicate that the KeyManager will no longer - # be used. Identities may still be requested and operations done on - # loaded identities, in which case, the agent will be automatically - # reconnected. This method simply allows the client connection to be - # closed when it will not be used in the immediate future. - def finish - @agent.close if @agent - @agent = nil - end - - # Iterates over all available identities (public keys) known to this - # manager. As it finds one, it will then yield it to the caller. - # The origin of the identities may be from files on disk or from an - # ssh-agent. Note that identities from an ssh-agent are always listed - # first in the array, with other identities coming after. - def each_identity - if agent - agent.identities.each do |key| - known_identities[key] = { :from => :agent } - yield key - end - end - - key_files.each do |file| - public_key_file = file + ".pub" - if File.readable?(public_key_file) - begin - key = KeyFactory.load_public_key(public_key_file) - known_identities[key] = { :from => :file, :file => file } - yield key - rescue Exception => e - error { "could not load public key file `#{public_key_file}': #{e.class} (#{e.message})" } - end - elsif File.readable?(file) - begin - private_key = KeyFactory.load_private_key(file, options[:passphrase]) - key = private_key.send(:public_key) - known_identities[key] = { :from => :file, :file => file, :key => private_key } - yield key - rescue Exception => e - error { "could not load private key file `#{file}': #{e.class} (#{e.message})" } - end - end - end - - key_data.each do |data| - private_key = KeyFactory.load_data_private_key(data) - key = private_key.send(:public_key) - known_identities[key] = { :from => :key_data, :data => data, :key => private_key } - yield key - end - - self - end - - # Sign the given data, using the corresponding private key of the given - # identity. If the identity was originally obtained from an ssh-agent, - # then the ssh-agent will be used to sign the data, otherwise the - # private key for the identity will be loaded from disk (if it hasn't - # been loaded already) and will then be used to sign the data. - # - # Regardless of the identity's origin or who does the signing, this - # will always return the signature in an SSH2-specified "signature - # blob" format. - def sign(identity, data) - info = known_identities[identity] or raise KeyManagerError, "the given identity is unknown to the key manager" - - if info[:key].nil? && info[:from] == :file - begin - info[:key] = KeyFactory.load_private_key(info[:file], options[:passphrase]) - rescue Exception => e - raise KeyManagerError, "the given identity is known, but the private key could not be loaded: #{e.class} (#{e.message})" - end - end - - if info[:key] - return Net::SSH::Buffer.from(:string, identity.ssh_type, - :string, info[:key].ssh_do_sign(data.to_s)).to_s - end - - if info[:from] == :agent - raise KeyManagerError, "the agent is no longer available" unless agent - return agent.sign(identity, data.to_s) - end - - raise KeyManagerError, "[BUG] can't determine identity origin (#{info.inspect})" - end - - # Identifies whether the ssh-agent will be used or not. - def use_agent? - @use_agent - end - - # Toggles whether the ssh-agent will be used or not. If true, an - # attempt will be made to use the ssh-agent. If false, any existing - # connection to an agent is closed and the agent will not be used. - def use_agent=(use_agent) - finish if !use_agent - @use_agent = use_agent - end - - # Returns an Agent instance to use for communicating with an SSH - # agent process. Returns nil if use of an SSH agent has been disabled, - # or if the agent is otherwise not available. - def agent - return unless use_agent? - @agent ||= Agent.connect(logger) - rescue AgentNotAvailable - @use_agent = false - nil - end - end - - end - end -end diff --git a/vendor/gems/net-ssh-2.0.15/lib/net/ssh/authentication/methods/abstract.rb b/vendor/gems/net-ssh-2.0.15/lib/net/ssh/authentication/methods/abstract.rb deleted file mode 100644 index 339c53c77..000000000 --- a/vendor/gems/net-ssh-2.0.15/lib/net/ssh/authentication/methods/abstract.rb +++ /dev/null @@ -1,60 +0,0 @@ -require 'net/ssh/buffer' -require 'net/ssh/errors' -require 'net/ssh/loggable' -require 'net/ssh/authentication/constants' - -module Net; module SSH; module Authentication; module Methods - - # The base class of all user authentication methods. It provides a few - # bits of common functionality. - class Abstract - include Constants, Loggable - - # The authentication session object - attr_reader :session - - # The key manager object. Not all authentication methods will require - # this. - attr_reader :key_manager - - # Instantiates a new authentication method. - def initialize(session, options={}) - @session = session - @key_manager = options[:key_manager] - @options = options - self.logger = session.logger - end - - # Returns the session-id, as generated during the first key exchange of - # an SSH connection. - def session_id - session.transport.algorithms.session_id - end - - # Sends a message via the underlying transport layer abstraction. This - # will block until the message is completely sent. - def send_message(msg) - session.transport.send_message(msg) - end - - # Creates a new USERAUTH_REQUEST packet. The extra arguments on the end - # must be either boolean values or strings, and are tacked onto the end - # of the packet. The new packet is returned, ready for sending. - def userauth_request(username, next_service, auth_method, *others) - buffer = Net::SSH::Buffer.from(:byte, USERAUTH_REQUEST, - :string, username, :string, next_service, :string, auth_method) - - others.each do |value| - case value - when true, false then buffer.write_bool(value) - when String then buffer.write_string(value) - else raise ArgumentError, "don't know how to write #{value.inspect}" - end - end - - buffer - end - - end - -end; end; end; end \ No newline at end of file diff --git a/vendor/gems/net-ssh-2.0.15/lib/net/ssh/authentication/methods/hostbased.rb b/vendor/gems/net-ssh-2.0.15/lib/net/ssh/authentication/methods/hostbased.rb deleted file mode 100644 index 43c3eac8f..000000000 --- a/vendor/gems/net-ssh-2.0.15/lib/net/ssh/authentication/methods/hostbased.rb +++ /dev/null @@ -1,71 +0,0 @@ -require 'net/ssh/authentication/methods/abstract' - -module Net - module SSH - module Authentication - module Methods - - # Implements the host-based SSH authentication method. - class Hostbased < Abstract - include Constants - - # Attempts to perform host-based authorization of the user by trying - # all known keys. - def authenticate(next_service, username, password=nil) - return false unless key_manager - - key_manager.each_identity do |identity| - return true if authenticate_with(identity, next_service, - username, key_manager) - end - - return false - end - - private - - # Returns the hostname as reported by the underlying socket. - def hostname - session.transport.socket.client_name - end - - # Attempts to perform host-based authentication of the user, using - # the given host identity (key). - def authenticate_with(identity, next_service, username, key_manager) - debug { "trying hostbased (#{identity.fingerprint})" } - client_username = ENV['USER'] || username - - req = build_request(identity, next_service, username, "#{hostname}.", client_username) - sig_data = Buffer.from(:string, session_id, :raw, req) - - sig = key_manager.sign(identity, sig_data.to_s) - - message = Buffer.from(:raw, req, :string, sig) - - send_message(message) - message = session.next_message - - case message.type - when USERAUTH_SUCCESS - info { "hostbased succeeded (#{identity.fingerprint})" } - return true - when USERAUTH_FAILURE - info { "hostbased failed (#{identity.fingerprint})" } - return false - else - raise Net::SSH::Exception, "unexpected server response to USERAUTH_REQUEST: #{message.type} (#{message.inspect})" - end - end - - # Build the "core" hostbased request string. - def build_request(identity, next_service, username, hostname, client_username) - userauth_request(username, next_service, "hostbased", identity.ssh_type, - Buffer.from(:key, identity).to_s, hostname, client_username).to_s - end - - end - - end - end - end -end diff --git a/vendor/gems/net-ssh-2.0.15/lib/net/ssh/authentication/methods/keyboard_interactive.rb b/vendor/gems/net-ssh-2.0.15/lib/net/ssh/authentication/methods/keyboard_interactive.rb deleted file mode 100644 index 1ab24590e..000000000 --- a/vendor/gems/net-ssh-2.0.15/lib/net/ssh/authentication/methods/keyboard_interactive.rb +++ /dev/null @@ -1,66 +0,0 @@ -require 'net/ssh/prompt' -require 'net/ssh/authentication/methods/abstract' - -module Net - module SSH - module Authentication - module Methods - - # Implements the "keyboard-interactive" SSH authentication method. - class KeyboardInteractive < Abstract - include Prompt - - USERAUTH_INFO_REQUEST = 60 - USERAUTH_INFO_RESPONSE = 61 - - # Attempt to authenticate the given user for the given service. - def authenticate(next_service, username, password=nil) - debug { "trying keyboard-interactive" } - send_message(userauth_request(username, next_service, "keyboard-interactive", "", "")) - - loop do - message = session.next_message - - case message.type - when USERAUTH_SUCCESS - debug { "keyboard-interactive succeeded" } - return true - when USERAUTH_FAILURE - debug { "keyboard-interactive failed" } - return false - when USERAUTH_INFO_REQUEST - name = message.read_string - instruction = message.read_string - debug { "keyboard-interactive info request" } - - unless password - puts(name) unless name.empty? - puts(instruction) unless instruction.empty? - end - - lang_tag = message.read_string - responses =[] - - message.read_long.times do - text = message.read_string - echo = message.read_bool - responses << (password || prompt(text, echo)) - end - - # if the password failed the first time around, don't try - # and use it on subsequent requests. - password = nil - - msg = Buffer.from(:byte, USERAUTH_INFO_RESPONSE, :long, responses.length, :string, responses) - send_message(msg) - else - raise Net::SSH::Exception, "unexpected reply in keyboard interactive: #{message.type} (#{message.inspect})" - end - end - end - end - - end - end - end -end diff --git a/vendor/gems/net-ssh-2.0.15/lib/net/ssh/authentication/methods/password.rb b/vendor/gems/net-ssh-2.0.15/lib/net/ssh/authentication/methods/password.rb deleted file mode 100644 index 9b1c09580..000000000 --- a/vendor/gems/net-ssh-2.0.15/lib/net/ssh/authentication/methods/password.rb +++ /dev/null @@ -1,39 +0,0 @@ -require 'net/ssh/errors' -require 'net/ssh/authentication/methods/abstract' - -module Net - module SSH - module Authentication - module Methods - - # Implements the "password" SSH authentication method. - class Password < Abstract - # Attempt to authenticate the given user for the given service. If - # the password parameter is nil, this will never do anything except - # return false. - def authenticate(next_service, username, password=nil) - return false unless password - - send_message(userauth_request(username, next_service, "password", false, password)) - message = session.next_message - - case message.type - when USERAUTH_SUCCESS - debug { "password succeeded" } - return true - when USERAUTH_FAILURE - debug { "password failed" } - return false - when USERAUTH_PASSWD_CHANGEREQ - debug { "password change request received, failing" } - return false - else - raise Net::SSH::Exception, "unexpected reply to USERAUTH_REQUEST: #{message.type} (#{message.inspect})" - end - end - end - - end - end - end -end diff --git a/vendor/gems/net-ssh-2.0.15/lib/net/ssh/authentication/methods/publickey.rb b/vendor/gems/net-ssh-2.0.15/lib/net/ssh/authentication/methods/publickey.rb deleted file mode 100644 index b453def5b..000000000 --- a/vendor/gems/net-ssh-2.0.15/lib/net/ssh/authentication/methods/publickey.rb +++ /dev/null @@ -1,92 +0,0 @@ -require 'net/ssh/buffer' -require 'net/ssh/errors' -require 'net/ssh/authentication/methods/abstract' - -module Net - module SSH - module Authentication - module Methods - - # Implements the "publickey" SSH authentication method. - class Publickey < Abstract - # Attempts to perform public-key authentication for the given - # username, trying each identity known to the key manager. If any of - # them succeed, returns +true+, otherwise returns +false+. This - # requires the presence of a key manager. - def authenticate(next_service, username, password=nil) - return false unless key_manager - - key_manager.each_identity do |identity| - return true if authenticate_with(identity, next_service, username) - end - - return false - end - - private - - # Builds a packet that contains the request formatted for sending - # a public-key request to the server. - def build_request(pub_key, username, next_service, has_sig) - blob = Net::SSH::Buffer.new - blob.write_key pub_key - - userauth_request(username, next_service, "publickey", has_sig, - pub_key.ssh_type, blob.to_s) - end - - # Builds and sends a request formatted for a public-key - # authentication request. - def send_request(pub_key, username, next_service, signature=nil) - msg = build_request(pub_key, username, next_service, !signature.nil?) - msg.write_string(signature) if signature - send_message(msg) - end - - # Attempts to perform public-key authentication for the given - # username, with the given identity (public key). Returns +true+ if - # successful, or +false+ otherwise. - def authenticate_with(identity, next_service, username) - debug { "trying publickey (#{identity.fingerprint})" } - send_request(identity, username, next_service) - - message = session.next_message - - case message.type - when USERAUTH_PK_OK - buffer = build_request(identity, username, next_service, true) - sig_data = Net::SSH::Buffer.new - sig_data.write_string(session_id) - sig_data.append(buffer.to_s) - - sig_blob = key_manager.sign(identity, sig_data) - - send_request(identity, username, next_service, sig_blob.to_s) - message = session.next_message - - case message.type - when USERAUTH_SUCCESS - debug { "publickey succeeded (#{identity.fingerprint})" } - return true - when USERAUTH_FAILURE - debug { "publickey failed (#{identity.fingerprint})" } - return false - else - raise Net::SSH::Exception, - "unexpected server response to USERAUTH_REQUEST: #{message.type} (#{message.inspect})" - end - - when USERAUTH_FAILURE - return false - - else - raise Net::SSH::Exception, "unexpected reply to USERAUTH_REQUEST: #{message.type} (#{message.inspect})" - end - end - - end - - end - end - end -end diff --git a/vendor/gems/net-ssh-2.0.15/lib/net/ssh/authentication/pageant.rb b/vendor/gems/net-ssh-2.0.15/lib/net/ssh/authentication/pageant.rb deleted file mode 100644 index 871e86b1c..000000000 --- a/vendor/gems/net-ssh-2.0.15/lib/net/ssh/authentication/pageant.rb +++ /dev/null @@ -1,183 +0,0 @@ -require 'dl/import' -require 'dl/struct' - -require 'net/ssh/errors' - -module Net; module SSH; module Authentication - - # This module encapsulates the implementation of a socket factory that - # uses the PuTTY "pageant" utility to obtain information about SSH - # identities. - # - # This code is a slightly modified version of the original implementation - # by Guillaume Marçais (guillaume.marcais@free.fr). It is used and - # relicensed by permission. - module Pageant - - # From Putty pageant.c - AGENT_MAX_MSGLEN = 8192 - AGENT_COPYDATA_ID = 0x804e50ba - - # The definition of the Windows methods and data structures used in - # communicating with the pageant process. - module Win - extend DL::Importable - - dlload 'user32' - dlload 'kernel32' - - typealias("LPCTSTR", "char *") # From winnt.h - typealias("LPVOID", "void *") # From winnt.h - typealias("LPCVOID", "const void *") # From windef.h - typealias("LRESULT", "long") # From windef.h - typealias("WPARAM", "unsigned int *") # From windef.h - typealias("LPARAM", "long *") # From windef.h - typealias("PDWORD_PTR", "long *") # From basetsd.h - - # From winbase.h, winnt.h - INVALID_HANDLE_VALUE = -1 - NULL = nil - PAGE_READWRITE = 0x0004 - FILE_MAP_WRITE = 2 - WM_COPYDATA = 74 - - SMTO_NORMAL = 0 # From winuser.h - - # args: lpClassName, lpWindowName - extern 'HWND FindWindow(LPCTSTR, LPCTSTR)' - - # args: none - extern 'DWORD GetCurrentThreadId()' - - # args: hFile, (ignored), flProtect, dwMaximumSizeHigh, - # dwMaximumSizeLow, lpName - extern 'HANDLE CreateFileMapping(HANDLE, void *, DWORD, DWORD, ' + - 'DWORD, LPCTSTR)' - - # args: hFileMappingObject, dwDesiredAccess, dwFileOffsetHigh, - # dwfileOffsetLow, dwNumberOfBytesToMap - extern 'LPVOID MapViewOfFile(HANDLE, DWORD, DWORD, DWORD, DWORD)' - - # args: lpBaseAddress - extern 'BOOL UnmapViewOfFile(LPCVOID)' - - # args: hObject - extern 'BOOL CloseHandle(HANDLE)' - - # args: hWnd, Msg, wParam, lParam, fuFlags, uTimeout, lpdwResult - extern 'LRESULT SendMessageTimeout(HWND, UINT, WPARAM, LPARAM, ' + - 'UINT, UINT, PDWORD_PTR)' - end - - # This is the pseudo-socket implementation that mimics the interface of - # a socket, translating each request into a Windows messaging call to - # the pageant daemon. This allows pageant support to be implemented - # simply by replacing the socket factory used by the Agent class. - class Socket - - private_class_method :new - - # The factory method for creating a new Socket instance. The location - # parameter is ignored, and is only needed for compatibility with - # the general Socket interface. - def self.open(location=nil) - new - end - - # Create a new instance that communicates with the running pageant - # instance. If no such instance is running, this will cause an error. - def initialize - @win = Win.findWindow("Pageant", "Pageant") - - if @win == 0 - raise Net::SSH::Exception, - "pageant process not running" - end - - @res = nil - @pos = 0 - end - - # Forwards the data to #send_query, ignoring any arguments after - # the first. Returns 0. - def send(data, *args) - @res = send_query(data) - @pos = 0 - end - - # Packages the given query string and sends it to the pageant - # process via the Windows messaging subsystem. The result is - # cached, to be returned piece-wise when #read is called. - def send_query(query) - res = nil - filemap = 0 - ptr = nil - id = DL::PtrData.malloc(DL.sizeof("L")) - - mapname = "PageantRequest%08x\000" % Win.getCurrentThreadId() - filemap = Win.createFileMapping(Win::INVALID_HANDLE_VALUE, - Win::NULL, - Win::PAGE_READWRITE, 0, - AGENT_MAX_MSGLEN, mapname) - if filemap == 0 - raise Net::SSH::Exception, - "Creation of file mapping failed" - end - - ptr = Win.mapViewOfFile(filemap, Win::FILE_MAP_WRITE, 0, 0, - AGENT_MAX_MSGLEN) - - if ptr.nil? || ptr.null? - raise Net::SSH::Exception, "Mapping of file failed" - end - - ptr[0] = query - - cds = [AGENT_COPYDATA_ID, mapname.size + 1, mapname]. - pack("LLp").to_ptr - succ = Win.sendMessageTimeout(@win, Win::WM_COPYDATA, Win::NULL, - cds, Win::SMTO_NORMAL, 5000, id) - - if succ > 0 - retlen = 4 + ptr.to_s(4).unpack("N")[0] - res = ptr.to_s(retlen) - end - - return res - ensure - Win.unmapViewOfFile(ptr) unless ptr.nil? || ptr.null? - Win.closeHandle(filemap) if filemap != 0 - end - - # Conceptually close the socket. This doesn't really do anthing - # significant, but merely complies with the Socket interface. - def close - @res = nil - @pos = 0 - end - - # Conceptually asks if the socket is closed. As with #close, - # this doesn't really do anything significant, but merely - # complies with the Socket interface. - def closed? - @res.nil? && @pos.zero? - end - - # Reads +n+ bytes from the cached result of the last query. If +n+ - # is +nil+, returns all remaining data from the last query. - def read(n = nil) - return nil unless @res - if n.nil? - start, @pos = @pos, @res.size - return @res[start..-1] - else - start, @pos = @pos, @pos + n - return @res[start, n] - end - end - - end - - end - -end; end; end diff --git a/vendor/gems/net-ssh-2.0.15/lib/net/ssh/authentication/session.rb b/vendor/gems/net-ssh-2.0.15/lib/net/ssh/authentication/session.rb deleted file mode 100644 index 8e7d3df8f..000000000 --- a/vendor/gems/net-ssh-2.0.15/lib/net/ssh/authentication/session.rb +++ /dev/null @@ -1,134 +0,0 @@ -require 'net/ssh/loggable' -require 'net/ssh/transport/constants' -require 'net/ssh/authentication/constants' -require 'net/ssh/authentication/key_manager' -require 'net/ssh/authentication/methods/publickey' -require 'net/ssh/authentication/methods/hostbased' -require 'net/ssh/authentication/methods/password' -require 'net/ssh/authentication/methods/keyboard_interactive' - -module Net; module SSH; module Authentication - - # Represents an authentication session. It manages the authentication of - # a user over an established connection (the "transport" object, see - # Net::SSH::Transport::Session). - # - # The use of an authentication session to manage user authentication is - # internal to Net::SSH (specifically Net::SSH.start). Consumers of the - # Net::SSH library will never need to access this class directly. - class Session - include Transport::Constants, Constants, Loggable - - # transport layer abstraction - attr_reader :transport - - # the list of authentication methods to try - attr_reader :auth_methods - - # the list of authentication methods that are allowed - attr_reader :allowed_auth_methods - - # a hash of options, given at construction time - attr_reader :options - - # Instantiates a new Authentication::Session object over the given - # transport layer abstraction. - def initialize(transport, options={}) - self.logger = transport.logger - @transport = transport - - @auth_methods = options[:auth_methods] || %w(publickey hostbased password keyboard-interactive) - @options = options - - @allowed_auth_methods = @auth_methods - end - - # Attempts to authenticate the given user, in preparation for the next - # service request. Returns true if an authentication method succeeds in - # authenticating the user, and false otherwise. - def authenticate(next_service, username, password=nil) - debug { "beginning authentication of `#{username}'" } - - transport.send_message(transport.service_request("ssh-userauth")) - message = expect_message(SERVICE_ACCEPT) - - key_manager = KeyManager.new(logger, options) - keys.each { |key| key_manager.add(key) } unless keys.empty? - key_data.each { |key2| key_manager.add_key_data(key2) } unless key_data.empty? - - attempted = [] - - @auth_methods.each do |name| - next unless @allowed_auth_methods.include?(name) - attempted << name - - debug { "trying #{name}" } - method = Methods.const_get(name.split(/\W+/).map { |p| p.capitalize }.join).new(self, :key_manager => key_manager) - - return true if method.authenticate(next_service, username, password) - end - - error { "all authorization methods failed (tried #{attempted.join(', ')})" } - return false - ensure - key_manager.finish if key_manager - end - - # Blocks until a packet is received. It silently handles USERAUTH_BANNER - # packets, and will raise an error if any packet is received that is not - # valid during user authentication. - def next_message - loop do - packet = transport.next_message - - case packet.type - when USERAUTH_BANNER - info { packet[:message] } - # TODO add a hook for people to retrieve the banner when it is sent - - when USERAUTH_FAILURE - @allowed_auth_methods = packet[:authentications].split(/,/) - debug { "allowed methods: #{packet[:authentications]}" } - return packet - - when USERAUTH_METHOD_RANGE, SERVICE_ACCEPT - return packet - - when USERAUTH_SUCCESS - transport.hint :authenticated - return packet - - else - raise Net::SSH::Exception, "unexpected message #{packet.type} (#{packet})" - end - end - end - - # Blocks until a packet is received, and returns it if it is of the given - # type. If it is not, an exception is raised. - def expect_message(type) - message = next_message - unless message.type == type - raise Net::SSH::Exception, "expected #{type}, got #{message.type} (#{message})" - end - message - end - - private - - # Returns an array of paths to the key files that should be used when - # attempting any key-based authentication mechanism. - def keys - Array( - options[:keys] || - %w(~/.ssh/id_dsa ~/.ssh/id_rsa ~/.ssh2/id_dsa ~/.ssh2/id_rsa) - ) - end - - # Returns an array of the key data that should be used when - # attempting any key-based authentication mechanism. - def key_data - Array(options[:key_data]) - end - end -end; end; end \ No newline at end of file diff --git a/vendor/gems/net-ssh-2.0.15/lib/net/ssh/buffer.rb b/vendor/gems/net-ssh-2.0.15/lib/net/ssh/buffer.rb deleted file mode 100644 index 51e1c4e82..000000000 --- a/vendor/gems/net-ssh-2.0.15/lib/net/ssh/buffer.rb +++ /dev/null @@ -1,340 +0,0 @@ -require 'net/ssh/ruby_compat' -require 'net/ssh/transport/openssl' - -module Net; module SSH - - # Net::SSH::Buffer is a flexible class for building and parsing binary - # data packets. It provides a stream-like interface for sequentially - # reading data items from the buffer, as well as a useful helper method - # for building binary packets given a signature. - # - # Writing to a buffer always appends to the end, regardless of where the - # read cursor is. Reading, on the other hand, always begins at the first - # byte of the buffer and increments the read cursor, with subsequent reads - # taking up where the last left off. - # - # As a consumer of the Net::SSH library, you will rarely come into contact - # with these buffer objects directly, but it could happen. Also, if you - # are ever implementing a protocol on top of SSH (e.g. SFTP), this buffer - # class can be quite handy. - class Buffer - # This is a convenience method for creating and populating a new buffer - # from a single command. The arguments must be even in length, with the - # first of each pair of arguments being a symbol naming the type of the - # data that follows. If the type is :raw, the value is written directly - # to the hash. - # - # b = Buffer.from(:byte, 1, :string, "hello", :raw, "\1\2\3\4") - # #-> "\1\0\0\0\5hello\1\2\3\4" - # - # The supported data types are: - # - # * :raw => write the next value verbatim (#write) - # * :int64 => write an 8-byte integer (#write_int64) - # * :long => write a 4-byte integer (#write_long) - # * :byte => write a single byte (#write_byte) - # * :string => write a 4-byte length followed by character data (#write_string) - # * :bool => write a single byte, interpreted as a boolean (#write_bool) - # * :bignum => write an SSH-encoded bignum (#write_bignum) - # * :key => write an SSH-encoded key value (#write_key) - # - # Any of these, except for :raw, accepts an Array argument, to make it - # easier to write multiple values of the same type in a briefer manner. - def self.from(*args) - raise ArgumentError, "odd number of arguments given" unless args.length % 2 == 0 - - buffer = new - 0.step(args.length-1, 2) do |index| - type = args[index] - value = args[index+1] - if type == :raw - buffer.append(value.to_s) - elsif Array === value - buffer.send("write_#{type}", *value) - else - buffer.send("write_#{type}", value) - end - end - - buffer - end - - # exposes the raw content of the buffer - attr_reader :content - - # the current position of the pointer in the buffer - attr_accessor :position - - # Creates a new buffer, initialized to the given content. The position - # is initialized to the beginning of the buffer. - def initialize(content="") - @content = content.to_s - @position = 0 - end - - # Returns the length of the buffer's content. - def length - @content.length - end - - # Returns the number of bytes available to be read (e.g., how many bytes - # remain between the current position and the end of the buffer). - def available - length - position - end - - # Returns a copy of the buffer's content. - def to_s - (@content || "").dup - end - - # Compares the contents of the two buffers, returning +true+ only if they - # are identical in size and content. - def ==(buffer) - to_s == buffer.to_s - end - - # Returns +true+ if the buffer contains no data (e.g., it is of zero length). - def empty? - @content.empty? - end - - # Resets the pointer to the start of the buffer. Subsequent reads will - # begin at position 0. - def reset! - @position = 0 - end - - # Returns true if the pointer is at the end of the buffer. Subsequent - # reads will return nil, in this case. - def eof? - @position >= length - end - - # Resets the buffer, making it empty. Also, resets the read position to - # 0. - def clear! - @content = "" - @position = 0 - end - - # Consumes n bytes from the buffer, where n is the current position - # unless otherwise specified. This is useful for removing data from the - # buffer that has previously been read, when you are expecting more data - # to be appended. It helps to keep the size of buffers down when they - # would otherwise tend to grow without bound. - # - # Returns the buffer object itself. - def consume!(n=position) - if n >= length - # optimize for a fairly common case - clear! - elsif n > 0 - @content = @content[n..-1] || "" - @position -= n - @position = 0 if @position < 0 - end - self - end - - # Appends the given text to the end of the buffer. Does not alter the - # read position. Returns the buffer object itself. - def append(text) - @content << text - self - end - - # Returns all text from the current pointer to the end of the buffer as - # a new Net::SSH::Buffer object. - def remainder_as_buffer - Buffer.new(@content[@position..-1]) - end - - # Reads all data up to and including the given pattern, which may be a - # String, Fixnum, or Regexp and is interpreted exactly as String#index - # does. Returns nil if nothing matches. Increments the position to point - # immediately after the pattern, if it does match. Returns all data up to - # and including the text that matched the pattern. - def read_to(pattern) - index = @content.index(pattern, @position) or return nil - length = case pattern - when String then pattern.length - when Fixnum then 1 - when Regexp then $&.length - end - index && read(index+length) - end - - # Reads and returns the next +count+ bytes from the buffer, starting from - # the read position. If +count+ is +nil+, this will return all remaining - # text in the buffer. This method will increment the pointer. - def read(count=nil) - count ||= length - count = length - @position if @position + count > length - @position += count - @content[@position-count, count] - end - - # Reads (as #read) and returns the given number of bytes from the buffer, - # and then consumes (as #consume!) all data up to the new read position. - def read!(count=nil) - data = read(count) - consume! - data - end - - # Return the next 8 bytes as a 64-bit integer (in network byte order). - # Returns nil if there are less than 8 bytes remaining to be read in the - # buffer. - def read_int64 - hi = read_long or return nil - lo = read_long or return nil - return (hi << 32) + lo - end - - # Return the next four bytes as a long integer (in network byte order). - # Returns nil if there are less than 4 bytes remaining to be read in the - # buffer. - def read_long - b = read(4) or return nil - b.unpack("N").first - end - - # Read and return the next byte in the buffer. Returns nil if called at - # the end of the buffer. - def read_byte - b = read(1) or return nil - b.getbyte(0) - end - - # Read and return an SSH2-encoded string. The string starts with a long - # integer that describes the number of bytes remaining in the string. - # Returns nil if there are not enough bytes to satisfy the request. - def read_string - length = read_long or return nil - read(length) - end - - # Read a single byte and convert it into a boolean, using 'C' rules - # (i.e., zero is false, non-zero is true). - def read_bool - b = read_byte or return nil - b != 0 - end - - # Read a bignum (OpenSSL::BN) from the buffer, in SSH2 format. It is - # essentially just a string, which is reinterpreted to be a bignum in - # binary format. - def read_bignum - data = read_string - return unless data - OpenSSL::BN.new(data, 2) - end - - # Read a key from the buffer. The key will start with a string - # describing its type. The remainder of the key is defined by the - # type that was read. - def read_key - type = read_string - return (type ? read_keyblob(type) : nil) - end - - # Read a keyblob of the given type from the buffer, and return it as - # a key. Only RSA and DSA keys are supported. - def read_keyblob(type) - case type - when "ssh-dss" - key = OpenSSL::PKey::DSA.new - key.p = read_bignum - key.q = read_bignum - key.g = read_bignum - key.pub_key = read_bignum - - when "ssh-rsa" - key = OpenSSL::PKey::RSA.new - key.e = read_bignum - key.n = read_bignum - - else - raise NotImplementedError, "unsupported key type `#{type}'" - end - - return key - end - - # Reads the next string from the buffer, and returns a new Buffer - # object that wraps it. - def read_buffer - Buffer.new(read_string) - end - - # Writes the given data literally into the string. Does not alter the - # read position. Returns the buffer object. - def write(*data) - data.each { |datum| @content << datum } - self - end - - # Writes each argument to the buffer as a network-byte-order-encoded - # 64-bit integer (8 bytes). Does not alter the read position. Returns the - # buffer object. - def write_int64(*n) - n.each do |i| - hi = (i >> 32) & 0xFFFFFFFF - lo = i & 0xFFFFFFFF - @content << [hi, lo].pack("N2") - end - self - end - - # Writes each argument to the buffer as a network-byte-order-encoded - # long (4-byte) integer. Does not alter the read position. Returns the - # buffer object. - def write_long(*n) - @content << n.pack("N*") - self - end - - # Writes each argument to the buffer as a byte. Does not alter the read - # position. Returns the buffer object. - def write_byte(*n) - n.each { |b| @content << b.chr } - self - end - - # Writes each argument to the buffer as an SSH2-encoded string. Each - # string is prefixed by its length, encoded as a 4-byte long integer. - # Does not alter the read position. Returns the buffer object. - def write_string(*text) - text.each do |string| - s = string.to_s - write_long(s.length) - write(s) - end - self - end - - # Writes each argument to the buffer as a (C-style) boolean, with 1 - # meaning true, and 0 meaning false. Does not alter the read position. - # Returns the buffer object. - def write_bool(*b) - b.each { |v| @content << (v ? "\1" : "\0") } - self - end - - # Writes each argument to the buffer as a bignum (SSH2-style). No - # checking is done to ensure that the arguments are, in fact, bignums. - # Does not alter the read position. Returns the buffer object. - def write_bignum(*n) - @content << n.map { |b| b.to_ssh }.join - self - end - - # Writes the given arguments to the buffer as SSH2-encoded keys. Does not - # alter the read position. Returns the buffer object. - def write_key(*key) - key.each { |k| append(k.to_blob) } - self - end - end -end; end; \ No newline at end of file diff --git a/vendor/gems/net-ssh-2.0.15/lib/net/ssh/buffered_io.rb b/vendor/gems/net-ssh-2.0.15/lib/net/ssh/buffered_io.rb deleted file mode 100644 index e48a8dcf7..000000000 --- a/vendor/gems/net-ssh-2.0.15/lib/net/ssh/buffered_io.rb +++ /dev/null @@ -1,150 +0,0 @@ -require 'net/ssh/buffer' -require 'net/ssh/loggable' -require 'net/ssh/ruby_compat' - -module Net; module SSH - - # This module is used to extend sockets and other IO objects, to allow - # them to be buffered for both read and write. This abstraction makes it - # quite easy to write a select-based event loop - # (see Net::SSH::Connection::Session#listen_to). - # - # The general idea is that instead of calling #read directly on an IO that - # has been extended with this module, you call #fill (to add pending input - # to the internal read buffer), and then #read_available (to read from that - # buffer). Likewise, you don't call #write directly, you call #enqueue to - # add data to the write buffer, and then #send_pending or #wait_for_pending_sends - # to actually send the data across the wire. - # - # In this way you can easily use the object as an argument to IO.select, - # calling #fill when it is available for read, or #send_pending when it is - # available for write, and then call #enqueue and #read_available during - # the idle times. - # - # socket = TCPSocket.new(address, port) - # socket.extend(Net::SSH::BufferedIo) - # - # ssh.listen_to(socket) - # - # ssh.loop do - # if socket.available > 0 - # puts socket.read_available - # socket.enqueue("response\n") - # end - # end - # - # Note that this module must be used to extend an instance, and should not - # be included in a class. If you do want to use it via an include, then you - # must make sure to invoke the private #initialize_buffered_io method in - # your class' #initialize method: - # - # class Foo < IO - # include Net::SSH::BufferedIo - # - # def initialize - # initialize_buffered_io - # # ... - # end - # end - module BufferedIo - include Loggable - - # Called when the #extend is called on an object, with this module as the - # argument. It ensures that the modules instance variables are all properly - # initialized. - def self.extended(object) #:nodoc: - # need to use __send__ because #send is overridden in Socket - object.__send__(:initialize_buffered_io) - end - - # Tries to read up to +n+ bytes of data from the remote end, and appends - # the data to the input buffer. It returns the number of bytes read, or 0 - # if no data was available to be read. - def fill(n=8192) - input.consume! - data = recv(n) - debug { "read #{data.length} bytes" } - input.append(data) - return data.length - end - - # Read up to +length+ bytes from the input buffer. If +length+ is nil, - # all available data is read from the buffer. (See #available.) - def read_available(length=nil) - input.read(length || available) - end - - # Returns the number of bytes available to be read from the input buffer. - # (See #read_available.) - def available - input.available - end - - # Enqueues data in the output buffer, to be written when #send_pending - # is called. Note that the data is _not_ sent immediately by this method! - def enqueue(data) - output.append(data) - end - - # Returns +true+ if there is data waiting in the output buffer, and - # +false+ otherwise. - def pending_write? - output.length > 0 - end - - # Sends as much of the pending output as possible. Returns +true+ if any - # data was sent, and +false+ otherwise. - def send_pending - if output.length > 0 - sent = send(output.to_s, 0) - debug { "sent #{sent} bytes" } - output.consume!(sent) - return sent > 0 - else - return false - end - end - - # Calls #send_pending repeatedly, if necessary, blocking until the output - # buffer is empty. - def wait_for_pending_sends - send_pending - while output.length > 0 - result = Net::SSH::Compat.io_select(nil, [self]) or next - next unless result[1].any? - send_pending - end - end - - public # these methods are primarily for use in tests - - def write_buffer #:nodoc: - output.to_s - end - - def read_buffer #:nodoc: - input.to_s - end - - private - - #-- - # Can't use attr_reader here (after +private+) without incurring the - # wrath of "ruby -w". We hates it. - #++ - - def input; @input; end - def output; @output; end - - # Initializes the intput and output buffers for this object. This method - # is called automatically when the module is mixed into an object via - # Object#extend (see Net::SSH::BufferedIo.extended), but must be called - # explicitly in the +initialize+ method of any class that uses - # Module#include to add this module. - def initialize_buffered_io - @input = Net::SSH::Buffer.new - @output = Net::SSH::Buffer.new - end - end - -end; end diff --git a/vendor/gems/net-ssh-2.0.15/lib/net/ssh/config.rb b/vendor/gems/net-ssh-2.0.15/lib/net/ssh/config.rb deleted file mode 100644 index 7dc922ea1..000000000 --- a/vendor/gems/net-ssh-2.0.15/lib/net/ssh/config.rb +++ /dev/null @@ -1,185 +0,0 @@ -module Net; module SSH - - # The Net::SSH::Config class is used to parse OpenSSH configuration files, - # and translates that syntax into the configuration syntax that Net::SSH - # understands. This lets Net::SSH scripts read their configuration (to - # some extent) from OpenSSH configuration files (~/.ssh/config, /etc/ssh_config, - # and so forth). - # - # Only a subset of OpenSSH configuration options are understood: - # - # * Ciphers => maps to the :encryption option - # * Compression => :compression - # * CompressionLevel => :compression_level - # * ConnectTimeout => maps to the :timeout option - # * ForwardAgent => :forward_agent - # * GlobalKnownHostsFile => :global_known_hosts_file - # * HostBasedAuthentication => maps to the :auth_methods option - # * HostKeyAlgorithms => maps to :host_key option - # * HostKeyAlias => :host_key_alias - # * HostName => :host_name - # * IdentityFile => maps to the :keys option - # * Macs => maps to the :hmac option - # * PasswordAuthentication => maps to the :auth_methods option - # * Port => :port - # * PreferredAuthentications => maps to the :auth_methods option - # * RekeyLimit => :rekey_limit - # * User => :user - # * UserKnownHostsFile => :user_known_hosts_file - # - # Note that you will never need to use this class directly--you can control - # whether the OpenSSH configuration files are read by passing the :config - # option to Net::SSH.start. (They are, by default.) - class Config - class < "xterm", - :chars_wide => 80, - :chars_high => 24, - :pixels_wide => 640, - :pixels_high => 480, - :modes => {} } - - # Requests that a pseudo-tty (or "pty") be made available for this channel. - # This is useful when you want to invoke and interact with some kind of - # screen-based program (e.g., vim, or some menuing system). - # - # Note, that without a pty some programs (e.g. sudo, or subversion) on - # some systems, will not be able to run interactively, and will error - # instead of prompt if they ever need some user interaction. - # - # Note, too, that when a pty is requested, user's shell configuration - # scripts (.bashrc and such) are not run by default, whereas they are - # run when a pty is not present. - # - # channel.request_pty do |ch, success| - # if success - # puts "pty successfully obtained" - # else - # puts "could not obtain pty" - # end - # end - def request_pty(opts={}, &block) - extra = opts.keys - VALID_PTY_OPTIONS.keys - raise ArgumentError, "invalid option(s) to request_pty: #{extra.inspect}" if extra.any? - - opts = VALID_PTY_OPTIONS.merge(opts) - - modes = opts[:modes].inject(Buffer.new) do |memo, (mode, data)| - memo.write_byte(mode).write_long(data) - end - # mark the end of the mode opcode list with a 0 byte - modes.write_byte(0) - - send_channel_request("pty-req", :string, opts[:term], - :long, opts[:chars_wide], :long, opts[:chars_high], - :long, opts[:pixels_wide], :long, opts[:pixels_high], - :string, modes.to_s, &block) - end - - # Sends data to the channel's remote endpoint. This usually has the - # effect of sending the given string to the remote process' stdin stream. - # Note that it does not immediately send the data across the channel, - # but instead merely appends the given data to the channel's output buffer, - # preparatory to being packaged up and sent out the next time the connection - # is accepting data. (A connection might not be accepting data if, for - # instance, it has filled its data window and has not yet been resized by - # the remote end-point.) - # - # This will raise an exception if the channel has previously declared - # that no more data will be sent (see #eof!). - # - # channel.send_data("the password\n") - def send_data(data) - raise EOFError, "cannot send data if channel has declared eof" if eof? - output.append(data.to_s) - end - - # Returns true if the channel exists in the channel list of the session, - # and false otherwise. This can be used to determine whether a channel has - # been closed or not. - # - # ssh.loop { channel.active? } - def active? - connection.channels.key?(local_id) - end - - # Runs the SSH event loop until the channel is no longer active. This is - # handy for blocking while you wait for some channel to finish. - # - # channel.exec("grep ...") { ... } - # channel.wait - def wait - connection.loop { active? } - end - - # Returns true if the channel is currently closing, but not actually - # closed. A channel is closing when, for instance, #close has been - # invoked, but the server has not yet responded with a CHANNEL_CLOSE - # packet of its own. - def closing? - @closing - end - - # Requests that the channel be closed. If the channel is already closing, - # this does nothing, nor does it do anything if the channel has not yet - # been confirmed open (see #do_open_confirmation). Otherwise, it sends a - # CHANNEL_CLOSE message and marks the channel as closing. - def close - return if @closing - if remote_id - @closing = true - connection.send_message(Buffer.from(:byte, CHANNEL_CLOSE, :long, remote_id)) - end - end - - # Returns true if the local end of the channel has declared that no more - # data is forthcoming (see #eof!). Trying to send data via #send_data when - # this is true will result in an exception being raised. - def eof? - @eof - end - - # Tells the remote end of the channel that no more data is forthcoming - # from this end of the channel. The remote end may still send data. - def eof! - return if eof? - @eof = true - connection.send_message(Buffer.from(:byte, CHANNEL_EOF, :long, remote_id)) - end - - # If an #on_process handler has been set up, this will cause it to be - # invoked (passing the channel itself as an argument). It also causes all - # pending output to be enqueued as CHANNEL_DATA packets (see #enqueue_pending_output). - def process - @on_process.call(self) if @on_process - enqueue_pending_output - end - - # Registers a callback to be invoked when data packets are received by the - # channel. The callback is called with the channel as the first argument, - # and the data as the second. - # - # channel.on_data do |ch, data| - # puts "got data: #{data.inspect}" - # end - # - # Data received this way is typically the data written by the remote - # process to its +stdout+ stream. - def on_data(&block) - old, @on_data = @on_data, block - old - end - - # Registers a callback to be invoked when extended data packets are received - # by the channel. The callback is called with the channel as the first - # argument, the data type (as an integer) as the second, and the data as - # the third. Extended data is almost exclusively used to send +stderr+ data - # (+type+ == 1). Other extended data types are not defined by the SSH - # protocol. - # - # channel.on_extended_data do |ch, type, data| - # puts "got stderr: #{data.inspect}" - # end - def on_extended_data(&block) - old, @on_extended_data = @on_extended_data, block - old - end - - # Registers a callback to be invoked for each pass of the event loop for - # this channel. There are no guarantees on timeliness in the event loop, - # but it will be called roughly once for each packet received by the - # connection (not the channel). This callback is invoked with the channel - # as the sole argument. - # - # Here's an example that accumulates the channel data into a variable on - # the channel itself, and displays individual lines in the input one - # at a time when the channel is processed: - # - # channel[:data] = "" - # - # channel.on_data do |ch, data| - # channel[:data] << data - # end - # - # channel.on_process do |ch| - # if channel[:data] =~ /^.*?\n/ - # puts $& - # channel[:data] = $' - # end - # end - def on_process(&block) - old, @on_process = @on_process, block - old - end - - # Registers a callback to be invoked when the server acknowledges that a - # channel is closed. This is invoked with the channel as the sole argument. - # - # channel.on_close do |ch| - # puts "remote end is closing!" - # end - def on_close(&block) - old, @on_close = @on_close, block - old - end - - # Registers a callback to be invoked when the server indicates that no more - # data will be sent to the channel (although the channel can still send - # data to the server). The channel is the sole argument to the callback. - # - # channel.on_eof do |ch| - # puts "remote end is done sending data" - # end - def on_eof(&block) - old, @on_eof = @on_eof, block - old - end - - # Registers a callback to be invoked when the server was unable to open - # the requested channel. The channel itself will be passed to the block, - # along with the integer "reason code" for the failure, and a textual - # description of the failure from the server. - # - # channel = session.open_channel do |ch| - # # .. - # end - # - # channel.on_open_failed { |ch, code, desc| ... } - def on_open_failed(&block) - old, @on_open_failed = @on_open_failed, block - old - end - - # Registers a callback to be invoked when a channel request of the given - # type is received. The callback will receive the channel as the first - # argument, and the associated (unparsed) data as the second. The data - # will be a Net::SSH::Buffer that you will need to parse, yourself, - # according to the kind of request you are watching. - # - # By default, if the request wants a reply, Net::SSH will send a - # CHANNEL_SUCCESS response for any request that was handled by a registered - # callback, and CHANNEL_FAILURE for any that wasn't, but if you want your - # registered callback to result in a CHANNEL_FAILURE response, just raise - # Net::SSH::ChannelRequestFailed. - # - # Some common channel requests that your programs might want to listen - # for are: - # - # * "exit-status" : the exit status of the remote process will be reported - # as a long integer in the data buffer, which you can grab via - # data.read_long. - # * "exit-signal" : if the remote process died as a result of a signal - # being sent to it, the signal will be reported as a string in the - # data, via data.read_string. (Not all SSH servers support this channel - # request type.) - # - # channel.on_request "exit-status" do |ch, data| - # puts "process terminated with exit status: #{data.read_long}" - # end - def on_request(type, &block) - old, @on_request[type] = @on_request[type], block - old - end - - # Sends a new channel request with the given name. The extra +data+ - # parameter must either be empty, or consist of an even number of - # arguments. See Net::SSH::Buffer.from for a description of their format. - # If a block is given, it is registered as a callback for a pending - # request, and the packet will be flagged so that the server knows a - # reply is required. If no block is given, the server will send no - # response to this request. Responses, where required, will cause the - # callback to be invoked with the channel as the first argument, and - # either true or false as the second, depending on whether the request - # succeeded or not. The meaning of "success" and "failure" in this context - # is dependent on the specific request that was sent. - # - # channel.send_channel_request "shell" do |ch, success| - # if success - # puts "user shell started successfully" - # else - # puts "could not start user shell" - # end - # end - # - # Most channel requests you'll want to send are already wrapped in more - # convenient helper methods (see #exec and #subsystem). - def send_channel_request(request_name, *data, &callback) - info { "sending channel request #{request_name.inspect}" } - msg = Buffer.from(:byte, CHANNEL_REQUEST, - :long, remote_id, :string, request_name, - :bool, !callback.nil?, *data) - connection.send_message(msg) - pending_requests << callback if callback - end - - public # these methods are public, but for Net::SSH internal use only - - # Enqueues pending output at the connection as CHANNEL_DATA packets. This - # does nothing if the channel has not yet been confirmed open (see - # #do_open_confirmation). This is called automatically by #process, which - # is called from the event loop (Connection::Session#process). You will - # generally not need to invoke it directly. - def enqueue_pending_output #:nodoc: - return unless remote_id - - while output.length > 0 - length = output.length - length = remote_window_size if length > remote_window_size - length = remote_maximum_packet_size if length > remote_maximum_packet_size - - if length > 0 - connection.send_message(Buffer.from(:byte, CHANNEL_DATA, :long, remote_id, :string, output.read(length))) - output.consume! - @remote_window_size -= length - else - break - end - end - end - - # Invoked when the server confirms that a channel has been opened. - # The remote_id is the id of the channel as assigned by the remote host, - # and max_window and max_packet are the maximum window and maximum - # packet sizes, respectively. If an open-confirmation callback was - # given when the channel was created, it is invoked at this time with - # the channel itself as the sole argument. - def do_open_confirmation(remote_id, max_window, max_packet) #:nodoc: - @remote_id = remote_id - @remote_window_size = @remote_maximum_window_size = max_window - @remote_maximum_packet_size = max_packet - connection.forward.agent(self) if connection.options[:forward_agent] && type == "session" - @on_confirm_open.call(self) if @on_confirm_open - end - - # Invoked when the server failed to open the channel. If an #on_open_failed - # callback was specified, it will be invoked with the channel, reason code, - # and description as arguments. Otherwise, a ChannelOpenFailed exception - # will be raised. - def do_open_failed(reason_code, description) - if @on_open_failed - @on_open_failed.call(self, reason_code, description) - else - raise ChannelOpenFailed.new(reason_code, description) - end - end - - # Invoked when the server sends a CHANNEL_WINDOW_ADJUST packet, and - # causes the remote window size to be adjusted upwards by the given - # number of bytes. This has the effect of allowing more data to be sent - # from the local end to the remote end of the channel. - def do_window_adjust(bytes) #:nodoc: - @remote_maximum_window_size += bytes - @remote_window_size += bytes - end - - # Invoked when the server sends a channel request. If any #on_request - # callback has been registered for the specific type of this request, - # it is invoked. If +want_reply+ is true, a packet will be sent of - # either CHANNEL_SUCCESS or CHANNEL_FAILURE type. If there was no callback - # to handle the request, CHANNEL_FAILURE will be sent. Otherwise, - # CHANNEL_SUCCESS, unless the callback raised ChannelRequestFailed. The - # callback should accept the channel as the first argument, and the - # request-specific data as the second. - def do_request(request, want_reply, data) #:nodoc: - result = true - - begin - callback = @on_request[request] or raise ChannelRequestFailed - callback.call(self, data) - rescue ChannelRequestFailed - result = false - end - - if want_reply - msg = Buffer.from(:byte, result ? CHANNEL_SUCCESS : CHANNEL_FAILURE, :long, remote_id) - connection.send_message(msg) - end - end - - # Invokes the #on_data callback when the server sends data to the - # channel. This will reduce the available window size on the local end, - # but does not actually throttle requests that come in illegally when - # the window size is too small. The callback is invoked with the channel - # as the first argument, and the data as the second. - def do_data(data) #:nodoc: - update_local_window_size(data.length) - @on_data.call(self, data) if @on_data - end - - # Invokes the #on_extended_data callback when the server sends - # extended data to the channel. This will reduce the available window - # size on the local end. The callback is invoked with the channel, - # type, and data. - def do_extended_data(type, data) - update_local_window_size(data.length) - @on_extended_data.call(self, type, data) if @on_extended_data - end - - # Invokes the #on_eof callback when the server indicates that no - # further data is forthcoming. The callback is invoked with the channel - # as the argument. - def do_eof - @on_eof.call(self) if @on_eof - end - - # Invokes the #on_close callback when the server closes a channel. - # The channel is the only argument. - def do_close - @on_close.call(self) if @on_close - end - - # Invokes the next pending request callback with +false+ as the second - # argument. - def do_failure - if callback = pending_requests.shift - callback.call(self, false) - else - error { "channel failure recieved with no pending request to handle it (bug?)" } - end - end - - # Invokes the next pending request callback with +true+ as the second - # argument. - def do_success - if callback = pending_requests.shift - callback.call(self, true) - else - error { "channel success recieved with no pending request to handle it (bug?)" } - end - end - - private - - # Updates the local window size by the given amount. If the window - # size drops to less than half of the local maximum (an arbitrary - # threshold), a CHANNEL_WINDOW_ADJUST message will be sent to the - # server telling it that the window size has grown. - def update_local_window_size(size) - @local_window_size -= size - if local_window_size < local_maximum_window_size/2 - connection.send_message(Buffer.from(:byte, CHANNEL_WINDOW_ADJUST, - :long, remote_id, :long, 0x20000)) - @local_window_size += 0x20000 - @local_maximum_window_size += 0x20000 - end - end - end - -end; end; end \ No newline at end of file diff --git a/vendor/gems/net-ssh-2.0.15/lib/net/ssh/connection/constants.rb b/vendor/gems/net-ssh-2.0.15/lib/net/ssh/connection/constants.rb deleted file mode 100644 index 2c3df5af0..000000000 --- a/vendor/gems/net-ssh-2.0.15/lib/net/ssh/connection/constants.rb +++ /dev/null @@ -1,33 +0,0 @@ -module Net; module SSH; module Connection - - # Definitions of constants that are specific to the connection layer of the - # SSH protocol. - module Constants - - #-- - # Connection protocol generic messages - #++ - - GLOBAL_REQUEST = 80 - REQUEST_SUCCESS = 81 - REQUEST_FAILURE = 82 - - #-- - # Channel related messages - #++ - - CHANNEL_OPEN = 90 - CHANNEL_OPEN_CONFIRMATION = 91 - CHANNEL_OPEN_FAILURE = 92 - CHANNEL_WINDOW_ADJUST = 93 - CHANNEL_DATA = 94 - CHANNEL_EXTENDED_DATA = 95 - CHANNEL_EOF = 96 - CHANNEL_CLOSE = 97 - CHANNEL_REQUEST = 98 - CHANNEL_SUCCESS = 99 - CHANNEL_FAILURE = 100 - - end - -end; end end \ No newline at end of file diff --git a/vendor/gems/net-ssh-2.0.15/lib/net/ssh/connection/session.rb b/vendor/gems/net-ssh-2.0.15/lib/net/ssh/connection/session.rb deleted file mode 100644 index 13270daa2..000000000 --- a/vendor/gems/net-ssh-2.0.15/lib/net/ssh/connection/session.rb +++ /dev/null @@ -1,597 +0,0 @@ -require 'net/ssh/loggable' -require 'net/ssh/ruby_compat' -require 'net/ssh/connection/channel' -require 'net/ssh/connection/constants' -require 'net/ssh/service/forward' - -module Net; module SSH; module Connection - - # A session class representing the connection service running on top of - # the SSH transport layer. It manages the creation of channels (see - # #open_channel), and the dispatching of messages to the various channels. - # It also encapsulates the SSH event loop (via #loop and #process), - # and serves as a central point-of-reference for all SSH-related services (e.g. - # port forwarding, SFTP, SCP, etc.). - # - # You will rarely (if ever) need to instantiate this class directly; rather, - # you'll almost always use Net::SSH.start to initialize a new network - # connection, authenticate a user, and return a new connection session, - # all in one call. - # - # Net::SSH.start("localhost", "user") do |ssh| - # # 'ssh' is an instance of Net::SSH::Connection::Session - # ssh.exec! "/etc/init.d/some_process start" - # end - class Session - include Constants, Loggable - - # The underlying transport layer abstraction (see Net::SSH::Transport::Session). - attr_reader :transport - - # The map of options that were used to initialize this instance. - attr_reader :options - - # The collection of custom properties for this instance. (See #[] and #[]=). - attr_reader :properties - - # The map of channels, each key being the local-id for the channel. - attr_reader :channels #:nodoc: - - # The map of listeners that the event loop knows about. See #listen_to. - attr_reader :listeners #:nodoc: - - # The map of specialized handlers for opening specific channel types. See - # #on_open_channel. - attr_reader :channel_open_handlers #:nodoc: - - # The list of callbacks for pending requests. See #send_global_request. - attr_reader :pending_requests #:nodoc: - - class NilChannel - def initialize(session) - @session = session - end - - def method_missing(sym, *args) - @session.lwarn { "ignoring request #{sym.inspect} for non-existent (closed?) channel; probably ssh server bug" } - end - end - - # Create a new connection service instance atop the given transport - # layer. Initializes the listeners to be only the underlying socket object. - def initialize(transport, options={}) - self.logger = transport.logger - - @transport = transport - @options = options - - @channel_id_counter = -1 - @channels = Hash.new(NilChannel.new(self)) - @listeners = { transport.socket => nil } - @pending_requests = [] - @channel_open_handlers = {} - @on_global_request = {} - @properties = (options[:properties] || {}).dup - end - - # Retrieves a custom property from this instance. This can be used to - # store additional state in applications that must manage multiple - # SSH connections. - def [](key) - @properties[key] - end - - # Sets a custom property for this instance. - def []=(key, value) - @properties[key] = value - end - - # Returns the name of the host that was given to the transport layer to - # connect to. - def host - transport.host - end - - # Returns true if the underlying transport has been closed. Note that - # this can be a little misleading, since if the remote server has - # closed the connection, the local end will still think it is open - # until the next operation on the socket. Nevertheless, this method can - # be useful if you just want to know if _you_ have closed the connection. - def closed? - transport.closed? - end - - # Closes the session gracefully, blocking until all channels have - # successfully closed, and then closes the underlying transport layer - # connection. - def close - info { "closing remaining channels (#{channels.length} open)" } - channels.each { |id, channel| channel.close } - loop { channels.any? } - transport.close - end - - # Performs a "hard" shutdown of the connection. In general, this should - # never be done, but it might be necessary (in a rescue clause, for instance, - # when the connection needs to close but you don't know the status of the - # underlying protocol's state). - def shutdown! - transport.shutdown! - end - - # preserve a reference to Kernel#loop - alias :loop_forever :loop - - # Returns +true+ if there are any channels currently active on this - # session. By default, this will not include "invisible" channels - # (such as those created by forwarding ports and such), but if you pass - # a +true+ value for +include_invisible+, then those will be counted. - # - # This can be useful for determining whether the event loop should continue - # to be run. - # - # ssh.loop { ssh.busy? } - def busy?(include_invisible=false) - if include_invisible - channels.any? - else - channels.any? { |id, ch| !ch[:invisible] } - end - end - - # The main event loop. Calls #process until #process returns false. If a - # block is given, it is passed to #process, otherwise a default proc is - # used that just returns true if there are any channels active (see #busy?). - # The # +wait+ parameter is also passed through to #process (where it is - # interpreted as the maximum number of seconds to wait for IO.select to return). - # - # # loop for as long as there are any channels active - # ssh.loop - # - # # loop for as long as there are any channels active, but make sure - # # the event loop runs at least once per 0.1 second - # ssh.loop(0.1) - # - # # loop until ctrl-C is pressed - # int_pressed = false - # trap("INT") { int_pressed = true } - # ssh.loop(0.1) { not int_pressed } - def loop(wait=nil, &block) - running = block || Proc.new { busy? } - loop_forever { break unless process(wait, &running) } - end - - # The core of the event loop. It processes a single iteration of the event - # loop. If a block is given, it should return false when the processing - # should abort, which causes #process to return false. Otherwise, - # #process returns true. The session itself is yielded to the block as its - # only argument. - # - # If +wait+ is nil (the default), this method will block until any of the - # monitored IO objects are ready to be read from or written to. If you want - # it to not block, you can pass 0, or you can pass any other numeric value - # to indicate that it should block for no more than that many seconds. - # Passing 0 is a good way to poll the connection, but if you do it too - # frequently it can make your CPU quite busy! - # - # This will also cause all active channels to be processed once each (see - # Net::SSH::Connection::Channel#on_process). - # - # # process multiple Net::SSH connections in parallel - # connections = [ - # Net::SSH.start("host1", ...), - # Net::SSH.start("host2", ...) - # ] - # - # connections.each do |ssh| - # ssh.exec "grep something /in/some/files" - # end - # - # condition = Proc.new { |s| s.busy? } - # - # loop do - # connections.delete_if { |ssh| !ssh.process(0.1, &condition) } - # break if connections.empty? - # end - def process(wait=nil, &block) - return false unless preprocess(&block) - - r = listeners.keys - w = r.select { |w2| w2.respond_to?(:pending_write?) && w2.pending_write? } - readers, writers, = Net::SSH::Compat.io_select(r, w, nil, wait) - - postprocess(readers, writers) - end - - # This is called internally as part of #process. It dispatches any - # available incoming packets, and then runs Net::SSH::Connection::Channel#process - # for any active channels. If a block is given, it is invoked at the - # start of the method and again at the end, and if the block ever returns - # false, this method returns false. Otherwise, it returns true. - def preprocess - return false if block_given? && !yield(self) - dispatch_incoming_packets - channels.each { |id, channel| channel.process unless channel.closing? } - return false if block_given? && !yield(self) - return true - end - - # This is called internally as part of #process. It loops over the given - # arrays of reader IO's and writer IO's, processing them as needed, and - # then calls Net::SSH::Transport::Session#rekey_as_needed to allow the - # transport layer to rekey. Then returns true. - def postprocess(readers, writers) - Array(readers).each do |reader| - if listeners[reader] - listeners[reader].call(reader) - else - if reader.fill.zero? - reader.close - stop_listening_to(reader) - end - end - end - - Array(writers).each do |writer| - writer.send_pending - end - - transport.rekey_as_needed - - return true - end - - # Send a global request of the given type. The +extra+ parameters must - # be even in number, and conform to the same format as described for - # Net::SSH::Buffer.from. If a callback is not specified, the request will - # not require a response from the server, otherwise the server is required - # to respond and indicate whether the request was successful or not. This - # success or failure is indicated by the callback being invoked, with the - # first parameter being true or false (success, or failure), and the second - # being the packet itself. - # - # Generally, Net::SSH will manage global requests that need to be sent - # (e.g. port forward requests and such are handled in the Net::SSH::Service::Forward - # class, for instance). However, there may be times when you need to - # send a global request that isn't explicitly handled by Net::SSH, and so - # this method is available to you. - # - # ssh.send_global_request("keep-alive@openssh.com") - def send_global_request(type, *extra, &callback) - info { "sending global request #{type}" } - msg = Buffer.from(:byte, GLOBAL_REQUEST, :string, type.to_s, :bool, !callback.nil?, *extra) - send_message(msg) - pending_requests << callback if callback - self - end - - # Requests that a new channel be opened. By default, the channel will be - # of type "session", but if you know what you're doing you can select any - # of the channel types supported by the SSH protocol. The +extra+ parameters - # must be even in number and conform to the same format as described for - # Net::SSH::Buffer.from. If a callback is given, it will be invoked when - # the server confirms that the channel opened successfully. The sole parameter - # for the callback is the channel object itself. - # - # In general, you'll use #open_channel without any arguments; the only - # time you'd want to set the channel type or pass additional initialization - # data is if you were implementing an SSH extension. - # - # channel = ssh.open_channel do |ch| - # ch.exec "grep something /some/files" do |ch, success| - # ... - # end - # end - # - # channel.wait - def open_channel(type="session", *extra, &on_confirm) - local_id = get_next_channel_id - channel = Channel.new(self, type, local_id, &on_confirm) - - msg = Buffer.from(:byte, CHANNEL_OPEN, :string, type, :long, local_id, - :long, channel.local_maximum_window_size, - :long, channel.local_maximum_packet_size, *extra) - send_message(msg) - - channels[local_id] = channel - end - - # A convenience method for executing a command and interacting with it. If - # no block is given, all output is printed via $stdout and $stderr. Otherwise, - # the block is called for each data and extended data packet, with three - # arguments: the channel object, a symbol indicating the data type - # (:stdout or :stderr), and the data (as a string). - # - # Note that this method returns immediately, and requires an event loop - # (see Session#loop) in order for the command to actually execute. - # - # This is effectively identical to calling #open_channel, and then - # Net::SSH::Connection::Channel#exec, and then setting up the channel - # callbacks. However, for most uses, this will be sufficient. - # - # ssh.exec "grep something /some/files" do |ch, stream, data| - # if stream == :stderr - # puts "ERROR: #{data}" - # else - # puts data - # end - # end - def exec(command, &block) - open_channel do |channel| - channel.exec(command) do |ch, success| - raise "could not execute command: #{command.inspect}" unless success - - channel.on_data do |ch2, data| - if block - block.call(ch2, :stdout, data) - else - $stdout.print(data) - end - end - - channel.on_extended_data do |ch2, type, data| - if block - block.call(ch2, :stderr, data) - else - $stderr.print(data) - end - end - end - end - end - - # Same as #exec, except this will block until the command finishes. Also, - # if a block is not given, this will return all output (stdout and stderr) - # as a single string. - # - # matches = ssh.exec!("grep something /some/files") - def exec!(command, &block) - block ||= Proc.new do |ch, type, data| - ch[:result] ||= "" - ch[:result] << data - end - - channel = exec(command, &block) - channel.wait - - return channel[:result] - end - - # Enqueues a message to be sent to the server as soon as the socket is - # available for writing. Most programs will never need to call this, but - # if you are implementing an extension to the SSH protocol, or if you - # need to send a packet that Net::SSH does not directly support, you can - # use this to send it. - # - # ssh.send_message(Buffer.from(:byte, REQUEST_SUCCESS).to_s) - def send_message(message) - transport.enqueue_message(message) - end - - # Adds an IO object for the event loop to listen to. If a callback - # is given, it will be invoked when the io is ready to be read, otherwise, - # the io will merely have its #fill method invoked. - # - # Any +io+ value passed to this method _must_ have mixed into it the - # Net::SSH::BufferedIo functionality, typically by calling #extend on the - # object. - # - # The following example executes a process on the remote server, opens - # a socket to somewhere, and then pipes data from that socket to the - # remote process' stdin stream: - # - # channel = ssh.open_channel do |ch| - # ch.exec "/some/process/that/wants/input" do |ch, success| - # abort "can't execute!" unless success - # - # io = TCPSocket.new(somewhere, port) - # io.extend(Net::SSH::BufferedIo) - # ssh.listen_to(io) - # - # ch.on_process do - # if io.available > 0 - # ch.send_data(io.read_available) - # end - # end - # - # ch.on_close do - # ssh.stop_listening_to(io) - # io.close - # end - # end - # end - # - # channel.wait - def listen_to(io, &callback) - listeners[io] = callback - end - - # Removes the given io object from the listeners collection, so that the - # event loop will no longer monitor it. - def stop_listening_to(io) - listeners.delete(io) - end - - # Returns a reference to the Net::SSH::Service::Forward service, which can - # be used for forwarding ports over SSH. - def forward - @forward ||= Service::Forward.new(self) - end - - # Registers a handler to be invoked when the server wants to open a - # channel on the client. The callback receives the connection object, - # the new channel object, and the packet itself as arguments, and should - # raise ChannelOpenFailed if it is unable to open the channel for some - # reason. Otherwise, the channel will be opened and a confirmation message - # sent to the server. - # - # This is used by the Net::SSH::Service::Forward service to open a channel - # when a remote forwarded port receives a connection. However, you are - # welcome to register handlers for other channel types, as needed. - def on_open_channel(type, &block) - channel_open_handlers[type] = block - end - - # Registers a handler to be invoked when the server sends a global request - # of the given type. The callback receives the request data as the first - # parameter, and true/false as the second (indicating whether a response - # is required). If the callback sends the response, it should return - # :sent. Otherwise, if it returns true, REQUEST_SUCCESS will be sent, and - # if it returns false, REQUEST_FAILURE will be sent. - def on_global_request(type, &block) - old, @on_global_request[type] = @on_global_request[type], block - old - end - - private - - # Read all pending packets from the connection and dispatch them as - # appropriate. Returns as soon as there are no more pending packets. - def dispatch_incoming_packets - while packet = transport.poll_message - unless MAP.key?(packet.type) - raise Net::SSH::Exception, "unexpected response #{packet.type} (#{packet.inspect})" - end - - send(MAP[packet.type], packet) - end - end - - # Returns the next available channel id to be assigned, and increments - # the counter. - def get_next_channel_id - @channel_id_counter += 1 - end - - # Invoked when a global request is received. The registered global - # request callback will be invoked, if one exists, and the necessary - # reply returned. - def global_request(packet) - info { "global request received: #{packet[:request_type]} #{packet[:want_reply]}" } - callback = @on_global_request[packet[:request_type]] - result = callback ? callback.call(packet[:request_data], packet[:want_reply]) : false - - if result != :sent && result != true && result != false - raise "expected global request handler for `#{packet[:request_type]}' to return true, false, or :sent, but got #{result.inspect}" - end - - if packet[:want_reply] && result != :sent - msg = Buffer.from(:byte, result ? REQUEST_SUCCESS : REQUEST_FAILURE) - send_message(msg) - end - end - - # Invokes the next pending request callback with +true+. - def request_success(packet) - info { "global request success" } - callback = pending_requests.shift - callback.call(true, packet) if callback - end - - # Invokes the next pending request callback with +false+. - def request_failure(packet) - info { "global request failure" } - callback = pending_requests.shift - callback.call(false, packet) if callback - end - - # Called when the server wants to open a channel. If no registered - # channel handler exists for the given channel type, CHANNEL_OPEN_FAILURE - # is returned, otherwise the callback is invoked and everything proceeds - # accordingly. - def channel_open(packet) - info { "channel open #{packet[:channel_type]}" } - - local_id = get_next_channel_id - channel = Channel.new(self, packet[:channel_type], local_id) - channel.do_open_confirmation(packet[:remote_id], packet[:window_size], packet[:packet_size]) - - callback = channel_open_handlers[packet[:channel_type]] - - if callback - begin - callback[self, channel, packet] - rescue ChannelOpenFailed => err - failure = [err.code, err.reason] - else - channels[local_id] = channel - msg = Buffer.from(:byte, CHANNEL_OPEN_CONFIRMATION, :long, channel.remote_id, :long, channel.local_id, :long, channel.local_maximum_window_size, :long, channel.local_maximum_packet_size) - end - else - failure = [3, "unknown channel type #{channel.type}"] - end - - if failure - error { failure.inspect } - msg = Buffer.from(:byte, CHANNEL_OPEN_FAILURE, :long, channel.remote_id, :long, failure[0], :string, failure[1], :string, "") - end - - send_message(msg) - end - - def channel_open_confirmation(packet) - info { "channel_open_confirmation: #{packet[:local_id]} #{packet[:remote_id]} #{packet[:window_size]} #{packet[:packet_size]}" } - channel = channels[packet[:local_id]] - channel.do_open_confirmation(packet[:remote_id], packet[:window_size], packet[:packet_size]) - end - - def channel_open_failure(packet) - error { "channel_open_failed: #{packet[:local_id]} #{packet[:reason_code]} #{packet[:description]}" } - channel = channels.delete(packet[:local_id]) - channel.do_open_failed(packet[:reason_code], packet[:description]) - end - - def channel_window_adjust(packet) - info { "channel_window_adjust: #{packet[:local_id]} +#{packet[:extra_bytes]}" } - channels[packet[:local_id]].do_window_adjust(packet[:extra_bytes]) - end - - def channel_request(packet) - info { "channel_request: #{packet[:local_id]} #{packet[:request]} #{packet[:want_reply]}" } - channels[packet[:local_id]].do_request(packet[:request], packet[:want_reply], packet[:request_data]) - end - - def channel_data(packet) - info { "channel_data: #{packet[:local_id]} #{packet[:data].length}b" } - channels[packet[:local_id]].do_data(packet[:data]) - end - - def channel_extended_data(packet) - info { "channel_extended_data: #{packet[:local_id]} #{packet[:data_type]} #{packet[:data].length}b" } - channels[packet[:local_id]].do_extended_data(packet[:data_type], packet[:data]) - end - - def channel_eof(packet) - info { "channel_eof: #{packet[:local_id]}" } - channels[packet[:local_id]].do_eof - end - - def channel_close(packet) - info { "channel_close: #{packet[:local_id]}" } - - channel = channels[packet[:local_id]] - channel.close - - channels.delete(packet[:local_id]) - channel.do_close - end - - def channel_success(packet) - info { "channel_success: #{packet[:local_id]}" } - channels[packet[:local_id]].do_success - end - - def channel_failure(packet) - info { "channel_failure: #{packet[:local_id]}" } - channels[packet[:local_id]].do_failure - end - - MAP = Constants.constants.inject({}) do |memo, name| - value = const_get(name) - next unless Integer === value - memo[value] = name.downcase.to_sym - memo - end - end - -end; end; end diff --git a/vendor/gems/net-ssh-2.0.15/lib/net/ssh/connection/term.rb b/vendor/gems/net-ssh-2.0.15/lib/net/ssh/connection/term.rb deleted file mode 100644 index 3e1caa5d0..000000000 --- a/vendor/gems/net-ssh-2.0.15/lib/net/ssh/connection/term.rb +++ /dev/null @@ -1,178 +0,0 @@ -module Net; module SSH; module Connection - - # These constants are used when requesting a pseudo-terminal (via - # Net::SSH::Connection::Channel#request_pty). The descriptions for each are - # taken directly from RFC 4254 ("The Secure Shell (SSH) Connection Protocol"), - # http://tools.ietf.org/html/rfc4254. - module Term - # Interrupt character; 255 if none. Similarly for the other characters. - # Not all of these characters are supported on all systems. - VINTR = 1 - - # The quit character (sends SIGQUIT signal on POSIX systems). - VQUIT = 2 - - # Erase the character to left of the cursor. - VERASE = 3 - - # Kill the current input line. - VKILL = 4 - - # End-of-file character (sends EOF from the terminal). - VEOF = 5 - - # End-of-line character in addition to carriage return and/or linefeed. - VEOL = 6 - - # Additional end-of-line character. - VEOL2 = 7 - - # Continues paused output (normally control-Q). - VSTART = 8 - - # Pauses output (normally control-S). - VSTOP = 9 - - # Suspends the current program. - VSUSP = 10 - - # Another suspend character. - VDSUSP = 11 - - # Reprints the current input line. - VREPRINT = 12 - - # Erases a word left of cursor. - VWERASE = 13 - - # Enter the next character typed literally, even if it is a special - # character. - VLNEXT = 14 - - # Character to flush output. - VFLUSH = 15 - - # Switch to a different shell layer. - VSWITCH = 16 - - # Prints system status line (load, command, pid, etc). - VSTATUS = 17 - - # Toggles the flushing of terminal output. - VDISCARD = 18 - - # The ignore parity flag. The parameter SHOULD be 0 if this flag is FALSE, - # and 1 if it is TRUE. - IGNPAR = 30 - - # Mark parity and framing errors. - PARMRK = 31 - - # Enable checking of parity errors. - INPCK = 32 - - # Strip 8th bit off characters. - ISTRIP = 33 - - # Map NL into CR on input. - INCLR = 34 - - # Ignore CR on input. - IGNCR = 35 - - # Map CR to NL on input. - ICRNL = 36 - - # Translate uppercase characters to lowercase. - IUCLC = 37 - - # Enable output flow control. - IXON = 38 - - # Any char will restart after stop. - IXANY = 39 - - # Enable input flow control. - IXOFF = 40 - - # Ring bell on input queue full. - IMAXBEL = 41 - - # Enable signals INTR, QUIT, [D]SUSP. - ISIG = 50 - - # Canonicalize input lines. - ICANON = 51 - - # Enable input and output of uppercase characters by preceding their - # lowercase equivalents with "\". - XCASE = 52 - - # Enable echoing. - ECHO = 53 - - # Visually erase chars. - ECHOE = 54 - - # Kill character discards current line. - ECHOK = 55 - - # Echo NL even if ECHO is off. - ECHONL = 56 - - # Don't flush after interrupt. - NOFLSH = 57 - - # Stop background jobs from output. - TOSTOP= 58 - - # Enable extensions. - IEXTEN = 59 - - # Echo control characters as ^(Char). - ECHOCTL = 60 - - # Visual erase for line kill. - ECHOKE = 61 - - # Retype pending input. - PENDIN = 62 - - # Enable output processing. - OPOST = 70 - - # Convert lowercase to uppercase. - OLCUC = 71 - - # Map NL to CR-NL. - ONLCR = 72 - - # Translate carriage return to newline (output). - OCRNL = 73 - - # Translate newline to carriage return-newline (output). - ONOCR = 74 - - # Newline performs a carriage return (output). - ONLRET = 75 - - # 7 bit mode. - CS7 = 90 - - # 8 bit mode. - CS8 = 91 - - # Parity enable. - PARENB = 92 - - # Odd parity, else even. - PARODD = 93 - - # Specifies the input baud rate in bits per second. - TTY_OP_ISPEED = 128 - - # Specifies the output baud rate in bits per second. - TTY_OP_OSPEED = 129 - end - -end; end; end diff --git a/vendor/gems/net-ssh-2.0.15/lib/net/ssh/errors.rb b/vendor/gems/net-ssh-2.0.15/lib/net/ssh/errors.rb deleted file mode 100644 index e65327806..000000000 --- a/vendor/gems/net-ssh-2.0.15/lib/net/ssh/errors.rb +++ /dev/null @@ -1,85 +0,0 @@ -module Net; module SSH - # A general exception class, to act as the ancestor of all other Net::SSH - # exception classes. - class Exception < ::RuntimeError; end - - # This exception is raised when authentication fails (whether it be - # public key authentication, password authentication, or whatever). - class AuthenticationFailed < Exception; end - - # This exception is raised when the remote host has disconnected - # unexpectedly. - class Disconnect < Exception; end - - # This exception is primarily used internally, but if you have a channel - # request handler (see Net::SSH::Connection::Channel#on_request) that you - # want to fail in such a way that the server knows it failed, you can - # raise this exception in the handler and Net::SSH will translate that into - # a "channel failure" message. - class ChannelRequestFailed < Exception; end - - # This is exception is primarily used internally, but if you have a channel - # open handler (see Net::SSH::Connection::Session#on_open_channel) and you - # want to fail in such a way that the server knows it failed, you can - # raise this exception in the handler and Net::SSH will translate that into - # a "channel open failed" message. - class ChannelOpenFailed < Exception - attr_reader :code, :reason - - def initialize(code, reason) - @code, @reason = code, reason - super "#{reason} (#{code})" - end - end - - # Raised when the cached key for a particular host does not match the - # key given by the host, which can be indicative of a man-in-the-middle - # attack. When rescuing this exception, you can inspect the key fingerprint - # and, if you want to proceed anyway, simply call the remember_host! - # method on the exception, and then retry. - class HostKeyMismatch < Exception - # the callback to use when #remember_host! is called - attr_writer :callback #:nodoc: - - # situation-specific data describing the host (see #host, #port, etc.) - attr_writer :data #:nodoc: - - # An accessor for getting at the data that was used to look up the host - # (see also #fingerprint, #host, #port, #ip, and #key). - def [](key) - @data && @data[key] - end - - # Returns the fingerprint of the key for the host, which either was not - # found or did not match. - def fingerprint - @data && @data[:fingerprint] - end - - # Returns the host name for the remote host, as reported by the socket. - def host - @data && @data[:peer] && @data[:peer][:host] - end - - # Returns the port number for the remote host, as reported by the socket. - def port - @data && @data[:peer] && @data[:peer][:port] - end - - # Returns the IP address of the remote host, as reported by the socket. - def ip - @data && @data[:peer] && @data[:peer][:ip] - end - - # Returns the key itself, as reported by the remote host. - def key - @data && @data[:key] - end - - # Tell Net::SSH to record this host and key in the known hosts file, so - # that subsequent connections will remember them. - def remember_host! - @callback.call - end - end -end; end \ No newline at end of file diff --git a/vendor/gems/net-ssh-2.0.15/lib/net/ssh/key_factory.rb b/vendor/gems/net-ssh-2.0.15/lib/net/ssh/key_factory.rb deleted file mode 100644 index cec1d3b95..000000000 --- a/vendor/gems/net-ssh-2.0.15/lib/net/ssh/key_factory.rb +++ /dev/null @@ -1,102 +0,0 @@ -require 'net/ssh/transport/openssl' -require 'net/ssh/prompt' - -module Net; module SSH - - # A factory class for returning new Key classes. It is used for obtaining - # OpenSSL key instances via their SSH names, and for loading both public and - # private keys. It used used primarily by Net::SSH itself, internally, and - # will rarely (if ever) be directly used by consumers of the library. - # - # klass = Net::SSH::KeyFactory.get("rsa") - # assert klass.is_a?(OpenSSL::PKey::RSA) - # - # key = Net::SSH::KeyFacory.load_public_key("~/.ssh/id_dsa.pub") - class KeyFactory - # Specifies the mapping of SSH names to OpenSSL key classes. - MAP = { - "dh" => OpenSSL::PKey::DH, - "rsa" => OpenSSL::PKey::RSA, - "dsa" => OpenSSL::PKey::DSA - } - - class < e - if encrypted_key - tries += 1 - if tries <= 3 - passphrase = prompt("Enter passphrase for #{filename}:", false) - retry - else - raise - end - else - raise - end - end - end - - # Loads a public key from a file. It will correctly determine whether - # the file describes an RSA or DSA key, and will load it - # appropriately. The new public key is returned. - def load_public_key(filename) - data = File.read(File.expand_path(filename)) - load_data_public_key(data, filename) - end - - # Loads a public key. It will correctly determine whether - # the file describes an RSA or DSA key, and will load it - # appropriately. The new public key is returned. - def load_data_public_key(data, filename="") - type, blob = data.split(/ /) - - raise Net::SSH::Exception, "public key at #{filename} is not valid" if blob.nil? - - blob = blob.unpack("m*").first - reader = Net::SSH::Buffer.new(blob) - reader.read_key or raise OpenSSL::PKey::PKeyError, "not a public key #{filename.inspect}" - end - end - - end - -end; end diff --git a/vendor/gems/net-ssh-2.0.15/lib/net/ssh/known_hosts.rb b/vendor/gems/net-ssh-2.0.15/lib/net/ssh/known_hosts.rb deleted file mode 100644 index 7b153d49c..000000000 --- a/vendor/gems/net-ssh-2.0.15/lib/net/ssh/known_hosts.rb +++ /dev/null @@ -1,129 +0,0 @@ -require 'strscan' -require 'net/ssh/buffer' - -module Net; module SSH - - # Searches an OpenSSH-style known-host file for a given host, and returns all - # matching keys. This is used to implement host-key verification, as well as - # to determine what key a user prefers to use for a given host. - # - # This is used internally by Net::SSH, and will never need to be used directly - # by consumers of the library. - class KnownHosts - class < 98 (CHANNEL_REQUEST) - # p packet[:request] - # p packet[:want_reply] - # - # This is used exclusively internally by Net::SSH, and unless you're doing - # protocol-level manipulation or are extending Net::SSH in some way, you'll - # never need to use this class directly. - class Packet < Buffer - @@types = {} - - # Register a new packet type that should be recognized and auto-parsed by - # Net::SSH::Packet. Note that any packet type that is not preregistered - # will not be autoparsed. - # - # The +pairs+ parameter must be either empty, or an array of two-element - # tuples, where the first element of each tuple is the name of the field, - # and the second is the type. - # - # register DISCONNECT, [:reason_code, :long], [:description, :string], [:language, :string] - def self.register(type, *pairs) - @@types[type] = pairs - end - - include Transport::Constants, Authentication::Constants, Connection::Constants - - #-- - # These are the recognized packet types. All other packet types will be - # accepted, but not auto-parsed, requiring the client to parse the - # fields using the methods provided by Net::SSH::Buffer. - #++ - - register DISCONNECT, [:reason_code, :long], [:description, :string], [:language, :string] - register IGNORE, [:data, :string] - register UNIMPLEMENTED, [:number, :long] - register DEBUG, [:always_display, :bool], [:message, :string], [:language, :string] - register SERVICE_ACCEPT, [:service_name, :string] - register USERAUTH_BANNER, [:message, :string], [:language, :string] - register USERAUTH_FAILURE, [:authentications, :string], [:partial_success, :bool] - register GLOBAL_REQUEST, [:request_type, :string], [:want_reply, :bool], [:request_data, :buffer] - register CHANNEL_OPEN, [:channel_type, :string], [:remote_id, :long], [:window_size, :long], [:packet_size, :long] - register CHANNEL_OPEN_CONFIRMATION, [:local_id, :long], [:remote_id, :long], [:window_size, :long], [:packet_size, :long] - register CHANNEL_OPEN_FAILURE, [:local_id, :long], [:reason_code, :long], [:description, :string], [:language, :string] - register CHANNEL_WINDOW_ADJUST, [:local_id, :long], [:extra_bytes, :long] - register CHANNEL_DATA, [:local_id, :long], [:data, :string] - register CHANNEL_EXTENDED_DATA, [:local_id, :long], [:data_type, :long], [:data, :string] - register CHANNEL_EOF, [:local_id, :long] - register CHANNEL_CLOSE, [:local_id, :long] - register CHANNEL_REQUEST, [:local_id, :long], [:request, :string], [:want_reply, :bool], [:request_data, :buffer] - register CHANNEL_SUCCESS, [:local_id, :long] - register CHANNEL_FAILURE, [:local_id, :long] - - # The (integer) type of this packet. - attr_reader :type - - # Create a new packet from the given payload. This will automatically - # parse the packet if it is one that has been previously registered with - # Packet.register; otherwise, the packet will need to be manually parsed - # using the methods provided in the Net::SSH::Buffer superclass. - def initialize(payload) - @named_elements = {} - super - @type = read_byte - instantiate! - end - - # Access one of the auto-parsed fields by name. Raises an error if no - # element by the given name exists. - def [](name) - name = name.to_sym - raise ArgumentError, "no such element #{name}" unless @named_elements.key?(name) - @named_elements[name] - end - - private - - # Parse the packet's contents and assign the named elements, as described - # by the registered format for the packet. - def instantiate! - (@@types[type] || []).each do |name, datatype| - @named_elements[name.to_sym] = if datatype == :buffer - remainder_as_buffer - else - send("read_#{datatype}") - end - end - end - end -end; end \ No newline at end of file diff --git a/vendor/gems/net-ssh-2.0.15/lib/net/ssh/prompt.rb b/vendor/gems/net-ssh-2.0.15/lib/net/ssh/prompt.rb deleted file mode 100644 index 505e0b3d4..000000000 --- a/vendor/gems/net-ssh-2.0.15/lib/net/ssh/prompt.rb +++ /dev/null @@ -1,93 +0,0 @@ -module Net; module SSH - - # A basic prompt module that can be mixed into other objects. If HighLine is - # installed, it will be used to display prompts and read input from the - # user. Otherwise, the termios library will be used. If neither HighLine - # nor termios is installed, a simple prompt that echos text in the clear - # will be used. - - module PromptMethods - - # Defines the prompt method to use if the Highline library is installed. - module Highline - # Uses Highline#ask to present a prompt and accept input. If +echo+ is - # +false+, the characters entered by the user will not be echoed to the - # screen. - def prompt(prompt, echo=true) - @highline ||= ::HighLine.new - @highline.ask(prompt + " ") { |q| q.echo = echo } - end - end - - # Defines the prompt method to use if the Termios library is installed. - module Termios - # Displays the prompt to $stdout. If +echo+ is false, the Termios - # library will be used to disable keystroke echoing for the duration of - # this method. - def prompt(prompt, echo=true) - $stdout.print(prompt) - $stdout.flush - - set_echo(false) unless echo - $stdin.gets.chomp - ensure - if !echo - set_echo(true) - $stdout.puts - end - end - - private - - # Enables or disables keystroke echoing using the Termios library. - def set_echo(enable) - term = ::Termios.getattr($stdin) - - if enable - term.c_lflag |= (::Termios::ECHO | ::Termios::ICANON) - else - term.c_lflag &= ~::Termios::ECHO - end - - ::Termios.setattr($stdin, ::Termios::TCSANOW, term) - end - end - - # Defines the prompt method to use when neither Highline nor Termios are - # installed. - module Clear - # Displays the prompt to $stdout and pulls the response from $stdin. - # Text is always echoed in the clear, regardless of the +echo+ setting. - # The first time a prompt is given and +echo+ is false, a warning will - # be written to $stderr recommending that either Highline or Termios - # be installed. - def prompt(prompt, echo=true) - @seen_warning ||= false - if !echo && !@seen_warning - $stderr.puts "Text will be echoed in the clear. Please install the HighLine or Termios libraries to suppress echoed text." - @seen_warning = true - end - - $stdout.print(prompt) - $stdout.flush - $stdin.gets.chomp - end - end - end - - # Try to load Highline and Termios in turn, selecting the corresponding - # PromptMethods module to use. If neither are available, choose PromptMethods::Clear. - Prompt = begin - require 'highline' - HighLine.track_eof = false - PromptMethods::Highline - rescue LoadError - begin - require 'termios' - PromptMethods::Termios - rescue LoadError - PromptMethods::Clear - end - end - -end; end \ No newline at end of file diff --git a/vendor/gems/net-ssh-2.0.15/lib/net/ssh/proxy/errors.rb b/vendor/gems/net-ssh-2.0.15/lib/net/ssh/proxy/errors.rb deleted file mode 100644 index 6eb3501a9..000000000 --- a/vendor/gems/net-ssh-2.0.15/lib/net/ssh/proxy/errors.rb +++ /dev/null @@ -1,14 +0,0 @@ -require 'net/ssh/errors' - -module Net; module SSH; module Proxy - - # A general exception class for all Proxy errors. - class Error < Net::SSH::Exception; end - - # Used for reporting proxy connection errors. - class ConnectError < Error; end - - # Used when the server doesn't recognize the user's credentials. - class UnauthorizedError < Error; end - -end; end; end diff --git a/vendor/gems/net-ssh-2.0.15/lib/net/ssh/proxy/http.rb b/vendor/gems/net-ssh-2.0.15/lib/net/ssh/proxy/http.rb deleted file mode 100644 index 4f86dcfc5..000000000 --- a/vendor/gems/net-ssh-2.0.15/lib/net/ssh/proxy/http.rb +++ /dev/null @@ -1,94 +0,0 @@ -require 'socket' -require 'net/ssh/proxy/errors' - -module Net; module SSH; module Proxy - - # An implementation of an HTTP proxy. To use it, instantiate it, then - # pass the instantiated object via the :proxy key to Net::SSH.start: - # - # require 'net/ssh/proxy/http' - # - # proxy = Net::SSH::Proxy::HTTP.new('proxy.host', proxy_port) - # Net::SSH.start('host', 'user', :proxy => proxy) do |ssh| - # ... - # end - # - # If the proxy requires authentication, you can pass :user and :password - # to the proxy's constructor: - # - # proxy = Net::SSH::Proxy::HTTP.new('proxy.host', proxy_port, - # :user => "user", :password => "password") - # - # Note that HTTP digest authentication is not supported; Basic only at - # this point. - class HTTP - - # The hostname or IP address of the HTTP proxy. - attr_reader :proxy_host - - # The port number of the proxy. - attr_reader :proxy_port - - # The map of additional options that were given to the object at - # initialization. - attr_reader :options - - # Create a new socket factory that tunnels via the given host and - # port. The +options+ parameter is a hash of additional settings that - # can be used to tweak this proxy connection. Specifically, the following - # options are supported: - # - # * :user => the user name to use when authenticating to the proxy - # * :password => the password to use when authenticating - def initialize(proxy_host, proxy_port=80, options={}) - @proxy_host = proxy_host - @proxy_port = proxy_port - @options = options - end - - # Return a new socket connected to the given host and port via the - # proxy that was requested when the socket factory was instantiated. - def open(host, port) - socket = TCPSocket.new(proxy_host, proxy_port) - socket.write "CONNECT #{host}:#{port} HTTP/1.0\r\n" - - if options[:user] - credentials = ["#{options[:user]}:#{options[:password]}"].pack("m*").gsub(/\s/, "") - socket.write "Proxy-Authorization: Basic #{credentials}\r\n" - end - - socket.write "\r\n" - - resp = parse_response(socket) - - return socket if resp[:code] == 200 - - socket.close - raise ConnectError, resp.inspect - end - - private - - def parse_response(socket) - version, code, reason = socket.gets.chomp.split(/ /, 3) - headers = {} - - while (line = socket.gets.chomp) != "" - name, value = line.split(/:/, 2) - headers[name.strip] = value.strip - end - - if headers["Content-Length"] - body = socket.read(headers["Content-Length"].to_i) - end - - return { :version => version, - :code => code.to_i, - :reason => reason, - :headers => headers, - :body => body } - end - - end - -end; end; end diff --git a/vendor/gems/net-ssh-2.0.15/lib/net/ssh/proxy/socks4.rb b/vendor/gems/net-ssh-2.0.15/lib/net/ssh/proxy/socks4.rb deleted file mode 100644 index fdb1e3295..000000000 --- a/vendor/gems/net-ssh-2.0.15/lib/net/ssh/proxy/socks4.rb +++ /dev/null @@ -1,70 +0,0 @@ -require 'socket' -require 'resolv' -require 'ipaddr' -require 'net/ssh/proxy/errors' - -module Net - module SSH - module Proxy - - # An implementation of a SOCKS4 proxy. To use it, instantiate it, then - # pass the instantiated object via the :proxy key to Net::SSH.start: - # - # require 'net/ssh/proxy/socks4' - # - # proxy = Net::SSH::Proxy::SOCKS4.new('proxy.host', proxy_port, :user => 'user') - # Net::SSH.start('host', 'user', :proxy => proxy) do |ssh| - # ... - # end - class SOCKS4 - - # The SOCKS protocol version used by this class - VERSION = 4 - - # The packet type for connection requests - CONNECT = 1 - - # The status code for a successful connection - GRANTED = 90 - - # The proxy's host name or IP address, as given to the constructor. - attr_reader :proxy_host - - # The proxy's port number. - attr_reader :proxy_port - - # The additional options that were given to the proxy's constructor. - attr_reader :options - - # Create a new proxy connection to the given proxy host and port. - # Optionally, a :user key may be given to identify the username - # with which to authenticate. - def initialize(proxy_host, proxy_port=1080, options={}) - @proxy_host = proxy_host - @proxy_port = proxy_port - @options = options - end - - # Return a new socket connected to the given host and port via the - # proxy that was requested when the socket factory was instantiated. - def open(host, port) - socket = TCPSocket.new(proxy_host, proxy_port) - ip_addr = IPAddr.new(Resolv.getaddress(host)) - - packet = [VERSION, CONNECT, port.to_i, ip_addr.to_i, options[:user]].pack("CCnNZ*") - socket.send packet, 0 - - version, status, port, ip = socket.recv(8).unpack("CCnN") - if status != GRANTED - socket.close - raise ConnectError, "error connecting to proxy (#{status})" - end - - return socket - end - - end - - end - end -end diff --git a/vendor/gems/net-ssh-2.0.15/lib/net/ssh/proxy/socks5.rb b/vendor/gems/net-ssh-2.0.15/lib/net/ssh/proxy/socks5.rb deleted file mode 100644 index 7fc06003e..000000000 --- a/vendor/gems/net-ssh-2.0.15/lib/net/ssh/proxy/socks5.rb +++ /dev/null @@ -1,142 +0,0 @@ -require 'socket' -require 'net/ssh/ruby_compat' -require 'net/ssh/proxy/errors' - -module Net - module SSH - module Proxy - - # An implementation of a SOCKS5 proxy. To use it, instantiate it, then - # pass the instantiated object via the :proxy key to Net::SSH.start: - # - # require 'net/ssh/proxy/socks5' - # - # proxy = Net::SSH::Proxy::SOCKS5.new('proxy.host', proxy_port, - # :user => 'user', :password => "password") - # Net::SSH.start('host', 'user', :proxy => proxy) do |ssh| - # ... - # end - class SOCKS5 - # The SOCKS protocol version used by this class - VERSION = 5 - - # The SOCKS authentication type for requests without authentication - METHOD_NO_AUTH = 0 - - # The SOCKS authentication type for requests via username/password - METHOD_PASSWD = 2 - - # The SOCKS authentication type for when there are no supported - # authentication methods. - METHOD_NONE = 0xFF - - # The SOCKS packet type for requesting a proxy connection. - CMD_CONNECT = 1 - - # The SOCKS address type for connections via IP address. - ATYP_IPV4 = 1 - - # The SOCKS address type for connections via domain name. - ATYP_DOMAIN = 3 - - # The SOCKS response code for a successful operation. - SUCCESS = 0 - - # The proxy's host name or IP address - attr_reader :proxy_host - - # The proxy's port number - attr_reader :proxy_port - - # The map of options given at initialization - attr_reader :options - - # Create a new proxy connection to the given proxy host and port. - # Optionally, :user and :password options may be given to - # identify the username and password with which to authenticate. - def initialize(proxy_host, proxy_port=1080, options={}) - @proxy_host = proxy_host - @proxy_port = proxy_port - @options = options - end - - # Return a new socket connected to the given host and port via the - # proxy that was requested when the socket factory was instantiated. - def open(host, port) - socket = TCPSocket.new(proxy_host, proxy_port) - - methods = [METHOD_NO_AUTH] - methods << METHOD_PASSWD if options[:user] - - packet = [VERSION, methods.size, *methods].pack("C*") - socket.send packet, 0 - - version, method = socket.recv(2).unpack("CC") - if version != VERSION - socket.close - raise Net::SSH::Proxy::Error, "invalid SOCKS version (#{version})" - end - - if method == METHOD_NONE - socket.close - raise Net::SSH::Proxy::Error, "no supported authorization methods" - end - - negotiate_password(socket) if method == METHOD_PASSWD - - packet = [VERSION, CMD_CONNECT, 0].pack("C*") - - if host =~ /^(\d+)\.(\d+)\.(\d+)\.(\d+)$/ - packet << [ATYP_IPV4, $1.to_i, $2.to_i, $3.to_i, $4.to_i].pack("C*") - else - packet << [ATYP_DOMAIN, host.length, host].pack("CCA*") - end - - packet << [port].pack("n") - socket.send packet, 0 - - version, reply, = socket.recv(2).unpack("C*") - socket.recv(1) - address_type = socket.recv(1).getbyte(0) - case address_type - when 1 - socket.recv(4) # get four bytes for IPv4 address - when 3 - len = socket.recv(1).getbyte(0) - hostname = socket.recv(len) - when 4 - ipv6addr hostname = socket.recv(16) - else - socket.close - raise ConnectionError, "Illegal response type" - end - portnum = socket.recv(2) - - unless reply == SUCCESS - socket.close - raise ConnectError, "#{reply}" - end - - return socket - end - - private - - # Simple username/password negotiation with the SOCKS5 server. - def negotiate_password(socket) - packet = [0x01, options[:user].length, options[:user], - options[:password].length, options[:password]].pack("CCA*CA*") - socket.send packet, 0 - - version, status = socket.recv(2).unpack("CC") - - if status != SUCCESS - socket.close - raise UnauthorizedError, "could not authorize user" - end - end - end - - end - end -end diff --git a/vendor/gems/net-ssh-2.0.15/lib/net/ssh/ruby_compat.rb b/vendor/gems/net-ssh-2.0.15/lib/net/ssh/ruby_compat.rb deleted file mode 100644 index 8a1c8f22b..000000000 --- a/vendor/gems/net-ssh-2.0.15/lib/net/ssh/ruby_compat.rb +++ /dev/null @@ -1,43 +0,0 @@ -require 'thread' - -class String - if RUBY_VERSION < "1.9" - def getbyte(index) - self[index] - end - end -end - -module Net; module SSH - - # This class contains miscellaneous patches and workarounds - # for different ruby implementations. - class Compat - - # A workaround for an IO#select threading bug in certain versions of MRI 1.8. - # See: http://net-ssh.lighthouseapp.com/projects/36253/tickets/1-ioselect-threading-bug-in-ruby-18 - # The root issue is documented here: http://redmine.ruby-lang.org/issues/show/1993 - if RUBY_VERSION >= '1.9' || RUBY_PLATFORM == 'java' - def self.io_select(*params) - IO.select(*params) - end - else - SELECT_MUTEX = Mutex.new - def self.io_select(*params) - # It should be safe to wrap calls in a mutex when the timeout is 0 - # (that is, the call is not supposed to block). - # We leave blocking calls unprotected to avoid causing deadlocks. - # This should still catch the main case for Capistrano users. - if params[3] == 0 - SELECT_MUTEX.synchronize do - IO.select(*params) - end - else - IO.select(*params) - end - end - end - - end - -end; end diff --git a/vendor/gems/net-ssh-2.0.15/lib/net/ssh/service/forward.rb b/vendor/gems/net-ssh-2.0.15/lib/net/ssh/service/forward.rb deleted file mode 100644 index 6df93ea47..000000000 --- a/vendor/gems/net-ssh-2.0.15/lib/net/ssh/service/forward.rb +++ /dev/null @@ -1,267 +0,0 @@ -require 'net/ssh/loggable' - -module Net; module SSH; module Service - - # This class implements various port forwarding services for use by - # Net::SSH clients. The Forward class should never need to be instantiated - # directly; instead, it should be accessed via the singleton instance - # returned by Connection::Session#forward: - # - # ssh.forward.local(1234, "www.capify.org", 80) - class Forward - include Loggable - - # The underlying connection service instance that the port-forwarding - # services employ. - attr_reader :session - - # A simple class for representing a requested remote forwarded port. - Remote = Struct.new(:host, :port) #:nodoc: - - # Instantiates a new Forward service instance atop the given connection - # service session. This will register new channel open handlers to handle - # the specialized channels that the SSH port forwarding protocols employ. - def initialize(session) - @session = session - self.logger = session.logger - @remote_forwarded_ports = {} - @local_forwarded_ports = {} - @agent_forwarded = false - - session.on_open_channel('forwarded-tcpip', &method(:forwarded_tcpip)) - session.on_open_channel('auth-agent', &method(:auth_agent_channel)) - session.on_open_channel('auth-agent@openssh.com', &method(:auth_agent_channel)) - end - - # Starts listening for connections on the local host, and forwards them - # to the specified remote host/port via the SSH connection. This method - # accepts either three or four arguments. When four arguments are given, - # they are: - # - # * the local address to bind to - # * the local port to listen on - # * the remote host to forward connections to - # * the port on the remote host to connect to - # - # If three arguments are given, it is as if the local bind address is - # "127.0.0.1", and the rest are applied as above. - # - # ssh.forward.local(1234, "www.capify.org", 80) - # ssh.forward.local("0.0.0.0", 1234, "www.capify.org", 80) - def local(*args) - if args.length < 3 || args.length > 4 - raise ArgumentError, "expected 3 or 4 parameters, got #{args.length}" - end - - bind_address = "127.0.0.1" - bind_address = args.shift if args.first.is_a?(String) && args.first =~ /\D/ - - local_port = args.shift.to_i - remote_host = args.shift - remote_port = args.shift.to_i - - socket = TCPServer.new(bind_address, local_port) - - @local_forwarded_ports[[local_port, bind_address]] = socket - - session.listen_to(socket) do |server| - client = server.accept - debug { "received connection on #{bind_address}:#{local_port}" } - - channel = session.open_channel("direct-tcpip", :string, remote_host, :long, remote_port, :string, bind_address, :long, local_port) do |achannel| - achannel.info { "direct channel established" } - end - - prepare_client(client, channel, :local) - - channel.on_open_failed do |ch, code, description| - channel.error { "could not establish direct channel: #{description} (#{code})" } - channel[:socket].close - end - end - end - - # Terminates an active local forwarded port. If no such forwarded port - # exists, this will raise an exception. Otherwise, the forwarded connection - # is terminated. - # - # ssh.forward.cancel_local(1234) - # ssh.forward.cancel_local(1234, "0.0.0.0") - def cancel_local(port, bind_address="127.0.0.1") - socket = @local_forwarded_ports.delete([port, bind_address]) - socket.shutdown rescue nil - socket.close rescue nil - session.stop_listening_to(socket) - end - - # Returns a list of all active locally forwarded ports. The returned value - # is an array of arrays, where each element is a two-element tuple - # consisting of the local port and bind address corresponding to the - # forwarding port. - def active_locals - @local_forwarded_ports.keys - end - - # Requests that all connections on the given remote-port be forwarded via - # the local host to the given port/host. The last argument describes the - # bind address on the remote host, and defaults to 127.0.0.1. - # - # This method will return immediately, but the port will not actually be - # forwarded immediately. If the remote server is not able to begin the - # listener for this request, an exception will be raised asynchronously. - # - # If you want to know when the connection is active, it will show up in the - # #active_remotes list. If you want to block until the port is active, you - # could do something like this: - # - # ssh.forward.remote(80, "www.google.com", 1234, "0.0.0.0") - # ssh.loop { !ssh.forward.active_remotes.include?([1234, "0.0.0.0"]) } - def remote(port, host, remote_port, remote_host="127.0.0.1") - session.send_global_request("tcpip-forward", :string, remote_host, :long, remote_port) do |success, response| - if success - debug { "remote forward from remote #{remote_host}:#{remote_port} to #{host}:#{port} established" } - @remote_forwarded_ports[[remote_port, remote_host]] = Remote.new(host, port) - else - error { "remote forwarding request failed" } - raise Net::SSH::Exception, "remote forwarding request failed" - end - end - end - - # an alias, for token backwards compatibility with the 1.x API - alias :remote_to :remote - - # Requests that a remote forwarded port be cancelled. The remote forwarded - # port on the remote host, bound to the given address on the remote host, - # will be terminated, but not immediately. This method returns immediately - # after queueing the request to be sent to the server. If for some reason - # the port cannot be cancelled, an exception will be raised (asynchronously). - # - # If you want to know when the connection has been cancelled, it will no - # longer be present in the #active_remotes list. If you want to block until - # the port is no longer active, you could do something like this: - # - # ssh.forward.cancel_remote(1234, "0.0.0.0") - # ssh.loop { ssh.forward.active_remotes.include?([1234, "0.0.0.0"]) } - def cancel_remote(port, host="127.0.0.1") - session.send_global_request("cancel-tcpip-forward", :string, host, :long, port) do |success, response| - if success - @remote_forwarded_ports.delete([port, host]) - else - raise Net::SSH::Exception, "could not cancel remote forward request on #{host}:#{port}" - end - end - end - - # Returns all active forwarded remote ports. The returned value is an - # array of two-element tuples, where the first element is the port on the - # remote host and the second is the bind address. - def active_remotes - @remote_forwarded_ports.keys - end - - # Enables SSH agent forwarding on the given channel. The forwarded agent - # will remain active even after the channel closes--the channel is only - # used as the transport for enabling the forwarded connection. You should - # never need to call this directly--it is called automatically the first - # time a session channel is opened, when the connection was created with - # :forward_agent set to true: - # - # Net::SSH.start("remote.host", "me", :forwrd_agent => true) do |ssh| - # ssh.open_channel do |ch| - # # agent will be automatically forwarded by this point - # end - # ssh.loop - # end - def agent(channel) - return if @agent_forwarded - @agent_forwarded = true - - channel.send_channel_request("auth-agent-req@openssh.com") do |achannel, success| - if success - debug { "authentication agent forwarding is active" } - else - achannel.send_channel_request("auth-agent-req") do |a2channel, success2| - if success2 - debug { "authentication agent forwarding is active" } - else - error { "could not establish forwarding of authentication agent" } - end - end - end - end - end - - private - - # Perform setup operations that are common to all forwarded channels. - # +client+ is a socket, +channel+ is the channel that was just created, - # and +type+ is an arbitrary string describing the type of the channel. - def prepare_client(client, channel, type) - client.extend(Net::SSH::BufferedIo) - client.logger = logger - - session.listen_to(client) - channel[:socket] = client - - channel.on_data do |ch, data| - ch[:socket].enqueue(data) - end - - channel.on_close do |ch| - debug { "closing #{type} forwarded channel" } - ch[:socket].close if !client.closed? - session.stop_listening_to(ch[:socket]) - end - - channel.on_process do |ch| - if ch[:socket].closed? - ch.info { "#{type} forwarded connection closed" } - ch.close - elsif ch[:socket].available > 0 - data = ch[:socket].read_available(8192) - ch.debug { "read #{data.length} bytes from client, sending over #{type} forwarded connection" } - ch.send_data(data) - end - end - end - - # The callback used when a new "forwarded-tcpip" channel is requested - # by the server. This will open a new socket to the host/port specified - # when the forwarded connection was first requested. - def forwarded_tcpip(session, channel, packet) - connected_address = packet.read_string - connected_port = packet.read_long - originator_address = packet.read_string - originator_port = packet.read_long - - remote = @remote_forwarded_ports[[connected_port, connected_address]] - - if remote.nil? - raise Net::SSH::ChannelOpenFailed.new(1, "unknown request from remote forwarded connection on #{connected_address}:#{connected_port}") - end - - client = TCPSocket.new(remote.host, remote.port) - info { "connected #{connected_address}:#{connected_port} originator #{originator_address}:#{originator_port}" } - - prepare_client(client, channel, :remote) - rescue SocketError => err - raise Net::SSH::ChannelOpenFailed.new(2, "could not connect to remote host (#{remote.host}:#{remote.port}): #{err.message}") - end - - # The callback used when an auth-agent channel is requested by the server. - def auth_agent_channel(session, channel, packet) - info { "opening auth-agent channel" } - channel[:invisible] = true - - begin - agent = Authentication::Agent.connect(logger) - prepare_client(agent.socket, channel, :agent) - rescue Exception => e - error { "attempted to connect to agent but failed: #{e.class.name} (#{e.message})" } - raise Net::SSH::ChannelOpenFailed.new(2, "could not connect to authentication agent") - end - end - end - -end; end; end \ No newline at end of file diff --git a/vendor/gems/net-ssh-2.0.15/lib/net/ssh/test.rb b/vendor/gems/net-ssh-2.0.15/lib/net/ssh/test.rb deleted file mode 100644 index 5ecb7d5a1..000000000 --- a/vendor/gems/net-ssh-2.0.15/lib/net/ssh/test.rb +++ /dev/null @@ -1,89 +0,0 @@ -require 'net/ssh/transport/session' -require 'net/ssh/connection/session' -require 'net/ssh/test/kex' -require 'net/ssh/test/socket' - -module Net; module SSH - - # This module may be used in unit tests, for when you want to test that your - # SSH state machines are really doing what you expect they are doing. You will - # typically include this module in your unit test class, and then build a - # "story" of expected sends and receives: - # - # require 'test/unit' - # require 'net/ssh/test' - # - # class MyTest < Test::Unit::TestCase - # include Net::SSH::Test - # - # def test_exec_via_channel_works - # story do |session| - # channel = session.opens_channel - # channel.sends_exec "ls" - # channel.gets_data "result of ls" - # channel.gets_close - # channel.sends_close - # end - # - # assert_scripted do - # result = nil - # - # connection.open_channel do |ch| - # ch.exec("ls") do |success| - # ch.on_data { |c, data| result = data } - # ch.on_close { |c| c.close } - # end - # end - # - # connection.loop - # assert_equal "result of ls", result - # end - # end - # end - # - # See Net::SSH::Test::Channel and Net::SSH::Test::Script for more options. - # - # Note that the Net::SSH::Test system is rather finicky yet, and can be kind - # of frustrating to get working. Any suggestions for improvement will be - # welcome! - module Test - # If a block is given, yields the script for the test socket (#socket). - # Otherwise, simply returns the socket's script. See Net::SSH::Test::Script. - def story - yield socket.script if block_given? - return socket.script - end - - # Returns the test socket instance to use for these tests (see - # Net::SSH::Test::Socket). - def socket(options={}) - @socket ||= Net::SSH::Test::Socket.new - end - - # Returns the connection session (Net::SSH::Connection::Session) for use - # in these tests. It is a fully functional SSH session, operating over - # a mock socket (#socket). - def connection(options={}) - @connection ||= Net::SSH::Connection::Session.new(transport(options), options) - end - - # Returns the transport session (Net::SSH::Transport::Session) for use - # in these tests. It is a fully functional SSH transport session, operating - # over a mock socket (#socket). - def transport(options={}) - @transport ||= Net::SSH::Transport::Session.new(options[:host] || "localhost", options.merge(:kex => "test", :host_key => "ssh-rsa", :paranoid => false, :proxy => socket(options))) - end - - # First asserts that a story has been described (see #story). Then yields, - # and then asserts that all items described in the script have been - # processed. Typically, this is called immediately after a story has - # been built, and the SSH commands being tested are then executed within - # the block passed to this assertion. - def assert_scripted - raise "there is no script to be processed" if socket.script.events.empty? - yield - assert socket.script.events.empty?, "there should not be any remaining scripted events, but there are still #{socket.script.events.length} pending" - end - end - -end; end \ No newline at end of file diff --git a/vendor/gems/net-ssh-2.0.15/lib/net/ssh/test/channel.rb b/vendor/gems/net-ssh-2.0.15/lib/net/ssh/test/channel.rb deleted file mode 100644 index 261d8f380..000000000 --- a/vendor/gems/net-ssh-2.0.15/lib/net/ssh/test/channel.rb +++ /dev/null @@ -1,129 +0,0 @@ -module Net; module SSH; module Test - - # A mock channel, used for scripting actions in tests. It wraps a - # Net::SSH::Test::Script instance, and delegates to it for the most part. - # This class has little real functionality on its own, but rather acts as - # a convenience for scripting channel-related activity for later comparison - # in a unit test. - # - # story do |session| - # channel = session.opens_channel - # channel.sends_exec "ls" - # channel.gets_data "result of ls" - # channel.gets_close - # channel.sends_close - # end - class Channel - # The Net::SSH::Test::Script instance employed by this mock channel. - attr_reader :script - - # Sets the local-id of this channel object (the id assigned by the client). - attr_writer :local_id - - # Sets the remote-id of this channel object (the id assigned by the mock-server). - attr_writer :remote_id - - # Creates a new Test::Channel instance on top of the given +script+ (which - # must be a Net::SSH::Test::Script instance). - def initialize(script) - @script = script - @local_id = @remote_id = nil - end - - # Returns the local (client-assigned) id for this channel, or a Proc object - # that will return the local-id later if the local id has not yet been set. - # (See Net::SSH::Test::Packet#instantiate!.) - def local_id - @local_id || Proc.new { @local_id or raise "local-id has not been set yet!" } - end - - # Returns the remote (server-assigned) id for this channel, or a Proc object - # that will return the remote-id later if the remote id has not yet been set. - # (See Net::SSH::Test::Packet#instantiate!.) - def remote_id - @remote_id || Proc.new { @remote_id or raise "remote-id has not been set yet!" } - end - - # Because adjacent calls to #gets_data will sometimes cause the data packets - # to be concatenated (causing expectations in tests to fail), you may - # need to separate those calls with calls to #inject_remote_delay! (which - # essentially just mimics receiving an empty data packet): - # - # channel.gets_data "abcdefg" - # channel.inject_remote_delay! - # channel.gets_data "hijklmn" - def inject_remote_delay! - gets_data("") - end - - # Scripts the sending of an "exec" channel request packet to the mock - # server. If +reply+ is true, then the server is expected to reply to the - # request, otherwise no response to this request will be sent. If +success+ - # is +true+, then the request will be successful, otherwise a failure will - # be scripted. - # - # channel.sends_exec "ls -l" - def sends_exec(command, reply=true, success=true) - script.sends_channel_request(self, "exec", reply, command, success) - end - - # Scripts the sending of a "subsystem" channel request packet to the mock - # server. See #sends_exec for a discussion of the meaning of the +reply+ - # and +success+ arguments. - # - # channel.sends_subsystem "sftp" - def sends_subsystem(subsystem, reply=true, success=true) - script.sends_channel_request(self, "subsystem", reply, subsystem, success) - end - - # Scripts the sending of a data packet across the channel. - # - # channel.sends_data "foo" - def sends_data(data) - script.sends_channel_data(self, data) - end - - # Scripts the sending of an EOF packet across the channel. - # - # channel.sends_eof - def sends_eof - script.sends_channel_eof(self) - end - - # Scripts the sending of a "channel close" packet across the channel. - # - # channel.sends_close - def sends_close - script.sends_channel_close(self) - end - - # Scripts the reception of a channel data packet from the remote end. - # - # channel.gets_data "bar" - def gets_data(data) - script.gets_channel_data(self, data) - end - - # Scripts the reception of an "exit-status" channel request packet. - # - # channel.gets_exit_status(127) - def gets_exit_status(status=0) - script.gets_channel_request(self, "exit-status", false, status) - end - - # Scripts the reception of an EOF packet from the remote end. - # - # channel.gets_eof - def gets_eof - script.gets_channel_eof(self) - end - - # Scripts the reception of a "channel close" packet from the remote end. - # - # channel.gets_close - def gets_close - script.gets_channel_close(self) - end - end - -end; end; end \ No newline at end of file diff --git a/vendor/gems/net-ssh-2.0.15/lib/net/ssh/test/extensions.rb b/vendor/gems/net-ssh-2.0.15/lib/net/ssh/test/extensions.rb deleted file mode 100644 index e19a98636..000000000 --- a/vendor/gems/net-ssh-2.0.15/lib/net/ssh/test/extensions.rb +++ /dev/null @@ -1,152 +0,0 @@ -require 'net/ssh/buffer' -require 'net/ssh/packet' -require 'net/ssh/buffered_io' -require 'net/ssh/connection/channel' -require 'net/ssh/connection/constants' -require 'net/ssh/transport/constants' -require 'net/ssh/transport/packet_stream' - -module Net; module SSH; module Test - - # A collection of modules used to extend/override the default behavior of - # Net::SSH internals for ease of testing. As a consumer of Net::SSH, you'll - # never need to use this directly--they're all used under the covers by - # the Net::SSH::Test system. - module Extensions - - # An extension to Net::SSH::BufferedIo (assumes that the underlying IO - # is actually a StringIO). Facilitates unit testing. - module BufferedIo - # Returns +true+ if the position in the stream is less than the total - # length of the stream. - def select_for_read? - pos < size - end - - # Set this to +true+ if you want the IO to pretend to be available for writing - attr_accessor :select_for_write - - # Set this to +true+ if you want the IO to pretend to be in an error state - attr_accessor :select_for_error - - alias select_for_write? select_for_write - alias select_for_error? select_for_error - end - - # An extension to Net::SSH::Transport::PacketStream (assumes that the - # underlying IO is actually a StringIO). Facilitates unit testing. - module PacketStream - include BufferedIo # make sure we get the extensions here, too - - def self.included(base) #:nodoc: - base.send :alias_method, :real_available_for_read?, :available_for_read? - base.send :alias_method, :available_for_read?, :test_available_for_read? - - base.send :alias_method, :real_enqueue_packet, :enqueue_packet - base.send :alias_method, :enqueue_packet, :test_enqueue_packet - - base.send :alias_method, :real_poll_next_packet, :poll_next_packet - base.send :alias_method, :poll_next_packet, :test_poll_next_packet - end - - # Called when another packet should be inspected from the current - # script. If the next packet is a remote packet, it pops it off the - # script and shoves it onto this IO object, making it available to - # be read. - def idle! - return false unless script.next(:first) - - if script.next(:first).remote? - self.string << script.next.to_s - self.pos = pos - end - - return true - end - - # The testing version of Net::SSH::Transport::PacketStream#available_for_read?. - # Returns true if there is data pending to be read. Otherwise calls #idle!. - def test_available_for_read? - return true if select_for_read? - idle! - false - end - - # The testing version of Net::SSH::Transport::PacketStream#enqueued_packet. - # Simply calls Net::SSH::Test::Script#process on the packet. - def test_enqueue_packet(payload) - packet = Net::SSH::Buffer.new(payload.to_s) - script.process(packet) - end - - # The testing version of Net::SSH::Transport::PacketStream#poll_next_packet. - # Reads the next available packet from the IO object and returns it. - def test_poll_next_packet - return nil if available <= 0 - packet = Net::SSH::Buffer.new(read_available(4)) - length = packet.read_long - Net::SSH::Packet.new(read_available(length)) - end - end - - # An extension to Net::SSH::Connection::Channel. Facilitates unit testing. - module Channel - def self.included(base) #:nodoc: - base.send :alias_method, :send_data_for_real, :send_data - base.send :alias_method, :send_data, :send_data_for_test - end - - # The testing version of Net::SSH::Connection::Channel#send_data. Calls - # the original implementation, and then immediately enqueues the data for - # output so that scripted sends are properly interpreted as discrete - # (rather than concatenated) data packets. - def send_data_for_test(data) - send_data_for_real(data) - enqueue_pending_output - end - end - - # An extension to the built-in ::IO class. Simply redefines IO.select - # so that it can be scripted in Net::SSH unit tests. - module IO - def self.included(base) #:nodoc: - base.extend(ClassMethods) - end - - module ClassMethods - def self.extended(obj) #:nodoc: - class < "abc-xyz", - :server_key => OpenSSL::PKey::RSA.new(32), - :shared_secret => OpenSSL::BN.new("1234567890", 10), - :hashing_algorithm => OpenSSL::Digest::SHA1 } - end - end - -end; end; end - -Net::SSH::Transport::Algorithms::ALGORITHMS[:kex] << "test" -Net::SSH::Transport::Kex::MAP["test"] = Net::SSH::Test::Kex diff --git a/vendor/gems/net-ssh-2.0.15/lib/net/ssh/test/local_packet.rb b/vendor/gems/net-ssh-2.0.15/lib/net/ssh/test/local_packet.rb deleted file mode 100644 index 3909d2111..000000000 --- a/vendor/gems/net-ssh-2.0.15/lib/net/ssh/test/local_packet.rb +++ /dev/null @@ -1,51 +0,0 @@ -require 'net/ssh/packet' -require 'net/ssh/test/packet' - -module Net; module SSH; module Test - - # This is a specialization of Net::SSH::Test::Packet for representing mock - # packets that are sent from the local (client) host. These are created - # automatically by Net::SSH::Test::Script and Net::SSH::Test::Channel by any - # of the sends_* methods. - class LocalPacket < Packet - attr_reader :init - - # Extend the default Net::SSH::Test::Packet constructor to also accept an - # optional block, which is used to finalize the initialization of the - # packet when #process is first called. - def initialize(type, *args, &block) - super(type, *args) - @init = block - end - - # Returns +true+; this is a local packet. - def local? - true - end - - # Called by Net::SSH::Test::Extensions::PacketStream#test_enqueue_packet - # to mimic remote processing of a locally-sent packet. It compares the - # packet it was given with the contents of this LocalPacket's data, to see - # if what was sent matches what was scripted. If it differs in any way, - # an exception is raised. - def process(packet) - @init.call(Net::SSH::Packet.new(packet.to_s)) if @init - type = packet.read_byte - raise "expected #{@type}, but got #{type}" if @type != type - - @data.zip(types).each do |expected, type| - type ||= case expected - when nil then break - when Numeric then :long - when String then :string - when TrueClass, FalseClass then :bool - end - - actual = packet.send("read_#{type}") - next if expected.nil? - raise "expected #{type} #{expected.inspect} but got #{actual.inspect}" unless expected == actual - end - end - end - -end; end; end \ No newline at end of file diff --git a/vendor/gems/net-ssh-2.0.15/lib/net/ssh/test/packet.rb b/vendor/gems/net-ssh-2.0.15/lib/net/ssh/test/packet.rb deleted file mode 100644 index 0853003ef..000000000 --- a/vendor/gems/net-ssh-2.0.15/lib/net/ssh/test/packet.rb +++ /dev/null @@ -1,81 +0,0 @@ -require 'net/ssh/connection/constants' -require 'net/ssh/transport/constants' - -module Net; module SSH; module Test - - # This is an abstract class, not to be instantiated directly, subclassed by - # Net::SSH::Test::LocalPacket and Net::SSH::Test::RemotePacket. It implements - # functionality common to those subclasses. - # - # These packets are not true packets, in that they don't represent what was - # actually sent between the hosst; rather, they represent what was expected - # to be sent, as dictated by the script (Net::SSH::Test::Script). Thus, - # though they are defined with data elements, these data elements are used - # to either validate data that was sent by the local host (Net::SSH::Test::LocalPacket) - # or to mimic the sending of data by the remote host (Net::SSH::Test::RemotePacket). - class Packet - include Net::SSH::Transport::Constants - include Net::SSH::Connection::Constants - - # Ceate a new packet of the given +type+, and with +args+ being a list of - # data elements in the order expected for packets of the given +type+ - # (see #types). - def initialize(type, *args) - @type = self.class.const_get(type.to_s.upcase) - @data = args - end - - # The default for +remote?+ is false. Subclasses should override as necessary. - def remote? - false - end - - # The default for +local?+ is false. Subclasses should override as necessary. - def local? - false - end - - # Instantiates the packets data elements. When the packet was first defined, - # some elements may not have been fully realized, and were described as - # Proc objects rather than atomic types. This invokes those Proc objects - # and replaces them with their returned values. This allows for values - # like Net::SSH::Test::Channel#remote_id to be used in scripts before - # the remote_id is known (since it is only known after a channel has been - # confirmed open). - def instantiate! - @data.map! { |i| i.respond_to?(:call) ? i.call : i } - end - - # Returns an array of symbols describing the data elements for packets of - # the same type as this packet. These types are used to either validate - # sent packets (Net::SSH::Test::LocalPacket) or build received packets - # (Net::SSH::Test::RemotePacket). - # - # Not all packet types are defined here. As new packet types are required - # (e.g., a unit test needs to test that the remote host sent a packet that - # is not implemented here), the description of that packet should be - # added. Unsupported packet types will otherwise raise an exception. - def types - @types ||= case @type - when KEXINIT then - [:long, :long, :long, :long, - :string, :string, :string, :string, :string, :string, :string, :string, :string, :string, - :bool] - when NEWKEYS then [] - when CHANNEL_OPEN then [:string, :long, :long, :long] - when CHANNEL_OPEN_CONFIRMATION then [:long, :long, :long, :long] - when CHANNEL_DATA then [:long, :string] - when CHANNEL_EOF, CHANNEL_CLOSE, CHANNEL_SUCCESS, CHANNEL_FAILURE then [:long] - when CHANNEL_REQUEST - parts = [:long, :string, :bool] - case @data[1] - when "exec", "subsystem" then parts << :string - when "exit-status" then parts << :long - else raise "don't know what to do about #{@data[1]} channel request" - end - else raise "don't know how to parse packet type #{@type}" - end - end - end - -end; end; end \ No newline at end of file diff --git a/vendor/gems/net-ssh-2.0.15/lib/net/ssh/test/remote_packet.rb b/vendor/gems/net-ssh-2.0.15/lib/net/ssh/test/remote_packet.rb deleted file mode 100644 index c09d750ad..000000000 --- a/vendor/gems/net-ssh-2.0.15/lib/net/ssh/test/remote_packet.rb +++ /dev/null @@ -1,38 +0,0 @@ -require 'net/ssh/buffer' -require 'net/ssh/test/packet' - -module Net; module SSH; module Test - - # This is a specialization of Net::SSH::Test::Packet for representing mock - # packets that are received by the local (client) host. These are created - # automatically by Net::SSH::Test::Script and Net::SSH::Test::Channel by any - # of the gets_* methods. - class RemotePacket < Packet - # Returns +true+; this is a remote packet. - def remote? - true - end - - # The #process method should only be called on Net::SSH::Test::LocalPacket - # packets; if it is attempted on a remote packet, then it is an expectation - # mismatch (a remote packet was received when a local packet was expected - # to be sent). This will happen when either your test script - # (Net::SSH::Test::Script) or your program are wrong. - def process(packet) - raise "received packet type #{packet.read_byte} and was not expecting any packet" - end - - # Returns this remote packet as a string, suitable for parsing by - # Net::SSH::Transport::PacketStream and friends. When a remote packet is - # received, this method is called and the result concatenated onto the - # input buffer for the packet stream. - def to_s - @to_s ||= begin - instantiate! - string = Net::SSH::Buffer.from(:byte, @type, *types.zip(@data).flatten).to_s - [string.length, string].pack("NA*") - end - end - end - -end; end; end \ No newline at end of file diff --git a/vendor/gems/net-ssh-2.0.15/lib/net/ssh/test/script.rb b/vendor/gems/net-ssh-2.0.15/lib/net/ssh/test/script.rb deleted file mode 100644 index 89ee064a4..000000000 --- a/vendor/gems/net-ssh-2.0.15/lib/net/ssh/test/script.rb +++ /dev/null @@ -1,157 +0,0 @@ -require 'net/ssh/test/channel' -require 'net/ssh/test/local_packet' -require 'net/ssh/test/remote_packet' - -module Net; module SSH; module Test - - # Represents a sequence of scripted events that identify the behavior that - # a test expects. Methods named "sends_*" create events for packets being - # sent from the local to the remote host, and methods named "gets_*" create - # events for packets being received by the local from the remote host. - # - # A reference to a script. is generally obtained in a unit test via the - # Net::SSH::Test#story helper method: - # - # story do |script| - # channel = script.opens_channel - # ... - # end - class Script - # The list of scripted events. These will be Net::SSH::Test::LocalPacket - # and Net::SSH::Test::RemotePacket instances. - attr_reader :events - - # Create a new, empty script. - def initialize - @events = [] - end - - # Scripts the opening of a channel by adding a local packet sending the - # channel open request, and if +confirm+ is true (the default), also - # adding a remote packet confirming the new channel. - # - # A new Net::SSH::Test::Channel instance is returned, which can be used - # to script additional channel operations. - def opens_channel(confirm=true) - channel = Channel.new(self) - channel.remote_id = 5555 - - events << LocalPacket.new(:channel_open) { |p| channel.local_id = p[:remote_id] } - - if confirm - events << RemotePacket.new(:channel_open_confirmation, channel.local_id, channel.remote_id, 0x20000, 0x10000) - end - - channel - end - - # A convenience method for adding an arbitrary local packet to the events - # list. - def sends(type, *args, &block) - events << LocalPacket.new(type, *args, &block) - end - - # A convenience method for adding an arbitrary remote packet to the events - # list. - def gets(type, *args) - events << RemotePacket.new(type, *args) - end - - # Scripts the sending of a new channel request packet to the remote host. - # +channel+ should be an instance of Net::SSH::Test::Channel. +request+ - # is a string naming the request type to send, +reply+ is a boolean - # indicating whether a response to this packet is required , and +data+ - # is any additional request-specific data that this packet should send. - # +success+ indicates whether the response (if one is required) should be - # success or failure. - # - # If a reply is desired, a remote packet will also be queued, :channel_success - # if +success+ is true, or :channel_failure if +success+ is false. - # - # This will typically be called via Net::SSH::Test::Channel#sends_exec or - # Net::SSH::Test::Channel#sends_subsystem. - def sends_channel_request(channel, request, reply, data, success=true) - events << LocalPacket.new(:channel_request, channel.remote_id, request, reply, data) - if reply - if success - events << RemotePacket.new(:channel_success, channel.local_id) - else - events << RemotePacket.new(:channel_failure, channel.local_id) - end - end - end - - # Scripts the sending of a channel data packet. +channel+ must be a - # Net::SSH::Test::Channel object, and +data+ is the (string) data to - # expect will be sent. - # - # This will typically be called via Net::SSH::Test::Channel#sends_data. - def sends_channel_data(channel, data) - events << LocalPacket.new(:channel_data, channel.remote_id, data) - end - - # Scripts the sending of a channel EOF packet from the given - # Net::SSH::Test::Channel +channel+. This will typically be called via - # Net::SSH::Test::Channel#sends_eof. - def sends_channel_eof(channel) - events << LocalPacket.new(:channel_eof, channel.remote_id) - end - - # Scripts the sending of a channel close packet from the given - # Net::SSH::Test::Channel +channel+. This will typically be called via - # Net::SSH::Test::Channel#sends_close. - def sends_channel_close(channel) - events << LocalPacket.new(:channel_close, channel.remote_id) - end - - # Scripts the reception of a channel data packet from the remote host by - # the given Net::SSH::Test::Channel +channel+. This will typically be - # called via Net::SSH::Test::Channel#gets_data. - def gets_channel_data(channel, data) - events << RemotePacket.new(:channel_data, channel.local_id, data) - end - - # Scripts the reception of a channel request packet from the remote host by - # the given Net::SSH::Test::Channel +channel+. This will typically be - # called via Net::SSH::Test::Channel#gets_exit_status. - def gets_channel_request(channel, request, reply, data) - events << RemotePacket.new(:channel_request, channel.local_id, request, reply, data) - end - - # Scripts the reception of a channel EOF packet from the remote host by - # the given Net::SSH::Test::Channel +channel+. This will typically be - # called via Net::SSH::Test::Channel#gets_eof. - def gets_channel_eof(channel) - events << RemotePacket.new(:channel_eof, channel.local_id) - end - - # Scripts the reception of a channel close packet from the remote host by - # the given Net::SSH::Test::Channel +channel+. This will typically be - # called via Net::SSH::Test::Channel#gets_close. - def gets_channel_close(channel) - events << RemotePacket.new(:channel_close, channel.local_id) - end - - # By default, removes the next event in the list and returns it. However, - # this can also be used to non-destructively peek at the next event in the - # list, by passing :first as the argument. - # - # # remove the next event and return it - # event = script.next - # - # # peek at the next event - # event = script.next(:first) - def next(mode=:shift) - events.send(mode) - end - - # Compare the given packet against the next event in the list. If there is - # no next event, an exception will be raised. This is called by - # Net::SSH::Test::Extensions::PacketStream#test_enqueue_packet. - def process(packet) - event = events.shift or raise "end of script reached, but got a packet type #{packet.read_byte}" - event.process(packet) - end - end - -end; end; end \ No newline at end of file diff --git a/vendor/gems/net-ssh-2.0.15/lib/net/ssh/test/socket.rb b/vendor/gems/net-ssh-2.0.15/lib/net/ssh/test/socket.rb deleted file mode 100644 index 4741255ab..000000000 --- a/vendor/gems/net-ssh-2.0.15/lib/net/ssh/test/socket.rb +++ /dev/null @@ -1,59 +0,0 @@ -require 'socket' -require 'stringio' -require 'net/ssh/test/extensions' -require 'net/ssh/test/script' - -module Net; module SSH; module Test - - # A mock socket implementation for use in testing. It implements the minimum - # necessary interface for interacting with the rest of the Net::SSH::Test - # system. - class Socket < StringIO - attr_reader :host, :port - - # The Net::SSH::Test::Script object in use by this socket. This is the - # canonical script instance that should be used for any test depending on - # this socket instance. - attr_reader :script - - # Create a new test socket. This will also instantiate a new Net::SSH::Test::Script - # and seed it with the necessary events to power the initialization of the - # connection. - def initialize - extend(Net::SSH::Transport::PacketStream) - super "SSH-2.0-Test\r\n" - - @script = Script.new - - script.gets(:kexinit, 1, 2, 3, 4, "test", "ssh-rsa", "none", "none", "none", "none", "none", "none", "", "", false) - script.sends(:kexinit) - script.sends(:newkeys) - script.gets(:newkeys) - end - - # This doesn't actually do anything, since we don't really care what gets - # written. - def write(data) - # black hole, because we don't actually care about what gets written - end - - # Allows the socket to also mimic a socket factory, simply returning - # +self+. - def open(host, port) - @host, @port = host, port - self - end - - # Returns a sockaddr struct for the port and host that were used when the - # socket was instantiated. - def getpeername - ::Socket.sockaddr_in(port, host) - end - - # Alias to #read, but never returns nil (returns an empty string instead). - def recv(n) - read(n) || "" - end - end - -end; end; end diff --git a/vendor/gems/net-ssh-2.0.15/lib/net/ssh/transport/algorithms.rb b/vendor/gems/net-ssh-2.0.15/lib/net/ssh/transport/algorithms.rb deleted file mode 100644 index 9c7f8d0af..000000000 --- a/vendor/gems/net-ssh-2.0.15/lib/net/ssh/transport/algorithms.rb +++ /dev/null @@ -1,384 +0,0 @@ -require 'net/ssh/buffer' -require 'net/ssh/known_hosts' -require 'net/ssh/loggable' -require 'net/ssh/transport/cipher_factory' -require 'net/ssh/transport/constants' -require 'net/ssh/transport/hmac' -require 'net/ssh/transport/kex' -require 'net/ssh/transport/server_version' - -module Net; module SSH; module Transport - - # Implements the higher-level logic behind an SSH key-exchange. It handles - # both the initial exchange, as well as subsequent re-exchanges (as needed). - # It also encapsulates the negotiation of the algorithms, and provides a - # single point of access to the negotiated algorithms. - # - # You will never instantiate or reference this directly. It is used - # internally by the transport layer. - class Algorithms - include Constants, Loggable - - # Define the default algorithms, in order of preference, supported by - # Net::SSH. - ALGORITHMS = { - :host_key => %w(ssh-rsa ssh-dss), - :kex => %w(diffie-hellman-group-exchange-sha1 - diffie-hellman-group1-sha1), - :encryption => %w(aes128-cbc 3des-cbc blowfish-cbc cast128-cbc - aes192-cbc aes256-cbc rijndael-cbc@lysator.liu.se - idea-cbc none arcfour128 arcfour256), - :hmac => %w(hmac-sha1 hmac-md5 hmac-sha1-96 hmac-md5-96 none), - :compression => %w(none zlib@openssh.com zlib), - :language => %w() - } - - # The underlying transport layer session that supports this object - attr_reader :session - - # The hash of options used to initialize this object - attr_reader :options - - # The kex algorithm to use settled on between the client and server. - attr_reader :kex - - # The type of host key that will be used for this session. - attr_reader :host_key - - # The type of the cipher to use to encrypt packets sent from the client to - # the server. - attr_reader :encryption_client - - # The type of the cipher to use to decrypt packets arriving from the server. - attr_reader :encryption_server - - # The type of HMAC to use to sign packets sent by the client. - attr_reader :hmac_client - - # The type of HMAC to use to validate packets arriving from the server. - attr_reader :hmac_server - - # The type of compression to use to compress packets being sent by the client. - attr_reader :compression_client - - # The type of compression to use to decompress packets arriving from the server. - attr_reader :compression_server - - # The language that will be used in messages sent by the client. - attr_reader :language_client - - # The language that will be used in messages sent from the server. - attr_reader :language_server - - # The hash of algorithms preferred by the client, which will be told to - # the server during algorithm negotiation. - attr_reader :algorithms - - # The session-id for this session, as decided during the initial key exchange. - attr_reader :session_id - - # Returns true if the given packet can be processed during a key-exchange. - def self.allowed_packet?(packet) - ( 1.. 4).include?(packet.type) || - ( 6..19).include?(packet.type) || - (21..49).include?(packet.type) - end - - # Instantiates a new Algorithms object, and prepares the hash of preferred - # algorithms based on the options parameter and the ALGORITHMS constant. - def initialize(session, options={}) - @session = session - @logger = session.logger - @options = options - @algorithms = {} - @pending = @initialized = false - @client_packet = @server_packet = nil - prepare_preferred_algorithms! - end - - # Request a rekey operation. This will return immediately, and does not - # actually perform the rekey operation. It does cause the session to change - # state, however--until the key exchange finishes, no new packets will be - # processed. - def rekey! - @client_packet = @server_packet = nil - @initialized = false - send_kexinit - end - - # Called by the transport layer when a KEXINIT packet is recieved, indicating - # that the server wants to exchange keys. This can be spontaneous, or it - # can be in response to a client-initiated rekey request (see #rekey!). Either - # way, this will block until the key exchange completes. - def accept_kexinit(packet) - info { "got KEXINIT from server" } - @server_data = parse_server_algorithm_packet(packet) - @server_packet = @server_data[:raw] - if !pending? - send_kexinit - else - proceed! - end - end - - # A convenience method for accessing the list of preferred types for a - # specific algorithm (see #algorithms). - def [](key) - algorithms[key] - end - - # Returns +true+ if a key-exchange is pending. This will be true from the - # moment either the client or server requests the key exchange, until the - # exchange completes. While an exchange is pending, only a limited number - # of packets are allowed, so event processing essentially stops during this - # period. - def pending? - @pending - end - - # Returns true if no exchange is pending, and otherwise returns true or - # false depending on whether the given packet is of a type that is allowed - # during a key exchange. - def allow?(packet) - !pending? || Algorithms.allowed_packet?(packet) - end - - # Returns true if the algorithms have been negotiated at all. - def initialized? - @initialized - end - - private - - # Sends a KEXINIT packet to the server. If a server KEXINIT has already - # been received, this will then invoke #proceed! to proceed with the key - # exchange, otherwise it returns immediately (but sets the object to the - # pending state). - def send_kexinit - info { "sending KEXINIT" } - @pending = true - packet = build_client_algorithm_packet - @client_packet = packet.to_s - session.send_message(packet) - proceed! if @server_packet - end - - # After both client and server have sent their KEXINIT packets, this - # will do the algorithm negotiation and key exchange. Once both finish, - # the object leaves the pending state and the method returns. - def proceed! - info { "negotiating algorithms" } - negotiate_algorithms - exchange_keys - @pending = false - end - - # Prepares the list of preferred algorithms, based on the options hash - # that was given when the object was constructed, and the ALGORITHMS - # constant. Also, when determining the host_key type to use, the known - # hosts files are examined to see if the host has ever sent a host_key - # before, and if so, that key type is used as the preferred type for - # communicating with this server. - def prepare_preferred_algorithms! - options[:compression] = %w(zlib@openssh.com zlib) if options[:compression] == true - - ALGORITHMS.each do |algorithm, list| - algorithms[algorithm] = list.dup - - # apply the preferred algorithm order, if any - if options[algorithm] - algorithms[algorithm] = Array(options[algorithm]).compact.uniq - invalid = algorithms[algorithm].detect { |name| !ALGORITHMS[algorithm].include?(name) } - raise NotImplementedError, "unsupported #{algorithm} algorithm: `#{invalid}'" if invalid - - # make sure all of our supported algorithms are tacked onto the - # end, so that if the user tries to give a list of which none are - # supported, we can still proceed. - list.each { |name| algorithms[algorithm] << name unless algorithms[algorithm].include?(name) } - end - end - - # for convention, make sure our list has the same keys as the server - # list - - algorithms[:encryption_client ] = algorithms[:encryption_server ] = algorithms[:encryption] - algorithms[:hmac_client ] = algorithms[:hmac_server ] = algorithms[:hmac] - algorithms[:compression_client] = algorithms[:compression_server] = algorithms[:compression] - algorithms[:language_client ] = algorithms[:language_server ] = algorithms[:language] - - if !options.key?(:host_key) - # make sure the host keys are specified in preference order, where any - # existing known key for the host has preference. - - existing_keys = KnownHosts.search_for(options[:host_key_alias] || session.host_as_string, options) - host_keys = existing_keys.map { |key| key.ssh_type }.uniq - algorithms[:host_key].each do |name| - host_keys << name unless host_keys.include?(name) - end - algorithms[:host_key] = host_keys - end - end - - # Parses a KEXINIT packet from the server. - def parse_server_algorithm_packet(packet) - data = { :raw => packet.content } - - packet.read(16) # skip the cookie value - - data[:kex] = packet.read_string.split(/,/) - data[:host_key] = packet.read_string.split(/,/) - data[:encryption_client] = packet.read_string.split(/,/) - data[:encryption_server] = packet.read_string.split(/,/) - data[:hmac_client] = packet.read_string.split(/,/) - data[:hmac_server] = packet.read_string.split(/,/) - data[:compression_client] = packet.read_string.split(/,/) - data[:compression_server] = packet.read_string.split(/,/) - data[:language_client] = packet.read_string.split(/,/) - data[:language_server] = packet.read_string.split(/,/) - - # TODO: if first_kex_packet_follows, we need to try to skip the - # actual kexinit stuff and try to guess what the server is doing... - # need to read more about this scenario. - first_kex_packet_follows = packet.read_bool - - return data - end - - # Given the #algorithms map of preferred algorithm types, this constructs - # a KEXINIT packet to send to the server. It does not actually send it, - # it simply builds the packet and returns it. - def build_client_algorithm_packet - kex = algorithms[:kex ].join(",") - host_key = algorithms[:host_key ].join(",") - encryption = algorithms[:encryption ].join(",") - hmac = algorithms[:hmac ].join(",") - compression = algorithms[:compression].join(",") - language = algorithms[:language ].join(",") - - Net::SSH::Buffer.from(:byte, KEXINIT, - :long, [rand(0xFFFFFFFF), rand(0xFFFFFFFF), rand(0xFFFFFFFF), rand(0xFFFFFFFF)], - :string, [kex, host_key, encryption, encryption, hmac, hmac], - :string, [compression, compression, language, language], - :bool, false, :long, 0) - end - - # Given the parsed server KEX packet, and the client's preferred algorithm - # lists in #algorithms, determine which preferred algorithms each has - # in common and set those as the selected algorithms. If, for any algorithm, - # no type can be settled on, an exception is raised. - def negotiate_algorithms - @kex = negotiate(:kex) - @host_key = negotiate(:host_key) - @encryption_client = negotiate(:encryption_client) - @encryption_server = negotiate(:encryption_server) - @hmac_client = negotiate(:hmac_client) - @hmac_server = negotiate(:hmac_server) - @compression_client = negotiate(:compression_client) - @compression_server = negotiate(:compression_server) - @language_client = negotiate(:language_client) rescue "" - @language_server = negotiate(:language_server) rescue "" - - debug do - "negotiated:\n" + - [:kex, :host_key, :encryption_server, :encryption_client, :hmac_client, :hmac_server, :compression_client, :compression_server, :language_client, :language_server].map do |key| - "* #{key}: #{instance_variable_get("@#{key}")}" - end.join("\n") - end - end - - # Negotiates a single algorithm based on the preferences reported by the - # server and those set by the client. This is called by - # #negotiate_algorithms. - def negotiate(algorithm) - match = self[algorithm].find { |item| @server_data[algorithm].include?(item) } - - if match.nil? - raise Net::SSH::Exception, "could not settle on #{algorithm} algorithm" - end - - return match - end - - # Considers the sizes of the keys and block-sizes for the selected ciphers, - # and the lengths of the hmacs, and returns the largest as the byte requirement - # for the key-exchange algorithm. - def kex_byte_requirement - sizes = [8] # require at least 8 bytes - - sizes.concat(CipherFactory.get_lengths(encryption_client)) - sizes.concat(CipherFactory.get_lengths(encryption_server)) - - sizes << HMAC.key_length(hmac_client) - sizes << HMAC.key_length(hmac_server) - - sizes.max - end - - # Instantiates one of the Transport::Kex classes (based on the negotiated - # kex algorithm), and uses it to exchange keys. Then, the ciphers and - # HMACs are initialized and fed to the transport layer, to be used in - # further communication with the server. - def exchange_keys - debug { "exchanging keys" } - - algorithm = Kex::MAP[kex].new(self, session, - :client_version_string => Net::SSH::Transport::ServerVersion::PROTO_VERSION, - :server_version_string => session.server_version.version, - :server_algorithm_packet => @server_packet, - :client_algorithm_packet => @client_packet, - :need_bytes => kex_byte_requirement, - :logger => logger) - result = algorithm.exchange_keys - - secret = result[:shared_secret].to_ssh - hash = result[:session_id] - digester = result[:hashing_algorithm] - - @session_id ||= hash - - key = Proc.new { |salt| digester.digest(secret + hash + salt + @session_id) } - - iv_client = key["A"] - iv_server = key["B"] - key_client = key["C"] - key_server = key["D"] - mac_key_client = key["E"] - mac_key_server = key["F"] - - parameters = { :iv => iv_client, :key => key_client, :shared => secret, - :hash => hash, :digester => digester } - - cipher_client = CipherFactory.get(encryption_client, parameters.merge(:encrypt => true)) - cipher_server = CipherFactory.get(encryption_server, parameters.merge(:iv => iv_server, :key => key_server, :decrypt => true)) - - mac_client = HMAC.get(hmac_client, mac_key_client) - mac_server = HMAC.get(hmac_server, mac_key_server) - - session.configure_client :cipher => cipher_client, :hmac => mac_client, - :compression => normalize_compression_name(compression_client), - :compression_level => options[:compression_level], - :rekey_limit => options[:rekey_limit], - :max_packets => options[:rekey_packet_limit], - :max_blocks => options[:rekey_blocks_limit] - - session.configure_server :cipher => cipher_server, :hmac => mac_server, - :compression => normalize_compression_name(compression_server), - :rekey_limit => options[:rekey_limit], - :max_packets => options[:rekey_packet_limit], - :max_blocks => options[:rekey_blocks_limit] - - @initialized = true - end - - # Given the SSH name for some compression algorithm, return a normalized - # name as a symbol. - def normalize_compression_name(name) - case name - when "none" then false - when "zlib" then :standard - when "zlib@openssh.com" then :delayed - else raise ArgumentError, "unknown compression type `#{name}'" - end - end - end -end; end; end \ No newline at end of file diff --git a/vendor/gems/net-ssh-2.0.15/lib/net/ssh/transport/cipher_factory.rb b/vendor/gems/net-ssh-2.0.15/lib/net/ssh/transport/cipher_factory.rb deleted file mode 100644 index ae57f2c27..000000000 --- a/vendor/gems/net-ssh-2.0.15/lib/net/ssh/transport/cipher_factory.rb +++ /dev/null @@ -1,97 +0,0 @@ -require 'openssl' -require 'net/ssh/transport/identity_cipher' - -module Net; module SSH; module Transport - - # Implements a factory of OpenSSL cipher algorithms. - class CipherFactory - # Maps the SSH name of a cipher to it's corresponding OpenSSL name - SSH_TO_OSSL = { - "3des-cbc" => "des-ede3-cbc", - "blowfish-cbc" => "bf-cbc", - "aes256-cbc" => "aes-256-cbc", - "aes192-cbc" => "aes-192-cbc", - "aes128-cbc" => "aes-128-cbc", - "idea-cbc" => "idea-cbc", - "cast128-cbc" => "cast-cbc", - "rijndael-cbc@lysator.liu.se" => "aes-256-cbc", - "arcfour128" => "rc4", - "arcfour256" => "rc4", - "arcfour512" => "rc4", - "none" => "none" - } - - # Ruby's OpenSSL bindings always return a key length of 16 for RC4 ciphers - # resulting in the error: OpenSSL::CipherError: key length too short. - # The following ciphers will override this key length. - KEY_LEN_OVERRIDE = { - "arcfour256" => 32, - "arcfour512" => 64 - } - - # Returns true if the underlying OpenSSL library supports the given cipher, - # and false otherwise. - def self.supported?(name) - ossl_name = SSH_TO_OSSL[name] or raise NotImplementedError, "unimplemented cipher `#{name}'" - return true if ossl_name == "none" - return OpenSSL::Cipher.ciphers.include?(ossl_name) - end - - # Retrieves a new instance of the named algorithm. The new instance - # will be initialized using an iv and key generated from the given - # iv, key, shared, hash and digester values. Additionally, the - # cipher will be put into encryption or decryption mode, based on the - # value of the +encrypt+ parameter. - def self.get(name, options={}) - ossl_name = SSH_TO_OSSL[name] or raise NotImplementedError, "unimplemented cipher `#{name}'" - return IdentityCipher if ossl_name == "none" - - cipher = OpenSSL::Cipher::Cipher.new(ossl_name) - cipher.send(options[:encrypt] ? :encrypt : :decrypt) - - cipher.padding = 0 - cipher.iv = make_key(cipher.iv_len, options[:iv], options) if ossl_name != "rc4" - key_len = KEY_LEN_OVERRIDE[name] || cipher.key_len - cipher.key_len = key_len - cipher.key = make_key(key_len, options[:key], options) - cipher.update(" " * 1536) if ossl_name == "rc4" - - return cipher - end - - # Returns a two-element array containing the [ key-length, - # block-size ] for the named cipher algorithm. If the cipher - # algorithm is unknown, or is "none", 0 is returned for both elements - # of the tuple. - def self.get_lengths(name) - ossl_name = SSH_TO_OSSL[name] - return [0, 0] if ossl_name.nil? || ossl_name == "none" - - cipher = OpenSSL::Cipher::Cipher.new(ossl_name) - key_len = KEY_LEN_OVERRIDE[name] || cipher.key_len - cipher.key_len = key_len - - return [key_len, ossl_name=="rc4" ? 8 : cipher.block_size] - end - - private - - # Generate a key value in accordance with the SSH2 specification. - def self.make_key(bytes, start, options={}) - k = start[0, bytes] - - digester = options[:digester] or raise 'No digester supplied' - shared = options[:shared] or raise 'No shared secret supplied' - hash = options[:hash] or raise 'No hash supplied' - - while k.length < bytes - step = digester.digest(shared + hash + k) - bytes_needed = bytes - k.length - k << step[0, bytes_needed] - end - - return k - end - end - -end; end; end diff --git a/vendor/gems/net-ssh-2.0.15/lib/net/ssh/transport/constants.rb b/vendor/gems/net-ssh-2.0.15/lib/net/ssh/transport/constants.rb deleted file mode 100644 index c87ce4cc6..000000000 --- a/vendor/gems/net-ssh-2.0.15/lib/net/ssh/transport/constants.rb +++ /dev/null @@ -1,30 +0,0 @@ -module Net; module SSH; module Transport - module Constants - - #-- - # Transport layer generic messages - #++ - - DISCONNECT = 1 - IGNORE = 2 - UNIMPLEMENTED = 3 - DEBUG = 4 - SERVICE_REQUEST = 5 - SERVICE_ACCEPT = 6 - - #-- - # Algorithm negotiation messages - #++ - - KEXINIT = 20 - NEWKEYS = 21 - - #-- - # Key exchange method specific messages - #++ - - KEXDH_INIT = 30 - KEXDH_REPLY = 31 - - end -end; end; end \ No newline at end of file diff --git a/vendor/gems/net-ssh-2.0.15/lib/net/ssh/transport/hmac.rb b/vendor/gems/net-ssh-2.0.15/lib/net/ssh/transport/hmac.rb deleted file mode 100644 index 262db7339..000000000 --- a/vendor/gems/net-ssh-2.0.15/lib/net/ssh/transport/hmac.rb +++ /dev/null @@ -1,31 +0,0 @@ -require 'net/ssh/transport/hmac/md5' -require 'net/ssh/transport/hmac/md5_96' -require 'net/ssh/transport/hmac/sha1' -require 'net/ssh/transport/hmac/sha1_96' -require 'net/ssh/transport/hmac/none' - -# Implements a simple factory interface for fetching hmac implementations, or -# for finding the key lengths for hmac implementations.s -module Net::SSH::Transport::HMAC - # The mapping of SSH hmac algorithms to their implementations - MAP = { - 'hmac-md5' => MD5, - 'hmac-md5-96' => MD5_96, - 'hmac-sha1' => SHA1, - 'hmac-sha1-96' => SHA1_96, - 'none' => None - } - - # Retrieves a new hmac instance of the given SSH type (+name+). If +key+ is - # given, the new instance will be initialized with that key. - def self.get(name, key="") - impl = MAP[name] or raise ArgumentError, "hmac not found: #{name.inspect}" - impl.new(key) - end - - # Retrieves the key length for the hmac of the given SSH type (+name+). - def self.key_length(name) - impl = MAP[name] or raise ArgumentError, "hmac not found: #{name.inspect}" - impl.key_length - end -end \ No newline at end of file diff --git a/vendor/gems/net-ssh-2.0.15/lib/net/ssh/transport/hmac/abstract.rb b/vendor/gems/net-ssh-2.0.15/lib/net/ssh/transport/hmac/abstract.rb deleted file mode 100644 index b3e3eaab7..000000000 --- a/vendor/gems/net-ssh-2.0.15/lib/net/ssh/transport/hmac/abstract.rb +++ /dev/null @@ -1,79 +0,0 @@ -require 'openssl' -require 'openssl/digest' - -module Net; module SSH; module Transport; module HMAC - - # The base class of all OpenSSL-based HMAC algorithm wrappers. - class Abstract - - class < DiffieHellmanGroupExchangeSHA1, - 'diffie-hellman-group1-sha1' => DiffieHellmanGroup1SHA1 - } - end -end \ No newline at end of file diff --git a/vendor/gems/net-ssh-2.0.15/lib/net/ssh/transport/kex/diffie_hellman_group1_sha1.rb b/vendor/gems/net-ssh-2.0.15/lib/net/ssh/transport/kex/diffie_hellman_group1_sha1.rb deleted file mode 100644 index a9875ac49..000000000 --- a/vendor/gems/net-ssh-2.0.15/lib/net/ssh/transport/kex/diffie_hellman_group1_sha1.rb +++ /dev/null @@ -1,208 +0,0 @@ -require 'net/ssh/buffer' -require 'net/ssh/errors' -require 'net/ssh/loggable' -require 'net/ssh/transport/openssl' -require 'net/ssh/transport/constants' - -module Net; module SSH; module Transport; module Kex - - # A key-exchange service implementing the "diffie-hellman-group1-sha1" - # key-exchange algorithm. - class DiffieHellmanGroup1SHA1 - include Constants, Loggable - - # The value of 'P', as a string, in hexadecimal - P_s = "FFFFFFFF" "FFFFFFFF" "C90FDAA2" "2168C234" + - "C4C6628B" "80DC1CD1" "29024E08" "8A67CC74" + - "020BBEA6" "3B139B22" "514A0879" "8E3404DD" + - "EF9519B3" "CD3A431B" "302B0A6D" "F25F1437" + - "4FE1356D" "6D51C245" "E485B576" "625E7EC6" + - "F44C42E9" "A637ED6B" "0BFF5CB6" "F406B7ED" + - "EE386BFB" "5A899FA5" "AE9F2411" "7C4B1FE6" + - "49286651" "ECE65381" "FFFFFFFF" "FFFFFFFF" - - # The radix in which P_s represents the value of P - P_r = 16 - - # The group constant - G = 2 - - attr_reader :p - attr_reader :g - attr_reader :digester - attr_reader :algorithms - attr_reader :connection - attr_reader :data - attr_reader :dh - - # Create a new instance of the DiffieHellmanGroup1SHA1 algorithm. - # The data is a Hash of symbols representing information - # required by this algorithm, which was acquired during earlier - # processing. - def initialize(algorithms, connection, data) - @p = OpenSSL::BN.new(P_s, P_r) - @g = G - - @digester = OpenSSL::Digest::SHA1 - @algorithms = algorithms - @connection = connection - - @data = data.dup - @dh = generate_key - @logger = @data.delete(:logger) - end - - # Perform the key-exchange for the given session, with the given - # data. This method will return a hash consisting of the - # following keys: - # - # * :session_id - # * :server_key - # * :shared_secret - # * :hashing_algorithm - # - # The caller is expected to be able to understand how to use these - # deliverables. - def exchange_keys - result = send_kexinit - verify_server_key(result[:server_key]) - session_id = verify_signature(result) - confirm_newkeys - - return { :session_id => session_id, - :server_key => result[:server_key], - :shared_secret => result[:shared_secret], - :hashing_algorithm => digester } - end - - private - - # Returns the DH key parameters for the current connection. - def get_parameters - [p, g] - end - - # Returns the INIT/REPLY constants used by this algorithm. - def get_message_types - [KEXDH_INIT, KEXDH_REPLY] - end - - # Build the signature buffer to use when verifying a signature from - # the server. - def build_signature_buffer(result) - response = Net::SSH::Buffer.new - response.write_string data[:client_version_string], - data[:server_version_string], - data[:client_algorithm_packet], - data[:server_algorithm_packet], - result[:key_blob] - response.write_bignum dh.pub_key, - result[:server_dh_pubkey], - result[:shared_secret] - response - end - - # Generate a DH key with a private key consisting of the given - # number of bytes. - def generate_key #:nodoc: - dh = OpenSSL::PKey::DH.new - - dh.p, dh.g = get_parameters - dh.priv_key = OpenSSL::BN.rand(data[:need_bytes] * 8) - - dh.generate_key! until dh.valid? - - dh - end - - # Send the KEXDH_INIT message, and expect the KEXDH_REPLY. Return the - # resulting buffer. - # - # Parse the buffer from a KEXDH_REPLY message, returning a hash of - # the extracted values. - def send_kexinit #:nodoc: - init, reply = get_message_types - - # send the KEXDH_INIT message - buffer = Net::SSH::Buffer.from(:byte, init, :bignum, dh.pub_key) - connection.send_message(buffer) - - # expect the KEXDH_REPLY message - buffer = connection.next_message - raise Net::SSH::Exception, "expected REPLY" unless buffer.type == reply - - result = Hash.new - - result[:key_blob] = buffer.read_string - result[:server_key] = Net::SSH::Buffer.new(result[:key_blob]).read_key - result[:server_dh_pubkey] = buffer.read_bignum - result[:shared_secret] = OpenSSL::BN.new(dh.compute_key(result[:server_dh_pubkey]), 2) - - sig_buffer = Net::SSH::Buffer.new(buffer.read_string) - sig_type = sig_buffer.read_string - if sig_type != algorithms.host_key - raise Net::SSH::Exception, - "host key algorithm mismatch for signature " + - "'#{sig_type}' != '#{algorithms.host_key}'" - end - result[:server_sig] = sig_buffer.read_string - - return result - end - - # Verify that the given key is of the expected type, and that it - # really is the key for the session's host. Raise Net::SSH::Exception - # if it is not. - def verify_server_key(key) #:nodoc: - if key.ssh_type != algorithms.host_key - raise Net::SSH::Exception, - "host key algorithm mismatch " + - "'#{key.ssh_type}' != '#{algorithms.host_key}'" - end - - blob, fingerprint = generate_key_fingerprint(key) - - unless connection.host_key_verifier.verify(:key => key, :key_blob => blob, :fingerprint => fingerprint, :session => connection) - raise Net::SSH::Exception, "host key verification failed" - end - end - - def generate_key_fingerprint(key) - blob = Net::SSH::Buffer.from(:key, key).to_s - fingerprint = OpenSSL::Digest::MD5.hexdigest(blob).scan(/../).join(":") - - [blob, fingerprint] - rescue ::Exception => e - [nil, "(could not generate fingerprint: #{e.message})"] - end - - # Verify the signature that was received. Raise Net::SSH::Exception - # if the signature could not be verified. Otherwise, return the new - # session-id. - def verify_signature(result) #:nodoc: - response = build_signature_buffer(result) - - hash = @digester.digest(response.to_s) - - unless result[:server_key].ssh_do_verify(result[:server_sig], hash) - raise Net::SSH::Exception, "could not verify server signature" - end - - return hash - end - - # Send the NEWKEYS message, and expect the NEWKEYS message in - # reply. - def confirm_newkeys #:nodoc: - # send own NEWKEYS message first (the wodSSHServer won't send first) - response = Net::SSH::Buffer.new - response.write_byte(NEWKEYS) - connection.send_message(response) - - # wait for the server's NEWKEYS message - buffer = connection.next_message - raise Net::SSH::Exception, "expected NEWKEYS" unless buffer.type == NEWKEYS - end - end - -end; end; end; end diff --git a/vendor/gems/net-ssh-2.0.15/lib/net/ssh/transport/kex/diffie_hellman_group_exchange_sha1.rb b/vendor/gems/net-ssh-2.0.15/lib/net/ssh/transport/kex/diffie_hellman_group_exchange_sha1.rb deleted file mode 100644 index da47ec2f9..000000000 --- a/vendor/gems/net-ssh-2.0.15/lib/net/ssh/transport/kex/diffie_hellman_group_exchange_sha1.rb +++ /dev/null @@ -1,77 +0,0 @@ -require 'net/ssh/errors' -require 'net/ssh/transport/constants' -require 'net/ssh/transport/kex/diffie_hellman_group1_sha1' - -module Net::SSH::Transport::Kex - - # A key-exchange service implementing the - # "diffie-hellman-group-exchange-sha1" key-exchange algorithm. - class DiffieHellmanGroupExchangeSHA1 < DiffieHellmanGroup1SHA1 - MINIMUM_BITS = 1024 - MAXIMUM_BITS = 8192 - - KEXDH_GEX_GROUP = 31 - KEXDH_GEX_INIT = 32 - KEXDH_GEX_REPLY = 33 - KEXDH_GEX_REQUEST = 34 - - private - - # Compute the number of bits needed for the given number of bytes. - def compute_need_bits - need_bits = data[:need_bytes] * 8 - if need_bits < MINIMUM_BITS - need_bits = MINIMUM_BITS - elsif need_bits > MAXIMUM_BITS - need_bits = MAXIMUM_BITS - end - - data[:need_bits ] = need_bits - data[:need_bytes] = need_bits / 8 - end - - # Returns the DH key parameters for the given session. - def get_parameters - compute_need_bits - - # request the DH key parameters for the given number of bits. - buffer = Net::SSH::Buffer.from(:byte, KEXDH_GEX_REQUEST, :long, MINIMUM_BITS, - :long, data[:need_bits], :long, MAXIMUM_BITS) - connection.send_message(buffer) - - buffer = connection.next_message - unless buffer.type == KEXDH_GEX_GROUP - raise Net::SSH::Exception, "expected KEXDH_GEX_GROUP, got #{buffer.type}" - end - - p = buffer.read_bignum - g = buffer.read_bignum - - [p, g] - end - - # Returns the INIT/REPLY constants used by this algorithm. - def get_message_types - [KEXDH_GEX_INIT, KEXDH_GEX_REPLY] - end - - # Build the signature buffer to use when verifying a signature from - # the server. - def build_signature_buffer(result) - response = Net::SSH::Buffer.new - response.write_string data[:client_version_string], - data[:server_version_string], - data[:client_algorithm_packet], - data[:server_algorithm_packet], - result[:key_blob] - response.write_long MINIMUM_BITS, - data[:need_bits], - MAXIMUM_BITS - response.write_bignum dh.p, dh.g, dh.pub_key, - result[:server_dh_pubkey], - result[:shared_secret] - response - end - end - -end \ No newline at end of file diff --git a/vendor/gems/net-ssh-2.0.15/lib/net/ssh/transport/openssl.rb b/vendor/gems/net-ssh-2.0.15/lib/net/ssh/transport/openssl.rb deleted file mode 100644 index 03036ec95..000000000 --- a/vendor/gems/net-ssh-2.0.15/lib/net/ssh/transport/openssl.rb +++ /dev/null @@ -1,128 +0,0 @@ -require 'openssl' -require 'net/ssh/buffer' - -module OpenSSL - - # This class is originally defined in the OpenSSL module. As needed, methods - # have been added to it by the Net::SSH module for convenience in dealing with - # SSH functionality. - class BN - - # Converts a BN object to a string. The format used is that which is - # required by the SSH2 protocol. - def to_ssh - if zero? - return [0].pack("N") - else - buf = to_s(2) - if buf.getbyte(0)[7] == 1 - return [buf.length+1, 0, buf].pack("NCA*") - else - return [buf.length, buf].pack("NA*") - end - end - end - - end - - module PKey - - class PKey - def fingerprint - @fingerprint ||= OpenSSL::Digest::MD5.hexdigest(to_blob).scan(/../).join(":") - end - end - - # This class is originally defined in the OpenSSL module. As needed, methods - # have been added to it by the Net::SSH module for convenience in dealing - # with SSH functionality. - class DH - - # Determines whether the pub_key for this key is valid. (This algorithm - # lifted more-or-less directly from OpenSSH, dh.c, dh_pub_is_valid.) - def valid? - return false if pub_key.nil? || pub_key < 0 - bits_set = 0 - pub_key.num_bits.times { |i| bits_set += 1 if pub_key.bit_set?(i) } - return ( bits_set > 1 && pub_key < p ) - end - - end - - # This class is originally defined in the OpenSSL module. As needed, methods - # have been added to it by the Net::SSH module for convenience in dealing - # with SSH functionality. - class RSA - - # Returns "ssh-rsa", which is the description of this key type used by the - # SSH2 protocol. - def ssh_type - "ssh-rsa" - end - - # Converts the key to a blob, according to the SSH2 protocol. - def to_blob - @blob ||= Net::SSH::Buffer.from(:string, ssh_type, :bignum, e, :bignum, n).to_s - end - - # Verifies the given signature matches the given data. - def ssh_do_verify(sig, data) - verify(OpenSSL::Digest::SHA1.new, sig, data) - end - - # Returns the signature for the given data. - def ssh_do_sign(data) - sign(OpenSSL::Digest::SHA1.new, data) - end - end - - # This class is originally defined in the OpenSSL module. As needed, methods - # have been added to it by the Net::SSH module for convenience in dealing - # with SSH functionality. - class DSA - - # Returns "ssh-dss", which is the description of this key type used by the - # SSH2 protocol. - def ssh_type - "ssh-dss" - end - - # Converts the key to a blob, according to the SSH2 protocol. - def to_blob - @blob ||= Net::SSH::Buffer.from(:string, ssh_type, - :bignum, p, :bignum, q, :bignum, g, :bignum, pub_key).to_s - end - - # Verifies the given signature matches the given data. - def ssh_do_verify(sig, data) - sig_r = sig[0,20].unpack("H*")[0].to_i(16) - sig_s = sig[20,20].unpack("H*")[0].to_i(16) - a1sig = OpenSSL::ASN1::Sequence([ - OpenSSL::ASN1::Integer(sig_r), - OpenSSL::ASN1::Integer(sig_s) - ]) - return verify(OpenSSL::Digest::DSS1.new, a1sig.to_der, data) - end - - # Signs the given data. - def ssh_do_sign(data) - sig = sign( OpenSSL::Digest::DSS1.new, data) - a1sig = OpenSSL::ASN1.decode( sig ) - - sig_r = a1sig.value[0].value.to_s(2) - sig_s = a1sig.value[1].value.to_s(2) - - if sig_r.length > 20 || sig_s.length > 20 - raise OpenSSL::PKey::DSAError, "bad sig size" - end - - sig_r = "\0" * ( 20 - sig_r.length ) + sig_r if sig_r.length < 20 - sig_s = "\0" * ( 20 - sig_s.length ) + sig_s if sig_s.length < 20 - - return sig_r + sig_s - end - end - - end - -end diff --git a/vendor/gems/net-ssh-2.0.15/lib/net/ssh/transport/packet_stream.rb b/vendor/gems/net-ssh-2.0.15/lib/net/ssh/transport/packet_stream.rb deleted file mode 100644 index 8404c56c5..000000000 --- a/vendor/gems/net-ssh-2.0.15/lib/net/ssh/transport/packet_stream.rb +++ /dev/null @@ -1,232 +0,0 @@ -require 'net/ssh/buffered_io' -require 'net/ssh/errors' -require 'net/ssh/packet' -require 'net/ssh/ruby_compat' -require 'net/ssh/transport/cipher_factory' -require 'net/ssh/transport/hmac' -require 'net/ssh/transport/state' - - -module Net; module SSH; module Transport - - # A module that builds additional functionality onto the Net::SSH::BufferedIo - # module. It adds SSH encryption, compression, and packet validation, as - # per the SSH2 protocol. It also adds an abstraction for polling packets, - # to allow for both blocking and non-blocking reads. - module PacketStream - include BufferedIo - - def self.extended(object) - object.__send__(:initialize_ssh) - end - - # The map of "hints" that can be used to modify the behavior of the packet - # stream. For instance, when authentication succeeds, an "authenticated" - # hint is set, which is used to determine whether or not to compress the - # data when using the "delayed" compression algorithm. - attr_reader :hints - - # The server state object, which encapsulates the algorithms used to interpret - # packets coming from the server. - attr_reader :server - - # The client state object, which encapsulates the algorithms used to build - # packets to send to the server. - attr_reader :client - - # The name of the client (local) end of the socket, as reported by the - # socket. - def client_name - @client_name ||= begin - sockaddr = getsockname - begin - Socket.getnameinfo(sockaddr, Socket::NI_NAMEREQD).first - rescue - begin - Socket.getnameinfo(sockaddr).first - rescue - begin - Socket.gethostbyname(Socket.gethostname).first - rescue - lwarn { "the client ipaddr/name could not be determined" } - "unknown" - end - end - end - end - end - - # The IP address of the peer (remote) end of the socket, as reported by - # the socket. - def peer_ip - @peer_ip ||= begin - addr = getpeername - Socket.getnameinfo(addr, Socket::NI_NUMERICHOST | Socket::NI_NUMERICSERV).first - end - end - - # Returns true if the IO is available for reading, and false otherwise. - def available_for_read? - result = Net::SSH::Compat.io_select([self], nil, nil, 0) - result && result.first.any? - end - - # Returns the next full packet. If the mode parameter is :nonblock (the - # default), then this will return immediately, whether a packet is - # available or not, and will return nil if there is no packet ready to be - # returned. If the mode parameter is :block, then this method will block - # until a packet is available. - def next_packet(mode=:nonblock) - case mode - when :nonblock then - fill if available_for_read? - poll_next_packet - - when :block then - loop do - packet = poll_next_packet - return packet if packet - - loop do - result = Net::SSH::Compat.io_select([self]) or next - break if result.first.any? - end - - if fill <= 0 - raise Net::SSH::Disconnect, "connection closed by remote host" - end - end - - else - raise ArgumentError, "expected :block or :nonblock, got #{mode.inspect}" - end - end - - # Enqueues a packet to be sent, and blocks until the entire packet is - # sent. - def send_packet(payload) - enqueue_packet(payload) - wait_for_pending_sends - end - - # Enqueues a packet to be sent, but does not immediately send the packet. - # The given payload is pre-processed according to the algorithms specified - # in the client state (compression, cipher, and hmac). - def enqueue_packet(payload) - # try to compress the packet - payload = client.compress(payload) - - # the length of the packet, minus the padding - actual_length = 4 + payload.length + 1 - - # compute the padding length - padding_length = client.block_size - (actual_length % client.block_size) - padding_length += client.block_size if padding_length < 4 - - # compute the packet length (sans the length field itself) - packet_length = payload.length + padding_length + 1 - - if packet_length < 16 - padding_length += client.block_size - packet_length = payload.length + padding_length + 1 - end - - padding = Array.new(padding_length) { rand(256) }.pack("C*") - - unencrypted_data = [packet_length, padding_length, payload, padding].pack("NCA*A*") - mac = client.hmac.digest([client.sequence_number, unencrypted_data].pack("NA*")) - - encrypted_data = client.update_cipher(unencrypted_data) << client.final_cipher - message = encrypted_data + mac - - debug { "queueing packet nr #{client.sequence_number} type #{payload.getbyte(0)} len #{packet_length}" } - enqueue(message) - - client.increment(packet_length) - - self - end - - # Performs any pending cleanup necessary on the IO and its associated - # state objects. (See State#cleanup). - def cleanup - client.cleanup - server.cleanup - end - - # If the IO object requires a rekey operation (as indicated by either its - # client or server state objects, see State#needs_rekey?), this will - # yield. Otherwise, this does nothing. - def if_needs_rekey? - if client.needs_rekey? || server.needs_rekey? - yield - client.reset! if client.needs_rekey? - server.reset! if server.needs_rekey? - end - end - - protected - - # Called when this module is used to extend an object. It initializes - # the states and generally prepares the object for use as a packet stream. - def initialize_ssh - @hints = {} - @server = State.new(self, :server) - @client = State.new(self, :client) - @packet = nil - initialize_buffered_io - end - - # Tries to read the next packet. If there is insufficient data to read - # an entire packet, this returns immediately, otherwise the packet is - # read, post-processed according to the cipher, hmac, and compression - # algorithms specified in the server state object, and returned as a - # new Packet object. - def poll_next_packet - if @packet.nil? - minimum = server.block_size < 4 ? 4 : server.block_size - return nil if available < minimum - data = read_available(minimum) - - # decipher it - @packet = Net::SSH::Buffer.new(server.update_cipher(data)) - @packet_length = @packet.read_long - end - - need = @packet_length + 4 - server.block_size - raise Net::SSH::Exception, "padding error, need #{need} block #{server.block_size}" if need % server.block_size != 0 - - return nil if available < need + server.hmac.mac_length - - if need > 0 - # read the remainder of the packet and decrypt it. - data = read_available(need) - @packet.append(server.update_cipher(data)) - end - - # get the hmac from the tail of the packet (if one exists), and - # then validate it. - real_hmac = read_available(server.hmac.mac_length) || "" - - @packet.append(server.final_cipher) - padding_length = @packet.read_byte - - payload = @packet.read(@packet_length - padding_length - 1) - padding = @packet.read(padding_length) if padding_length > 0 - - my_computed_hmac = server.hmac.digest([server.sequence_number, @packet.content].pack("NA*")) - raise Net::SSH::Exception, "corrupted mac detected" if real_hmac != my_computed_hmac - - # try to decompress the payload, in case compression is active - payload = server.decompress(payload) - - debug { "received packet nr #{server.sequence_number} type #{payload.getbyte(0)} len #{@packet_length}" } - - server.increment(@packet_length) - @packet = nil - - return Packet.new(payload) - end - end - -end; end; end diff --git a/vendor/gems/net-ssh-2.0.15/lib/net/ssh/transport/server_version.rb b/vendor/gems/net-ssh-2.0.15/lib/net/ssh/transport/server_version.rb deleted file mode 100644 index 9a0fb605a..000000000 --- a/vendor/gems/net-ssh-2.0.15/lib/net/ssh/transport/server_version.rb +++ /dev/null @@ -1,70 +0,0 @@ -require 'net/ssh/errors' -require 'net/ssh/loggable' -require 'net/ssh/version' - -module Net; module SSH; module Transport - - # Negotiates the SSH protocol version and trades information about server - # and client. This is never used directly--it is always called by the - # transport layer as part of the initialization process of the transport - # layer. - # - # Note that this class also encapsulates the negotiated version, and acts as - # the authoritative reference for any queries regarding the version in effect. - class ServerVersion - include Loggable - - # The SSH version string as reported by Net::SSH - PROTO_VERSION = "SSH-2.0-Ruby/Net::SSH_#{Net::SSH::Version::CURRENT} #{RUBY_PLATFORM}" - - # Any header text sent by the server prior to sending the version. - attr_reader :header - - # The version string reported by the server. - attr_reader :version - - # Instantiates a new ServerVersion and immediately (and synchronously) - # negotiates the SSH protocol in effect, using the given socket. - def initialize(socket, logger) - @header = "" - @version = nil - @logger = logger - negotiate!(socket) - end - - private - - # Negotiates the SSH protocol to use, via the given socket. If the server - # reports an incompatible SSH version (e.g., SSH1), this will raise an - # exception. - def negotiate!(socket) - info { "negotiating protocol version" } - - loop do - @version = "" - loop do - b = socket.recv(1) - - if b.nil? - raise Net::SSH::Disconnect, "connection closed by remote host" - end - @version << b - break if b == "\n" - end - break if @version.match(/^SSH-/) - @header << @version - end - - @version.chomp! - debug { "remote is `#{@version}'" } - - unless @version.match(/^SSH-(1\.99|2\.0)-/) - raise Net::SSH::Exception, "incompatible SSH version `#{@version}'" - end - - debug { "local is `#{PROTO_VERSION}'" } - socket.write "#{PROTO_VERSION}\r\n" - socket.flush - end - end -end; end; end diff --git a/vendor/gems/net-ssh-2.0.15/lib/net/ssh/transport/session.rb b/vendor/gems/net-ssh-2.0.15/lib/net/ssh/transport/session.rb deleted file mode 100644 index 519777f23..000000000 --- a/vendor/gems/net-ssh-2.0.15/lib/net/ssh/transport/session.rb +++ /dev/null @@ -1,276 +0,0 @@ -require 'socket' -require 'timeout' - -require 'net/ssh/errors' -require 'net/ssh/loggable' -require 'net/ssh/version' -require 'net/ssh/transport/algorithms' -require 'net/ssh/transport/constants' -require 'net/ssh/transport/packet_stream' -require 'net/ssh/transport/server_version' -require 'net/ssh/verifiers/null' -require 'net/ssh/verifiers/strict' -require 'net/ssh/verifiers/lenient' - -module Net; module SSH; module Transport - - # The transport layer represents the lowest level of the SSH protocol, and - # implements basic message exchanging and protocol initialization. It will - # never be instantiated directly (unless you really know what you're about), - # but will instead be created for you automatically when you create a new - # SSH session via Net::SSH.start. - class Session - include Constants, Loggable - - # The standard port for the SSH protocol. - DEFAULT_PORT = 22 - - # The host to connect to, as given to the constructor. - attr_reader :host - - # The port number to connect to, as given in the options to the constructor. - # If no port number was given, this will default to DEFAULT_PORT. - attr_reader :port - - # The underlying socket object being used to communicate with the remote - # host. - attr_reader :socket - - # The ServerVersion instance that encapsulates the negotiated protocol - # version. - attr_reader :server_version - - # The Algorithms instance used to perform key exchanges. - attr_reader :algorithms - - # The host-key verifier object used to verify host keys, to ensure that - # the connection is not being spoofed. - attr_reader :host_key_verifier - - # The hash of options that were given to the object at initialization. - attr_reader :options - - # Instantiates a new transport layer abstraction. This will block until - # the initial key exchange completes, leaving you with a ready-to-use - # transport session. - def initialize(host, options={}) - self.logger = options[:logger] - - @host = host - @port = options[:port] || DEFAULT_PORT - @options = options - - debug { "establishing connection to #{@host}:#{@port}" } - factory = options[:proxy] || TCPSocket - @socket = timeout(options[:timeout] || 0) { factory.open(@host, @port) } - @socket.extend(PacketStream) - @socket.logger = @logger - - debug { "connection established" } - - @queue = [] - - @host_key_verifier = select_host_key_verifier(options[:paranoid]) - - @server_version = ServerVersion.new(socket, logger) - - @algorithms = Algorithms.new(self, options) - wait { algorithms.initialized? } - end - - # Returns the host (and possibly IP address) in a format compatible with - # SSH known-host files. - def host_as_string - @host_as_string ||= begin - string = "#{host}" - string = "[#{string}]:#{port}" if port != DEFAULT_PORT - if socket.peer_ip != host - string2 = socket.peer_ip - string2 = "[#{string2}]:#{port}" if port != DEFAULT_PORT - string << "," << string2 - end - string - end - end - - # Returns true if the underlying socket has been closed. - def closed? - socket.closed? - end - - # Cleans up (see PacketStream#cleanup) and closes the underlying socket. - def close - socket.cleanup - socket.close - end - - # Performs a "hard" shutdown of the connection. In general, this should - # never be done, but it might be necessary (in a rescue clause, for instance, - # when the connection needs to close but you don't know the status of the - # underlying protocol's state). - def shutdown! - error { "forcing connection closed" } - socket.close - end - - # Returns a new service_request packet for the given service name, ready - # for sending to the server. - def service_request(service) - Net::SSH::Buffer.from(:byte, SERVICE_REQUEST, :string, service) - end - - # Requests a rekey operation, and blocks until the operation completes. - # If a rekey is already pending, this returns immediately, having no - # effect. - def rekey! - if !algorithms.pending? - algorithms.rekey! - wait { algorithms.initialized? } - end - end - - # Returns immediately if a rekey is already in process. Otherwise, if a - # rekey is needed (as indicated by the socket, see PacketStream#if_needs_rekey?) - # one is performed, causing this method to block until it completes. - def rekey_as_needed - return if algorithms.pending? - socket.if_needs_rekey? { rekey! } - end - - # Returns a hash of information about the peer (remote) side of the socket, - # including :ip, :port, :host, and :canonized (see #host_as_string). - def peer - @peer ||= { :ip => socket.peer_ip, :port => @port.to_i, :host => @host, :canonized => host_as_string } - end - - # Blocks until a new packet is available to be read, and returns that - # packet. See #poll_message. - def next_message - poll_message(:block) - end - - # Tries to read the next packet from the socket. If mode is :nonblock (the - # default), this will not block and will return nil if there are no packets - # waiting to be read. Otherwise, this will block until a packet is - # available. Note that some packet types (DISCONNECT, IGNORE, UNIMPLEMENTED, - # DEBUG, and KEXINIT) are handled silently by this method, and will never - # be returned. - # - # If a key-exchange is in process and a disallowed packet type is - # received, it will be enqueued and otherwise ignored. When a key-exchange - # is not in process, and consume_queue is true, packets will be first - # read from the queue before the socket is queried. - def poll_message(mode=:nonblock, consume_queue=true) - loop do - if consume_queue && @queue.any? && algorithms.allow?(@queue.first) - return @queue.shift - end - - packet = socket.next_packet(mode) - return nil if packet.nil? - - case packet.type - when DISCONNECT - raise Net::SSH::Disconnect, "disconnected: #{packet[:description]} (#{packet[:reason_code]})" - - when IGNORE - debug { "IGNORE packet recieved: #{packet[:data].inspect}" } - - when UNIMPLEMENTED - lwarn { "UNIMPLEMENTED: #{packet[:number]}" } - - when DEBUG - send(packet[:always_display] ? :fatal : :debug) { packet[:message] } - - when KEXINIT - algorithms.accept_kexinit(packet) - - else - return packet if algorithms.allow?(packet) - push(packet) - end - end - end - - # Waits (blocks) until the given block returns true. If no block is given, - # this just waits long enough to see if there are any pending packets. Any - # packets read are enqueued (see #push). - def wait - loop do - break if block_given? && yield - message = poll_message(:nonblock, false) - push(message) if message - break if !block_given? - end - end - - # Adds the given packet to the packet queue. If the queue is non-empty, - # #poll_message will return packets from the queue in the order they - # were received. - def push(packet) - @queue.push(packet) - end - - # Sends the given message via the packet stream, blocking until the - # entire message has been sent. - def send_message(message) - socket.send_packet(message) - end - - # Enqueues the given message, such that it will be sent at the earliest - # opportunity. This does not block, but returns immediately. - def enqueue_message(message) - socket.enqueue_packet(message) - end - - # Configure's the packet stream's client state with the given set of - # options. This is typically used to define the cipher, compression, and - # hmac algorithms to use when sending packets to the server. - def configure_client(options={}) - socket.client.set(options) - end - - # Configure's the packet stream's server state with the given set of - # options. This is typically used to define the cipher, compression, and - # hmac algorithms to use when reading packets from the server. - def configure_server(options={}) - socket.server.set(options) - end - - # Sets a new hint for the packet stream, which the packet stream may use - # to change its behavior. (See PacketStream#hints). - def hint(which, value=true) - socket.hints[which] = value - end - - public - - # this method is primarily for use in tests - attr_reader :queue #:nodoc: - - private - - # Instantiates a new host-key verification class, based on the value of - # the parameter. When true or nil, the default Lenient verifier is - # returned. If it is false, the Null verifier is returned, and if it is - # :very, the Strict verifier is returned. If the argument happens to - # respond to :verify, it is returned directly. Otherwise, an exception - # is raised. - def select_host_key_verifier(paranoid) - case paranoid - when true, nil then - Net::SSH::Verifiers::Lenient.new - when false then - Net::SSH::Verifiers::Null.new - when :very then - Net::SSH::Verifiers::Strict.new - else - if paranoid.respond_to?(:verify) - paranoid - else - raise ArgumentError, "argument to :paranoid is not valid: #{paranoid.inspect}" - end - end - end - end -end; end; end diff --git a/vendor/gems/net-ssh-2.0.15/lib/net/ssh/transport/state.rb b/vendor/gems/net-ssh-2.0.15/lib/net/ssh/transport/state.rb deleted file mode 100644 index 2d8a3ddaa..000000000 --- a/vendor/gems/net-ssh-2.0.15/lib/net/ssh/transport/state.rb +++ /dev/null @@ -1,206 +0,0 @@ -require 'zlib' -require 'net/ssh/transport/cipher_factory' -require 'net/ssh/transport/hmac' - -module Net; module SSH; module Transport - - # Encapsulates state information about one end of an SSH connection. Such - # state includes the packet sequence number, the algorithms in use, how - # many packets and blocks have been processed since the last reset, and so - # forth. This class will never be instantiated directly, but is used as - # part of the internal state of the PacketStream module. - class State - # The socket object that owns this state object. - attr_reader :socket - - # The next packet sequence number for this socket endpoint. - attr_reader :sequence_number - - # The hmac algorithm in use for this endpoint. - attr_reader :hmac - - # The compression algorithm in use for this endpoint. - attr_reader :compression - - # The compression level to use when compressing data (or nil, for the default). - attr_reader :compression_level - - # The number of packets processed since the last call to #reset! - attr_reader :packets - - # The number of data blocks processed since the last call to #reset! - attr_reader :blocks - - # The cipher algorithm in use for this socket endpoint. - attr_reader :cipher - - # The block size for the cipher - attr_reader :block_size - - # The role that this state plays (either :client or :server) - attr_reader :role - - # The maximum number of packets that this endpoint wants to process before - # needing a rekey. - attr_accessor :max_packets - - # The maximum number of blocks that this endpoint wants to process before - # needing a rekey. - attr_accessor :max_blocks - - # The user-specified maximum number of bytes that this endpoint ought to - # process before needing a rekey. - attr_accessor :rekey_limit - - # Creates a new state object, belonging to the given socket. Initializes - # the algorithms to "none". - def initialize(socket, role) - @socket = socket - @role = role - @sequence_number = @packets = @blocks = 0 - @cipher = CipherFactory.get("none") - @block_size = 8 - @hmac = HMAC.get("none") - @compression = nil - @compressor = @decompressor = nil - @next_iv = "" - end - - # A convenience method for quickly setting multiple values in a single - # command. - def set(values) - values.each do |key, value| - instance_variable_set("@#{key}", value) - end - reset! - end - - def update_cipher(data) - result = cipher.update(data) - update_next_iv(role == :client ? result : data) - return result - end - - def final_cipher - result = cipher.final - update_next_iv(role == :client ? result : "", true) - return result - end - - # Increments the counters. The sequence number is incremented (and remapped - # so it always fits in a 32-bit integer). The number of packets and blocks - # are also incremented. - def increment(packet_length) - @sequence_number = (@sequence_number + 1) & 0xFFFFFFFF - @packets += 1 - @blocks += (packet_length + 4) / @block_size - end - - # The compressor object to use when compressing data. This takes into account - # the desired compression level. - def compressor - @compressor ||= Zlib::Deflate.new(compression_level || Zlib::DEFAULT_COMPRESSION) - end - - # The decompressor object to use when decompressing data. - def decompressor - @decompressor ||= Zlib::Inflate.new(nil) - end - - # Returns true if data compression/decompression is enabled. This will - # return true if :standard compression is selected, or if :delayed - # compression is selected and the :authenticated hint has been received - # by the socket. - def compression? - compression == :standard || (compression == :delayed && socket.hints[:authenticated]) - end - - # Compresses the data. If no compression is in effect, this will just return - # the data unmodified, otherwise it uses #compressor to compress the data. - def compress(data) - data = data.to_s - return data unless compression? - compressor.deflate(data, Zlib::SYNC_FLUSH) - end - - # Deompresses the data. If no compression is in effect, this will just return - # the data unmodified, otherwise it uses #decompressor to decompress the data. - def decompress(data) - data = data.to_s - return data unless compression? - decompressor.inflate(data) - end - - # Resets the counters on the state object, but leaves the sequence_number - # unchanged. It also sets defaults for and recomputes the max_packets and - # max_blocks values. - def reset! - @packets = @blocks = 0 - - @max_packets ||= 1 << 31 - - @block_size = cipher.name == "RC4" ? 8 : cipher.block_size - - if max_blocks.nil? - # cargo-culted from openssh. the idea is that "the 2^(blocksize*2) - # limit is too expensive for 3DES, blowfish, etc., so enforce a 1GB - # limit for small blocksizes." - if @block_size >= 16 - @max_blocks = 1 << (@block_size * 2) - else - @max_blocks = (1 << 30) / @block_size - end - - # if a limit on the # of bytes has been given, convert that into a - # minimum number of blocks processed. - - if rekey_limit - @max_blocks = [@max_blocks, rekey_limit / @block_size].min - end - end - - cleanup - end - - # Closes any the compressor and/or decompressor objects that have been - # instantiated. - def cleanup - if @compressor - @compressor.finish if !@compressor.finished? - @compressor.close - end - - if @decompressor - # we call reset here so that we don't get warnings when we try to - # close the decompressor - @decompressor.reset - @decompressor.close - end - - @compressor = @decompressor = nil - end - - # Returns true if the number of packets processed exceeds the maximum - # number of packets, or if the number of blocks processed exceeds the - # maximum number of blocks. - def needs_rekey? - max_packets && packets > max_packets || - max_blocks && blocks > max_blocks - end - - private - - def update_next_iv(data, reset=false) - @next_iv << data - @next_iv = @next_iv[-cipher.iv_len..-1] - - if reset - cipher.reset - cipher.iv = @next_iv - end - - return data - end - end - -end; end; end diff --git a/vendor/gems/net-ssh-2.0.15/lib/net/ssh/verifiers/lenient.rb b/vendor/gems/net-ssh-2.0.15/lib/net/ssh/verifiers/lenient.rb deleted file mode 100644 index 1fcdd5834..000000000 --- a/vendor/gems/net-ssh-2.0.15/lib/net/ssh/verifiers/lenient.rb +++ /dev/null @@ -1,30 +0,0 @@ -require 'net/ssh/verifiers/strict' - -module Net; module SSH; module Verifiers - - # Basically the same as the Strict verifier, but does not try to actually - # verify a connection if the server is the localhost and the port is a - # nonstandard port number. Those two conditions will typically mean the - # connection is being tunnelled through a forwarded port, so the known-hosts - # file will not be helpful (in general). - class Lenient < Strict - # Tries to determine if the connection is being tunnelled, and if so, - # returns true. Otherwise, performs the standard strict verification. - def verify(arguments) - return true if tunnelled?(arguments) - super - end - - private - - # A connection is potentially being tunnelled if the port is not 22, - # and the ip refers to the localhost. - def tunnelled?(args) - return false if args[:session].port == Net::SSH::Transport::Session::DEFAULT_PORT - - ip = args[:session].peer[:ip] - return ip == "127.0.0.1" || ip == "::1" - end - end - -end; end; end \ No newline at end of file diff --git a/vendor/gems/net-ssh-2.0.15/lib/net/ssh/verifiers/null.rb b/vendor/gems/net-ssh-2.0.15/lib/net/ssh/verifiers/null.rb deleted file mode 100644 index c2bda3a0d..000000000 --- a/vendor/gems/net-ssh-2.0.15/lib/net/ssh/verifiers/null.rb +++ /dev/null @@ -1,12 +0,0 @@ -module Net; module SSH; module Verifiers - - # The Null host key verifier simply allows every key it sees, without - # bothering to verify. This is simple, but is not particularly secure. - class Null - # Returns true. - def verify(arguments) - true - end - end - -end; end; end \ No newline at end of file diff --git a/vendor/gems/net-ssh-2.0.15/lib/net/ssh/verifiers/strict.rb b/vendor/gems/net-ssh-2.0.15/lib/net/ssh/verifiers/strict.rb deleted file mode 100644 index ef8edfded..000000000 --- a/vendor/gems/net-ssh-2.0.15/lib/net/ssh/verifiers/strict.rb +++ /dev/null @@ -1,53 +0,0 @@ -require 'net/ssh/errors' -require 'net/ssh/known_hosts' - -module Net; module SSH; module Verifiers - - # Does a strict host verification, looking the server up in the known - # host files to see if a key has already been seen for this server. If this - # server does not appear in any host file, this will silently add the - # server. If the server does appear at least once, but the key given does - # not match any known for the server, an exception will be raised (HostKeyMismatch). - # Otherwise, this returns true. - class Strict - def verify(arguments) - options = arguments[:session].options - host = options[:host_key_alias] || arguments[:session].host_as_string - matches = Net::SSH::KnownHosts.search_for(host, arguments[:session].options) - - # we've never seen this host before, so just automatically add the key. - # not the most secure option (since the first hit might be the one that - # is hacked), but since almost nobody actually compares the key - # fingerprint, this is a reasonable compromise between usability and - # security. - if matches.empty? - ip = arguments[:session].peer[:ip] - Net::SSH::KnownHosts.add(host, arguments[:key], arguments[:session].options) - return true - end - - # If we found any matches, check to see that the key type and - # blob also match. - found = matches.any? do |key| - key.ssh_type == arguments[:key].ssh_type && - key.to_blob == arguments[:key].to_blob - end - - # If a match was found, return true. Otherwise, raise an exception - # indicating that the key was not recognized. - found || process_cache_miss(host, arguments) - end - - private - - def process_cache_miss(host, args) - exception = HostKeyMismatch.new("fingerprint #{args[:fingerprint]} does not match for #{host.inspect}") - exception.data = args - exception.callback = Proc.new do - Net::SSH::KnownHosts.add(host, args[:key], args[:session].options) - end - raise exception - end - end - -end; end; end \ No newline at end of file diff --git a/vendor/gems/net-ssh-2.0.15/lib/net/ssh/version.rb b/vendor/gems/net-ssh-2.0.15/lib/net/ssh/version.rb deleted file mode 100644 index 263f36e70..000000000 --- a/vendor/gems/net-ssh-2.0.15/lib/net/ssh/version.rb +++ /dev/null @@ -1,62 +0,0 @@ -module Net; module SSH - # A class for describing the current version of a library. The version - # consists of three parts: the +major+ number, the +minor+ number, and the - # +tiny+ (or +patch+) number. - # - # Two Version instances may be compared, so that you can test that a version - # of a library is what you require: - # - # require 'net/ssh/version' - # - # if Net::SSH::Version::CURRENT < Net::SSH::Version[2,1,0] - # abort "your software is too old!" - # end - class Version - include Comparable - - # A convenience method for instantiating a new Version instance with the - # given +major+, +minor+, and +tiny+ components. - def self.[](major, minor, tiny) - new(major, minor, tiny) - end - - attr_reader :major, :minor, :tiny - - # Create a new Version object with the given components. - def initialize(major, minor, tiny) - @major, @minor, @tiny = major, minor, tiny - end - - # Compare this version to the given +version+ object. - def <=>(version) - to_i <=> version.to_i - end - - # Converts this version object to a string, where each of the three - # version components are joined by the '.' character. E.g., 2.0.0. - def to_s - @to_s ||= [@major, @minor, @tiny].join(".") - end - - # Converts this version to a canonical integer that may be compared - # against other version objects. - def to_i - @to_i ||= @major * 1_000_000 + @minor * 1_000 + @tiny - end - - # The major component of this version of the Net::SSH library - MAJOR = 2 - - # The minor component of this version of the Net::SSH library - MINOR = 0 - - # The tiny component of this version of the Net::SSH library - TINY = 15 - - # The current version of the Net::SSH library as a Version instance - CURRENT = new(MAJOR, MINOR, TINY) - - # The current version of the Net::SSH library as a String - STRING = CURRENT.to_s - end -end; end diff --git a/vendor/gems/net-ssh-2.0.15/net-ssh.gemspec b/vendor/gems/net-ssh-2.0.15/net-ssh.gemspec deleted file mode 100644 index a7ac88ae1..000000000 --- a/vendor/gems/net-ssh-2.0.15/net-ssh.gemspec +++ /dev/null @@ -1,131 +0,0 @@ -@spec = Gem::Specification.new do |s| - s.name = "net-ssh" - s.rubyforge_project = 'net-ssh' - s.version = "2.0.15" - s.summary = "Net::SSH: a pure-Ruby implementation of the SSH2 client protocol." - s.description = s.summary - s.authors = ["Jamis Buck", "Delano Mandelbaum"] - s.email = ["net-ssh@solutious.com", "net-ssh@solutious.com"] - s.homepage = "http://rubyforge.org/projects/net-ssh/" - - s.extra_rdoc_files = %w[README.rdoc THANKS.rdoc CHANGELOG.rdoc] - s.has_rdoc = true - s.rdoc_options = ["--line-numbers", "--title", s.summary, "--main", "README.rdoc"] - s.require_paths = %w[lib] - s.rubygems_version = '1.3.2' - - s.executables = %w[] - - # = MANIFEST = - s.files = %w( - CHANGELOG.rdoc - Manifest - README.rdoc - Rakefile - Rudyfile - THANKS.rdoc - lib/net/ssh.rb - lib/net/ssh/authentication/agent.rb - lib/net/ssh/authentication/constants.rb - lib/net/ssh/authentication/key_manager.rb - lib/net/ssh/authentication/methods/abstract.rb - lib/net/ssh/authentication/methods/hostbased.rb - lib/net/ssh/authentication/methods/keyboard_interactive.rb - lib/net/ssh/authentication/methods/password.rb - lib/net/ssh/authentication/methods/publickey.rb - lib/net/ssh/authentication/pageant.rb - lib/net/ssh/authentication/session.rb - lib/net/ssh/buffer.rb - lib/net/ssh/buffered_io.rb - lib/net/ssh/config.rb - lib/net/ssh/connection/channel.rb - lib/net/ssh/connection/constants.rb - lib/net/ssh/connection/session.rb - lib/net/ssh/connection/term.rb - lib/net/ssh/errors.rb - lib/net/ssh/key_factory.rb - lib/net/ssh/known_hosts.rb - lib/net/ssh/loggable.rb - lib/net/ssh/packet.rb - lib/net/ssh/prompt.rb - lib/net/ssh/proxy/errors.rb - lib/net/ssh/proxy/http.rb - lib/net/ssh/proxy/socks4.rb - lib/net/ssh/proxy/socks5.rb - lib/net/ssh/ruby_compat.rb - lib/net/ssh/service/forward.rb - lib/net/ssh/test.rb - lib/net/ssh/test/channel.rb - lib/net/ssh/test/extensions.rb - lib/net/ssh/test/kex.rb - lib/net/ssh/test/local_packet.rb - lib/net/ssh/test/packet.rb - lib/net/ssh/test/remote_packet.rb - lib/net/ssh/test/script.rb - lib/net/ssh/test/socket.rb - lib/net/ssh/transport/algorithms.rb - lib/net/ssh/transport/cipher_factory.rb - lib/net/ssh/transport/constants.rb - lib/net/ssh/transport/hmac.rb - lib/net/ssh/transport/hmac/abstract.rb - lib/net/ssh/transport/hmac/md5.rb - lib/net/ssh/transport/hmac/md5_96.rb - lib/net/ssh/transport/hmac/none.rb - lib/net/ssh/transport/hmac/sha1.rb - lib/net/ssh/transport/hmac/sha1_96.rb - lib/net/ssh/transport/identity_cipher.rb - lib/net/ssh/transport/kex.rb - lib/net/ssh/transport/kex/diffie_hellman_group1_sha1.rb - lib/net/ssh/transport/kex/diffie_hellman_group_exchange_sha1.rb - lib/net/ssh/transport/openssl.rb - lib/net/ssh/transport/packet_stream.rb - lib/net/ssh/transport/server_version.rb - lib/net/ssh/transport/session.rb - lib/net/ssh/transport/state.rb - lib/net/ssh/verifiers/lenient.rb - lib/net/ssh/verifiers/null.rb - lib/net/ssh/verifiers/strict.rb - lib/net/ssh/version.rb - net-ssh.gemspec - setup.rb - support/arcfour_check.rb - test/authentication/methods/common.rb - test/authentication/methods/test_abstract.rb - test/authentication/methods/test_hostbased.rb - test/authentication/methods/test_keyboard_interactive.rb - test/authentication/methods/test_password.rb - test/authentication/methods/test_publickey.rb - test/authentication/test_agent.rb - test/authentication/test_key_manager.rb - test/authentication/test_session.rb - test/common.rb - test/configs/eqsign - test/configs/exact_match - test/configs/multihost - test/configs/wild_cards - test/connection/test_channel.rb - test/connection/test_session.rb - test/test_all.rb - test/test_buffer.rb - test/test_buffered_io.rb - test/test_config.rb - test/test_key_factory.rb - test/transport/hmac/test_md5.rb - test/transport/hmac/test_md5_96.rb - test/transport/hmac/test_none.rb - test/transport/hmac/test_sha1.rb - test/transport/hmac/test_sha1_96.rb - test/transport/kex/test_diffie_hellman_group1_sha1.rb - test/transport/kex/test_diffie_hellman_group_exchange_sha1.rb - test/transport/test_algorithms.rb - test/transport/test_cipher_factory.rb - test/transport/test_hmac.rb - test/transport/test_identity_cipher.rb - test/transport/test_packet_stream.rb - test/transport/test_server_version.rb - test/transport/test_session.rb - test/transport/test_state.rb - ) - - -end diff --git a/vendor/gems/net-ssh-2.0.15/setup.rb b/vendor/gems/net-ssh-2.0.15/setup.rb deleted file mode 100644 index 424a5f37c..000000000 --- a/vendor/gems/net-ssh-2.0.15/setup.rb +++ /dev/null @@ -1,1585 +0,0 @@ -# -# setup.rb -# -# Copyright (c) 2000-2005 Minero Aoki -# -# This program is free software. -# You can distribute/modify this program under the terms of -# the GNU LGPL, Lesser General Public License version 2.1. -# - -unless Enumerable.method_defined?(:map) # Ruby 1.4.6 - module Enumerable - alias map collect - end -end - -unless File.respond_to?(:read) # Ruby 1.6 - def File.read(fname) - open(fname) {|f| - return f.read - } - end -end - -unless Errno.const_defined?(:ENOTEMPTY) # Windows? - module Errno - class ENOTEMPTY - # We do not raise this exception, implementation is not needed. - end - end -end - -def File.binread(fname) - open(fname, 'rb') {|f| - return f.read - } -end - -# for corrupted Windows' stat(2) -def File.dir?(path) - File.directory?((path[-1,1] == '/') ? path : path + '/') -end - - -class ConfigTable - - include Enumerable - - def initialize(rbconfig) - @rbconfig = rbconfig - @items = [] - @table = {} - # options - @install_prefix = nil - @config_opt = nil - @verbose = true - @no_harm = false - end - - attr_accessor :install_prefix - attr_accessor :config_opt - - attr_writer :verbose - - def verbose? - @verbose - end - - attr_writer :no_harm - - def no_harm? - @no_harm - end - - def [](key) - lookup(key).resolve(self) - end - - def []=(key, val) - lookup(key).set val - end - - def names - @items.map {|i| i.name } - end - - def each(&block) - @items.each(&block) - end - - def key?(name) - @table.key?(name) - end - - def lookup(name) - @table[name] or setup_rb_error "no such config item: #{name}" - end - - def add(item) - @items.push item - @table[item.name] = item - end - - def remove(name) - item = lookup(name) - @items.delete_if {|i| i.name == name } - @table.delete_if {|name, i| i.name == name } - item - end - - def load_script(path, inst = nil) - if File.file?(path) - MetaConfigEnvironment.new(self, inst).instance_eval File.read(path), path - end - end - - def savefile - '.config' - end - - def load_savefile - begin - File.foreach(savefile()) do |line| - k, v = *line.split(/=/, 2) - self[k] = v.strip - end - rescue Errno::ENOENT - setup_rb_error $!.message + "\n#{File.basename($0)} config first" - end - end - - def save - @items.each {|i| i.value } - File.open(savefile(), 'w') {|f| - @items.each do |i| - f.printf "%s=%s\n", i.name, i.value if i.value? and i.value - end - } - end - - def load_standard_entries - standard_entries(@rbconfig).each do |ent| - add ent - end - end - - def standard_entries(rbconfig) - c = rbconfig - - rubypath = File.join(c['bindir'], c['ruby_install_name'] + c['EXEEXT']) - - major = c['MAJOR'].to_i - minor = c['MINOR'].to_i - teeny = c['TEENY'].to_i - version = "#{major}.#{minor}" - - # ruby ver. >= 1.4.4? - newpath_p = ((major >= 2) or - ((major == 1) and - ((minor >= 5) or - ((minor == 4) and (teeny >= 4))))) - - if c['rubylibdir'] - # V > 1.6.3 - libruby = "#{c['prefix']}/lib/ruby" - librubyver = c['rubylibdir'] - librubyverarch = c['archdir'] - siteruby = c['sitedir'] - siterubyver = c['sitelibdir'] - siterubyverarch = c['sitearchdir'] - elsif newpath_p - # 1.4.4 <= V <= 1.6.3 - libruby = "#{c['prefix']}/lib/ruby" - librubyver = "#{c['prefix']}/lib/ruby/#{version}" - librubyverarch = "#{c['prefix']}/lib/ruby/#{version}/#{c['arch']}" - siteruby = c['sitedir'] - siterubyver = "$siteruby/#{version}" - siterubyverarch = "$siterubyver/#{c['arch']}" - else - # V < 1.4.4 - libruby = "#{c['prefix']}/lib/ruby" - librubyver = "#{c['prefix']}/lib/ruby/#{version}" - librubyverarch = "#{c['prefix']}/lib/ruby/#{version}/#{c['arch']}" - siteruby = "#{c['prefix']}/lib/ruby/#{version}/site_ruby" - siterubyver = siteruby - siterubyverarch = "$siterubyver/#{c['arch']}" - end - parameterize = lambda {|path| - path.sub(/\A#{Regexp.quote(c['prefix'])}/, '$prefix') - } - - if arg = c['configure_args'].split.detect {|arg| /--with-make-prog=/ =~ arg } - makeprog = arg.sub(/'/, '').split(/=/, 2)[1] - else - makeprog = 'make' - end - - [ - ExecItem.new('installdirs', 'std/site/home', - 'std: install under libruby; site: install under site_ruby; home: install under $HOME')\ - {|val, table| - case val - when 'std' - table['rbdir'] = '$librubyver' - table['sodir'] = '$librubyverarch' - when 'site' - table['rbdir'] = '$siterubyver' - table['sodir'] = '$siterubyverarch' - when 'home' - setup_rb_error '$HOME was not set' unless ENV['HOME'] - table['prefix'] = ENV['HOME'] - table['rbdir'] = '$libdir/ruby' - table['sodir'] = '$libdir/ruby' - end - }, - PathItem.new('prefix', 'path', c['prefix'], - 'path prefix of target environment'), - PathItem.new('bindir', 'path', parameterize.call(c['bindir']), - 'the directory for commands'), - PathItem.new('libdir', 'path', parameterize.call(c['libdir']), - 'the directory for libraries'), - PathItem.new('datadir', 'path', parameterize.call(c['datadir']), - 'the directory for shared data'), - PathItem.new('mandir', 'path', parameterize.call(c['mandir']), - 'the directory for man pages'), - PathItem.new('sysconfdir', 'path', parameterize.call(c['sysconfdir']), - 'the directory for system configuration files'), - PathItem.new('localstatedir', 'path', parameterize.call(c['localstatedir']), - 'the directory for local state data'), - PathItem.new('libruby', 'path', libruby, - 'the directory for ruby libraries'), - PathItem.new('librubyver', 'path', librubyver, - 'the directory for standard ruby libraries'), - PathItem.new('librubyverarch', 'path', librubyverarch, - 'the directory for standard ruby extensions'), - PathItem.new('siteruby', 'path', siteruby, - 'the directory for version-independent aux ruby libraries'), - PathItem.new('siterubyver', 'path', siterubyver, - 'the directory for aux ruby libraries'), - PathItem.new('siterubyverarch', 'path', siterubyverarch, - 'the directory for aux ruby binaries'), - PathItem.new('rbdir', 'path', '$siterubyver', - 'the directory for ruby scripts'), - PathItem.new('sodir', 'path', '$siterubyverarch', - 'the directory for ruby extentions'), - PathItem.new('rubypath', 'path', rubypath, - 'the path to set to #! line'), - ProgramItem.new('rubyprog', 'name', rubypath, - 'the ruby program using for installation'), - ProgramItem.new('makeprog', 'name', makeprog, - 'the make program to compile ruby extentions'), - SelectItem.new('shebang', 'all/ruby/never', 'ruby', - 'shebang line (#!) editing mode'), - BoolItem.new('without-ext', 'yes/no', 'no', - 'does not compile/install ruby extentions') - ] - end - private :standard_entries - - def load_multipackage_entries - multipackage_entries().each do |ent| - add ent - end - end - - def multipackage_entries - [ - PackageSelectionItem.new('with', 'name,name...', '', 'ALL', - 'package names that you want to install'), - PackageSelectionItem.new('without', 'name,name...', '', 'NONE', - 'package names that you do not want to install') - ] - end - private :multipackage_entries - - ALIASES = { - 'std-ruby' => 'librubyver', - 'stdruby' => 'librubyver', - 'rubylibdir' => 'librubyver', - 'archdir' => 'librubyverarch', - 'site-ruby-common' => 'siteruby', # For backward compatibility - 'site-ruby' => 'siterubyver', # For backward compatibility - 'bin-dir' => 'bindir', - 'bin-dir' => 'bindir', - 'rb-dir' => 'rbdir', - 'so-dir' => 'sodir', - 'data-dir' => 'datadir', - 'ruby-path' => 'rubypath', - 'ruby-prog' => 'rubyprog', - 'ruby' => 'rubyprog', - 'make-prog' => 'makeprog', - 'make' => 'makeprog' - } - - def fixup - ALIASES.each do |ali, name| - @table[ali] = @table[name] - end - @items.freeze - @table.freeze - @options_re = /\A--(#{@table.keys.join('|')})(?:=(.*))?\z/ - end - - def parse_opt(opt) - m = @options_re.match(opt) or setup_rb_error "config: unknown option #{opt}" - m.to_a[1,2] - end - - def dllext - @rbconfig['DLEXT'] - end - - def value_config?(name) - lookup(name).value? - end - - class Item - def initialize(name, template, default, desc) - @name = name.freeze - @template = template - @value = default - @default = default - @description = desc - end - - attr_reader :name - attr_reader :description - - attr_accessor :default - alias help_default default - - def help_opt - "--#{@name}=#{@template}" - end - - def value? - true - end - - def value - @value - end - - def resolve(table) - @value.gsub(%r<\$([^/]+)>) { table[$1] } - end - - def set(val) - @value = check(val) - end - - private - - def check(val) - setup_rb_error "config: --#{name} requires argument" unless val - val - end - end - - class BoolItem < Item - def config_type - 'bool' - end - - def help_opt - "--#{@name}" - end - - private - - def check(val) - return 'yes' unless val - case val - when /\Ay(es)?\z/i, /\At(rue)?\z/i then 'yes' - when /\An(o)?\z/i, /\Af(alse)\z/i then 'no' - else - setup_rb_error "config: --#{@name} accepts only yes/no for argument" - end - end - end - - class PathItem < Item - def config_type - 'path' - end - - private - - def check(path) - setup_rb_error "config: --#{@name} requires argument" unless path - path[0,1] == '$' ? path : File.expand_path(path) - end - end - - class ProgramItem < Item - def config_type - 'program' - end - end - - class SelectItem < Item - def initialize(name, selection, default, desc) - super - @ok = selection.split('/') - end - - def config_type - 'select' - end - - private - - def check(val) - unless @ok.include?(val.strip) - setup_rb_error "config: use --#{@name}=#{@template} (#{val})" - end - val.strip - end - end - - class ExecItem < Item - def initialize(name, selection, desc, &block) - super name, selection, nil, desc - @ok = selection.split('/') - @action = block - end - - def config_type - 'exec' - end - - def value? - false - end - - def resolve(table) - setup_rb_error "$#{name()} wrongly used as option value" - end - - undef set - - def evaluate(val, table) - v = val.strip.downcase - unless @ok.include?(v) - setup_rb_error "invalid option --#{@name}=#{val} (use #{@template})" - end - @action.call v, table - end - end - - class PackageSelectionItem < Item - def initialize(name, template, default, help_default, desc) - super name, template, default, desc - @help_default = help_default - end - - attr_reader :help_default - - def config_type - 'package' - end - - private - - def check(val) - unless File.dir?("packages/#{val}") - setup_rb_error "config: no such package: #{val}" - end - val - end - end - - class MetaConfigEnvironment - def initialize(config, installer) - @config = config - @installer = installer - end - - def config_names - @config.names - end - - def config?(name) - @config.key?(name) - end - - def bool_config?(name) - @config.lookup(name).config_type == 'bool' - end - - def path_config?(name) - @config.lookup(name).config_type == 'path' - end - - def value_config?(name) - @config.lookup(name).config_type != 'exec' - end - - def add_config(item) - @config.add item - end - - def add_bool_config(name, default, desc) - @config.add BoolItem.new(name, 'yes/no', default ? 'yes' : 'no', desc) - end - - def add_path_config(name, default, desc) - @config.add PathItem.new(name, 'path', default, desc) - end - - def set_config_default(name, default) - @config.lookup(name).default = default - end - - def remove_config(name) - @config.remove(name) - end - - # For only multipackage - def packages - raise '[setup.rb fatal] multi-package metaconfig API packages() called for single-package; contact application package vendor' unless @installer - @installer.packages - end - - # For only multipackage - def declare_packages(list) - raise '[setup.rb fatal] multi-package metaconfig API declare_packages() called for single-package; contact application package vendor' unless @installer - @installer.packages = list - end - end - -end # class ConfigTable - - -# This module requires: #verbose?, #no_harm? -module FileOperations - - def mkdir_p(dirname, prefix = nil) - dirname = prefix + File.expand_path(dirname) if prefix - $stderr.puts "mkdir -p #{dirname}" if verbose? - return if no_harm? - - # Does not check '/', it's too abnormal. - dirs = File.expand_path(dirname).split(%r<(?=/)>) - if /\A[a-z]:\z/i =~ dirs[0] - disk = dirs.shift - dirs[0] = disk + dirs[0] - end - dirs.each_index do |idx| - path = dirs[0..idx].join('') - Dir.mkdir path unless File.dir?(path) - end - end - - def rm_f(path) - $stderr.puts "rm -f #{path}" if verbose? - return if no_harm? - force_remove_file path - end - - def rm_rf(path) - $stderr.puts "rm -rf #{path}" if verbose? - return if no_harm? - remove_tree path - end - - def remove_tree(path) - if File.symlink?(path) - remove_file path - elsif File.dir?(path) - remove_tree0 path - else - force_remove_file path - end - end - - def remove_tree0(path) - Dir.foreach(path) do |ent| - next if ent == '.' - next if ent == '..' - entpath = "#{path}/#{ent}" - if File.symlink?(entpath) - remove_file entpath - elsif File.dir?(entpath) - remove_tree0 entpath - else - force_remove_file entpath - end - end - begin - Dir.rmdir path - rescue Errno::ENOTEMPTY - # directory may not be empty - end - end - - def move_file(src, dest) - force_remove_file dest - begin - File.rename src, dest - rescue - File.open(dest, 'wb') {|f| - f.write File.binread(src) - } - File.chmod File.stat(src).mode, dest - File.unlink src - end - end - - def force_remove_file(path) - begin - remove_file path - rescue - end - end - - def remove_file(path) - File.chmod 0777, path - File.unlink path - end - - def install(from, dest, mode, prefix = nil) - $stderr.puts "install #{from} #{dest}" if verbose? - return if no_harm? - - realdest = prefix ? prefix + File.expand_path(dest) : dest - realdest = File.join(realdest, File.basename(from)) if File.dir?(realdest) - str = File.binread(from) - if diff?(str, realdest) - verbose_off { - rm_f realdest if File.exist?(realdest) - } - File.open(realdest, 'wb') {|f| - f.write str - } - File.chmod mode, realdest - - File.open("#{objdir_root()}/InstalledFiles", 'a') {|f| - if prefix - f.puts realdest.sub(prefix, '') - else - f.puts realdest - end - } - end - end - - def diff?(new_content, path) - return true unless File.exist?(path) - new_content != File.binread(path) - end - - def command(*args) - $stderr.puts args.join(' ') if verbose? - system(*args) or raise RuntimeError, - "system(#{args.map{|a| a.inspect }.join(' ')}) failed" - end - - def ruby(*args) - command config('rubyprog'), *args - end - - def make(task = nil) - command(*[config('makeprog'), task].compact) - end - - def extdir?(dir) - File.exist?("#{dir}/MANIFEST") or File.exist?("#{dir}/extconf.rb") - end - - def files_of(dir) - Dir.open(dir) {|d| - return d.select {|ent| File.file?("#{dir}/#{ent}") } - } - end - - DIR_REJECT = %w( . .. CVS SCCS RCS CVS.adm .svn ) - - def directories_of(dir) - Dir.open(dir) {|d| - return d.select {|ent| File.dir?("#{dir}/#{ent}") } - DIR_REJECT - } - end - -end - - -# This module requires: #srcdir_root, #objdir_root, #relpath -module HookScriptAPI - - def get_config(key) - @config[key] - end - - alias config get_config - - # obsolete: use metaconfig to change configuration - def set_config(key, val) - @config[key] = val - end - - # - # srcdir/objdir (works only in the package directory) - # - - def curr_srcdir - "#{srcdir_root()}/#{relpath()}" - end - - def curr_objdir - "#{objdir_root()}/#{relpath()}" - end - - def srcfile(path) - "#{curr_srcdir()}/#{path}" - end - - def srcexist?(path) - File.exist?(srcfile(path)) - end - - def srcdirectory?(path) - File.dir?(srcfile(path)) - end - - def srcfile?(path) - File.file?(srcfile(path)) - end - - def srcentries(path = '.') - Dir.open("#{curr_srcdir()}/#{path}") {|d| - return d.to_a - %w(. ..) - } - end - - def srcfiles(path = '.') - srcentries(path).select {|fname| - File.file?(File.join(curr_srcdir(), path, fname)) - } - end - - def srcdirectories(path = '.') - srcentries(path).select {|fname| - File.dir?(File.join(curr_srcdir(), path, fname)) - } - end - -end - - -class ToplevelInstaller - - Version = '3.4.1' - Copyright = 'Copyright (c) 2000-2005 Minero Aoki' - - TASKS = [ - [ 'all', 'do config, setup, then install' ], - [ 'config', 'saves your configurations' ], - [ 'show', 'shows current configuration' ], - [ 'setup', 'compiles ruby extentions and others' ], - [ 'install', 'installs files' ], - [ 'test', 'run all tests in test/' ], - [ 'clean', "does `make clean' for each extention" ], - [ 'distclean',"does `make distclean' for each extention" ] - ] - - def ToplevelInstaller.invoke - config = ConfigTable.new(load_rbconfig()) - config.load_standard_entries - config.load_multipackage_entries if multipackage? - config.fixup - klass = (multipackage?() ? ToplevelInstallerMulti : ToplevelInstaller) - klass.new(File.dirname($0), config).invoke - end - - def ToplevelInstaller.multipackage? - File.dir?(File.dirname($0) + '/packages') - end - - def ToplevelInstaller.load_rbconfig - if arg = ARGV.detect {|arg| /\A--rbconfig=/ =~ arg } - ARGV.delete(arg) - load File.expand_path(arg.split(/=/, 2)[1]) - $".push 'rbconfig.rb' - else - require 'rbconfig' - end - ::Config::CONFIG - end - - def initialize(ardir_root, config) - @ardir = File.expand_path(ardir_root) - @config = config - # cache - @valid_task_re = nil - end - - def config(key) - @config[key] - end - - def inspect - "#<#{self.class} #{__id__()}>" - end - - def invoke - run_metaconfigs - case task = parsearg_global() - when nil, 'all' - parsearg_config - init_installers - exec_config - exec_setup - exec_install - else - case task - when 'config', 'test' - ; - when 'clean', 'distclean' - @config.load_savefile if File.exist?(@config.savefile) - else - @config.load_savefile - end - __send__ "parsearg_#{task}" - init_installers - __send__ "exec_#{task}" - end - end - - def run_metaconfigs - @config.load_script "#{@ardir}/metaconfig" - end - - def init_installers - @installer = Installer.new(@config, @ardir, File.expand_path('.')) - end - - # - # Hook Script API bases - # - - def srcdir_root - @ardir - end - - def objdir_root - '.' - end - - def relpath - '.' - end - - # - # Option Parsing - # - - def parsearg_global - while arg = ARGV.shift - case arg - when /\A\w+\z/ - setup_rb_error "invalid task: #{arg}" unless valid_task?(arg) - return arg - when '-q', '--quiet' - @config.verbose = false - when '--verbose' - @config.verbose = true - when '--help' - print_usage $stdout - exit 0 - when '--version' - puts "#{File.basename($0)} version #{Version}" - exit 0 - when '--copyright' - puts Copyright - exit 0 - else - setup_rb_error "unknown global option '#{arg}'" - end - end - nil - end - - def valid_task?(t) - valid_task_re() =~ t - end - - def valid_task_re - @valid_task_re ||= /\A(?:#{TASKS.map {|task,desc| task }.join('|')})\z/ - end - - def parsearg_no_options - unless ARGV.empty? - task = caller(0).first.slice(%r<`parsearg_(\w+)'>, 1) - setup_rb_error "#{task}: unknown options: #{ARGV.join(' ')}" - end - end - - alias parsearg_show parsearg_no_options - alias parsearg_setup parsearg_no_options - alias parsearg_test parsearg_no_options - alias parsearg_clean parsearg_no_options - alias parsearg_distclean parsearg_no_options - - def parsearg_config - evalopt = [] - set = [] - @config.config_opt = [] - while i = ARGV.shift - if /\A--?\z/ =~ i - @config.config_opt = ARGV.dup - break - end - name, value = *@config.parse_opt(i) - if @config.value_config?(name) - @config[name] = value - else - evalopt.push [name, value] - end - set.push name - end - evalopt.each do |name, value| - @config.lookup(name).evaluate value, @config - end - # Check if configuration is valid - set.each do |n| - @config[n] if @config.value_config?(n) - end - end - - def parsearg_install - @config.no_harm = false - @config.install_prefix = '' - while a = ARGV.shift - case a - when '--no-harm' - @config.no_harm = true - when /\A--prefix=/ - path = a.split(/=/, 2)[1] - path = File.expand_path(path) unless path[0,1] == '/' - @config.install_prefix = path - else - setup_rb_error "install: unknown option #{a}" - end - end - end - - def print_usage(out) - out.puts 'Typical Installation Procedure:' - out.puts " $ ruby #{File.basename $0} config" - out.puts " $ ruby #{File.basename $0} setup" - out.puts " # ruby #{File.basename $0} install (may require root privilege)" - out.puts - out.puts 'Detailed Usage:' - out.puts " ruby #{File.basename $0} " - out.puts " ruby #{File.basename $0} [] []" - - fmt = " %-24s %s\n" - out.puts - out.puts 'Global options:' - out.printf fmt, '-q,--quiet', 'suppress message outputs' - out.printf fmt, ' --verbose', 'output messages verbosely' - out.printf fmt, ' --help', 'print this message' - out.printf fmt, ' --version', 'print version and quit' - out.printf fmt, ' --copyright', 'print copyright and quit' - out.puts - out.puts 'Tasks:' - TASKS.each do |name, desc| - out.printf fmt, name, desc - end - - fmt = " %-24s %s [%s]\n" - out.puts - out.puts 'Options for CONFIG or ALL:' - @config.each do |item| - out.printf fmt, item.help_opt, item.description, item.help_default - end - out.printf fmt, '--rbconfig=path', 'rbconfig.rb to load',"running ruby's" - out.puts - out.puts 'Options for INSTALL:' - out.printf fmt, '--no-harm', 'only display what to do if given', 'off' - out.printf fmt, '--prefix=path', 'install path prefix', '' - out.puts - end - - # - # Task Handlers - # - - def exec_config - @installer.exec_config - @config.save # must be final - end - - def exec_setup - @installer.exec_setup - end - - def exec_install - @installer.exec_install - end - - def exec_test - @installer.exec_test - end - - def exec_show - @config.each do |i| - printf "%-20s %s\n", i.name, i.value if i.value? - end - end - - def exec_clean - @installer.exec_clean - end - - def exec_distclean - @installer.exec_distclean - end - -end # class ToplevelInstaller - - -class ToplevelInstallerMulti < ToplevelInstaller - - include FileOperations - - def initialize(ardir_root, config) - super - @packages = directories_of("#{@ardir}/packages") - raise 'no package exists' if @packages.empty? - @root_installer = Installer.new(@config, @ardir, File.expand_path('.')) - end - - def run_metaconfigs - @config.load_script "#{@ardir}/metaconfig", self - @packages.each do |name| - @config.load_script "#{@ardir}/packages/#{name}/metaconfig" - end - end - - attr_reader :packages - - def packages=(list) - raise 'package list is empty' if list.empty? - list.each do |name| - raise "directory packages/#{name} does not exist"\ - unless File.dir?("#{@ardir}/packages/#{name}") - end - @packages = list - end - - def init_installers - @installers = {} - @packages.each do |pack| - @installers[pack] = Installer.new(@config, - "#{@ardir}/packages/#{pack}", - "packages/#{pack}") - end - with = extract_selection(config('with')) - without = extract_selection(config('without')) - @selected = @installers.keys.select {|name| - (with.empty? or with.include?(name)) \ - and not without.include?(name) - } - end - - def extract_selection(list) - a = list.split(/,/) - a.each do |name| - setup_rb_error "no such package: #{name}" unless @installers.key?(name) - end - a - end - - def print_usage(f) - super - f.puts 'Inluded packages:' - f.puts ' ' + @packages.sort.join(' ') - f.puts - end - - # - # Task Handlers - # - - def exec_config - run_hook 'pre-config' - each_selected_installers {|inst| inst.exec_config } - run_hook 'post-config' - @config.save # must be final - end - - def exec_setup - run_hook 'pre-setup' - each_selected_installers {|inst| inst.exec_setup } - run_hook 'post-setup' - end - - def exec_install - run_hook 'pre-install' - each_selected_installers {|inst| inst.exec_install } - run_hook 'post-install' - end - - def exec_test - run_hook 'pre-test' - each_selected_installers {|inst| inst.exec_test } - run_hook 'post-test' - end - - def exec_clean - rm_f @config.savefile - run_hook 'pre-clean' - each_selected_installers {|inst| inst.exec_clean } - run_hook 'post-clean' - end - - def exec_distclean - rm_f @config.savefile - run_hook 'pre-distclean' - each_selected_installers {|inst| inst.exec_distclean } - run_hook 'post-distclean' - end - - # - # lib - # - - def each_selected_installers - Dir.mkdir 'packages' unless File.dir?('packages') - @selected.each do |pack| - $stderr.puts "Processing the package `#{pack}' ..." if verbose? - Dir.mkdir "packages/#{pack}" unless File.dir?("packages/#{pack}") - Dir.chdir "packages/#{pack}" - yield @installers[pack] - Dir.chdir '../..' - end - end - - def run_hook(id) - @root_installer.run_hook id - end - - # module FileOperations requires this - def verbose? - @config.verbose? - end - - # module FileOperations requires this - def no_harm? - @config.no_harm? - end - -end # class ToplevelInstallerMulti - - -class Installer - - FILETYPES = %w( bin lib ext data conf man ) - - include FileOperations - include HookScriptAPI - - def initialize(config, srcroot, objroot) - @config = config - @srcdir = File.expand_path(srcroot) - @objdir = File.expand_path(objroot) - @currdir = '.' - end - - def inspect - "#<#{self.class} #{File.basename(@srcdir)}>" - end - - def noop(rel) - end - - # - # Hook Script API base methods - # - - def srcdir_root - @srcdir - end - - def objdir_root - @objdir - end - - def relpath - @currdir - end - - # - # Config Access - # - - # module FileOperations requires this - def verbose? - @config.verbose? - end - - # module FileOperations requires this - def no_harm? - @config.no_harm? - end - - def verbose_off - begin - save, @config.verbose = @config.verbose?, false - yield - ensure - @config.verbose = save - end - end - - # - # TASK config - # - - def exec_config - exec_task_traverse 'config' - end - - alias config_dir_bin noop - alias config_dir_lib noop - - def config_dir_ext(rel) - extconf if extdir?(curr_srcdir()) - end - - alias config_dir_data noop - alias config_dir_conf noop - alias config_dir_man noop - - def extconf - ruby "#{curr_srcdir()}/extconf.rb", *@config.config_opt - end - - # - # TASK setup - # - - def exec_setup - exec_task_traverse 'setup' - end - - def setup_dir_bin(rel) - files_of(curr_srcdir()).each do |fname| - update_shebang_line "#{curr_srcdir()}/#{fname}" - end - end - - alias setup_dir_lib noop - - def setup_dir_ext(rel) - make if extdir?(curr_srcdir()) - end - - alias setup_dir_data noop - alias setup_dir_conf noop - alias setup_dir_man noop - - def update_shebang_line(path) - return if no_harm? - return if config('shebang') == 'never' - old = Shebang.load(path) - if old - $stderr.puts "warning: #{path}: Shebang line includes too many args. It is not portable and your program may not work." if old.args.size > 1 - new = new_shebang(old) - return if new.to_s == old.to_s - else - return unless config('shebang') == 'all' - new = Shebang.new(config('rubypath')) - end - $stderr.puts "updating shebang: #{File.basename(path)}" if verbose? - open_atomic_writer(path) {|output| - File.open(path, 'rb') {|f| - f.gets if old # discard - output.puts new.to_s - output.print f.read - } - } - end - - def new_shebang(old) - if /\Aruby/ =~ File.basename(old.cmd) - Shebang.new(config('rubypath'), old.args) - elsif File.basename(old.cmd) == 'env' and old.args.first == 'ruby' - Shebang.new(config('rubypath'), old.args[1..-1]) - else - return old unless config('shebang') == 'all' - Shebang.new(config('rubypath')) - end - end - - def open_atomic_writer(path, &block) - tmpfile = File.basename(path) + '.tmp' - begin - File.open(tmpfile, 'wb', &block) - File.rename tmpfile, File.basename(path) - ensure - File.unlink tmpfile if File.exist?(tmpfile) - end - end - - class Shebang - def Shebang.load(path) - line = nil - File.open(path) {|f| - line = f.gets - } - return nil unless /\A#!/ =~ line - parse(line) - end - - def Shebang.parse(line) - cmd, *args = *line.strip.sub(/\A\#!/, '').split(' ') - new(cmd, args) - end - - def initialize(cmd, args = []) - @cmd = cmd - @args = args - end - - attr_reader :cmd - attr_reader :args - - def to_s - "#! #{@cmd}" + (@args.empty? ? '' : " #{@args.join(' ')}") - end - end - - # - # TASK install - # - - def exec_install - rm_f 'InstalledFiles' - exec_task_traverse 'install' - end - - def install_dir_bin(rel) - install_files targetfiles(), "#{config('bindir')}/#{rel}", 0755 - end - - def install_dir_lib(rel) - install_files libfiles(), "#{config('rbdir')}/#{rel}", 0644 - end - - def install_dir_ext(rel) - return unless extdir?(curr_srcdir()) - install_files rubyextentions('.'), - "#{config('sodir')}/#{File.dirname(rel)}", - 0555 - end - - def install_dir_data(rel) - install_files targetfiles(), "#{config('datadir')}/#{rel}", 0644 - end - - def install_dir_conf(rel) - # FIXME: should not remove current config files - # (rename previous file to .old/.org) - install_files targetfiles(), "#{config('sysconfdir')}/#{rel}", 0644 - end - - def install_dir_man(rel) - install_files targetfiles(), "#{config('mandir')}/#{rel}", 0644 - end - - def install_files(list, dest, mode) - mkdir_p dest, @config.install_prefix - list.each do |fname| - install fname, dest, mode, @config.install_prefix - end - end - - def libfiles - glob_reject(%w(*.y *.output), targetfiles()) - end - - def rubyextentions(dir) - ents = glob_select("*.#{@config.dllext}", targetfiles()) - if ents.empty? - setup_rb_error "no ruby extention exists: 'ruby #{$0} setup' first" - end - ents - end - - def targetfiles - mapdir(existfiles() - hookfiles()) - end - - def mapdir(ents) - ents.map {|ent| - if File.exist?(ent) - then ent # objdir - else "#{curr_srcdir()}/#{ent}" # srcdir - end - } - end - - # picked up many entries from cvs-1.11.1/src/ignore.c - JUNK_FILES = %w( - core RCSLOG tags TAGS .make.state - .nse_depinfo #* .#* cvslog.* ,* .del-* *.olb - *~ *.old *.bak *.BAK *.orig *.rej _$* *$ - - *.org *.in .* - ) - - def existfiles - glob_reject(JUNK_FILES, (files_of(curr_srcdir()) | files_of('.'))) - end - - def hookfiles - %w( pre-%s post-%s pre-%s.rb post-%s.rb ).map {|fmt| - %w( config setup install clean ).map {|t| sprintf(fmt, t) } - }.flatten - end - - def glob_select(pat, ents) - re = globs2re([pat]) - ents.select {|ent| re =~ ent } - end - - def glob_reject(pats, ents) - re = globs2re(pats) - ents.reject {|ent| re =~ ent } - end - - GLOB2REGEX = { - '.' => '\.', - '$' => '\$', - '#' => '\#', - '*' => '.*' - } - - def globs2re(pats) - /\A(?:#{ - pats.map {|pat| pat.gsub(/[\.\$\#\*]/) {|ch| GLOB2REGEX[ch] } }.join('|') - })\z/ - end - - # - # TASK test - # - - TESTDIR = 'test' - - def exec_test - unless File.directory?('test') - $stderr.puts 'no test in this package' if verbose? - return - end - $stderr.puts 'Running tests...' if verbose? - begin - require 'test/unit' - rescue LoadError - setup_rb_error 'test/unit cannot loaded. You need Ruby 1.8 or later to invoke this task.' - end - runner = Test::Unit::AutoRunner.new(true) - runner.to_run << TESTDIR - runner.run - end - - # - # TASK clean - # - - def exec_clean - exec_task_traverse 'clean' - rm_f @config.savefile - rm_f 'InstalledFiles' - end - - alias clean_dir_bin noop - alias clean_dir_lib noop - alias clean_dir_data noop - alias clean_dir_conf noop - alias clean_dir_man noop - - def clean_dir_ext(rel) - return unless extdir?(curr_srcdir()) - make 'clean' if File.file?('Makefile') - end - - # - # TASK distclean - # - - def exec_distclean - exec_task_traverse 'distclean' - rm_f @config.savefile - rm_f 'InstalledFiles' - end - - alias distclean_dir_bin noop - alias distclean_dir_lib noop - - def distclean_dir_ext(rel) - return unless extdir?(curr_srcdir()) - make 'distclean' if File.file?('Makefile') - end - - alias distclean_dir_data noop - alias distclean_dir_conf noop - alias distclean_dir_man noop - - # - # Traversing - # - - def exec_task_traverse(task) - run_hook "pre-#{task}" - FILETYPES.each do |type| - if type == 'ext' and config('without-ext') == 'yes' - $stderr.puts 'skipping ext/* by user option' if verbose? - next - end - traverse task, type, "#{task}_dir_#{type}" - end - run_hook "post-#{task}" - end - - def traverse(task, rel, mid) - dive_into(rel) { - run_hook "pre-#{task}" - __send__ mid, rel.sub(%r[\A.*?(?:/|\z)], '') - directories_of(curr_srcdir()).each do |d| - traverse task, "#{rel}/#{d}", mid - end - run_hook "post-#{task}" - } - end - - def dive_into(rel) - return unless File.dir?("#{@srcdir}/#{rel}") - - dir = File.basename(rel) - Dir.mkdir dir unless File.dir?(dir) - prevdir = Dir.pwd - Dir.chdir dir - $stderr.puts '---> ' + rel if verbose? - @currdir = rel - yield - Dir.chdir prevdir - $stderr.puts '<--- ' + rel if verbose? - @currdir = File.dirname(rel) - end - - def run_hook(id) - path = [ "#{curr_srcdir()}/#{id}", - "#{curr_srcdir()}/#{id}.rb" ].detect {|cand| File.file?(cand) } - return unless path - begin - instance_eval File.read(path), path, 1 - rescue - raise if $DEBUG - setup_rb_error "hook #{path} failed:\n" + $!.message - end - end - -end # class Installer - - -class SetupError < StandardError; end - -def setup_rb_error(msg) - raise SetupError, msg -end - -if $0 == __FILE__ - begin - ToplevelInstaller.invoke - rescue SetupError - raise if $DEBUG - $stderr.puts $!.message - $stderr.puts "Try 'ruby #{$0} --help' for detailed usage." - exit 1 - end -end diff --git a/vendor/gems/net-ssh-2.0.15/support/arcfour_check.rb b/vendor/gems/net-ssh-2.0.15/support/arcfour_check.rb deleted file mode 100644 index a823a1f15..000000000 --- a/vendor/gems/net-ssh-2.0.15/support/arcfour_check.rb +++ /dev/null @@ -1,20 +0,0 @@ - -require 'net/ssh' - -# ARCFOUR CHECK -# -# Usage: -# $ ruby support/arcfour_check.rb -# -# Expected Output: -# arcfour128: [16, 8] OpenSSL::Cipher::Cipher -# arcfour256: [32, 8] OpenSSL::Cipher::Cipher -# arcfour512: [64, 8] OpenSSL::Cipher::Cipher - -[['arcfour128', 16], ['arcfour256', 32], ['arcfour512', 64]].each do |cipher| - print "#{cipher[0]}: " - a = Net::SSH::Transport::CipherFactory.get_lengths(cipher[0]) - b = Net::SSH::Transport::CipherFactory.get(cipher[0], :key => ([].fill('x', 0, cipher[1]).join)) - puts "#{a} #{b.class}" -end - diff --git a/vendor/gems/net-ssh-2.0.15/test/authentication/methods/common.rb b/vendor/gems/net-ssh-2.0.15/test/authentication/methods/common.rb deleted file mode 100644 index 735836d30..000000000 --- a/vendor/gems/net-ssh-2.0.15/test/authentication/methods/common.rb +++ /dev/null @@ -1,28 +0,0 @@ -module Authentication; module Methods - - module Common - include Net::SSH::Authentication::Constants - - private - - def socket(options={}) - @socket ||= stub("socket", :client_name => "me.ssh.test") - end - - def transport(options={}) - @transport ||= MockTransport.new(options.merge(:socket => socket)) - end - - def session(options={}) - @session ||= begin - sess = stub("auth-session", :logger => nil, :transport => transport(options)) - def sess.next_message - transport.next_message - end - sess - end - end - - end - -end; end \ No newline at end of file diff --git a/vendor/gems/net-ssh-2.0.15/test/authentication/methods/test_abstract.rb b/vendor/gems/net-ssh-2.0.15/test/authentication/methods/test_abstract.rb deleted file mode 100644 index f0a18d55e..000000000 --- a/vendor/gems/net-ssh-2.0.15/test/authentication/methods/test_abstract.rb +++ /dev/null @@ -1,51 +0,0 @@ -require 'common' -require 'authentication/methods/common' -require 'net/ssh/authentication/methods/abstract' - -module Authentication; module Methods - - class TestAbstract < Test::Unit::TestCase - include Common - - def test_constructor_should_set_defaults - assert_nil subject.key_manager - end - - def test_constructor_should_honor_options - assert_equal :manager, subject(:key_manager => :manager).key_manager - end - - def test_session_id_should_query_session_id_from_key_exchange - transport.stubs(:algorithms).returns(stub("algorithms", :session_id => "abcxyz123")) - assert_equal "abcxyz123", subject.session_id - end - - def test_send_message_should_delegate_to_transport - transport.expects(:send_message).with("abcxyz123") - subject.send_message("abcxyz123") - end - - def test_userauth_request_should_build_well_formed_userauth_packet - packet = subject.userauth_request("jamis", "ssh-connection", "password") - assert_equal "\062\0\0\0\005jamis\0\0\0\016ssh-connection\0\0\0\010password", packet.to_s - end - - def test_userauth_request_should_translate_extra_booleans_onto_end - packet = subject.userauth_request("jamis", "ssh-connection", "password", true, false) - assert_equal "\062\0\0\0\005jamis\0\0\0\016ssh-connection\0\0\0\010password\1\0", packet.to_s - end - - def test_userauth_request_should_translate_extra_strings_onto_end - packet = subject.userauth_request("jamis", "ssh-connection", "password", "foo", "bar") - assert_equal "\062\0\0\0\005jamis\0\0\0\016ssh-connection\0\0\0\010password\0\0\0\3foo\0\0\0\3bar", packet.to_s - end - - private - - def subject(options={}) - @subject ||= Net::SSH::Authentication::Methods::Abstract.new(session(options), options) - end - - end - -end; end \ No newline at end of file diff --git a/vendor/gems/net-ssh-2.0.15/test/authentication/methods/test_hostbased.rb b/vendor/gems/net-ssh-2.0.15/test/authentication/methods/test_hostbased.rb deleted file mode 100644 index 281c86d99..000000000 --- a/vendor/gems/net-ssh-2.0.15/test/authentication/methods/test_hostbased.rb +++ /dev/null @@ -1,114 +0,0 @@ -require 'common' -require 'net/ssh/authentication/methods/hostbased' -require 'authentication/methods/common' - -module Authentication; module Methods - - class TestHostbased < Test::Unit::TestCase - include Common - - def test_authenticate_should_return_false_when_no_key_manager_has_been_set - assert_equal false, subject(:key_manager => nil).authenticate("ssh-connection", "jamis") - end - - def test_authenticate_should_return_false_when_key_manager_has_no_keys - assert_equal false, subject(:keys => []).authenticate("ssh-connection", "jamis") - end - - def test_authenticate_should_return_false_if_no_keys_can_authenticate - ENV.stubs(:[]).with('USER').returns(nil) - key_manager.expects(:sign).with(&signature_parameters(keys.first)).returns("sig-one") - key_manager.expects(:sign).with(&signature_parameters(keys.last)).returns("sig-two") - - transport.expect do |t, packet| - assert_equal USERAUTH_REQUEST, packet.type - assert verify_userauth_request_packet(packet, keys.first) - assert_equal "sig-one", packet.read_string - t.return(USERAUTH_FAILURE, :string, "hostbased,password") - - t.expect do |t2, packet2| - assert_equal USERAUTH_REQUEST, packet2.type - assert verify_userauth_request_packet(packet2, keys.last) - assert_equal "sig-two", packet2.read_string - t2.return(USERAUTH_FAILURE, :string, "hostbased,password") - end - end - - assert_equal false, subject.authenticate("ssh-connection", "jamis") - end - - def test_authenticate_should_return_true_if_any_key_can_authenticate - ENV.stubs(:[]).with('USER').returns(nil) - key_manager.expects(:sign).with(&signature_parameters(keys.first)).returns("sig-one") - - transport.expect do |t, packet| - assert_equal USERAUTH_REQUEST, packet.type - assert verify_userauth_request_packet(packet, keys.first) - assert_equal "sig-one", packet.read_string - t.return(USERAUTH_SUCCESS) - end - - assert subject.authenticate("ssh-connection", "jamis") - end - - private - - def signature_parameters(key) - Proc.new do |given_key, data| - next false unless given_key.to_blob == key.to_blob - buffer = Net::SSH::Buffer.new(data) - buffer.read_string == "abcxyz123" && # session-id - buffer.read_byte == USERAUTH_REQUEST && # type - verify_userauth_request_packet(buffer, key) - end - end - - def verify_userauth_request_packet(packet, key) - packet.read_string == "jamis" && # user-name - packet.read_string == "ssh-connection" && # next service - packet.read_string == "hostbased" && # auth-method - packet.read_string == key.ssh_type && # key type - packet.read_buffer.read_key.to_blob == key.to_blob && # key - packet.read_string == "me.ssh.test." && # client hostname - packet.read_string == "jamis" # client username - end - - @@keys = nil - def keys - @@keys ||= [OpenSSL::PKey::RSA.new(32), OpenSSL::PKey::DSA.new(32)] - end - - def key_manager(options={}) - @key_manager ||= begin - manager = stub("key_manager") - manager.stubs(:each_identity).multiple_yields(*(options[:keys] || keys)) - manager - end - end - - def subject(options={}) - options[:key_manager] = key_manager(options) unless options.key?(:key_manager) - @subject ||= Net::SSH::Authentication::Methods::Hostbased.new(session(options), options) - end - - def socket(options={}) - @socket ||= stub("socket", :client_name => "me.ssh.test") - end - - def transport(options={}) - @transport ||= MockTransport.new(options.merge(:socket => socket)) - end - - def session(options={}) - @session ||= begin - sess = stub("auth-session", :logger => nil, :transport => transport(options)) - def sess.next_message - transport.next_message - end - sess - end - end - - end - -end; end diff --git a/vendor/gems/net-ssh-2.0.15/test/authentication/methods/test_keyboard_interactive.rb b/vendor/gems/net-ssh-2.0.15/test/authentication/methods/test_keyboard_interactive.rb deleted file mode 100644 index b0922636b..000000000 --- a/vendor/gems/net-ssh-2.0.15/test/authentication/methods/test_keyboard_interactive.rb +++ /dev/null @@ -1,98 +0,0 @@ -require 'common' -require 'net/ssh/authentication/methods/keyboard_interactive' -require 'authentication/methods/common' - -module Authentication; module Methods - - class TestKeyboardInteractive < Test::Unit::TestCase - include Common - - USERAUTH_INFO_REQUEST = 60 - USERAUTH_INFO_RESPONSE = 61 - - def test_authenticate_should_be_false_when_server_does_not_support_this_method - transport.expect do |t,packet| - assert_equal USERAUTH_REQUEST, packet.type - assert_equal "jamis", packet.read_string - assert_equal "ssh-connection", packet.read_string - assert_equal "keyboard-interactive", packet.read_string - assert_equal "", packet.read_string # language tags - assert_equal "", packet.read_string # submethods - - t.return(USERAUTH_FAILURE, :string, "password") - end - - assert_equal false, subject.authenticate("ssh-connection", "jamis") - end - - def test_authenticate_should_be_false_if_given_password_is_not_accepted - transport.expect do |t,packet| - assert_equal USERAUTH_REQUEST, packet.type - t.return(USERAUTH_INFO_REQUEST, :string, "", :string, "", :string, "", :long, 1, :string, "Password:", :bool, false) - t.expect do |t2,packet2| - assert_equal USERAUTH_INFO_RESPONSE, packet2.type - assert_equal 1, packet2.read_long - assert_equal "the-password", packet2.read_string - t2.return(USERAUTH_FAILURE, :string, "publickey") - end - end - - assert_equal false, subject.authenticate("ssh-connection", "jamis", "the-password") - end - - def test_authenticate_should_be_true_if_given_password_is_accepted - transport.expect do |t,packet| - assert_equal USERAUTH_REQUEST, packet.type - t.return(USERAUTH_INFO_REQUEST, :string, "", :string, "", :string, "", :long, 1, :string, "Password:", :bool, false) - t.expect do |t2,packet2| - assert_equal USERAUTH_INFO_RESPONSE, packet2.type - t2.return(USERAUTH_SUCCESS) - end - end - - assert subject.authenticate("ssh-connection", "jamis", "the-password") - end - - def test_authenticate_should_duplicate_password_as_needed_to_fill_request - transport.expect do |t,packet| - assert_equal USERAUTH_REQUEST, packet.type - t.return(USERAUTH_INFO_REQUEST, :string, "", :string, "", :string, "", :long, 2, :string, "Password:", :bool, false, :string, "Again:", :bool, false) - t.expect do |t2,packet2| - assert_equal USERAUTH_INFO_RESPONSE, packet2.type - assert_equal 2, packet2.read_long - assert_equal "the-password", packet2.read_string - assert_equal "the-password", packet2.read_string - t2.return(USERAUTH_SUCCESS) - end - end - - assert subject.authenticate("ssh-connection", "jamis", "the-password") - end - - def test_authenticate_should_prompt_for_input_when_password_is_not_given - subject.expects(:prompt).with("Name:", true).returns("name") - subject.expects(:prompt).with("Password:", false).returns("password") - - transport.expect do |t,packet| - assert_equal USERAUTH_REQUEST, packet.type - t.return(USERAUTH_INFO_REQUEST, :string, "", :string, "", :string, "", :long, 2, :string, "Name:", :bool, true, :string, "Password:", :bool, false) - t.expect do |t2,packet2| - assert_equal USERAUTH_INFO_RESPONSE, packet2.type - assert_equal 2, packet2.read_long - assert_equal "name", packet2.read_string - assert_equal "password", packet2.read_string - t2.return(USERAUTH_SUCCESS) - end - end - - assert subject.authenticate("ssh-connection", "jamis", nil) - end - - private - - def subject(options={}) - @subject ||= Net::SSH::Authentication::Methods::KeyboardInteractive.new(session(options), options) - end - end - -end; end \ No newline at end of file diff --git a/vendor/gems/net-ssh-2.0.15/test/authentication/methods/test_password.rb b/vendor/gems/net-ssh-2.0.15/test/authentication/methods/test_password.rb deleted file mode 100644 index 52f4196ea..000000000 --- a/vendor/gems/net-ssh-2.0.15/test/authentication/methods/test_password.rb +++ /dev/null @@ -1,50 +0,0 @@ -require 'common' -require 'net/ssh/authentication/methods/password' -require 'authentication/methods/common' - -module Authentication; module Methods - - class TestPassword < Test::Unit::TestCase - include Common - - def test_authenticate_when_password_is_unacceptible_should_return_false - transport.expect do |t,packet| - assert_equal USERAUTH_REQUEST, packet.type - assert_equal "jamis", packet.read_string - assert_equal "ssh-connection", packet.read_string - assert_equal "password", packet.read_string - assert_equal false, packet.read_bool - assert_equal "the-password", packet.read_string - - t.return(USERAUTH_FAILURE, :string, "publickey") - end - - assert !subject.authenticate("ssh-connection", "jamis", "the-password") - end - - def test_authenticate_when_password_is_acceptible_should_return_true - transport.expect do |t,packet| - assert_equal USERAUTH_REQUEST, packet.type - t.return(USERAUTH_SUCCESS) - end - - assert subject.authenticate("ssh-connection", "jamis", "the-password") - end - - def test_authenticate_should_return_false_if_password_change_request_is_received - transport.expect do |t,packet| - assert_equal USERAUTH_REQUEST, packet.type - t.return(USERAUTH_PASSWD_CHANGEREQ, :string, "Change your password:", :string, "") - end - - assert !subject.authenticate("ssh-connection", "jamis", "the-password") - end - - private - - def subject(options={}) - @subject ||= Net::SSH::Authentication::Methods::Password.new(session(options), options) - end - end - -end; end diff --git a/vendor/gems/net-ssh-2.0.15/test/authentication/methods/test_publickey.rb b/vendor/gems/net-ssh-2.0.15/test/authentication/methods/test_publickey.rb deleted file mode 100644 index f4f544f94..000000000 --- a/vendor/gems/net-ssh-2.0.15/test/authentication/methods/test_publickey.rb +++ /dev/null @@ -1,127 +0,0 @@ -require 'common' -require 'net/ssh/authentication/methods/publickey' -require 'authentication/methods/common' - -module Authentication; module Methods - - class TestPublickey < Test::Unit::TestCase - include Common - - def test_authenticate_should_return_false_when_no_key_manager_has_been_set - assert_equal false, subject(:key_manager => nil).authenticate("ssh-connection", "jamis") - end - - def test_authenticate_should_return_false_when_key_manager_has_no_keys - assert_equal false, subject(:keys => []).authenticate("ssh-connection", "jamis") - end - - def test_authenticate_should_return_false_if_no_keys_can_authenticate - transport.expect do |t, packet| - assert_equal USERAUTH_REQUEST, packet.type - assert verify_userauth_request_packet(packet, keys.first, false) - t.return(USERAUTH_FAILURE, :string, "hostbased,password") - - t.expect do |t2, packet2| - assert_equal USERAUTH_REQUEST, packet2.type - assert verify_userauth_request_packet(packet2, keys.last, false) - t2.return(USERAUTH_FAILURE, :string, "hostbased,password") - end - end - - assert_equal false, subject.authenticate("ssh-connection", "jamis") - end - - def test_authenticate_should_return_false_if_signature_exchange_fails - key_manager.expects(:sign).with(&signature_parameters(keys.first)).returns("sig-one") - key_manager.expects(:sign).with(&signature_parameters(keys.last)).returns("sig-two") - - transport.expect do |t, packet| - assert_equal USERAUTH_REQUEST, packet.type - assert verify_userauth_request_packet(packet, keys.first, false) - t.return(USERAUTH_PK_OK, :string, keys.first.ssh_type, :string, Net::SSH::Buffer.from(:key, keys.first)) - - t.expect do |t2,packet2| - assert_equal USERAUTH_REQUEST, packet2.type - assert verify_userauth_request_packet(packet2, keys.first, true) - assert_equal "sig-one", packet2.read_string - t2.return(USERAUTH_FAILURE, :string, "hostbased,password") - - t2.expect do |t3, packet3| - assert_equal USERAUTH_REQUEST, packet3.type - assert verify_userauth_request_packet(packet3, keys.last, false) - t3.return(USERAUTH_PK_OK, :string, keys.last.ssh_type, :string, Net::SSH::Buffer.from(:key, keys.last)) - - t3.expect do |t4,packet4| - assert_equal USERAUTH_REQUEST, packet4.type - assert verify_userauth_request_packet(packet4, keys.last, true) - assert_equal "sig-two", packet4.read_string - t4.return(USERAUTH_FAILURE, :string, "hostbased,password") - end - end - end - end - - assert !subject.authenticate("ssh-connection", "jamis") - end - - def test_authenticate_should_return_true_if_any_key_can_authenticate - key_manager.expects(:sign).with(&signature_parameters(keys.first)).returns("sig-one") - - transport.expect do |t, packet| - assert_equal USERAUTH_REQUEST, packet.type - assert verify_userauth_request_packet(packet, keys.first, false) - t.return(USERAUTH_PK_OK, :string, keys.first.ssh_type, :string, Net::SSH::Buffer.from(:key, keys.first)) - - t.expect do |t2,packet2| - assert_equal USERAUTH_REQUEST, packet2.type - assert verify_userauth_request_packet(packet2, keys.first, true) - assert_equal "sig-one", packet2.read_string - t2.return(USERAUTH_SUCCESS) - end - end - - assert subject.authenticate("ssh-connection", "jamis") - end - - private - - def signature_parameters(key) - Proc.new do |given_key, data| - next false unless given_key.to_blob == key.to_blob - buffer = Net::SSH::Buffer.new(data) - buffer.read_string == "abcxyz123" && # session-id - buffer.read_byte == USERAUTH_REQUEST && # type - verify_userauth_request_packet(buffer, key, true) - end - end - - def verify_userauth_request_packet(packet, key, has_sig) - packet.read_string == "jamis" && # user-name - packet.read_string == "ssh-connection" && # next service - packet.read_string == "publickey" && # auth-method - packet.read_bool == has_sig && # whether a signature is appended - packet.read_string == key.ssh_type && # ssh key type - packet.read_buffer.read_key.to_blob == key.to_blob # key - end - - @@keys = nil - def keys - @@keys ||= [OpenSSL::PKey::RSA.new(32), OpenSSL::PKey::DSA.new(32)] - end - - def key_manager(options={}) - @key_manager ||= begin - manager = stub("key_manager") - manager.stubs(:each_identity).multiple_yields(*(options[:keys] || keys)) - manager - end - end - - def subject(options={}) - options[:key_manager] = key_manager(options) unless options.key?(:key_manager) - @subject ||= Net::SSH::Authentication::Methods::Publickey.new(session(options), options) - end - - end - -end; end diff --git a/vendor/gems/net-ssh-2.0.15/test/authentication/test_agent.rb b/vendor/gems/net-ssh-2.0.15/test/authentication/test_agent.rb deleted file mode 100644 index 248a3d793..000000000 --- a/vendor/gems/net-ssh-2.0.15/test/authentication/test_agent.rb +++ /dev/null @@ -1,205 +0,0 @@ -require 'common' -require 'net/ssh/authentication/agent' - -module Authentication - - class TestAgent < Test::Unit::TestCase - - SSH2_AGENT_REQUEST_VERSION = 1 - SSH2_AGENT_REQUEST_IDENTITIES = 11 - SSH2_AGENT_IDENTITIES_ANSWER = 12 - SSH2_AGENT_SIGN_REQUEST = 13 - SSH2_AGENT_SIGN_RESPONSE = 14 - SSH2_AGENT_FAILURE = 30 - SSH2_AGENT_VERSION_RESPONSE = 103 - - SSH_COM_AGENT2_FAILURE = 102 - - SSH_AGENT_REQUEST_RSA_IDENTITIES = 1 - SSH_AGENT_RSA_IDENTITIES_ANSWER = 2 - SSH_AGENT_FAILURE = 5 - - def setup - @original, ENV['SSH_AUTH_SOCK'] = ENV['SSH_AUTH_SOCK'], "/path/to/ssh.agent.sock" - end - - def teardown - ENV['SSH_AUTH_SOCK'] = @original - end - - def test_connect_should_use_agent_factory_to_determine_connection_type - factory.expects(:open).with("/path/to/ssh.agent.sock").returns(socket) - agent(false).connect! - end - - def test_connect_should_raise_error_if_connection_could_not_be_established - factory.expects(:open).raises(SocketError) - assert_raises(Net::SSH::Authentication::AgentNotAvailable) { agent(false).connect! } - end - - def test_negotiate_should_raise_error_if_ssh2_agent_response_recieved - socket.expect do |s, type, buffer| - assert_equal SSH2_AGENT_REQUEST_VERSION, type - assert_equal Net::SSH::Transport::ServerVersion::PROTO_VERSION, buffer.read_string - s.return(SSH2_AGENT_VERSION_RESPONSE) - end - assert_raises(NotImplementedError) { agent.negotiate! } - end - - def test_negotiate_should_raise_error_if_response_was_unexpected - socket.expect do |s, type, buffer| - assert_equal SSH2_AGENT_REQUEST_VERSION, type - s.return(255) - end - assert_raises(Net::SSH::Authentication::AgentError) { agent.negotiate! } - end - - def test_negotiate_should_be_successful_with_expected_response - socket.expect do |s, type, buffer| - assert_equal SSH2_AGENT_REQUEST_VERSION, type - s.return(SSH_AGENT_RSA_IDENTITIES_ANSWER) - end - assert_nothing_raised { agent(:connect).negotiate! } - end - - def test_identities_should_fail_if_SSH_AGENT_FAILURE_recieved - socket.expect do |s, type, buffer| - assert_equal SSH2_AGENT_REQUEST_IDENTITIES, type - s.return(SSH_AGENT_FAILURE) - end - assert_raises(Net::SSH::Authentication::AgentError) { agent.identities } - end - - def test_identities_should_fail_if_SSH2_AGENT_FAILURE_recieved - socket.expect do |s, type, buffer| - assert_equal SSH2_AGENT_REQUEST_IDENTITIES, type - s.return(SSH2_AGENT_FAILURE) - end - assert_raises(Net::SSH::Authentication::AgentError) { agent.identities } - end - - def test_identities_should_fail_if_SSH_COM_AGENT2_FAILURE_recieved - socket.expect do |s, type, buffer| - assert_equal SSH2_AGENT_REQUEST_IDENTITIES, type - s.return(SSH_COM_AGENT2_FAILURE) - end - assert_raises(Net::SSH::Authentication::AgentError) { agent.identities } - end - - def test_identities_should_fail_if_response_is_not_SSH2_AGENT_IDENTITIES_ANSWER - socket.expect do |s, type, buffer| - assert_equal SSH2_AGENT_REQUEST_IDENTITIES, type - s.return(255) - end - assert_raises(Net::SSH::Authentication::AgentError) { agent.identities } - end - - def test_identities_should_augment_identities_with_comment_field - key1 = key - key2 = OpenSSL::PKey::DSA.new(32) - - socket.expect do |s, type, buffer| - assert_equal SSH2_AGENT_REQUEST_IDENTITIES, type - s.return(SSH2_AGENT_IDENTITIES_ANSWER, :long, 2, :string, Net::SSH::Buffer.from(:key, key1), :string, "My favorite key", :string, Net::SSH::Buffer.from(:key, key2), :string, "Okay, but not the best") - end - - result = agent.identities - assert_equal key1.to_blob, result.first.to_blob - assert_equal key2.to_blob, result.last.to_blob - assert_equal "My favorite key", result.first.comment - assert_equal "Okay, but not the best", result.last.comment - end - - def test_close_should_close_socket - socket.expects(:close) - agent.close - end - - def test_sign_should_fail_if_response_is_SSH_AGENT_FAILURE - socket.expect { |s,| s.return(SSH_AGENT_FAILURE) } - assert_raises(Net::SSH::Authentication::AgentError) { agent.sign(key, "hello world") } - end - - def test_sign_should_fail_if_response_is_SSH2_AGENT_FAILURE - socket.expect { |s,| s.return(SSH2_AGENT_FAILURE) } - assert_raises(Net::SSH::Authentication::AgentError) { agent.sign(key, "hello world") } - end - - def test_sign_should_fail_if_response_is_SSH_COM_AGENT2_FAILURE - socket.expect { |s,| s.return(SSH_COM_AGENT2_FAILURE) } - assert_raises(Net::SSH::Authentication::AgentError) { agent.sign(key, "hello world") } - end - - def test_sign_should_fail_if_response_is_not_SSH2_AGENT_SIGN_RESPONSE - socket.expect { |s,| s.return(255) } - assert_raises(Net::SSH::Authentication::AgentError) { agent.sign(key, "hello world") } - end - - def test_sign_should_return_signed_data_from_agent - socket.expect do |s,type,buffer| - assert_equal SSH2_AGENT_SIGN_REQUEST, type - assert_equal key.to_blob, Net::SSH::Buffer.new(buffer.read_string).read_key.to_blob - assert_equal "hello world", buffer.read_string - assert_equal 0, buffer.read_long - - s.return(SSH2_AGENT_SIGN_RESPONSE, :string, "abcxyz123") - end - - assert_equal "abcxyz123", agent.sign(key, "hello world") - end - - private - - class MockSocket - def initialize - @expectation = nil - @buffer = Net::SSH::Buffer.new - end - - def expect(&block) - @expectation = block - end - - def return(type, *args) - data = Net::SSH::Buffer.from(*args) - @buffer.append([data.length+1, type, data.to_s].pack("NCA*")) - end - - def send(data, flags) - raise "got #{data.inspect} but no packet was expected" unless @expectation - buffer = Net::SSH::Buffer.new(data) - buffer.read_long # skip the length - type = buffer.read_byte - @expectation.call(self, type, buffer) - @expectation = nil - end - - def read(length) - @buffer.read(length) - end - end - - def key - @key ||= OpenSSL::PKey::RSA.new(32) - end - - def socket - @socket ||= MockSocket.new - end - - def factory - @factory ||= stub("socket factory", :open => socket) - end - - def agent(auto=:connect) - @agent ||= begin - agent = Net::SSH::Authentication::Agent.new - agent.stubs(:agent_socket_factory).returns(factory) - agent.connect! if auto == :connect - agent - end - end - - end - -end \ No newline at end of file diff --git a/vendor/gems/net-ssh-2.0.15/test/authentication/test_key_manager.rb b/vendor/gems/net-ssh-2.0.15/test/authentication/test_key_manager.rb deleted file mode 100644 index af8422b4b..000000000 --- a/vendor/gems/net-ssh-2.0.15/test/authentication/test_key_manager.rb +++ /dev/null @@ -1,105 +0,0 @@ -require 'common' -require 'net/ssh/authentication/key_manager' - -module Authentication - - class TestKeyManager < Test::Unit::TestCase - def test_key_files_and_known_identities_are_empty_by_default - assert manager.key_files.empty? - assert manager.known_identities.empty? - end - - def test_assume_agent_is_available_by_default - assert manager.use_agent? - end - - def test_add_ensures_list_is_unique - manager.add "/first" - manager.add "/second" - manager.add "/third" - manager.add "/second" - assert_equal %w(/first /second /third), manager.key_files - end - - def test_use_agent_should_be_set_to_false_if_agent_could_not_be_found - Net::SSH::Authentication::Agent.expects(:connect).raises(Net::SSH::Authentication::AgentNotAvailable) - assert manager.use_agent? - assert_nil manager.agent - assert !manager.use_agent? - end - - def test_each_identity_should_load_from_key_files - manager.stubs(:agent).returns(nil) - - stub_file_key "/first", rsa - stub_file_key "/second", dsa - - identities = [] - manager.each_identity { |identity| identities << identity } - - assert_equal 2, identities.length - assert_equal rsa.to_blob, identities.first.to_blob - assert_equal dsa.to_blob, identities.last.to_blob - - assert_equal({:from => :file, :file => "/first", :key => rsa}, manager.known_identities[rsa]) - assert_equal({:from => :file, :file => "/second", :key => dsa}, manager.known_identities[dsa]) - end - - def test_identities_should_load_from_agent - manager.stubs(:agent).returns(agent) - - identities = [] - manager.each_identity { |identity| identities << identity } - - assert_equal 2, identities.length - assert_equal rsa.to_blob, identities.first.to_blob - assert_equal dsa.to_blob, identities.last.to_blob - - assert_equal({:from => :agent}, manager.known_identities[rsa]) - assert_equal({:from => :agent}, manager.known_identities[dsa]) - end - - def test_sign_with_agent_originated_key_should_request_signature_from_agent - manager.stubs(:agent).returns(agent) - manager.each_identity { |identity| } # preload the known_identities - agent.expects(:sign).with(rsa, "hello, world").returns("abcxyz123") - assert_equal "abcxyz123", manager.sign(rsa, "hello, world") - end - - def test_sign_with_file_originated_key_should_load_private_key_and_sign_with_it - manager.stubs(:agent).returns(nil) - stub_file_key "/first", rsa(512), true - rsa.expects(:ssh_do_sign).with("hello, world").returns("abcxyz123") - manager.each_identity { |identity| } # preload the known_identities - assert_equal "\0\0\0\assh-rsa\0\0\0\011abcxyz123", manager.sign(rsa, "hello, world") - end - - private - - def stub_file_key(name, key, also_private=false) - manager.add(name) - File.expects(:readable?).with(name).returns(true) - File.expects(:readable?).with(name + ".pub").returns(false) - Net::SSH::KeyFactory.expects(:load_private_key).with(name, nil).returns(key).at_least_once - key.expects(:public_key).returns(key) - end - - def rsa(size=32) - @rsa ||= OpenSSL::PKey::RSA.new(size) - end - - def dsa - @dsa ||= OpenSSL::PKey::DSA.new(32) - end - - def agent - @agent ||= stub("agent", :identities => [rsa, dsa]) - end - - def manager - @manager ||= Net::SSH::Authentication::KeyManager.new(nil) - end - - end - -end diff --git a/vendor/gems/net-ssh-2.0.15/test/authentication/test_session.rb b/vendor/gems/net-ssh-2.0.15/test/authentication/test_session.rb deleted file mode 100644 index 4cc9bd5ab..000000000 --- a/vendor/gems/net-ssh-2.0.15/test/authentication/test_session.rb +++ /dev/null @@ -1,93 +0,0 @@ -require 'common' -require 'net/ssh/authentication/session' - -module Authentication - - class TestSession < Test::Unit::TestCase - include Net::SSH::Transport::Constants - include Net::SSH::Authentication::Constants - - def test_constructor_should_set_defaults - assert_equal %w(publickey hostbased password keyboard-interactive), session.auth_methods - assert_equal session.auth_methods, session.allowed_auth_methods - end - - def test_authenticate_should_raise_error_if_service_request_fails - transport.expect do |t, packet| - assert_equal SERVICE_REQUEST, packet.type - assert_equal "ssh-userauth", packet.read_string - t.return(255) - end - - assert_raises(Net::SSH::Exception) { session.authenticate("next service", "username", "password") } - end - - def test_authenticate_should_return_false_if_all_auth_methods_fail - transport.expect do |t, packet| - assert_equal SERVICE_REQUEST, packet.type - assert_equal "ssh-userauth", packet.read_string - t.return(SERVICE_ACCEPT) - end - - Net::SSH::Authentication::Methods::Publickey.any_instance.expects(:authenticate).with("next service", "username", "password").returns(false) - Net::SSH::Authentication::Methods::Hostbased.any_instance.expects(:authenticate).with("next service", "username", "password").returns(false) - Net::SSH::Authentication::Methods::Password.any_instance.expects(:authenticate).with("next service", "username", "password").returns(false) - Net::SSH::Authentication::Methods::KeyboardInteractive.any_instance.expects(:authenticate).with("next service", "username", "password").returns(false) - - assert_equal false, session.authenticate("next service", "username", "password") - end - - def test_next_message_should_silently_handle_USERAUTH_BANNER_packets - transport.return(USERAUTH_BANNER, :string, "Howdy, folks!") - transport.return(SERVICE_ACCEPT) - assert_equal SERVICE_ACCEPT, session.next_message.type - end - - def test_next_message_should_understand_USERAUTH_FAILURE - transport.return(USERAUTH_FAILURE, :string, "a,b,c", :bool, false) - packet = session.next_message - assert_equal USERAUTH_FAILURE, packet.type - assert_equal %w(a b c), session.allowed_auth_methods - end - - (60..79).each do |type| - define_method("test_next_message_should_return_packets_of_type_#{type}") do - transport.return(type) - assert_equal type, session.next_message.type - end - end - - def test_next_message_should_understand_USERAUTH_SUCCESS - transport.return(USERAUTH_SUCCESS) - assert !transport.hints[:authenticated] - assert_equal USERAUTH_SUCCESS, session.next_message.type - assert transport.hints[:authenticated] - end - - def test_next_message_should_raise_error_on_unrecognized_packet_types - transport.return(1) - assert_raises(Net::SSH::Exception) { session.next_message } - end - - def test_expect_message_should_raise_exception_if_next_packet_is_not_expected_type - transport.return(SERVICE_ACCEPT) - assert_raises(Net::SSH::Exception) { session.expect_message(USERAUTH_BANNER) } - end - - def test_expect_message_should_return_packet_if_next_packet_is_expected_type - transport.return(SERVICE_ACCEPT) - assert_equal SERVICE_ACCEPT, session.expect_message(SERVICE_ACCEPT).type - end - - private - - def session(options={}) - @session ||= Net::SSH::Authentication::Session.new(transport(options), options) - end - - def transport(options={}) - @transport ||= MockTransport.new(options) - end - end - -end diff --git a/vendor/gems/net-ssh-2.0.15/test/common.rb b/vendor/gems/net-ssh-2.0.15/test/common.rb deleted file mode 100644 index 4637cf0ad..000000000 --- a/vendor/gems/net-ssh-2.0.15/test/common.rb +++ /dev/null @@ -1,107 +0,0 @@ -$LOAD_PATH.unshift "#{File.dirname(__FILE__)}/../lib" -gem "test-unit" # http://rubyforge.org/pipermail/test-unit-tracker/2009-July/000075.html -require 'test/unit' -require 'mocha' -require 'net/ssh/buffer' -require 'net/ssh/config' -require 'net/ssh/loggable' -require 'net/ssh/packet' -require 'net/ssh/transport/session' -require 'ostruct' - -# clear the default files out so that tests don't get confused by existing -# SSH config files. -$original_config_default_files = Net::SSH::Config.default_files.dup -Net::SSH::Config.default_files.clear - -def P(*args) - Net::SSH::Packet.new(Net::SSH::Buffer.from(*args)) -end - -class MockTransport < Net::SSH::Transport::Session - class BlockVerifier - def initialize(block) - @block = block - end - - def verify(data) - @block.call(data) - end - end - - attr_reader :host_key_verifier - attr_accessor :host_as_string - attr_accessor :server_version - - attr_reader :client_options - attr_reader :server_options - attr_reader :hints, :queue - - attr_accessor :mock_enqueue - - def initialize(options={}) - self.logger = options[:logger] - self.host_as_string = "net.ssh.test,127.0.0.1" - self.server_version = OpenStruct.new(:version => "SSH-2.0-Ruby/Net::SSH::Test") - @expectation = nil - @queue = [] - @hints = {} - @socket = options[:socket] - @algorithms = OpenStruct.new(:session_id => "abcxyz123") - verifier { |data| true } - end - - def send_message(message) - buffer = Net::SSH::Buffer.new(message.to_s) - if @expectation.nil? - raise "got #{message.to_s.inspect} but was not expecting anything" - else - block, @expectation = @expectation, nil - block.call(self, Net::SSH::Packet.new(buffer)) - end - end - - def enqueue_message(message) - if mock_enqueue - send_message(message) - else - super - end - end - - def poll_message - @queue.shift - end - - def next_message - @queue.shift or raise "expected a message from the server but nothing was ready to send" - end - - def return(type, *args) - @queue << P(:byte, type, *args) - end - - def expect(&block) - @expectation = block - end - - def expect! - expect {} - end - - def verifier(&block) - @host_key_verifier = BlockVerifier.new(block) - end - - def configure_client(options) - @client_options = options - end - - def configure_server(options) - @server_options = options - end - - def hint(name, value=true) - @hints[name] = value - end -end diff --git a/vendor/gems/net-ssh-2.0.15/test/configs/eqsign b/vendor/gems/net-ssh-2.0.15/test/configs/eqsign deleted file mode 100644 index ed3623685..000000000 --- a/vendor/gems/net-ssh-2.0.15/test/configs/eqsign +++ /dev/null @@ -1,3 +0,0 @@ -Host=test.test - Port =1234 - Compression yes diff --git a/vendor/gems/net-ssh-2.0.15/test/configs/exact_match b/vendor/gems/net-ssh-2.0.15/test/configs/exact_match deleted file mode 100644 index 908d631f7..000000000 --- a/vendor/gems/net-ssh-2.0.15/test/configs/exact_match +++ /dev/null @@ -1,8 +0,0 @@ -Host other.host - Compression no - Port 1231 - -Host test.host - Compression yes - ForwardAgent yes - Port 1234 \ No newline at end of file diff --git a/vendor/gems/net-ssh-2.0.15/test/configs/multihost b/vendor/gems/net-ssh-2.0.15/test/configs/multihost deleted file mode 100644 index 732975cdb..000000000 --- a/vendor/gems/net-ssh-2.0.15/test/configs/multihost +++ /dev/null @@ -1,4 +0,0 @@ -Host other.host, test.host - Compression yes - Port 1980 - RekeyLimit 2G diff --git a/vendor/gems/net-ssh-2.0.15/test/configs/wild_cards b/vendor/gems/net-ssh-2.0.15/test/configs/wild_cards deleted file mode 100644 index 9e02dc848..000000000 --- a/vendor/gems/net-ssh-2.0.15/test/configs/wild_cards +++ /dev/null @@ -1,14 +0,0 @@ -Host test.* - Port 1234 - Compression no - -Host tes?.host - Port 4321 - ForwardAgent yes - -Host *.hos? - IdentityFile ~/.ssh/id_dsa - Compression yes - -Host k*.host - RekeyLimit 1G \ No newline at end of file diff --git a/vendor/gems/net-ssh-2.0.15/test/connection/test_channel.rb b/vendor/gems/net-ssh-2.0.15/test/connection/test_channel.rb deleted file mode 100644 index 3600cf644..000000000 --- a/vendor/gems/net-ssh-2.0.15/test/connection/test_channel.rb +++ /dev/null @@ -1,452 +0,0 @@ -require 'common' -require 'net/ssh/connection/channel' - -module Connection - - class TestChannel < Test::Unit::TestCase - include Net::SSH::Connection::Constants - - def teardown - connection.test! - end - - def test_constructor_should_set_defaults - assert_equal 0x10000, channel.local_maximum_packet_size - assert_equal 0x20000, channel.local_maximum_window_size - assert channel.pending_requests.empty? - end - - def test_channel_properties - channel[:hello] = "some value" - assert_equal "some value", channel[:hello] - end - - def test_exec_should_be_syntactic_sugar_for_a_channel_request - channel.expects(:send_channel_request).with("exec", :string, "ls").yields - found_block = false - channel.exec("ls") { found_block = true } - assert found_block, "expected block to be passed to send_channel_request" - end - - def test_subsystem_should_be_syntactic_sugar_for_a_channel_request - channel.expects(:send_channel_request).with("subsystem", :string, "sftp").yields - found_block = false - channel.subsystem("sftp") { found_block = true } - assert found_block, "expected block to be passed to send_channel_request" - end - - def test_request_pty_with_invalid_option_should_raise_error - assert_raises(ArgumentError) do - channel.request_pty(:bogus => "thing") - end - end - - def test_request_pty_without_options_should_use_defaults - channel.expects(:send_channel_request).with("pty-req", :string, "xterm", - :long, 80, :long, 24, :long, 640, :long, 480, :string, "\0").yields - found_block = false - channel.request_pty { found_block = true } - assert found_block, "expected block to be passed to send_channel_request" - end - - def test_request_pty_with_options_should_honor_options - channel.expects(:send_channel_request).with("pty-req", :string, "vanilla", - :long, 60, :long, 15, :long, 400, :long, 200, :string, "\5\0\0\0\1\0") - channel.request_pty :term => "vanilla", :chars_wide => 60, :chars_high => 15, - :pixels_wide => 400, :pixels_high => 200, :modes => { 5 => 1 } - end - - def test_send_data_should_append_to_channels_output_buffer - channel.send_data("hello") - assert_equal "hello", channel.output.to_s - channel.send_data("world") - assert_equal "helloworld", channel.output.to_s - end - - def test_close_before_channel_has_been_confirmed_should_do_nothing - assert !channel.closing? - channel.close - assert !channel.closing? - end - - def test_close_should_set_closing_and_send_message - channel.do_open_confirmation(0, 100, 100) - assert !channel.closing? - - connection.expect { |t,packet| assert_equal CHANNEL_CLOSE, packet.type } - channel.close - - assert channel.closing? - end - - def test_close_while_closing_should_do_nothing - test_close_should_set_closing_and_send_message - assert_nothing_raised { channel.close } - end - - def test_process_when_process_callback_is_not_set_should_just_enqueue_data - channel.expects(:enqueue_pending_output) - channel.process - end - - def test_process_when_process_callback_is_set_should_yield_self_before_enqueuing_data - channel.expects(:enqueue_pending_output).never - channel.on_process { |ch| ch.expects(:enqueue_pending_output).once } - channel.process - end - - def test_enqueue_pending_output_should_have_no_effect_if_channel_has_not_been_confirmed - channel.send_data("hello") - assert_nothing_raised { channel.enqueue_pending_output } - end - - def test_enqueue_pending_output_should_have_no_effect_if_there_is_no_output - channel.do_open_confirmation(0, 100, 100) - assert_nothing_raised { channel.enqueue_pending_output } - end - - def test_enqueue_pending_output_should_not_enqueue_more_than_output_length - channel.do_open_confirmation(0, 100, 100) - channel.send_data("hello world") - - connection.expect do |t,packet| - assert_equal CHANNEL_DATA, packet.type - assert_equal 0, packet[:local_id] - assert_equal 11, packet[:data].length - end - - channel.enqueue_pending_output - end - - def test_enqueue_pending_output_should_not_enqueue_more_than_max_packet_length_at_once - channel.do_open_confirmation(0, 100, 8) - channel.send_data("hello world") - - connection.expect do |t,packet| - assert_equal CHANNEL_DATA, packet.type - assert_equal 0, packet[:local_id] - assert_equal "hello wo", packet[:data] - - t.expect do |t2,packet2| - assert_equal CHANNEL_DATA, packet2.type - assert_equal 0, packet2[:local_id] - assert_equal "rld", packet2[:data] - end - end - - channel.enqueue_pending_output - end - - def test_enqueue_pending_output_should_not_enqueue_more_than_max_window_size - channel.do_open_confirmation(0, 8, 100) - channel.send_data("hello world") - - connection.expect do |t,packet| - assert_equal CHANNEL_DATA, packet.type - assert_equal 0, packet[:local_id] - assert_equal "hello wo", packet[:data] - end - - channel.enqueue_pending_output - end - - def test_on_data_with_block_should_set_callback - flag = false - channel.on_data { flag = !flag } - channel.do_data("") - assert(flag, "callback should have been invoked") - channel.on_data - channel.do_data("") - assert(flag, "callback should have been removed") - end - - def test_on_extended_data_with_block_should_set_callback - flag = false - channel.on_extended_data { flag = !flag } - channel.do_extended_data(0, "") - assert(flag, "callback should have been invoked") - channel.on_extended_data - channel.do_extended_data(0, "") - assert(flag, "callback should have been removed") - end - - def test_on_process_with_block_should_set_callback - flag = false - channel.on_process { flag = !flag } - channel.process - assert(flag, "callback should have been invoked") - channel.on_process - channel.process - assert(flag, "callback should have been removed") - end - - def test_on_close_with_block_should_set_callback - flag = false - channel.on_close { flag = !flag } - channel.do_close - assert(flag, "callback should have been invoked") - channel.on_close - channel.do_close - assert(flag, "callback should have been removed") - end - - def test_on_eof_with_block_should_set_callback - flag = false - channel.on_eof { flag = !flag } - channel.do_eof - assert(flag, "callback should have been invoked") - channel.on_eof - channel.do_eof - assert(flag, "callback should have been removed") - end - - def test_do_request_for_unhandled_request_should_do_nothing_if_not_wants_reply - channel.do_open_confirmation(0, 100, 100) - assert_nothing_raised { channel.do_request "exit-status", false, nil } - end - - def test_do_request_for_unhandled_request_should_send_CHANNEL_FAILURE_if_wants_reply - channel.do_open_confirmation(0, 100, 100) - connection.expect { |t,packet| assert_equal CHANNEL_FAILURE, packet.type } - channel.do_request "keepalive@openssh.com", true, nil - end - - def test_do_request_for_handled_request_should_invoke_callback_and_do_nothing_if_returns_true_and_not_wants_reply - channel.do_open_confirmation(0, 100, 100) - flag = false - channel.on_request("exit-status") { flag = true; true } - assert_nothing_raised { channel.do_request "exit-status", false, nil } - assert flag, "callback should have been invoked" - end - - def test_do_request_for_handled_request_should_invoke_callback_and_do_nothing_if_fails_and_not_wants_reply - channel.do_open_confirmation(0, 100, 100) - flag = false - channel.on_request("exit-status") { flag = true; raise Net::SSH::ChannelRequestFailed } - assert_nothing_raised { channel.do_request "exit-status", false, nil } - assert flag, "callback should have been invoked" - end - - def test_do_request_for_handled_request_should_invoke_callback_and_send_CHANNEL_SUCCESS_if_returns_true_and_wants_reply - channel.do_open_confirmation(0, 100, 100) - flag = false - channel.on_request("exit-status") { flag = true; true } - connection.expect { |t,p| assert_equal CHANNEL_SUCCESS, p.type } - assert_nothing_raised { channel.do_request "exit-status", true, nil } - assert flag, "callback should have been invoked" - end - - def test_do_request_for_handled_request_should_invoke_callback_and_send_CHANNEL_FAILURE_if_returns_false_and_wants_reply - channel.do_open_confirmation(0, 100, 100) - flag = false - channel.on_request("exit-status") { flag = true; raise Net::SSH::ChannelRequestFailed } - connection.expect { |t,p| assert_equal CHANNEL_FAILURE, p.type } - assert_nothing_raised { channel.do_request "exit-status", true, nil } - assert flag, "callback should have been invoked" - end - - def test_send_channel_request_without_callback_should_not_want_reply - channel.do_open_confirmation(0, 100, 100) - connection.expect do |t,p| - assert_equal CHANNEL_REQUEST, p.type - assert_equal 0, p[:local_id] - assert_equal "exec", p[:request] - assert_equal false, p[:want_reply] - assert_equal "ls", p[:request_data].read_string - end - channel.send_channel_request("exec", :string, "ls") - assert channel.pending_requests.empty? - end - - def test_send_channel_request_with_callback_should_want_reply - channel.do_open_confirmation(0, 100, 100) - connection.expect do |t,p| - assert_equal CHANNEL_REQUEST, p.type - assert_equal 0, p[:local_id] - assert_equal "exec", p[:request] - assert_equal true, p[:want_reply] - assert_equal "ls", p[:request_data].read_string - end - callback = Proc.new {} - channel.send_channel_request("exec", :string, "ls", &callback) - assert_equal [callback], channel.pending_requests - end - - def test_do_open_confirmation_should_set_remote_parameters - channel.do_open_confirmation(1, 2, 3) - assert_equal 1, channel.remote_id - assert_equal 2, channel.remote_window_size - assert_equal 2, channel.remote_maximum_window_size - assert_equal 3, channel.remote_maximum_packet_size - end - - def test_do_open_confirmation_should_call_open_confirmation_callback - flag = false - channel { flag = true } - assert !flag, "callback should not have been invoked yet" - channel.do_open_confirmation(1,2,3) - assert flag, "callback should have been invoked" - end - - def test_do_open_confirmation_with_session_channel_should_invoke_agent_forwarding_if_agent_forwarding_requested - connection :forward_agent => true - forward = mock("forward") - forward.expects(:agent).with(channel) - connection.expects(:forward).returns(forward) - channel.do_open_confirmation(1,2,3) - end - - def test_do_open_confirmation_with_non_session_channel_should_not_invoke_agent_forwarding_even_if_agent_forwarding_requested - connection :forward_agent => true - channel :type => "direct-tcpip" - connection.expects(:forward).never - channel.do_open_confirmation(1,2,3) - end - - def test_do_window_adjust_should_adjust_remote_window_size_by_the_given_amount - channel.do_open_confirmation(0, 1000, 1000) - assert_equal 1000, channel.remote_window_size - assert_equal 1000, channel.remote_maximum_window_size - channel.do_window_adjust(500) - assert_equal 1500, channel.remote_window_size - assert_equal 1500, channel.remote_maximum_window_size - end - - def test_do_data_should_update_local_window_size - assert_equal 0x20000, channel.local_maximum_window_size - assert_equal 0x20000, channel.local_window_size - channel.do_data("here is some data") - assert_equal 0x20000, channel.local_maximum_window_size - assert_equal 0x1FFEF, channel.local_window_size - end - - def test_do_extended_data_should_update_local_window_size - assert_equal 0x20000, channel.local_maximum_window_size - assert_equal 0x20000, channel.local_window_size - channel.do_extended_data(1, "here is some data") - assert_equal 0x20000, channel.local_maximum_window_size - assert_equal 0x1FFEF, channel.local_window_size - end - - def test_do_data_when_local_window_size_drops_below_threshold_should_trigger_WINDOW_ADJUST_message - channel.do_open_confirmation(0, 1000, 1000) - assert_equal 0x20000, channel.local_maximum_window_size - assert_equal 0x20000, channel.local_window_size - - connection.expect do |t,p| - assert_equal CHANNEL_WINDOW_ADJUST, p.type - assert_equal 0, p[:local_id] - assert_equal 0x20000, p[:extra_bytes] - end - - channel.do_data("." * 0x10001) - assert_equal 0x40000, channel.local_maximum_window_size - assert_equal 0x2FFFF, channel.local_window_size - end - - def test_do_failure_should_grab_next_pending_request_and_call_it - result = nil - channel.pending_requests << Proc.new { |*args| result = args } - channel.do_failure - assert_equal [channel, false], result - assert channel.pending_requests.empty? - end - - def test_do_success_should_grab_next_pending_request_and_call_it - result = nil - channel.pending_requests << Proc.new { |*args| result = args } - channel.do_success - assert_equal [channel, true], result - assert channel.pending_requests.empty? - end - - def test_active_should_be_true_when_channel_appears_in_channel_list - connection.channels[channel.local_id] = channel - assert channel.active? - end - - def test_active_should_be_false_when_channel_is_not_in_channel_list - assert !channel.active? - end - - def test_wait_should_block_while_channel_is_active? - channel.expects(:active?).times(3).returns(true,true,false) - channel.wait - end - - def test_eof_bang_should_send_eof_to_server - channel.do_open_confirmation(0, 1000, 1000) - connection.expect { |t,p| assert_equal CHANNEL_EOF, p.type } - channel.eof! - end - - def test_eof_bang_should_not_send_eof_if_eof_was_already_declared - channel.do_open_confirmation(0, 1000, 1000) - connection.expect { |t,p| assert_equal CHANNEL_EOF, p.type } - channel.eof! - assert_nothing_raised { channel.eof! } - end - - def test_eof_q_should_return_true_if_eof_declared - channel.do_open_confirmation(0, 1000, 1000) - connection.expect { |t,p| assert_equal CHANNEL_EOF, p.type } - - assert !channel.eof? - channel.eof! - assert channel.eof? - end - - def test_send_data_should_raise_exception_if_eof_declared - channel.do_open_confirmation(0, 1000, 1000) - connection.expect { |t,p| assert_equal CHANNEL_EOF, p.type } - channel.eof! - assert_raises(EOFError) { channel.send_data("die! die! die!") } - end - - private - - class MockConnection - attr_reader :logger - attr_reader :options - attr_reader :channels - - def initialize(options={}) - @expectation = nil - @options = options - @channels = {} - end - - def expect(&block) - @expectation = block - end - - def send_message(msg) - raise "#{msg.to_s.inspect} recieved but no message was expected" unless @expectation - packet = Net::SSH::Packet.new(msg.to_s) - callback, @expectation = @expectation, nil - callback.call(self, packet) - end - - alias loop_forever loop - def loop(&block) - loop_forever { break unless block.call } - end - - def test! - raise "expected a packet but none were sent" if @expectation - end - end - - def connection(options={}) - @connection ||= MockConnection.new(options) - end - - def channel(options={}, &block) - @channel ||= Net::SSH::Connection::Channel.new(connection(options), - options[:type] || "session", - options[:local_id] || 0, - &block) - end - end - -end diff --git a/vendor/gems/net-ssh-2.0.15/test/connection/test_session.rb b/vendor/gems/net-ssh-2.0.15/test/connection/test_session.rb deleted file mode 100644 index 05c3ad856..000000000 --- a/vendor/gems/net-ssh-2.0.15/test/connection/test_session.rb +++ /dev/null @@ -1,488 +0,0 @@ -require 'common' -require 'net/ssh/connection/session' - -module Connection - - class TestSession < Test::Unit::TestCase - include Net::SSH::Connection::Constants - - def test_constructor_should_set_defaults - assert session.channels.empty? - assert session.pending_requests.empty? - assert_equal({ socket => nil }, session.listeners) - end - - def test_on_open_channel_should_register_block_with_given_channel_type - flag = false - session.on_open_channel("testing") { flag = true } - assert_not_nil session.channel_open_handlers["testing"] - session.channel_open_handlers["testing"].call - assert flag, "callback should have been invoked" - end - - def test_forward_should_create_and_cache_instance_of_forward_service - assert_instance_of Net::SSH::Service::Forward, session.forward - assert_equal session.forward.object_id, session.forward.object_id - end - - def test_listen_to_without_callback_should_add_argument_as_listener - io = stub("io") - session.listen_to(io) - assert session.listeners.key?(io) - assert_nil session.listeners[io] - end - - def test_listen_to_should_add_argument_to_listeners_list_if_block_is_given - io = stub("io", :pending_write? => true) - flag = false - session.listen_to(io) { flag = true } - assert !flag, "callback should not be invoked immediately" - assert session.listeners.key?(io) - session.listeners[io].call - assert flag, "callback should have been invoked" - end - - def test_stop_listening_to_should_remove_argument_from_listeners - io = stub("io", :pending_write? => true) - - session.listen_to(io) - assert session.listeners.key?(io) - - session.stop_listening_to(io) - assert !session.listeners.key?(io) - end - - def test_send_message_should_enqueue_message_at_transport_layer - packet = P(:byte, REQUEST_SUCCESS) - session.send_message(packet) - assert_equal packet.to_s, socket.write_buffer - end - - def test_open_channel_defaults_should_use_session_channel - flag = false - channel = session.open_channel { flag = true } - assert !flag, "callback should not be invoked immediately" - channel.do_open_confirmation(1,2,3) - assert flag, "callback should have been invoked" - assert_equal "session", channel.type - assert_equal 0, channel.local_id - assert_equal channel, session.channels[channel.local_id] - - packet = P(:byte, CHANNEL_OPEN, :string, "session", :long, channel.local_id, - :long, channel.local_maximum_window_size, :long, channel.local_maximum_packet_size) - assert_equal packet.to_s, socket.write_buffer - end - - def test_open_channel_with_type_should_use_type - channel = session.open_channel("direct-tcpip") - assert_equal "direct-tcpip", channel.type - packet = P(:byte, CHANNEL_OPEN, :string, "direct-tcpip", :long, channel.local_id, - :long, channel.local_maximum_window_size, :long, channel.local_maximum_packet_size) - assert_equal packet.to_s, socket.write_buffer - end - - def test_open_channel_with_extras_should_append_extras_to_packet - channel = session.open_channel("direct-tcpip", :string, "other.host", :long, 1234) - packet = P(:byte, CHANNEL_OPEN, :string, "direct-tcpip", :long, channel.local_id, - :long, channel.local_maximum_window_size, :long, channel.local_maximum_packet_size, - :string, "other.host", :long, 1234) - assert_equal packet.to_s, socket.write_buffer - end - - def test_send_global_request_without_callback_should_not_expect_reply - packet = P(:byte, GLOBAL_REQUEST, :string, "testing", :bool, false) - session.send_global_request("testing") - assert_equal packet.to_s, socket.write_buffer - assert session.pending_requests.empty? - end - - def test_send_global_request_with_callback_should_expect_reply - packet = P(:byte, GLOBAL_REQUEST, :string, "testing", :bool, true) - proc = Proc.new {} - session.send_global_request("testing", &proc) - assert_equal packet.to_s, socket.write_buffer - assert_equal [proc], session.pending_requests - end - - def test_send_global_request_with_extras_should_append_extras_to_packet - packet = P(:byte, GLOBAL_REQUEST, :string, "testing", :bool, false, :string, "other.host", :long, 1234) - session.send_global_request("testing", :string, "other.host", :long, 1234) - assert_equal packet.to_s, socket.write_buffer - end - - def test_process_should_exit_immediately_if_block_is_false - session.channels[0] = stub("channel", :closing? => false) - session.channels[0].expects(:process).never - process_times(0) - end - - def test_process_should_exit_after_processing_if_block_is_true_then_false - session.channels[0] = stub("channel", :closing? => false) - session.channels[0].expects(:process) - IO.expects(:select).never - process_times(2) - end - - def test_process_should_not_process_channels_that_are_closing - session.channels[0] = stub("channel", :closing? => true) - session.channels[0].expects(:process).never - IO.expects(:select).never - process_times(2) - end - - def test_global_request_packets_should_be_silently_handled_if_no_handler_exists_for_them - transport.return(GLOBAL_REQUEST, :string, "testing", :bool, false) - process_times(2) - assert transport.queue.empty? - assert !socket.pending_write? - end - - def test_global_request_packets_should_be_auto_replied_to_even_if_no_handler_exists - transport.return(GLOBAL_REQUEST, :string, "testing", :bool, true) - process_times(2) - assert_equal P(:byte, REQUEST_FAILURE).to_s, socket.write_buffer - end - - def test_global_request_handler_should_not_trigger_auto_reply_if_no_reply_is_wanted - flag = false - session.on_global_request("testing") { flag = true } - assert !flag, "callback should not be invoked yet" - transport.return(GLOBAL_REQUEST, :string, "testing", :bool, false) - process_times(2) - assert transport.queue.empty? - assert !socket.pending_write? - assert flag, "callback should have been invoked" - end - - def test_global_request_handler_returning_true_should_trigger_success_auto_reply - flag = false - session.on_global_request("testing") { flag = true } - transport.return(GLOBAL_REQUEST, :string, "testing", :bool, true) - process_times(2) - assert_equal P(:byte, REQUEST_SUCCESS).to_s, socket.write_buffer - assert flag - end - - def test_global_request_handler_returning_false_should_trigger_failure_auto_reply - flag = false - session.on_global_request("testing") { flag = true; false } - transport.return(GLOBAL_REQUEST, :string, "testing", :bool, true) - process_times(2) - assert_equal P(:byte, REQUEST_FAILURE).to_s, socket.write_buffer - assert flag - end - - def test_global_request_handler_returning_sent_should_not_trigger_auto_reply - flag = false - session.on_global_request("testing") { flag = true; :sent } - transport.return(GLOBAL_REQUEST, :string, "testing", :bool, true) - process_times(2) - assert !socket.pending_write? - assert flag - end - - def test_global_request_handler_returning_other_value_should_raise_error - session.on_global_request("testing") { "bug" } - transport.return(GLOBAL_REQUEST, :string, "testing", :bool, true) - assert_raises(RuntimeError) { process_times(2) } - end - - def test_request_success_packets_should_invoke_next_pending_request_with_true - result = nil - session.pending_requests << Proc.new { |*args| result = args } - transport.return(REQUEST_SUCCESS) - process_times(2) - assert_equal [true, P(:byte, REQUEST_SUCCESS)], result - assert session.pending_requests.empty? - end - - def test_request_failure_packets_should_invoke_next_pending_request_with_false - result = nil - session.pending_requests << Proc.new { |*args| result = args } - transport.return(REQUEST_FAILURE) - process_times(2) - assert_equal [false, P(:byte, REQUEST_FAILURE)], result - assert session.pending_requests.empty? - end - - def test_channel_open_packet_without_corresponding_channel_open_handler_should_result_in_channel_open_failure - transport.return(CHANNEL_OPEN, :string, "auth-agent", :long, 14, :long, 0x20000, :long, 0x10000) - process_times(2) - assert_equal P(:byte, CHANNEL_OPEN_FAILURE, :long, 14, :long, 3, :string, "unknown channel type auth-agent", :string, "").to_s, socket.write_buffer - end - - def test_channel_open_packet_with_corresponding_handler_should_result_in_channel_open_failure_when_handler_returns_an_error - transport.return(CHANNEL_OPEN, :string, "auth-agent", :long, 14, :long, 0x20000, :long, 0x10000) - session.on_open_channel "auth-agent" do |s, ch, p| - raise Net::SSH::ChannelOpenFailed.new(1234, "we iz in ur channelz!") - end - process_times(2) - assert_equal P(:byte, CHANNEL_OPEN_FAILURE, :long, 14, :long, 1234, :string, "we iz in ur channelz!", :string, "").to_s, socket.write_buffer - end - - def test_channel_open_packet_with_corresponding_handler_should_result_in_channel_open_confirmation_when_handler_succeeds - transport.return(CHANNEL_OPEN, :string, "auth-agent", :long, 14, :long, 0x20001, :long, 0x10001) - result = nil - session.on_open_channel("auth-agent") { |*args| result = args } - process_times(2) - assert_equal P(:byte, CHANNEL_OPEN_CONFIRMATION, :long, 14, :long, 0, :long, 0x20000, :long, 0x10000).to_s, socket.write_buffer - assert_not_nil(ch = session.channels[0]) - assert_equal [session, ch, P(:byte, CHANNEL_OPEN, :string, "auth-agent", :long, 14, :long, 0x20001, :long, 0x10001)], result - assert_equal 0, ch.local_id - assert_equal 14, ch.remote_id - assert_equal 0x20001, ch.remote_maximum_window_size - assert_equal 0x10001, ch.remote_maximum_packet_size - assert_equal 0x20000, ch.local_maximum_window_size - assert_equal 0x10000, ch.local_maximum_packet_size - assert_equal "auth-agent", ch.type - end - - def test_channel_open_failure_should_remove_channel_and_tell_channel_that_open_failed - session.channels[1] = stub("channel") - session.channels[1].expects(:do_open_failed).with(1234, "some reason") - transport.return(CHANNEL_OPEN_FAILURE, :long, 1, :long, 1234, :string, "some reason", :string, "lang tag") - process_times(2) - assert session.channels.empty? - end - - def test_channel_open_confirmation_packet_should_be_routed_to_corresponding_channel - channel_at(14).expects(:do_open_confirmation).with(1234, 0x20001, 0x10001) - transport.return(CHANNEL_OPEN_CONFIRMATION, :long, 14, :long, 1234, :long, 0x20001, :long, 0x10001) - process_times(2) - end - - def test_channel_window_adjust_packet_should_be_routed_to_corresponding_channel - channel_at(14).expects(:do_window_adjust).with(5000) - transport.return(CHANNEL_WINDOW_ADJUST, :long, 14, :long, 5000) - process_times(2) - end - - def test_channel_request_for_nonexistant_channel_should_be_ignored - transport.return(CHANNEL_REQUEST, :long, 14, :string, "testing", :bool, false) - assert_nothing_raised { process_times(2) } - end - - def test_channel_request_packet_should_be_routed_to_corresponding_channel - channel_at(14).expects(:do_request).with("testing", false, Net::SSH::Buffer.new) - transport.return(CHANNEL_REQUEST, :long, 14, :string, "testing", :bool, false) - process_times(2) - end - - def test_channel_data_packet_should_be_routed_to_corresponding_channel - channel_at(14).expects(:do_data).with("bring it on down") - transport.return(CHANNEL_DATA, :long, 14, :string, "bring it on down") - process_times(2) - end - - def test_channel_extended_data_packet_should_be_routed_to_corresponding_channel - channel_at(14).expects(:do_extended_data).with(1, "bring it on down") - transport.return(CHANNEL_EXTENDED_DATA, :long, 14, :long, 1, :string, "bring it on down") - process_times(2) - end - - def test_channel_eof_packet_should_be_routed_to_corresponding_channel - channel_at(14).expects(:do_eof).with() - transport.return(CHANNEL_EOF, :long, 14) - process_times(2) - end - - def test_channel_success_packet_should_be_routed_to_corresponding_channel - channel_at(14).expects(:do_success).with() - transport.return(CHANNEL_SUCCESS, :long, 14) - process_times(2) - end - - def test_channel_failure_packet_should_be_routed_to_corresponding_channel - channel_at(14).expects(:do_failure).with() - transport.return(CHANNEL_FAILURE, :long, 14) - process_times(2) - end - - def test_channel_close_packet_should_be_routed_to_corresponding_channel_and_channel_should_be_closed_and_removed - channel_at(14).expects(:do_close).with() - session.channels[14].expects(:close).with() - transport.return(CHANNEL_CLOSE, :long, 14) - process_times(2) - assert session.channels.empty? - end - - def test_multiple_pending_dispatches_should_be_dispatched_together - channel_at(14).expects(:do_eof).with() - session.channels[14].expects(:do_success).with() - transport.return(CHANNEL_SUCCESS, :long, 14) - transport.return(CHANNEL_EOF, :long, 14) - process_times(2) - end - - def test_writers_without_pending_writes_should_not_be_considered_for_select - IO.expects(:select).with([socket],[],nil,nil).returns([[],[],[]]) - session.process - end - - def test_writers_with_pending_writes_should_be_considered_for_select - socket.enqueue("laksdjflasdkf") - IO.expects(:select).with([socket],[socket],nil,nil).returns([[],[],[]]) - session.process - end - - def test_ready_readers_should_be_filled - socket.expects(:recv).returns("this is some data") - IO.expects(:select).with([socket],[],nil,nil).returns([[socket],[],[]]) - session.process - assert_equal [socket], session.listeners.keys - end - - def test_ready_readers_that_cant_be_filled_should_be_removed - socket.expects(:recv).returns("") - socket.expects(:close) - IO.expects(:select).with([socket],[],nil,nil).returns([[socket],[],[]]) - session.process - assert session.listeners.empty? - end - - def test_ready_readers_that_are_registered_with_a_block_should_call_block_instead_of_fill - io = stub("io", :pending_write? => false) - flag = false - session.stop_listening_to(socket) # so that we only have to test the presence of a single IO object - session.listen_to(io) { flag = true } - IO.expects(:select).with([io],[],nil,nil).returns([[io],[],[]]) - session.process - assert flag, "callback should have been invoked" - end - - def test_ready_writers_should_call_send_pending - socket.enqueue("laksdjflasdkf") - socket.expects(:send).with("laksdjflasdkf", 0).returns(13) - IO.expects(:select).with([socket],[socket],nil,nil).returns([[],[socket],[]]) - session.process - end - - def test_process_should_call_rekey_as_needed - transport.expects(:rekey_as_needed) - IO.expects(:select).with([socket],[],nil,nil).returns([[],[],[]]) - session.process - end - - def test_loop_should_call_process_until_process_returns_false - IO.stubs(:select).with([socket],[],nil,nil).returns([[],[],[]]) - session.expects(:process).with(nil).times(4).returns(true,true,true,false).yields - n = 0 - session.loop { n += 1 } - assert_equal 4, n - end - - def test_exec_should_open_channel_and_configure_default_callbacks - prep_exec("ls", :stdout, "data packet", :stderr, "extended data packet") - - call = :first - session.exec "ls" do |channel, type, data| - if call == :first - assert_equal :stdout, type - assert_equal "data packet", data - call = :second - elsif call == :second - assert_equal :stderr, type - assert_equal "extended data packet", data - call = :third - else - flunk "should never get here, call == #{call.inspect}" - end - end - - session.loop - assert_equal :third, call - end - - def test_exec_without_block_should_use_print_to_display_result - prep_exec("ls", :stdout, "data packet", :stderr, "extended data packet") - $stdout.expects(:print).with("data packet") - $stderr.expects(:print).with("extended data packet") - - session.exec "ls" - session.loop - end - - def test_exec_bang_should_block_until_command_finishes - prep_exec("ls", :stdout, "some data") - called = false - session.exec! "ls" do |channel, type, data| - called = true - assert_equal :stdout, type - assert_equal "some data", data - end - assert called - end - - def test_exec_bang_without_block_should_return_data_as_string - prep_exec("ls", :stdout, "some data") - assert_equal "some data", session.exec!("ls") - end - - private - - def prep_exec(command, *data) - transport.mock_enqueue = true - transport.expect do |t, p| - assert_equal CHANNEL_OPEN, p.type - t.return(CHANNEL_OPEN_CONFIRMATION, :long, p[:remote_id], :long, 0, :long, 0x20000, :long, 0x10000) - t.expect do |t2, p2| - assert_equal CHANNEL_REQUEST, p2.type - assert_equal "exec", p2[:request] - assert_equal true, p2[:want_reply] - assert_equal "ls", p2.read_string - - t2.return(CHANNEL_SUCCESS, :long, p[:remote_id]) - - 0.step(data.length-1, 2) do |index| - type = data[index] - datum = data[index+1] - - if type == :stdout - t2.return(CHANNEL_DATA, :long, p[:remote_id], :string, datum) - else - t2.return(CHANNEL_EXTENDED_DATA, :long, p[:remote_id], :long, 1, :string, datum) - end - end - - t2.return(CHANNEL_CLOSE, :long, p[:remote_id]) - t2.expect { |t3,p3| assert_equal CHANNEL_CLOSE, p3.type } - end - end - end - - module MockSocket - # so that we can easily test the contents that were enqueued, without - # worrying about all the packet stream overhead - def enqueue_packet(message) - enqueue(message.to_s) - end - end - - def socket - @socket ||= begin - socket ||= Object.new - socket.extend(Net::SSH::Transport::PacketStream) - socket.extend(MockSocket) - socket - end - end - - def channel_at(local_id) - session.channels[local_id] = stub("channel", :process => true, :closing? => false) - end - - def transport(options={}) - @transport ||= MockTransport.new(options.merge(:socket => socket)) - end - - def session(options={}) - @session ||= Net::SSH::Connection::Session.new(transport, options) - end - - def process_times(n) - i = 0 - session.process { (i += 1) < n } - end - end - -end diff --git a/vendor/gems/net-ssh-2.0.15/test/test_all.rb b/vendor/gems/net-ssh-2.0.15/test/test_all.rb deleted file mode 100644 index 47305dc4d..000000000 --- a/vendor/gems/net-ssh-2.0.15/test/test_all.rb +++ /dev/null @@ -1,8 +0,0 @@ -# $ ruby -Ilib -Itest -rrubygems test/test_all.rb -# $ ruby -Ilib -Itest -rrubygems test/transport/test_server_version.rb -Dir.chdir(File.dirname(__FILE__)) do - test_files = Dir['**/test_*.rb'] - test_files = test_files.select { |f| f =~ Regexp.new(ENV['ONLY']) } if ENV['ONLY'] - test_files = test_files.reject { |f| f =~ Regexp.new(ENV['EXCEPT']) } if ENV['EXCEPT'] - test_files.each { |file| require(file) } -end \ No newline at end of file diff --git a/vendor/gems/net-ssh-2.0.15/test/test_buffer.rb b/vendor/gems/net-ssh-2.0.15/test/test_buffer.rb deleted file mode 100644 index 81a91302e..000000000 --- a/vendor/gems/net-ssh-2.0.15/test/test_buffer.rb +++ /dev/null @@ -1,336 +0,0 @@ -require 'common' -require 'net/ssh/buffer' - -class TestBuffer < Test::Unit::TestCase - def test_constructor_should_initialize_buffer_to_empty_by_default - buffer = new - assert buffer.empty? - assert_equal 0, buffer.position - end - - def test_constructor_with_string_should_initialize_buffer_to_the_string - buffer = new("hello") - assert !buffer.empty? - assert_equal "hello", buffer.to_s - assert_equal 0, buffer.position - end - - def test_from_should_require_an_even_number_of_arguments - assert_raises(ArgumentError) { Net::SSH::Buffer.from("this") } - end - - def test_from_should_build_new_buffer_from_definition - buffer = Net::SSH::Buffer.from(:byte, 1, :long, 2, :int64, 3, :string, "4", :bool, true, :bool, false, :bignum, OpenSSL::BN.new("1234567890", 10), :raw, "something") - assert_equal "\1\0\0\0\2\0\0\0\0\0\0\0\3\0\0\0\0014\1\0\000\000\000\004I\226\002\322something", buffer.to_s - end - - def test_from_with_array_argument_should_write_multiple_of_the_given_type - buffer = Net::SSH::Buffer.from(:byte, [1,2,3,4,5]) - assert_equal "\1\2\3\4\5", buffer.to_s - end - - def test_read_without_argument_should_read_to_end - buffer = new("hello world") - assert_equal "hello world", buffer.read - assert buffer.eof? - assert_equal 11, buffer.position - end - - def test_read_with_argument_that_is_less_than_length_should_read_that_many_bytes - buffer = new "hello world" - assert_equal "hello", buffer.read(5) - assert_equal 5, buffer.position - end - - def test_read_with_argument_that_is_more_than_length_should_read_no_more_than_length - buffer = new "hello world" - assert_equal "hello world", buffer.read(500) - assert_equal 11, buffer.position - end - - def test_read_at_eof_should_return_empty_string - buffer = new "hello" - buffer.position = 5 - assert_equal "", buffer.read - end - - def test_consume_without_argument_should_resize_buffer_to_start_at_position - buffer = new "hello world" - buffer.read(5) - assert_equal 5, buffer.position - assert_equal 11, buffer.length - buffer.consume! - assert_equal 0, buffer.position - assert_equal 6, buffer.length - assert_equal " world", buffer.to_s - end - - def test_consume_with_argument_should_resize_buffer_starting_at_n - buffer = new "hello world" - assert_equal 0, buffer.position - buffer.consume!(5) - assert_equal 0, buffer.position - assert_equal 6, buffer.length - assert_equal " world", buffer.to_s - end - - def test_read_bang_should_read_and_consume_and_return_read_portion - buffer = new "hello world" - assert_equal "hello", buffer.read!(5) - assert_equal 0, buffer.position - assert_equal 6, buffer.length - assert_equal " world", buffer.to_s - end - - def test_available_should_return_length_after_position_to_end_of_string - buffer = new "hello world" - buffer.read(5) - assert_equal 6, buffer.available - end - - def test_clear_bang_should_reset_buffer_contents_and_counters - buffer = new "hello world" - buffer.read(5) - buffer.clear! - assert_equal 0, buffer.length - assert_equal 0, buffer.position - assert_equal "", buffer.to_s - end - - def test_append_should_append_argument_without_changing_position_and_should_return_self - buffer = new "hello world" - buffer.read(5) - buffer.append(" again") - assert_equal 5, buffer.position - assert_equal 12, buffer.available - assert_equal 17, buffer.length - assert_equal "hello world again", buffer.to_s - end - - def test_remainder_as_buffer_should_return_a_new_buffer_filled_with_the_text_after_the_current_position - buffer = new "hello world" - buffer.read(6) - b2 = buffer.remainder_as_buffer - assert_equal 6, buffer.position - assert_equal 0, b2.position - assert_equal "world", b2.to_s - end - - def test_read_int64_should_return_8_byte_integer - buffer = new "\xff\xee\xdd\xcc\xbb\xaa\x99\x88" - assert_equal 0xffeeddccbbaa9988, buffer.read_int64 - assert_equal 8, buffer.position - end - - def test_read_int64_should_return_nil_on_partial_read - buffer = new "\0\0\0\0\0\0\0" - assert_nil buffer.read_int64 - assert buffer.eof? - end - - def test_read_long_should_return_4_byte_integer - buffer = new "\xff\xee\xdd\xcc\xbb\xaa\x99\x88" - assert_equal 0xffeeddcc, buffer.read_long - assert_equal 4, buffer.position - end - - def test_read_long_should_return_nil_on_partial_read - buffer = new "\0\0\0" - assert_nil buffer.read_long - assert buffer.eof? - end - - def test_read_byte_should_return_single_byte_integer - buffer = new "\xfe\xdc" - assert_equal 0xfe, buffer.read_byte - assert_equal 1, buffer.position - end - - def test_read_byte_should_return_nil_at_eof - assert_nil new.read_byte - end - - def test_read_string_should_read_length_and_data_from_buffer - buffer = new "\0\0\0\x0bhello world" - assert_equal "hello world", buffer.read_string - end - - def test_read_string_should_return_nil_if_4_byte_length_cannot_be_read - assert_nil new("\0\1").read_string - end - - def test_read_bool_should_return_true_if_non_zero_byte_is_read - buffer = new "\1\2\3\4\5\6" - 6.times { assert_equal true, buffer.read_bool } - end - - def test_read_bool_should_return_false_if_zero_byte_is_read - buffer = new "\0" - assert_equal false, buffer.read_bool - end - - def test_read_bool_should_return_nil_at_eof - assert_nil new.read_bool - end - - def test_read_bignum_should_read_openssl_formatted_bignum - buffer = new("\000\000\000\004I\226\002\322") - assert_equal OpenSSL::BN.new("1234567890", 10), buffer.read_bignum - end - - def test_read_bignum_should_return_nil_if_length_cannot_be_read - assert_nil new("\0\1\2").read_bignum - end - - def test_read_key_blob_should_read_dsa_keys - random_dss { |buffer| buffer.read_keyblob("ssh-dss") } - end - - def test_read_key_blob_should_read_rsa_keys - random_rsa { |buffer| buffer.read_keyblob("ssh-rsa") } - end - - def test_read_key_should_read_dsa_key_type_and_keyblob - random_dss do |buffer| - b2 = Net::SSH::Buffer.from(:string, "ssh-dss", :raw, buffer) - b2.read_key - end - end - - def test_read_key_should_read_rsa_key_type_and_keyblob - random_rsa do |buffer| - b2 = Net::SSH::Buffer.from(:string, "ssh-rsa", :raw, buffer) - b2.read_key - end - end - - def test_read_buffer_should_read_a_string_and_return_it_wrapped_in_a_buffer - buffer = new("\0\0\0\x0bhello world") - b2 = buffer.read_buffer - assert_equal 0, b2.position - assert_equal 11, b2.length - assert_equal "hello world", b2.read - end - - def test_read_to_should_return_nil_if_pattern_does_not_exist_in_buffer - buffer = new("one two three") - assert_nil buffer.read_to("\n") - end - - def test_read_to_should_grok_string_patterns - buffer = new("one two three") - assert_equal "one tw", buffer.read_to("tw") - assert_equal 6, buffer.position - end - - def test_read_to_should_grok_regex_patterns - buffer = new("one two three") - assert_equal "one tw", buffer.read_to(/tw/) - assert_equal 6, buffer.position - end - - def test_read_to_should_grok_fixnum_patterns - buffer = new("one two three") - assert_equal "one tw", buffer.read_to(?w) - assert_equal 6, buffer.position - end - - def test_reset_bang_should_reset_position_to_0 - buffer = new("hello world") - buffer.read(5) - assert_equal 5, buffer.position - buffer.reset! - assert_equal 0, buffer.position - end - - def test_write_should_write_arguments_directly_to_end_buffer - buffer = new("start") - buffer.write "hello", " ", "world" - assert_equal "starthello world", buffer.to_s - assert_equal 0, buffer.position - end - - def test_write_int64_should_write_arguments_as_8_byte_integers_to_end_of_buffer - buffer = new("start") - buffer.write_int64 0xffeeddccbbaa9988, 0x7766554433221100 - assert_equal "start\xff\xee\xdd\xcc\xbb\xaa\x99\x88\x77\x66\x55\x44\x33\x22\x11\x00", buffer.to_s - end - - def test_write_long_should_write_arguments_as_4_byte_integers_to_end_of_buffer - buffer = new("start") - buffer.write_long 0xffeeddcc, 0xbbaa9988 - assert_equal "start\xff\xee\xdd\xcc\xbb\xaa\x99\x88", buffer.to_s - end - - def test_write_byte_should_write_arguments_as_1_byte_integers_to_end_of_buffer - buffer = new("start") - buffer.write_byte 1, 2, 3, 4, 5 - assert_equal "start\1\2\3\4\5", buffer.to_s - end - - def test_write_bool_should_write_arguments_as_1_byte_boolean_values_to_end_of_buffer - buffer = new("start") - buffer.write_bool nil, false, true, 1, Object.new - assert_equal "start\0\0\1\1\1", buffer.to_s - end - - def test_write_bignum_should_write_arguments_as_ssh_formatted_bignum_values_to_end_of_buffer - buffer = new("start") - buffer.write_bignum OpenSSL::BN.new('1234567890', 10) - assert_equal "start\000\000\000\004I\226\002\322", buffer.to_s - end - - def test_write_dss_key_should_write_argument_to_end_of_buffer - buffer = new("start") - - key = OpenSSL::PKey::DSA.new - key.p = 0xffeeddccbbaa9988 - key.q = 0x7766554433221100 - key.g = 0xffddbb9977553311 - key.pub_key = 0xeeccaa8866442200 - - buffer.write_key(key) - assert_equal "start\0\0\0\7ssh-dss\0\0\0\011\0\xff\xee\xdd\xcc\xbb\xaa\x99\x88\0\0\0\010\x77\x66\x55\x44\x33\x22\x11\x00\0\0\0\011\0\xff\xdd\xbb\x99\x77\x55\x33\x11\0\0\0\011\0\xee\xcc\xaa\x88\x66\x44\x22\x00", buffer.to_s - end - - def test_write_rsa_key_should_write_argument_to_end_of_buffer - buffer = new("start") - - key = OpenSSL::PKey::RSA.new - key.e = 0xffeeddccbbaa9988 - key.n = 0x7766554433221100 - - buffer.write_key(key) - assert_equal "start\0\0\0\7ssh-rsa\0\0\0\011\0\xff\xee\xdd\xcc\xbb\xaa\x99\x88\0\0\0\010\x77\x66\x55\x44\x33\x22\x11\x00", buffer.to_s - end - - private - - def random_rsa - n1 = OpenSSL::BN.new(rand(0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF).to_s, 10) - n2 = OpenSSL::BN.new(rand(0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF).to_s, 10) - buffer = Net::SSH::Buffer.from(:bignum, [n1, n2]) - key = yield(buffer) - assert_equal "ssh-rsa", key.ssh_type - assert_equal n1, key.e - assert_equal n2, key.n - end - - def random_dss - n1 = OpenSSL::BN.new(rand(0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF).to_s, 10) - n2 = OpenSSL::BN.new(rand(0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF).to_s, 10) - n3 = OpenSSL::BN.new(rand(0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF).to_s, 10) - n4 = OpenSSL::BN.new(rand(0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF).to_s, 10) - buffer = Net::SSH::Buffer.from(:bignum, [n1, n2, n3, n4]) - key = yield(buffer) - assert_equal "ssh-dss", key.ssh_type - assert_equal n1, key.p - assert_equal n2, key.q - assert_equal n3, key.g - assert_equal n4, key.pub_key - end - - def new(*args) - Net::SSH::Buffer.new(*args) - end -end \ No newline at end of file diff --git a/vendor/gems/net-ssh-2.0.15/test/test_buffered_io.rb b/vendor/gems/net-ssh-2.0.15/test/test_buffered_io.rb deleted file mode 100644 index 6ee46ef4b..000000000 --- a/vendor/gems/net-ssh-2.0.15/test/test_buffered_io.rb +++ /dev/null @@ -1,63 +0,0 @@ -require 'common' -require 'net/ssh/buffered_io' - -class TestBufferedIo < Test::Unit::TestCase - def test_fill_should_pull_from_underlying_io - io.expects(:recv).with(8192).returns("here is some data") - assert_equal 17, io.fill - assert_equal 17, io.available - assert_equal "here is some data", io.read_available(20) - end - - def test_enqueue_should_not_write_to_underlying_io - assert !io.pending_write? - io.expects(:send).never - io.enqueue("here is some data") - assert io.pending_write? - end - - def test_send_pending_should_not_fail_when_no_writes_are_pending - assert !io.pending_write? - io.expects(:send).never - assert_nothing_raised { io.send_pending } - end - - def test_send_pending_with_pending_writes_should_write_to_underlying_io - io.enqueue("here is some data") - io.expects(:send).with("here is some data", 0).returns(17) - assert io.pending_write? - assert_nothing_raised { io.send_pending } - assert !io.pending_write? - end - - def test_wait_for_pending_sends_should_write_only_once_if_all_can_be_written_at_once - io.enqueue("here is some data") - io.expects(:send).with("here is some data", 0).returns(17) - assert io.pending_write? - assert_nothing_raised { io.wait_for_pending_sends } - assert !io.pending_write? - end - - def test_wait_for_pending_sends_should_write_multiple_times_if_first_write_was_partial - io.enqueue("here is some data") - - io.expects(:send).with("here is some data", 0).returns(10) - io.expects(:send).with("me data", 0).returns(4) - io.expects(:send).with("ata", 0).returns(3) - - IO.expects(:select).times(2).with(nil, [io]).returns([[], [io]]) - - assert_nothing_raised { io.wait_for_pending_sends } - assert !io.pending_write? - end - - private - - def io - @io ||= begin - io = mock("io") - io.extend(Net::SSH::BufferedIo) - io - end - end -end \ No newline at end of file diff --git a/vendor/gems/net-ssh-2.0.15/test/test_config.rb b/vendor/gems/net-ssh-2.0.15/test/test_config.rb deleted file mode 100644 index 82ad815c9..000000000 --- a/vendor/gems/net-ssh-2.0.15/test/test_config.rb +++ /dev/null @@ -1,99 +0,0 @@ -require 'common' -require 'net/ssh/config' - -class TestConfig < Test::Unit::TestCase - def test_load_for_non_existant_file_should_return_empty_hash - File.expects(:readable?).with("/bogus/file").returns(false) - assert_equal({}, Net::SSH::Config.load("/bogus/file", "host.name")) - end - - def test_load_should_expand_path - expected = File.expand_path("~/.ssh/config") - File.expects(:readable?).with(expected).returns(false) - Net::SSH::Config.load("~/.ssh/config", "host.name") - end - - def test_load_with_exact_host_match_should_load_that_section - config = Net::SSH::Config.load(config(:exact_match), "test.host") - assert config['compression'] - assert config['forwardagent'] - assert_equal 1234, config['port'] - end - - def test_load_with_wild_card_matches_should_load_all_matches_with_first_match_taking_precedence - config = Net::SSH::Config.load(config(:wild_cards), "test.host") - assert_equal 1234, config['port'] - assert !config['compression'] - assert config['forwardagent'] - assert_equal %w(~/.ssh/id_dsa), config['identityfile'] - assert !config.key?('rekeylimit') - end - - def test_for_should_load_all_files_and_translate_to_net_ssh_options - config = Net::SSH::Config.for("test.host", [config(:exact_match), config(:wild_cards)]) - assert_equal 1234, config[:port] - assert config[:compression] - assert config[:forward_agent] - assert_equal %w(~/.ssh/id_dsa), config[:keys] - assert !config.key?(:rekey_limit) - end - - def test_load_with_multiple_hosts - config = Net::SSH::Config.load(config(:multihost), "test.host") - assert config['compression'] - assert_equal '2G', config['rekeylimit'] - assert_equal 1980, config['port'] - end - - def test_load_with_multiple_hosts_and_config_should_match_for_both - aconfig = Net::SSH::Config.load(config(:multihost), "test.host") - bconfig = Net::SSH::Config.load(config(:multihost), "other.host") - assert_equal aconfig['port'], bconfig['port'] - assert_equal aconfig['compression'], bconfig['compression'] - assert_equal aconfig['rekeylimit'], bconfig['rekeylimit'] - end - - def test_load_should_parse_equal_sign_delimiters - config = Net::SSH::Config.load(config(:eqsign), "test.test") - assert config['compression'] - assert_equal 1234, config['port'] - end - - def test_translate_should_correctly_translate_from_openssh_to_net_ssh_names - open_ssh = { - 'ciphers' => "a,b,c", - 'compression' => true, - 'compressionlevel' => 6, - 'connecttimeout' => 100, - 'forwardagent' => true, - 'hostbasedauthentication' => true, - 'hostkeyalgorithms' => "d,e,f", - 'identityfile' => %w(g h i), - 'macs' => "j,k,l", - 'passwordauthentication' => true, - 'port' => 1234, - 'pubkeyauthentication' => true, - 'rekeylimit' => 1024 - } - - net_ssh = Net::SSH::Config.translate(open_ssh) - - assert_equal %w(a b c), net_ssh[:encryption] - assert_equal true, net_ssh[:compression] - assert_equal 6, net_ssh[:compression_level] - assert_equal 100, net_ssh[:timeout] - assert_equal true, net_ssh[:forward_agent] - assert_equal %w(hostbased password publickey), net_ssh[:auth_methods].sort - assert_equal %w(d e f), net_ssh[:host_key] - assert_equal %w(g h i), net_ssh[:keys] - assert_equal %w(j k l), net_ssh[:hmac] - assert_equal 1234, net_ssh[:port] - assert_equal 1024, net_ssh[:rekey_limit] - end - - private - - def config(name) - "test/configs/#{name}" - end -end \ No newline at end of file diff --git a/vendor/gems/net-ssh-2.0.15/test/test_key_factory.rb b/vendor/gems/net-ssh-2.0.15/test/test_key_factory.rb deleted file mode 100644 index e5a38bbbe..000000000 --- a/vendor/gems/net-ssh-2.0.15/test/test_key_factory.rb +++ /dev/null @@ -1,67 +0,0 @@ -require 'common' -require 'net/ssh/key_factory' - -class TestKeyFactory < Test::Unit::TestCase - def test_load_unencrypted_private_RSA_key_should_return_key - File.expects(:read).with("/key-file").returns(rsa_key.export) - assert_equal rsa_key.to_der, Net::SSH::KeyFactory.load_private_key("/key-file").to_der - end - - def test_load_unencrypted_private_DSA_key_should_return_key - File.expects(:read).with("/key-file").returns(dsa_key.export) - assert_equal dsa_key.to_der, Net::SSH::KeyFactory.load_private_key("/key-file").to_der - end - - def test_load_encrypted_private_RSA_key_should_prompt_for_password_and_return_key - File.expects(:read).with("/key-file").returns(encrypted(rsa_key, "password")) - Net::SSH::KeyFactory.expects(:prompt).with("Enter passphrase for /key-file:", false).returns("password") - assert_equal rsa_key.to_der, Net::SSH::KeyFactory.load_private_key("/key-file").to_der - end - - def test_load_encrypted_private_RSA_key_with_password_should_not_prompt_and_return_key - File.expects(:read).with("/key-file").returns(encrypted(rsa_key, "password")) - assert_equal rsa_key.to_der, Net::SSH::KeyFactory.load_private_key("/key-file", "password").to_der - end - - def test_load_encrypted_private_DSA_key_should_prompt_for_password_and_return_key - File.expects(:read).with("/key-file").returns(encrypted(dsa_key, "password")) - Net::SSH::KeyFactory.expects(:prompt).with("Enter passphrase for /key-file:", false).returns("password") - assert_equal dsa_key.to_der, Net::SSH::KeyFactory.load_private_key("/key-file").to_der - end - - def test_load_encrypted_private_DSA_key_with_password_should_not_prompt_and_return_key - File.expects(:read).with("/key-file").returns(encrypted(dsa_key, "password")) - assert_equal dsa_key.to_der, Net::SSH::KeyFactory.load_private_key("/key-file", "password").to_der - end - - def test_load_encrypted_private_key_should_give_three_tries_for_the_password_and_then_raise_exception - File.expects(:read).with("/key-file").returns(encrypted(rsa_key, "password")) - Net::SSH::KeyFactory.expects(:prompt).times(3).with("Enter passphrase for /key-file:", false).returns("passwod","passphrase","passwd") - assert_raises(OpenSSL::PKey::RSAError) { Net::SSH::KeyFactory.load_private_key("/key-file") } - end - - def test_load_public_rsa_key_should_return_key - File.expects(:read).with("/key-file").returns(public(rsa_key)) - assert_equal rsa_key.to_blob, Net::SSH::KeyFactory.load_public_key("/key-file").to_blob - end - - private - - def rsa_key - @rsa_key ||= OpenSSL::PKey::RSA.new("0@\002\001\000\002\t\000\300\030\317\2132\340 \267\002\003\001\000\001\002\t\000\236~\232\025\350Y=\341\002\005\000\352D\217\a\002\005\000\321\352\304\321\002\005\000\242\350\206%\002\005\000\270\021\217\361\002\004~\253\214j") - end - - def dsa_key - @dsa_key ||= OpenSSL::PKey::DSA.new("0\201\367\002\001\000\002A\000\203\316/\037u\272&J\265\003l3\315d\324h\372{\t8\252#\331_\026\006\035\270\266\255\343\353Z\302\276\335\336\306\220\375\202L\244\244J\206>\346\b\315\211\302L\246x\247u\a\376\366\345\302\016#\002\025\000\244\274\302\221Og\275/\302+\356\346\360\024\373wI\2573\361\002@\027\215\270r*\f\213\350C\245\021:\350 \006\\\376\345\022`\210b\262\3643\023XLKS\320\370\002\276\347A\nU\204\276\324\256`=\026\240\330\306J\316V\213\024\e\030\215\355\006\037q\337\356ln\002@\017\257\034\f\260\333'S\271#\237\230E\321\312\027\021\226\331\251Vj\220\305\316\036\v\266+\000\230\270\177B\003?t\a\305]e\344\261\334\023\253\323\251\223M\2175)a(\004\"lI8\312\303\307\a\002\024_\aznW\345\343\203V\326\246ua\203\376\201o\350\302\002") - end - - def encrypted(key, password) - key.export(OpenSSL::Cipher::Cipher.new("des-ede3-cbc"), password) - end - - def public(key) - result = "#{key.ssh_type} " - result << [Net::SSH::Buffer.from(:key, key).to_s].pack("m*").strip.tr("\n\r\t ", "") - result << " joe@host.test" - end -end \ No newline at end of file diff --git a/vendor/gems/net-ssh-2.0.15/test/transport/hmac/test_md5.rb b/vendor/gems/net-ssh-2.0.15/test/transport/hmac/test_md5.rb deleted file mode 100644 index d7854f28f..000000000 --- a/vendor/gems/net-ssh-2.0.15/test/transport/hmac/test_md5.rb +++ /dev/null @@ -1,39 +0,0 @@ -require 'common' -require 'net/ssh/transport/hmac/md5' - -module Transport; module HMAC - - class TestMD5 < Test::Unit::TestCase - def test_expected_digest_class - assert_equal OpenSSL::Digest::MD5, subject.digest_class - assert_equal OpenSSL::Digest::MD5, subject.new.digest_class - end - - def test_expected_key_length - assert_equal 16, subject.key_length - assert_equal 16, subject.new.key_length - end - - def test_expected_mac_length - assert_equal 16, subject.mac_length - assert_equal 16, subject.new.mac_length - end - - def test_expected_digest - hmac = subject.new("1234567890123456") - assert_equal "\275\345\006\307y~Oi\035<.\341\031\250<\257", hmac.digest("hello world") - end - - def test_key_should_be_truncated_to_required_length - hmac = subject.new("12345678901234567890") - assert_equal "1234567890123456", hmac.key - end - - private - - def subject - Net::SSH::Transport::HMAC::MD5 - end - end - -end; end \ No newline at end of file diff --git a/vendor/gems/net-ssh-2.0.15/test/transport/hmac/test_md5_96.rb b/vendor/gems/net-ssh-2.0.15/test/transport/hmac/test_md5_96.rb deleted file mode 100644 index 575447be7..000000000 --- a/vendor/gems/net-ssh-2.0.15/test/transport/hmac/test_md5_96.rb +++ /dev/null @@ -1,25 +0,0 @@ -require 'common' -require 'transport/hmac/test_md5' -require 'net/ssh/transport/hmac/md5_96' - -module Transport; module HMAC - - class TestMD5_96 < TestMD5 - def test_expected_mac_length - assert_equal 12, subject.mac_length - assert_equal 12, subject.new.mac_length - end - - def test_expected_digest - hmac = subject.new("1234567890123456") - assert_equal "\275\345\006\307y~Oi\035<.\341", hmac.digest("hello world") - end - - private - - def subject - Net::SSH::Transport::HMAC::MD5_96 - end - end - -end; end \ No newline at end of file diff --git a/vendor/gems/net-ssh-2.0.15/test/transport/hmac/test_none.rb b/vendor/gems/net-ssh-2.0.15/test/transport/hmac/test_none.rb deleted file mode 100644 index 7b49fe8a1..000000000 --- a/vendor/gems/net-ssh-2.0.15/test/transport/hmac/test_none.rb +++ /dev/null @@ -1,34 +0,0 @@ -require 'common' -require 'net/ssh/transport/hmac/none' - -module Transport; module HMAC - - class TestNone < Test::Unit::TestCase - def test_expected_digest_class - assert_equal nil, subject.digest_class - assert_equal nil, subject.new.digest_class - end - - def test_expected_key_length - assert_equal 0, subject.key_length - assert_equal 0, subject.new.key_length - end - - def test_expected_mac_length - assert_equal 0, subject.mac_length - assert_equal 0, subject.new.mac_length - end - - def test_expected_digest - hmac = subject.new("1234567890123456") - assert_equal "", hmac.digest("hello world") - end - - private - - def subject - Net::SSH::Transport::HMAC::None - end - end - -end; end \ No newline at end of file diff --git a/vendor/gems/net-ssh-2.0.15/test/transport/hmac/test_sha1.rb b/vendor/gems/net-ssh-2.0.15/test/transport/hmac/test_sha1.rb deleted file mode 100644 index 4be100a88..000000000 --- a/vendor/gems/net-ssh-2.0.15/test/transport/hmac/test_sha1.rb +++ /dev/null @@ -1,34 +0,0 @@ -require 'common' -require 'net/ssh/transport/hmac/sha1' - -module Transport; module HMAC - - class TestSHA1 < Test::Unit::TestCase - def test_expected_digest_class - assert_equal OpenSSL::Digest::SHA1, subject.digest_class - assert_equal OpenSSL::Digest::SHA1, subject.new.digest_class - end - - def test_expected_key_length - assert_equal 20, subject.key_length - assert_equal 20, subject.new.key_length - end - - def test_expected_mac_length - assert_equal 20, subject.mac_length - assert_equal 20, subject.new.mac_length - end - - def test_expected_digest - hmac = subject.new("1234567890123456") - assert_equal "\000\004W\202\204+&\335\311\251P\266\250\214\276\206;\022U\365", hmac.digest("hello world") - end - - private - - def subject - Net::SSH::Transport::HMAC::SHA1 - end - end - -end; end \ No newline at end of file diff --git a/vendor/gems/net-ssh-2.0.15/test/transport/hmac/test_sha1_96.rb b/vendor/gems/net-ssh-2.0.15/test/transport/hmac/test_sha1_96.rb deleted file mode 100644 index 866e15a2d..000000000 --- a/vendor/gems/net-ssh-2.0.15/test/transport/hmac/test_sha1_96.rb +++ /dev/null @@ -1,25 +0,0 @@ -require 'common' -require 'transport/hmac/test_sha1' -require 'net/ssh/transport/hmac/sha1_96' - -module Transport; module HMAC - - class TestSHA1_96 < TestSHA1 - def test_expected_mac_length - assert_equal 12, subject.mac_length - assert_equal 12, subject.new.mac_length - end - - def test_expected_digest - hmac = subject.new("1234567890123456") - assert_equal "\000\004W\202\204+&\335\311\251P\266", hmac.digest("hello world") - end - - private - - def subject - Net::SSH::Transport::HMAC::SHA1_96 - end - end - -end; end \ No newline at end of file diff --git a/vendor/gems/net-ssh-2.0.15/test/transport/kex/test_diffie_hellman_group1_sha1.rb b/vendor/gems/net-ssh-2.0.15/test/transport/kex/test_diffie_hellman_group1_sha1.rb deleted file mode 100644 index 619b71620..000000000 --- a/vendor/gems/net-ssh-2.0.15/test/transport/kex/test_diffie_hellman_group1_sha1.rb +++ /dev/null @@ -1,146 +0,0 @@ -require 'common' -require 'net/ssh/transport/kex/diffie_hellman_group1_sha1' -require 'ostruct' - -module Transport; module Kex - - class TestDiffieHellmanGroup1SHA1 < Test::Unit::TestCase - include Net::SSH::Transport::Constants - - def setup - @dh_options = @dh = @algorithms = @connection = @server_key = - @packet_data = @shared_secret = nil - end - - def test_exchange_keys_should_return_expected_results_when_successful - result = exchange! - assert_equal session_id, result[:session_id] - assert_equal server_key.to_blob, result[:server_key].to_blob - assert_equal shared_secret, result[:shared_secret] - assert_equal OpenSSL::Digest::SHA1, result[:hashing_algorithm] - end - - def test_exchange_keys_with_unverifiable_host_should_raise_exception - connection.verifier { false } - assert_raises(Net::SSH::Exception) { exchange! } - end - - def test_exchange_keys_with_signature_key_type_mismatch_should_raise_exception - assert_raises(Net::SSH::Exception) { exchange! :key_type => "ssh-dss" } - end - - def test_exchange_keys_with_host_key_type_mismatch_should_raise_exception - algorithms :host_key => "ssh-dss" - assert_raises(Net::SSH::Exception) { exchange! :key_type => "ssh-dss" } - end - - def test_exchange_keys_when_server_signature_could_not_be_verified_should_raise_exception - @signature = "1234567890" - assert_raises(Net::SSH::Exception) { exchange! } - end - - def test_exchange_keys_should_pass_expected_parameters_to_host_key_verifier - verified = false - connection.verifier do |data| - verified = true - assert_equal server_key.to_blob, data[:key].to_blob - - blob = b(:key, data[:key]).to_s - fingerprint = OpenSSL::Digest::MD5.hexdigest(blob).scan(/../).join(":") - - assert_equal blob, data[:key_blob] - assert_equal fingerprint, data[:fingerprint] - assert_equal connection, data[:session] - - true - end - - assert_nothing_raised { exchange! } - assert verified - end - - private - - def exchange!(options={}) - connection.expect do |t, buffer| - assert_equal KEXDH_INIT, buffer.type - assert_equal dh.dh.pub_key, buffer.read_bignum - t.return(KEXDH_REPLY, :string, b(:key, server_key), :bignum, server_dh_pubkey, :string, b(:string, options[:key_type] || "ssh-rsa", :string, signature)) - connection.expect do |t2, buffer2| - assert_equal NEWKEYS, buffer2.type - t2.return(NEWKEYS) - end - end - - dh.exchange_keys - end - - def dh_options(options={}) - @dh_options = options - end - - def dh - @dh ||= subject.new(algorithms, connection, packet_data.merge(:need_bytes => 20).merge(@dh_options || {})) - end - - def algorithms(options={}) - @algorithms ||= OpenStruct.new(:host_key => options[:host_key] || "ssh-rsa") - end - - def connection - @connection ||= MockTransport.new - end - - def subject - Net::SSH::Transport::Kex::DiffieHellmanGroup1SHA1 - end - - # 368 bits is the smallest possible key that will work with this, so - # we use it for speed reasons - def server_key(bits=368) - @server_key ||= OpenSSL::PKey::RSA.new(bits) - end - - def packet_data - @packet_data ||= { :client_version_string => "client version string", - :server_version_string => "server version string", - :server_algorithm_packet => "server algorithm packet", - :client_algorithm_packet => "client algorithm packet" } - end - - def server_dh_pubkey - @server_dh_pubkey ||= bn(1234567890) - end - - def shared_secret - @shared_secret ||= OpenSSL::BN.new(dh.dh.compute_key(server_dh_pubkey), 2) - end - - def session_id - @session_id ||= begin - buffer = Net::SSH::Buffer.from(:string, packet_data[:client_version_string], - :string, packet_data[:server_version_string], - :string, packet_data[:client_algorithm_packet], - :string, packet_data[:server_algorithm_packet], - :string, Net::SSH::Buffer.from(:key, server_key), - :bignum, dh.dh.pub_key, - :bignum, server_dh_pubkey, - :bignum, shared_secret) - OpenSSL::Digest::SHA1.digest(buffer.to_s) - end - end - - def signature - @signature ||= server_key.ssh_do_sign(session_id) - end - - def bn(number, base=10) - OpenSSL::BN.new(number.to_s, base) - end - - def b(*args) - Net::SSH::Buffer.from(*args) - end - end - -end; end \ No newline at end of file diff --git a/vendor/gems/net-ssh-2.0.15/test/transport/kex/test_diffie_hellman_group_exchange_sha1.rb b/vendor/gems/net-ssh-2.0.15/test/transport/kex/test_diffie_hellman_group_exchange_sha1.rb deleted file mode 100644 index dc5a2bc1b..000000000 --- a/vendor/gems/net-ssh-2.0.15/test/transport/kex/test_diffie_hellman_group_exchange_sha1.rb +++ /dev/null @@ -1,92 +0,0 @@ -require 'common' -require 'transport/kex/test_diffie_hellman_group1_sha1' -require 'net/ssh/transport/kex/diffie_hellman_group_exchange_sha1' - -module Transport; module Kex - - class TestDiffieHellmanGroupExchangeSHA1 < TestDiffieHellmanGroup1SHA1 - KEXDH_GEX_GROUP = 31 - KEXDH_GEX_INIT = 32 - KEXDH_GEX_REPLY = 33 - KEXDH_GEX_REQUEST = 34 - - def test_exchange_with_fewer_than_minimum_bits_uses_minimum_bits - dh_options :need_bytes => 20 - assert_equal 1024, need_bits - assert_nothing_raised { exchange! } - end - - def test_exchange_with_fewer_than_maximum_bits_uses_need_bits - dh_options :need_bytes => 500 - need_bits(4000) - assert_nothing_raised { exchange! } - end - - def test_exchange_with_more_than_maximum_bits_uses_maximum_bits - dh_options :need_bytes => 2000 - need_bits(8192) - assert_nothing_raised { exchange! } - end - - def test_that_p_and_g_are_provided_by_the_server - assert_nothing_raised { exchange! :p => default_p+2, :g => 3 } - assert_equal default_p+2, dh.dh.p - assert_equal 3, dh.dh.g - end - - private - - def need_bits(bits=1024) - @need_bits ||= bits - end - - def default_p - 142326151570335518660743995281621698377057354949884468943021767573608899048361360422513557553514790045512299468953431585300812548859419857171094366358158903433167915517332113861059747425408670144201099811846875730766487278261498262568348338476437200556998366087779709990807518291581860338635288400119315130179 - end - - def exchange!(options={}) - connection.expect do |t, buffer| - assert_equal KEXDH_GEX_REQUEST, buffer.type - assert_equal 1024, buffer.read_long - assert_equal need_bits, buffer.read_long - assert_equal 8192, buffer.read_long - t.return(KEXDH_GEX_GROUP, :bignum, bn(options[:p] || default_p), :bignum, bn(options[:g] || 2)) - t.expect do |t2, buffer2| - assert_equal KEXDH_GEX_INIT, buffer2.type - assert_equal dh.dh.pub_key, buffer2.read_bignum - t2.return(KEXDH_GEX_REPLY, :string, b(:key, server_key), :bignum, server_dh_pubkey, :string, b(:string, options[:key_type] || "ssh-rsa", :string, signature)) - t2.expect do |t3, buffer3| - assert_equal NEWKEYS, buffer3.type - t3.return(NEWKEYS) - end - end - end - - dh.exchange_keys - end - - def subject - Net::SSH::Transport::Kex::DiffieHellmanGroupExchangeSHA1 - end - - def session_id - @session_id ||= begin - buffer = Net::SSH::Buffer.from(:string, packet_data[:client_version_string], - :string, packet_data[:server_version_string], - :string, packet_data[:client_algorithm_packet], - :string, packet_data[:server_algorithm_packet], - :string, Net::SSH::Buffer.from(:key, server_key), - :long, 1024, - :long, need_bits, # need bits, figure this part out, - :long, 8192, - :bignum, dh.dh.p, - :bignum, dh.dh.g, - :bignum, dh.dh.pub_key, - :bignum, server_dh_pubkey, - :bignum, shared_secret) - OpenSSL::Digest::SHA1.digest(buffer.to_s) - end - end - end - -end; end \ No newline at end of file diff --git a/vendor/gems/net-ssh-2.0.15/test/transport/test_algorithms.rb b/vendor/gems/net-ssh-2.0.15/test/transport/test_algorithms.rb deleted file mode 100644 index 4a864ec47..000000000 --- a/vendor/gems/net-ssh-2.0.15/test/transport/test_algorithms.rb +++ /dev/null @@ -1,302 +0,0 @@ -require 'common' -require 'net/ssh/transport/algorithms' - -module Transport - - class TestAlgorithms < Test::Unit::TestCase - include Net::SSH::Transport::Constants - - def test_allowed_packets - (0..255).each do |type| - packet = stub("packet", :type => type) - case type - when 1..4, 6..19, 21..49 then assert(Net::SSH::Transport::Algorithms.allowed_packet?(packet), "#{type} should be allowed during key exchange") - else assert(!Net::SSH::Transport::Algorithms.allowed_packet?(packet), "#{type} should not be allowed during key exchange") - end - end - end - - def test_constructor_should_build_default_list_of_preferred_algorithms - assert_equal %w(ssh-rsa ssh-dss), algorithms[:host_key] - assert_equal %w(diffie-hellman-group-exchange-sha1 diffie-hellman-group1-sha1), algorithms[:kex] - assert_equal %w(aes128-cbc 3des-cbc blowfish-cbc cast128-cbc aes192-cbc aes256-cbc rijndael-cbc@lysator.liu.se idea-cbc none arcfour128 arcfour256), algorithms[:encryption] - assert_equal %w(hmac-sha1 hmac-md5 hmac-sha1-96 hmac-md5-96 none), algorithms[:hmac] - assert_equal %w(none zlib@openssh.com zlib), algorithms[:compression] - assert_equal %w(), algorithms[:language] - end - - def test_constructor_should_set_client_and_server_prefs_identically - %w(encryption hmac compression language).each do |key| - assert_equal algorithms[key.to_sym], algorithms[:"#{key}_client"], key - assert_equal algorithms[key.to_sym], algorithms[:"#{key}_server"], key - end - end - - def test_constructor_with_preferred_host_key_type_should_put_preferred_host_key_type_first - assert_equal %w(ssh-dss ssh-rsa), algorithms(:host_key => "ssh-dss")[:host_key] - end - - def test_constructor_with_known_hosts_reporting_known_host_key_should_use_that_host_key_type - Net::SSH::KnownHosts.expects(:search_for).with("net.ssh.test,127.0.0.1", {}).returns([stub("key", :ssh_type => "ssh-dss")]) - assert_equal %w(ssh-dss ssh-rsa), algorithms[:host_key] - end - - def test_constructor_with_unrecognized_host_key_type_should_raise_exception - assert_raises(NotImplementedError) { algorithms(:host_key => "bogus") } - end - - def test_constructor_with_preferred_kex_should_put_preferred_kex_first - assert_equal %w(diffie-hellman-group1-sha1 diffie-hellman-group-exchange-sha1), algorithms(:kex => "diffie-hellman-group1-sha1")[:kex] - end - - def test_constructor_with_unrecognized_kex_should_raise_exception - assert_raises(NotImplementedError) { algorithms(:kex => "bogus") } - end - - def test_constructor_with_preferred_encryption_should_put_preferred_encryption_first - assert_equal %w(aes256-cbc aes128-cbc 3des-cbc blowfish-cbc cast128-cbc aes192-cbc rijndael-cbc@lysator.liu.se idea-cbc none arcfour128 arcfour256), algorithms(:encryption => "aes256-cbc")[:encryption] - end - - def test_constructor_with_multiple_preferred_encryption_should_put_all_preferred_encryption_first - assert_equal %w(aes256-cbc 3des-cbc idea-cbc aes128-cbc blowfish-cbc cast128-cbc aes192-cbc rijndael-cbc@lysator.liu.se none arcfour128 arcfour256), algorithms(:encryption => %w(aes256-cbc 3des-cbc idea-cbc))[:encryption] - end - - def test_constructor_with_unrecognized_encryption_should_raise_exception - assert_raises(NotImplementedError) { algorithms(:encryption => "bogus") } - end - - def test_constructor_with_preferred_hmac_should_put_preferred_hmac_first - assert_equal %w(hmac-md5-96 hmac-sha1 hmac-md5 hmac-sha1-96 none), algorithms(:hmac => "hmac-md5-96")[:hmac] - end - - def test_constructor_with_multiple_preferred_hmac_should_put_all_preferred_hmac_first - assert_equal %w(hmac-md5-96 hmac-sha1-96 hmac-sha1 hmac-md5 none), algorithms(:hmac => %w(hmac-md5-96 hmac-sha1-96))[:hmac] - end - - def test_constructor_with_unrecognized_hmac_should_raise_exception - assert_raises(NotImplementedError) { algorithms(:hmac => "bogus") } - end - - def test_constructor_with_preferred_compression_should_put_preferred_compression_first - assert_equal %w(zlib none zlib@openssh.com), algorithms(:compression => "zlib")[:compression] - end - - def test_constructor_with_multiple_preferred_compression_should_put_all_preferred_compression_first - assert_equal %w(zlib@openssh.com zlib none), algorithms(:compression => %w(zlib@openssh.com zlib))[:compression] - end - - def test_constructor_with_general_preferred_compression_should_put_none_last - assert_equal %w(zlib@openssh.com zlib none), algorithms(:compression => true)[:compression] - end - - def test_constructor_with_unrecognized_compression_should_raise_exception - assert_raises(NotImplementedError) { algorithms(:compression => "bogus") } - end - - def test_initial_state_should_be_neither_pending_nor_initialized - assert !algorithms.pending? - assert !algorithms.initialized? - end - - def test_key_exchange_when_initiated_by_server - transport.expect do |t, buffer| - assert_kexinit(buffer) - install_mock_key_exchange(buffer) - end - - install_mock_algorithm_lookups - algorithms.accept_kexinit(kexinit) - - assert_exchange_results - end - - def test_key_exchange_when_initiated_by_client - state = nil - transport.expect do |t, buffer| - assert_kexinit(buffer) - state = :sent_kexinit - install_mock_key_exchange(buffer) - end - - algorithms.rekey! - assert_equal state, :sent_kexinit - assert algorithms.pending? - - install_mock_algorithm_lookups - algorithms.accept_kexinit(kexinit) - - assert_exchange_results - end - - def test_key_exchange_when_server_does_not_support_preferred_kex_should_fallback_to_secondary - kexinit :kex => "diffie-hellman-group1-sha1" - transport.expect do |t,buffer| - assert_kexinit(buffer) - install_mock_key_exchange(buffer, :kex => Net::SSH::Transport::Kex::DiffieHellmanGroup1SHA1) - end - algorithms.accept_kexinit(kexinit) - end - - def test_key_exchange_when_server_does_not_support_any_preferred_kex_should_raise_error - kexinit :kex => "something-obscure" - transport.expect { |t,buffer| assert_kexinit(buffer) } - assert_raises(Net::SSH::Exception) { algorithms.accept_kexinit(kexinit) } - end - - def test_allow_when_not_pending_should_be_true_for_all_packets - (0..255).each do |type| - packet = stub("packet", :type => type) - assert algorithms.allow?(packet), type - end - end - - def test_allow_when_pending_should_be_true_only_for_packets_valid_during_key_exchange - transport.expect! - algorithms.rekey! - assert algorithms.pending? - - (0..255).each do |type| - packet = stub("packet", :type => type) - case type - when 1..4, 6..19, 21..49 then assert(algorithms.allow?(packet), "#{type} should be allowed during key exchange") - else assert(!algorithms.allow?(packet), "#{type} should not be allowed during key exchange") - end - end - end - - def test_exchange_with_zlib_compression_enabled_sets_compression_to_standard - algorithms :compression => "zlib" - - transport.expect do |t, buffer| - assert_kexinit(buffer, :compression_client => "zlib,none,zlib@openssh.com", :compression_server => "zlib,none,zlib@openssh.com") - install_mock_key_exchange(buffer) - end - - install_mock_algorithm_lookups - algorithms.accept_kexinit(kexinit) - - assert_equal :standard, transport.client_options[:compression] - assert_equal :standard, transport.server_options[:compression] - end - - def test_exchange_with_zlib_at_openssh_dot_com_compression_enabled_sets_compression_to_delayed - algorithms :compression => "zlib@openssh.com" - - transport.expect do |t, buffer| - assert_kexinit(buffer, :compression_client => "zlib@openssh.com,none,zlib", :compression_server => "zlib@openssh.com,none,zlib") - install_mock_key_exchange(buffer) - end - - install_mock_algorithm_lookups - algorithms.accept_kexinit(kexinit) - - assert_equal :delayed, transport.client_options[:compression] - assert_equal :delayed, transport.server_options[:compression] - end - - private - - def install_mock_key_exchange(buffer, options={}) - kex = options[:kex] || Net::SSH::Transport::Kex::DiffieHellmanGroupExchangeSHA1 - - Net::SSH::Transport::Kex::MAP.each do |name, klass| - next if klass == kex - klass.expects(:new).never - end - - kex.expects(:new). - with(algorithms, transport, - :client_version_string => Net::SSH::Transport::ServerVersion::PROTO_VERSION, - :server_version_string => transport.server_version.version, - :server_algorithm_packet => kexinit.to_s, - :client_algorithm_packet => buffer.to_s, - :need_bytes => 20, - :logger => nil). - returns(stub("kex", :exchange_keys => { :shared_secret => shared_secret, :session_id => session_id, :hashing_algorithm => hashing_algorithm })) - end - - def install_mock_algorithm_lookups(options={}) - Net::SSH::Transport::CipherFactory.expects(:get). - with(options[:client_cipher] || "aes128-cbc", :iv => key("A"), :key => key("C"), :shared => shared_secret.to_ssh, :hash => session_id, :digester => hashing_algorithm, :encrypt => true). - returns(:client_cipher) - Net::SSH::Transport::CipherFactory.expects(:get). - with(options[:server_cipher] || "aes128-cbc", :iv => key("B"), :key => key("D"), :shared => shared_secret.to_ssh, :hash => session_id, :digester => hashing_algorithm, :decrypt => true). - returns(:server_cipher) - - Net::SSH::Transport::HMAC.expects(:get).with(options[:client_hmac] || "hmac-sha1", key("E")).returns(:client_hmac) - Net::SSH::Transport::HMAC.expects(:get).with(options[:server_hmac] || "hmac-sha1", key("F")).returns(:server_hmac) - end - - def shared_secret - @shared_secret ||= OpenSSL::BN.new("1234567890", 10) - end - - def session_id - @session_id ||= "this is the session id" - end - - def hashing_algorithm - OpenSSL::Digest::SHA1 - end - - def key(salt) - hashing_algorithm.digest(shared_secret.to_ssh + session_id + salt + session_id) - end - - def cipher(type, options={}) - Net::SSH::Transport::CipherFactory.get(type, options) - end - - def kexinit(options={}) - @kexinit ||= P(:byte, KEXINIT, - :long, rand(0xFFFFFFFF), :long, rand(0xFFFFFFFF), :long, rand(0xFFFFFFFF), :long, rand(0xFFFFFFFF), - :string, options[:kex] || "diffie-hellman-group-exchange-sha1,diffie-hellman-group1-sha1", - :string, options[:host_key] || "ssh-rsa,ssh-dss", - :string, options[:encryption_client] || "aes128-cbc,3des-cbc,blowfish-cbc,cast128-cbc,aes192-cbc,aes256-cbc,rijndael-cbc@lysator.liu.se,idea-cbc", - :string, options[:encryption_server] || "aes128-cbc,3des-cbc,blowfish-cbc,cast128-cbc,aes192-cbc,aes256-cbc,rijndael-cbc@lysator.liu.se,idea-cbc", - :string, options[:hmac_client] || "hmac-sha1,hmac-md5,hmac-sha1-96,hmac-md5-96", - :string, options[:hmac_server] || "hmac-sha1,hmac-md5,hmac-sha1-96,hmac-md5-96", - :string, options[:compmression_client] || "none,zlib@openssh.com,zlib", - :string, options[:compmression_server] || "none,zlib@openssh.com,zlib", - :string, options[:language_client] || "", - :string, options[:langauge_server] || "", - :bool, options[:first_kex_follows]) - end - - def assert_kexinit(buffer, options={}) - assert_equal KEXINIT, buffer.type - assert_equal 16, buffer.read(16).length - assert_equal options[:kex] || "diffie-hellman-group-exchange-sha1,diffie-hellman-group1-sha1", buffer.read_string - assert_equal options[:host_key] || "ssh-rsa,ssh-dss", buffer.read_string - assert_equal options[:encryption_client] || "aes128-cbc,3des-cbc,blowfish-cbc,cast128-cbc,aes192-cbc,aes256-cbc,rijndael-cbc@lysator.liu.se,idea-cbc,none,arcfour128,arcfour256", buffer.read_string - assert_equal options[:encryption_server] || "aes128-cbc,3des-cbc,blowfish-cbc,cast128-cbc,aes192-cbc,aes256-cbc,rijndael-cbc@lysator.liu.se,idea-cbc,none,arcfour128,arcfour256", buffer.read_string - assert_equal options[:hmac_client] || "hmac-sha1,hmac-md5,hmac-sha1-96,hmac-md5-96,none", buffer.read_string - assert_equal options[:hmac_server] || "hmac-sha1,hmac-md5,hmac-sha1-96,hmac-md5-96,none", buffer.read_string - assert_equal options[:compression_client] || "none,zlib@openssh.com,zlib", buffer.read_string - assert_equal options[:compression_server] || "none,zlib@openssh.com,zlib", buffer.read_string - assert_equal options[:language_client] || "", buffer.read_string - assert_equal options[:language_server] || "", buffer.read_string - assert_equal options[:first_kex_follows] || false, buffer.read_bool - end - - def assert_exchange_results - assert algorithms.initialized? - assert !algorithms.pending? - assert !transport.client_options[:compression] - assert !transport.server_options[:compression] - assert_equal :client_cipher, transport.client_options[:cipher] - assert_equal :server_cipher, transport.server_options[:cipher] - assert_equal :client_hmac, transport.client_options[:hmac] - assert_equal :server_hmac, transport.server_options[:hmac] - end - - def algorithms(options={}) - @algorithms ||= Net::SSH::Transport::Algorithms.new(transport, options) - end - - def transport - @transport ||= MockTransport.new - end - end - -end \ No newline at end of file diff --git a/vendor/gems/net-ssh-2.0.15/test/transport/test_cipher_factory.rb b/vendor/gems/net-ssh-2.0.15/test/transport/test_cipher_factory.rb deleted file mode 100644 index bdb0f4d6d..000000000 --- a/vendor/gems/net-ssh-2.0.15/test/transport/test_cipher_factory.rb +++ /dev/null @@ -1,213 +0,0 @@ -require 'common' -require 'net/ssh/transport/cipher_factory' - -module Transport - - class TestCipherFactory < Test::Unit::TestCase - def self.if_supported?(name) - yield if Net::SSH::Transport::CipherFactory.supported?(name) - end - - def test_lengths_for_none - assert_equal [0,0], factory.get_lengths("none") - assert_equal [0,0], factory.get_lengths("bogus") - end - - def test_lengths_for_blowfish_cbc - assert_equal [16,8], factory.get_lengths("blowfish-cbc") - end - - if_supported?("idea-cbc") do - def test_lengths_for_idea_cbc - assert_equal [16,8], factory.get_lengths("idea-cbc") - end - end - - def test_lengths_for_rijndael_cbc - assert_equal [32,16], factory.get_lengths("rijndael-cbc@lysator.liu.se") - end - - def test_lengths_for_cast128_cbc - assert_equal [16,8], factory.get_lengths("cast128-cbc") - end - - def test_lengths_for_3des_cbc - assert_equal [24,8], factory.get_lengths("3des-cbc") - end - - def test_lengths_for_aes192_cbc - assert_equal [24,16], factory.get_lengths("aes192-cbc") - end - - def test_lengths_for_aes128_cbc - assert_equal [16,16], factory.get_lengths("aes128-cbc") - end - - def test_lengths_for_aes256_cbc - assert_equal [32,16], factory.get_lengths("aes256-cbc") - end - - def test_lengths_for_arcfour128 - assert_equal [16,8], factory.get_lengths("arcfour128") - end - - def test_lengths_for_arcfour256 - assert_equal [32,8], factory.get_lengths("arcfour256") - end - - def test_lengths_for_arcfour512 - assert_equal [64,8], factory.get_lengths("arcfour512") - end - - BLOWFISH = "\210\021\200\315\240_\026$\352\204g\233\244\242x\332e\370\001\327\224Nv@9_\323\037\252kb\037\036\237\375]\343/y\037\237\312Q\f7]\347Y\005\275%\377\0010$G\272\250B\265Nd\375\342\372\025r6}+Y\213y\n\237\267\\\374^\346BdJ$\353\220Ik\023<\236&H\277=\225" - - def test_blowfish_cbc_for_encryption - assert_equal BLOWFISH, encrypt("blowfish-cbc") - end - - def test_blowfish_cbc_for_decryption - assert_equal TEXT, decrypt("blowfish-cbc", BLOWFISH) - end - - if_supported?("idea-cbc") do - IDEA = "W\234\017G\231\b\357\370H\b\256U]\343M\031k\233]~\023C\363\263\177\262-\261\341$\022\376mv\217\322\b\2763\270H\306\035\343z\313\312\3531\351\t\201\302U\022\360\300\354ul7$z\320O]\360g\024\305\005`V\005\335A\351\312\270c\320D\232\eQH1\340\265\2118\031g*\303v" - - def test_idea_cbc_for_encryption - assert_equal IDEA, encrypt("idea-cbc") - end - - def test_idea_cbc_for_decryption - assert_equal TEXT, decrypt("idea-cbc", IDEA) - end - end - - RIJNDAEL = "$\253\271\255\005Z\354\336&\312\324\221\233\307Mj\315\360\310Fk\241EfN\037\231\213\361{'\310\204\347I\343\271\005\240`\325;\034\346uM>#\241\231C`\374\261\vo\226;Z\302:\b\250\366T\330\\#V\330\340\226\363\374!\bm\266\232\207!\232\347\340\t\307\370\356z\236\343=v\210\206y" - - def test_rijndael_cbc_for_encryption - assert_equal RIJNDAEL, encrypt("rijndael-cbc@lysator.liu.se") - end - - def test_rijndael_cbc_for_decryption - assert_equal TEXT, decrypt("rijndael-cbc@lysator.liu.se", RIJNDAEL) - end - - CAST128 = "qW\302\331\333P\223t[9 ~(sg\322\271\227\272\022I\223\373p\255>k\326\314\260\2003\236C_W\211\227\373\205>\351\334\322\227\223\e\236\202Ii\032!P\214\035:\017\360h7D\371v\210\264\317\236a\262w1\2772\023\036\331\227\240:\f/X\351\324I\t[x\350\323E\2301\016m" - - def test_cast128_cbc_for_encryption - assert_equal CAST128, encrypt("cast128-cbc") - end - - def test_cast128_cbc_for_decryption - assert_equal TEXT, decrypt("cast128-cbc", CAST128) - end - - TRIPLE_DES = "\322\252\216D\303Q\375gg\367A{\177\313\3436\272\353%\223K?\257\206|\r&\353/%\340\336 \203E8rY\206\234\004\274\267\031\233T/{\"\227/B!i?[qGaw\306T\206\223\213n \212\032\244%]@\355\250\334\312\265E\251\017\361\270\357\230\274KP&^\031r+r%\370" - - def test_3des_cbc_for_encryption - assert_equal TRIPLE_DES, encrypt("3des-cbc") - end - - def test_3des_cbc_for_decryption - assert_equal TEXT, decrypt("3des-cbc", TRIPLE_DES) - end - - AES128 = "k\026\350B\366-k\224\313\3277}B\035\004\200\035\r\233\024$\205\261\231Q\2214r\245\250\360\315\237\266hg\262C&+\321\346Pf\267v\376I\215P\327\345-\232&HK\375\326_\030<\a\276\212\303g\342C\242O\233\260\006\001a&V\345`\\T\e\236.\207\223l\233ri^\v\252\363\245" - - def test_aes128_cbc_for_encryption - assert_equal AES128, encrypt("aes128-cbc") - end - - def test_aes128_cbc_for_decryption - assert_equal TEXT, decrypt("aes128-cbc", AES128) - end - - AES192 = "\256\017)x\270\213\336\303L\003f\235'jQ\3231k9\225\267\242\364C4\370\224\201\302~\217I\202\374\2167='\272\037\225\223\177Y\r\212\376(\275\n\3553\377\177\252C\254\236\016MA\274Z@H\331<\rL\317\205\323[\305X8\376\237=\374\352bH9\244\0231\353\204\352p\226\326~J\242" - - def test_aes192_cbc_for_encryption - assert_equal AES192, encrypt("aes192-cbc") - end - - def test_aes192_cbc_for_decryption - assert_equal TEXT, decrypt("aes192-cbc", AES192) - end - - AES256 = "$\253\271\255\005Z\354\336&\312\324\221\233\307Mj\315\360\310Fk\241EfN\037\231\213\361{'\310\204\347I\343\271\005\240`\325;\034\346uM>#\241\231C`\374\261\vo\226;Z\302:\b\250\366T\330\\#V\330\340\226\363\374!\bm\266\232\207!\232\347\340\t\307\370\356z\236\343=v\210\206y" - - def test_aes256_cbc_for_encryption - assert_equal AES256, encrypt("aes256-cbc") - end - - def test_aes256_cbc_for_decryption - assert_equal TEXT, decrypt("aes256-cbc", AES256) - end - - ARCFOUR128 = "\n\x90\xED*\xD4\xBE\xCBg5\xA5\a\xEC]\x97\xB7L\x06)6\x12FL\x90@\xF4Sqxqh\r\x11\x1Aq \xC8\xE6v\xC6\x12\xD9 "ABC", - :key => "abc", - :digester => OpenSSL::Digest::MD5, - :shared => "1234567890123456780", - :hash => '!@#$%#$^%$&^&%#$@$' - } - - def factory - Net::SSH::Transport::CipherFactory - end - - def encrypt(type) - cipher = factory.get(type, OPTIONS.merge(:encrypt => true)) - padding = TEXT.length % cipher.block_size - result = cipher.update(TEXT.dup) - result << cipher.update(" " * (cipher.block_size - padding)) if padding > 0 - result << cipher.final - end - - def decrypt(type, data) - cipher = factory.get(type, OPTIONS.merge(:decrypt => true)) - result = cipher.update(data.dup) - result << cipher.final - result.strip - end - end - -end diff --git a/vendor/gems/net-ssh-2.0.15/test/transport/test_hmac.rb b/vendor/gems/net-ssh-2.0.15/test/transport/test_hmac.rb deleted file mode 100644 index 51ba7aeea..000000000 --- a/vendor/gems/net-ssh-2.0.15/test/transport/test_hmac.rb +++ /dev/null @@ -1,34 +0,0 @@ -require 'common' -require 'net/ssh/transport/hmac' - -module Transport - - class TestHMAC < Test::Unit::TestCase - Net::SSH::Transport::HMAC::MAP.each do |name, value| - method = name.tr("-", "_") - define_method("test_get_with_#{method}_returns_new_hmac_instance") do - key = "abcdefghijklmnopqrstuvwxyz"[0,Net::SSH::Transport::HMAC::MAP[name].key_length] - hmac = Net::SSH::Transport::HMAC.get(name, key) - assert_instance_of Net::SSH::Transport::HMAC::MAP[name], hmac - assert_equal key, hmac.key - end - - define_method("test_key_length_with_#{method}_returns_correct_key_length") do - assert_equal Net::SSH::Transport::HMAC::MAP[name].key_length, Net::SSH::Transport::HMAC.key_length(name) - end - end - - def test_get_with_unrecognized_hmac_raises_argument_error - assert_raises(ArgumentError) do - Net::SSH::Transport::HMAC.get("bogus") - end - end - - def test_key_length_with_unrecognized_hmac_raises_argument_error - assert_raises(ArgumentError) do - Net::SSH::Transport::HMAC.get("bogus") - end - end - end - -end \ No newline at end of file diff --git a/vendor/gems/net-ssh-2.0.15/test/transport/test_identity_cipher.rb b/vendor/gems/net-ssh-2.0.15/test/transport/test_identity_cipher.rb deleted file mode 100644 index 6bfcce046..000000000 --- a/vendor/gems/net-ssh-2.0.15/test/transport/test_identity_cipher.rb +++ /dev/null @@ -1,40 +0,0 @@ -require 'common' -require 'net/ssh/transport/identity_cipher' - -module Transport - - class TestIdentityCipher < Test::Unit::TestCase - - def test_block_size_should_be_8 - assert_equal 8, cipher.block_size - end - - def test_encrypt_should_return_self - assert_equal cipher, cipher.encrypt - end - - def test_decrypt_should_return_self - assert_equal cipher, cipher.decrypt - end - - def test_update_should_return_argument - assert_equal "hello, world", cipher.update("hello, world") - end - - def test_final_should_return_empty_string - assert_equal "", cipher.final - end - - def test_name_should_be_identity - assert_equal "identity", cipher.name - end - - private - - def cipher - Net::SSH::Transport::IdentityCipher - end - - end - -end diff --git a/vendor/gems/net-ssh-2.0.15/test/transport/test_packet_stream.rb b/vendor/gems/net-ssh-2.0.15/test/transport/test_packet_stream.rb deleted file mode 100644 index fc713fc93..000000000 --- a/vendor/gems/net-ssh-2.0.15/test/transport/test_packet_stream.rb +++ /dev/null @@ -1,441 +0,0 @@ -require 'common' -require 'net/ssh/transport/packet_stream' - -module Transport - - class TestPacketStream < Test::Unit::TestCase - include Net::SSH::Transport::Constants - - def test_client_name_when_getnameinfo_works - stream.expects(:getsockname).returns(:sockaddr) - Socket.expects(:getnameinfo).with(:sockaddr, Socket::NI_NAMEREQD).returns(["net.ssh.test"]) - assert_equal "net.ssh.test", stream.client_name - end - - def test_client_name_when_getnameinfo_fails_first_and_then_works - stream.expects(:getsockname).returns(:sockaddr) - Socket.expects(:getnameinfo).with(:sockaddr, Socket::NI_NAMEREQD).raises(SocketError) - Socket.expects(:getnameinfo).with(:sockaddr).returns(["1.2.3.4"]) - assert_equal "1.2.3.4", stream.client_name - end - - def test_client_name_when_getnameinfo_fails_but_gethostbyname_works - stream.expects(:getsockname).returns(:sockaddr) - Socket.expects(:getnameinfo).with(:sockaddr, Socket::NI_NAMEREQD).raises(SocketError) - Socket.expects(:getnameinfo).with(:sockaddr).raises(SocketError) - Socket.expects(:gethostname).returns(:hostname) - Socket.expects(:gethostbyname).with(:hostname).returns(["net.ssh.test"]) - assert_equal "net.ssh.test", stream.client_name - end - - def test_client_name_when_getnameinfo_and_gethostbyname_all_fail - stream.expects(:getsockname).returns(:sockaddr) - Socket.expects(:getnameinfo).with(:sockaddr, Socket::NI_NAMEREQD).raises(SocketError) - Socket.expects(:getnameinfo).with(:sockaddr).raises(SocketError) - Socket.expects(:gethostname).returns(:hostname) - Socket.expects(:gethostbyname).with(:hostname).raises(SocketError) - assert_equal "unknown", stream.client_name - end - - def test_peer_ip_should_query_socket_for_info_about_peer - stream.expects(:getpeername).returns(:sockaddr) - Socket.expects(:getnameinfo).with(:sockaddr, Socket::NI_NUMERICHOST | Socket::NI_NUMERICSERV).returns(["1.2.3.4"]) - assert_equal "1.2.3.4", stream.peer_ip - end - - def test_available_for_read_should_return_nontrue_when_select_fails - IO.expects(:select).returns(nil) - assert !stream.available_for_read? - end - - def test_available_for_read_should_return_nontrue_when_self_is_not_ready - IO.expects(:select).with([stream], nil, nil, 0).returns([[],[],[]]) - assert !stream.available_for_read? - end - - def test_available_for_read_should_return_true_when_self_is_ready - IO.expects(:select).with([stream], nil, nil, 0).returns([[self],[],[]]) - assert stream.available_for_read? - end - - def test_cleanup_should_delegate_cleanup_to_client_and_server_states - stream.client.expects(:cleanup) - stream.server.expects(:cleanup) - stream.cleanup - end - - def test_if_needs_rekey_should_not_yield_if_neither_client_nor_server_states_need_rekey - stream.if_needs_rekey? { flunk "shouldn't need rekey" } - assert(true) - end - - def test_if_needs_rekey_should_yield_and_cleanup_if_client_needs_rekey - stream.client.stubs(:needs_rekey?).returns(true) - stream.client.expects(:reset!) - stream.server.expects(:reset!).never - rekeyed = false - stream.if_needs_rekey? { rekeyed = true } - assert(rekeyed) - end - - def test_if_needs_rekey_should_yield_and_cleanup_if_server_needs_rekey - stream.server.stubs(:needs_rekey?).returns(true) - stream.server.expects(:reset!) - stream.client.expects(:reset!).never - rekeyed = false - stream.if_needs_rekey? { rekeyed = true } - assert(rekeyed) - end - - def test_if_needs_rekey_should_yield_and_cleanup_if_both_need_rekey - stream.server.stubs(:needs_rekey?).returns(true) - stream.client.stubs(:needs_rekey?).returns(true) - stream.server.expects(:reset!) - stream.client.expects(:reset!) - rekeyed = false - stream.if_needs_rekey? { rekeyed = true } - assert(rekeyed) - end - - def test_next_packet_should_not_block_by_default - IO.expects(:select).returns(nil) - assert_nothing_raised do - timeout(1) { stream.next_packet } - end - end - - def test_next_packet_should_return_nil_when_non_blocking_and_not_ready - IO.expects(:select).returns(nil) - assert_nil stream.next_packet(:nonblock) - end - - def test_next_packet_should_return_nil_when_non_blocking_and_partial_read - IO.expects(:select).returns([[stream]]) - stream.expects(:recv).returns([8].pack("N")) - assert_nil stream.next_packet(:nonblock) - assert !stream.read_buffer.empty? - end - - def test_next_packet_should_return_packet_when_non_blocking_and_full_read - IO.expects(:select).returns([[stream]]) - stream.expects(:recv).returns(packet) - packet = stream.next_packet(:nonblock) - assert_not_nil packet - assert_equal DEBUG, packet.type - end - - def test_next_packet_should_eventually_return_packet_when_non_blocking_and_partial_read - IO.stubs(:select).returns([[stream]]) - stream.stubs(:recv).returns(packet[0,10], packet[10..-1]) - assert_nil stream.next_packet(:nonblock) - packet = stream.next_packet(:nonblock) - assert_not_nil packet - assert_equal DEBUG, packet.type - end - - def test_next_packet_should_block_when_requested_until_entire_packet_is_available - IO.stubs(:select).returns([[stream]]) - stream.stubs(:recv).returns(packet[0,10], packet[10,20], packet[20..-1]) - packet = stream.next_packet(:block) - assert_not_nil packet - assert_equal DEBUG, packet.type - end - - def test_next_packet_when_blocking_should_fail_when_fill_could_not_read_any_data - IO.stubs(:select).returns([[stream]]) - stream.stubs(:recv).returns("") - assert_raises(Net::SSH::Disconnect) { stream.next_packet(:block) } - end - - def test_next_packet_fails_with_invalid_argument - assert_raises(ArgumentError) { stream.next_packet("invalid") } - end - - def test_send_packet_should_enqueue_and_send_data_immediately - stream.expects(:send).times(3).with { |a,b| a == stream.write_buffer && b == 0 }.returns(15) - IO.expects(:select).times(2).returns([[], [stream]]) - stream.send_packet(ssh_packet) - assert !stream.pending_write? - end - - def test_enqueue_short_packet_should_ensure_packet_is_at_least_16_bytes_long - packet = Net::SSH::Buffer.from(:byte, 0) - stream.enqueue_packet(packet) - # 12 originally, plus the block-size (8), plus the 4-byte length field - assert_equal 24, stream.write_buffer.length - end - - PACKETS = { - "3des-cbc" => { - "hmac-md5" => { - false => "\003\352\031\261k\243\200\204\301\203]!\a\306\217\201\a[^\304\317\322\264\265~\361\017\n\205\272, #[\343\200Sb\377\265\322\003=S\255N\2654", - :standard => "\317\222v\316\234<\310\377\310\034\346\351\020:\025{\372PDS\246\344\312J\364\301\n\262\r<\037\231Mu\031\240\255\026\362\200A\305\027\341\261\331x\353\0372\3643h`\177\202", - }, - "hmac-md5-96" => { - false => "\003\352\031\261k\243\200\204\301\203]!\a\306\217\201\a[^\304\317\322\264\265~\361\017\n\205\272, #[\343\200Sb\377\265\322\003=S", - :standard => "\317\222v\316\234<\310\377\310\034\346\351\020:\025{\372PDS\246\344\312J\364\301\n\262\r<\037\231Mu\031\240\255\026\362\200A\305\027\341\261\331x\353\0372\3643", - }, - "hmac-sha1" => { - false => "\003\352\031\261k\243\200\204\301\203]!\a\306\217\201\a[^\304\317\322\264\265~\361\017\n\205\272, \235J\004f\262\3730t\376\273\323n\260\275\202\223\214\370D\204", - :standard => "\317\222v\316\234<\310\377\310\034\346\351\020:\025{\372PDS\246\344\312J\364\301\n\262\r<\037\231Mu\031\240\255\026\362\200\345\a{|\0367\355\2735\310'\n\342\250\246\030*1\353\330", - }, - "hmac-sha1-96" => { - false => "\003\352\031\261k\243\200\204\301\203]!\a\306\217\201\a[^\304\317\322\264\265~\361\017\n\205\272, \235J\004f\262\3730t\376\273\323n", - :standard => "\317\222v\316\234<\310\377\310\034\346\351\020:\025{\372PDS\246\344\312J\364\301\n\262\r<\037\231Mu\031\240\255\026\362\200\345\a{|\0367\355\2735\310'\n", - }, - "none" => { - false => "\003\352\031\261k\243\200\204\301\203]!\a\306\217\201\a[^\304\317\322\264\265~\361\017\n\205\272, ", - :standard => "\317\222v\316\234<\310\377\310\034\346\351\020:\025{\372PDS\246\344\312J\364\301\n\262\r<\037\231Mu\031\240\255\026\362\200", - }, - }, - "aes128-cbc" => { - "hmac-md5" => { - false => "\240\016\243k]0\330\253\030\320\334\261(\034E\211\230#\326\374\267\311O\211E(\234\325n\306NY#[\343\200Sb\377\265\322\003=S\255N\2654", - :standard => "\273\367\324\032\3762\334\026\r\246\342\022\016\325\024\270.\273\005\314\036\312\211\261\037A\361\362:W\316\352K\204\216b\2124>A\265g\331\177\233dK\251\337\227`9L\324[bPd\253XY\205\241\310", - }, - "hmac-md5-96" => { - false => "\240\016\243k]0\330\253\030\320\334\261(\034E\211\230#\326\374\267\311O\211E(\234\325n\306NY#[\343\200Sb\377\265\322\003=S", - :standard => "\273\367\324\032\3762\334\026\r\246\342\022\016\325\024\270.\273\005\314\036\312\211\261\037A\361\362:W\316\352K\204\216b\2124>A\265g\331\177\233dK\251\337\227`9L\324[bPd\253X", - }, - "hmac-sha1" => { - false => "\240\016\243k]0\330\253\030\320\334\261(\034E\211\230#\326\374\267\311O\211E(\234\325n\306NY\235J\004f\262\3730t\376\273\323n\260\275\202\223\214\370D\204", - :standard => "\273\367\324\032\3762\334\026\r\246\342\022\016\325\024\270.\273\005\314\036\312\211\261\037A\361\362:W\316\352K\204\216b\2124>A\265g\331\177\233dK\251\314\r\224%\316I\370t\251\372]\031\322pH%\267\337r\247", - }, - "hmac-sha1-96" => { - false => "\240\016\243k]0\330\253\030\320\334\261(\034E\211\230#\326\374\267\311O\211E(\234\325n\306NY\235J\004f\262\3730t\376\273\323n", - :standard => "\273\367\324\032\3762\334\026\r\246\342\022\016\325\024\270.\273\005\314\036\312\211\261\037A\361\362:W\316\352K\204\216b\2124>A\265g\331\177\233dK\251\314\r\224%\316I\370t\251\372]\031", - }, - "none" => { - false => "\240\016\243k]0\330\253\030\320\334\261(\034E\211\230#\326\374\267\311O\211E(\234\325n\306NY", - :standard => "\273\367\324\032\3762\334\026\r\246\342\022\016\325\024\270.\273\005\314\036\312\211\261\037A\361\362:W\316\352K\204\216b\2124>A\265g\331\177\233dK\251", - }, - }, - "aes192-cbc" => { - "hmac-md5" => { - false => "P$\377\302\326\262\276\215\206\343&\257#\315>Mp\232P\345o\215\330\213\t\027\300\360\300\037\267\003#[\343\200Sb\377\265\322\003=S\255N\2654", - :standard => "se\347\230\026\311\212\250yH\241\302n\364:\276\270M=H1\317\222^\362\237D\225N\354:\343\205M\006[\313$U/yZ\330\235\032\307\320D\337\227`9L\324[bPd\253XY\205\241\310", - }, - "hmac-md5-96" => { - false => "P$\377\302\326\262\276\215\206\343&\257#\315>Mp\232P\345o\215\330\213\t\027\300\360\300\037\267\003#[\343\200Sb\377\265\322\003=S", - :standard => "se\347\230\026\311\212\250yH\241\302n\364:\276\270M=H1\317\222^\362\237D\225N\354:\343\205M\006[\313$U/yZ\330\235\032\307\320D\337\227`9L\324[bPd\253X", - }, - "hmac-sha1" => { - false => "P$\377\302\326\262\276\215\206\343&\257#\315>Mp\232P\345o\215\330\213\t\027\300\360\300\037\267\003\235J\004f\262\3730t\376\273\323n\260\275\202\223\214\370D\204", - :standard => "se\347\230\026\311\212\250yH\241\302n\364:\276\270M=H1\317\222^\362\237D\225N\354:\343\205M\006[\313$U/yZ\330\235\032\307\320D\314\r\224%\316I\370t\251\372]\031\322pH%\267\337r\247", - }, - "hmac-sha1-96" => { - false => "P$\377\302\326\262\276\215\206\343&\257#\315>Mp\232P\345o\215\330\213\t\027\300\360\300\037\267\003\235J\004f\262\3730t\376\273\323n", - :standard => "se\347\230\026\311\212\250yH\241\302n\364:\276\270M=H1\317\222^\362\237D\225N\354:\343\205M\006[\313$U/yZ\330\235\032\307\320D\314\r\224%\316I\370t\251\372]\031", - }, - "none" => { - false => "P$\377\302\326\262\276\215\206\343&\257#\315>Mp\232P\345o\215\330\213\t\027\300\360\300\037\267\003", - :standard => "se\347\230\026\311\212\250yH\241\302n\364:\276\270M=H1\317\222^\362\237D\225N\354:\343\205M\006[\313$U/yZ\330\235\032\307\320D", - }, - }, - "aes256-cbc" => { - "hmac-md5" => { - false => "\266\001oG(\201s\255[\202j\031-\354\353]\022\374\367j2\257\b#\273r\275\341\232\264\255\340#[\343\200Sb\377\265\322\003=S\255N\2654", - :standard => "\251!O/_\253\321\217e\225\202\202W\261p\r\357\357\375\231\264Y,nZ/\366\225G\256\3000\036\223\237\353\265vG\231\215cvY\236%\315\365\337\227`9L\324[bPd\253XY\205\241\310", - }, - "hmac-md5-96" => { - false => "\266\001oG(\201s\255[\202j\031-\354\353]\022\374\367j2\257\b#\273r\275\341\232\264\255\340#[\343\200Sb\377\265\322\003=S", - :standard => "\251!O/_\253\321\217e\225\202\202W\261p\r\357\357\375\231\264Y,nZ/\366\225G\256\3000\036\223\237\353\265vG\231\215cvY\236%\315\365\337\227`9L\324[bPd\253X", - }, - "hmac-sha1" => { - false => "\266\001oG(\201s\255[\202j\031-\354\353]\022\374\367j2\257\b#\273r\275\341\232\264\255\340\235J\004f\262\3730t\376\273\323n\260\275\202\223\214\370D\204", - :standard => "\251!O/_\253\321\217e\225\202\202W\261p\r\357\357\375\231\264Y,nZ/\366\225G\256\3000\036\223\237\353\265vG\231\215cvY\236%\315\365\314\r\224%\316I\370t\251\372]\031\322pH%\267\337r\247", - }, - "hmac-sha1-96" => { - false => "\266\001oG(\201s\255[\202j\031-\354\353]\022\374\367j2\257\b#\273r\275\341\232\264\255\340\235J\004f\262\3730t\376\273\323n", - :standard => "\251!O/_\253\321\217e\225\202\202W\261p\r\357\357\375\231\264Y,nZ/\366\225G\256\3000\036\223\237\353\265vG\231\215cvY\236%\315\365\314\r\224%\316I\370t\251\372]\031", - }, - "none" => { - false => "\266\001oG(\201s\255[\202j\031-\354\353]\022\374\367j2\257\b#\273r\275\341\232\264\255\340", - :standard => "\251!O/_\253\321\217e\225\202\202W\261p\r\357\357\375\231\264Y,nZ/\366\225G\256\3000\036\223\237\353\265vG\231\215cvY\236%\315\365", - }, - }, - "blowfish-cbc" => { - "hmac-md5" => { - false => "vT\353\203\247\206L\255e\371\001 6B/\234g\332\371\224l\227\257\346\373E\237C2\212u)#[\343\200Sb\377\265\322\003=S\255N\2654", - :standard => "U\257\231e\347\274\bh\016X\232h\334\v\005\316e1G$-\367##\256$rW\000\210\335_\360\f\000\205#\370\201\006A\305\027\341\261\331x\353\0372\3643h`\177\202", - }, - "hmac-md5-96" => { - false => "vT\353\203\247\206L\255e\371\001 6B/\234g\332\371\224l\227\257\346\373E\237C2\212u)#[\343\200Sb\377\265\322\003=S", - :standard => "U\257\231e\347\274\bh\016X\232h\334\v\005\316e1G$-\367##\256$rW\000\210\335_\360\f\000\205#\370\201\006A\305\027\341\261\331x\353\0372\3643", - }, - "hmac-sha1" => { - false => "vT\353\203\247\206L\255e\371\001 6B/\234g\332\371\224l\227\257\346\373E\237C2\212u)\235J\004f\262\3730t\376\273\323n\260\275\202\223\214\370D\204", - :standard => "U\257\231e\347\274\bh\016X\232h\334\v\005\316e1G$-\367##\256$rW\000\210\335_\360\f\000\205#\370\201\006\345\a{|\0367\355\2735\310'\n\342\250\246\030*1\353\330", - }, - "hmac-sha1-96" => { - false => "vT\353\203\247\206L\255e\371\001 6B/\234g\332\371\224l\227\257\346\373E\237C2\212u)\235J\004f\262\3730t\376\273\323n", - :standard => "U\257\231e\347\274\bh\016X\232h\334\v\005\316e1G$-\367##\256$rW\000\210\335_\360\f\000\205#\370\201\006\345\a{|\0367\355\2735\310'\n", - }, - "none" => { - false => "vT\353\203\247\206L\255e\371\001 6B/\234g\332\371\224l\227\257\346\373E\237C2\212u)", - :standard => "U\257\231e\347\274\bh\016X\232h\334\v\005\316e1G$-\367##\256$rW\000\210\335_\360\f\000\205#\370\201\006", - }, - }, - "cast128-cbc" => { - "hmac-md5" => { - false => "\361\026\313!\31235|w~\n\261\257\277\e\277b\246b\342\333\eE\021N\345\343m\314\272\315\376#[\343\200Sb\377\265\322\003=S\255N\2654", - :standard => "\375i\253\004\311E\2011)\220$\251A\245\f(\371\263\314\242\353\260\272\367\276\"\031\224$\244\311W\307Oe\224\0017\336\325A\305\027\341\261\331x\353\0372\3643h`\177\202", - }, - "hmac-md5-96" => { - false => "\361\026\313!\31235|w~\n\261\257\277\e\277b\246b\342\333\eE\021N\345\343m\314\272\315\376#[\343\200Sb\377\265\322\003=S", - :standard => "\375i\253\004\311E\2011)\220$\251A\245\f(\371\263\314\242\353\260\272\367\276\"\031\224$\244\311W\307Oe\224\0017\336\325A\305\027\341\261\331x\353\0372\3643", - }, - "hmac-sha1" => { - false => "\361\026\313!\31235|w~\n\261\257\277\e\277b\246b\342\333\eE\021N\345\343m\314\272\315\376\235J\004f\262\3730t\376\273\323n\260\275\202\223\214\370D\204", - :standard => "\375i\253\004\311E\2011)\220$\251A\245\f(\371\263\314\242\353\260\272\367\276\"\031\224$\244\311W\307Oe\224\0017\336\325\345\a{|\0367\355\2735\310'\n\342\250\246\030*1\353\330", - }, - "hmac-sha1-96" => { - false => "\361\026\313!\31235|w~\n\261\257\277\e\277b\246b\342\333\eE\021N\345\343m\314\272\315\376\235J\004f\262\3730t\376\273\323n", - :standard => "\375i\253\004\311E\2011)\220$\251A\245\f(\371\263\314\242\353\260\272\367\276\"\031\224$\244\311W\307Oe\224\0017\336\325\345\a{|\0367\355\2735\310'\n", - }, - "none" => { - false => "\361\026\313!\31235|w~\n\261\257\277\e\277b\246b\342\333\eE\021N\345\343m\314\272\315\376", - :standard => "\375i\253\004\311E\2011)\220$\251A\245\f(\371\263\314\242\353\260\272\367\276\"\031\224$\244\311W\307Oe\224\0017\336\325", - }, - }, - "idea-cbc" => { - "hmac-md5" => { - false => "\342\255\202$\273\201\025#\245\2341F\263\005@{\000<\266&s\016\251NH=J\322/\220 H#[\343\200Sb\377\265\322\003=S\255N\2654", - :standard => "F\3048\360\357\265\215I\021)\a\254/\315%\354M\004\330\006\356\vFr\250K\225\223x\277+Q)\022\327\311K\025\322\317A\305\027\341\261\331x\353\0372\3643h`\177\202", - }, - "hmac-md5-96" => { - false => "\342\255\202$\273\201\025#\245\2341F\263\005@{\000<\266&s\016\251NH=J\322/\220 H#[\343\200Sb\377\265\322\003=S", - :standard => "F\3048\360\357\265\215I\021)\a\254/\315%\354M\004\330\006\356\vFr\250K\225\223x\277+Q)\022\327\311K\025\322\317A\305\027\341\261\331x\353\0372\3643", - }, - "hmac-sha1" => { - false => "\342\255\202$\273\201\025#\245\2341F\263\005@{\000<\266&s\016\251NH=J\322/\220 H\235J\004f\262\3730t\376\273\323n\260\275\202\223\214\370D\204", - :standard => "F\3048\360\357\265\215I\021)\a\254/\315%\354M\004\330\006\356\vFr\250K\225\223x\277+Q)\022\327\311K\025\322\317\345\a{|\0367\355\2735\310'\n\342\250\246\030*1\353\330", - }, - "hmac-sha1-96" => { - false => "\342\255\202$\273\201\025#\245\2341F\263\005@{\000<\266&s\016\251NH=J\322/\220 H\235J\004f\262\3730t\376\273\323n", - :standard => "F\3048\360\357\265\215I\021)\a\254/\315%\354M\004\330\006\356\vFr\250K\225\223x\277+Q)\022\327\311K\025\322\317\345\a{|\0367\355\2735\310'\n", - }, - "none" => { - false => "\342\255\202$\273\201\025#\245\2341F\263\005@{\000<\266&s\016\251NH=J\322/\220 H", - :standard => "F\3048\360\357\265\215I\021)\a\254/\315%\354M\004\330\006\356\vFr\250K\225\223x\277+Q)\022\327\311K\025\322\317", - }, - }, - "none" => { - "hmac-md5" => { - false => "\000\000\000\034\b\004\001\000\000\000\tdebugging\000\000\000\000\b\030CgWO\260\212#[\343\200Sb\377\265\322\003=S\255N\2654", - :standard => "\000\000\000$\tx\234bad``\340LIM*MO\317\314K\ar\030\000\000\000\000\377\377\b\030CgWO\260\212^A\305\027\341\261\331x\353\0372\3643h`\177\202", - }, - "hmac-md5-96" => { - false => "\000\000\000\034\b\004\001\000\000\000\tdebugging\000\000\000\000\b\030CgWO\260\212#[\343\200Sb\377\265\322\003=S", - :standard => "\000\000\000$\tx\234bad``\340LIM*MO\317\314K\ar\030\000\000\000\000\377\377\b\030CgWO\260\212^A\305\027\341\261\331x\353\0372\3643", - }, - "hmac-sha1" => { - false => "\000\000\000\034\b\004\001\000\000\000\tdebugging\000\000\000\000\b\030CgWO\260\212\235J\004f\262\3730t\376\273\323n\260\275\202\223\214\370D\204", - :standard => "\000\000\000$\tx\234bad``\340LIM*MO\317\314K\ar\030\000\000\000\000\377\377\b\030CgWO\260\212^\345\a{|\0367\355\2735\310'\n\342\250\246\030*1\353\330", - }, - "hmac-sha1-96" => { - false => "\000\000\000\034\b\004\001\000\000\000\tdebugging\000\000\000\000\b\030CgWO\260\212\235J\004f\262\3730t\376\273\323n", - :standard => "\000\000\000$\tx\234bad``\340LIM*MO\317\314K\ar\030\000\000\000\000\377\377\b\030CgWO\260\212^\345\a{|\0367\355\2735\310'\n", - }, - "none" => { - false => "\000\000\000\034\b\004\001\000\000\000\tdebugging\000\000\000\000\b\030CgWO\260\212", - :standard => "\000\000\000$\tx\234bad``\340LIM*MO\317\314K\ar\030\000\000\000\000\377\377\b\030CgWO\260\212^", - }, - }, - "rijndael-cbc@lysator.liu.se" => { - "hmac-md5" => { - false => "\266\001oG(\201s\255[\202j\031-\354\353]\022\374\367j2\257\b#\273r\275\341\232\264\255\340#[\343\200Sb\377\265\322\003=S\255N\2654", - :standard => "\251!O/_\253\321\217e\225\202\202W\261p\r\357\357\375\231\264Y,nZ/\366\225G\256\3000\036\223\237\353\265vG\231\215cvY\236%\315\365\337\227`9L\324[bPd\253XY\205\241\310", - }, - "hmac-md5-96" => { - false => "\266\001oG(\201s\255[\202j\031-\354\353]\022\374\367j2\257\b#\273r\275\341\232\264\255\340#[\343\200Sb\377\265\322\003=S", - :standard => "\251!O/_\253\321\217e\225\202\202W\261p\r\357\357\375\231\264Y,nZ/\366\225G\256\3000\036\223\237\353\265vG\231\215cvY\236%\315\365\337\227`9L\324[bPd\253X", - }, - "hmac-sha1" => { - false => "\266\001oG(\201s\255[\202j\031-\354\353]\022\374\367j2\257\b#\273r\275\341\232\264\255\340\235J\004f\262\3730t\376\273\323n\260\275\202\223\214\370D\204", - :standard => "\251!O/_\253\321\217e\225\202\202W\261p\r\357\357\375\231\264Y,nZ/\366\225G\256\3000\036\223\237\353\265vG\231\215cvY\236%\315\365\314\r\224%\316I\370t\251\372]\031\322pH%\267\337r\247", - }, - "hmac-sha1-96" => { - false => "\266\001oG(\201s\255[\202j\031-\354\353]\022\374\367j2\257\b#\273r\275\341\232\264\255\340\235J\004f\262\3730t\376\273\323n", - :standard => "\251!O/_\253\321\217e\225\202\202W\261p\r\357\357\375\231\264Y,nZ/\366\225G\256\3000\036\223\237\353\265vG\231\215cvY\236%\315\365\314\r\224%\316I\370t\251\372]\031", - }, - "none" => { - false => "\266\001oG(\201s\255[\202j\031-\354\353]\022\374\367j2\257\b#\273r\275\341\232\264\255\340", - :standard => "\251!O/_\253\321\217e\225\202\202W\261p\r\357\357\375\231\264Y,nZ/\366\225G\256\3000\036\223\237\353\265vG\231\215cvY\236%\315\365", - }, - }, - } - - ciphers = Net::SSH::Transport::CipherFactory::SSH_TO_OSSL.keys - hmacs = Net::SSH::Transport::HMAC::MAP.keys - - ciphers.each do |cipher_name| - next unless Net::SSH::Transport::CipherFactory.supported?(cipher_name) - - # TODO: How are the expected packets generated? - if cipher_name =~ /arcfour/ - puts "Skipping packet stream test for #{cipher_name}" - next - end - - hmacs.each do |hmac_name| - [false, :standard].each do |compress| - cipher_method_name = cipher_name.gsub(/\W/, "_") - hmac_method_name = hmac_name.gsub(/\W/, "_") - - define_method("test_next_packet_with_#{cipher_method_name}_and_#{hmac_method_name}_and_#{compress}_compression") do - cipher = Net::SSH::Transport::CipherFactory.get(cipher_name, :key => "ABC", :iv => "abc", :shared => "123", :digester => OpenSSL::Digest::SHA1, :hash => "^&*", :decrypt => true) - hmac = Net::SSH::Transport::HMAC.get(hmac_name, "{}|") - - stream.server.set :cipher => cipher, :hmac => hmac, :compression => compress - stream.stubs(:recv).returns(PACKETS[cipher_name][hmac_name][compress]) - IO.stubs(:select).returns([[stream]]) - packet = stream.next_packet(:nonblock) - assert_not_nil packet - assert_equal DEBUG, packet.type - assert packet[:always_display] - assert_equal "debugging", packet[:message] - assert_equal "", packet[:language] - stream.cleanup - end - - define_method("test_enqueue_packet_with_#{cipher_method_name}_and_#{hmac_method_name}_and_#{compress}_compression") do - cipher = Net::SSH::Transport::CipherFactory.get(cipher_name, :key => "ABC", :iv => "abc", :shared => "123", :digester => OpenSSL::Digest::SHA1, :hash => "^&*", :encrypt => true) - hmac = Net::SSH::Transport::HMAC.get(hmac_name, "{}|") - - srand(100) - stream.client.set :cipher => cipher, :hmac => hmac, :compression => compress - stream.enqueue_packet(ssh_packet) - assert_equal stream.write_buffer, PACKETS[cipher_name][hmac_name][compress] - stream.cleanup - end - end - end - end - - private - - def stream - @stream ||= begin - stream = mock("packet_stream") - stream.extend(Net::SSH::Transport::PacketStream) - stream - end - end - - def ssh_packet - Net::SSH::Buffer.from(:byte, DEBUG, :bool, true, :string, "debugging", :string, "") - end - - def packet - @packet ||= begin - data = ssh_packet - length = data.length + 4 + 1 # length + padding length - padding = stream.server.cipher.block_size - (length % stream.server.cipher.block_size) - padding += stream.server.cipher.block_size if padding < 4 - Net::SSH::Buffer.from(:long, length + padding - 4, :byte, padding, :raw, data, :raw, "\0" * padding).to_s - end - end - end - -end \ No newline at end of file diff --git a/vendor/gems/net-ssh-2.0.15/test/transport/test_server_version.rb b/vendor/gems/net-ssh-2.0.15/test/transport/test_server_version.rb deleted file mode 100644 index c297a10cd..000000000 --- a/vendor/gems/net-ssh-2.0.15/test/transport/test_server_version.rb +++ /dev/null @@ -1,68 +0,0 @@ -require 'common' -require 'net/ssh/transport/server_version' - -module Transport - - class TestServerVersion < Test::Unit::TestCase - - def test_1_99_server_version_should_be_acceptible - s = subject(socket(true, "SSH-1.99-Testing_1.0\r\n")) - assert s.header.empty? - assert_equal "SSH-1.99-Testing_1.0", s.version - end - - def test_2_0_server_version_should_be_acceptible - s = subject(socket(true, "SSH-2.0-Testing_1.0\r\n")) - assert s.header.empty? - assert_equal "SSH-2.0-Testing_1.0", s.version - end - - def test_trailing_whitespace_should_be_preserved - # some servers, like Mocana, send a version string with trailing - # spaces, which are significant when exchanging keys later. - s = subject(socket(true, "SSH-2.0-Testing_1.0 \r\n")) - assert_equal "SSH-2.0-Testing_1.0 ", s.version - end - - def test_unacceptible_server_version_should_raise_exception - assert_raises(Net::SSH::Exception) { subject(socket(false, "SSH-1.4-Testing_1.0\r\n")) } - end - - def test_header_lines_should_be_accumulated - s = subject(socket(true, "Welcome\r\nAnother line\r\nSSH-2.0-Testing_1.0\r\n")) - assert_equal "Welcome\r\nAnother line\r\n", s.header - assert_equal "SSH-2.0-Testing_1.0", s.version - end - - def test_server_disconnect_should_raise_exception - assert_raises(Net::SSH::Disconnect) { subject(socket(false, "SSH-2.0-Aborting")) } - end - - private - - def socket(good, version_header) - socket = mock("socket") - - data = version_header.split('') - recv_times = data.length - if data[-1] != "\n" - recv_times += 1 - end - socket.expects(:recv).with(1).times(recv_times).returns(*data).then.returns(nil) - - if good - socket.expects(:write).with("#{Net::SSH::Transport::ServerVersion::PROTO_VERSION}\r\n") - socket.expects(:flush) - else - socket.expects(:write).never - end - - socket - end - - def subject(socket) - Net::SSH::Transport::ServerVersion.new(socket, nil) - end - end - -end diff --git a/vendor/gems/net-ssh-2.0.15/test/transport/test_session.rb b/vendor/gems/net-ssh-2.0.15/test/transport/test_session.rb deleted file mode 100644 index 206e134a2..000000000 --- a/vendor/gems/net-ssh-2.0.15/test/transport/test_session.rb +++ /dev/null @@ -1,315 +0,0 @@ -require 'common' -require 'net/ssh/transport/session' - -# mocha adds #verify to Object, which throws off the host-key-verifier part of -# these tests. - -# can't use .include? because ruby18 uses strings and ruby19 uses symbols :/ -if Object.instance_methods.any? { |v| v.to_sym == :verify } - Object.send(:undef_method, :verify) -end - -module Transport - - class TestSession < Test::Unit::TestCase - include Net::SSH::Transport::Constants - - def test_constructor_defaults - assert_equal "net.ssh.test", session.host - assert_equal 22, session.port - assert_instance_of Net::SSH::Verifiers::Lenient, session.host_key_verifier - end - - def test_paranoid_true_uses_lenient_verifier - assert_instance_of Net::SSH::Verifiers::Lenient, session(:paranoid => true).host_key_verifier - end - - def test_paranoid_very_uses_strict_verifier - assert_instance_of Net::SSH::Verifiers::Strict, session(:paranoid => :very).host_key_verifier - end - - def test_paranoid_false_uses_null_verifier - assert_instance_of Net::SSH::Verifiers::Null, session(:paranoid => false).host_key_verifier - end - - def test_unknown_paranoid_value_raises_exception_if_value_does_not_respond_to_verify - assert_raises(ArgumentError) { session(:paranoid => :bogus).host_key_verifier } - end - - def test_paranoid_value_responding_to_verify_should_pass_muster - object = stub("thingy", :verify => true) - assert_equal object, session(:paranoid => object).host_key_verifier - end - - def test_host_as_string_should_return_host_and_ip_when_port_is_default - session! - socket.stubs(:peer_ip).returns("1.2.3.4") - assert_equal "net.ssh.test,1.2.3.4", session.host_as_string - end - - def test_host_as_string_should_return_host_and_ip_with_port_when_port_is_not_default - session(:port => 1234) # force session to be instantiated - socket.stubs(:peer_ip).returns("1.2.3.4") - assert_equal "[net.ssh.test]:1234,[1.2.3.4]:1234", session.host_as_string - end - - def test_host_as_string_should_return_only_host_when_host_is_ip - session!(:host => "1.2.3.4") - socket.stubs(:peer_ip).returns("1.2.3.4") - assert_equal "1.2.3.4", session.host_as_string - end - - def test_host_as_string_should_return_only_host_and_port_when_host_is_ip_and_port_is_not_default - session!(:host => "1.2.3.4", :port => 1234) - socket.stubs(:peer_ip).returns("1.2.3.4") - assert_equal "[1.2.3.4]:1234", session.host_as_string - end - - def test_close_should_cleanup_and_close_socket - session! - socket.expects(:cleanup) - socket.expects(:close) - session.close - end - - def test_service_request_should_return_buffer - assert_equal "\005\000\000\000\004sftp", session.service_request('sftp').to_s - end - - def test_rekey_when_kex_is_pending_should_do_nothing - algorithms.stubs(:pending? => true) - algorithms.expects(:rekey!).never - session.rekey! - end - - def test_rekey_when_no_kex_is_pending_should_initiate_rekey_and_block_until_it_completes - algorithms.stubs(:pending? => false) - algorithms.expects(:rekey!) - session.expects(:wait).yields - algorithms.expects(:initialized?).returns(true) - session.rekey! - end - - def test_rekey_as_needed_when_kex_is_pending_should_do_nothing - session! - algorithms.stubs(:pending? => true) - socket.expects(:if_needs_rekey?).never - session.rekey_as_needed - end - - def test_rekey_as_needed_when_no_kex_is_pending_and_no_rekey_is_needed_should_do_nothing - session! - algorithms.stubs(:pending? => false) - socket.stubs(:if_needs_rekey? => false) - session.expects(:rekey!).never - session.rekey_as_needed - end - - def test_rekey_as_needed_when_no_kex_is_pending_and_rekey_is_needed_should_initiate_rekey_and_block - session! - algorithms.stubs(:pending? => false) - socket.expects(:if_needs_rekey?).yields - session.expects(:rekey!) - session.rekey_as_needed - end - - def test_peer_should_return_hash_of_info_about_peer - session! - socket.stubs(:peer_ip => "1.2.3.4") - assert_equal({:ip => "1.2.3.4", :port => 22, :host => "net.ssh.test", :canonized => "net.ssh.test,1.2.3.4"}, session.peer) - end - - def test_next_message_should_block_until_next_message_is_available - session.expects(:poll_message).with(:block) - session.next_message - end - - def test_poll_message_should_query_next_packet_using_the_given_blocking_parameter - session! - socket.expects(:next_packet).with(:blocking_parameter).returns(nil) - session.poll_message(:blocking_parameter) - end - - def test_poll_message_should_default_to_non_blocking - session! - socket.expects(:next_packet).with(:nonblock).returns(nil) - session.poll_message - end - - def test_poll_message_should_silently_handle_disconnect_packets - session! - socket.expects(:next_packet).returns(P(:byte, DISCONNECT, :long, 1, :string, "testing", :string, "")) - assert_raises(Net::SSH::Disconnect) { session.poll_message } - end - - def test_poll_message_should_silently_handle_ignore_packets - session! - socket.expects(:next_packet).times(2).returns(P(:byte, IGNORE, :string, "test"), nil) - assert_nil session.poll_message - end - - def test_poll_message_should_silently_handle_unimplemented_packets - session! - socket.expects(:next_packet).times(2).returns(P(:byte, UNIMPLEMENTED, :long, 15), nil) - assert_nil session.poll_message - end - - def test_poll_message_should_silently_handle_debug_packets_with_always_display - session! - socket.expects(:next_packet).times(2).returns(P(:byte, DEBUG, :bool, true, :string, "testing", :string, ""), nil) - assert_nil session.poll_message - end - - def test_poll_message_should_silently_handle_debug_packets_without_always_display - session! - socket.expects(:next_packet).times(2).returns(P(:byte, DEBUG, :bool, false, :string, "testing", :string, ""), nil) - assert_nil session.poll_message - end - - def test_poll_message_should_silently_handle_kexinit_packets - session! - packet = P(:byte, KEXINIT, :raw, "lasdfalksdjfa;slkdfja;slkfjsdfaklsjdfa;df") - socket.expects(:next_packet).times(2).returns(packet, nil) - algorithms.expects(:accept_kexinit).with(packet) - assert_nil session.poll_message - end - - def test_poll_message_should_return_other_packets - session! - packet = P(:byte, SERVICE_ACCEPT, :string, "test") - socket.expects(:next_packet).returns(packet) - assert_equal packet, session.poll_message - end - - def test_poll_message_should_enqueue_packets_when_algorithm_disallows_packet - session! - packet = P(:byte, SERVICE_ACCEPT, :string, "test") - algorithms.stubs(:allow?).with(packet).returns(false) - socket.expects(:next_packet).times(2).returns(packet, nil) - assert_nil session.poll_message - assert_equal [packet], session.queue - end - - def test_poll_message_should_read_from_queue_when_next_in_queue_is_allowed_and_consume_queue_is_true - session! - packet = P(:byte, SERVICE_ACCEPT, :string, "test") - session.push(packet) - socket.expects(:next_packet).never - assert_equal packet, session.poll_message - assert session.queue.empty? - end - - def test_poll_message_should_not_read_from_queue_when_next_in_queue_is_not_allowed - session! - packet = P(:byte, SERVICE_ACCEPT, :string, "test") - algorithms.stubs(:allow?).with(packet).returns(false) - session.push(packet) - socket.expects(:next_packet).returns(nil) - assert_nil session.poll_message - assert_equal [packet], session.queue - end - - def test_poll_message_should_not_read_from_queue_when_consume_queue_is_false - session! - packet = P(:byte, SERVICE_ACCEPT, :string, "test") - session.push(packet) - socket.expects(:next_packet).returns(nil) - assert_nil session.poll_message(:nonblock, false) - assert_equal [packet], session.queue - end - - def test_wait_with_block_should_return_immediately_if_block_returns_truth - session.expects(:poll_message).never - session.wait { true } - end - - def test_wait_should_not_consume_queue_on_reads - n = 0 - session.expects(:poll_message).with(:nonblock, false).returns(nil) - session.wait { (n += 1) > 1 } - end - - def test_wait_without_block_should_return_after_first_read - session.expects(:poll_message).returns(nil) - session.wait - end - - def test_wait_should_enqueue_packets - session! - - p1 = P(:byte, SERVICE_REQUEST, :string, "test") - p2 = P(:byte, SERVICE_ACCEPT, :string, "test") - socket.expects(:next_packet).times(2).returns(p1, p2) - - n = 0 - session.wait { (n += 1) > 2 } - assert_equal [p1, p2], session.queue - end - - def test_push_should_enqueue_packet - packet = P(:byte, SERVICE_ACCEPT, :string, "test") - session.push(packet) - assert_equal [packet], session.queue - end - - def test_send_message_should_delegate_to_socket - session! - packet = P(:byte, SERVICE_ACCEPT, :string, "test") - socket.expects(:send_packet).with(packet) - session.send_message(packet) - end - - def test_enqueue_message_should_delegate_to_socket - session! - packet = P(:byte, SERVICE_ACCEPT, :string, "test") - socket.expects(:enqueue_packet).with(packet) - session.enqueue_message(packet) - end - - def test_configure_client_should_pass_options_to_socket_client_state - session.configure_client :compression => :standard - assert_equal :standard, socket.client.compression - end - - def test_configure_server_should_pass_options_to_socket_server_state - session.configure_server :compression => :standard - assert_equal :standard, socket.server.compression - end - - def test_hint_should_set_hint_on_socket - assert !socket.hints[:authenticated] - session.hint :authenticated - assert socket.hints[:authenticated] - end - - private - - def socket - @socket ||= stub("socket", :hints => {}) - end - - def server_version - @server_version ||= stub("server_version") - end - - def algorithms - @algorithms ||= stub("algorithms", :initialized? => true, :allow? => true) - end - - def session(options={}) - @session ||= begin - host = options.delete(:host) || "net.ssh.test" - TCPSocket.stubs(:open).with(host, options[:port] || 22).returns(socket) - Net::SSH::Transport::ServerVersion.stubs(:new).returns(server_version) - Net::SSH::Transport::Algorithms.stubs(:new).returns(algorithms) - - Net::SSH::Transport::Session.new(host, options) - end - end - - # a simple alias to make the tests more self-documenting. the bang - # version makes it look more like the session is being instantiated - alias session! session - end - -end \ No newline at end of file diff --git a/vendor/gems/net-ssh-2.0.15/test/transport/test_state.rb b/vendor/gems/net-ssh-2.0.15/test/transport/test_state.rb deleted file mode 100644 index 87fad5cfe..000000000 --- a/vendor/gems/net-ssh-2.0.15/test/transport/test_state.rb +++ /dev/null @@ -1,173 +0,0 @@ -require 'common' -require 'net/ssh/transport/state' - -module Transport - - class TestState < Test::Unit::TestCase - - def setup - @socket = @state = @deflater = @inflater = nil - end - - def teardown - if @deflater - @deflater.finish if !@deflater.finished? - @deflater.close - end - - if @inflater - @inflater.finish if !@inflater.finished? - @inflater.close - end - - state.cleanup - end - - def test_constructor_should_initialize_all_values - assert_equal 0, state.sequence_number - assert_equal 0, state.packets - assert_equal 0, state.blocks - - assert_nil state.compression - assert_nil state.compression_level - assert_nil state.max_packets - assert_nil state.max_blocks - assert_nil state.rekey_limit - - assert_equal "identity", state.cipher.name - assert_instance_of Net::SSH::Transport::HMAC::None, state.hmac - end - - def test_increment_should_increment_counters - state.increment(24) - assert_equal 1, state.sequence_number - assert_equal 1, state.packets - assert_equal 3, state.blocks - end - - def test_reset_should_reset_counters_and_fix_defaults_for_maximums - state.increment(24) - state.reset! - assert_equal 1, state.sequence_number - assert_equal 0, state.packets - assert_equal 0, state.blocks - assert_equal 2147483648, state.max_packets - assert_equal 134217728, state.max_blocks - end - - def test_set_should_set_variables_and_reset_counters - state.expects(:reset!) - state.set :cipher => :a, :hmac => :b, :compression => :c, - :compression_level => :d, :max_packets => 500, :max_blocks => 1000, - :rekey_limit => 1500 - assert_equal :a, state.cipher - assert_equal :b, state.hmac - assert_equal :c, state.compression - assert_equal :d, state.compression_level - assert_equal 500, state.max_packets - assert_equal 1000, state.max_blocks - assert_equal 1500, state.rekey_limit - end - - def test_set_with_max_packets_should_respect_max_packets_setting - state.set :max_packets => 500 - assert_equal 500, state.max_packets - end - - def test_set_with_max_blocks_should_respect_max_blocks_setting - state.set :max_blocks => 1000 - assert_equal 1000, state.max_blocks - end - - def test_set_with_rekey_limit_should_include_rekey_limit_in_computation_of_max_blocks - state.set :rekey_limit => 4000 - assert_equal 500, state.max_blocks - end - - def test_compressor_defaults_to_default_zlib_compression - expect = deflater.deflate("hello world") - assert_equal expect, state.compressor.deflate("hello world") - end - - def test_compressor_uses_compression_level_when_given - state.set :compression_level => 1 - expect = deflater(1).deflate("hello world") - assert_equal expect, state.compressor.deflate("hello world") - end - - def test_compress_when_no_compression_is_active_returns_text - assert_equal "hello everybody", state.compress("hello everybody") - end - - def test_decompress_when_no_compression_is_active_returns_text - assert_equal "hello everybody", state.decompress("hello everybody") - end - - def test_compress_when_compression_is_delayed_and_no_auth_hint_is_set_should_return_text - state.set :compression => :delayed - assert_equal "hello everybody", state.compress("hello everybody") - end - - def test_decompress_when_compression_is_delayed_and_no_auth_hint_is_set_should_return_text - state.set :compression => :delayed - assert_equal "hello everybody", state.decompress("hello everybody") - end - - def test_compress_when_compression_is_enabled_should_return_compressed_text - state.set :compression => :standard - assert_equal "x\234\312H\315\311\311WH-K-\252L\312O\251\004\000\000\000\377\377", state.compress("hello everybody") - end - - def test_decompress_when_compression_is_enabled_should_return_decompressed_text - state.set :compression => :standard - assert_equal "hello everybody", state.decompress("x\234\312H\315\311\311WH-K-\252L\312O\251\004\000\000\000\377\377") - end - - def test_compress_when_compression_is_delayed_and_auth_hint_is_set_should_return_compressed_text - socket.hints[:authenticated] = true - state.set :compression => :delayed - assert_equal "x\234\312H\315\311\311WH-K-\252L\312O\251\004\000\000\000\377\377", state.compress("hello everybody") - end - - def test_decompress_when_compression_is_delayed_and_auth_hint_is_set_should_return_decompressed_text - socket.hints[:authenticated] = true - state.set :compression => :delayed - assert_equal "hello everybody", state.decompress("x\234\312H\315\311\311WH-K-\252L\312O\251\004\000\000\000\377\377") - end - - def test_needs_rekey_should_be_true_if_packets_exceeds_max_packets - state.set :max_packets => 2 - state.increment(8) - state.increment(8) - assert !state.needs_rekey? - state.increment(8) - assert state.needs_rekey? - end - - def test_needs_rekey_should_be_true_if_blocks_exceeds_max_blocks - state.set :max_blocks => 10 - assert !state.needs_rekey? - state.increment(88) - assert state.needs_rekey? - end - - private - - def deflater(level=Zlib::DEFAULT_COMPRESSION) - @deflater ||= Zlib::Deflate.new(level) - end - - def inflater - @inflater ||= Zlib::Inflate.new(nil) - end - - def socket - @socket ||= stub("socket", :hints => {}) - end - - def state - @state ||= Net::SSH::Transport::State.new(socket, :test) - end - end - -end \ No newline at end of file diff --git a/vendor/gems/net-ssh-gateway-1.0.1/.specification b/vendor/gems/net-ssh-gateway-1.0.1/.specification deleted file mode 100644 index 0158db0fa..000000000 --- a/vendor/gems/net-ssh-gateway-1.0.1/.specification +++ /dev/null @@ -1,88 +0,0 @@ ---- !ruby/object:Gem::Specification -name: net-ssh-gateway -version: !ruby/object:Gem::Version - version: 1.0.1 -platform: ruby -authors: -- Jamis Buck -autorequire: -bindir: bin -cert_chain: [] - -date: 2009-02-01 00:00:00 +00:00 -default_executable: -dependencies: -- !ruby/object:Gem::Dependency - name: net-ssh - type: :runtime - version_requirement: - version_requirements: !ruby/object:Gem::Requirement - requirements: - - - ">=" - - !ruby/object:Gem::Version - version: 1.99.1 - version: -- !ruby/object:Gem::Dependency - name: echoe - type: :development - version_requirement: - version_requirements: !ruby/object:Gem::Requirement - requirements: - - - ">=" - - !ruby/object:Gem::Version - version: "0" - version: -description: A simple library to assist in establishing tunneled Net::SSH connections -email: jamis@jamisbuck.org -executables: [] - -extensions: [] - -extra_rdoc_files: -- CHANGELOG.rdoc -- lib/net/ssh/gateway.rb -- README.rdoc -files: -- CHANGELOG.rdoc -- lib/net/ssh/gateway.rb -- Manifest -- Rakefile -- README.rdoc -- setup.rb -- test/gateway_test.rb -- net-ssh-gateway.gemspec -has_rdoc: true -homepage: http://net-ssh.rubyforge.org/gateway -licenses: [] - -post_install_message: -rdoc_options: -- --line-numbers -- --inline-source -- --title -- Net-ssh-gateway -- --main -- README.rdoc -require_paths: -- lib -required_ruby_version: !ruby/object:Gem::Requirement - requirements: - - - ">=" - - !ruby/object:Gem::Version - version: "0" - version: -required_rubygems_version: !ruby/object:Gem::Requirement - requirements: - - - ">=" - - !ruby/object:Gem::Version - version: "1.2" - version: -requirements: [] - -rubyforge_project: net-ssh-gateway -rubygems_version: 1.3.4 -signing_key: -specification_version: 2 -summary: A simple library to assist in establishing tunneled Net::SSH connections -test_files: -- test/gateway_test.rb diff --git a/vendor/gems/net-ssh-gateway-1.0.1/CHANGELOG.rdoc b/vendor/gems/net-ssh-gateway-1.0.1/CHANGELOG.rdoc deleted file mode 100644 index e4620c878..000000000 --- a/vendor/gems/net-ssh-gateway-1.0.1/CHANGELOG.rdoc +++ /dev/null @@ -1,11 +0,0 @@ -=== 1.0.1 / 1 Feb 2009 - -* Allow local port to be specified [Will Klancnik] - -=== 1.0.0 / 1 May 2008 - -* (no changes since the preview release) - -=== 1.0 Preview Release 1 (0.99.0) / 10 Apr 2008 - -* First release of Net::SSH::Gateway diff --git a/vendor/gems/net-ssh-gateway-1.0.1/Manifest b/vendor/gems/net-ssh-gateway-1.0.1/Manifest deleted file mode 100644 index 020aef7c8..000000000 --- a/vendor/gems/net-ssh-gateway-1.0.1/Manifest +++ /dev/null @@ -1,7 +0,0 @@ -CHANGELOG.rdoc -lib/net/ssh/gateway.rb -Manifest -Rakefile -README.rdoc -setup.rb -test/gateway_test.rb diff --git a/vendor/gems/net-ssh-gateway-1.0.1/README.rdoc b/vendor/gems/net-ssh-gateway-1.0.1/README.rdoc deleted file mode 100644 index ddedbf3db..000000000 --- a/vendor/gems/net-ssh-gateway-1.0.1/README.rdoc +++ /dev/null @@ -1,70 +0,0 @@ -= Net::SSH::Gateway - -* http://net-ssh.rubyforge.org/gateway - -== DESCRIPTION: - -Net::SSH::Gateway is a library for programmatically tunneling connections to servers via a single "gateway" host. It is useful for establishing Net::SSH connections to servers behind firewalls, but can also be used to forward ports and establish connections of other types, like HTTP, to servers with restricted access. - -== FEATURES: - -* Easily manage forwarded ports -* Establish Net::SSH connections through firewalls - -== SYNOPSIS: - -In a nutshell: - - require 'net/ssh/gateway' - - gateway = Net::SSH::Gateway.new('host', 'user') - - gateway.ssh("host.private", "user") do |ssh| - puts ssh.exec!("hostname") - end - - gateway.open("host.private", 80) do |port| - Net::HTTP.get_print("127.0.0.1", "/path", port) - end - - gateway.shutdown! - -See Net::SSH::Gateway for more documentation. - -== REQUIREMENTS: - -* net-ssh (version 2) - -If you want to run the tests or use any of the Rake tasks, you'll need: - -* Echoe (for the Rakefile) -* Mocha (for the tests) - -== INSTALL: - -* gem install net-ssh-gateway (might need sudo privileges) - -== LICENSE: - -(The MIT License) - -Copyright (c) 2008 Jamis Buck - -Permission is hereby granted, free of charge, to any person obtaining -a copy of this software and associated documentation files (the -'Software'), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, sublicense, and/or sell copies of the Software, and to -permit persons to whom the Software is furnished to do so, subject to -the following conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY -CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, -TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/vendor/gems/net-ssh-gateway-1.0.1/Rakefile b/vendor/gems/net-ssh-gateway-1.0.1/Rakefile deleted file mode 100644 index 520728d97..000000000 --- a/vendor/gems/net-ssh-gateway-1.0.1/Rakefile +++ /dev/null @@ -1,28 +0,0 @@ -require './lib/net/ssh/gateway' - -begin - require 'echoe' -rescue LoadError - abort "You'll need to have `echoe' installed to use Net::SSH::Gateway's Rakefile" -end - -version = Net::SSH::Gateway::Version::STRING.dup -if ENV['SNAPSHOT'].to_i == 1 - version << "." << Time.now.utc.strftime("%Y%m%d%H%M%S") -end - -Echoe.new('net-ssh-gateway', version) do |p| - p.changelog = "CHANGELOG.rdoc" - - p.author = "Jamis Buck" - p.email = "jamis@jamisbuck.org" - p.summary = "A simple library to assist in establishing tunneled Net::SSH connections" - p.url = "http://net-ssh.rubyforge.org/gateway" - - p.dependencies = ["net-ssh >=1.99.1"] - - p.need_zip = true - p.include_rakefile = true - - p.rdoc_pattern = /^(lib|README.rdoc|CHANGELOG.rdoc)/ -end diff --git a/vendor/gems/net-ssh-gateway-1.0.1/lib/net/ssh/gateway.rb b/vendor/gems/net-ssh-gateway-1.0.1/lib/net/ssh/gateway.rb deleted file mode 100644 index 214dd3596..000000000 --- a/vendor/gems/net-ssh-gateway-1.0.1/lib/net/ssh/gateway.rb +++ /dev/null @@ -1,208 +0,0 @@ -require 'thread' -require 'net/ssh' -require 'net/ssh/version' - -# A Gateway is an object that allows you to tunnel network connections through -# a publicly visible host to a host hidden behind it. This is particularly -# useful when dealing with hosts behind a firewall. One host will generally -# be visible (and accessible) outside the firewall, while the others will all -# be behind the firewall, and the only way to access those restricted hosts -# is by first logging into the publicly visible host, and from thence logging -# into the restricted ones. -# -# This class makes it easy to programmatically connect to these restricted -# hosts via SSH. You can either simply forward a port from the local host to -# the remote host, or you can open a new Net::SSH connection to the remote -# host via a forwarded port. -# -# require 'net/ssh/gateway' -# -# gateway = Net::SSH::Gateway.new('host.name', 'user') -# -# gateway.open('hidden.host', 80) do |port| -# Net::HTTP.get_print '127.0.0.1', '/path', port -# end -# -# gateway.ssh('hidden.host', 'user') do |ssh| -# puts ssh.exec!("hostname") -# end -# -# gateway.shutdown! -# -# Port numbers are allocated automatically, beginning at MAX_PORT and -# decrementing on each request for a new port until MIN_PORT is reached. If -# a port is already in use, this is detected and a different port will be -# assigned. -class Net::SSH::Gateway - # A trivial class for representing the version of this library. - class Version < Net::SSH::Version - # The major component of the library's version - MAJOR = 1 - - # The minor component of the library's version - MINOR = 0 - - # The tiny component of the library's version - TINY = 1 - - # The library's version as a Version instance - CURRENT = new(MAJOR, MINOR, TINY) - - # The library's version as a String instance - STRING = CURRENT.to_s - end - - # The maximum port number that the gateway will attempt to use to forward - # connections from. - MAX_PORT = 65535 - - # The minimum port number that the gateway will attempt to use to forward - # connections from. - MIN_PORT = 1024 - - # Instantiate a new Gateway object, using the given remote host as the - # tunnel. The arguments here are identical to those for Net::SSH.start, and - # are passed as given to that method to start up the gateway connection. - # - # gateway = Net::SSH::Gateway.new('host', 'user', :password => "password") - def initialize(host, user, options={}) - @session = Net::SSH.start(host, user, options) - @session_mutex = Mutex.new - @port_mutex = Mutex.new - @next_port = MAX_PORT - - initiate_event_loop! - end - - # Returns +true+ if the gateway is currently open and accepting connections. - # This will be the case unless #shutdown! has been invoked. - def active? - @active - end - - # Shuts down the gateway by closing all forwarded ports and then closing - # the gateway's SSH session. - def shutdown! - return unless active? - - @session_mutex.synchronize do - # cancel all active forward channels - @session.forward.active_locals.each do |lport, host, port| - @session.forward.cancel_local(lport) - end - end - - @active = false - - @thread.join - @session.close - end - - # Opens a new port on the local host and forwards it to the given host/port - # via the gateway host. If a block is given, the newly allocated port - # number will be yielded to the block, and the port automatically closed - # (see #close) when the block finishes. Otherwise, the port number will be - # returned, and the caller is responsible for closing the port (#close). - # - # gateway.open('host', 80) do |port| - # # ... - # end - # - # port = gateway.open('host', 80) - # # ... - # gateway.close(port) - # - # If +local_port+ is not specified, the next available port will be used. - def open(host, port, local_port=nil) - ensure_open! - - actual_local_port = local_port || next_port - - @session_mutex.synchronize do - @session.forward.local(actual_local_port, host, port) - end - - if block_given? - begin - yield actual_local_port - ensure - close(actual_local_port) - end - else - return actual_local_port - end - rescue Errno::EADDRINUSE - raise if local_port # if a local port was explicitly requested, bubble the error up - retry - end - - # Cancels port-forwarding over an open port that was previously opened via - # #open. - def close(port) - ensure_open! - - @session_mutex.synchronize do - @session.forward.cancel_local(port) - end - end - - # Forwards a new connection to the given +host+ and opens a new Net::SSH - # connection to that host over the forwarded port. If a block is given, - # the new SSH connection will be yielded to the block, and autoclosed - # when the block terminates. The forwarded port will be autoclosed as well. - # If no block was given, the new SSH connection will be returned, and it - # is up to the caller to terminate both the connection and the forwarded - # port when done. - # - # gateway.ssh('host', 'user') do |ssh| - # # ... - # end - # - # ssh = gateway.ssh('host', 'user') - # # ... - # ssh.close - # gateway.close(ssh.transport.port) - def ssh(host, user, options={}, &block) - local_port = open(host, options[:port] || 22) - - begin - Net::SSH.start("127.0.0.1", user, options.merge(:port => local_port), &block) - ensure - close(local_port) if block || $! - end - end - - private - - # Raises a RuntimeError if the gateway is not active. This is used as a - # sanity check to make sure a client doesn't try to call any methods on - # a closed gateway. - def ensure_open! - raise "attempt to use a closed gateway" unless active? - end - - # Fires up the gateway session's event loop within a thread, so that it - # can run in the background. The loop will run for as long as the gateway - # remains active. - def initiate_event_loop! - @active = true - - @thread = Thread.new do - while @active - @session_mutex.synchronize do - @session.process(0.1) - end - end - end - end - - # Grabs the next available port number and returns it. - def next_port - @port_mutex.synchronize do - port = @next_port - @next_port -= 1 - @next_port = MAX_PORT if @next_port < MIN_PORT - port - end - end -end diff --git a/vendor/gems/net-ssh-gateway-1.0.1/net-ssh-gateway.gemspec b/vendor/gems/net-ssh-gateway-1.0.1/net-ssh-gateway.gemspec deleted file mode 100644 index a49a99463..000000000 --- a/vendor/gems/net-ssh-gateway-1.0.1/net-ssh-gateway.gemspec +++ /dev/null @@ -1,36 +0,0 @@ -Gem::Specification.new do |s| - s.name = %q{net-ssh-gateway} - s.version = "1.0.1" - - s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version= - s.authors = ["Jamis Buck"] - s.date = %q{2009-02-01} - s.description = %q{A simple library to assist in establishing tunneled Net::SSH connections} - s.email = %q{jamis@jamisbuck.org} - s.extra_rdoc_files = ["CHANGELOG.rdoc", "lib/net/ssh/gateway.rb", "README.rdoc"] - s.files = ["CHANGELOG.rdoc", "lib/net/ssh/gateway.rb", "Manifest", "Rakefile", "README.rdoc", "setup.rb", "test/gateway_test.rb", "net-ssh-gateway.gemspec"] - s.has_rdoc = true - s.homepage = %q{http://net-ssh.rubyforge.org/gateway} - s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "Net-ssh-gateway", "--main", "README.rdoc"] - s.require_paths = ["lib"] - s.rubyforge_project = %q{net-ssh-gateway} - s.rubygems_version = %q{1.2.0} - s.summary = %q{A simple library to assist in establishing tunneled Net::SSH connections} - s.test_files = ["test/gateway_test.rb"] - - if s.respond_to? :specification_version then - current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION - s.specification_version = 2 - - if current_version >= 3 then - s.add_runtime_dependency(%q, [">= 1.99.1"]) - s.add_development_dependency(%q, [">= 0"]) - else - s.add_dependency(%q, [">= 1.99.1"]) - s.add_dependency(%q, [">= 0"]) - end - else - s.add_dependency(%q, [">= 1.99.1"]) - s.add_dependency(%q, [">= 0"]) - end -end diff --git a/vendor/gems/net-ssh-gateway-1.0.1/setup.rb b/vendor/gems/net-ssh-gateway-1.0.1/setup.rb deleted file mode 100644 index 424a5f37c..000000000 --- a/vendor/gems/net-ssh-gateway-1.0.1/setup.rb +++ /dev/null @@ -1,1585 +0,0 @@ -# -# setup.rb -# -# Copyright (c) 2000-2005 Minero Aoki -# -# This program is free software. -# You can distribute/modify this program under the terms of -# the GNU LGPL, Lesser General Public License version 2.1. -# - -unless Enumerable.method_defined?(:map) # Ruby 1.4.6 - module Enumerable - alias map collect - end -end - -unless File.respond_to?(:read) # Ruby 1.6 - def File.read(fname) - open(fname) {|f| - return f.read - } - end -end - -unless Errno.const_defined?(:ENOTEMPTY) # Windows? - module Errno - class ENOTEMPTY - # We do not raise this exception, implementation is not needed. - end - end -end - -def File.binread(fname) - open(fname, 'rb') {|f| - return f.read - } -end - -# for corrupted Windows' stat(2) -def File.dir?(path) - File.directory?((path[-1,1] == '/') ? path : path + '/') -end - - -class ConfigTable - - include Enumerable - - def initialize(rbconfig) - @rbconfig = rbconfig - @items = [] - @table = {} - # options - @install_prefix = nil - @config_opt = nil - @verbose = true - @no_harm = false - end - - attr_accessor :install_prefix - attr_accessor :config_opt - - attr_writer :verbose - - def verbose? - @verbose - end - - attr_writer :no_harm - - def no_harm? - @no_harm - end - - def [](key) - lookup(key).resolve(self) - end - - def []=(key, val) - lookup(key).set val - end - - def names - @items.map {|i| i.name } - end - - def each(&block) - @items.each(&block) - end - - def key?(name) - @table.key?(name) - end - - def lookup(name) - @table[name] or setup_rb_error "no such config item: #{name}" - end - - def add(item) - @items.push item - @table[item.name] = item - end - - def remove(name) - item = lookup(name) - @items.delete_if {|i| i.name == name } - @table.delete_if {|name, i| i.name == name } - item - end - - def load_script(path, inst = nil) - if File.file?(path) - MetaConfigEnvironment.new(self, inst).instance_eval File.read(path), path - end - end - - def savefile - '.config' - end - - def load_savefile - begin - File.foreach(savefile()) do |line| - k, v = *line.split(/=/, 2) - self[k] = v.strip - end - rescue Errno::ENOENT - setup_rb_error $!.message + "\n#{File.basename($0)} config first" - end - end - - def save - @items.each {|i| i.value } - File.open(savefile(), 'w') {|f| - @items.each do |i| - f.printf "%s=%s\n", i.name, i.value if i.value? and i.value - end - } - end - - def load_standard_entries - standard_entries(@rbconfig).each do |ent| - add ent - end - end - - def standard_entries(rbconfig) - c = rbconfig - - rubypath = File.join(c['bindir'], c['ruby_install_name'] + c['EXEEXT']) - - major = c['MAJOR'].to_i - minor = c['MINOR'].to_i - teeny = c['TEENY'].to_i - version = "#{major}.#{minor}" - - # ruby ver. >= 1.4.4? - newpath_p = ((major >= 2) or - ((major == 1) and - ((minor >= 5) or - ((minor == 4) and (teeny >= 4))))) - - if c['rubylibdir'] - # V > 1.6.3 - libruby = "#{c['prefix']}/lib/ruby" - librubyver = c['rubylibdir'] - librubyverarch = c['archdir'] - siteruby = c['sitedir'] - siterubyver = c['sitelibdir'] - siterubyverarch = c['sitearchdir'] - elsif newpath_p - # 1.4.4 <= V <= 1.6.3 - libruby = "#{c['prefix']}/lib/ruby" - librubyver = "#{c['prefix']}/lib/ruby/#{version}" - librubyverarch = "#{c['prefix']}/lib/ruby/#{version}/#{c['arch']}" - siteruby = c['sitedir'] - siterubyver = "$siteruby/#{version}" - siterubyverarch = "$siterubyver/#{c['arch']}" - else - # V < 1.4.4 - libruby = "#{c['prefix']}/lib/ruby" - librubyver = "#{c['prefix']}/lib/ruby/#{version}" - librubyverarch = "#{c['prefix']}/lib/ruby/#{version}/#{c['arch']}" - siteruby = "#{c['prefix']}/lib/ruby/#{version}/site_ruby" - siterubyver = siteruby - siterubyverarch = "$siterubyver/#{c['arch']}" - end - parameterize = lambda {|path| - path.sub(/\A#{Regexp.quote(c['prefix'])}/, '$prefix') - } - - if arg = c['configure_args'].split.detect {|arg| /--with-make-prog=/ =~ arg } - makeprog = arg.sub(/'/, '').split(/=/, 2)[1] - else - makeprog = 'make' - end - - [ - ExecItem.new('installdirs', 'std/site/home', - 'std: install under libruby; site: install under site_ruby; home: install under $HOME')\ - {|val, table| - case val - when 'std' - table['rbdir'] = '$librubyver' - table['sodir'] = '$librubyverarch' - when 'site' - table['rbdir'] = '$siterubyver' - table['sodir'] = '$siterubyverarch' - when 'home' - setup_rb_error '$HOME was not set' unless ENV['HOME'] - table['prefix'] = ENV['HOME'] - table['rbdir'] = '$libdir/ruby' - table['sodir'] = '$libdir/ruby' - end - }, - PathItem.new('prefix', 'path', c['prefix'], - 'path prefix of target environment'), - PathItem.new('bindir', 'path', parameterize.call(c['bindir']), - 'the directory for commands'), - PathItem.new('libdir', 'path', parameterize.call(c['libdir']), - 'the directory for libraries'), - PathItem.new('datadir', 'path', parameterize.call(c['datadir']), - 'the directory for shared data'), - PathItem.new('mandir', 'path', parameterize.call(c['mandir']), - 'the directory for man pages'), - PathItem.new('sysconfdir', 'path', parameterize.call(c['sysconfdir']), - 'the directory for system configuration files'), - PathItem.new('localstatedir', 'path', parameterize.call(c['localstatedir']), - 'the directory for local state data'), - PathItem.new('libruby', 'path', libruby, - 'the directory for ruby libraries'), - PathItem.new('librubyver', 'path', librubyver, - 'the directory for standard ruby libraries'), - PathItem.new('librubyverarch', 'path', librubyverarch, - 'the directory for standard ruby extensions'), - PathItem.new('siteruby', 'path', siteruby, - 'the directory for version-independent aux ruby libraries'), - PathItem.new('siterubyver', 'path', siterubyver, - 'the directory for aux ruby libraries'), - PathItem.new('siterubyverarch', 'path', siterubyverarch, - 'the directory for aux ruby binaries'), - PathItem.new('rbdir', 'path', '$siterubyver', - 'the directory for ruby scripts'), - PathItem.new('sodir', 'path', '$siterubyverarch', - 'the directory for ruby extentions'), - PathItem.new('rubypath', 'path', rubypath, - 'the path to set to #! line'), - ProgramItem.new('rubyprog', 'name', rubypath, - 'the ruby program using for installation'), - ProgramItem.new('makeprog', 'name', makeprog, - 'the make program to compile ruby extentions'), - SelectItem.new('shebang', 'all/ruby/never', 'ruby', - 'shebang line (#!) editing mode'), - BoolItem.new('without-ext', 'yes/no', 'no', - 'does not compile/install ruby extentions') - ] - end - private :standard_entries - - def load_multipackage_entries - multipackage_entries().each do |ent| - add ent - end - end - - def multipackage_entries - [ - PackageSelectionItem.new('with', 'name,name...', '', 'ALL', - 'package names that you want to install'), - PackageSelectionItem.new('without', 'name,name...', '', 'NONE', - 'package names that you do not want to install') - ] - end - private :multipackage_entries - - ALIASES = { - 'std-ruby' => 'librubyver', - 'stdruby' => 'librubyver', - 'rubylibdir' => 'librubyver', - 'archdir' => 'librubyverarch', - 'site-ruby-common' => 'siteruby', # For backward compatibility - 'site-ruby' => 'siterubyver', # For backward compatibility - 'bin-dir' => 'bindir', - 'bin-dir' => 'bindir', - 'rb-dir' => 'rbdir', - 'so-dir' => 'sodir', - 'data-dir' => 'datadir', - 'ruby-path' => 'rubypath', - 'ruby-prog' => 'rubyprog', - 'ruby' => 'rubyprog', - 'make-prog' => 'makeprog', - 'make' => 'makeprog' - } - - def fixup - ALIASES.each do |ali, name| - @table[ali] = @table[name] - end - @items.freeze - @table.freeze - @options_re = /\A--(#{@table.keys.join('|')})(?:=(.*))?\z/ - end - - def parse_opt(opt) - m = @options_re.match(opt) or setup_rb_error "config: unknown option #{opt}" - m.to_a[1,2] - end - - def dllext - @rbconfig['DLEXT'] - end - - def value_config?(name) - lookup(name).value? - end - - class Item - def initialize(name, template, default, desc) - @name = name.freeze - @template = template - @value = default - @default = default - @description = desc - end - - attr_reader :name - attr_reader :description - - attr_accessor :default - alias help_default default - - def help_opt - "--#{@name}=#{@template}" - end - - def value? - true - end - - def value - @value - end - - def resolve(table) - @value.gsub(%r<\$([^/]+)>) { table[$1] } - end - - def set(val) - @value = check(val) - end - - private - - def check(val) - setup_rb_error "config: --#{name} requires argument" unless val - val - end - end - - class BoolItem < Item - def config_type - 'bool' - end - - def help_opt - "--#{@name}" - end - - private - - def check(val) - return 'yes' unless val - case val - when /\Ay(es)?\z/i, /\At(rue)?\z/i then 'yes' - when /\An(o)?\z/i, /\Af(alse)\z/i then 'no' - else - setup_rb_error "config: --#{@name} accepts only yes/no for argument" - end - end - end - - class PathItem < Item - def config_type - 'path' - end - - private - - def check(path) - setup_rb_error "config: --#{@name} requires argument" unless path - path[0,1] == '$' ? path : File.expand_path(path) - end - end - - class ProgramItem < Item - def config_type - 'program' - end - end - - class SelectItem < Item - def initialize(name, selection, default, desc) - super - @ok = selection.split('/') - end - - def config_type - 'select' - end - - private - - def check(val) - unless @ok.include?(val.strip) - setup_rb_error "config: use --#{@name}=#{@template} (#{val})" - end - val.strip - end - end - - class ExecItem < Item - def initialize(name, selection, desc, &block) - super name, selection, nil, desc - @ok = selection.split('/') - @action = block - end - - def config_type - 'exec' - end - - def value? - false - end - - def resolve(table) - setup_rb_error "$#{name()} wrongly used as option value" - end - - undef set - - def evaluate(val, table) - v = val.strip.downcase - unless @ok.include?(v) - setup_rb_error "invalid option --#{@name}=#{val} (use #{@template})" - end - @action.call v, table - end - end - - class PackageSelectionItem < Item - def initialize(name, template, default, help_default, desc) - super name, template, default, desc - @help_default = help_default - end - - attr_reader :help_default - - def config_type - 'package' - end - - private - - def check(val) - unless File.dir?("packages/#{val}") - setup_rb_error "config: no such package: #{val}" - end - val - end - end - - class MetaConfigEnvironment - def initialize(config, installer) - @config = config - @installer = installer - end - - def config_names - @config.names - end - - def config?(name) - @config.key?(name) - end - - def bool_config?(name) - @config.lookup(name).config_type == 'bool' - end - - def path_config?(name) - @config.lookup(name).config_type == 'path' - end - - def value_config?(name) - @config.lookup(name).config_type != 'exec' - end - - def add_config(item) - @config.add item - end - - def add_bool_config(name, default, desc) - @config.add BoolItem.new(name, 'yes/no', default ? 'yes' : 'no', desc) - end - - def add_path_config(name, default, desc) - @config.add PathItem.new(name, 'path', default, desc) - end - - def set_config_default(name, default) - @config.lookup(name).default = default - end - - def remove_config(name) - @config.remove(name) - end - - # For only multipackage - def packages - raise '[setup.rb fatal] multi-package metaconfig API packages() called for single-package; contact application package vendor' unless @installer - @installer.packages - end - - # For only multipackage - def declare_packages(list) - raise '[setup.rb fatal] multi-package metaconfig API declare_packages() called for single-package; contact application package vendor' unless @installer - @installer.packages = list - end - end - -end # class ConfigTable - - -# This module requires: #verbose?, #no_harm? -module FileOperations - - def mkdir_p(dirname, prefix = nil) - dirname = prefix + File.expand_path(dirname) if prefix - $stderr.puts "mkdir -p #{dirname}" if verbose? - return if no_harm? - - # Does not check '/', it's too abnormal. - dirs = File.expand_path(dirname).split(%r<(?=/)>) - if /\A[a-z]:\z/i =~ dirs[0] - disk = dirs.shift - dirs[0] = disk + dirs[0] - end - dirs.each_index do |idx| - path = dirs[0..idx].join('') - Dir.mkdir path unless File.dir?(path) - end - end - - def rm_f(path) - $stderr.puts "rm -f #{path}" if verbose? - return if no_harm? - force_remove_file path - end - - def rm_rf(path) - $stderr.puts "rm -rf #{path}" if verbose? - return if no_harm? - remove_tree path - end - - def remove_tree(path) - if File.symlink?(path) - remove_file path - elsif File.dir?(path) - remove_tree0 path - else - force_remove_file path - end - end - - def remove_tree0(path) - Dir.foreach(path) do |ent| - next if ent == '.' - next if ent == '..' - entpath = "#{path}/#{ent}" - if File.symlink?(entpath) - remove_file entpath - elsif File.dir?(entpath) - remove_tree0 entpath - else - force_remove_file entpath - end - end - begin - Dir.rmdir path - rescue Errno::ENOTEMPTY - # directory may not be empty - end - end - - def move_file(src, dest) - force_remove_file dest - begin - File.rename src, dest - rescue - File.open(dest, 'wb') {|f| - f.write File.binread(src) - } - File.chmod File.stat(src).mode, dest - File.unlink src - end - end - - def force_remove_file(path) - begin - remove_file path - rescue - end - end - - def remove_file(path) - File.chmod 0777, path - File.unlink path - end - - def install(from, dest, mode, prefix = nil) - $stderr.puts "install #{from} #{dest}" if verbose? - return if no_harm? - - realdest = prefix ? prefix + File.expand_path(dest) : dest - realdest = File.join(realdest, File.basename(from)) if File.dir?(realdest) - str = File.binread(from) - if diff?(str, realdest) - verbose_off { - rm_f realdest if File.exist?(realdest) - } - File.open(realdest, 'wb') {|f| - f.write str - } - File.chmod mode, realdest - - File.open("#{objdir_root()}/InstalledFiles", 'a') {|f| - if prefix - f.puts realdest.sub(prefix, '') - else - f.puts realdest - end - } - end - end - - def diff?(new_content, path) - return true unless File.exist?(path) - new_content != File.binread(path) - end - - def command(*args) - $stderr.puts args.join(' ') if verbose? - system(*args) or raise RuntimeError, - "system(#{args.map{|a| a.inspect }.join(' ')}) failed" - end - - def ruby(*args) - command config('rubyprog'), *args - end - - def make(task = nil) - command(*[config('makeprog'), task].compact) - end - - def extdir?(dir) - File.exist?("#{dir}/MANIFEST") or File.exist?("#{dir}/extconf.rb") - end - - def files_of(dir) - Dir.open(dir) {|d| - return d.select {|ent| File.file?("#{dir}/#{ent}") } - } - end - - DIR_REJECT = %w( . .. CVS SCCS RCS CVS.adm .svn ) - - def directories_of(dir) - Dir.open(dir) {|d| - return d.select {|ent| File.dir?("#{dir}/#{ent}") } - DIR_REJECT - } - end - -end - - -# This module requires: #srcdir_root, #objdir_root, #relpath -module HookScriptAPI - - def get_config(key) - @config[key] - end - - alias config get_config - - # obsolete: use metaconfig to change configuration - def set_config(key, val) - @config[key] = val - end - - # - # srcdir/objdir (works only in the package directory) - # - - def curr_srcdir - "#{srcdir_root()}/#{relpath()}" - end - - def curr_objdir - "#{objdir_root()}/#{relpath()}" - end - - def srcfile(path) - "#{curr_srcdir()}/#{path}" - end - - def srcexist?(path) - File.exist?(srcfile(path)) - end - - def srcdirectory?(path) - File.dir?(srcfile(path)) - end - - def srcfile?(path) - File.file?(srcfile(path)) - end - - def srcentries(path = '.') - Dir.open("#{curr_srcdir()}/#{path}") {|d| - return d.to_a - %w(. ..) - } - end - - def srcfiles(path = '.') - srcentries(path).select {|fname| - File.file?(File.join(curr_srcdir(), path, fname)) - } - end - - def srcdirectories(path = '.') - srcentries(path).select {|fname| - File.dir?(File.join(curr_srcdir(), path, fname)) - } - end - -end - - -class ToplevelInstaller - - Version = '3.4.1' - Copyright = 'Copyright (c) 2000-2005 Minero Aoki' - - TASKS = [ - [ 'all', 'do config, setup, then install' ], - [ 'config', 'saves your configurations' ], - [ 'show', 'shows current configuration' ], - [ 'setup', 'compiles ruby extentions and others' ], - [ 'install', 'installs files' ], - [ 'test', 'run all tests in test/' ], - [ 'clean', "does `make clean' for each extention" ], - [ 'distclean',"does `make distclean' for each extention" ] - ] - - def ToplevelInstaller.invoke - config = ConfigTable.new(load_rbconfig()) - config.load_standard_entries - config.load_multipackage_entries if multipackage? - config.fixup - klass = (multipackage?() ? ToplevelInstallerMulti : ToplevelInstaller) - klass.new(File.dirname($0), config).invoke - end - - def ToplevelInstaller.multipackage? - File.dir?(File.dirname($0) + '/packages') - end - - def ToplevelInstaller.load_rbconfig - if arg = ARGV.detect {|arg| /\A--rbconfig=/ =~ arg } - ARGV.delete(arg) - load File.expand_path(arg.split(/=/, 2)[1]) - $".push 'rbconfig.rb' - else - require 'rbconfig' - end - ::Config::CONFIG - end - - def initialize(ardir_root, config) - @ardir = File.expand_path(ardir_root) - @config = config - # cache - @valid_task_re = nil - end - - def config(key) - @config[key] - end - - def inspect - "#<#{self.class} #{__id__()}>" - end - - def invoke - run_metaconfigs - case task = parsearg_global() - when nil, 'all' - parsearg_config - init_installers - exec_config - exec_setup - exec_install - else - case task - when 'config', 'test' - ; - when 'clean', 'distclean' - @config.load_savefile if File.exist?(@config.savefile) - else - @config.load_savefile - end - __send__ "parsearg_#{task}" - init_installers - __send__ "exec_#{task}" - end - end - - def run_metaconfigs - @config.load_script "#{@ardir}/metaconfig" - end - - def init_installers - @installer = Installer.new(@config, @ardir, File.expand_path('.')) - end - - # - # Hook Script API bases - # - - def srcdir_root - @ardir - end - - def objdir_root - '.' - end - - def relpath - '.' - end - - # - # Option Parsing - # - - def parsearg_global - while arg = ARGV.shift - case arg - when /\A\w+\z/ - setup_rb_error "invalid task: #{arg}" unless valid_task?(arg) - return arg - when '-q', '--quiet' - @config.verbose = false - when '--verbose' - @config.verbose = true - when '--help' - print_usage $stdout - exit 0 - when '--version' - puts "#{File.basename($0)} version #{Version}" - exit 0 - when '--copyright' - puts Copyright - exit 0 - else - setup_rb_error "unknown global option '#{arg}'" - end - end - nil - end - - def valid_task?(t) - valid_task_re() =~ t - end - - def valid_task_re - @valid_task_re ||= /\A(?:#{TASKS.map {|task,desc| task }.join('|')})\z/ - end - - def parsearg_no_options - unless ARGV.empty? - task = caller(0).first.slice(%r<`parsearg_(\w+)'>, 1) - setup_rb_error "#{task}: unknown options: #{ARGV.join(' ')}" - end - end - - alias parsearg_show parsearg_no_options - alias parsearg_setup parsearg_no_options - alias parsearg_test parsearg_no_options - alias parsearg_clean parsearg_no_options - alias parsearg_distclean parsearg_no_options - - def parsearg_config - evalopt = [] - set = [] - @config.config_opt = [] - while i = ARGV.shift - if /\A--?\z/ =~ i - @config.config_opt = ARGV.dup - break - end - name, value = *@config.parse_opt(i) - if @config.value_config?(name) - @config[name] = value - else - evalopt.push [name, value] - end - set.push name - end - evalopt.each do |name, value| - @config.lookup(name).evaluate value, @config - end - # Check if configuration is valid - set.each do |n| - @config[n] if @config.value_config?(n) - end - end - - def parsearg_install - @config.no_harm = false - @config.install_prefix = '' - while a = ARGV.shift - case a - when '--no-harm' - @config.no_harm = true - when /\A--prefix=/ - path = a.split(/=/, 2)[1] - path = File.expand_path(path) unless path[0,1] == '/' - @config.install_prefix = path - else - setup_rb_error "install: unknown option #{a}" - end - end - end - - def print_usage(out) - out.puts 'Typical Installation Procedure:' - out.puts " $ ruby #{File.basename $0} config" - out.puts " $ ruby #{File.basename $0} setup" - out.puts " # ruby #{File.basename $0} install (may require root privilege)" - out.puts - out.puts 'Detailed Usage:' - out.puts " ruby #{File.basename $0} " - out.puts " ruby #{File.basename $0} [] []" - - fmt = " %-24s %s\n" - out.puts - out.puts 'Global options:' - out.printf fmt, '-q,--quiet', 'suppress message outputs' - out.printf fmt, ' --verbose', 'output messages verbosely' - out.printf fmt, ' --help', 'print this message' - out.printf fmt, ' --version', 'print version and quit' - out.printf fmt, ' --copyright', 'print copyright and quit' - out.puts - out.puts 'Tasks:' - TASKS.each do |name, desc| - out.printf fmt, name, desc - end - - fmt = " %-24s %s [%s]\n" - out.puts - out.puts 'Options for CONFIG or ALL:' - @config.each do |item| - out.printf fmt, item.help_opt, item.description, item.help_default - end - out.printf fmt, '--rbconfig=path', 'rbconfig.rb to load',"running ruby's" - out.puts - out.puts 'Options for INSTALL:' - out.printf fmt, '--no-harm', 'only display what to do if given', 'off' - out.printf fmt, '--prefix=path', 'install path prefix', '' - out.puts - end - - # - # Task Handlers - # - - def exec_config - @installer.exec_config - @config.save # must be final - end - - def exec_setup - @installer.exec_setup - end - - def exec_install - @installer.exec_install - end - - def exec_test - @installer.exec_test - end - - def exec_show - @config.each do |i| - printf "%-20s %s\n", i.name, i.value if i.value? - end - end - - def exec_clean - @installer.exec_clean - end - - def exec_distclean - @installer.exec_distclean - end - -end # class ToplevelInstaller - - -class ToplevelInstallerMulti < ToplevelInstaller - - include FileOperations - - def initialize(ardir_root, config) - super - @packages = directories_of("#{@ardir}/packages") - raise 'no package exists' if @packages.empty? - @root_installer = Installer.new(@config, @ardir, File.expand_path('.')) - end - - def run_metaconfigs - @config.load_script "#{@ardir}/metaconfig", self - @packages.each do |name| - @config.load_script "#{@ardir}/packages/#{name}/metaconfig" - end - end - - attr_reader :packages - - def packages=(list) - raise 'package list is empty' if list.empty? - list.each do |name| - raise "directory packages/#{name} does not exist"\ - unless File.dir?("#{@ardir}/packages/#{name}") - end - @packages = list - end - - def init_installers - @installers = {} - @packages.each do |pack| - @installers[pack] = Installer.new(@config, - "#{@ardir}/packages/#{pack}", - "packages/#{pack}") - end - with = extract_selection(config('with')) - without = extract_selection(config('without')) - @selected = @installers.keys.select {|name| - (with.empty? or with.include?(name)) \ - and not without.include?(name) - } - end - - def extract_selection(list) - a = list.split(/,/) - a.each do |name| - setup_rb_error "no such package: #{name}" unless @installers.key?(name) - end - a - end - - def print_usage(f) - super - f.puts 'Inluded packages:' - f.puts ' ' + @packages.sort.join(' ') - f.puts - end - - # - # Task Handlers - # - - def exec_config - run_hook 'pre-config' - each_selected_installers {|inst| inst.exec_config } - run_hook 'post-config' - @config.save # must be final - end - - def exec_setup - run_hook 'pre-setup' - each_selected_installers {|inst| inst.exec_setup } - run_hook 'post-setup' - end - - def exec_install - run_hook 'pre-install' - each_selected_installers {|inst| inst.exec_install } - run_hook 'post-install' - end - - def exec_test - run_hook 'pre-test' - each_selected_installers {|inst| inst.exec_test } - run_hook 'post-test' - end - - def exec_clean - rm_f @config.savefile - run_hook 'pre-clean' - each_selected_installers {|inst| inst.exec_clean } - run_hook 'post-clean' - end - - def exec_distclean - rm_f @config.savefile - run_hook 'pre-distclean' - each_selected_installers {|inst| inst.exec_distclean } - run_hook 'post-distclean' - end - - # - # lib - # - - def each_selected_installers - Dir.mkdir 'packages' unless File.dir?('packages') - @selected.each do |pack| - $stderr.puts "Processing the package `#{pack}' ..." if verbose? - Dir.mkdir "packages/#{pack}" unless File.dir?("packages/#{pack}") - Dir.chdir "packages/#{pack}" - yield @installers[pack] - Dir.chdir '../..' - end - end - - def run_hook(id) - @root_installer.run_hook id - end - - # module FileOperations requires this - def verbose? - @config.verbose? - end - - # module FileOperations requires this - def no_harm? - @config.no_harm? - end - -end # class ToplevelInstallerMulti - - -class Installer - - FILETYPES = %w( bin lib ext data conf man ) - - include FileOperations - include HookScriptAPI - - def initialize(config, srcroot, objroot) - @config = config - @srcdir = File.expand_path(srcroot) - @objdir = File.expand_path(objroot) - @currdir = '.' - end - - def inspect - "#<#{self.class} #{File.basename(@srcdir)}>" - end - - def noop(rel) - end - - # - # Hook Script API base methods - # - - def srcdir_root - @srcdir - end - - def objdir_root - @objdir - end - - def relpath - @currdir - end - - # - # Config Access - # - - # module FileOperations requires this - def verbose? - @config.verbose? - end - - # module FileOperations requires this - def no_harm? - @config.no_harm? - end - - def verbose_off - begin - save, @config.verbose = @config.verbose?, false - yield - ensure - @config.verbose = save - end - end - - # - # TASK config - # - - def exec_config - exec_task_traverse 'config' - end - - alias config_dir_bin noop - alias config_dir_lib noop - - def config_dir_ext(rel) - extconf if extdir?(curr_srcdir()) - end - - alias config_dir_data noop - alias config_dir_conf noop - alias config_dir_man noop - - def extconf - ruby "#{curr_srcdir()}/extconf.rb", *@config.config_opt - end - - # - # TASK setup - # - - def exec_setup - exec_task_traverse 'setup' - end - - def setup_dir_bin(rel) - files_of(curr_srcdir()).each do |fname| - update_shebang_line "#{curr_srcdir()}/#{fname}" - end - end - - alias setup_dir_lib noop - - def setup_dir_ext(rel) - make if extdir?(curr_srcdir()) - end - - alias setup_dir_data noop - alias setup_dir_conf noop - alias setup_dir_man noop - - def update_shebang_line(path) - return if no_harm? - return if config('shebang') == 'never' - old = Shebang.load(path) - if old - $stderr.puts "warning: #{path}: Shebang line includes too many args. It is not portable and your program may not work." if old.args.size > 1 - new = new_shebang(old) - return if new.to_s == old.to_s - else - return unless config('shebang') == 'all' - new = Shebang.new(config('rubypath')) - end - $stderr.puts "updating shebang: #{File.basename(path)}" if verbose? - open_atomic_writer(path) {|output| - File.open(path, 'rb') {|f| - f.gets if old # discard - output.puts new.to_s - output.print f.read - } - } - end - - def new_shebang(old) - if /\Aruby/ =~ File.basename(old.cmd) - Shebang.new(config('rubypath'), old.args) - elsif File.basename(old.cmd) == 'env' and old.args.first == 'ruby' - Shebang.new(config('rubypath'), old.args[1..-1]) - else - return old unless config('shebang') == 'all' - Shebang.new(config('rubypath')) - end - end - - def open_atomic_writer(path, &block) - tmpfile = File.basename(path) + '.tmp' - begin - File.open(tmpfile, 'wb', &block) - File.rename tmpfile, File.basename(path) - ensure - File.unlink tmpfile if File.exist?(tmpfile) - end - end - - class Shebang - def Shebang.load(path) - line = nil - File.open(path) {|f| - line = f.gets - } - return nil unless /\A#!/ =~ line - parse(line) - end - - def Shebang.parse(line) - cmd, *args = *line.strip.sub(/\A\#!/, '').split(' ') - new(cmd, args) - end - - def initialize(cmd, args = []) - @cmd = cmd - @args = args - end - - attr_reader :cmd - attr_reader :args - - def to_s - "#! #{@cmd}" + (@args.empty? ? '' : " #{@args.join(' ')}") - end - end - - # - # TASK install - # - - def exec_install - rm_f 'InstalledFiles' - exec_task_traverse 'install' - end - - def install_dir_bin(rel) - install_files targetfiles(), "#{config('bindir')}/#{rel}", 0755 - end - - def install_dir_lib(rel) - install_files libfiles(), "#{config('rbdir')}/#{rel}", 0644 - end - - def install_dir_ext(rel) - return unless extdir?(curr_srcdir()) - install_files rubyextentions('.'), - "#{config('sodir')}/#{File.dirname(rel)}", - 0555 - end - - def install_dir_data(rel) - install_files targetfiles(), "#{config('datadir')}/#{rel}", 0644 - end - - def install_dir_conf(rel) - # FIXME: should not remove current config files - # (rename previous file to .old/.org) - install_files targetfiles(), "#{config('sysconfdir')}/#{rel}", 0644 - end - - def install_dir_man(rel) - install_files targetfiles(), "#{config('mandir')}/#{rel}", 0644 - end - - def install_files(list, dest, mode) - mkdir_p dest, @config.install_prefix - list.each do |fname| - install fname, dest, mode, @config.install_prefix - end - end - - def libfiles - glob_reject(%w(*.y *.output), targetfiles()) - end - - def rubyextentions(dir) - ents = glob_select("*.#{@config.dllext}", targetfiles()) - if ents.empty? - setup_rb_error "no ruby extention exists: 'ruby #{$0} setup' first" - end - ents - end - - def targetfiles - mapdir(existfiles() - hookfiles()) - end - - def mapdir(ents) - ents.map {|ent| - if File.exist?(ent) - then ent # objdir - else "#{curr_srcdir()}/#{ent}" # srcdir - end - } - end - - # picked up many entries from cvs-1.11.1/src/ignore.c - JUNK_FILES = %w( - core RCSLOG tags TAGS .make.state - .nse_depinfo #* .#* cvslog.* ,* .del-* *.olb - *~ *.old *.bak *.BAK *.orig *.rej _$* *$ - - *.org *.in .* - ) - - def existfiles - glob_reject(JUNK_FILES, (files_of(curr_srcdir()) | files_of('.'))) - end - - def hookfiles - %w( pre-%s post-%s pre-%s.rb post-%s.rb ).map {|fmt| - %w( config setup install clean ).map {|t| sprintf(fmt, t) } - }.flatten - end - - def glob_select(pat, ents) - re = globs2re([pat]) - ents.select {|ent| re =~ ent } - end - - def glob_reject(pats, ents) - re = globs2re(pats) - ents.reject {|ent| re =~ ent } - end - - GLOB2REGEX = { - '.' => '\.', - '$' => '\$', - '#' => '\#', - '*' => '.*' - } - - def globs2re(pats) - /\A(?:#{ - pats.map {|pat| pat.gsub(/[\.\$\#\*]/) {|ch| GLOB2REGEX[ch] } }.join('|') - })\z/ - end - - # - # TASK test - # - - TESTDIR = 'test' - - def exec_test - unless File.directory?('test') - $stderr.puts 'no test in this package' if verbose? - return - end - $stderr.puts 'Running tests...' if verbose? - begin - require 'test/unit' - rescue LoadError - setup_rb_error 'test/unit cannot loaded. You need Ruby 1.8 or later to invoke this task.' - end - runner = Test::Unit::AutoRunner.new(true) - runner.to_run << TESTDIR - runner.run - end - - # - # TASK clean - # - - def exec_clean - exec_task_traverse 'clean' - rm_f @config.savefile - rm_f 'InstalledFiles' - end - - alias clean_dir_bin noop - alias clean_dir_lib noop - alias clean_dir_data noop - alias clean_dir_conf noop - alias clean_dir_man noop - - def clean_dir_ext(rel) - return unless extdir?(curr_srcdir()) - make 'clean' if File.file?('Makefile') - end - - # - # TASK distclean - # - - def exec_distclean - exec_task_traverse 'distclean' - rm_f @config.savefile - rm_f 'InstalledFiles' - end - - alias distclean_dir_bin noop - alias distclean_dir_lib noop - - def distclean_dir_ext(rel) - return unless extdir?(curr_srcdir()) - make 'distclean' if File.file?('Makefile') - end - - alias distclean_dir_data noop - alias distclean_dir_conf noop - alias distclean_dir_man noop - - # - # Traversing - # - - def exec_task_traverse(task) - run_hook "pre-#{task}" - FILETYPES.each do |type| - if type == 'ext' and config('without-ext') == 'yes' - $stderr.puts 'skipping ext/* by user option' if verbose? - next - end - traverse task, type, "#{task}_dir_#{type}" - end - run_hook "post-#{task}" - end - - def traverse(task, rel, mid) - dive_into(rel) { - run_hook "pre-#{task}" - __send__ mid, rel.sub(%r[\A.*?(?:/|\z)], '') - directories_of(curr_srcdir()).each do |d| - traverse task, "#{rel}/#{d}", mid - end - run_hook "post-#{task}" - } - end - - def dive_into(rel) - return unless File.dir?("#{@srcdir}/#{rel}") - - dir = File.basename(rel) - Dir.mkdir dir unless File.dir?(dir) - prevdir = Dir.pwd - Dir.chdir dir - $stderr.puts '---> ' + rel if verbose? - @currdir = rel - yield - Dir.chdir prevdir - $stderr.puts '<--- ' + rel if verbose? - @currdir = File.dirname(rel) - end - - def run_hook(id) - path = [ "#{curr_srcdir()}/#{id}", - "#{curr_srcdir()}/#{id}.rb" ].detect {|cand| File.file?(cand) } - return unless path - begin - instance_eval File.read(path), path, 1 - rescue - raise if $DEBUG - setup_rb_error "hook #{path} failed:\n" + $!.message - end - end - -end # class Installer - - -class SetupError < StandardError; end - -def setup_rb_error(msg) - raise SetupError, msg -end - -if $0 == __FILE__ - begin - ToplevelInstaller.invoke - rescue SetupError - raise if $DEBUG - $stderr.puts $!.message - $stderr.puts "Try 'ruby #{$0} --help' for detailed usage." - exit 1 - end -end diff --git a/vendor/gems/net-ssh-gateway-1.0.1/test/gateway_test.rb b/vendor/gems/net-ssh-gateway-1.0.1/test/gateway_test.rb deleted file mode 100644 index 8d7fac730..000000000 --- a/vendor/gems/net-ssh-gateway-1.0.1/test/gateway_test.rb +++ /dev/null @@ -1,122 +0,0 @@ -require 'test/unit' -require 'mocha' -require 'net/ssh/gateway' - -class GatewayTest < Test::Unit::TestCase - def teardown - Thread.list { |t| t.kill unless Thread.current == t } - end - - def test_shutdown_without_any_open_connections_should_terminate_session - session, gateway = new_gateway - session.expects(:close) - gateway.shutdown! - assert !gateway.active? - assert session.forward.active_locals.empty? - end - - def test_open_should_start_local_ports_at_65535 - gateway_session, gateway = new_gateway - assert_equal 65535, gateway.open("app1", 22) - assert_equal [65535, "app1", 22], gateway_session.forward.active_locals[65535] - end - - def test_open_should_decrement_port_and_retry_if_ports_are_in_use - gateway_session, gateway = new_gateway(:reserved => lambda { |n| n > 65000 }) - assert_equal 65000, gateway.open("app1", 22) - assert_equal [65000, "app1", 22], gateway_session.forward.active_locals[65000] - end - - def test_open_with_explicit_local_port_should_use_that_port - gateway_session, gateway = new_gateway - assert_equal 8181, gateway.open("app1", 22, 8181) - assert_equal [8181, "app1", 22], gateway_session.forward.active_locals[8181] - end - - def test_ssh_should_return_connection_when_no_block_is_given - gateway_session, gateway = new_gateway - expect_connect_to("127.0.0.1", "user", :port => 65535).returns(result = mock("session")) - newsess = gateway.ssh("app1", "user") - assert_equal result, newsess - assert_equal [65535, "app1", 22], gateway_session.forward.active_locals[65535] - end - - def test_ssh_with_block_should_yield_session_and_then_close_port - gateway_session, gateway = new_gateway - expect_connect_to("127.0.0.1", "user", :port => 65535).yields(result = mock("session")) - yielded = false - gateway.ssh("app1", "user") do |newsess| - yielded = true - assert_equal result, newsess - end - assert yielded - assert gateway_session.forward.active_locals.empty? - end - - def test_shutdown_should_cancel_active_forwarded_ports - gateway_session, gateway = new_gateway - gateway.open("app1", 80) - assert !gateway_session.forward.active_locals.empty? - gateway.shutdown! - assert gateway_session.forward.active_locals.empty? - end - - private - - def expect_connect_to(host, user, options={}) - Net::SSH.expects(:start).with do |real_host, real_user, real_options| - host == real_host && - user == real_user && - options[:port] == real_options[:port] - end - end - - def new_gateway(options={}) - session = MockSession.new(options) - expect_connect_to("test.host", "tester").returns(session) - [session, Net::SSH::Gateway.new("test.host", "tester")] - end - - class MockForward - attr_reader :active_locals - - def initialize(options) - @options = options - @active_locals = {} - end - - def cancel_local(port) - @active_locals.delete(port) - end - - def local(lport, host, rport) - raise Errno::EADDRINUSE if @options[:reserved] && @options[:reserved][lport] - @active_locals[lport] = [lport, host, rport] - end - end - - class MockSession - attr_reader :forward - - def initialize(options={}) - @forward = MockForward.new(options) - end - - def close - end - - def process(wait=nil) - true - end - - def looping? - @looping - end - - def loop - @looping = true - sleep 0.1 while yield - @looping = false - end - end -end diff --git a/vendor/gems/open4-0.9.3/.specification b/vendor/gems/open4-0.9.3/.specification deleted file mode 100644 index 4f658f993..000000000 --- a/vendor/gems/open4-0.9.3/.specification +++ /dev/null @@ -1,68 +0,0 @@ ---- !ruby/object:Gem::Specification -name: open4 -version: !ruby/object:Gem::Version - version: 0.9.3 -platform: ruby -authors: -- Ara T. Howard -autorequire: open4 -bindir: bin -cert_chain: -date: 2007-03-26 00:00:00 +00:00 -default_executable: -dependencies: [] - -description: -email: ara.t.howard@noaa.gov -executables: [] - -extensions: [] - -extra_rdoc_files: [] - -files: -- install.rb -- sample -- sample/block.rb -- sample/simple.rb -- sample/exception.rb -- sample/spawn.rb -- sample/bg.rb -- sample/timeout.rb -- sample/stdin_timeout.rb -- lib -- lib/open4.rb -- lib/open4-0.9.3.rb -- README -- gemspec.rb -- open4-0.9.3.gem -- white_box -- white_box/leak.rb -has_rdoc: false -homepage: http://codeforpeople.com/lib/ruby/open4/ -post_install_message: -rdoc_options: [] - -require_paths: -- lib -required_ruby_version: !ruby/object:Gem::Requirement - requirements: - - - ">" - - !ruby/object:Gem::Version - version: 0.0.0 - version: -required_rubygems_version: !ruby/object:Gem::Requirement - requirements: - - - ">=" - - !ruby/object:Gem::Version - version: "0" - version: -requirements: [] - -rubyforge_project: -rubygems_version: 1.3.1 -signing_key: -specification_version: 1 -summary: open4 -test_files: [] - diff --git a/vendor/gems/open4-0.9.3/README b/vendor/gems/open4-0.9.3/README deleted file mode 100644 index 298f01948..000000000 --- a/vendor/gems/open4-0.9.3/README +++ /dev/null @@ -1,347 +0,0 @@ -URIS - - http://rubyforge.org/projects/codeforpeople/ - http://www.codeforpeople.com/lib/ruby/ - -SYNOPSIS - - open child process with handles on pid, stdin, stdout, and stderr: manage - child processes and their io handles easily. - -HISTORY - - 0.9.3: - - removed some debugging output accidentally left in 0.9.2. arggh! - - 0.9.2: - - fixed a descriptor leak. thanks Andre Nathan. - - 0.9.1: - - fixed warning with '-w' : @cid not initialized. thanks blaise tarr. - - 0.9.0: - - added the ability for open4.spawn to take either an array of arguments - or multiple arguments in order to specify the argv for the command run. - for example - - open4.spawn ['touch', 'difficult to "quote"'], :stdout=>STDOUT - - same thing - - open4.spawn 'touch', 'difficult to "quote"', :stdout=>STDOUT - - thanks to jordan breeding for this suggestion - - - - added 'cwd'/:cwd keyword. usage is pretty obivous - - open4.spawn 'pwd', 1=>STDOUT, :cwd=>'/tmp' #=> /tmp - - this one also from jordan - - 0.8.0: - - - fixed a critical bug whereby a process producing tons of stdout, but for - which the stdout was not handled, would cause the child process to - become blocked/hung writing to the pipe. eg, this command would cause a - hang - - include Open4 - - spawn 'ruby -e" puts Array.new(65536){ 42 } "' - - whereas this one would not - - include Open4 - - spawn 'ruby -e" puts Array.new(65536){ 42 } "', :stdout=>StringIO.new - - this version handles the former by spawning a 'null' thread which reads, - but does not process stdout/stderr. that way commands which generate - tons of output will never become blocked. - - 0.7.0: - - merged functionality of exitstatus/status keywords: - - include Open4 - - spawn 'ruby -e "exit 42"' # raises - spawn 'ruby -e "exit 42"', :status=>true # ok, returns status - spawn 'ruby -e "exit 42"', :status=>42 # raises if status != 42 - spawn 'ruby -e "exit 42"', :status=>0,42 # raises if status != 0||42 - - - the 0.6.0 was broken on rubyforge... this release fixes that (somehow!?) - - 0.6.0: - - added feature for exitstatus to be list of acceptable exit statuses - - Open4.spawn 'ruby -e "exit 42"' # raises - Open4.spawn 'ruby -e "exit 42"', :exitstatus=>[0,42] # ok - - - added :status switch, which will always simply return the status (no - error thrown for failure) - - Open4.spawn 'ruby -e "exit 42"' # raises - status = Open4.spawn 'ruby -e "exit 42"', :status=>true # ok - - note, however, that any SpawnError does in fact contain the failed - status so, even when they are thrown, error status can be retrieved: - - include Open4 - - status = - begin - spawn 'ruby -e "exit 42"' - rescue SpawnError => e - warn{ e } - e.status - end - - 0.5.1: - - fixes a __critical__ but in ThreadEnsemble class that had a race - condition that could cause thread deadlock. sorry bout that folks. - - 0.5.0: - - on the suggestion of tim pease (thanks tim!), i added timeout features - to open4. the command run may have an overall timeout and individual - timeouts set for each of the io handles. for example - - cmd = 'command_that_produce_out_at_one_second_intervals' - - open4.spawn cmd, :stdout_timeout => 2 - - or - - cmd = 'command_that_should_complete_in_about_one_minute' - - open4.spawn cmd, :timeout => 60 - - or - - cmd = 'consumes_input_at_one_line_per_second_rate' - - input = %w( 42 forty-two 42.0 ) - - open4.spawn cmd, :stdin=>input, :stdin_timeout=>1 - - - added 'open4' alias so one can write - - open4.spawn vs Open4.spawn - - or even - - open4(cmd) do |pid,i,o,e| - end - - - added signal info to SpawnError - - 0.4.0: - - improved error handling contributed by jordan breeding. - - introduction of background/bg method - - 0.3.0 : - - bug fix from jordan breeding. general clean up. added spawn method. - - 0.2.0 : - - added exception marshaled from child -> parent when exec fails. thanks - to jordan breeding for a patch (yay!) and paul brannan for this most - excellent idea. - - 0.1.0 : - - fixed docs to correctly show return value of popen4 (pid first not last). - thanks Stefanie Tellex for catching this. - 0.0.0 : - - initial version - -INSTALL - - ~> gem install open4 - -SAMPLES - - ---------------------------------------------------------------------------- - simple usage - ---------------------------------------------------------------------------- - - harp: > cat sample/simple.rb - require "open4" - - pid, stdin, stdout, stderr = Open4::popen4 "sh" - - stdin.puts "echo 42.out" - stdin.puts "echo 42.err 1>&2" - stdin.close - - ignored, status = Process::waitpid2 pid - - puts "pid : #{ pid }" - puts "stdout : #{ stdout.read.strip }" - puts "stderr : #{ stderr.read.strip }" - puts "status : #{ status.inspect }" - puts "exitstatus : #{ status.exitstatus }" - - - harp: > ruby sample/simple.rb - pid : 17273 - stdout : 42.out - stderr : 42.err - status : # - exitstatus : 0 - - - ---------------------------------------------------------------------------- - in block form - the child process is automatically waited for - ---------------------------------------------------------------------------- - - harp: > cat sample/block.rb - require 'open4' - - status = - Open4::popen4("sh") do |pid, stdin, stdout, stderr| - stdin.puts "echo 42.out" - stdin.puts "echo 42.err 1>&2" - stdin.close - - puts "pid : #{ pid }" - puts "stdout : #{ stdout.read.strip }" - puts "stderr : #{ stderr.read.strip }" - end - - puts "status : #{ status.inspect }" - puts "exitstatus : #{ status.exitstatus }" - - - harp: > ruby sample/block.rb - pid : 17295 - stdout : 42.out - stderr : 42.err - status : # - exitstatus : 0 - - ---------------------------------------------------------------------------- - exceptions are marshaled from child to parent if fork/exec fails - ---------------------------------------------------------------------------- - - harp: > cat sample/exception.rb - require "open4" - Open4::popen4 "noexist" - - - harp: > ruby sample/exception.rb - /dmsp/reference/ruby-1.8.1//lib/ruby/site_ruby/open4.rb:100:in `popen4': No such file or directory - noexist (Errno::ENOENT) - from sample/exception.rb:3 - - ---------------------------------------------------------------------------- - the spawn method provides and even more convenient method of running a - process, allowing any object that supports 'each', 'read', or 'to_s' to be - given as stdin and any objects that support '<<' to be given as - stdout/stderr. an exception is thrown if the exec'd cmd fails (nonzero - exitstatus) unless the option 'raise'=>false is given - ---------------------------------------------------------------------------- - - harp: > cat sample/spawn.rb - require 'open4' - include Open4 - - cat = ' ruby -e" ARGF.each{|line| STDOUT << line} " ' - - stdout, stderr = '', '' - status = spawn cat, 'stdin' => '42', 'stdout' => stdout, 'stderr' => stderr - p status - p stdout - p stderr - - stdout, stderr = '', '' - status = spawn cat, 0=>'42', 1=>stdout, 2=>stderr - p status - p stdout - p stderr - - - harp: > RUBYLIB=lib ruby sample/spawn.rb - 0 - "42" - "" - 0 - "42" - "" - - - ---------------------------------------------------------------------------- - the bg/background method is similar to spawn, but the process is - automatically set running in a thread. the returned thread has several - methods added dynamically which return the pid and blocking calls to the - exitstatus. - ---------------------------------------------------------------------------- - - harp: > cat sample/bg.rb - require 'yaml' - require 'open4' - include Open4 - - stdin = '42' - stdout = '' - stderr = '' - - t = bg 'ruby -e"sleep 4; puts ARGF.read"', 0=>stdin, 1=>stdout, 2=>stderr - - waiter = Thread.new{ y t.pid => t.exitstatus } # t.exitstatus is a blocking call! - - while((status = t.status)) - y "status" => status - sleep 1 - end - - waiter.join - - y "stdout" => stdout - - - harp: > ruby sample/bg.rb - --- - status: run - --- - status: sleep - --- - status: sleep - --- - status: sleep - --- - 21357: 0 - --- - stdout: "42\n" - - ---------------------------------------------------------------------------- - the timeout methods can be used to ensure execution is preceding at the - desired interval. note also how to setup a 'pipeline' - ---------------------------------------------------------------------------- - - harp: > cat sample/stdin_timeout.rb - require 'open4' - - producer = 'ruby -e" STDOUT.sync = true; loop{sleep(rand+rand) and puts 42} "' - - consumer = 'ruby -e" STDOUT.sync = true; STDIN.each{|line| puts line} "' - - open4(producer) do |pid, i, o, e| - - open4.spawn consumer, :stdin=>o, :stdout=>STDOUT, :stdin_timeout => 1.4 - - end - - - harp: > ruby sample/stdin_timeout.rb - 42 - 42 - 42 - 42 - 42 - /dmsp/reference/ruby-1.8.1//lib/ruby/1.8/timeout.rb:42:in `relay': execution expired (Timeout::Error) - -AUTHOR - - ara.t.howard@noaa.gov - -LICENSE - - ruby's diff --git a/vendor/gems/open4-0.9.3/gemspec.rb b/vendor/gems/open4-0.9.3/gemspec.rb deleted file mode 100644 index b678d8a1a..000000000 --- a/vendor/gems/open4-0.9.3/gemspec.rb +++ /dev/null @@ -1,23 +0,0 @@ -lib, version = File::basename(File::dirname(File::expand_path(__FILE__))).split %r/-/, 2 - -require 'rubygems' - -Gem::Specification::new do |spec| - spec.name = lib - spec.version = version - spec.platform = Gem::Platform::RUBY - spec.summary = lib - - spec.files = Dir::glob "**/**" - spec.executables = Dir::glob("bin/*").map{|exe| File::basename exe} - - spec.require_path = "lib" - spec.autorequire = lib - - spec.has_rdoc = File::exist? "doc" - spec.test_suite_file = "test/#{ lib }.rb" if File::directory? "test" - - spec.author = "Ara T. Howard" - spec.email = "ara.t.howard@noaa.gov" - spec.homepage = "http://codeforpeople.com/lib/ruby/#{ lib }/" -end diff --git a/vendor/gems/open4-0.9.3/install.rb b/vendor/gems/open4-0.9.3/install.rb deleted file mode 100644 index 417618619..000000000 --- a/vendor/gems/open4-0.9.3/install.rb +++ /dev/null @@ -1,201 +0,0 @@ -#!/usr/bin/env ruby -require 'rbconfig' -require 'find' -require 'ftools' -require 'tempfile' -include Config - -LIBDIR = "lib" -LIBDIR_MODE = 0644 - -BINDIR = "bin" -BINDIR_MODE = 0755 - - -$srcdir = CONFIG["srcdir"] -$version = CONFIG["MAJOR"]+"."+CONFIG["MINOR"] -$libdir = File.join(CONFIG["libdir"], "ruby", $version) -$archdir = File.join($libdir, CONFIG["arch"]) -$site_libdir = $:.find {|x| x =~ /site_ruby$/} -$bindir = CONFIG["bindir"] || CONFIG['BINDIR'] -$ruby_install_name = CONFIG['ruby_install_name'] || CONFIG['RUBY_INSTALL_NAME'] || 'ruby' -$ruby_ext = CONFIG['EXEEXT'] || '' -$ruby = File.join($bindir, ($ruby_install_name + $ruby_ext)) - -if !$site_libdir - $site_libdir = File.join($libdir, "site_ruby") -elsif $site_libdir !~ %r/#{Regexp.quote($version)}/ - $site_libdir = File.join($site_libdir, $version) -end - -def install_rb(srcdir=nil, destdir=nil, mode=nil, bin=nil) -#{{{ - path = [] - dir = [] - Find.find(srcdir) do |f| - next unless FileTest.file?(f) - next if (f = f[srcdir.length+1..-1]) == nil - next if (/CVS$/ =~ File.dirname(f)) - next if f =~ %r/\.lnk/ - path.push f - dir |= [File.dirname(f)] - end - for f in dir - next if f == "." - next if f == "CVS" - File::makedirs(File.join(destdir, f)) - end - for f in path - next if (/\~$/ =~ f) - next if (/^\./ =~ File.basename(f)) - unless bin - File::install(File.join(srcdir, f), File.join(destdir, f), mode, true) - else - from = File.join(srcdir, f) - to = File.join(destdir, f) - shebangify(from) do |sf| - $deferr.print from, " -> ", File::catname(from, to), "\n" - $deferr.printf "chmod %04o %s\n", mode, to - File::install(sf, to, mode, false) - end - end - end -#}}} -end -def shebangify f -#{{{ - open(f) do |fd| - buf = fd.read 42 - if buf =~ %r/^\s*#\s*!.*ruby/o - ftmp = Tempfile::new("#{ $$ }_#{ File::basename(f) }") - begin - fd.rewind - ftmp.puts "#!#{ $ruby }" - while((buf = fd.read(8192))) - ftmp.write buf - end - ftmp.close - yield ftmp.path - ensure - ftmp.close! - end - else - yield f - end - end -#}}} -end -def ARGV.switch -#{{{ - return nil if self.empty? - arg = self.shift - return nil if arg == '--' - if arg =~ /^-(.)(.*)/ - return arg if $1 == '-' - raise 'unknown switch "-"' if $2.index('-') - self.unshift "-#{$2}" if $2.size > 0 - "-#{$1}" - else - self.unshift arg - nil - end -#}}} -end -def ARGV.req_arg -#{{{ - self.shift || raise('missing argument') -#}}} -end -def linkify d, linked = [] -#--{{{ - if test ?d, d - versioned = Dir[ File::join(d, "*-[0-9].[0-9].[0-9].rb") ] - versioned.each do |v| - src, dst = v, v.gsub(%r/\-[\d\.]+\.rb$/, '.rb') - lnk = nil - begin - if test ?l, dst - lnk = "#{ dst }.lnk" - puts "#{ dst } -> #{ lnk }" - File::rename dst, lnk - end - unless test ?e, dst - puts "#{ src } -> #{ dst }" - File::copy src, dst - linked << dst - end - ensure - if lnk - at_exit do - puts "#{ lnk } -> #{ dst }" - File::rename lnk, dst - end - end - end - end - end - linked -#--}}} -end - - -# -# main program -# - -libdir = $site_libdir -bindir = $bindir -no_linkify = false -linked = nil -help = false - -usage = <<-usage - #{ File::basename $0 } - -d, --destdir - -l, --libdir - -b, --bindir - -r, --ruby - -n, --no_linkify - -h, --help -usage - -begin - while switch = ARGV.switch - case switch - when '-d', '--destdir' - libdir = ARGV.req_arg - when '-l', '--libdir' - libdir = ARGV.req_arg - when '-b', '--bindir' - bindir = ARGV.req_arg - when '-r', '--ruby' - $ruby = ARGV.req_arg - when '-n', '--no_linkify' - no_linkify = true - when '-h', '--help' - help = true - else - raise "unknown switch #{switch.dump}" - end - end -rescue - STDERR.puts $!.to_s - STDERR.puts usage - exit 1 -end - -if help - STDOUT.puts usage - exit -end - -unless no_linkify - linked = linkify('lib') + linkify('bin') -end - -install_rb(LIBDIR, libdir, LIBDIR_MODE) -install_rb(BINDIR, bindir, BINDIR_MODE, bin=true) - -if linked - linked.each{|path| File::rm_f path} -end diff --git a/vendor/gems/open4-0.9.3/lib/open4-0.9.3.rb b/vendor/gems/open4-0.9.3/lib/open4-0.9.3.rb deleted file mode 100644 index 69c12867f..000000000 --- a/vendor/gems/open4-0.9.3/lib/open4-0.9.3.rb +++ /dev/null @@ -1,381 +0,0 @@ -require 'fcntl' -require 'timeout' -require 'thread' - -module Open4 -#--{{{ - VERSION = '0.9.3' - def self.version() VERSION end - - class Error < ::StandardError; end - - def popen4(*cmd, &b) -#--{{{ - pw, pr, pe, ps = IO.pipe, IO.pipe, IO.pipe, IO.pipe - - verbose = $VERBOSE - begin - $VERBOSE = nil - ps.last.fcntl(Fcntl::F_SETFD, Fcntl::FD_CLOEXEC) - - cid = fork { - pw.last.close - STDIN.reopen pw.first - pw.first.close - - pr.first.close - STDOUT.reopen pr.last - pr.last.close - - pe.first.close - STDERR.reopen pe.last - pe.last.close - - STDOUT.sync = STDERR.sync = true - - begin - exec(*cmd) - raise 'forty-two' - rescue Exception => e - Marshal.dump(e, ps.last) - ps.last.flush - end - ps.last.close unless (ps.last.closed?) - exit! - } - ensure - $VERBOSE = verbose - end - - [pw.first, pr.last, pe.last, ps.last].each{|fd| fd.close} - - begin - e = Marshal.load ps.first - raise(Exception === e ? e : "unknown failure!") - rescue EOFError # If we get an EOF error, then the exec was successful - 42 - ensure - ps.first.close - end - - pw.last.sync = true - - pi = [pw.last, pr.first, pe.first] - - if b - begin - b[cid, *pi] - Process.waitpid2(cid).last - ensure - pi.each{|fd| fd.close unless fd.closed?} - end - else - [cid, pw.last, pr.first, pe.first] - end -#--}}} - end - alias open4 popen4 - module_function :popen4 - module_function :open4 - - class SpawnError < Error -#--{{{ - attr 'cmd' - attr 'status' - attr 'signals' - def exitstatus - @status.exitstatus - end - def initialize cmd, status - @cmd, @status = cmd, status - @signals = {} - if status.signaled? - @signals['termsig'] = status.termsig - @signals['stopsig'] = status.stopsig - end - sigs = @signals.map{|k,v| "#{ k }:#{ v.inspect }"}.join(' ') - super "cmd <#{ cmd }> failed with status <#{ exitstatus.inspect }> signals <#{ sigs }>" - end -#--}}} - end - - class ThreadEnsemble -#--{{{ - attr 'threads' - - def initialize cid - @cid, @threads, @argv, @done, @running = cid, [], [], Queue.new, false - @killed = false - end - - def add_thread *a, &b - @running ? raise : (@argv << [a, b]) - end - -# -# take down process more nicely -# - def killall - c = Thread.critical - return nil if @killed - Thread.critical = true - (@threads - [Thread.current]).each{|t| t.kill rescue nil} - @killed = true - ensure - Thread.critical = c - end - - def run - @running = true - - begin - @argv.each do |a, b| - @threads << Thread.new(*a) do |*a| - begin - b[*a] - ensure - killall rescue nil if $! - @done.push Thread.current - end - end - end - rescue - killall - raise - ensure - all_done - end - - @threads.map{|t| t.value} - end - - def all_done - @threads.size.times{ @done.pop } - end -#--}}} - end - - def to timeout = nil -#--{{{ - Timeout.timeout(timeout){ yield } -#--}}} - end - module_function :to - - def new_thread *a, &b -#--{{{ - cur = Thread.current - Thread.new(*a) do |*a| - begin - b[*a] - rescue Exception => e - cur.raise e - end - end -#--}}} - end - module_function :new_thread - - def getopts opts = {} -#--{{{ - lambda do |*args| - keys, default, ignored = args - catch('opt') do - [keys].flatten.each do |key| - [key, key.to_s, key.to_s.intern].each do |key| - throw 'opt', opts[key] if opts.has_key?(key) - end - end - default - end - end -#--}}} - end - module_function :getopts - - def relay src, dst = nil, t = nil -#--{{{ - unless src.nil? - if src.respond_to? :gets - while buf = to(t){ src.gets } - dst << buf if dst - end - - elsif src.respond_to? :each - q = Queue.new - th = nil - - timer_set = lambda do |t| - th = new_thread{ to(t){ q.pop } } - end - - timer_cancel = lambda do |t| - th.kill if th rescue nil - end - - timer_set[t] - begin - src.each do |buf| - timer_cancel[t] - dst << buf if dst - timer_set[t] - end - ensure - timer_cancel[t] - end - - elsif src.respond_to? :read - buf = to(t){ src.read } - dst << buf if dst - - else - buf = to(t){ src.to_s } - dst << buf if dst - end - end -#--}}} - end - module_function :relay - - def spawn arg, *argv -#--{{{ - argv.unshift(arg) - opts = ((argv.size > 1 and Hash === argv.last) ? argv.pop : {}) - argv.flatten! - cmd = argv.join(' ') - - - getopt = getopts opts - - ignore_exit_failure = getopt[ 'ignore_exit_failure', getopt['quiet', false] ] - ignore_exec_failure = getopt[ 'ignore_exec_failure', !getopt['raise', true] ] - exitstatus = getopt[ %w( exitstatus exit_status status ) ] - stdin = getopt[ %w( stdin in i 0 ) << 0 ] - stdout = getopt[ %w( stdout out o 1 ) << 1 ] - stderr = getopt[ %w( stderr err e 2 ) << 2 ] - pid = getopt[ 'pid' ] - timeout = getopt[ %w( timeout spawn_timeout ) ] - stdin_timeout = getopt[ %w( stdin_timeout ) ] - stdout_timeout = getopt[ %w( stdout_timeout io_timeout ) ] - stderr_timeout = getopt[ %w( stderr_timeout ) ] - status = getopt[ %w( status ) ] - cwd = getopt[ %w( cwd dir ), Dir.pwd ] - - exitstatus = - case exitstatus - when TrueClass, FalseClass - ignore_exit_failure = true if exitstatus - [0] - else - [*(exitstatus || 0)].map{|i| Integer i} - end - - stdin ||= '' if stdin_timeout - stdout ||= '' if stdout_timeout - stderr ||= '' if stderr_timeout - - started = false - - status = - begin - Dir.chdir(cwd) do - Timeout::timeout(timeout) do - popen4(*argv) do |c, i, o, e| - started = true - - %w( replace pid= << push update ).each do |msg| - break(pid.send(msg, c)) if pid.respond_to? msg - end - - te = ThreadEnsemble.new c - - te.add_thread(i, stdin) do |i, stdin| - relay stdin, i, stdin_timeout - i.close rescue nil - end - - te.add_thread(o, stdout) do |o, stdout| - relay o, stdout, stdout_timeout - end - - te.add_thread(e, stderr) do |o, stderr| - relay e, stderr, stderr_timeout - end - - te.run - end - end - end - rescue - raise unless(not started and ignore_exec_failure) - end - - raise SpawnError.new(cmd, status) unless - (ignore_exit_failure or (status.nil? and ignore_exec_failure) or exitstatus.include?(status.exitstatus)) - - status -#--}}} - end - module_function :spawn - - def background arg, *argv -#--{{{ - require 'thread' - q = Queue.new - opts['pid'] = opts[:pid] = q - thread = Thread.new(arg, argv){|arg, argv| spawn arg, *argv} - pid = q.pop - sc = class << thread; self; end - sc.module_eval { - define_method(:pid){ pid } - define_method(:spawn_status){ @spawn_status ||= value } - define_method(:exitstatus){ spawn_status.exitstatus } - } - thread -#--}}} - end - alias bg background - module_function :background - module_function :bg - - def maim pid, opts = {} -#--{{{ - getopt = getopts opts - sigs = getopt[ 'signals', %w(SIGTERM SIGQUIT SIGKILL) ] - suspend = getopt[ 'suspend', 4 ] - pid = Integer pid - existed = false - sigs.each do |sig| - begin - Process.kill sig, pid - existed = true - rescue Errno::ESRCH - return(existed ? nil : true) - end - return true unless alive? pid - sleep suspend - return true unless alive? pid - end - return(not alive?(pid)) -#--}}} - end - module_function :maim - - def alive pid -#--{{{ - pid = Integer pid - begin - Process.kill 0, pid - true - rescue Errno::ESRCH - false - end -#--}}} - end - alias alive? alive - module_function :alive - module_function :'alive?' -#--}}} -end - -def open4(*cmd, &b) cmd.size == 0 ? Open4 : Open4::popen4(*cmd, &b) end diff --git a/vendor/gems/open4-0.9.3/lib/open4.rb b/vendor/gems/open4-0.9.3/lib/open4.rb deleted file mode 100644 index 69c12867f..000000000 --- a/vendor/gems/open4-0.9.3/lib/open4.rb +++ /dev/null @@ -1,381 +0,0 @@ -require 'fcntl' -require 'timeout' -require 'thread' - -module Open4 -#--{{{ - VERSION = '0.9.3' - def self.version() VERSION end - - class Error < ::StandardError; end - - def popen4(*cmd, &b) -#--{{{ - pw, pr, pe, ps = IO.pipe, IO.pipe, IO.pipe, IO.pipe - - verbose = $VERBOSE - begin - $VERBOSE = nil - ps.last.fcntl(Fcntl::F_SETFD, Fcntl::FD_CLOEXEC) - - cid = fork { - pw.last.close - STDIN.reopen pw.first - pw.first.close - - pr.first.close - STDOUT.reopen pr.last - pr.last.close - - pe.first.close - STDERR.reopen pe.last - pe.last.close - - STDOUT.sync = STDERR.sync = true - - begin - exec(*cmd) - raise 'forty-two' - rescue Exception => e - Marshal.dump(e, ps.last) - ps.last.flush - end - ps.last.close unless (ps.last.closed?) - exit! - } - ensure - $VERBOSE = verbose - end - - [pw.first, pr.last, pe.last, ps.last].each{|fd| fd.close} - - begin - e = Marshal.load ps.first - raise(Exception === e ? e : "unknown failure!") - rescue EOFError # If we get an EOF error, then the exec was successful - 42 - ensure - ps.first.close - end - - pw.last.sync = true - - pi = [pw.last, pr.first, pe.first] - - if b - begin - b[cid, *pi] - Process.waitpid2(cid).last - ensure - pi.each{|fd| fd.close unless fd.closed?} - end - else - [cid, pw.last, pr.first, pe.first] - end -#--}}} - end - alias open4 popen4 - module_function :popen4 - module_function :open4 - - class SpawnError < Error -#--{{{ - attr 'cmd' - attr 'status' - attr 'signals' - def exitstatus - @status.exitstatus - end - def initialize cmd, status - @cmd, @status = cmd, status - @signals = {} - if status.signaled? - @signals['termsig'] = status.termsig - @signals['stopsig'] = status.stopsig - end - sigs = @signals.map{|k,v| "#{ k }:#{ v.inspect }"}.join(' ') - super "cmd <#{ cmd }> failed with status <#{ exitstatus.inspect }> signals <#{ sigs }>" - end -#--}}} - end - - class ThreadEnsemble -#--{{{ - attr 'threads' - - def initialize cid - @cid, @threads, @argv, @done, @running = cid, [], [], Queue.new, false - @killed = false - end - - def add_thread *a, &b - @running ? raise : (@argv << [a, b]) - end - -# -# take down process more nicely -# - def killall - c = Thread.critical - return nil if @killed - Thread.critical = true - (@threads - [Thread.current]).each{|t| t.kill rescue nil} - @killed = true - ensure - Thread.critical = c - end - - def run - @running = true - - begin - @argv.each do |a, b| - @threads << Thread.new(*a) do |*a| - begin - b[*a] - ensure - killall rescue nil if $! - @done.push Thread.current - end - end - end - rescue - killall - raise - ensure - all_done - end - - @threads.map{|t| t.value} - end - - def all_done - @threads.size.times{ @done.pop } - end -#--}}} - end - - def to timeout = nil -#--{{{ - Timeout.timeout(timeout){ yield } -#--}}} - end - module_function :to - - def new_thread *a, &b -#--{{{ - cur = Thread.current - Thread.new(*a) do |*a| - begin - b[*a] - rescue Exception => e - cur.raise e - end - end -#--}}} - end - module_function :new_thread - - def getopts opts = {} -#--{{{ - lambda do |*args| - keys, default, ignored = args - catch('opt') do - [keys].flatten.each do |key| - [key, key.to_s, key.to_s.intern].each do |key| - throw 'opt', opts[key] if opts.has_key?(key) - end - end - default - end - end -#--}}} - end - module_function :getopts - - def relay src, dst = nil, t = nil -#--{{{ - unless src.nil? - if src.respond_to? :gets - while buf = to(t){ src.gets } - dst << buf if dst - end - - elsif src.respond_to? :each - q = Queue.new - th = nil - - timer_set = lambda do |t| - th = new_thread{ to(t){ q.pop } } - end - - timer_cancel = lambda do |t| - th.kill if th rescue nil - end - - timer_set[t] - begin - src.each do |buf| - timer_cancel[t] - dst << buf if dst - timer_set[t] - end - ensure - timer_cancel[t] - end - - elsif src.respond_to? :read - buf = to(t){ src.read } - dst << buf if dst - - else - buf = to(t){ src.to_s } - dst << buf if dst - end - end -#--}}} - end - module_function :relay - - def spawn arg, *argv -#--{{{ - argv.unshift(arg) - opts = ((argv.size > 1 and Hash === argv.last) ? argv.pop : {}) - argv.flatten! - cmd = argv.join(' ') - - - getopt = getopts opts - - ignore_exit_failure = getopt[ 'ignore_exit_failure', getopt['quiet', false] ] - ignore_exec_failure = getopt[ 'ignore_exec_failure', !getopt['raise', true] ] - exitstatus = getopt[ %w( exitstatus exit_status status ) ] - stdin = getopt[ %w( stdin in i 0 ) << 0 ] - stdout = getopt[ %w( stdout out o 1 ) << 1 ] - stderr = getopt[ %w( stderr err e 2 ) << 2 ] - pid = getopt[ 'pid' ] - timeout = getopt[ %w( timeout spawn_timeout ) ] - stdin_timeout = getopt[ %w( stdin_timeout ) ] - stdout_timeout = getopt[ %w( stdout_timeout io_timeout ) ] - stderr_timeout = getopt[ %w( stderr_timeout ) ] - status = getopt[ %w( status ) ] - cwd = getopt[ %w( cwd dir ), Dir.pwd ] - - exitstatus = - case exitstatus - when TrueClass, FalseClass - ignore_exit_failure = true if exitstatus - [0] - else - [*(exitstatus || 0)].map{|i| Integer i} - end - - stdin ||= '' if stdin_timeout - stdout ||= '' if stdout_timeout - stderr ||= '' if stderr_timeout - - started = false - - status = - begin - Dir.chdir(cwd) do - Timeout::timeout(timeout) do - popen4(*argv) do |c, i, o, e| - started = true - - %w( replace pid= << push update ).each do |msg| - break(pid.send(msg, c)) if pid.respond_to? msg - end - - te = ThreadEnsemble.new c - - te.add_thread(i, stdin) do |i, stdin| - relay stdin, i, stdin_timeout - i.close rescue nil - end - - te.add_thread(o, stdout) do |o, stdout| - relay o, stdout, stdout_timeout - end - - te.add_thread(e, stderr) do |o, stderr| - relay e, stderr, stderr_timeout - end - - te.run - end - end - end - rescue - raise unless(not started and ignore_exec_failure) - end - - raise SpawnError.new(cmd, status) unless - (ignore_exit_failure or (status.nil? and ignore_exec_failure) or exitstatus.include?(status.exitstatus)) - - status -#--}}} - end - module_function :spawn - - def background arg, *argv -#--{{{ - require 'thread' - q = Queue.new - opts['pid'] = opts[:pid] = q - thread = Thread.new(arg, argv){|arg, argv| spawn arg, *argv} - pid = q.pop - sc = class << thread; self; end - sc.module_eval { - define_method(:pid){ pid } - define_method(:spawn_status){ @spawn_status ||= value } - define_method(:exitstatus){ spawn_status.exitstatus } - } - thread -#--}}} - end - alias bg background - module_function :background - module_function :bg - - def maim pid, opts = {} -#--{{{ - getopt = getopts opts - sigs = getopt[ 'signals', %w(SIGTERM SIGQUIT SIGKILL) ] - suspend = getopt[ 'suspend', 4 ] - pid = Integer pid - existed = false - sigs.each do |sig| - begin - Process.kill sig, pid - existed = true - rescue Errno::ESRCH - return(existed ? nil : true) - end - return true unless alive? pid - sleep suspend - return true unless alive? pid - end - return(not alive?(pid)) -#--}}} - end - module_function :maim - - def alive pid -#--{{{ - pid = Integer pid - begin - Process.kill 0, pid - true - rescue Errno::ESRCH - false - end -#--}}} - end - alias alive? alive - module_function :alive - module_function :'alive?' -#--}}} -end - -def open4(*cmd, &b) cmd.size == 0 ? Open4 : Open4::popen4(*cmd, &b) end diff --git a/vendor/gems/open4-0.9.3/open4-0.9.3.gem b/vendor/gems/open4-0.9.3/open4-0.9.3.gem deleted file mode 100644 index e69de29bb..000000000 diff --git a/vendor/gems/open4-0.9.3/sample/bg.rb b/vendor/gems/open4-0.9.3/sample/bg.rb deleted file mode 100644 index 1dcf3e88d..000000000 --- a/vendor/gems/open4-0.9.3/sample/bg.rb +++ /dev/null @@ -1,21 +0,0 @@ -require 'yaml' -require 'open4' -include Open4 - -stdin = '42' -stdout = '' -stderr = '' - -t = bg 'ruby -e"sleep 4; puts ARGF.read"', 0=>stdin, 1=>stdout, 2=>stderr - -waiter = Thread.new{ y t.pid => t.exitstatus } # t.exitstatus is a blocking call! - -while((status = t.status)) - y "status" => status - sleep 1 -end - -waiter.join - -y "stdout" => stdout - diff --git a/vendor/gems/open4-0.9.3/sample/block.rb b/vendor/gems/open4-0.9.3/sample/block.rb deleted file mode 100644 index 320f5c3f2..000000000 --- a/vendor/gems/open4-0.9.3/sample/block.rb +++ /dev/null @@ -1,19 +0,0 @@ -require 'open4' -# -# when using block form the child process is automatically waited using -# waitpid2 -# - -status = - Open4::popen4("sh") do |pid, stdin, stdout, stderr| - stdin.puts "echo 42.out" - stdin.puts "echo 42.err 1>&2" - stdin.close - - puts "pid : #{ pid }" - puts "stdout : #{ stdout.read.strip }" - puts "stderr : #{ stderr.read.strip }" - end - - puts "status : #{ status.inspect }" - puts "exitstatus : #{ status.exitstatus }" diff --git a/vendor/gems/open4-0.9.3/sample/exception.rb b/vendor/gems/open4-0.9.3/sample/exception.rb deleted file mode 100644 index 3294c02b8..000000000 --- a/vendor/gems/open4-0.9.3/sample/exception.rb +++ /dev/null @@ -1,3 +0,0 @@ -require "open4" - -Open4::popen4 "noexist" diff --git a/vendor/gems/open4-0.9.3/sample/simple.rb b/vendor/gems/open4-0.9.3/sample/simple.rb deleted file mode 100644 index 7b44b8352..000000000 --- a/vendor/gems/open4-0.9.3/sample/simple.rb +++ /dev/null @@ -1,15 +0,0 @@ -require "open4" - -pid, stdin, stdout, stderr = Open4::popen4 "sh" - -stdin.puts "echo 42.out" -stdin.puts "echo 42.err 1>&2" -stdin.close - -ignored, status = Process::waitpid2 pid - -puts "pid : #{ pid }" -puts "stdout : #{ stdout.read.strip }" -puts "stderr : #{ stderr.read.strip }" -puts "status : #{ status.inspect }" -puts "exitstatus : #{ status.exitstatus }" diff --git a/vendor/gems/open4-0.9.3/sample/spawn.rb b/vendor/gems/open4-0.9.3/sample/spawn.rb deleted file mode 100644 index de7401685..000000000 --- a/vendor/gems/open4-0.9.3/sample/spawn.rb +++ /dev/null @@ -1,16 +0,0 @@ -require 'open4' -include Open4 - -cat = 'ruby -e" ARGF.each{|line| STDOUT << line} "' - -stdout, stderr = '', '' -status = spawn cat, 'stdin' => '42', 'stdout' => stdout, 'stderr' => stderr -p status -p stdout -p stderr - -stdout, stderr = '', '' -status = spawn cat, 0=>'42', 1=>stdout, 2=>stderr -p status -p stdout -p stderr diff --git a/vendor/gems/open4-0.9.3/sample/stdin_timeout.rb b/vendor/gems/open4-0.9.3/sample/stdin_timeout.rb deleted file mode 100644 index 8680bee23..000000000 --- a/vendor/gems/open4-0.9.3/sample/stdin_timeout.rb +++ /dev/null @@ -1,9 +0,0 @@ -require 'open4' - -producer = 'ruby -e" STDOUT.sync = true; loop{sleep(rand+rand) and puts 42} " 2>/dev/null' - -consumer = 'ruby -e" STDOUT.sync = true; STDIN.each{|line| puts line} "' - -open4(producer) do |pid, i, o, e| - open4.spawn consumer, 0=>o, 1=>STDOUT, :stdin_timeout => 1.4 -end diff --git a/vendor/gems/open4-0.9.3/sample/timeout.rb b/vendor/gems/open4-0.9.3/sample/timeout.rb deleted file mode 100644 index 8b68d1cba..000000000 --- a/vendor/gems/open4-0.9.3/sample/timeout.rb +++ /dev/null @@ -1,37 +0,0 @@ - -require 'open4' - -def show_failure - fork{ yield } - Process.wait - puts -end - -# -# command timeout -# - show_failure{ - open4.spawn 'sleep 42', 'timeout' => 1 - } - -# -# stdin timeout -# - show_failure{ - - producer = 'ruby -e" STDOUT.sync = true; loop{sleep(rand+rand) and puts 42} " 2>/dev/null' - - consumer = 'ruby -e" STDOUT.sync = true; STDIN.each{|line| puts line} "' - - open4(producer) do |pid, i, o, e| - open4.spawn consumer, 0=>o, 1=>STDOUT, :stdin_timeout => 1.4 - end - } - -# -# stdout timeout (stderr is similar) -# - - show_failure{ - open4.spawn 'ruby -e" sleep 2 and puts 42 "', 'stdout_timeout' => 1 - } diff --git a/vendor/gems/open4-0.9.3/white_box/leak.rb b/vendor/gems/open4-0.9.3/white_box/leak.rb deleted file mode 100644 index a724c7a66..000000000 --- a/vendor/gems/open4-0.9.3/white_box/leak.rb +++ /dev/null @@ -1,17 +0,0 @@ -require 'open4' - -pid = Process.pid -fds = lambda{|pid| Dir["/proc/#{ pid }/fd/*"]} - -loop do - before = fds[pid] - Open4.popen4 'ruby -e"buf = STDIN.read; STDOUT.puts buf; STDERR.puts buf "' do |p,i,o,e| - i.puts 42 - i.close_write - o.read - e.read - end - after = fds[pid] - p(after - before) - puts -end diff --git a/vendor/gems/syntax-1.0.0/.specification b/vendor/gems/syntax-1.0.0/.specification deleted file mode 100644 index b56f69948..000000000 --- a/vendor/gems/syntax-1.0.0/.specification +++ /dev/null @@ -1,72 +0,0 @@ ---- !ruby/object:Gem::Specification -name: syntax -version: !ruby/object:Gem::Version - version: 1.0.0 -platform: ruby -authors: -- Jamis Buck -autorequire: syntax -bindir: bin -cert_chain: -date: 2005-06-18 00:00:00 +00:00 -default_executable: -dependencies: [] - -description: -email: jamis@jamisbuck.org -executables: [] - -extensions: [] - -extra_rdoc_files: [] - -files: -- data/ruby.css -- data/xml.css -- data/yaml.css -- lib/syntax -- lib/syntax.rb -- lib/syntax/common.rb -- lib/syntax/convertors -- lib/syntax/lang -- lib/syntax/version.rb -- lib/syntax/convertors/abstract.rb -- lib/syntax/convertors/html.rb -- lib/syntax/lang/ruby.rb -- lib/syntax/lang/xml.rb -- lib/syntax/lang/yaml.rb -- test/ALL-TESTS.rb -- test/syntax -- test/tc_syntax.rb -- test/syntax/tc_ruby.rb -- test/syntax/tc_xml.rb -- test/syntax/tc_yaml.rb -- test/syntax/tokenizer_testcase.rb -has_rdoc: true -homepage: -post_install_message: -rdoc_options: [] - -require_paths: -- lib -required_ruby_version: !ruby/object:Gem::Requirement - requirements: - - - ">" - - !ruby/object:Gem::Version - version: 0.0.0 - version: -required_rubygems_version: !ruby/object:Gem::Requirement - requirements: - - - ">=" - - !ruby/object:Gem::Version - version: "0" - version: -requirements: [] - -rubyforge_project: -rubygems_version: 1.3.1 -signing_key: -specification_version: 1 -summary: Syntax is Ruby library for performing simple syntax highlighting. -test_files: -- test/ALL-TESTS.rb diff --git a/vendor/gems/syntax-1.0.0/data/ruby.css b/vendor/gems/syntax-1.0.0/data/ruby.css deleted file mode 100644 index 2bc85c46f..000000000 --- a/vendor/gems/syntax-1.0.0/data/ruby.css +++ /dev/null @@ -1,18 +0,0 @@ -.ruby .normal {} -.ruby .comment { color: #005; font-style: italic; } -.ruby .keyword { color: #A00; font-weight: bold; } -.ruby .method { color: #077; } -.ruby .class { color: #074; } -.ruby .module { color: #050; } -.ruby .punct { color: #447; font-weight: bold; } -.ruby .symbol { color: #099; } -.ruby .string { color: #944; background: #FFE; } -.ruby .char { color: #F07; } -.ruby .ident { color: #004; } -.ruby .constant { color: #07F; } -.ruby .regex { color: #B66; background: #FEF; } -.ruby .number { color: #F99; } -.ruby .attribute { color: #7BB; } -.ruby .global { color: #7FB; } -.ruby .expr { color: #227; } -.ruby .escape { color: #277; } diff --git a/vendor/gems/syntax-1.0.0/data/xml.css b/vendor/gems/syntax-1.0.0/data/xml.css deleted file mode 100644 index c3efc661b..000000000 --- a/vendor/gems/syntax-1.0.0/data/xml.css +++ /dev/null @@ -1,8 +0,0 @@ -.xml .normal {} -.xml .namespace { color: #B66; font-weight: bold; } -.xml .tag { color: #F88; } -.xml .comment { color: #005; font-style: italic; } -.xml .punct { color: #447; font-weight: bold; } -.xml .string { color: #944; } -.xml .number { color: #F99; } -.xml .attribute { color: #BB7; } diff --git a/vendor/gems/syntax-1.0.0/data/yaml.css b/vendor/gems/syntax-1.0.0/data/yaml.css deleted file mode 100644 index 610e00574..000000000 --- a/vendor/gems/syntax-1.0.0/data/yaml.css +++ /dev/null @@ -1,12 +0,0 @@ -.yaml .normal {} -.yaml .document { font-weight: bold; color: #07F; } -.yaml .type { font-weight: bold; color: #05C; } -.yaml .key { color: #F88; } -.yaml .comment { color: #005; font-style: italic; } -.yaml .punct { color: #447; font-weight: bold; } -.yaml .string { color: #944; } -.yaml .number { color: #F99; } -.yaml .time { color: #F99; } -.yaml .date { color: #F99; } -.yaml .ref { color: #944; } -.yaml .anchor { color: #944; } diff --git a/vendor/gems/syntax-1.0.0/lib/syntax.rb b/vendor/gems/syntax-1.0.0/lib/syntax.rb deleted file mode 100644 index 604dcc2fb..000000000 --- a/vendor/gems/syntax-1.0.0/lib/syntax.rb +++ /dev/null @@ -1,38 +0,0 @@ -require 'syntax/common' - -module Syntax - - # A default tokenizer for handling syntaxes that are not explicitly handled - # elsewhere. It simply yields the given text as a single token. - class Default - - # Yield the given text as a single token. - def tokenize( text ) - yield Token.new( text, :normal ) - end - - end - - # A hash for registering syntax implementations. - SYNTAX = Hash.new( Default ) - - # Load the implementation of the requested syntax. If the syntax cannot be - # found, or if it cannot be loaded for whatever reason, the Default syntax - # handler will be returned. - def load( syntax ) - begin - require "syntax/lang/#{syntax}" - rescue LoadError - end - SYNTAX[ syntax ].new - end - module_function :load - - # Return an array of the names of supported syntaxes. - def all - lang_dir = File.join(File.dirname(__FILE__), "syntax", "lang") - Dir["#{lang_dir}/*.rb"].map { |path| File.basename(path, ".rb") } - end - module_function :all - -end diff --git a/vendor/gems/syntax-1.0.0/lib/syntax/common.rb b/vendor/gems/syntax-1.0.0/lib/syntax/common.rb deleted file mode 100644 index a986e656a..000000000 --- a/vendor/gems/syntax-1.0.0/lib/syntax/common.rb +++ /dev/null @@ -1,163 +0,0 @@ -require 'strscan' - -module Syntax - - # A single token extracted by a tokenizer. It is simply the lexeme - # itself, decorated with a 'group' attribute to identify the type of the - # lexeme. - class Token < String - - # the type of the lexeme that was extracted. - attr_reader :group - - # the instruction associated with this token (:none, :region_open, or - # :region_close) - attr_reader :instruction - - # Create a new Token representing the given text, and belonging to the - # given group. - def initialize( text, group, instruction = :none ) - super text - @group = group - @instruction = instruction - end - - end - - # The base class of all tokenizers. It sets up the scanner and manages the - # looping until all tokens have been extracted. It also provides convenience - # methods to make sure adjacent tokens of identical groups are returned as - # a single token. - class Tokenizer - - # The current group being processed by the tokenizer - attr_reader :group - - # The current chunk of text being accumulated - attr_reader :chunk - - # Start tokenizing. This sets up the state in preparation for tokenization, - # such as creating a new scanner for the text and saving the callback block. - # The block will be invoked for each token extracted. - def start( text, &block ) - @chunk = "" - @group = :normal - @callback = block - @text = StringScanner.new( text ) - setup - end - - # Subclasses may override this method to provide implementation-specific - # setup logic. - def setup - end - - # Finish tokenizing. This flushes the buffer, yielding any remaining text - # to the client. - def finish - start_group nil - teardown - end - - # Subclasses may override this method to provide implementation-specific - # teardown logic. - def teardown - end - - # Subclasses must implement this method, which is called for each iteration - # of the tokenization process. This method may extract multiple tokens. - def step - raise NotImplementedError, "subclasses must implement #step" - end - - # Begins tokenizing the given text, calling #step until the text has been - # exhausted. - def tokenize( text, &block ) - start text, &block - step until @text.eos? - finish - end - - # Specify a set of tokenizer-specific options. Each tokenizer may (or may - # not) publish any options, but if a tokenizer does those options may be - # used to specify optional behavior. - def set( opts={} ) - ( @options ||= Hash.new ).update opts - end - - # Get the value of the specified option. - def option(opt) - @options ? @options[opt] : nil - end - - private - - EOL = /(?=\r\n?|\n|$)/ - - # A convenience for delegating method calls to the scanner. - def self.delegate( sym ) - define_method( sym ) { |*a| @text.__send__( sym, *a ) } - end - - delegate :bol? - delegate :eos? - delegate :scan - delegate :scan_until - delegate :check - delegate :check_until - delegate :getch - delegate :matched - delegate :pre_match - delegate :peek - delegate :pos - - # Access the n-th subgroup from the most recent match. - def subgroup(n) - @text[n] - end - - # Append the given data to the currently active chunk. - def append( data ) - @chunk << data - end - - # Request that a new group be started. If the current group is the same - # as the group being requested, a new group will not be created. If a new - # group is created and the current chunk is not empty, the chunk's - # contents will be yielded to the client as a token, and then cleared. - # - # After the new group is started, if +data+ is non-nil it will be appended - # to the chunk. - def start_group( gr, data=nil ) - flush_chunk if gr != @group - @group = gr - @chunk << data if data - end - - def start_region( gr, data=nil ) - flush_chunk - @group = gr - @callback.call( Token.new( data||"", @group, :region_open ) ) - end - - def end_region( gr, data=nil ) - flush_chunk - @group = gr - @callback.call( Token.new( data||"", @group, :region_close ) ) - end - - def flush_chunk - @callback.call( Token.new( @chunk, @group ) ) unless @chunk.empty? - @chunk = "" - end - - def subtokenize( syntax, text ) - tokenizer = Syntax.load( syntax ) - tokenizer.set @options if @options - flush_chunk - tokenizer.tokenize( text, &@callback ) - end - - end - -end diff --git a/vendor/gems/syntax-1.0.0/lib/syntax/convertors/abstract.rb b/vendor/gems/syntax-1.0.0/lib/syntax/convertors/abstract.rb deleted file mode 100644 index 46c2f6fe8..000000000 --- a/vendor/gems/syntax-1.0.0/lib/syntax/convertors/abstract.rb +++ /dev/null @@ -1,27 +0,0 @@ -require 'syntax' - -module Syntax - module Convertors - - # The abstract ancestor class for all convertors. It implements a few - # convenience methods to provide a common interface for all convertors. - class Abstract - - # A reference to the tokenizer used by this convertor. - attr_reader :tokenizer - - # A convenience method for instantiating a new convertor for a - # specific syntax. - def self.for_syntax( syntax ) - new( Syntax.load( syntax ) ) - end - - # Creates a new convertor that uses the given tokenizer. - def initialize( tokenizer ) - @tokenizer = tokenizer - end - - end - - end -end diff --git a/vendor/gems/syntax-1.0.0/lib/syntax/convertors/html.rb b/vendor/gems/syntax-1.0.0/lib/syntax/convertors/html.rb deleted file mode 100644 index 5df416a82..000000000 --- a/vendor/gems/syntax-1.0.0/lib/syntax/convertors/html.rb +++ /dev/null @@ -1,51 +0,0 @@ -require 'syntax/convertors/abstract' - -module Syntax - module Convertors - - # A simple class for converting a text into HTML. - class HTML < Abstract - - # Converts the given text to HTML, using spans to represent token groups - # of any type but :normal (which is always unhighlighted). If - # +pre+ is +true+, the html is automatically wrapped in pre tags. - def convert( text, pre=true ) - html = "" - html << "
" if pre
-        regions = []
-        @tokenizer.tokenize( text ) do |tok|
-          value = html_escape(tok)
-          case tok.instruction
-            when :region_close then
-              regions.pop
-              html << ""
-            when :region_open then
-              regions.push tok.group
-              html << "#{value}"
-            else
-              if tok.group == ( regions.last || :normal )
-                html << value
-              else
-                html << "#{value}"
-              end
-          end
-        end
-        html << "" while regions.pop
-        html << "
" if pre - html - end - - private - - # Replaces some characters with their corresponding HTML entities. - def html_escape( string ) - string.gsub( /&/, "&" ). - gsub( //, ">" ). - gsub( /"/, """ ) - end - - end - - end -end diff --git a/vendor/gems/syntax-1.0.0/lib/syntax/lang/ruby.rb b/vendor/gems/syntax-1.0.0/lib/syntax/lang/ruby.rb deleted file mode 100644 index 66afaa47d..000000000 --- a/vendor/gems/syntax-1.0.0/lib/syntax/lang/ruby.rb +++ /dev/null @@ -1,317 +0,0 @@ -require 'syntax' - -module Syntax - - # A tokenizer for the Ruby language. It recognizes all common syntax - # (and some less common syntax) but because it is not a true lexer, it - # will make mistakes on some ambiguous cases. - class Ruby < Tokenizer - - # The list of all identifiers recognized as keywords. - KEYWORDS = - %w{if then elsif else end begin do rescue ensure while for - class module def yield raise until unless and or not when - case super undef break next redo retry in return alias - defined?} - - # Perform ruby-specific setup - def setup - @selector = false - @allow_operator = false - @heredocs = [] - end - - # Step through a single iteration of the tokenization process. - def step - case - when bol? && check( /=begin/ ) - start_group( :comment, scan_until( /^=end#{EOL}/ ) ) - when bol? && check( /__END__#{EOL}/ ) - start_group( :comment, scan_until( /\Z/ ) ) - else - case - when check( /def\s+/ ) - start_group :keyword, scan( /def\s+/ ) - start_group :method, scan_until( /(?=[;(\s]|#{EOL})/ ) - when check( /class\s+/ ) - start_group :keyword, scan( /class\s+/ ) - start_group :class, scan_until( /(?=[;\s<]|#{EOL})/ ) - when check( /module\s+/ ) - start_group :keyword, scan( /module\s+/ ) - start_group :module, scan_until( /(?=[;\s]|#{EOL})/ ) - when check( /::/ ) - start_group :punct, scan(/::/) - when check( /:"/ ) - start_group :symbol, scan(/:/) - scan_delimited_region :symbol, :symbol, "", true - @allow_operator = true - when check( /:'/ ) - start_group :symbol, scan(/:/) - scan_delimited_region :symbol, :symbol, "", false - @allow_operator = true - when scan( /:[_a-zA-Z@$][$@\w]*[=!?]?/ ) - start_group :symbol, matched - @allow_operator = true - when scan( /\?(\\[^\n\r]|[^\\\n\r\s])/ ) - start_group :char, matched - @allow_operator = true - when check( /(__FILE__|__LINE__|true|false|nil|self)[?!]?/ ) - if @selector || matched[-1] == ?? || matched[-1] == ?! - start_group :ident, - scan(/(__FILE__|__LINE__|true|false|nil|self)[?!]?/) - else - start_group :constant, - scan(/(__FILE__|__LINE__|true|false|nil|self)/) - end - @selector = false - @allow_operator = true - when scan(/0([bB][01]+|[oO][0-7]+|[dD][0-9]+|[xX][0-9a-fA-F]+)/) - start_group :number, matched - @allow_operator = true - else - case peek(2) - when "%r" - scan_delimited_region :punct, :regex, scan( /../ ), true - @allow_operator = true - when "%w", "%q" - scan_delimited_region :punct, :string, scan( /../ ), false - @allow_operator = true - when "%s" - scan_delimited_region :punct, :symbol, scan( /../ ), false - @allow_operator = true - when "%W", "%Q", "%x" - scan_delimited_region :punct, :string, scan( /../ ), true - @allow_operator = true - when /%[^\sa-zA-Z0-9]/ - scan_delimited_region :punct, :string, scan( /./ ), true - @allow_operator = true - when "<<" - saw_word = ( chunk[-1,1] =~ /[\w!?]/ ) - start_group :punct, scan( /<(\[\{}:;,&|%]/ - start_group :punct, scan(/./) - @allow_operator = false - when /[)\]]/ - start_group :punct, scan(/./) - @allow_operator = true - else - # all else just falls through this, to prevent - # infinite loops... - append getch - end - end - end - end - end - - private - - # Scan a delimited region of text. This handles the simple cases (strings - # delimited with quotes) as well as the more complex cases of %-strings - # and here-documents. - # - # * +delim_group+ is the group to use to classify the delimiters of the - # region - # * +inner_group+ is the group to use to classify the contents of the - # region - # * +starter+ is the text to use as the starting delimiter - # * +exprs+ is a boolean flag indicating whether the region is an - # interpolated string or not - # * +delim+ is the text to use as the delimiter of the region. If +nil+, - # the next character will be treated as the delimiter. - # * +heredoc+ is either +false+, meaning the region is not a heredoc, or - # :flush (meaning the delimiter must be flushed left), or - # :float (meaning the delimiter doens't have to be flush left). - def scan_delimited_region( delim_group, inner_group, starter, exprs, - delim=nil, heredoc=false ) - # begin - if !delim - start_group delim_group, starter - delim = scan( /./ ) - append delim - - delim = case delim - when '{' then '}' - when '(' then ')' - when '[' then ']' - when '<' then '>' - else delim - end - end - - start_region inner_group - - items = "\\\\|" - if heredoc - items << "(^" - items << '\s*' if heredoc == :float - items << "#{Regexp.escape(delim)}\s*?)#{EOL}" - else - items << "#{Regexp.escape(delim)}" - end - items << "|#(\\$|@@?|\\{)" if exprs - items = Regexp.new( items ) - - loop do - p = pos - match = scan_until( items ) - if match.nil? - start_group inner_group, scan_until( /\Z/ ) - break - else - text = pre_match[p..-1] - start_group inner_group, text if text.length > 0 - case matched.strip - when "\\" - unless exprs - case peek(1) - when "'" - scan(/./) - start_group :escape, "\\'" - when "\\" - scan(/./) - start_group :escape, "\\\\" - else - start_group inner_group, "\\" - end - else - start_group :escape, "\\" - c = getch - append c - case c - when 'x' - append scan( /[a-fA-F0-9]{1,2}/ ) - when /[0-7]/ - append scan( /[0-7]{0,2}/ ) - end - end - when delim - end_region inner_group - start_group delim_group, matched - break - when /^#/ - do_highlight = (option(:expressions) == :highlight) - start_region :expr if do_highlight - start_group :expr, matched - case matched[1] - when ?{ - depth = 1 - content = "" - while depth > 0 - p = pos - c = scan_until( /[\{}]/ ) - if c.nil? - content << scan_until( /\Z/ ) - break - else - depth += ( matched == "{" ? 1 : -1 ) - content << pre_match[p..-1] - content << matched if depth > 0 - end - end - if do_highlight - subtokenize "ruby", content - start_group :expr, "}" - else - append content + "}" - end - when ?$, ?@ - append scan( /\w+/ ) - end - end_region :expr if do_highlight - else raise "unexpected match on #{matched}" - end - end - end - end - - # Scan a heredoc beginning at the current position. - # - # * +float+ indicates whether the delimiter may be floated to the right - # * +type+ is +nil+, a single quote, or a double quote - # * +delim+ is the delimiter to look for - def scan_heredoc(float, type, delim) - scan_delimited_region( :constant, :string, "", type != "'", - delim, float ? :float : :flush ) - end - end - - SYNTAX["ruby"] = Ruby - -end diff --git a/vendor/gems/syntax-1.0.0/lib/syntax/lang/xml.rb b/vendor/gems/syntax-1.0.0/lib/syntax/lang/xml.rb deleted file mode 100644 index 7d530e024..000000000 --- a/vendor/gems/syntax-1.0.0/lib/syntax/lang/xml.rb +++ /dev/null @@ -1,108 +0,0 @@ -require 'syntax' - -module Syntax - - # A simple implementation of an XML lexer. It handles most cases. It is - # not a validating lexer, meaning it will happily process invalid XML without - # complaining. - class XML < Tokenizer - - # Initialize the lexer. - def setup - @in_tag = false - end - - # Step through a single iteration of the tokenization process. This will - # yield (potentially) many tokens, and possibly zero tokens. - def step - start_group :normal, matched if scan( /\s+/ ) - if @in_tag - case - when scan( /([-\w]+):([-\w]+)/ ) - start_group :namespace, subgroup(1) - start_group :punct, ":" - start_group :attribute, subgroup(2) - when scan( /\d+/ ) - start_group :number, matched - when scan( /[-\w]+/ ) - start_group :attribute, matched - when scan( %r{[/?]?>} ) - @in_tag = false - start_group :punct, matched - when scan( /=/ ) - start_group :punct, matched - when scan( /["']/ ) - scan_string matched - else - append getch - end - elsif ( text = scan_until( /(?=[<&])/ ) ) - start_group :normal, text unless text.empty? - if scan(/|\Z)/m) - start_group :comment, matched - else - case peek(1) - when "<" - start_group :punct, getch - case peek(1) - when "?" - append getch - when "/" - append getch - when "!" - append getch - end - start_group :normal, matched if scan( /\s+/ ) - if scan( /([-\w]+):([-\w]+)/ ) - start_group :namespace, subgroup(1) - start_group :punct, ":" - start_group :tag, subgroup(2) - elsif scan( /[-\w]+/ ) - start_group :tag, matched - end - @in_tag = true - when "&" - if scan( /&\S{1,10};/ ) - start_group :entity, matched - else - start_group :normal, scan( /&/ ) - end - end - end - else - append scan_until( /\Z/ ) - end - end - - private - - # Scan the string starting at the current position, with the given - # delimiter character. - def scan_string( delim ) - start_group :punct, delim - match = /(?=[&\\]|#{delim})/ - loop do - break unless ( text = scan_until( match ) ) - start_group :string, text unless text.empty? - case peek(1) - when "&" - if scan( /&\S{1,10};/ ) - start_group :entity, matched - else - start_group :string, getch - end - when "\\" - start_group :string, getch - append getch || "" - when delim - start_group :punct, getch - break - end - end - end - - end - - SYNTAX["xml"] = XML - -end diff --git a/vendor/gems/syntax-1.0.0/lib/syntax/lang/yaml.rb b/vendor/gems/syntax-1.0.0/lib/syntax/lang/yaml.rb deleted file mode 100644 index 53b052db9..000000000 --- a/vendor/gems/syntax-1.0.0/lib/syntax/lang/yaml.rb +++ /dev/null @@ -1,105 +0,0 @@ -require 'syntax' - -module Syntax - - # A simple implementation of an YAML lexer. It handles most cases. It is - # not a validating lexer. - class YAML < Tokenizer - - # Step through a single iteration of the tokenization process. This will - # yield (potentially) many tokens, and possibly zero tokens. - def step - if bol? - case - when scan(/---(\s*.+)?$/) - start_group :document, matched - when scan(/(\s*)([a-zA-Z][-\w]*)(\s*):/) - start_group :normal, subgroup(1) - start_group :key, subgroup(2) - start_group :normal, subgroup(3) - start_group :punct, ":" - when scan(/(\s*)-/) - start_group :normal, subgroup(1) - start_group :punct, "-" - when scan(/\s*$/) - start_group :normal, matched - when scan(/#.*$/) - start_group :comment, matched - else - append getch - end - else - case - when scan(/[\n\r]+/) - start_group :normal, matched - when scan(/[ \t]+/) - start_group :normal, matched - when scan(/!+(.*?^)?\S+/) - start_group :type, matched - when scan(/&\S+/) - start_group :anchor, matched - when scan(/\*\S+/) - start_group :ref, matched - when scan(/\d\d:\d\d:\d\d/) - start_group :time, matched - when scan(/\d\d\d\d-\d\d-\d\d\s\d\d:\d\d:\d\d(\.\d+)? [-+]\d\d:\d\d/) - start_group :date, matched - when scan(/['"]/) - start_group :punct, matched - scan_string matched - when scan(/:\w+/) - start_group :symbol, matched - when scan(/[:]/) - start_group :punct, matched - when scan(/#.*$/) - start_group :comment, matched - when scan(/>-?/) - start_group :punct, matched - start_group :normal, scan(/.*$/) - append getch until eos? || bol? - return if eos? - indent = check(/ */) - start_group :string - loop do - line = check_until(/[\n\r]|\Z/) - break if line.nil? - if line.chomp.length > 0 - this_indent = line.chomp.match( /^\s*/ )[0] - break if this_indent.length < indent.length - end - append scan_until(/[\n\r]|\Z/) - end - else - start_group :normal, scan_until(/(?=$|#)/) - end - end - end - - private - - def scan_string( delim ) - regex = /(?=[#{delim=="'" ? "" : "\\\\"}#{delim}])/ - loop do - text = scan_until( regex ) - if text.nil? - start_group :string, scan_until( /\Z/ ) - break - else - start_group :string, text unless text.empty? - end - - case peek(1) - when "\\" - start_group :expr, scan(/../) - else - start_group :punct, getch - break - end - end - end - - end - - SYNTAX["yaml"] = YAML - -end diff --git a/vendor/gems/syntax-1.0.0/lib/syntax/version.rb b/vendor/gems/syntax-1.0.0/lib/syntax/version.rb deleted file mode 100644 index d53304681..000000000 --- a/vendor/gems/syntax-1.0.0/lib/syntax/version.rb +++ /dev/null @@ -1,9 +0,0 @@ -module Syntax - module Version - MAJOR=1 - MINOR=0 - TINY=0 - - STRING=[MAJOR,MINOR,TINY].join('.') - end -end diff --git a/vendor/gems/syntax-1.0.0/test/ALL-TESTS.rb b/vendor/gems/syntax-1.0.0/test/ALL-TESTS.rb deleted file mode 100644 index 4014cdcb4..000000000 --- a/vendor/gems/syntax-1.0.0/test/ALL-TESTS.rb +++ /dev/null @@ -1,5 +0,0 @@ -#!/usr/bin/env ruby -$:.unshift "../lib" - -Dir.chdir File.dirname(__FILE__) -Dir["**/tc_*.rb"].each { |file| load file } diff --git a/vendor/gems/syntax-1.0.0/test/syntax/tc_ruby.rb b/vendor/gems/syntax-1.0.0/test/syntax/tc_ruby.rb deleted file mode 100644 index b3a0cb2d3..000000000 --- a/vendor/gems/syntax-1.0.0/test/syntax/tc_ruby.rb +++ /dev/null @@ -1,871 +0,0 @@ -require File.dirname(__FILE__) + "/tokenizer_testcase" - -class TC_Syntax_Ruby < TokenizerTestCase - - syntax "ruby" - - def test_empty - tokenize "" - assert_no_next_token - end - - def test_constant - tokenize "Foo" - assert_next_token :constant, "Foo" - end - - def test_ident - tokenize "foo" - assert_next_token :ident, "foo" - end - - def test_comment_eol - tokenize "# a comment\nfoo" - assert_next_token :comment, "# a comment" - assert_next_token :normal, "\n" - assert_next_token :ident, "foo" - end - - def test_comment_block - tokenize "=begin\nthis is a comment\n=end\nnoncomment" - assert_next_token :comment, "=begin\nthis is a comment\n=end" - assert_next_token :normal, "\n" - assert_next_token :ident, "noncomment" - end - - def test_comment_block_with_CRNL - tokenize "=begin\r\nthis is a comment\r\n=end\r\nnoncomment" - assert_next_token :comment, "=begin\r\nthis is a comment\r\n=end" - assert_next_token :normal, "\r\n" - assert_next_token :ident, "noncomment" - end - - def test_keyword - Syntax::Ruby::KEYWORDS.each do |word| - tokenize word - assert_next_token :keyword, word - end - Syntax::Ruby::KEYWORDS.each do |word| - tokenize "foo.#{word}" - skip_token 2 - assert_next_token :ident, word - end - end - - def test__END__ - tokenize "__END__\n\nblah blah blah" - assert_next_token :comment, "__END__\n\nblah blah blah" - end - - def test__END__with_CRNL - tokenize "__END__\r\nblah blah blah" - assert_next_token :comment, "__END__\r\nblah blah blah" - end - - def test_def_paren - tokenize "def foo(bar)" - assert_next_token :keyword, "def " - assert_next_token :method, "foo" - assert_next_token :punct, "(" - assert_next_token :ident, "bar" - assert_next_token :punct, ")" - end - - def test_def_space - tokenize "def foo bar" - assert_next_token :keyword, "def " - assert_next_token :method, "foo" - assert_next_token :normal, " " - assert_next_token :ident, "bar" - end - - def test_def_semicolon - tokenize "def foo;" - assert_next_token :keyword, "def " - assert_next_token :method, "foo" - assert_next_token :punct, ";" - end - - def test_def_eol - tokenize "def foo" - assert_next_token :keyword, "def " - assert_next_token :method, "foo" - end - - def test_class_space - tokenize "class Foo\n" - assert_next_token :keyword, "class " - assert_next_token :class, "Foo" - assert_next_token :normal, "\n" - end - - def test_class_semicolon - tokenize "class Foo;" - assert_next_token :keyword, "class " - assert_next_token :class, "Foo" - assert_next_token :punct, ";" - end - - def test_class_extend - tokenize "class Foo< Bang" - assert_next_token :keyword, "class " - assert_next_token :class, "Foo" - assert_next_token :punct, "<" - assert_next_token :normal, " " - assert_next_token :constant, "Bang" - end - - def test_module_space - tokenize "module Foo\n" - assert_next_token :keyword, "module " - assert_next_token :module, "Foo" - assert_next_token :normal, "\n" - end - - def test_module_semicolon - tokenize "module Foo;" - assert_next_token :keyword, "module " - assert_next_token :module, "Foo" - assert_next_token :punct, ";" - end - - def test_module_other - tokenize "module Foo!\n" - assert_next_token :keyword, "module " - assert_next_token :module, "Foo!" - end - - def test_scope_operator - tokenize "Foo::Bar" - assert_next_token :constant, "Foo" - assert_next_token :punct, "::" - assert_next_token :constant, "Bar" - end - - def test_symbol_dquote - tokenize ':"foo"' - assert_next_token :symbol, ':"' - assert_next_token :symbol, '', :region_open - assert_next_token :symbol, 'foo' - assert_next_token :symbol, '', :region_close - assert_next_token :symbol, '"' - assert_no_next_token - end - - def test_symbol_squote - tokenize ":'foo'" - assert_next_token :symbol, ":'" - assert_next_token :symbol, "", :region_open - assert_next_token :symbol, "foo" - assert_next_token :symbol, "", :region_close - assert_next_token :symbol, "'" - assert_no_next_token - end - - def test_symbol - tokenize ":foo_123" - assert_next_token :symbol, ":foo_123" - - tokenize ":123" - assert_next_token :punct, ":" - assert_next_token :number, "123" - - tokenize ":foo=" - assert_next_token :symbol, ":foo=" - - tokenize ":foo!" - assert_next_token :symbol, ":foo!" - - tokenize ":foo?" - assert_next_token :symbol, ":foo?" - end - - def test_char - tokenize "?." - assert_next_token :char, "?." - - tokenize '?\n' - assert_next_token :char, '?\n' - end - - def test_specials - %w{__FILE__ __LINE__ true false nil self}.each do |word| - tokenize word - assert_next_token :constant, word - end - - %w{__FILE__ __LINE__ true false nil self}.each do |word| - tokenize "#{word}?" - assert_next_token :ident, "#{word}?" - end - - %w{__FILE__ __LINE__ true false nil self}.each do |word| - tokenize "#{word}!" - assert_next_token :ident, "#{word}!" - end - - %w{__FILE__ __LINE__ true false nil self}.each do |word| - tokenize "x.#{word}" - skip_token 2 - assert_next_token :ident, word - end - end - - def test_pct_r - tokenize '%r{foo#{x}bar}' - assert_next_token :punct, "%r{" - assert_next_token :regex, "", :region_open - assert_next_token :regex, "foo" - assert_next_token :expr, '#{x}' - assert_next_token :regex, "bar" - assert_next_token :regex, "", :region_close - assert_next_token :punct, "}" - - tokenize '%r-foo#{x}bar-' - assert_next_token :punct, "%r-" - assert_next_token :regex, "", :region_open - assert_next_token :regex, "foo" - assert_next_token :expr, '#{x}' - assert_next_token :regex, "bar" - assert_next_token :regex, "", :region_close - assert_next_token :punct, "-" - end - - def test_pct_r_with_wakas - tokenize '%r foo' - assert_next_token :punct, "%r<" - assert_next_token :regex, "", :region_open - assert_next_token :regex, "foo" - assert_next_token :expr, '#{x}' - assert_next_token :regex, "bar" - assert_next_token :regex, "", :region_close - assert_next_token :punct, ">" - assert_next_token :normal, " " - assert_next_token :ident, "foo" - end - - def test_pct_w_brace - tokenize '%w{foo bar baz}' - assert_next_token :punct, "%w{" - assert_next_token :string, '', :region_open - assert_next_token :string, 'foo bar baz' - assert_next_token :string, '', :region_close - assert_next_token :punct, "}" - end - - def test_pct_w - tokenize '%w-foo#{x} bar baz-' - assert_next_token :punct, "%w-" - assert_next_token :string, '', :region_open - assert_next_token :string, 'foo#{x} bar baz' - assert_next_token :string, '', :region_close - assert_next_token :punct, "-" - end - - def test_pct_q - tokenize '%q-hello #{world}-' - assert_next_token :punct, "%q-" - assert_next_token :string, '', :region_open - assert_next_token :string, 'hello #{world}' - assert_next_token :string, '', :region_close - assert_next_token :punct, "-" - end - - def test_pct_s - tokenize '%s-hello #{world}-' - assert_next_token :punct, "%s-" - assert_next_token :symbol, '', :region_open - assert_next_token :symbol, 'hello #{world}' - assert_next_token :symbol, '', :region_close - assert_next_token :punct, "-" - end - - def test_pct_W - tokenize '%W-foo#{x} bar baz-' - assert_next_token :punct, "%W-" - assert_next_token :string, '', :region_open - assert_next_token :string, 'foo' - assert_next_token :expr, '#{x}' - assert_next_token :string, ' bar baz' - assert_next_token :string, '', :region_close - assert_next_token :punct, "-" - end - - def test_pct_Q - tokenize '%Q-hello #{world}-' - assert_next_token :punct, "%Q-" - assert_next_token :string, '', :region_open - assert_next_token :string, 'hello ' - assert_next_token :expr, '#{world}' - assert_next_token :string, '', :region_close - assert_next_token :punct, "-" - end - - def test_pct_x - tokenize '%x-ls /blah/#{foo}-' - assert_next_token :punct, "%x-" - assert_next_token :string, '', :region_open - assert_next_token :string, 'ls /blah/' - assert_next_token :expr, '#{foo}' - assert_next_token :string, '', :region_close - assert_next_token :punct, "-" - end - - def test_pct_string - tokenize '%-hello #{world}-' - assert_next_token :punct, "%-" - assert_next_token :string, '', :region_open - assert_next_token :string, 'hello ' - assert_next_token :expr, '#{world}' - assert_next_token :string, '', :region_close - assert_next_token :punct, "-" - end - - def test_bad_pct_string - tokenize '%0hello #{world}0' - assert_next_token :punct, "%" - assert_next_token :number, '0' - assert_next_token :ident, 'hello' - assert_next_token :normal, ' ' - assert_next_token :comment, '#{world}0' - end - - def test_shift_left - tokenize 'foo << 5' - assert_next_token :ident, "foo" - assert_next_token :normal, " " - assert_next_token :punct, "<<" - assert_next_token :normal, " " - assert_next_token :number, "5" - end - - def test_shift_left_no_white - tokenize 'foo<<5' - assert_next_token :ident, "foo" - assert_next_token :punct, "<<" - assert_next_token :number, "5" - end - - def test_here_doc_no_opts - tokenize "foo < :highlight - tokenize '"la la #{["hello", "world"].each { |f| puts "string #{f}" }}"' - assert_next_token :punct, '"' - assert_next_token :string, "", :region_open - assert_next_token :string, "la la " - assert_next_token :expr, "", :region_open - assert_next_token :expr, '#{' - assert_next_token :punct, '["' - assert_next_token :string, "", :region_open - assert_next_token :string, 'hello' - assert_next_token :string, "", :region_close - assert_next_token :punct, '",' - assert_next_token :normal, ' ' - assert_next_token :punct, '"' - assert_next_token :string, "", :region_open - assert_next_token :string, "world" - assert_next_token :string, "", :region_close - assert_next_token :punct, '"].' - assert_next_token :ident, 'each' - assert_next_token :normal, ' ' - assert_next_token :punct, '{' - assert_next_token :normal, ' ' - assert_next_token :punct, '|' - assert_next_token :ident, 'f' - assert_next_token :punct, '|' - assert_next_token :normal, ' ' - assert_next_token :ident, 'puts' - assert_next_token :normal, ' ' - assert_next_token :punct, '"' - assert_next_token :string, "", :region_open - assert_next_token :string, "string " - assert_next_token :expr, "", :region_open - assert_next_token :expr, '#{' - assert_next_token :ident, 'f' - assert_next_token :expr, '}' - assert_next_token :expr, "", :region_close - assert_next_token :string, "", :region_close - assert_next_token :punct, '"' - assert_next_token :normal, ' ' - assert_next_token :punct, '}' - assert_next_token :expr, '}' - assert_next_token :expr, "", :region_close - assert_next_token :string, "", :region_close - assert_next_token :punct, '"' - end - - def test_expr_in_braces - tokenize '"#{f}"' - assert_next_token :punct, '"' - assert_next_token :string, "", :region_open - assert_next_token :expr, '#{f}' - assert_next_token :string, "", :region_close - assert_next_token :punct, '"' - end - - def test_expr_in_braces_with_nested_braces - tokenize '"#{loop{break}}"' - assert_next_token :punct, '"' - assert_next_token :string, "", :region_open - assert_next_token :expr, '#{loop{break}}' - assert_next_token :string, "", :region_close - assert_next_token :punct, '"' - end - - def test_expr_with_global_var - tokenize '"#$f"' - assert_next_token :punct, '"' - assert_next_token :string, "", :region_open - assert_next_token :expr, '#$f' - assert_next_token :string, "", :region_close - assert_next_token :punct, '"' - end - - def test_expr_with_instance_var - tokenize '"#@f"' - assert_next_token :punct, '"' - assert_next_token :string, "", :region_open - assert_next_token :expr, '#@f' - assert_next_token :string, "", :region_close - assert_next_token :punct, '"' - end - - def test_expr_with_class_var - tokenize '"#@@f"' - assert_next_token :punct, '"' - assert_next_token :string, "", :region_open - assert_next_token :expr, '#@@f' - assert_next_token :string, "", :region_close - assert_next_token :punct, '"' - end - - def test_qmark_space - tokenize "? " - assert_next_token :punct, "?" - assert_next_token :normal, " " - end - - def test_capitalized_method - tokenize "obj.Foo" - skip_token 2 - assert_next_token :ident, "Foo" - end - - def test_hexadecimal_literal - tokenize "0xDEADbeef 0X1234567890ABCDEFG" - assert_next_token :number, "0xDEADbeef" - skip_token - assert_next_token :number, "0X1234567890ABCDEF" - assert_next_token :constant, "G" - end - - def test_binary_literal - tokenize "0b2 0b0 0b101 0B123" - assert_next_token :number, "0" - assert_next_token :ident, "b2" - skip_token - assert_next_token :number, "0b0" - skip_token - assert_next_token :number, "0b101" - skip_token - assert_next_token :number, "0B123" - end - - def test_octal_literal - tokenize "0o9 0o12345670abc 0O12345678" - assert_next_token :number, "0" - assert_next_token :ident, "o9" - skip_token - assert_next_token :number, "0o12345670" - assert_next_token :ident, "abc" - skip_token - assert_next_token :number, "0O12345678" - end - - def test_decimal_literal - tokenize "0dA 0d1234567890abc 0D1234567890" - assert_next_token :number, "0" - assert_next_token :ident, "dA" - skip_token - assert_next_token :number, "0d1234567890" - assert_next_token :ident, "abc" - skip_token - assert_next_token :number, "0D1234567890" - end -end diff --git a/vendor/gems/syntax-1.0.0/test/syntax/tc_xml.rb b/vendor/gems/syntax-1.0.0/test/syntax/tc_xml.rb deleted file mode 100644 index 83cd26b19..000000000 --- a/vendor/gems/syntax-1.0.0/test/syntax/tc_xml.rb +++ /dev/null @@ -1,202 +0,0 @@ -$:.unshift File.dirname(__FILE__) +"/../../lib" - -require 'test/unit' -require 'syntax/lang/xml' - -class TC_Syntax_XML < Test::Unit::TestCase - - def setup - @xml = Syntax::XML.new - end - - def test_empty - called = false - @xml.tokenize( "" ) { |tok| called = true } - assert !called - end - - def test_no_tag - tok = [] - @xml.tokenize( "foo bar baz" ) { |t| tok << t } - assert_equal [ :normal, "foo bar baz" ], [ tok.first.group, tok.shift ] - end - - def test_entity_outside_tag - tok = [] - @xml.tokenize( "& &x157; &nosemi & foo;" ) { |t| tok << t } - assert_equal [ :entity, "&" ], [ tok.first.group, tok.shift ] - tok.shift - assert_equal [ :entity, " " ], [ tok.first.group, tok.shift ] - tok.shift - assert_equal [ :entity, "&x157;" ], [ tok.first.group, tok.shift ] - assert_equal [ :normal, " &nosemi & foo;" ], [ tok.first.group, tok.shift ] - end - - def test_start_tag - tok = [] - @xml.tokenize( "" ) { |t| tok << t } - assert_equal [ :normal, "/>" ], [ tok.first.group, tok.shift ] - end - - def test_start_namespaced_tag - tok = [] - @xml.tokenize( " foo' ) { |t| tok << t } - assert_equal [ :punct, "<" ], [ tok.first.group, tok.shift ] - assert_equal [ :tag, "name" ], [ tok.first.group, tok.shift ] - assert_equal [ :punct, ">" ], [ tok.first.group, tok.shift ] - assert_equal [ :normal, " foo" ], [ tok.first.group, tok.shift ] - end - - def test_close_self_tag - tok = [] - @xml.tokenize( ' foo' ) { |t| tok << t } - assert_equal [ :punct, "<" ], [ tok.first.group, tok.shift ] - assert_equal [ :tag, "name" ], [ tok.first.group, tok.shift ] - assert_equal [ :normal, " " ], [ tok.first.group, tok.shift ] - assert_equal [ :punct, "/>" ], [ tok.first.group, tok.shift ] - assert_equal [ :normal, " foo" ], [ tok.first.group, tok.shift ] - end - - def test_close_decl_tag - tok = [] - @xml.tokenize( ' foo' ) { |t| tok << t } - assert_equal [ :punct, "" ], [ tok.first.group, tok.shift ] - assert_equal [ :normal, " foo" ], [ tok.first.group, tok.shift ] - end - - def test_comment - tok = [] - @xml.tokenize( "foo bar" ) { |t| tok << t } - assert_equal [ :normal, "foo " ], [ tok.first.group, tok.shift ] - assert_equal [ :comment, "" ], [ tok.first.group, tok.shift ] - assert_equal [ :normal, " bar" ], [ tok.first.group, tok.shift ] - end - - def test_comment_unterminated - tok = [] - @xml.tokenize( "foo