Sha256: 681593c7e9b07eb22948ecd98675d684bc4702595ead6b956f36077e63a429b0

Contents?: true

Size: 1.02 KB

Versions: 33

Compression:

Stored size: 1.02 KB

Contents

class VagrantWrapper
  class << self
    def hosts
      @vm_hosts ||= begin
        result = {}

        boxes = boxes_list

        unless running?
          boxes.map! do |box|
            box['user'] = ENV['USER']
            box['port'] = '22'
            box
          end
        end

        boxes.each do |vm|
          result[vm['name']] = vm_host(vm)
        end

        result
      end
    end

    def running?
      @running ||= begin
        status = `#{vagrant_binary} status`
        status.include?('running')
      end
    end

    def boxes_list
      json_config_path = File.join('test', 'boxes.json')
      boxes = File.open(json_config_path).read
      JSON.parse(boxes)
    end

    def vagrant_binary
      'vagrant'
    end

    private

    def vm_host(vm)
      host_options = {
          user: vm['user'] || 'vagrant',
          hostname: vm['hostname'] || 'localhost',
          port: vm['port'] || '22',
          password: vm['password'] || 'vagrant'
      }

      SSHKit::Host.new(host_options)
    end
  end
end

Version data entries

33 entries across 31 versions & 3 rubygems

Version Path
honeybadger-4.5.3 vendor/bundle/ruby/2.6.0/gems/sshkit-1.18.2/test/support/vagrant_wrapper.rb
sshkit-1.18.2 test/support/vagrant_wrapper.rb
sshkit-1.18.1 test/support/vagrant_wrapper.rb
sshkit-1.18.0 test/support/vagrant_wrapper.rb
sshkit-1.17.0 test/support/vagrant_wrapper.rb
sshkit-1.16.1 test/support/vagrant_wrapper.rb
sshkit-1.16.0 test/support/vagrant_wrapper.rb
sshkit-1.15.1 test/support/vagrant_wrapper.rb
sshkit-1.15.0 test/support/vagrant_wrapper.rb
sshkit-1.14.0 test/support/vagrant_wrapper.rb
sshkit-1.13.1 test/support/vagrant_wrapper.rb
sshkit-1.13.0 test/support/vagrant_wrapper.rb
sshkit-1.12.0 test/support/vagrant_wrapper.rb
sshkit-1.11.5 test/support/vagrant_wrapper.rb
sshkit-1.11.4 test/support/vagrant_wrapper.rb
sshkit-1.11.3 test/support/vagrant_wrapper.rb
sshkit-1.11.2 test/support/vagrant_wrapper.rb
sshkit-1.11.1 test/support/vagrant_wrapper.rb
sshkit-1.11.0 test/support/vagrant_wrapper.rb
sshkit-1.10.0 test/support/vagrant_wrapper.rb