Class: VagrantPlugins::Shell::Config
- Inherits:
-
Object
- Object
- VagrantPlugins::Shell::Config
- Defined in:
- lib/vagrant-shell/config.rb
Instance Attribute Summary collapse
-
#image ⇒ String
The ID of the Image to use.
-
#instance_ready_timeout ⇒ Fixnum
The timeout to wait for an instance to become ready.
-
#run_args ⇒ String
The shell script run-instance args.
-
#script ⇒ String
The shell script implementing some tech.
-
#user_data ⇒ String
The user data string.
Instance Method Summary collapse
- #finalize! ⇒ Object
- #find_script(name) ⇒ Object
-
#initialize ⇒ Config
constructor
A new instance of Config.
-
#merge(other) ⇒ Object
——————————————————————- Internal methods.
-
#read_script(pth_script) ⇒ Object
utilities.
- #validate(machine) ⇒ Object
Constructor Details
#initialize ⇒ Config
Returns a new instance of Config.
31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/vagrant-shell/config.rb', line 31 def initialize @image = UNSET_VALUE @instance_ready_timeout = UNSET_VALUE @user_data = UNSET_VALUE @script = UNSET_VALUE @run_args = UNSET_VALUE # Internal state (prefix with __ so they aren't automatically # merged) @__finalized = false end |
Instance Attribute Details
#image ⇒ String
The ID of the Image to use.
9 10 11 |
# File 'lib/vagrant-shell/config.rb', line 9 def image @image end |
#instance_ready_timeout ⇒ Fixnum
The timeout to wait for an instance to become ready.
14 15 16 |
# File 'lib/vagrant-shell/config.rb', line 14 def instance_ready_timeout @instance_ready_timeout end |
#run_args ⇒ String
The shell script run-instance args
29 30 31 |
# File 'lib/vagrant-shell/config.rb', line 29 def run_args @run_args end |
#script ⇒ String
The shell script implementing some tech
24 25 26 |
# File 'lib/vagrant-shell/config.rb', line 24 def script @script end |
#user_data ⇒ String
The user data string
19 20 21 |
# File 'lib/vagrant-shell/config.rb', line 19 def user_data @user_data end |
Instance Method Details
#finalize! ⇒ Object
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 |
# File 'lib/vagrant-shell/config.rb', line 52 def finalize! # Image must be nil, since we can't default that @image = nil if @image == UNSET_VALUE # Set the default timeout for waiting for an instance to be ready @instance_ready_timeout = 120 if @instance_ready_timeout == UNSET_VALUE # User Data is nil by default @user_data = nil if @user_data == UNSET_VALUE # No default shell script @script = nil if @script == UNSET_VALUE # No rub args by default @run_args = [] if @run_args == UNSET_VALUE # Mark that we finalized @__finalized = true end |
#find_script(name) ⇒ Object
81 82 83 84 85 86 87 88 89 90 91 |
# File 'lib/vagrant-shell/config.rb', line 81 def find_script name try_path = ENV['PATH'].split(/:/).flatten.inject([]) { |acc, p| x = File.join(p,"shell-#{name.to_s}"); File.exists?(x) && acc << x; acc }.first if try_path return try_path end try_load = $:.inject([]) { |acc, p| x = File.("../libexec/shell-#{name.to_s}", p); File.exists?(x) && acc << x; acc }.first if try_load return try_load end end |
#merge(other) ⇒ Object
Internal methods.
47 48 49 50 |
# File 'lib/vagrant-shell/config.rb', line 47 def merge(other) super.tap do |result| end end |
#read_script(pth_script) ⇒ Object
utilities
77 78 79 |
# File 'lib/vagrant-shell/config.rb', line 77 def read_script pth_script File.read(pth_script).split(/[ \t]*[\r\n]+/).join("; ") end |
#validate(machine) ⇒ Object
72 73 74 |
# File 'lib/vagrant-shell/config.rb', line 72 def validate(machine) { "Shell Provider" => [ ] } end |