From b76a86c5b36473f8b34142755621f08482a2c179 Mon Sep 17 00:00:00 2001 From: Beat Richartz Date: Mon, 26 Jan 2015 18:49:46 +0100 Subject: [PATCH 1/2] require dsl with default require, but make include optional --- lib/sshkit/all.rb | 3 ++- lib/sshkit/dsl.rb | 2 -- test/unit/test_dsl.rb | 26 ++++++++++++++++++++++++++ 3 files changed, 28 insertions(+), 3 deletions(-) create mode 100644 test/unit/test_dsl.rb diff --git a/lib/sshkit/all.rb b/lib/sshkit/all.rb index b27db0f7..24f64879 100644 --- a/lib/sshkit/all.rb +++ b/lib/sshkit/all.rb @@ -10,6 +10,7 @@ require_relative 'coordinator' require_relative 'deprecation_logger' +require_relative 'dsl' require_relative 'exception' @@ -35,4 +36,4 @@ require_relative 'backends/printer' require_relative 'backends/netssh' require_relative 'backends/local' -require_relative 'backends/skipper' \ No newline at end of file +require_relative 'backends/skipper' diff --git a/lib/sshkit/dsl.rb b/lib/sshkit/dsl.rb index 5c72cd07..ba9e2e64 100644 --- a/lib/sshkit/dsl.rb +++ b/lib/sshkit/dsl.rb @@ -13,5 +13,3 @@ def run_locally(&block) end end - -include SSHKit::DSL diff --git a/test/unit/test_dsl.rb b/test/unit/test_dsl.rb new file mode 100644 index 00000000..256e38e8 --- /dev/null +++ b/test/unit/test_dsl.rb @@ -0,0 +1,26 @@ +require 'helper' + +module SSHKit + + class TestDSL < UnitTest + include SSHKit::DSL + + def test_dsl_on + coordinator = mock + Coordinator.stubs(:new).returns coordinator + coordinator.expects(:each).at_least_once + + on('1.2.3.4') + end + + def test_dsl_run_locally + local_backend = mock + Backend::Local.stubs(:new).returns local_backend + local_backend.expects(:run).at_least_once + + run_locally + end + + end + +end From 4da5151519e92c97b6978976d866400c643d150f Mon Sep 17 00:00:00 2001 From: Beat Richartz Date: Mon, 22 Feb 2016 20:49:09 +0000 Subject: [PATCH 2/2] Update CHANGELOG, EXAMPLES and README --- CHANGELOG.md | 3 +++ EXAMPLES.md | 4 +++- README.md | 2 +- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3aae1fee..11d3514e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,9 @@ This file is written in reverse chronological order, newer releases will appear at the top. ## `master` (Unreleased) + * Do not auto-include DSL in context of `require`. Load DSL with Gem and allow to include it. + [PR #219](https://github.com/capistrano/sshkit/pull/219) + @beatrichartz * `SSHKit::Backend::Netssh.pool.idle_timeout = 0` doesn't disable connection pooling anymore, only connection expiration. To disable connection polling use `SSHKit::Backend::Netssh.pool.enabled = false` * Add your entries below here, remember to credit yourself however you want diff --git a/EXAMPLES.md b/EXAMPLES.md index d171ba82..5c70eb0b 100644 --- a/EXAMPLES.md +++ b/EXAMPLES.md @@ -366,12 +366,14 @@ known test cases, it works. The key thing is that `if` is not mapped to Into the `Rakefile` simply put something like: ```ruby -require 'sshkit/dsl' +require 'sshkit' SSHKit.config.command_map[:rake] = "./bin/rake" desc "Deploy the site, pulls from Git, migrate the db and precompile assets, then restart Passenger." task :deploy do + include SSHKit::DSL + on "example.com" do |host| within "/opt/sites/example.com" do execute :git, :pull diff --git a/README.md b/README.md index 21719cee..8818693b 100644 --- a/README.md +++ b/README.md @@ -13,7 +13,7 @@ The typical use-case looks something like this: ```ruby require 'sshkit' -require 'sshkit/dsl' +include SSHKit::DSL on %w{1.example.com 2.example.com}, in: :sequence, wait: 5 do |host| within "/opt/sites/example.com" do