screwcap 0.1 → 0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.bundle/config +2 -0
- data/Manifest.txt +2 -1
- data/Rakefile +2 -2
- data/lib/screwcap.rb +1 -1
- data/lib/screwcap/task.rb +0 -1
- data/screwcap.gemspec +2 -1
- data/spec/task_spec.rb +33 -33
- data/test/config/expect.rb +9 -2
- data/test/config/upload.rb +4 -0
- metadata +27 -10
- data/test/test_command_set.rb +0 -40
data/.bundle/config
ADDED
data/Manifest.txt
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
.bundle/config
|
1
2
|
Gemfile
|
2
3
|
Gemfile.lock
|
3
4
|
History.txt
|
@@ -33,5 +34,5 @@ test/config/undefined_command_set.rb
|
|
33
34
|
test/config/undefined_item.rb
|
34
35
|
test/config/undefined_server.rb
|
35
36
|
test/config/unknown_use.rb
|
37
|
+
test/config/upload.rb
|
36
38
|
test/config/use.rb
|
37
|
-
test/test_command_set.rb
|
data/Rakefile
CHANGED
@@ -11,10 +11,10 @@ Hoe.plugin :newgem
|
|
11
11
|
# Generate all the Rake tasks
|
12
12
|
# Run 'rake -T' to see list of generated tasks (from gem root directory)
|
13
13
|
$hoe = Hoe.spec 'screwcap' do
|
14
|
-
self.version = '0.
|
14
|
+
self.version = '0.2'
|
15
15
|
self.developer 'Grant Ammons', 'grant@pipelinedeals.com'
|
16
16
|
self.rubyforge_name = self.name # TODO this is default value
|
17
|
-
self.extra_deps = [['net-ssh','>= 2.0.23'],['net-ssh-gateway','>=1.0.1']]
|
17
|
+
self.extra_deps = [['net-ssh','>= 2.0.23'],['net-ssh-gateway','>=1.0.1'], ['net-scp','>=1.0.4']]
|
18
18
|
end
|
19
19
|
|
20
20
|
require 'newgem/tasks'
|
data/lib/screwcap.rb
CHANGED
data/lib/screwcap/task.rb
CHANGED
@@ -129,7 +129,6 @@ class Task < Screwcap::Base
|
|
129
129
|
rescue Net::SSH::AuthenticationFailed => e
|
130
130
|
raise Net::SSH::AuthenticationFailed, "Authentication failed for server named #{server.name}. Please check your authentication credentials."
|
131
131
|
rescue Exception => e
|
132
|
-
debugger
|
133
132
|
errorlog red(" F: (#{address}): #{e}")
|
134
133
|
ensure
|
135
134
|
log blue("*** END executing task #{self.__name} on #{server.name} with address #{address}\n\n") unless self.__options[:silent] == true
|
data/screwcap.gemspec
CHANGED
@@ -6,7 +6,7 @@ require 'bundler/version'
|
|
6
6
|
|
7
7
|
Gem::Specification.new do |s|
|
8
8
|
s.name = "screwcap"
|
9
|
-
s.version = "0.
|
9
|
+
s.version = "0.2"
|
10
10
|
s.platform = Gem::Platform::RUBY
|
11
11
|
s.author = "Grant Ammons"
|
12
12
|
s.email = ["grant@pipelinedealsco.com"]
|
@@ -15,6 +15,7 @@ Gem::Specification.new do |s|
|
|
15
15
|
|
16
16
|
s.add_dependency(['net-ssh','>=2.0.23'])
|
17
17
|
s.add_dependency(['net-ssh-gateway','>=1.0.1'])
|
18
|
+
s.add_dependency(['net-scp','>=1.0.4'])
|
18
19
|
s.rubyforge_project = 'screwcap'
|
19
20
|
|
20
21
|
s.files = Dir.glob("{bin,lib}/**/*") + %w(README.rdoc screwcap.gemspec)
|
data/spec/task_spec.rb
CHANGED
@@ -16,22 +16,22 @@ describe "Tasks" do
|
|
16
16
|
Net::SCP.stubs(:upload!).returns(nil)
|
17
17
|
end
|
18
18
|
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
19
|
+
it "should be able to create variables" do
|
20
|
+
task = @deployer.__tasks.find {|t| t.name == :task1 }
|
21
|
+
task.bango.should == "bongo"
|
22
|
+
end
|
23
23
|
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
24
|
+
it "should compile run statements" do
|
25
|
+
task = @deployer.__tasks.find {|t| t.name == :task1 }
|
26
|
+
task.should have(6).__commands
|
27
|
+
end
|
28
28
|
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
29
|
+
it "should be able to execute statements on a remote server" do
|
30
|
+
task = @deployer.__tasks.find {|t| t.name == :task1 }
|
31
|
+
task.execute!
|
32
|
+
@stderr.should == []
|
33
|
+
@stdout.size.should == 29
|
34
|
+
end
|
35
35
|
|
36
36
|
it "should be able to use variables in the run statement" do
|
37
37
|
task = @deployer.__tasks.find {|t| t.name == :task1 }
|
@@ -39,30 +39,30 @@ describe "Tasks" do
|
|
39
39
|
command.should == "deploy dir = tester"
|
40
40
|
end
|
41
41
|
|
42
|
-
|
43
|
-
|
44
|
-
|
42
|
+
it "should be able to override a globally set variable" do
|
43
|
+
@deployer.deploy_var_2.should == "bongo"
|
44
|
+
@deployer.deploy_var_3.should == %w(one two)
|
45
45
|
|
46
|
-
|
47
|
-
|
46
|
+
task = @deployer.__tasks.find {|t| t.name == :task1 }
|
47
|
+
task.deploy_var_2.should == "shasta"
|
48
48
|
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
49
|
+
task = @deployer.__tasks.find {|t| t.name == :task2 }
|
50
|
+
task.deploy_var_2.should == "purple"
|
51
|
+
task.deploy_var_3.should == "mountain dew"
|
52
|
+
end
|
53
53
|
|
54
|
-
|
55
|
-
|
56
|
-
|
54
|
+
it "should complain if you do not pass the task a server argument" do
|
55
|
+
lambda { Deployer.new(:recipe_file => "./test/config/no_server.rb", :silent => false)}.should raise_error(Screwcap::ConfigurationError)
|
56
|
+
end
|
57
57
|
|
58
|
-
|
59
|
-
|
60
|
-
|
58
|
+
it "should complain if you pass a server that is not defined" do
|
59
|
+
lambda { Deployer.new(:recipe_file => "./test/config/undefined_server.rb", :silent => false)}.should raise_error(Screwcap::ConfigurationError)
|
60
|
+
end
|
61
61
|
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
62
|
+
it "should be able to disable parallel running" do
|
63
|
+
# this is hard to test. with threads and stuff
|
64
|
+
lambda { @deployer.run! :non_parallel }.should_not raise_error
|
65
|
+
end
|
66
66
|
|
67
67
|
it "should be able to run local commands" do
|
68
68
|
lambda { @deployer.run! :task3 }.should_not raise_error
|
data/test/config/expect.rb
CHANGED
@@ -16,8 +16,15 @@ task_for :logic, :server => :test do
|
|
16
16
|
end
|
17
17
|
end
|
18
18
|
|
19
|
-
|
19
|
+
command_set :fail do
|
20
|
+
run "ls"
|
21
|
+
end
|
22
|
+
|
23
|
+
command_set :success do
|
20
24
|
run "ls"
|
21
|
-
|
25
|
+
end
|
26
|
+
|
27
|
+
task_for :expect, :server => :test do
|
28
|
+
run "ls", :onfail => :fail, :onsuccess => :success
|
22
29
|
end
|
23
30
|
|
metadata
CHANGED
@@ -1,12 +1,12 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: screwcap
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 15
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
|
-
-
|
9
|
-
version: "0.
|
8
|
+
- 2
|
9
|
+
version: "0.2"
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Grant Ammons
|
@@ -50,9 +50,25 @@ dependencies:
|
|
50
50
|
type: :runtime
|
51
51
|
version_requirements: *id002
|
52
52
|
- !ruby/object:Gem::Dependency
|
53
|
-
name:
|
53
|
+
name: net-scp
|
54
54
|
prerelease: false
|
55
55
|
requirement: &id003 !ruby/object:Gem::Requirement
|
56
|
+
none: false
|
57
|
+
requirements:
|
58
|
+
- - ">="
|
59
|
+
- !ruby/object:Gem::Version
|
60
|
+
hash: 31
|
61
|
+
segments:
|
62
|
+
- 1
|
63
|
+
- 0
|
64
|
+
- 4
|
65
|
+
version: 1.0.4
|
66
|
+
type: :runtime
|
67
|
+
version_requirements: *id003
|
68
|
+
- !ruby/object:Gem::Dependency
|
69
|
+
name: rubyforge
|
70
|
+
prerelease: false
|
71
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
56
72
|
none: false
|
57
73
|
requirements:
|
58
74
|
- - ">="
|
@@ -64,11 +80,11 @@ dependencies:
|
|
64
80
|
- 4
|
65
81
|
version: 2.0.4
|
66
82
|
type: :development
|
67
|
-
version_requirements: *
|
83
|
+
version_requirements: *id004
|
68
84
|
- !ruby/object:Gem::Dependency
|
69
85
|
name: hoe
|
70
86
|
prerelease: false
|
71
|
-
requirement: &
|
87
|
+
requirement: &id005 !ruby/object:Gem::Requirement
|
72
88
|
none: false
|
73
89
|
requirements:
|
74
90
|
- - ">="
|
@@ -80,7 +96,7 @@ dependencies:
|
|
80
96
|
- 2
|
81
97
|
version: 2.6.2
|
82
98
|
type: :development
|
83
|
-
version_requirements: *
|
99
|
+
version_requirements: *id005
|
84
100
|
description: |-
|
85
101
|
Screwcap is a library that wraps Net::SSH and makes it easy to perform actions on remote servers. It's not smart and does not make any assumptions about your setup.
|
86
102
|
|
@@ -95,6 +111,7 @@ extra_rdoc_files:
|
|
95
111
|
- History.txt
|
96
112
|
- Manifest.txt
|
97
113
|
files:
|
114
|
+
- .bundle/config
|
98
115
|
- Gemfile
|
99
116
|
- Gemfile.lock
|
100
117
|
- History.txt
|
@@ -130,8 +147,8 @@ files:
|
|
130
147
|
- test/config/undefined_item.rb
|
131
148
|
- test/config/undefined_server.rb
|
132
149
|
- test/config/unknown_use.rb
|
150
|
+
- test/config/upload.rb
|
133
151
|
- test/config/use.rb
|
134
|
-
- test/test_command_set.rb
|
135
152
|
has_rdoc: true
|
136
153
|
homepage: http://github.com/#{github_username}/#{project_name}
|
137
154
|
licenses: []
|
@@ -167,5 +184,5 @@ rubygems_version: 1.3.7
|
|
167
184
|
signing_key:
|
168
185
|
specification_version: 3
|
169
186
|
summary: Screwcap is a library that wraps Net::SSH and makes it easy to perform actions on remote servers
|
170
|
-
test_files:
|
171
|
-
|
187
|
+
test_files: []
|
188
|
+
|
data/test/test_command_set.rb
DELETED
@@ -1,40 +0,0 @@
|
|
1
|
-
require File.dirname(__FILE__) + '/test_helper.rb'
|
2
|
-
|
3
|
-
class TestCommandSet < Test::Unit::TestCase
|
4
|
-
|
5
|
-
def setup
|
6
|
-
Net::SSH.stubs(:start).yields(SSHObject.new(:return_stream => :stdout, :return_data => "hostname = asdf\n"))
|
7
|
-
end
|
8
|
-
|
9
|
-
def test_command_sets
|
10
|
-
deployer = Deployer.new(:recipe_file => "./test/config/command_sets.rb", :silent => true)
|
11
|
-
assert deployer
|
12
|
-
|
13
|
-
task = deployer.__tasks.find {|t| t.name == :use_command_set_no_override }
|
14
|
-
assert task
|
15
|
-
|
16
|
-
task.__command_sets.first.instance_eval(&task.__command_sets.first.__block)
|
17
|
-
assert_equal ["tester","run with tester", "bongo"], task.__commands
|
18
|
-
|
19
|
-
task = deployer.__tasks.find {|t| t.name == :use_command_set_with_override }
|
20
|
-
assert task
|
21
|
-
|
22
|
-
assert_equal ["shasta","run with shasta", "bongo"], task.__commands
|
23
|
-
|
24
|
-
task = deployer.__tasks.find {|t| t.name == :use_command_set_complex_override }
|
25
|
-
assert task
|
26
|
-
assert_equal ["dingle"], task.__commands
|
27
|
-
end
|
28
|
-
|
29
|
-
def test_nested_command_sets
|
30
|
-
deployer = Deployer.new(:recipe_file => "./test/config/command_sets.rb", :silent => true)
|
31
|
-
|
32
|
-
task = deployer.__tasks.find {|t| t.name == :nested_command_set }
|
33
|
-
assert task
|
34
|
-
assert_equal %w(1 2 3 4), task.__commands
|
35
|
-
end
|
36
|
-
|
37
|
-
def test_undefined_value_in_command_set
|
38
|
-
assert_raise(NoMethodError) { Deployer.new(:recipe_file => "./test/config/undefined_command_set.rb", :silent => true) }
|
39
|
-
end
|
40
|
-
end
|