Class: VagrantPlugins::Fabric::Config
- Inherits:
-
Object
- Object
- VagrantPlugins::Fabric::Config
- Defined in:
- lib/vagrant-fabric/config.rb
Instance Attribute Summary collapse
-
#fabfile_path ⇒ Object
Returns the value of attribute fabfile_path.
-
#fabric_path ⇒ Object
Returns the value of attribute fabric_path.
-
#python_path ⇒ Object
Returns the value of attribute python_path.
-
#tasks ⇒ Object
Returns the value of attribute tasks.
Instance Method Summary collapse
- #execute(command) ⇒ Object
- #finalize! ⇒ Object
-
#initialize ⇒ Config
constructor
A new instance of Config.
- #validate(env) ⇒ Object
Constructor Details
#initialize ⇒ Config
Returns a new instance of Config.
9 10 11 12 13 14 |
# File 'lib/vagrant-fabric/config.rb', line 9 def initialize @fabfile_path = UNSET_VALUE @fabric_path = UNSET_VALUE @python_path = UNSET_VALUE @tasks = UNSET_VALUE end |
Instance Attribute Details
#fabfile_path ⇒ Object
Returns the value of attribute fabfile_path.
4 5 6 |
# File 'lib/vagrant-fabric/config.rb', line 4 def fabfile_path @fabfile_path end |
#fabric_path ⇒ Object
Returns the value of attribute fabric_path.
5 6 7 |
# File 'lib/vagrant-fabric/config.rb', line 5 def fabric_path @fabric_path end |
#python_path ⇒ Object
Returns the value of attribute python_path.
6 7 8 |
# File 'lib/vagrant-fabric/config.rb', line 6 def python_path @python_path end |
#tasks ⇒ Object
Returns the value of attribute tasks.
7 8 9 |
# File 'lib/vagrant-fabric/config.rb', line 7 def tasks @tasks end |
Instance Method Details
#execute(command) ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/vagrant-fabric/config.rb', line 23 def execute(command) output = '' begin IO.popen(command, "w+") do |f| f.close_write output = f.read end output rescue Errno::ENOENT false end end |
#finalize! ⇒ Object
16 17 18 19 20 21 |
# File 'lib/vagrant-fabric/config.rb', line 16 def finalize! @fabfile_path = "fabfile.py" if @fabfile_path == UNSET_VALUE @fabric_path = "fab" if @fabric_path == UNSET_VALUE @python_path = "python" if @python_path == UNSET_VALUE @tasks = [] if @tasks == UNSET_VALUE end |
#validate(env) ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/vagrant-fabric/config.rb', line 36 def validate(env) errors = _detected_errors errors << "fabfile does not exist." if not File.exist?(fabfile_path) command = "#{fabric_path} -V" output = execute(command) errors << "fabric command does not exist." if not output command = "#{fabric_path} -f #{fabfile_path} -l" output = execute(command) errors << "#{fabfile_path} could not recognize by fabric." if not $?.success? for task in tasks task = task.split(':').first command = "#{fabric_path} -f #{fabfile_path} -d #{task}" output = execute(command) errors << "#{task} task does not exist." if not $?.success? end { "fabric provisioner" => errors } end |