vagrant-shortcuts 0.0.1 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +61 -10
- data/lib/vagrant-shortcuts/version.rb +1 -1
- data/lib/vagrant-shortcuts.rb +16 -2
- data/vagrant-shortcuts.gemspec +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6e94cfdd7ea4c44cfd7229753110286711a8d56d
|
4
|
+
data.tar.gz: bd63397478fadfe26c7063db0967367a3610c932
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9c1460c365caa674562192e88114f6d047e6ce597d2c1eb26191d228558625b04671a2a244932524ee358be6283076d32cd0d90a77101ca3fe5d84817674473a
|
7
|
+
data.tar.gz: 0363294843abab4f01b45613d3238480e219bc60b9b9a3f30dcd0a537f5b9db5add022c18c6de6a3a3433c0718f9db4ccb51cfa7aef601c528d92a16c5a8523d
|
data/README.md
CHANGED
@@ -1,30 +1,81 @@
|
|
1
1
|
# Vagrant::Shortcuts
|
2
2
|
|
3
|
-
|
3
|
+
Add shortcut commands to your Vagrantfile:
|
4
|
+
|
5
|
+
```ruby
|
6
|
+
config.shortcuts.add(:assets) do |machine|
|
7
|
+
machine.action(:ssh_run, ssh_run_command: <<-cmd)
|
8
|
+
gulp assets
|
9
|
+
cmd
|
10
|
+
end
|
11
|
+
```
|
12
|
+
|
13
|
+
```bash
|
14
|
+
$ vagrant do assets
|
15
|
+
```
|
4
16
|
|
5
17
|
## Installation
|
6
18
|
|
7
|
-
|
19
|
+
Install the gem:
|
20
|
+
|
21
|
+
$ gem install vagrant-shortcuts
|
22
|
+
|
23
|
+
## Usage
|
24
|
+
|
25
|
+
### Defining shortcuts
|
26
|
+
|
27
|
+
In your `Vagrantfile`, in a `Vagrant.configure` block,
|
28
|
+
add any number of shortcuts.
|
29
|
+
To define a shortcut called `assets` that precompiles all your frontend assets
|
30
|
+
using the Rails asset pipeline, you might do something like:
|
8
31
|
|
9
32
|
```ruby
|
10
|
-
|
33
|
+
Vagrant.configure("2") do |config|
|
34
|
+
|
35
|
+
# ...
|
36
|
+
|
37
|
+
config.shortcuts.add(:assets) do |machine|
|
38
|
+
machine.action(:ssh_run, ssh_run_command: <<-cmd)
|
39
|
+
bin/rake assets:precompile
|
40
|
+
cmd
|
41
|
+
end
|
42
|
+
end
|
11
43
|
```
|
12
44
|
|
13
|
-
|
45
|
+
Shortcuts are defined by a name and a ruby function.
|
46
|
+
The function must take one argument: a Vagrant machine.
|
47
|
+
The function may do anything it wants with this machine,
|
48
|
+
but common tasks include SSHing in to the box and running a command.
|
14
49
|
|
15
|
-
|
50
|
+
By default, the machine is started before the shortcut is run.
|
51
|
+
This may involve fetching a base box and provisioning the machine.
|
52
|
+
If you do not want to start the box by default,
|
53
|
+
pass `start_machine: false` when adding the shortcut:
|
16
54
|
|
17
|
-
|
55
|
+
```ruby
|
56
|
+
config.shortcuts.add(:assets, start_machine: False) do |machine|
|
57
|
+
# ...
|
58
|
+
end
|
59
|
+
```
|
18
60
|
|
19
|
-
|
61
|
+
The machine can be started manually by:
|
20
62
|
|
21
|
-
|
63
|
+
```ruby
|
64
|
+
machine.action(:up, {:provision_ignore_sentinel => false})
|
65
|
+
```
|
66
|
+
|
67
|
+
### Running shortcuts
|
22
68
|
|
23
|
-
|
69
|
+
Run a shortcut from the command line using `vagrant do <shortcut>`.
|
70
|
+
To run the example `assets` shortcut defined previously, run:
|
71
|
+
|
72
|
+
```bash
|
73
|
+
$ vagrant do assets
|
74
|
+
```
|
24
75
|
|
25
76
|
## Contributing
|
26
77
|
|
27
|
-
1. Fork it ( https://
|
78
|
+
1. Fork it ( <https://bitbucket.org/tim_heap/vagrant-shortcuts/fork> )
|
28
79
|
2. Create your feature branch (`git checkout -b my-new-feature`)
|
29
80
|
3. Commit your changes (`git commit -am 'Add some feature'`)
|
30
81
|
4. Push to the branch (`git push origin my-new-feature`)
|
data/lib/vagrant-shortcuts.rb
CHANGED
@@ -2,6 +2,20 @@ require "vagrant-shortcuts/version"
|
|
2
2
|
|
3
3
|
module VagrantPlugins
|
4
4
|
|
5
|
+
class Shortcut
|
6
|
+
def initialize(callable, start_machine: true)
|
7
|
+
@callable = callable
|
8
|
+
@start_machine = start_machine
|
9
|
+
end
|
10
|
+
|
11
|
+
def call(machine)
|
12
|
+
if @start_machine
|
13
|
+
machine.action(:up, {:provision_ignore_sentinel => false})
|
14
|
+
end
|
15
|
+
@callable.call(machine)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
5
19
|
class Shortcuts < Vagrant.plugin("2")
|
6
20
|
name "Shortcuts plugin"
|
7
21
|
|
@@ -31,8 +45,8 @@ module VagrantPlugins
|
|
31
45
|
def initialize
|
32
46
|
@shortcuts = {}
|
33
47
|
end
|
34
|
-
def add(name, &block)
|
35
|
-
@shortcuts[name] = block
|
48
|
+
def add(name, *args, &block)
|
49
|
+
@shortcuts[name] = Shortcut.new(block, *args)
|
36
50
|
end
|
37
51
|
def get(name)
|
38
52
|
@shortcuts[name]
|
data/vagrant-shortcuts.gemspec
CHANGED
@@ -10,7 +10,7 @@ Gem::Specification.new do |spec|
|
|
10
10
|
spec.email = ["tim@timheap.me"]
|
11
11
|
spec.summary = "Embed shortcut commands in your Vagrantfile"
|
12
12
|
spec.description = "Embed shortcut commands directly in your Vagrant file"
|
13
|
-
spec.homepage = ""
|
13
|
+
spec.homepage = "https://bitbucket.org/tim_heap/vagrant-shortcuts"
|
14
14
|
spec.license = "BSD"
|
15
15
|
|
16
16
|
spec.files = `git ls-files -z`.split("\x0")
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: vagrant-shortcuts
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tim Heap
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-04-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -53,7 +53,7 @@ files:
|
|
53
53
|
- lib/vagrant-shortcuts.rb
|
54
54
|
- lib/vagrant-shortcuts/version.rb
|
55
55
|
- vagrant-shortcuts.gemspec
|
56
|
-
homepage:
|
56
|
+
homepage: https://bitbucket.org/tim_heap/vagrant-shortcuts
|
57
57
|
licenses:
|
58
58
|
- BSD
|
59
59
|
metadata: {}
|