Skip to content

Commit

Permalink
Merge pull request #219 from beatrichartz/no_include_on_require
Browse files Browse the repository at this point in the history
Do not include SSHKit::DSL in the context it is required in
  • Loading branch information
leehambley committed Feb 22, 2016
2 parents 6de1e10 + 4da5151 commit 211a168
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 5 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 3 additions & 1 deletion EXAMPLES.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion lib/sshkit/all.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
require_relative 'coordinator'

require_relative 'deprecation_logger'
require_relative 'dsl'

require_relative 'exception'

Expand All @@ -35,4 +36,4 @@
require_relative 'backends/printer'
require_relative 'backends/netssh'
require_relative 'backends/local'
require_relative 'backends/skipper'
require_relative 'backends/skipper'
2 changes: 0 additions & 2 deletions lib/sshkit/dsl.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,3 @@ def run_locally(&block)
end

end

include SSHKit::DSL
26 changes: 26 additions & 0 deletions test/unit/test_dsl.rb
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 211a168

Please sign in to comment.