vagrant-devcommands 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3de3849c6e3d761ca5b178fdc94bf957632e3b78
4
- data.tar.gz: eda7f7046ff1ba3ed1f71d36b90acb595d887b4c
3
+ metadata.gz: c1835de5d77e36ecc2fdda818fd4b6f682d044b8
4
+ data.tar.gz: b9edaee5f787c09dd8b4783d5342fb7e55045a0c
5
5
  SHA512:
6
- metadata.gz: 53997668cf426e5f6536a72bd3013807d4fd7209ee2adb58850d54220c1b6071fbfd2e5d7074c87b3fdfb6b5965c3e7de5bf3ffae52137e96fcf26fd430677f9
7
- data.tar.gz: 69a93bfdb2e66e45833d4b9ee2164cb3d334ce0b05e3defa4ac954c3bfe659ee7c2ed78c9545364af53a2bea1e61dae15aaf4c6c9291a3284e7d0a13aa7ac598
6
+ metadata.gz: 5cc5094fa2638a80ce20390587e42c26b589c02c8744fe112166cd82f2d54f796983866967af80021ad7c97a5b6caa52cc3fc03f62c412f36525ffca99590b6c
7
+ data.tar.gz: 9323285ba6a94e6339f28c44b539c7cc0eb27698acc28b08ea22671a5c08c8a07230f1de03e3ed41cbd7ce6c2aba3bd8517dc5bb704edd4afa436baaa6942198
data/CHANGELOG.md CHANGED
@@ -1,5 +1,15 @@
1
1
  # Changelog
2
2
 
3
+ ## v0.2.0 (2015-11-02)
4
+
5
+ - Enhancements
6
+ - Commandfile is read from the path of the loaded Vagrantfile
7
+ - Commandfile is looked up case insensitive (`Commandfile` vs `commandfile`)
8
+ - Descriptions can be set for commands
9
+
10
+ - Bug fixes
11
+ - Commandfile can be located outside of current working directory
12
+
3
13
  ## v0.1.0 (2015-10-16)
4
14
 
5
15
  - Initial Release
data/README.md CHANGED
@@ -3,24 +3,30 @@
3
3
  Runs vagrant commands from a Commandfile.
4
4
 
5
5
 
6
- ## Command Definition
6
+ ## Usage
7
+
8
+ ### Command Definition
7
9
 
8
10
  Add to a `Commandfile` besides your `Vagrantfile`:
9
11
 
10
12
  ```ruby
11
- VagrantDevCommands.define 'with_options', box: :my_box, command: 'hostname'
12
- VagrantDevCommands.define 'without_otions', 'hostname'
13
+ VagrantDevCommands.define 'basic', 'hostname'
14
+
15
+ VagrantDevCommands.define 'with_options',
16
+ box: :my_box,
17
+ desc: 'executes "hostname" on the box "my_box"',
18
+ command: 'hostname'
13
19
  ```
14
20
 
15
21
 
16
- ## Command Listing
22
+ ### Command Listing
17
23
 
18
24
  ```shell
19
25
  vagrant run
20
26
  ```
21
27
 
22
28
 
23
- ## Command Execution
29
+ ### Command Execution
24
30
 
25
31
  ```shell
26
32
  # single-vm environment
@@ -32,6 +38,35 @@ vagrant run your_box your_command
32
38
  ```
33
39
 
34
40
 
41
+ ## Notes for Windows Users
42
+
43
+ ### SSH
44
+
45
+ If you are using this plugin on a Windows host system, please make sure your
46
+ regular `vagrant ssh [box]` succeeds. In some cases you may need to add the
47
+ `ssh.exe` (i.e. from a git installation) manually to your `%PATH%`.
48
+
49
+ ### Command Definition
50
+
51
+ When using multi-line commands you probably need to define your command using
52
+ a sigil notation like the following:
53
+
54
+ ```ruby
55
+ VagrantDevCommands.define 'long_running_task',
56
+ command: %(cd /path/to/somewhere \
57
+ && echo "starting long running task" \
58
+ && ./long_running_task.sh \
59
+ && echo "finished long running task")
60
+ ```
61
+
62
+ Using a quote delimited command definition might otherwise result in not that
63
+ helpful error messages about a bad shell command.
64
+
65
+ It might also help to double check the line endings in your Commandfile are set
66
+ unix-style (`\n`) and not windows-style (`\r\n`) if you get errors when running
67
+ your commands.
68
+
69
+
35
70
  ## License
36
71
 
