vagrant-shell-commander 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore CHANGED
@@ -16,4 +16,5 @@ test/version_tmp
16
16
  tmp
17
17
  .ruby-*
18
18
  *~
19
- .vagrant
19
+ .vagrant
20
+ *gem
data/Gemfile.lock CHANGED
@@ -13,7 +13,7 @@ GIT
13
13
  PATH
14
14
  remote: .
15
15
  specs:
16
- vagrant-shell-commander (0.1.0)
16
+ vagrant-shell-commander (0.1.1)
17
17
 
18
18
  GEM
19
19
  remote: https://rubygems.org/
data/README.md CHANGED
@@ -7,7 +7,7 @@ Vagrant plugin for executing arbitrary shell commands on guest. Executes the giv
7
7
 
8
8
  ## Installation
9
9
 
10
- Install it as a vagrant plugin:
10
+ As usual with vagrant plugins:
11
11
 
12
12
  $ vagrant plugin install vagrant-shell-commander
13
13
 
@@ -21,14 +21,19 @@ Restrict the machine to run:
21
21
 
22
22
  $ vagrant sh --cmd 'free' machine1
23
23
 
24
- Add working directory:
24
+ Specify the working directory:
25
25
 
26
- $ vagrant sh --cmd 'ls -al' --cwd '/srv/www'
26
+ $ vagrant sh --cmd 'ls -al' --dir '/srv/www'
27
+
28
+ Get help:
29
+
30
+ $ vagrant sh -h
27
31
 
28
32
  ## Contributing
29
33
 
30
34
  1. Fork it
31
35
  2. Create your feature branch (`git checkout -b my-new-feature`)
32
- 3. Commit your changes (`git commit -am 'Add some feature'`)
33
- 4. Push to the branch (`git push origin my-new-feature`)
34
- 5. Create new Pull Request
36
+ 3. Add and implement your specs
37
+ 4. Commit your changes (`git commit -am 'Add some feature'`)
38
+ 5. Push to the branch (`git push origin my-new-feature`)
39
+ 6. Create new Pull Request
@@ -11,10 +11,11 @@ module VagrantShellCommander
11
11
 
12
12
  return unless argv
13
13
 
14
- with_target_vms(argv) do |machine|
15
- manage_machine(machine, cli_options)
14
+ unless [nil, ''].include? cli_options[:values][:cmd]
15
+ with_target_vms(argv) do |machine|
16
+ manage_machine(machine, cli_options)
17
+ end
16
18
  end
17
-
18
19
  0
19
20
  end
20
21
 
@@ -9,13 +9,13 @@ module VagrantShellCommander
9
9
  def execute
10
10
  options = {}
11
11
  block = lambda do |parser|
12
- parser.banner = "Usage: vagrant sh --cmd 'COMMAND' --cwd [DIR] [MACHINE]"
12
+ parser.banner = "Usage: vagrant sh --cmd 'COMMAND' --dir [DIR] [MACHINE]"
13
13
 
14
14
  parser.separator ''
15
15
 
16
- parser.on('--cwd [DIR]', '--change-working-dir [DIR]',
17
- 'Directory to execute the command') do |cwd|
18
- options[:cwd] = cwd
16
+ parser.on('--dir [DIR]', '--change-working-dir [DIR]',
17
+ 'Directory to execute the command') do |dir|
18
+ options[:dir] = dir
19
19
  end
20
20
 
