cast-ssh 0.1.5 → 0.1.6
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/cast.rb +4 -15
- data/spec/lib/cast_spec.rb +26 -27
- metadata +34 -22
- checksums.yaml +0 -7
data/lib/cast.rb
CHANGED
@@ -8,7 +8,7 @@ STDOUT.sync = true
|
|
8
8
|
STDERR.sync = true
|
9
9
|
|
10
10
|
module Cast
|
11
|
-
VERSION = '0.1.
|
11
|
+
VERSION = '0.1.6'
|
12
12
|
DEFAULTGROUPS = '~/.cast.yml'
|
13
13
|
|
14
14
|
@@mux = Mutex.new
|
@@ -68,23 +68,12 @@ module Cast
|
|
68
68
|
def self.remote host, cmd, ssh = 'ssh'
|
69
69
|
fullcmd = "#{ssh} #{host} '#{cmd}'"
|
70
70
|
log "running #{fullcmd}"
|
71
|
-
local fullcmd
|
72
|
-
end
|
73
|
-
|
74
|
-
def self.ensure_local cmd, prefix = nil
|
75
|
-
r = local cmd, prefix
|
76
|
-
raise "command failed: #{cmd}" unless r == 0
|
77
|
-
return r
|
71
|
+
local fullcmd
|
78
72
|
end
|
79
73
|
|
80
74
|
def self.local cmd, options = {}
|
81
|
-
|
82
|
-
|
83
|
-
if options.is_a? String
|
84
|
-
prefix = options # this is for backwards compatibility
|
85
|
-
elsif options[:prefix]
|
86
|
-
prefix = options[:prefix]
|
87
|
-
end
|
75
|
+
options = {} if options == nil
|
76
|
+
prefix = options[:prefix]
|
88
77
|
|
89
78
|
r = nil
|
90
79
|
|
data/spec/lib/cast_spec.rb
CHANGED
@@ -3,51 +3,50 @@ require 'spec_helper'
|
|
3
3
|
describe Cast do
|
4
4
|
it 'should return the command output' do
|
5
5
|
r = Cast::local 'true'
|
6
|
-
r.
|
6
|
+
expect(r).to eq(0)
|
7
7
|
|
8
8
|
r = Cast::local 'false'
|
9
|
-
r.
|
9
|
+
expect(r).to eq(1)
|
10
10
|
end
|
11
11
|
|
12
12
|
it 'should ensure local commands finish' do
|
13
|
-
r = Cast::
|
14
|
-
r.
|
15
|
-
|
16
|
-
expect { Cast::ensure_local 'false'}.to raise_error
|
13
|
+
r = Cast::local 'true', {:ensure => true}
|
14
|
+
expect(r).to eq(0)
|
15
|
+
expect { Cast::local('false', {:ensure => true}) }.to raise_error
|
17
16
|
end
|
18
17
|
|
19
18
|
it 'should load groups' do
|
20
19
|
groups = Cast::load_groups 'spec/test.yml'
|
21
|
-
groups.size.
|
22
|
-
groups['group1'].size.
|
23
|
-
groups['group1'][0].
|
20
|
+
expect(groups.size).to eq(2)
|
21
|
+
expect(groups['group1'].size).to eq(3)
|
22
|
+
expect(groups['group1'][0]).to eq('host1')
|
24
23
|
end
|
25
24
|
|
26
25
|
it 'should expand groups' do
|
27
26
|
groups = Cast::load_groups 'spec/test.yml'
|
28
27
|
hosts = Cast::expand_groups ['group1'], groups
|
29
|
-
hosts.size.
|
30
|
-
hosts[0].
|
31
|
-
hosts[1].
|
32
|
-
hosts[2].
|
28
|
+
expect(hosts.size).to eq(3)
|
29
|
+
expect(hosts[0]).to eq('host1')
|
30
|
+
expect(hosts[1]).to eq('host2')
|
31
|
+
expect(hosts[2]).to eq('host3')
|
33
32
|
|
34
33
|
hosts = Cast::expand_groups ['group1', 'group2']
|
35
|
-
hosts.size.
|
36
|
-
hosts[0].
|
37
|
-
hosts[1].
|
38
|
-
hosts[2].
|
39
|
-
hosts[3].
|
40
|
-
hosts[4].
|
34
|
+
expect(hosts.size).to eq(5)
|
35
|
+
expect(hosts[0]).to eq('host1')
|
36
|
+
expect(hosts[1]).to eq('host2')
|
37
|
+
expect(hosts[2]).to eq('host3')
|
38
|
+
expect(hosts[3]).to eq('host4')
|
39
|
+
expect(hosts[4]).to eq('host5')
|
41
40
|
|
42
41
|
hosts = Cast::expand_groups ['host10', 'group1', 'host11', 'group2']
|
43
|
-
hosts.size.
|
44
|
-
hosts[0].
|
45
|
-
hosts[1].
|
46
|
-
hosts[2].
|
47
|
-
hosts[3].
|
48
|
-
hosts[4].
|
49
|
-
hosts[5].
|
50
|
-
hosts[6].
|
42
|
+
expect(hosts.size).to eq(7)
|
43
|
+
expect(hosts[0]).to eq('host10')
|
44
|
+
expect(hosts[1]).to eq('host1')
|
45
|
+
expect(hosts[2]).to eq('host2')
|
46
|
+
expect(hosts[3]).to eq('host3')
|
47
|
+
expect(hosts[4]).to eq('host11')
|
48
|
+
expect(hosts[5]).to eq('host4')
|
49
|
+
expect(hosts[6]).to eq('host5')
|
51
50
|
end
|
52
51
|
end
|
53
52
|
|
metadata
CHANGED
@@ -1,83 +1,94 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cast-ssh
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.6
|
5
|
+
prerelease:
|
5
6
|
platform: ruby
|
6
7
|
authors:
|
7
8
|
- Peter Bakkum
|
8
9
|
autorequire:
|
9
10
|
bindir: bin
|
10
11
|
cert_chain: []
|
11
|
-
date:
|
12
|
+
date: 2015-01-06 00:00:00.000000000 Z
|
12
13
|
dependencies:
|
13
14
|
- !ruby/object:Gem::Dependency
|
14
15
|
name: mocha
|
15
16
|
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
16
18
|
requirements:
|
17
|
-
- -
|
19
|
+
- - ! '>='
|
18
20
|
- !ruby/object:Gem::Version
|
19
21
|
version: '0'
|
20
22
|
type: :development
|
21
23
|
prerelease: false
|
22
24
|
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
23
26
|
requirements:
|
24
|
-
- -
|
27
|
+
- - ! '>='
|
25
28
|
- !ruby/object:Gem::Version
|
26
29
|
version: '0'
|
27
30
|
- !ruby/object:Gem::Dependency
|
28
31
|
name: rspec
|
29
32
|
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
30
34
|
requirements:
|
31
|
-
- -
|
35
|
+
- - ! '>='
|
32
36
|
- !ruby/object:Gem::Version
|
33
37
|
version: '0'
|
34
38
|
type: :development
|
35
39
|
prerelease: false
|
36
40
|
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
37
42
|
requirements:
|
38
|
-
- -
|
43
|
+
- - ! '>='
|
39
44
|
- !ruby/object:Gem::Version
|
40
45
|
version: '0'
|
41
46
|
- !ruby/object:Gem::Dependency
|
42
47
|
name: autotest-standalone
|
43
48
|
requirement: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
44
50
|
requirements:
|
45
|
-
- -
|
51
|
+
- - ! '>='
|
46
52
|
- !ruby/object:Gem::Version
|
47
53
|
version: '0'
|
48
54
|
type: :development
|
49
55
|
prerelease: false
|
50
56
|
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
51
58
|
requirements:
|
52
|
-
- -
|
59
|
+
- - ! '>='
|
53
60
|
- !ruby/object:Gem::Version
|
54
61
|
version: '0'
|
55
62
|
- !ruby/object:Gem::Dependency
|
56
63
|
name: peach
|
57
64
|
requirement: !ruby/object:Gem::Requirement
|
65
|
+
none: false
|
58
66
|
requirements:
|
59
|
-
- -
|
67
|
+
- - ! '>='
|
60
68
|
- !ruby/object:Gem::Version
|
61
69
|
version: '0'
|
62
70
|
type: :runtime
|
63
71
|
prerelease: false
|
64
72
|
version_requirements: !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
65
74
|
requirements:
|
66
|
-
- -
|
75
|
+
- - ! '>='
|
67
76
|
- !ruby/object:Gem::Version
|
68
77
|
version: '0'
|
69
78
|
- !ruby/object:Gem::Dependency
|
70
79
|
name: trollop
|
71
80
|
requirement: !ruby/object:Gem::Requirement
|
81
|
+
none: false
|
72
82
|
requirements:
|
73
|
-
- -
|
83
|
+
- - ! '>='
|
74
84
|
- !ruby/object:Gem::Version
|
75
85
|
version: '0'
|
76
86
|
type: :runtime
|
77
87
|
prerelease: false
|
78
88
|
version_requirements: !ruby/object:Gem::Requirement
|
89
|
+
none: false
|
79
90
|
requirements:
|
80
|
-
- -
|
91
|
+
- - ! '>='
|
81
92
|
- !ruby/object:Gem::Version
|
82
93
|
version: '0'
|
83
94
|
description: Execute remote commands via ssh on groups of machines
|
@@ -90,41 +101,42 @@ extra_rdoc_files:
|
|
90
101
|
- LICENSE.md
|
91
102
|
- README.md
|
92
103
|
files:
|
93
|
-
- ".rspec"
|
94
|
-
- ".travis.yml"
|
95
|
-
- Gemfile
|
96
104
|
- LICENSE.md
|
97
105
|
- README.md
|
98
|
-
- bin/cast
|
99
106
|
- cast.gemspec
|
107
|
+
- Gemfile
|
108
|
+
- .rspec
|
109
|
+
- .travis.yml
|
100
110
|
- lib/cast.rb
|
111
|
+
- bin/cast
|
101
112
|
- spec/lib/cast_spec.rb
|
102
113
|
- spec/spec_helper.rb
|
103
114
|
- spec/test.yml
|
104
115
|
homepage: http://github.com/bakks/cast
|
105
116
|
licenses:
|
106
117
|
- MIT
|
107
|
-
metadata: {}
|
108
118
|
post_install_message:
|
109
119
|
rdoc_options:
|
110
|
-
-
|
120
|
+
- --charset=UTF-8
|
111
121
|
require_paths:
|
112
122
|
- lib
|
113
123
|
required_ruby_version: !ruby/object:Gem::Requirement
|
124
|
+
none: false
|
114
125
|
requirements:
|
115
|
-
- -
|
126
|
+
- - ! '>='
|
116
127
|
- !ruby/object:Gem::Version
|
117
128
|
version: '0'
|
118
129
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
130
|
+
none: false
|
119
131
|
requirements:
|
120
|
-
- -
|
132
|
+
- - ! '>='
|
121
133
|
- !ruby/object:Gem::Version
|
122
134
|
version: 1.3.6
|
123
135
|
requirements: []
|
124
136
|
rubyforge_project:
|
125
|
-
rubygems_version:
|
137
|
+
rubygems_version: 1.8.23.2
|
126
138
|
signing_key:
|
127
|
-
specification_version:
|
139
|
+
specification_version: 3
|
128
140
|
summary: Execute remote commands via ssh on groups of machines
|
129
141
|
test_files:
|
130
142
|
- spec/lib/cast_spec.rb
|
checksums.yaml
DELETED
@@ -1,7 +0,0 @@
|
|
1
|
-
---
|
2
|
-
SHA1:
|
3
|
-
metadata.gz: cceed46756626f5c4c561cf1f6d906db52030585
|
4
|
-
data.tar.gz: ea3828524600ca8e6f073b7b5de2da4d4b6e7ae6
|
5
|
-
SHA512:
|
6
|
-
metadata.gz: 7f15fca12981a9c221f10e3d5a5975d4da9950afc192d89b0c5db69d3709cf913a4014cd3915bf30e353ad1038eb2be8233a7d0e037a4945f25664151ee56c0c
|
7
|
-
data.tar.gz: c873f60082c69d8c5bbac734243f4636db527e48f9e385e45c6fc7a9705b3227eaa54c637056cc67a2271ca9c3004fcfc4e104851e1ddcba0fd596adb42a75c2
|