vhost 1.1.4 → 1.1.5

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a27db3605a2ab07093455c7ae95a39bc60e38372
4
- data.tar.gz: 4ba7454add6f822ae2f3595c6ac84da9fc8e098d
3
+ metadata.gz: 5e72cf3506c17a59bf1dedfaa3c87ac9a5600de4
4
+ data.tar.gz: b995f164b7b6ac112c0a8f486e305c74b2162899
5
5
  SHA512:
6
- metadata.gz: 573f1531bc2120cd63e7b559d86927e74df8827ea8348b3655b89381c4d712b763ea7adb3d6af4aa0456c1ded0738ff484dc1f71d6a71f5e3a7eacdfac479a82
7
- data.tar.gz: d809941d1581fe2392abc43641fd00122f295e310f1b1c494d20b2063c86c7d2eb2c8e9279cbfb848e37f88e5a7362802f0d43160a65749b27be500efd314ccf
6
+ metadata.gz: b0fd7c18203e0e4355dbbc3c037fa5697452ebe0069d05cada71d4c95ceb363a66b3bb458d79fab3ee8cd690da166b38d1af4c0416b4455f3463d25439ec8cac
7
+ data.tar.gz: 2d612a67504fbadf73754cd08d75a21dcd0d3a649cb56573bdb24559b267c2a3f52c28bc8b7d3c9d7574c62ef71ee371122547b21b688b618fa8b69bbf12cab5
data/bin/vhost CHANGED
@@ -98,7 +98,15 @@ end
98
98
 
99
99
  vhost = Vhost.find(ARGV[0])
100
100
  abort "#{ARGV[0]} doesn't exist" unless vhost
101
- abort "#{vhost.basename} exists" if options.empty? and not ARGV[0].nil?
101
+
102
+ if options.empty? and not ARGV[0].nil?
103
+ # abort "#{vhost.basename} exists"
104
+ puts " Name: #{vhost.name}"
105
+ print "Status: "
106
+ puts vhost.enabled? ? "Enabled".green : "Disabled".red
107
+ puts " Path: #{vhost.path}"
108
+ puts "Folder: #{vhost.folder}"
109
+ end
102
110
 
103
111
  if options[:delete]
104
112
  print "Really delete #{vhost.basename}? [y/n]: "
@@ -140,18 +148,22 @@ if options[:disable]
140
148
  end
141
149
 
142
150
  if options[:list]
143
- puts "Sites available:"
144
- system "ls", File.join(Vhost.conf['server_conf'], 'sites-available')
145
- puts "\nSites enabled:"
146
- system "ls", File.join(Vhost.conf['server_conf'], 'sites-enabled')
151
+ Vhost.all.sort { |v1,v2| v1 <=> v2 }.each do |v|
152
+ puts v.enabled? ? " Enabled: #{File.basename(v.path)}".green : "Disabled: #{File.basename(v.path)}".red
153
+ end
147
154
  end
148
155
 
149
156
  if options[:lista]
150
- system "ls", File.join(Vhost.conf['server_conf'], 'sites-available')
157
+ Vhost.all.each do |v|
158
+ puts v.path
159
+ end
151
160
  end
152
161
 
153
162
  if options[:liste]
154
- system "ls", File.join(Vhost.conf['server_conf'], 'sites-enabled')
163
+ # system "ls", File.join(Vhost.conf['server_conf'], 'sites-enabled')
164
+ Vhost.all.each do |v|
165
+ puts v.path if v.enabled?
166
+ end
155
167
  end
156
168
 
157
169
  if options[:info]
data/lib/vhost.rb CHANGED
@@ -9,7 +9,7 @@ class Vhost
9
9
  require 'erubis'
10
10
  require 'yaml'
11
11
 
12
- VERSION = "1.1.4"
12
+ VERSION = "1.1.5"
13
13
  CONF_NAME = "vhosts.yml"
14
14
  CONFIG_PATHS = [
15
15
  'vhosts-conf',
@@ -76,11 +76,11 @@ class Vhost
76
76
  end
77
77
 
78
78
  def self.available
79
- Dir[File.join(@@available_path, '*')]
79
+ Dir[File.join(@@available_path, '*')].keep_if { |v| File.basename(v) =~ /\A[^\.].*[^\#\~]\Z/ }
80
80
  end
81
81
 
82
82
  def self.enabled
83
- Dir[File.join(@@enabled_path, '*')]
83
+ Dir[File.join(@@enabled_path, '*')].keep_if { |v| File.basename(v) =~ /\A[^\.].*[^\#\~]\Z/ }
84
84
  end
85
85
 
86
86
  def self.all
@@ -133,6 +133,14 @@ class Vhost
133
133
  File.basename(@name, ".conf")
134
134
  end
135
135
 
136
+ def path
137
+ @paths[:available]
138
+ end
139
+
140
+ def folder
141
+ @paths[:folder]
142
+ end
143
+
136
144
  def enabled?
137
145
  File.exist? @paths[:enabled]
138
146
  end
@@ -156,4 +164,11 @@ class Vhost
156
164
  basename
157
165
  end
158
166
 
167
+ def <=> (other)
168
+ return -1 if self.enabled? and not other.enabled?
169
+ return self.name <=> other.name if (self.enabled? and other.enabled?) or (not self.enabled? and not other.enabled?)
170
+ return 1 if not self.enabled? and other.enabled?
171
+ nil
172
+ end
173
+
159
174
  end
@@ -2,10 +2,9 @@
2
2
  <% site_name = vhost %>
3
3
  <% error_log = File.join(conf['sites_folder'], vhost, "log", "apache-error.log") %>
4
4
  <% access_log = File.join(conf['sites_folder'], vhost, "log", "apache-access.log") %>
5
-
6
5
  <VirtualHost *:80>
7
6
  ServerName <%= site_name %>
8
7
  DocumentRoot "<%= site_root %>"
9
8
  ErrorLog "<%= error_log %>"
10
- CustomLog "<%= access_log %>"
9
+ CustomLog "<%= access_log %>" common
11
10
  </VirtualHost>
@@ -2,7 +2,6 @@
2
2
  <% site_name = vhost %>
3
3
  <% error_log = File.join(conf['sites_folder'], vhost, "log", "nginx-error.log") %>
4
4
  <% access_log = File.join(conf['sites_folder'], vhost, "log", "nginx-access.log") %>
5
-
6
5
  server {
7
6
  listen 80;
8
7
 
@@ -16,7 +15,7 @@ server {
16
15
  location / {
17
16
  # include /usr/local/etc/nginx/conf.d/php-fpm; # enable php
18
17
  # passenger_enabled on # enabled passenger for rack based apps
19
- # autoindex on; # just for development
18
+ # autoindex on; # show index of pages
20
19
  }
21
20
 
22
21
  }
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vhost
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.4
4
+ version: 1.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alex Clink
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-02-21 00:00:00.000000000 Z
11
+ date: 2015-03-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: colorize
@@ -57,6 +57,7 @@ metadata: {}
57
57
  post_install_message:
58
58
  rdoc_options: []
59
59
  require_paths:
60
+ - lib
60
61
  - vhosts-conf
61
62
  required_ruby_version: !ruby/object:Gem::Requirement
62
63
  requirements: