Class: VagrantPlugins::Unison::Config

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(region_specific = false) ⇒ Config

Returns a new instance of Config.



58
59
60
61
62
63
64
65
66
67
68
69
# File 'lib/vagrant-unison2/config.rb', line 58

def initialize(region_specific = false)
  @host_folder   = UNSET_VALUE
  @guest_folder  = UNSET_VALUE
  @ignore        = UNSET_VALUE
  @repeat        = UNSET_VALUE
  @ssh_host      = UNSET_VALUE
  @ssh_port      = UNSET_VALUE
  @ssh_user      = UNSET_VALUE
  @ssh_use_agent = UNSET_VALUE
  @mem_cap_mb    = UNSET_VALUE
  @perms         = UNSET_VALUE
end

Instance Attribute Details

#guest_folderString

Guest Folder to Sync.

Returns:

  • (String)


14
15
16
# File 'lib/vagrant-unison2/config.rb', line 14

def guest_folder
  @guest_folder
end

#host_folderString

Host Folder to Sync

Returns:

  • (String)


9
10
11
# File 'lib/vagrant-unison2/config.rb', line 9

def host_folder
  @host_folder
end

#ignoreString+

Pattern of files to ignore.

Returns:

  • (String, Array<String>)


19
20
21
# File 'lib/vagrant-unison2/config.rb', line 19

def ignore
  @ignore
end

#mem_cap_mbint

Memory usage cap in MB Restart Unison in the VM when it’s consuming more than this amount of memory (in MB)

Returns:

  • (int)


45
46
47
# File 'lib/vagrant-unison2/config.rb', line 45

def mem_cap_mb
  @mem_cap_mb
end

#permsint

perms arg value

Returns:

  • (int)


50
51
52
# File 'lib/vagrant-unison2/config.rb', line 50

def perms
  @perms
end

#repeatString

Repeat speed.

Returns:

  • (String)


24
25
26
# File 'lib/vagrant-unison2/config.rb', line 24

def repeat
  @repeat
end

#ssh_hostString

SSH host.

Returns:

  • (String)


29
30
31
# File 'lib/vagrant-unison2/config.rb', line 29

def ssh_host
  @ssh_host
end

#ssh_portString

SSH port.

Returns:

  • (String)


34
35
36
# File 'lib/vagrant-unison2/config.rb', line 34

def ssh_port
  @ssh_port
end

#ssh_use_agentBoolean

Airlab-specific config option to leave off the Vagrant identity file, so SSH will just use ssh-agent

Returns:

  • (Boolean)


56
57
58
# File 'lib/vagrant-unison2/config.rb', line 56

def ssh_use_agent
  @ssh_use_agent
end

#ssh_userString

SSH user.

Returns:

  • (String)


39
40
41
# File 'lib/vagrant-unison2/config.rb', line 39

def ssh_user
  @ssh_user
end

Instance Method Details

#finalize!Object



71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
# File 'lib/vagrant-unison2/config.rb', line 71

def finalize!
  # The access keys default to nil
  @host_folder  = nil         if @host_folder  == UNSET_VALUE
  @guest_folder = nil         if @guest_folder == UNSET_VALUE
  @ignore       = nil         if @ignore       == UNSET_VALUE
  @repeat       = 1           if @repeat       == UNSET_VALUE
  @ssh_host     = '127.0.0.1' if @ssh_host     == UNSET_VALUE
  @ssh_port     = 2222        if @ssh_port     == UNSET_VALUE
  @ssh_user     = 'vagrant'   if @ssh_user     == UNSET_VALUE
  @mem_cap_mb   = 200         if @mem_cap_mb   == UNSET_VALUE
  @perms        = nil         if @perms        == UNSET_VALUE
  @ssh_use_agent = false      if @ssh_use_agent == UNSET_VALUE

  # Mark that we finalized
  @__finalized = true
end

#validate(machine) ⇒ Object



88
89
90
91
92
93
94
95
96
97
# File 'lib/vagrant-unison2/config.rb', line 88

def validate(machine)
  errors = []

  if !(@host_folder.nil? && @guest_folder.nil?)
    errors << I18n.t("vagrant_unison.config.unison_host_folder_required") if @host_folder.nil?
    errors << I18n.t("vagrant_unison.config.unison_guest_folder_required") if @guest_folder.nil?
  end

  { "Unison" => errors }
end