Class: ProvisionVagrant::PvInitializer
- Inherits:
-
Object
- Object
- ProvisionVagrant::PvInitializer
- Defined in:
- lib/pv_initializer.rb
Instance Method Summary collapse
- #copy_interpolated_post_hook ⇒ Object
- #copy_post_hook_script(interpolated) ⇒ Object
- #copy_provision_vagrant_config ⇒ Object
- #copy_vagrantfile_template ⇒ Object
- #init ⇒ Object
-
#initialize(opts = {}) ⇒ PvInitializer
constructor
A new instance of PvInitializer.
- #user_directory ⇒ Object
Constructor Details
#initialize(opts = {}) ⇒ PvInitializer
Returns a new instance of PvInitializer.
7 8 9 10 |
# File 'lib/pv_initializer.rb', line 7 def initialize(opts = {}) @opts = opts @opts.merge!(read_default_config_opts) end |
Instance Method Details
#copy_interpolated_post_hook ⇒ Object
42 43 44 45 46 47 |
# File 'lib/pv_initializer.rb', line 42 def copy_interpolated_post_hook complete_opts = opts.merge(fetch_github_vars) interpolator = Interpolator.new( { vars: complete_opts, input: post_hook_source_string }) interpolated = interpolator.interpolate copy_post_hook_script(interpolated) end |
#copy_post_hook_script(interpolated) ⇒ Object
49 50 51 52 |
# File 'lib/pv_initializer.rb', line 49 def copy_post_hook_script(interpolated) puts "Copying example post hook bash script to: #{target_post_hook_path}" ProvisionVagrant.write_string_to_File(interpolated, target_post_hook_path) end |
#copy_provision_vagrant_config ⇒ Object
54 55 56 57 |
# File 'lib/pv_initializer.rb', line 54 def copy_provision_vagrant_config puts "Copying provision-vagrant config yml file to: #{target_provision_vagrant_config_path}" FileUtils.cp(source_provision_vagrant_config_path, target_provision_vagrant_config_path) end |
#copy_vagrantfile_template ⇒ Object
37 38 39 40 |
# File 'lib/pv_initializer.rb', line 37 def copy_vagrantfile_template puts "Copying example Vagrantfile template to: #{target_vagrantfile_path}" FileUtils.cp(source_vagrantfile_path, target_vagrantfile_path) end |
#init ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/pv_initializer.rb', line 12 def init puts "\nUsing home directory: #{user_directory}" if !opts[:force] && (File.exist?(target_vagrantfile_path) || File.exist?(target_post_hook_path)) help("Aborting. One of the target output files already exists: #{target_file_list}") exit(false) end copy_vagrantfile_template copy_interpolated_post_hook copy_provision_vagrant_config if File.exist?(target_vagrantfile_path) && File.exist?(target_post_hook_path) && File.exist?(target_provision_vagrant_config_path) puts "\nSuccess! You should now be ready to use provision-vagrant. Usage:\n\n" puts " provision-vagrant new-box-name\n\n" exit(1) else msg = "Error: There was a probelm initializing provision-vagrant. One of the following files did not get created: #{target_file_list}" help(msg) exit(0) end end |
#user_directory ⇒ Object
59 60 61 |
# File 'lib/pv_initializer.rb', line 59 def user_directory @_user_directory ||= set_userdir end |