37
72
  Licensed under the [MIT license](http://opensource.org/licenses/MIT).
@@ -7,18 +7,17 @@ module VagrantPlugins
7
7
  end
8
8
 
9
9
  def execute
10
- command = @argv.last
10
+ command = @argv.last
11
+ commandfile = Commandfile.new(@env)
11
12
 
12
- unless File.exist?(command_file_path)
13
- return display_error('Missing "Commandfile"')
14
- end
13
+ return display_error('Missing "Commandfile"') unless commandfile.exist?
15
14
 
16
- import_commands(command_file_path)
15
+ commandfile.import
17
16
 
18
17
  return display_help unless command
19
18
 
20
19
  unless valid_command?(command)
21
- return display_error("Invalid command \"#{command}\"")
20
+ return display_error("Invalid command \"#{command}\"\n")
22
21
  end
23
22
 
24
23
  run command
@@ -26,43 +25,17 @@ module VagrantPlugins
26
25
 
27
26
  private
28
27
 
29
- def command_file_path
30
- File.join @env.cwd, 'Commandfile'
31
- end
32
-
33
28
  def display_error(msg)
34
- puts msg
35
-
36
- display_help
29
+ puts(msg) && display_help
37
30
  end
38
31
 
39
32
  def display_help
40
- list_commands
33
+ Help.display
41
34
 
42
35
  # return exit code
43
36
  127
44
37
  end
45
38
 
46
- def import_commands(command_file)
47
- load command_file
48
- end
49
-
50
- def list_commands
51
- if Definer.commands.empty?
52
- puts 'No commands defined!'
53
- return
54
- end
55
-
56
- puts 'Available commands:'
57
-
58
- Definer.commands.each_key do |name|
59
- puts "- #{name}"
60
- end
61
-
62
- puts ''
63
- puts 'Usage: vagrant run <command>'
64
- end
65
-
66
39
  def run(name)
67
40
  cmd = Definer.commands[name]
68
41
  argv = run_argv(cmd)
@@ -0,0 +1,38 @@
1
+ module VagrantPlugins
2
+ module DevCommands
3
+ # Loads and handles the Commandfile
4
+ class Commandfile
5
+ def initialize(env)
6
+ @env = env
7
+ end
8
+
9
+ def exist?
10
+ nil != find_commandfile
11
+ end
12
+
13
+ def path
14
+ find_commandfile
15
+ end
16
+
17
+ def import
18
+ load path
19
+ end
20
+
21
+ private
22
+
23
+ attr_accessor :env
24
+
25
+ def find_commandfile
26
+ return nil unless @env.root_path
27
+
28
+ %w(Commandfile commandfile).each do |commandfile|
29
+ current_path = @env.root_path.join(commandfile)
30
+
31
+ return current_path if current_path.file?
32
+ end
33
+
34
+ nil
35
+ end
36
+ end
37
+ end
38
+ end
@@ -0,0 +1,40 @@
1
+ module VagrantPlugins
2
+ module DevCommands
3
+ # Defines the help output
4
+ #
5
+ # Printed when running "vagrant run" without a command
6
+ class Help
7
+ def self.display
8
+ if Definer.commands.empty?
9
+ puts 'No commands defined!'
10
+ return
11
+ end
12
+
13
+ display_header
14
+ display_commands
15
+ end
16
+
17
+ class << self
18
+ private
19
+
20
+ def display_commands
21
+ pad_to = Definer.commands.keys.map(&:length).max
22
+
23
+ Definer.commands.each do |name, command|
24
+ if command.key?(:desc)
25
+ puts " #{name.ljust(pad_to)} #{command[:desc]}"
26
+ else
27
+ puts " #{name}"
28
+ end
29
+ end
30
+ end
31
+
32
+ def display_header
33
+ puts 'Usage: vagrant run [box] <command>'
34
+ puts ''
35
+ puts 'Available commands:'
36
+ end
37
+ end
38
+ end
39
+ end
40
+ end
@@ -6,7 +6,6 @@ module VagrantPlugins
6
6
  description 'Runs vagrant commands from a Commandfile'
7
7
 
8
8
  command :run do
9
- require_relative 'command'
10
9
  Command
11
10
  end
12
11
  end
@@ -1,8 +1,6 @@
1
1
  module VagrantPlugins
2
2
  # Defines the current plugin version
3
3
  module DevCommands
4
- # Defines the current plugin version
5
-
6
- VERSION = '0.1.0'
4
+ VERSION = '0.2.0'
7
5
  end
8
6
  end
@@ -1,6 +1,9 @@
1
1
  require 'vagrant'
2
2
 
3
+ require 'vagrant/devcommands/command'
4
+ require 'vagrant/devcommands/commandfile'
3
5
  require 'vagrant/devcommands/definer'
6
+ require 'vagrant/devcommands/help'
4
7
  require 'vagrant/devcommands/plugin'
5
8
  require 'vagrant/devcommands/version'
6
9
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vagrant-devcommands
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Marc Neudert
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-10-16 00:00:00.000000000 Z
11
+ date: 2015-11-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -24,6 +24,20 @@ dependencies:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
26
  version: '1.8'
27
+ - !ruby/object:Gem::Dependency
28
+ name: coveralls
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '0.8'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '0.8'
27
41
  - !ruby/object:Gem::Dependency
28
42
  name: rake
29
43
  requirement: !ruby/object:Gem::Requirement
@@ -66,28 +80,26 @@ dependencies:
66
80
  - - "~>"
67
81
  - !ruby/object:Gem::Version
68
82
  version: '0.34'
69
- description: ''
83
+ description: Vagrant plugin to run commands specified in a Commandfile inside one
84
+ of your vagrant boxes
70
85
  email:
71
86
  - marc.neudert@gmail.com
72
87
  executables: []
73
88
  extensions: []
74
89
  extra_rdoc_files: []
75
90
  files:
76
- - ".gitignore"
77
- - ".travis.yml"
78
91
  - CHANGELOG.md
79
- - Gemfile
80
92
  - LICENSE.txt
81
93
  - README.md
82
- - Rakefile
83
94
  - lib/vagrant/devcommands.rb
84
95
  - lib/vagrant/devcommands/_proxy.rb
85
96
  - lib/vagrant/devcommands/command.rb
97
+ - lib/vagrant/devcommands/commandfile.rb
86
98
  - lib/vagrant/devcommands/definer.rb
99
+ - lib/vagrant/devcommands/help.rb
87
100
  - lib/vagrant/devcommands/plugin.rb
88
101
  - lib/vagrant/devcommands/version.rb
89
- - vagrant-devcommands.gemspec
90
- homepage: ''
102
+ homepage: https://github.com/mneudert/vagrant-devcommands
91
103
  licenses:
92
104
  - MIT
93
105
  metadata:
@@ -108,7 +120,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
108
120
  version: '0'
109
121
  requirements: []
110
122
  rubyforge_project:
111
- rubygems_version: 2.4.5
123
+ rubygems_version: 2.4.8
112
124
  signing_key:
113
125
  specification_version: 4
114
126
  summary: Runs vagrant commands from a Commandfile
data/.gitignore DELETED
@@ -1,2 +0,0 @@
1
- /pkg/
2
- /Gemfile.lock
data/.travis.yml DELETED
@@ -1,6 +0,0 @@
1
- language: ruby
2
- rvm:
3
- - 2.2.0
4
-
5
- before_install:
6
- - gem update bundler
data/Gemfile DELETED
@@ -1,9 +0,0 @@
1
- source 'https://rubygems.org'
2
-
3
- group :development do
4
- gem 'vagrant', git: 'https://github.com/mitchellh/vagrant.git'
5
- end
6
-
7
- group :plugins do
8
- gemspec
9
- end
data/Rakefile DELETED
@@ -1,26 +0,0 @@
1
- require 'bundler/gem_tasks'
2
- require 'rspec/core/rake_task'
3
- require 'rubocop/rake_task'
4
-
5
- namespace :style do
6
- desc 'Run ruby style checks'
7
-
8
- RuboCop::RakeTask.new(:ruby) do |task|
9
- task.patterns = [
10
- '**/*.rb',
11
- '*.gemspec',
12
- 'Gemfile',
13
- 'Rakefile'
14
- ]
15
- end
16
- end
17
-
18
- namespace :test do
19
- desc 'Run tests'
20
-
21
- RSpec::Core::RakeTask.new(:unit) do |t|
22
- t.pattern = 'test/unit/**/*_spec.rb'
23
- end
24
- end
25
-
26
- task default: ['style:ruby', 'test:unit']
@@ -1,35 +0,0 @@
1
- # coding: utf-8
2
- lib = File.expand_path('../lib', __FILE__)
3
-
4
- $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
5
-
6
- require 'vagrant/devcommands/version'
7
-
8
- Gem::Specification.new do |spec|
9
- spec.name = 'vagrant-devcommands'
10
- spec.version = VagrantPlugins::DevCommands::VERSION
11
- spec.platform = Gem::Platform::RUBY
12
- spec.authors = ['Marc Neudert']
13
- spec.email = ['marc.neudert@gmail.com']
14
-
15
- spec.summary = 'Runs vagrant commands from a Commandfile'
16
- spec.description = ''
17
- spec.homepage = ''
18
- spec.license = 'MIT'
19
-
20
- spec.files = `git ls-files -z`.split("\x0").reject { |f|
21
- f.match(%r{^(test|spec|features)/})
22
- }
23
-
24
- spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
25
- spec.require_paths = ['lib']
26
-
27
- if spec.respond_to?(:metadata)
28
- spec.metadata['allowed_push_host'] = 'https://rubygems.org'
29
- end
30
-
31
- spec.add_development_dependency 'bundler', '~> 1.8'
32
- spec.add_development_dependency 'rake', '~> 10.0'
33
- spec.add_development_dependency 'rspec', '~> 3.3'
34
- spec.add_development_dependency 'rubocop', '~> 0.34'
35
- end