public
Description: Magic configuration for your nginx, mongrels and god!
Homepage: http://archangel.rubyforge.org/
Clone URL: git://github.com/halorgium/archangel.git
Allow the overriding of the site path through the configuration file
Raise an exception if the same site name is used twice
halorgium (author)
Thu Feb 14 06:26:47 -0800 2008
commit  af5ab590234569ad60e60fb8246e781d762d5710
tree    037aea13fa6d68167a9503234412cd6e3bd98a84
parent  25c0ad31822cc51c2eca0de93f2594cb8d2f4bb4
...
27
28
29
 
30
31
32
...
27
28
29
30
31
32
33
0
@@ -27,6 +27,7 @@ script/generate
0
 setup.rb
0
 spec/archangel/configuration_spec.rb
0
 spec/archangel/mongrel_spec.rb
0
+spec/archangel/site_builder_spec.rb
0
 spec/archangel_spec.rb
0
 spec/spec.opts
0
 spec/spec_helper.rb
...
63
64
65
 
 
 
 
 
 
66
67
68
...
63
64
65
66
67
68
69
70
71
72
73
74
0
@@ -63,6 +63,12 @@ module Archangel
0
       @sites ||= []
0
     end
0
     
0
+ def site_names
0
+ sites.map do |s|
0
+ s.name
0
+ end
0
+ end
0
+
0
     def sites_running_on(load_balancer)
0
       sites.select do |site|
0
         site.load_balancer_name == load_balancer
...
34
35
36
37
 
 
38
39
40
...
34
35
36
 
37
38
39
40
41
0
@@ -34,7 +34,8 @@ module Archangel
0
     
0
     def site(name, *args, &block)
0
       options = args.last.is_a?(Hash) ? args.pop : {}
0
- site = Site.new(name, options, @configuration)
0
+ raise ArgumentError, "`#{name}' already has been defined" if @configuration.site_names.include?(name.to_s)
0
+ site = Site.new(name.to_s, options, @configuration)
0
       b = SiteBuilder.new(site)
0
       b.instance_eval(&block)
0
       @configuration.sites << site
...
6
7
8
9
 
10
11
12
...
28
29
30
 
 
 
 
31
32
 
33
34
35
...
6
7
8
 
9
10
11
12
...
28
29
30
31
32
33
34
35
 
36
37
38
39
0
@@ -6,7 +6,7 @@ module Archangel
0
     end
0
     attr_reader :name, :options, :configuration
0
     attr_accessor :hostnames, :aliases, :profile_name, :fair
0
- attr_writer :port
0
+ attr_writer :port, :path
0
     
0
     def watch
0
       upstreams.each do |upstream|
0
@@ -28,8 +28,12 @@ module Archangel
0
       @profile ||= configuration.profile_for(profile_name)
0
     end
0
     
0
+ def path
0
+ @path || name
0
+ end
0
+
0
     def root_path
0
- profile[:path] % name
0
+ profile[:path] % path
0
     end
0
     
0
     def public_path
...
12
13
14
 
 
 
 
15
16
17
...
12
13
14
15
16
17
18
19
20
21
0
@@ -12,6 +12,10 @@ module Archangel
0
       @site.aliases = names
0
     end
0
     
0
+ def path(path)
0
+ @site.path = path
0
+ end
0
+
0
     def port(number)
0
       @site.port = number
0
     end
...
77
78
79
80
 
81
82
83
...
114
115
116
117
 
118
119
120
...
77
78
79
 
80
81
82
83
...
114
115
116
 
117
118
119
120
0
@@ -77,7 +77,7 @@ module Archangel
0
     end
0
     
0
     it "should have a site called :twitter" do
0
- @config.sites.first.name.should == :twitter
0
+ @config.sites.first.name.should == "twitter"
0
     end
0
     
0
     it "should have a site with profile_name :rails" do
0
@@ -114,7 +114,7 @@ module Archangel
0
     end
0
     
0
     it "should have a site called :twitter" do
0
- @config.sites.first.name.should == :basecamp
0
+ @config.sites.first.name.should == "basecamp"
0
     end
0
     
0
     it "should be hosted on nginx" do

Comments

    No one has commented yet.