public
Description: A very fast & simple Ruby web server
Homepage: http://code.macournoyer.com/thin/
Clone URL: git://github.com/macournoyer/thin.git
Search Repo:
Add --require (-r) option to require a library, before executing your 
script.
Rename --rackup short option to -R, warn and load as rackup when file ends 
with .ru.
macournoyer (author)
Sat Apr 05 13:32:56 -0700 2008
commit  a3a783e2ffe03eebde8c329479b8e15dc0b3d21a
tree    ae75ab61b967a3e7173e2e67f1d40ab0f2ca859d
parent  dc472b681619c0134db30e7d68b2edbfb1a02076
...
1
 
 
2
3
4
...
1
2
3
4
5
6
0
@@ -1,4 +1,6 @@
0
 == 0.8.0 Dodgy Dentist release
0
+ * Add --require (-r) option to require a library, before executing your script.
0
+ * Rename --rackup short option to -R, warn and load as rackup when file ends with .ru.
0
  * List supported adapters in command usage.
0
  * Add file adapter to built-in adapter, serve static files in current directory.
0
  * Allow disabling signal handling in Server with :signals => false
...
14
15
16
17
 
18
19
20
 
21
22
23
...
14
15
16
 
17
18
19
 
20
21
22
23
0
@@ -14,10 +14,10 @@
0
   # Raised when an option is not valid.
0
   class InvalidOption < RunnerError; end
0
   
0
- # Build and control one Thin server.
0
+ # Build and control Thin servers.
0
   # Hey Controller pattern is not only for web apps yo!
0
   module Controllers
0
- # Controls a Thin server.
0
+ # Controls one Thin server.
0
     # Allow to start, stop, restart and configure a single thin server.
0
     class Controller
0
       include Logging
...
64
65
66
67
 
68
69
70
...
113
114
115
 
116
117
118
...
184
185
186
 
 
 
 
 
 
 
 
 
187
188
189
...
64
65
66
 
67
68
69
70
...
113
114
115
116
117
118
119
...
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
0
@@ -64,7 +64,7 @@
0
         opts.on("-y", "--swiftiply [KEY]", "Run using swiftiply") { |key| @options[:swiftiply] = key }
0
         opts.on("-A", "--adapter NAME", "Rack adapter to use (default: autodetect)",
0
                                         "(#{Rack::ADAPTERS.keys.join(', ')})") { |name| @options[:adapter] = name }
0
- opts.on("-r", "--rackup FILE", "Load a Rack config file instead of " +
0
+ opts.on("-R", "--rackup FILE", "Load a Rack config file instead of " +
0
                                        "Rack adapter") { |file| @options[:rackup] = file }
0
         opts.on("-c", "--chdir DIR", "Change to dir before starting") { |dir| @options[:chdir] = File.expand_path(dir) }
0
         opts.on( "--stats PATH", "Mount the Stats adapter under PATH") { |path| @options[:stats] = path }
0
@@ -113,6 +113,7 @@
0
         opts.separator ""
0
         opts.separator "Common options:"
0
 
0
+ opts.on_tail("-r", "--require FILE", "require the library") { |file| ruby_require file }
0
         opts.on_tail("-D", "--debug", "Set debbuging on") { Logging.debug = true }
0
         opts.on_tail("-V", "--trace", "Set tracing on (log raw request/response)") { Logging.trace = true }
0
         opts.on_tail("-h", "--help", "Show this message") { puts opts; exit }
0
@@ -184,6 +185,15 @@
0
       def load_options_from_config_file!
0
         if file = @options.delete(:config)
0
           YAML.load_file(file).each { |key, value| @options[key.to_sym] = value }
0
+ end
0
+ end
0
+
0
+ def ruby_require(file)
0
+ if File.extname(file) == '.ru'
0
+ warn 'WARNING: Use the -R option to load a Rack config file'
0
+ @options[:rackup] = file
0
+ else
0
+ require file
0
         end
0
       end
0
   end
...
61
62
63
64
 
 
 
 
 
 
 
 
 
 
 
 
 
 
65
66
67
...
61
62
63
 
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
0
@@ -61,7 +61,20 @@
0
   
0
   it "should consider as a cluster with :only option" do
0
     Runner.new(%w(start --only 3000)).should be_a_cluster
0
- end
0
+ end
0
+
0
+ it "should warn when require a rack config file" do
0
+ STDERR.stub!(:write)
0
+ STDERR.should_receive(:write).with(/WARNING:/)
0
+
0
+ runner = Runner.new(%w(start -r config.ru))
0
+
0
+ runner.options[:rackup].should == 'config.ru'
0
+ end
0
+
0
+ it "should require file" do
0
+ proc { Runner.new(%w(start -r unexisting)) }.should raise_error(LoadError)
0
+ end
0
 end
0
 
0
 describe Runner, 'with config file' do

Comments

    No one has commented yet.