Skip to content

Commit 211a168

Browse files
committed
Merge pull request #219 from beatrichartz/no_include_on_require
Do not include SSHKit::DSL in the context it is required in
2 parents 6de1e10 + 4da5151 commit 211a168

File tree

6 files changed

+35
-5
lines changed

6 files changed

+35
-5
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ This file is written in reverse chronological order, newer releases will
44
appear at the top.
55

66
## `master` (Unreleased)
7+
* Do not auto-include DSL in context of `require`. Load DSL with Gem and allow to include it.
8+
[PR #219](https://github.com/capistrano/sshkit/pull/219)
9+
@beatrichartz
710
* `SSHKit::Backend::Netssh.pool.idle_timeout = 0` doesn't disable connection pooling anymore,
811
only connection expiration. To disable connection polling use `SSHKit::Backend::Netssh.pool.enabled = false`
912
* Add your entries below here, remember to credit yourself however you want

EXAMPLES.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -366,12 +366,14 @@ known test cases, it works. The key thing is that `if` is not mapped to
366366
Into the `Rakefile` simply put something like:
367367

368368
```ruby
369-
require 'sshkit/dsl'
369+
require 'sshkit'
370370

371371
SSHKit.config.command_map[:rake] = "./bin/rake"
372372

373373
desc "Deploy the site, pulls from Git, migrate the db and precompile assets, then restart Passenger."
374374
task :deploy do
375+
include SSHKit::DSL
376+
375377
on "example.com" do |host|
376378
within "/opt/sites/example.com" do
377379
execute :git, :pull

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ The typical use-case looks something like this:
1313

1414
```ruby
1515
require 'sshkit'
16-
require 'sshkit/dsl'
16+
include SSHKit::DSL
1717

1818
on %w{1.example.com 2.example.com}, in: :sequence, wait: 5 do |host|
1919
within "/opt/sites/example.com" do

lib/sshkit/all.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
require_relative 'coordinator'
1111

1212
require_relative 'deprecation_logger'
13+
require_relative 'dsl'
1314

1415
require_relative 'exception'
1516

@@ -35,4 +36,4 @@
3536
require_relative 'backends/printer'
3637
require_relative 'backends/netssh'
3738
require_relative 'backends/local'
38-
require_relative 'backends/skipper'
39+
require_relative 'backends/skipper'

lib/sshkit/dsl.rb

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,3 @@ def run_locally(&block)
1313
end
1414

1515
end
16-
17-
include SSHKit::DSL

test/unit/test_dsl.rb

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
require 'helper'
2+
3+
module SSHKit
4+
5+
class TestDSL < UnitTest
6+
include SSHKit::DSL
7+
8+
def test_dsl_on
9+
coordinator = mock
10+
Coordinator.stubs(:new).returns coordinator
11+
coordinator.expects(:each).at_least_once
12+
13+
on('1.2.3.4')
14+
end
15+
16+
def test_dsl_run_locally
17+
local_backend = mock
18+
Backend::Local.stubs(:new).returns local_backend
19+
local_backend.expects(:run).at_least_once
20+
21+
run_locally
22+
end
23+
24+
end
25+
26+
end

0 commit comments

Comments
 (0)