landlord 0.1.0
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.
- data/.document +5 -0
- data/Gemfile +8 -0
- data/LICENSE.txt +20 -0
- data/README.rdoc +14 -0
- data/Rakefile +29 -0
- data/VERSION +1 -0
- data/bin/landlord +84 -0
- data/landlord.gemspec +65 -0
- data/lib/landlord.rb +28 -0
- data/lib/landlord/config.rb +33 -0
- data/lib/landlord/virtual_host.rb +169 -0
- data/templates/virtual_host.apache.conf +21 -0
- data/test/expected_results/example_virtual_host.conf +9 -0
- data/test/expected_results/example_virtual_host_with_aliases.conf +10 -0
- data/test/expected_results/example_virtual_host_with_redirects.conf +23 -0
- data/test/helper.rb +28 -0
- data/test/test_landlord.rb +10 -0
- data/test/test_landlord_config.rb +9 -0
- data/test/test_landlord_virtual_host.rb +38 -0
- metadata +101 -0
data/.document
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2012 Scott Tadman
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.rdoc
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
= landlord
|
2
|
+
|
3
|
+
Landlord is a tool for managing tenant applications.
|
4
|
+
|
5
|
+
Examples:
|
6
|
+
|
7
|
+
landlord add example.com --redirect=www.example.com
|
8
|
+
landlord list
|
9
|
+
landlord show example.com
|
10
|
+
|
11
|
+
== Copyright
|
12
|
+
|
13
|
+
Copyright (c) 2012 Scott Tadman, The Working Group Inc. See LICENSE.txt for
|
14
|
+
further details.
|
data/Rakefile
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'rubygems'
|
4
|
+
require 'bundler'
|
5
|
+
|
6
|
+
begin
|
7
|
+
Bundler.setup(:default, :development)
|
8
|
+
rescue Bundler::BundlerError => e
|
9
|
+
$stderr.puts e.message
|
10
|
+
$stderr.puts "Run `bundle install` to install missing gems"
|
11
|
+
exit e.status_code
|
12
|
+
end
|
13
|
+
|
14
|
+
require 'rake'
|
15
|
+
require 'jeweler'
|
16
|
+
|
17
|
+
Jeweler::Tasks.new do |gem|
|
18
|
+
# gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
|
19
|
+
gem.name = "landlord"
|
20
|
+
gem.homepage = "http://github.com/twg/landlord"
|
21
|
+
gem.license = "MIT"
|
22
|
+
gem.summary = %Q{Web server virtual-host tenant management tool}
|
23
|
+
gem.description = %Q{A command-line tool for managing multiple virtual-host configurations on a web server}
|
24
|
+
gem.email = "github@tadman.ca"
|
25
|
+
gem.authors = ["Scott Tadman"]
|
26
|
+
# dependencies defined in Gemfile
|
27
|
+
end
|
28
|
+
|
29
|
+
Jeweler::RubygemsDotOrgTasks.new
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.1.0
|
data/bin/landlord
ADDED
@@ -0,0 +1,84 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'optparse'
|
4
|
+
|
5
|
+
$LOAD_PATH << File.expand_path(File.join('..', 'lib'), File.dirname(__FILE__))
|
6
|
+
|
7
|
+
require 'landlord'
|
8
|
+
|
9
|
+
def show_version
|
10
|
+
puts "landlord #{Landlord::VERSION}"
|
11
|
+
end
|
12
|
+
|
13
|
+
# == Main ===================================================================
|
14
|
+
|
15
|
+
action = nil
|
16
|
+
|
17
|
+
options = {
|
18
|
+
:redirects => [ ],
|
19
|
+
:aliases => [ ]
|
20
|
+
}
|
21
|
+
|
22
|
+
OptionParser.new do |parser|
|
23
|
+
parser.banner = "Usage: landlord [options] command hostname [hostname [...]]"
|
24
|
+
|
25
|
+
parser.separator ""
|
26
|
+
parser.separator "Specific commands:"
|
27
|
+
|
28
|
+
parser.separator " %-32s %s" % [ 'add', 'Add a virtual host and configuration file' ]
|
29
|
+
parser.separator " %-32s %s" % [ 'remove', 'Remove a virtual host configuration file' ]
|
30
|
+
parser.separator " %-32s %s" % [ 'enable', 'Enable a virtual host configuration file' ]
|
31
|
+
parser.separator " %-32s %s" % [ 'disable', 'Disable a virtual host configuration file' ]
|
32
|
+
|
33
|
+
parser.separator ""
|
34
|
+
parser.separator "Specific options:"
|
35
|
+
|
36
|
+
parser.on('-a', '--alias=s', 'Create an alias for this virtual host') do |s|
|
37
|
+
options[:aliases] << s
|
38
|
+
end
|
39
|
+
parser.on('-r', '--redirect=s', 'Create a redirect for this virtual host') do |s|
|
40
|
+
options[:redirects] << s
|
41
|
+
end
|
42
|
+
parser.on('-f', '--config=s', 'Specify an alternate configuration file') do |s|
|
43
|
+
options[:config] = s
|
44
|
+
end
|
45
|
+
parser.on('--verbose', 'Verbose mode') do
|
46
|
+
options[:verbose] = true
|
47
|
+
end
|
48
|
+
parser.on('-v', '--version', 'Display version number') do
|
49
|
+
show_version
|
50
|
+
exit(0)
|
51
|
+
end
|
52
|
+
parser.on('-h', '--help', 'Show this help') do
|
53
|
+
puts parser
|
54
|
+
exit(0)
|
55
|
+
end
|
56
|
+
end.parse!.each do |arg|
|
57
|
+
case (arg)
|
58
|
+
when /\./
|
59
|
+
virtual_host = Landlord::VirtualHost.new(arg)
|
60
|
+
|
61
|
+
if (action)
|
62
|
+
virtual_host.send(:"#{action}!")
|
63
|
+
else
|
64
|
+
puts "landlord: No command specified"
|
65
|
+
exit(-1)
|
66
|
+
end
|
67
|
+
when 'list'
|
68
|
+
Landlord::VirtualHost.each do |config|
|
69
|
+
puts config[:server_name]
|
70
|
+
if (aliases = config[:aliases])
|
71
|
+
aliases.each do |as_alias|
|
72
|
+
puts "\t+ #{as_alias} (Alias)"
|
73
|
+
end
|
74
|
+
end
|
75
|
+
if (redirects = config[:redirects])
|
76
|
+
redirects.each do |as_redirect|
|
77
|
+
puts "\t+ #{as_redirect} (Redirect)"
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
81
|
+
when 'add', 'remove', 'enable', 'disable'
|
82
|
+
action = arg.to_sym
|
83
|
+
end
|
84
|
+
end
|
data/landlord.gemspec
ADDED
@@ -0,0 +1,65 @@
|
|
1
|
+
# Generated by jeweler
|
2
|
+
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
|
+
# -*- encoding: utf-8 -*-
|
5
|
+
|
6
|
+
Gem::Specification.new do |s|
|
7
|
+
s.name = "landlord"
|
8
|
+
s.version = "0.1.0"
|
9
|
+
|
10
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
+
s.authors = ["Scott Tadman"]
|
12
|
+
s.date = "2012-01-27"
|
13
|
+
s.description = "A command-line tool for managing multiple virtual-host configurations on a web server"
|
14
|
+
s.email = "github@tadman.ca"
|
15
|
+
s.executables = ["landlord"]
|
16
|
+
s.extra_rdoc_files = [
|
17
|
+
"LICENSE.txt",
|
18
|
+
"README.rdoc"
|
19
|
+
]
|
20
|
+
s.files = [
|
21
|
+
".document",
|
22
|
+
"Gemfile",
|
23
|
+
"LICENSE.txt",
|
24
|
+
"README.rdoc",
|
25
|
+
"Rakefile",
|
26
|
+
"VERSION",
|
27
|
+
"bin/landlord",
|
28
|
+
"landlord.gemspec",
|
29
|
+
"lib/landlord.rb",
|
30
|
+
"lib/landlord/config.rb",
|
31
|
+
"lib/landlord/virtual_host.rb",
|
32
|
+
"templates/virtual_host.apache.conf",
|
33
|
+
"test/expected_results/example_virtual_host.conf",
|
34
|
+
"test/expected_results/example_virtual_host_with_aliases.conf",
|
35
|
+
"test/expected_results/example_virtual_host_with_redirects.conf",
|
36
|
+
"test/helper.rb",
|
37
|
+
"test/test_landlord.rb",
|
38
|
+
"test/test_landlord_config.rb",
|
39
|
+
"test/test_landlord_virtual_host.rb"
|
40
|
+
]
|
41
|
+
s.homepage = "http://github.com/twg/landlord"
|
42
|
+
s.licenses = ["MIT"]
|
43
|
+
s.require_paths = ["lib"]
|
44
|
+
s.rubygems_version = "1.8.11"
|
45
|
+
s.summary = "Web server virtual-host tenant management tool"
|
46
|
+
|
47
|
+
if s.respond_to? :specification_version then
|
48
|
+
s.specification_version = 3
|
49
|
+
|
50
|
+
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
51
|
+
s.add_runtime_dependency(%q<handlebar>, [">= 0"])
|
52
|
+
s.add_development_dependency(%q<bundler>, [">= 0"])
|
53
|
+
s.add_development_dependency(%q<jeweler>, [">= 0"])
|
54
|
+
else
|
55
|
+
s.add_dependency(%q<handlebar>, [">= 0"])
|
56
|
+
s.add_dependency(%q<bundler>, [">= 0"])
|
57
|
+
s.add_dependency(%q<jeweler>, [">= 0"])
|
58
|
+
end
|
59
|
+
else
|
60
|
+
s.add_dependency(%q<handlebar>, [">= 0"])
|
61
|
+
s.add_dependency(%q<bundler>, [">= 0"])
|
62
|
+
s.add_dependency(%q<jeweler>, [">= 0"])
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
data/lib/landlord.rb
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
require 'yaml'
|
2
|
+
|
3
|
+
module Landlord
|
4
|
+
# == Constants ============================================================
|
5
|
+
|
6
|
+
VERSION = File.read(File.expand_path(File.join('..', 'VERSION'), File.dirname(__FILE__))).chomp.freeze
|
7
|
+
|
8
|
+
DEFAULT_CONFIG_PATH = '/etc/landlord.conf'.freeze
|
9
|
+
|
10
|
+
# == Submodules ===========================================================
|
11
|
+
|
12
|
+
autoload(:Config, 'landlord/config')
|
13
|
+
autoload(:VirtualHost, 'landlord/virtual_host')
|
14
|
+
|
15
|
+
# == Module Methods =======================================================
|
16
|
+
|
17
|
+
def self.config_path=(path)
|
18
|
+
@config_path = path
|
19
|
+
end
|
20
|
+
|
21
|
+
def self.config_path
|
22
|
+
@config_path || DEFAULT_CONFIG_PATH
|
23
|
+
end
|
24
|
+
|
25
|
+
def self.config
|
26
|
+
@config ||= Config.new(self.config_path)
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
require 'ostruct'
|
2
|
+
|
3
|
+
class Landlord::Config < OpenStruct
|
4
|
+
# == Constants ============================================================
|
5
|
+
|
6
|
+
DEFAULTS = {
|
7
|
+
:config_file => '/etc/landlord.conf'.freeze,
|
8
|
+
:template_dir => '/etc/landlord'.freeze,
|
9
|
+
:virtual_host_base_dir => '/web'.freeze,
|
10
|
+
:virtual_host_config_dir => '/etc/httpd/vhosts.d'.freeze,
|
11
|
+
:server_type => :apache,
|
12
|
+
:virtual_host_subdirs => %w[ . shared shared/log shared/config releases ]
|
13
|
+
}.freeze
|
14
|
+
|
15
|
+
# == Class Methods ========================================================
|
16
|
+
|
17
|
+
# == Instance Methods =====================================================
|
18
|
+
|
19
|
+
def initialize(config_file = nil)
|
20
|
+
config = DEFAULTS
|
21
|
+
|
22
|
+
if (config_file and File.exist?(config_file))
|
23
|
+
config = DEFAULTS.merge(YAML.load(File.read(config_file)))
|
24
|
+
end
|
25
|
+
|
26
|
+
super(config)
|
27
|
+
|
28
|
+
self.disabled_virtual_host_config_dir ||= File.expand_path(
|
29
|
+
'disabled',
|
30
|
+
self.virtual_host_config_dir
|
31
|
+
)
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,169 @@
|
|
1
|
+
require 'handlebar'
|
2
|
+
require 'fileutils'
|
3
|
+
|
4
|
+
class Landlord::VirtualHost
|
5
|
+
# == Constants ============================================================
|
6
|
+
|
7
|
+
# == Class Methods ========================================================
|
8
|
+
|
9
|
+
def self.each
|
10
|
+
Dir.glob(File.expand_path("*.conf", Landlord.config.virtual_host_config_dir)).each do |path|
|
11
|
+
config = {
|
12
|
+
:server_name => File.basename(path).sub(/\.conf$/, ''),
|
13
|
+
:aliases => [ ],
|
14
|
+
:redirects => [ ]
|
15
|
+
}
|
16
|
+
|
17
|
+
File.open(path).readlines.each do |line|
|
18
|
+
line.chomp!
|
19
|
+
|
20
|
+
if (line.match(/\# VirtualHost (.*)/))
|
21
|
+
aliases = $1.split(/\s+/)
|
22
|
+
|
23
|
+
server_name = aliases.shift
|
24
|
+
|
25
|
+
config[:aliases] += aliases
|
26
|
+
elsif (line.match(/\# VirtualHost:Redirect (.*)/))
|
27
|
+
redirects = $1.split(/\s+/)
|
28
|
+
|
29
|
+
server_name = redirects.shift
|
30
|
+
|
31
|
+
config[:redirects] += redirects
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
yield(config)
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
# == Instance Methods =====================================================
|
40
|
+
|
41
|
+
def initialize(server_name, options = nil)
|
42
|
+
@options = {
|
43
|
+
:server_name => server_name.freeze
|
44
|
+
}
|
45
|
+
|
46
|
+
if (options)
|
47
|
+
@options.merge!(options)
|
48
|
+
end
|
49
|
+
|
50
|
+
@options[:virtual_host_path] ||= File.expand_path(
|
51
|
+
@options[:server_name],
|
52
|
+
Landlord.config.virtual_host_base_dir
|
53
|
+
)
|
54
|
+
end
|
55
|
+
|
56
|
+
def server_name
|
57
|
+
@options[:server_name]
|
58
|
+
end
|
59
|
+
|
60
|
+
def config_file_path(group = nil)
|
61
|
+
File.expand_path(
|
62
|
+
"#{@options[:server_name]}.conf",
|
63
|
+
case (group)
|
64
|
+
when :disabled
|
65
|
+
Landlord.config.disabled_virtual_host_config_dir
|
66
|
+
else
|
67
|
+
Landlord.config.virtual_host_config_dir
|
68
|
+
end
|
69
|
+
)
|
70
|
+
end
|
71
|
+
|
72
|
+
def config_template_path(type = nil)
|
73
|
+
conf_file = [
|
74
|
+
'virtual_host',
|
75
|
+
type || Landlord.config.server_type,
|
76
|
+
'conf'
|
77
|
+
].join('.')
|
78
|
+
|
79
|
+
Landlord.config.virtual_host_template or
|
80
|
+
[
|
81
|
+
File.expand_path(
|
82
|
+
conf_file,
|
83
|
+
Landlord.config.template_dir
|
84
|
+
),
|
85
|
+
File.expand_path(
|
86
|
+
File.join(
|
87
|
+
'..',
|
88
|
+
'..',
|
89
|
+
'templates',
|
90
|
+
conf_file
|
91
|
+
),
|
92
|
+
File.dirname(__FILE__)
|
93
|
+
)
|
94
|
+
].find do |path|
|
95
|
+
File.exist?(path)
|
96
|
+
end
|
97
|
+
end
|
98
|
+
|
99
|
+
def config_file(type = nil)
|
100
|
+
Handlebar::Template.new(
|
101
|
+
File.read(self.config_template_path(type))
|
102
|
+
).render(
|
103
|
+
:server_name => @options[:server_name],
|
104
|
+
:virtual_host_path => @options[:virtual_host_path],
|
105
|
+
:server_aliases => @options[:aliases] && @options[:aliases].join(' '),
|
106
|
+
:server_redirects => @options[:redirects] && @options[:redirects].collect do |redirect|
|
107
|
+
{
|
108
|
+
:server_name => @options[:server_name],
|
109
|
+
:redirect => redirect
|
110
|
+
}
|
111
|
+
end,
|
112
|
+
:rack_env => @options[:rack_env],
|
113
|
+
:rails_env => @options[:rails_env]
|
114
|
+
).sub(/\n+\Z/, "\n")
|
115
|
+
end
|
116
|
+
|
117
|
+
def enable!
|
118
|
+
_config_file_path = self.config_file_path
|
119
|
+
|
120
|
+
if (File.exist?(_config_file_path))
|
121
|
+
# File already exists?!
|
122
|
+
else
|
123
|
+
File.rename(self.config_file_path(:disabled), _config_file_path)
|
124
|
+
end
|
125
|
+
end
|
126
|
+
|
127
|
+
def disable!
|
128
|
+
_config_file_path = self.config_file_path
|
129
|
+
|
130
|
+
if (File.exist?(_config_file_path))
|
131
|
+
File.rename(_config_file_path, self.config_file_path(:disabled))
|
132
|
+
end
|
133
|
+
end
|
134
|
+
|
135
|
+
def add!
|
136
|
+
File.open(self.config_file_path, 'w') do |f|
|
137
|
+
f.write(self.config_file)
|
138
|
+
end
|
139
|
+
|
140
|
+
_virtual_host_path = @options[:virtual_host_path]
|
141
|
+
|
142
|
+
Landlord.config.virtual_host_subdirs.each do |dir|
|
143
|
+
_path = File.expand_path(
|
144
|
+
dir,
|
145
|
+
_virtual_host_path
|
146
|
+
)
|
147
|
+
|
148
|
+
unless (File.exist?(_path))
|
149
|
+
FileUtils.mkdir_p(_path)
|
150
|
+
|
151
|
+
if (Landlord.config.chown_user and Landlord.config.chown_group)
|
152
|
+
FileUtils.chown_R(
|
153
|
+
Landlord.config.chown_user,
|
154
|
+
Landlord.config.chown_group,
|
155
|
+
_path
|
156
|
+
)
|
157
|
+
end
|
158
|
+
end
|
159
|
+
end
|
160
|
+
end
|
161
|
+
|
162
|
+
def remove!
|
163
|
+
_config_file_path = self.config_file_path
|
164
|
+
|
165
|
+
if (File.exist?(_config_file_path))
|
166
|
+
File.unlink(_config_file_path)
|
167
|
+
end
|
168
|
+
end
|
169
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# VirtualHost {{server_name}} {{server_aliases}}
|
2
|
+
<VirtualHost *:80>
|
3
|
+
ServerName {{server_name}}{{?server_aliases}}
|
4
|
+
ServerAlias {{server_aliases}}{{/}}{{?rack_env}}
|
5
|
+
|
6
|
+
RackEnv {{rack_env}}{{/}}
|
7
|
+
|
8
|
+
DocumentRoot {{virtual_host_path}}/current/public
|
9
|
+
|
10
|
+
CustomLog {{virtual_host_path}}/shared/log/access.log combined
|
11
|
+
ErrorLog {{virtual_host_path}}/shared/log/error.log
|
12
|
+
</VirtualHost>
|
13
|
+
|
14
|
+
{{?server_redirects}}{{:server_redirects}}# VirtualHost:Redirect {{server_name}} {{redirect}}
|
15
|
+
<VirtualHost *:80>
|
16
|
+
ServerName {{redirect}}
|
17
|
+
|
18
|
+
RedirectMatch permanent /(.*) http://{{server_name}}/$1
|
19
|
+
</VirtualHost>
|
20
|
+
|
21
|
+
{{/}}{{/}}
|
@@ -0,0 +1,10 @@
|
|
1
|
+
# VirtualHost example.com example.net example.org
|
2
|
+
<VirtualHost *:80>
|
3
|
+
ServerName example.com
|
4
|
+
ServerAlias example.net example.org
|
5
|
+
|
6
|
+
DocumentRoot /web/example.com/current/public
|
7
|
+
|
8
|
+
CustomLog /web/example.com/shared/log/access.log combined
|
9
|
+
ErrorLog /web/example.com/shared/log/error.log
|
10
|
+
</VirtualHost>
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# VirtualHost example.com
|
2
|
+
<VirtualHost *:80>
|
3
|
+
ServerName example.com
|
4
|
+
|
5
|
+
DocumentRoot /web/example.com/current/public
|
6
|
+
|
7
|
+
CustomLog /web/example.com/shared/log/access.log combined
|
8
|
+
ErrorLog /web/example.com/shared/log/error.log
|
9
|
+
</VirtualHost>
|
10
|
+
|
11
|
+
# VirtualHost:Redirect example.com example.net
|
12
|
+
<VirtualHost *:80>
|
13
|
+
ServerName example.net
|
14
|
+
|
15
|
+
RedirectMatch permanent /(.*) http://example.com/$1
|
16
|
+
</VirtualHost>
|
17
|
+
|
18
|
+
# VirtualHost:Redirect example.com example.org
|
19
|
+
<VirtualHost *:80>
|
20
|
+
ServerName example.org
|
21
|
+
|
22
|
+
RedirectMatch permanent /(.*) http://example.com/$1
|
23
|
+
</VirtualHost>
|
data/test/helper.rb
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'bundler'
|
3
|
+
|
4
|
+
begin
|
5
|
+
Bundler.setup(:default, :development)
|
6
|
+
rescue Bundler::BundlerError => e
|
7
|
+
$stderr.puts e.message
|
8
|
+
$stderr.puts "Run `bundle install` to install missing gems"
|
9
|
+
exit e.status_code
|
10
|
+
end
|
11
|
+
|
12
|
+
require 'test/unit'
|
13
|
+
|
14
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
15
|
+
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
16
|
+
|
17
|
+
require 'landlord'
|
18
|
+
|
19
|
+
class Test::Unit::TestCase
|
20
|
+
def expected_result(name)
|
21
|
+
File.read(
|
22
|
+
File.expand_path(
|
23
|
+
File.join('expected_results', name),
|
24
|
+
File.dirname(__FILE__)
|
25
|
+
)
|
26
|
+
)
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
class TestLandlordVirtualHost < Test::Unit::TestCase
|
4
|
+
def setup
|
5
|
+
Landlord.config.template_dir = File.expand_path(
|
6
|
+
File.join('..', 'templates'),
|
7
|
+
File.dirname(__FILE__)
|
8
|
+
)
|
9
|
+
end
|
10
|
+
|
11
|
+
def test_simple_config
|
12
|
+
virtual_host = Landlord::VirtualHost.new('example.com')
|
13
|
+
|
14
|
+
assert virtual_host
|
15
|
+
|
16
|
+
assert_equal 'example.com', virtual_host.server_name
|
17
|
+
|
18
|
+
expected_conf = expected_result('example_virtual_host.conf')
|
19
|
+
|
20
|
+
assert_equal expected_conf, virtual_host.config_file
|
21
|
+
end
|
22
|
+
|
23
|
+
def test_config_with_aliases
|
24
|
+
virtual_host = Landlord::VirtualHost.new('example.com', :aliases => %w[ example.net example.org ])
|
25
|
+
|
26
|
+
expected_conf = expected_result('example_virtual_host_with_aliases.conf')
|
27
|
+
|
28
|
+
assert_equal expected_conf, virtual_host.config_file
|
29
|
+
end
|
30
|
+
|
31
|
+
def test_config_with_redirects
|
32
|
+
virtual_host = Landlord::VirtualHost.new('example.com', :redirects => %w[ example.net example.org ])
|
33
|
+
|
34
|
+
expected_conf = expected_result('example_virtual_host_with_redirects.conf')
|
35
|
+
|
36
|
+
assert_equal expected_conf, virtual_host.config_file
|
37
|
+
end
|
38
|
+
end
|
metadata
ADDED
@@ -0,0 +1,101 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: landlord
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Scott Tadman
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-01-27 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: handlebar
|
16
|
+
requirement: &2158107120 !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: *2158107120
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: bundler
|
27
|
+
requirement: &2158106540 !ruby/object:Gem::Requirement
|
28
|
+
none: false
|
29
|
+
requirements:
|
30
|
+
- - ! '>='
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '0'
|
33
|
+
type: :development
|
34
|
+
prerelease: false
|
35
|
+
version_requirements: *2158106540
|
36
|
+
- !ruby/object:Gem::Dependency
|
37
|
+
name: jeweler
|
38
|
+
requirement: &2158105700 !ruby/object:Gem::Requirement
|
39
|
+
none: false
|
40
|
+
requirements:
|
41
|
+
- - ! '>='
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: '0'
|
44
|
+
type: :development
|
45
|
+
prerelease: false
|
46
|
+
version_requirements: *2158105700
|
47
|
+
description: A command-line tool for managing multiple virtual-host configurations
|
48
|
+
on a web server
|
49
|
+
email: github@tadman.ca
|
50
|
+
executables:
|
51
|
+
- landlord
|
52
|
+
extensions: []
|
53
|
+
extra_rdoc_files:
|
54
|
+
- LICENSE.txt
|
55
|
+
- README.rdoc
|
56
|
+
files:
|
57
|
+
- .document
|
58
|
+
- Gemfile
|
59
|
+
- LICENSE.txt
|
60
|
+
- README.rdoc
|
61
|
+
- Rakefile
|
62
|
+
- VERSION
|
63
|
+
- bin/landlord
|
64
|
+
- landlord.gemspec
|
65
|
+
- lib/landlord.rb
|
66
|
+
- lib/landlord/config.rb
|
67
|
+
- lib/landlord/virtual_host.rb
|
68
|
+
- templates/virtual_host.apache.conf
|
69
|
+
- test/expected_results/example_virtual_host.conf
|
70
|
+
- test/expected_results/example_virtual_host_with_aliases.conf
|
71
|
+
- test/expected_results/example_virtual_host_with_redirects.conf
|
72
|
+
- test/helper.rb
|
73
|
+
- test/test_landlord.rb
|
74
|
+
- test/test_landlord_config.rb
|
75
|
+
- test/test_landlord_virtual_host.rb
|
76
|
+
homepage: http://github.com/twg/landlord
|
77
|
+
licenses:
|
78
|
+
- MIT
|
79
|
+
post_install_message:
|
80
|
+
rdoc_options: []
|
81
|
+
require_paths:
|
82
|
+
- lib
|
83
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
84
|
+
none: false
|
85
|
+
requirements:
|
86
|
+
- - ! '>='
|
87
|
+
- !ruby/object:Gem::Version
|
88
|
+
version: '0'
|
89
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
90
|
+
none: false
|
91
|
+
requirements:
|
92
|
+
- - ! '>='
|
93
|
+
- !ruby/object:Gem::Version
|
94
|
+
version: '0'
|
95
|
+
requirements: []
|
96
|
+
rubyforge_project:
|
97
|
+
rubygems_version: 1.8.11
|
98
|
+
signing_key:
|
99
|
+
specification_version: 3
|
100
|
+
summary: Web server virtual-host tenant management tool
|
101
|
+
test_files: []
|