Class: Pave::VirtualHost
- Inherits:
-
Object
show all
- Includes:
- Shell
- Defined in:
- lib/pave/virtual_host.rb
Constant Summary
collapse
- VHOST_CONF_FILE =
"/etc/apache2/extra/httpd-vhosts.conf".freeze
- VHOST_CONF_FILE_BACKUP =
"#{VHOST_CONF_FILE}.backup".freeze
- HOSTS_FILE =
"/etc/hosts".freeze
- HOSTS_FILE_BACKUP =
"#{HOSTS_FILE}.backup".freeze
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Methods included from Shell
#file_insert, included, #sh, #shell
Constructor Details
#initialize(host, dir) ⇒ VirtualHost
Returns a new instance of VirtualHost.
14
15
16
17
|
# File 'lib/pave/virtual_host.rb', line 14
def initialize(host, dir)
@hostname = host
@directory = dir
end
|
Instance Attribute Details
#directory ⇒ Object
Returns the value of attribute directory.
7
8
9
|
# File 'lib/pave/virtual_host.rb', line 7
def directory
@directory
end
|
#hostname ⇒ Object
Returns the value of attribute hostname.
7
8
9
|
# File 'lib/pave/virtual_host.rb', line 7
def hostname
@hostname
end
|
Class Method Details
.restart_apache ⇒ Object
19
20
21
22
23
|
# File 'lib/pave/virtual_host.rb', line 19
def self.restart_apache
`sudo apachectl restart`
say "Apache restarted."
true
end
|
Instance Method Details
#create_vhost ⇒ Object
47
48
49
50
51
52
|
# File 'lib/pave/virtual_host.rb', line 47
def create_vhost
return say "No virtual host backup found. Run `pave vh:backup` before adding a virtual host." unless check_backup
return say "No host name provided. Run `pave help` for more details." unless hostname.size > 0
add_vhost_to_conf && add_hosts_entry && self.class.restart_apache && say("Created virtual host for #{hostname}.")
end
|
#remove_vhost ⇒ Object
54
55
56
57
58
|
# File 'lib/pave/virtual_host.rb', line 54
def remove_vhost
return say "No virtual host backup found. Run `pave vh:backup` before adding a virtual host." unless check_backup
remove_vhost_from_conf && remove_hosts_entry && self.class.restart_apache && say("Removed virtual host for #{hostname}.")
end
|