21
21
  parser.on("--cmd 'COMMAND'", "--command 'COMMAND'",
@@ -1,3 +1,3 @@
1
1
  module VagrantShellCommander
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
data/spec/command_spec.rb CHANGED
@@ -3,7 +3,7 @@ require 'spec_helper'
3
3
  describe VagrantShellCommander::Command do
4
4
  let(:subject) {described_class.new('2', 'command')}
5
5
  let(:argv) {double}
6
- let(:opts) {{parser: 'parser', values: 'values'}}
6
+ let(:opts) {{parser: 'parser', values: {cmd: 'cmd'}}}
7
7
 
8
8
  before(:each) do
9
9
  VagrantShellCommander::OptionManager.stub_chain(:new, :execute).
@@ -67,6 +67,7 @@ describe VagrantShellCommander::Command do
67
67
 
68
68
  context 'running machine' do
69
69
  let(:cmd) {'command'}
70
+ let(:cwd) {'cwd'}
70
71
  let(:communicate) {double(execute: true)}
71
72
 
72
73
  before(:each) do
@@ -90,14 +91,27 @@ describe VagrantShellCommander::Command do
90
91
  end
91
92
 
92
93
  it 'executes the command in the given cwd' do
93
- cwd = 'cwd'
94
-
95
94
  VagrantShellCommander::OptionManager.stub_chain(:new, :execute).
96
95
  and_return(parser: 'parser', values: {cmd: cmd, cwd: cwd})
97
96
 
98
97
  communicate.should_receive(:execute).with("cd #{cwd} && #{cmd}")
99
98
  end
100
99
 
100
+ describe 'does nothing' do
101
+ after(:each) do
102
+ subject.should_not_receive(:with_target_vms)
103
+ end
104
+
105
+ it 'an empty command' do
106
+ VagrantShellCommander::OptionManager.stub_chain(:new, :execute).
107
+ and_return(parser: 'parser', values: {cmd: '', cwd: cwd})
108
+ end
109
+
110
+ it 'non present command' do
111
+ VagrantShellCommander::OptionManager.stub_chain(:new, :execute).
112
+ and_return(parser: 'parser', values: {cwd: cwd})
113
+ end
114
+ end
101
115
  end
102
116
  end
103
117
  end
@@ -26,17 +26,17 @@ describe VagrantShellCommander::OptionManager do
26
26
  subject.execute
27
27
  end
28
28
 
29
- it 'has a cwd option' do
30
- cwd_value = 'cwd'
29
+ it 'has a dir option' do
30
+ dir_value = 'dir'
31
31
 
32
- option_parser.stub(:on).with('--cwd [DIR]',
32
+ option_parser.stub(:on).with('--dir [DIR]',
33
33
  anything,
34
34
  anything).
35
- and_yield(cwd_value)
35
+ and_yield(dir_value)
36
36
 
37
37
  result = subject.execute
38
38
 
39
- expect(result[:values][:cwd]).to eql(cwd_value)
39
+ expect(result[:values][:dir]).to eql(dir_value)
40
40
  end
41
41
 
42
42
  it 'has a cmd option' do
@@ -8,7 +8,7 @@ Gem::Specification.new do |spec|
8
8
  spec.version = VagrantShellCommander::VERSION
9
9
  spec.authors = ["Federico Gimenez Nieto"]
10
10
  spec.email = ["federico.gimenez@gmail.com"]
11
- spec.description = %q{This plugin allows you to execute a given shell command on all the machines of your multinode environment. You can aldo specify the working directory to execute the command}
11
+ spec.description = %q{This Vagrant plugin allows you to execute a given shell command on all the machines of your multinode environment. You can also specify the working directory to execute the command}
12
12
  spec.summary = %q{Vagrant plugin for executing arbitrary shell commands on guest(s)}
13
13
  spec.homepage = "https://github.com/fgimenez/vagrant-shell-commander"
14
14
  spec.license = "MIT"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vagrant-shell-commander
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-07-10 00:00:00.000000000 Z
12
+ date: 2013-07-11 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler
@@ -123,9 +123,9 @@ dependencies:
123
123
  - - ! '>='
124
124
  - !ruby/object:Gem::Version
125
125
  version: '0'
126
- description: This plugin allows you to execute a given shell command on all the machines
127
- of your multinode environment. You can aldo specify the working directory to execute
128
- the command
126
+ description: This Vagrant plugin allows you to execute a given shell command on all
127
+ the machines of your multinode environment. You can also specify the working directory
128
+ to execute the command
129
129
  email:
130
130
  - federico.gimenez@gmail.com
131
131
  executables: []