Class: Kamaze::Project::Tools::Vagrant
- Inherits:
-
BaseTool
- Object
- Observable
- BaseTool
- Kamaze::Project::Tools::Vagrant
- Defined in:
- lib/kamaze/project/tools/vagrant.rb,
lib/kamaze/project/tools/vagrant/shell.rb,
lib/kamaze/project/tools/vagrant/remote.rb,
lib/kamaze/project/tools/vagrant/writer.rb,
lib/kamaze/project/tools/vagrant/composer.rb
Overview
rubocop:disable Style/Documentation
Defined Under Namespace
Classes: Composer, Remote, Shell, Writer
Instance Attribute Summary collapse
-
#composer ⇒ Composer
readonly
protected
Get composer, responsible to read and combine files describing boxes.
-
#executable ⇒ String|nil
Absolute path to the vagrant executable.
- #observer_peers ⇒ Hash|nil included from Concern::Observable readonly protected
-
#path ⇒ String
Path to files describing boxes (directory).
-
#shell ⇒ Shell
readonly
protected
Get a shell, to execute
vagrant
commands. -
#template ⇒ String
Template file (used for code generation).
-
#vagrantfile ⇒ Pathname
Get path to actual
Vagrantfile
. -
#writer ⇒ Writer
readonly
protected
Get writer, reponsible of
Vagrantfile
generation.
Instance Method Summary collapse
-
#executable? ⇒ Boolean
Denote
vagrant
executable is present. -
#execute(*args, &block) ⇒ Object
Run the vagrant command with given
args
. -
#install ⇒ self
Install a new Vagrantfile.
- #method_missing(method, *args, &block) ⇒ Object
- #mutable_attributes ⇒ Object
-
#pwd ⇒ Pathname
Get working dir.
-
#remote ⇒ Remote
protected
Get remote shell provider.
- #respond_to_missing?(method, include_private = false) ⇒ Boolean
- #setup ⇒ Object protected
-
#setup_compose ⇒ Object
protected
Initialize most of the tools used internally.
-
#ssh(*args, &block) ⇒ Object
Run a command remotely on box identified by
box_id
.
Constructor Details
This class inherits a constructor from Kamaze::Project::Tools::BaseTool
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args, &block) ⇒ Object
117 118 119 120 121 122 123 |
# File 'lib/kamaze/project/tools/vagrant.rb', line 117 def method_missing(method, *args, &block) if respond_to_missing?(method) composer.public_send(method, *args, &block) else super end end |
Instance Attribute Details
#composer ⇒ Composer (readonly, protected)
Get composer, responsible to read and combine files describing boxes
136 137 138 |
# File 'lib/kamaze/project/tools/vagrant.rb', line 136 def composer @composer end |
#executable ⇒ String|nil
Absolute path to the vagrant executable
55 56 57 |
# File 'lib/kamaze/project/tools/vagrant.rb', line 55 def executable @executable end |
#observer_peers ⇒ Hash|nil (readonly, protected) Originally defined in module Concern::Observable
#path ⇒ String
Path to files describing boxes (directory)
defaults to ./vagrant
67 68 69 |
# File 'lib/kamaze/project/tools/vagrant.rb', line 67 def path @path end |
#shell ⇒ Shell (readonly, protected)
Get a shell, to execute vagrant
commands
141 142 143 |
# File 'lib/kamaze/project/tools/vagrant.rb', line 141 def shell @shell end |
#template ⇒ String
Template file (used for code generation)
50 51 52 |
# File 'lib/kamaze/project/tools/vagrant.rb', line 50 def template @template end |
#vagrantfile ⇒ Pathname
Get path to actual Vagrantfile
60 61 62 |
# File 'lib/kamaze/project/tools/vagrant.rb', line 60 def vagrantfile @vagrantfile end |
#writer ⇒ Writer (readonly, protected)
Get writer, reponsible of Vagrantfile
generation
146 147 148 |
# File 'lib/kamaze/project/tools/vagrant.rb', line 146 def writer @writer end |
Instance Method Details
#executable? ⇒ Boolean
Denote vagrant
executable is present
83 84 85 |
# File 'lib/kamaze/project/tools/vagrant.rb', line 83 def executable? shell.executable? end |
#execute(*args, &block) ⇒ Object
Run the vagrant command with given args
.
90 91 92 |
# File 'lib/kamaze/project/tools/vagrant.rb', line 90 def execute(*args, &block) shell.execute(*args, &block) end |
#install ⇒ self
Install a new Vagrantfile
Vagrant file is installed with additionnal YAML file,
defining boxes
111 112 113 114 115 |
# File 'lib/kamaze/project/tools/vagrant.rb', line 111 def install writer.write(boxes) self end |
#mutable_attributes ⇒ Object
69 70 71 |
# File 'lib/kamaze/project/tools/vagrant.rb', line 69 def mutable_attributes [:path, :executable, :template, :vagrantfile] end |
#pwd ⇒ Pathname
Get working dir
76 77 78 |
# File 'lib/kamaze/project/tools/vagrant.rb', line 76 def pwd Pathname.new(Dir.pwd).realpath end |
#remote ⇒ Remote (protected)
Get remote shell provider
169 170 171 |
# File 'lib/kamaze/project/tools/vagrant.rb', line 169 def remote Remote.new(boxes, executable: executable) end |
#respond_to_missing?(method, include_private = false) ⇒ Boolean
125 126 127 128 129 |
# File 'lib/kamaze/project/tools/vagrant.rb', line 125 def respond_to_missing?(method, include_private = false) return true if composer.respond_to?(method, include_private) super end |
#setup ⇒ Object (protected)
148 149 150 151 152 153 154 155 |
# File 'lib/kamaze/project/tools/vagrant.rb', line 148 def setup @template ||= Pathname.new(__dir__).join('..', 'resources').to_s @vagrantfile ||= ::Pathname.new(@vagrantfile || pwd.join('Vagrantfile')) @executable ||= :vagrant @path ||= pwd.join('vagrant').to_s setup_compose end |
#setup_compose ⇒ Object (protected)
Initialize most of the tools used internally
158 159 160 161 162 163 164 |
# File 'lib/kamaze/project/tools/vagrant.rb', line 158 def setup_compose @composer = Composer.new(@path) @shell = Shell.new(executable: executable) @writer = Writer.new(@template, vagrantfile) self end |
#ssh(*args, &block) ⇒ Object
Run a command remotely on box identified by box_id
Sample of use:
vagrant.ssh('freebsd', 'rake clobber')
101 102 103 |
# File 'lib/kamaze/project/tools/vagrant.rb', line 101 def ssh(*args, &block) remote.execute(*args, &block) end |