bonethug 0.0.81 → 0.0.82

Sign up to get free protection for your applications and to get access to all the features.
data/lib/bonethug/cli.rb CHANGED
@@ -139,9 +139,22 @@ module Bonethug
139
139
  else # apache
140
140
 
141
141
  # install the vhost
142
- exec "echo \"#{vh}\" > #{conf_path}/#{vhost}.conf"
142
+ system "echo \"#{vh}\" > #{conf_path}/#{vhost}.conf"
143
143
 
144
- end
144
+ end
145
+
146
+ # handle hosts file update
147
+ path = RbConfig::CONFIG['target_os'] =~ /mswin|mingw|cygwin/i ? '/c/Windows/System32/drivers/etc/hosts' : '/etc/hosts'
148
+ hosts = "
149
+ ## BONETHUG-#{vhost} ##
150
+ #{Configurator.hosts vh_cnf}
151
+ ## END_BONETHUG-#{vhost} ##
152
+ "
153
+
154
+ # write the to the hosts file
155
+ system "sed -i '/## BONETHUG-#{vhost} ##/,/## END_BONETHUG-#{vhost} ##/ s/.*//g' #{path}"
156
+ escaped = (hosts).gsub(/"/, '\"')
157
+ system "echo \"#{escaped}\" >> #{path}"
145
158
 
146
159
  when 'init', 'update'
147
160
 
@@ -14,6 +14,17 @@ module Bonethug
14
14
  include FileUtils
15
15
  include Digest
16
16
 
17
+ def self.hosts(vh_cnf)
18
+ hosts = "127.0.0.1 #{vh_cnf.get('server_name')}\n"
19
+ aliases = vh_cnf.get('server_aliases')
20
+ if aliases
21
+ aliases.each do |index, server_alias|
22
+ hosts += "127.0.0.1 #{server_alias}\n"
23
+ end
24
+ end
25
+ hosts
26
+ end
27
+
17
28
  def self.vhost(vh_cnf, base_path, is_remote = false)
18
29
 
19
30
  # server aliases
@@ -1,6 +1,6 @@
1
1
 
2
2
  module Bonethug
3
- VERSION = "0.0.81"
4
- BUILD_DATE = "2014-06-02 10:38:16 +1200"
3
+ VERSION = "0.0.82"
4
+ BUILD_DATE = "2014-06-02 12:27:14 +1200"
5
5
  end
6
6
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bonethug
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.81
4
+ version: 0.0.82
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-06-01 00:00:00.000000000 Z
12
+ date: 2014-06-02 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler