public
Rubygem
Description: Merb Core: All you need. None you don't.
Homepage: http://www.merbivore.com
Clone URL: git://github.com/wycats/merb-core.git
Search Repo:
Provide opts for alternate rackup config path. This is consistent with 
--rackup option for thin and gives a little more freedom to specify the 
rackup config (instead of being forced to rack.rb).

Signed-off-by: Michael S. Klishin <michael@novemberain.com>
gabriel (author)
Thu May 01 09:24:44 -0700 2008
Michael S. Klishin (committer)
Sat May 03 00:48:42 -0700 2008
commit  ae200b7dbe4ad5e1629617f99a16c94d3acd10bf
tree    3aaa26727ef3c91d01f3a02ba0f8c94e33646709
parent  4b7318104e94b7b404fff4140e2bf2e94b53a278
...
550
551
552
553
554
555
556
 
 
 
557
558
559
560
561
 
 
 
 
 
 
562
563
564
...
550
551
552
 
 
 
 
553
554
555
556
557
558
559
 
560
561
562
563
564
565
566
567
568
0
@@ -550,15 +550,19 @@ class Merb::BootLoader::ChooseAdapter < Merb::BootLoader
0
 end
0
 
0
 class Merb::BootLoader::RackUpApplication < Merb::BootLoader
0
-
0
- # Setup the Merb Rack App or read a rack.rb config file located at the
0
- # Merb.root or Merb.root / config / rack.rb with the same syntax as the
0
- # rackup tool that comes with rack. Automatically evals the rack.rb file in
0
+ # Setup the Merb Rack App or read a rackup file located at
0
+ # Merb::Config[:rackup] with the same syntax as the
0
+ # rackup tool that comes with rack. Automatically evals the file in
0
   # the context of a Rack::Builder.new { } block. Allows for mounting
0
   # additional apps or middleware.
0
   def self.run
0
     if File.exists?(Merb.dir_for(:config) / "rack.rb")
0
- Merb::Config[:app] = eval("::Rack::Builder.new {( #{IO.read(Merb.dir_for(:config) / 'rack.rb')}\n )}.to_app", TOPLEVEL_BINDING, __FILE__, __LINE__)
0
+ Merb::Config[:rackup] ||= Merb.dir_for(:config) / "rack.rb"
0
+ end
0
+
0
+ if Merb::Config[:rackup]
0
+ rackup_code = File.read(Merb::Config[:rackup])
0
+ Merb::Config[:app] = eval("::Rack::Builder.new {( #{rackup_code}\n )}.to_app", TOPLEVEL_BINDING, Merb::Config[:rackup])
0
     else
0
       Merb::Config[:app] = ::Merb::Rack::Application.new
0
     end
...
166
167
168
 
 
 
 
169
170
171
...
166
167
168
169
170
171
172
173
174
175
0
@@ -166,6 +166,10 @@ module Merb
0
             options[:adapter] = adapter
0
           end
0
 
0
+ opts.on("-R", "--rackup FILE", "Load an alternate Rack config file (default is config/rack.rb)") do |rackup|
0
+ options[:rackup] = rackup
0
+ end
0
+
0
           opts.on("-i", "--irb-console", "This flag will start merb in irb console mode. All your models and other classes will be available for you in an irb session.") do |console|
0
             options[:adapter] = 'irb'
0
           end
...
4
5
6
7
 
8
9
10
11
12
13
 
14
15
16
17
 
18
19
20
21
22
 
23
24
25
 
 
26
27
 
28
29
 
30
31
32
...
43
44
45
46
 
47
48
49
 
50
51
52
53
54
55
56
 
57
58
59
60
61
 
62
63
64
 
65
66
 
67
68
69
70
71
 
72
73
74
75
76
 
77
78
79
80
81
82
 
83
84
85
...
89
90
91
92
 
93
94
95
96
97
 
98
99
100
101
102
 
103
104
105
106
107
 
108
109
110
111
112
113
 
 
 
 
 
 
114
115
116
...
120
121
122
123
 
124
125
126
...
130
131
132
133
 
134
135
136
...
140
141
142
143
 
144
145
146
...
151
152
153
154
155
156
 
 
...
4
5
6
 
7
8
9
10
11
12
 
13
14
15
16
 
17
18
19
20
21
 
22
23
 
 
24
25
26
 
27
28
 
29
30
31
32
...
43
44
45
 
46
47
48
 
49
50
51
52
53
54
55
 
56
57
58
59
60
 
61
62
63
 
64
65
 
66
67
68
69
70
 
71
72
73
74
75
 
76
77
78
79
80
81
 
82
83
84
85
...
89
90
91
 
92
93
94
95
96
 
97
98
99
100
101
 
102
103
104
105
106
 
107
108
109
110
111
112
 
113
114
115
116
117
118
119
120
121
...
125
126
127
 
128
129
130
131
...
135
136
137
 
138
139
140
141
...
145
146
147
 
148
149
150
151
...
156
157
158
 
 
159
160
161
0
@@ -4,29 +4,29 @@ describe Merb::Config do
0
   before do
0
     Merb::Config.setup
0
   end
0
-
0
+
0
   it "should be able to yield the configuration via #use" do
0
     res = nil
0
     Merb::Config.use {|c| res = c}
0
     res.should == Merb::Config.defaults
0
   end
0
-
0
+
0
   it "should be able to get a configuration key" do
0
     Merb::Config[:host].should == "0.0.0.0"
0
   end
0
-
0
+
0
   it "should be able to set a configuration key" do
0
     Merb::Config[:bar] = "Hello"
0
     Merb::Config[:bar].should == "Hello"
0
   end
0
-
0
+
0
   it "should be able to #delete a configuration key" do
0
- Merb::Config[:bar] = "Hello"
0
- Merb::Config[:bar].should == "Hello"
0
+ Merb::Config[:bar] = "Hello"
0
+ Merb::Config[:bar].should == "Hello"
0
     Merb::Config.delete(:bar)
0
- Merb::Config[:bar].should == nil
0
+ Merb::Config[:bar].should == nil
0
   end
0
-
0
+
0
   it "should be able to #fetch a key that does exist" do
0
     Merb::Config.fetch(:host, "192.168.2.1").should == "0.0.0.0"
0
   end
0
@@ -43,43 +43,43 @@ describe Merb::Config do
0
     Merb::Config.parse_args(["-u", "tester"])
0
     Merb::Config[:user].should == "tester"
0
   end
0
-
0
+
0
   it "should support -G to set the group to run Merb as" do
0
     Merb::Config.parse_args(["-G", "tester"])
0
- Merb::Config[:group].should == "tester"
0
+ Merb::Config[:group].should == "tester"
0
   end
0
 
0
   it "should support -f to set the filename to run Merb as" do
0
     Merb::Config.parse_args(["-d"])
0
     Merb::Config[:daemonize].should == true
0
   end
0
-
0
+
0
   it "should support -c to set the number of cluster nodes" do
0
     Merb::Config.parse_args(["-c", "4"])
0
     Merb::Config[:cluster].should == "4"
0
   end
0
-
0
+
0
   it "should support -p to set the port number" do
0
     Merb::Config.parse_args(["-p", "6000"])
0
- Merb::Config[:port].should == "6000"
0
+ Merb::Config[:port].should == "6000"
0
   end
0
-
0
+
0
   it "should support -P to set the PIDfile" do
0
     Merb::Config.parse_args(["-P", "pidfile"])
0
     Merb::Config[:pid_file].should == "pidfile"
0
   end
0
-
0
+
0
   it "should have server return PIDfile setting as is with no cluster nodes" do
0
     Merb::Config.parse_args(["-P", "pidfile", "-p", "6000"])
0
     Merb::Server.pid_file(6000).should == "pidfile"
0
   end
0
-
0
+
0
   it "should support setting of PIDfile with cluster nodes" do
0
     Merb::Config.parse_args(["-P", "/tmp/merb.pidfile", "-c", "2", "-p", "6000"])
0
     Merb::Server.pid_file(6000).should == "/tmp/merb.6000.pidfile"
0
     Merb::Server.pid_file(6001).should == "/tmp/merb.6001.pidfile"
0
   end
0
-
0
+
0
   it "should support default PIDfile setting" do
0
     Merb::Config.parse_args(["-p", "6000"])
0
     Merb::Server.pid_file(6000).should == Merb.log_path / "merb.6000.pid"
0
@@ -89,28 +89,33 @@ describe Merb::Config do
0
     Merb::Config.parse_args(["-h", "hostname"])
0
     Merb::Config[:host].should == "hostname"
0
   end
0
-
0
+
0
   it "should support -i to specify loading IRB" do
0
     Merb::Config.parse_args(["-i"])
0
     Merb::Config[:adapter].should == "irb"
0
   end
0
-
0
+
0
   it "should support -l to specify the log level" do
0
     Merb::Config.parse_args(["-l", "debug"])
0
     Merb::Config[:log_level].should == :debug
0
   end
0
-
0
+
0
   it "should support -L to specify the location of the log file" do
0
     Merb::Config.parse_args(["-L", "log_file"])
0
     Merb::Config[:log_file].should == "log_file"
0
   end
0
-
0
+
0
   it "should support -r to specify a runner" do
0
     Merb::Config.parse_args(["-r", "foo_runner"])
0
     Merb::Config[:runner_code].should == "foo_runner"
0
     Merb::Config[:adapter].should == "runner"
0
   end
0
-
0
+
0
+ it "should support -R to specify a rackup file" do
0
+ Merb::Config.parse_args(["-R", "config.ru"])
0
+ Merb::Config[:rackup].should == "config.ru"
0
+ end
0
+
0
   it "should support -K for a graceful kill" do
0
     Merb::Server.should_receive(:kill).with("all", 1)
0
     Merb.start(["-K", "all"])
0
@@ -120,7 +125,7 @@ describe Merb::Config do
0
     Merb::Server.should_receive(:kill).with("all", 9)
0
     Merb.start(["-k", "all"])
0
   end
0
-
0
+
0
   it "should support -X off to turn off the mutex" do
0
     Merb::Config.parse_args(["-X", "off"])
0
     Merb::Config[:use_mutex].should == false
0
@@ -130,7 +135,7 @@ describe Merb::Config do
0
     Merb::Config.parse_args(["-X", "on"])
0
     Merb::Config[:use_mutex].should == true
0
   end
0
-
0
+
0
   it "should take Merb.disable into account" do
0
     Merb::Config[:disabled_components].should == []
0
     Merb::Config[:disabled_components] << :foo
0
@@ -140,7 +145,7 @@ describe Merb::Config do
0
     Merb.disabled?(:foo).should == true
0
     Merb.disabled?(:foo, :buz).should == true
0
   end
0
-
0
+
0
   it "should take Merb.testing? into account" do
0
     $TESTING.should == true
0
     Merb::Config[:testing].should be_nil
0
@@ -151,5 +156,5 @@ describe Merb::Config do
0
     Merb.should be_testing
0
     $TESTING = true; Merb::Config[:testing] = false # reset
0
   end
0
-
0
-end
0
\ No newline at end of file
0
+
0
+end

Comments

    No one has commented yet.