Class: Vagrant::Pyinfra::Config

Inherits:
Object
  • Object
show all
Defined in:
lib/vagrant-pyinfra/config.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfig

Returns a new instance of Config.



6
7
8
# File 'lib/vagrant-pyinfra/config.rb', line 6

def initialize
    @deploy_file = UNSET_VALUE
end

Instance Attribute Details

#deploy_fileObject

Returns the value of attribute deploy_file.



4
5
6
# File 'lib/vagrant-pyinfra/config.rb', line 4

def deploy_file
  @deploy_file
end

Instance Method Details

#execute(command) ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/vagrant-pyinfra/config.rb', line 14

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



10
11
12
# File 'lib/vagrant-pyinfra/config.rb', line 10

def finalize!
    @deploy_file = 'deploy.py' if @deploy_file == UNSET_VALUE
end

#validate(env) ⇒ Object



27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/vagrant-pyinfra/config.rb', line 27

def validate(env)
    errors = _detected_errors

    if not File.exist?(deploy_file) then
        errors << "#{deploy_file} does not exist."
    end

    command = 'pyinfra --version'
    output = execute(command)
    if not output then
        errors << 'pyinfra command does not exist.'
    end

    {'pyinfra provisioner' => errors}
end