vh 0.0.1 → 0.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. data/lib/vh/version.rb +1 -1
  2. metadata +1 -2
  3. data/vh.rb +0 -83
@@ -1,3 +1,3 @@
1
1
  module Vh
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vh
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -48,7 +48,6 @@ files:
48
48
  - lib/vh/hosts_config.rb
49
49
  - lib/vh/version.rb
50
50
  - vh.gemspec
51
- - vh.rb
52
51
  homepage: https://ncuesta.github.com/vh
53
52
  licenses: []
54
53
  post_install_message:
data/vh.rb DELETED
@@ -1,83 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- ##
4
- # vh.rb
5
- # Add virtual hosts to the apache configuration and the hosts file.
6
- #
7
- # Copyright (c) 2012 José Nahuel Cuesta Luengo
8
- ##
9
-
10
- require 'pathname'
11
-
12
- # Validate required arguments
13
- if ARGV.length < 2
14
- puts 'Missing arguments.'
15
- puts 'Usage:'
16
- puts ' vh.rb path hostname'
17
- exit 1
18
- end
19
-
20
- path = Pathname.new(ARGV[0]).realpath
21
- server_name = ARGV[1]
22
-
23
- # Check the validity of path
24
- if not File.directory? path
25
- puts "'#{path}' is not a valid path. Please correct that and try again."
26
- exit 2
27
- end
28
-
29
- # Check if the server is not already defined
30
- vhosts_path = '/etc/apache2/extra/httpd-vhosts.conf'
31
- add = true
32
- open vhosts_path do | f |
33
- if f.grep(/ServerName\s+"#{server_name}"/i).length > 0
34
- puts "There already exists a server named '#{server_name}' in the virtual hosts file. Skipping..."
35
- add = false
36
- end
37
- end
38
-
39
- # Append the vhost to the vhosts file
40
- if add
41
- puts 'Adding virtual host to the virtual hosts file...'
42
- open vhosts_path, 'a+' do | f |
43
- f.puts <<-VHOST
44
-
45
- # vh - #{server_name}
46
- <Directory "#{path}">
47
- Allow From All
48
- AllowOverride All
49
- </Directory>
50
- <VirtualHost *:80>
51
- ServerName "#{server_name}"
52
- DocumentRoot "#{path}"
53
- </VirtualHost>
54
- # /vh - #{server_name}
55
- VHOST
56
- end
57
- puts 'Done'
58
- end
59
-
60
- # Append the new host to the hosts file
61
- hosts_path = '/etc/hosts'
62
- add = true
63
- open hosts_path do | f |
64
- if f.grep(/\W#{server_name}\W/i).length > 0
65
- puts "There is already a host named '#{server_name}'. Skipping..."
66
- add = false
67
- end
68
- end
69
-
70
- if add
71
- puts 'Adding host alias to hosts file...'
72
- open hosts_path, 'a+' do | f |
73
- f.puts <<-HOST
74
- 127.0.0.1 #{server_name} # vh
75
- HOST
76
- end
77
- puts 'Done'
78
- end
79
-
80
- # Restart apache
81
- puts 'Restarting apache...'
82
- system 'apachectl restart'
83
- puts 'Done'