Class: VagrantSpec::Command::Init
- Inherits:
-
Object
- Object
- VagrantSpec::Command::Init
- Includes:
- Utils
- Defined in:
- lib/vagrant_spec/command/init.rb
Overview
This command instantiates serveral files for deployment and testing
argv env [Vagrant::Environment]
Constant Summary collapse
- DEFAULTS =
VagrantSpec::Config::DEFAULTS
Instance Attribute Summary collapse
-
#ansible_inventory ⇒ Object
Returns the value of attribute ansible_inventory.
-
#config ⇒ Object
Returns the value of attribute config.
-
#directory ⇒ Object
Returns the value of attribute directory.
Instance Method Summary collapse
- #execute ⇒ Object
-
#initialize(argv, env) ⇒ Init
constructor
A new instance of Init.
- #parse_opts ⇒ Object
Methods included from Utils
#lib_root, #project_root, #template_dir
Constructor Details
#initialize(argv, env) ⇒ Init
19 20 21 22 23 24 |
# File 'lib/vagrant_spec/command/init.rb', line 19 def initialize(argv, env) super @config = VagrantSpec::Config.load env @directory = @config.spec.directory @ansible_inventory = @config.spec.ansible_inventory end |
Instance Attribute Details
#ansible_inventory ⇒ Object
Returns the value of attribute ansible_inventory.
18 19 20 |
# File 'lib/vagrant_spec/command/init.rb', line 18 def ansible_inventory @ansible_inventory end |
#config ⇒ Object
Returns the value of attribute config.
18 19 20 |
# File 'lib/vagrant_spec/command/init.rb', line 18 def config @config end |
#directory ⇒ Object
Returns the value of attribute directory.
18 19 20 |
# File 'lib/vagrant_spec/command/init.rb', line 18 def directory @directory end |
Instance Method Details
#execute ⇒ Object
26 27 28 29 30 31 32 |
# File 'lib/vagrant_spec/command/init.rb', line 26 def execute return unless parse_opts VagrantSpec::SpecHelper.new(@env).generate unless @ansible_inventory == DEFAULTS['ansible_inventory'] VagrantSpec::AnsibleInventory.new(@env).generate end end |
#parse_opts ⇒ Object
34 35 36 37 38 39 40 41 42 |
# File 'lib/vagrant_spec/command/init.rb', line 34 def parse_opts opts = OptionParser.new do |o| o. = "\nCreates the serverspec/spec_helper.rb file for testing" o.separator '' o.separator 'Usage: vagrant spec init' o.separator '' end (opts) end |