ruby-style 1.1.5 → 1.2.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/README CHANGED
@@ -14,9 +14,9 @@ style is distributed as a gem, and can be installed with:
14
14
  Feedback/Bugs/Support Requests should be handled through RubyForge at
15
15
  http://rubyforge.org/projects/ruby-style/.
16
16
 
17
- The RDoc is available at http://code.jeremyevans.net/doc/ruby-style/.
18
- Source control access is available at github
19
- (http://github.com/jeremyevans/ruby-style/tree/master).
17
+ The RDoc is available at http://ruby-style.rubyforge.org.
18
+
19
+ Source is available at github: http://github.com/jeremyevans/ruby-style
20
20
 
21
21
  == Highlights
22
22
 
@@ -29,8 +29,7 @@ Source control access is available at github
29
29
  the fly
30
30
  * Supports both command line and yaml config file configuration
31
31
  * Is easily extensible to support running other frameworks and protocols other
32
- than the included ones (Rails, Ramaze, and a generic adapter; SCGI, Mongrel,
33
- Thin, and Evented Mongrel)
32
+ than the included ones (Rails; SCGI, Mongrel, Thin, and Evented Mongrel)
34
33
 
35
34
  == Running and configuration
36
35
 
@@ -41,16 +40,16 @@ style [option value, ...] (decrement|halt|increment|restart|run|start|stop)
41
40
  Options:
42
41
  -a, --adapter Adapter/Framework to use [rails]
43
42
  -b, --bind IP address to bind to [127.0.0.1]
44
- -c, --config Location of config file [config/style.yaml]
43
+ -c, --config Location of config file [style.yaml]
45
44
  -d, --directory Working directory [.]
46
45
  -D, --debug Run the program in the foreground without forking [No]
47
46
  -f, --fork Number of listners on each port [1]
48
47
  -h, --handler Handler/Server to use [mongrel]
49
48
  -k, --killtime Number of seconds to wait when killing each child [2]
50
- -l, --logfile Where to redirect STDOUT and STDERR [log/style.log]
49
+ -l, --logfile Where to redirect STDOUT and STDERR [style.log]
51
50
  -n, --number Number of ports to which to bind [1]
52
51
  -p, --port Starting port to which to bind [9999]
53
- -P, --pidfile Location of pid file [log/style.pid]
52
+ -P, --pidfile Location of pid file [style.pid]
54
53
  -u, --unsupervised Whether to run unsupervised [No]
55
54
 
56
55
  Here's what the various commands do:
@@ -76,9 +75,9 @@ Here's a longer explanation of the options:
76
75
 
77
76
  -a, --adapter Adapter/Framework to use [rails]
78
77
 
79
- This is the adapter/framework to use. Support for Rails and Ramaze is
80
- included in the distribution, support for other frameworks should be fairly
81
- easy to add.
78
+ This is the adapter/framework to use. Support for Rails is
79
+ included in the distribution, and is special-cased. Any other value runs
80
+ require with the argument given.
82
81
 
83
82
  -b, --bind IP address to bind to [127.0.0.1]
84
83
 
@@ -218,13 +217,13 @@ listener on each port:
218
217
  | :adapter: rails
219
218
  | :handler: thin
220
219
 
221
- Very simple configuration that runs Ramaze+Evented Mongrel in unsupervised
222
- mode on port 3000.
220
+ Very simple configuration that runs Ramaze (with the default start.rb runner)
221
+ +Evented Mongrel in unsupervised mode on port 3000.
223
222
 
224
223
  | ---
225
224
  | :port: 3000
226
225
  | :unsupervised: 1
227
- | :adapter: ramaze
226
+ | :adapter: start
228
227
  | :handler: evented_mongrel
229
228
 
230
229
  Using the generic adapter to host a camping application (you are responsible
@@ -233,9 +232,7 @@ $LOAD_PATH that uses Mongrel to run camping):
233
232
 
234
233
  | ---
235
234
  | :port: 3301
236
- | :adapter: generic
237
- | :adapter_config:
238
- | :script: my_camping_app
235
+ | :adapter: my_camping_app
239
236
 
240
237
  == How restarting works
241
238
 
@@ -293,21 +290,87 @@ For example:
293
290
  Result, three brand new listening processes, total time to restart is about 12
294
291
  seconds (2 * (2 killtime * 1 number * 3 fork)).
295
292
 
296
- == Other handlers and adapter
293
+ == Other handlers
297
294
 
298
295
  To add support for another handler, make sure the instead of creating a socket,
299
296
  it uses the socket provided by style, available in the global variable
300
297
  $STYLE_SOCKET. See existing handler code to see how Mongrel, SCGI, and Event
301
298
  Machine were modified to support this.
302
299
 
303
- Support for other adapters is easily added by adding the run method to the
304
- Style class. This can be easy (as it is with Ramaze), or more difficult (as it
305
- is with Rails). If the adapter uses Rack, it should be fairly simple. You can
306
- also just use the generic adapter to specify a string to require.
300
+ Style loads handlers from style/handler relative to the load path, so you can
301
+ add your own handlers without modifying the program, as long as you place the
302
+ files somewhere in the load path.
303
+
304
+ == Changes to the default config, logfile, and pidfile in 1.2.0
305
+
306
+ Previously, style had the following defaults:
307
+
308
+ * config - config/style.yaml
309
+ * logfile - log/style.log
310
+ * pidfile - log/style.pid
307
311
 
308
- Style loads adapters and handlers from style/{adapter,handler} relative to the
309
- load path, so you can add your own adapters and handlers without modifying the
310
- program, as long as you place the files somewhere in the load path.
312
+ These made sense because style was originally designed to serve Rails
313
+ applications, which all have config and log directories. Now that style
314
+ serves more types of applications, and few of those have config or log
315
+ directories, these no longer made good defaults. The new defaults use the
316
+ same filename, without the directory:
317
+
318
+ * config - style.yaml
319
+ * logfile - style.log
320
+ * pidfile - style.pid
321
+
322
+ == Changes to adapter handling in 1.2.0
323
+
324
+ Adapter handling was simplified in 1.2.0. Because there is no easy script
325
+ that loads rails, there is still a rails adapter. However, for all other
326
+ framaworks you would want to use, just specify the file you want to require
327
+ as the adapter. This simplifies things and allows you to specify your
328
+ adapter file on the command line:
329
+
330
+ style -a sinatra_runner start
331
+
332
+ Before, this wasn't possible, you had to set up a configuration file or put
333
+ the adapter file you wanted to use in a style/adapter subdirectory in the load
334
+ path.
335
+
336
+ == Upgrading from 1.1.*, previously using ramaze adapter
337
+
338
+ Previously, if you used the following configuration:
339
+
340
+ | ---
341
+ | :adapter: ramaze
342
+
343
+ You should change it to:
344
+
345
+ | ---
346
+ | :adapter: start
347
+
348
+ If you specified your own :runner via :adapter_config, just use that runner
349
+ name for the :adapter instead of start.
350
+
351
+ The Ramaze adapter had some default settings that you might want to consider:
352
+
353
+ :test_connections=>false, :force=>true
354
+
355
+ You should make sure your ramaze runner sets the correct :adapter for Ramaze to
356
+ use (it should use the same one as style uses). Having it set the :host and
357
+ :port are good ideas, otherwise it may display those incorrectly. You should
358
+ make sure your ramaze runner actually calls Ramaze.start, as well.
359
+
360
+ == Upgrading from 1.1.*, previously using generic adapter
361
+
362
+ If you were previously using the generic adapter, the upgrade is simple. Change
363
+ the following cofiguration from:
364
+
365
+ | ---
366
+ | :adapter: generic
367
+ | :adapter_config:
368
+ | :script: cse
369
+
370
+ To:
371
+
372
+ | ---
373
+ | :adapter: cse
311
374
 
312
375
  == FAQ
313
376
 
data/lib/style.rb CHANGED
@@ -19,10 +19,10 @@ class Style
19
19
 
20
20
  # Configure style
21
21
  def initialize
22
- @config = {:pidfile=>'log/style.pid', :number=>1, :port=>9999,
23
- :style=>'RailsMongrel', :fork=>1, :bind=>'127.0.0.1',
24
- :cliconfig=>{}, :killtime=>2, :config=>'config/style.yaml',
25
- :logfile=>'log/style.log', :children=>{},:sockets=>{},
22
+ @config = {:pidfile=>'style.pid', :number=>1, :port=>9999,
23
+ :fork=>1, :bind=>'127.0.0.1',
24
+ :cliconfig=>{}, :killtime=>2, :config=>'style.yaml',
25
+ :logfile=>'style.log', :children=>{},:sockets=>{},
26
26
  :adapter_config=>{}, :directory=>'.', :debug=>false,
27
27
  :unsupervised=> false, :adapter=>'rails', :handler=>'mongrel'}
28
28
  @mutex = Mutex.new
@@ -99,7 +99,13 @@ class Style
99
99
 
100
100
  # Load the revelent style adapter/framework
101
101
  def load_adapter
102
- require "style/adapter/#{config[:adapter]}"
102
+ adapter = config[:adapter].to_s
103
+ if adapter == 'rails'
104
+ require "style/adapter/rails"
105
+ run
106
+ else
107
+ require adapter
108
+ end
103
109
  end
104
110
 
105
111
  # Load the revelent style handler/server
@@ -275,7 +281,6 @@ class Style
275
281
  def run_child
276
282
  load_handler
277
283
  load_adapter
278
- run
279
284
  end
280
285
 
281
286
  # Run the program in the foreground instead of daemonizing. Only runs on one
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby-style
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.5
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jeremy Evans
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2008-05-09 00:00:00 -07:00
12
+ date: 2008-06-18 00:00:00 -07:00
13
13
  default_executable:
14
14
  dependencies: []
15
15
 
@@ -25,16 +25,14 @@ files:
25
25
  - LICENSE
26
26
  - README
27
27
  - lib/style.rb
28
- - lib/style/adapter/generic.rb
29
28
  - lib/style/adapter/rails.rb
30
- - lib/style/adapter/ramaze.rb
31
29
  - lib/style/handler/evented_mongrel.rb
32
30
  - lib/style/handler/eventmachine.rb
33
31
  - lib/style/handler/mongrel.rb
34
32
  - lib/style/handler/scgi.rb
35
33
  - lib/style/handler/thin.rb
36
34
  has_rdoc: true
37
- homepage:
35
+ homepage: http://ruby-style.rubyforge.org
38
36
  post_install_message:
39
37
  rdoc_options:
40
38
  - --inline-source
@@ -1,9 +0,0 @@
1
- class Style
2
- # This requires config[:adapter_config][:script] || 'style_adapter',
3
- # which means you can use it to host other supported web frameworks.
4
- # Those frameworks should start the server that style is currently using,
5
- # in order to pick up the correct socket.
6
- def run
7
- require(config[:adapter_config][:script] || 'style_adapter')
8
- end
9
- end
@@ -1,14 +0,0 @@
1
- require 'rubygems'
2
- require 'ramaze'
3
-
4
- class Style
5
- # Run Ramaze with the mongrel adapter and start.rb runner
6
- def run
7
- settings = {:adapter=>config[:handler].to_sym, :test_connections=>false,
8
- :force=>true, :runner =>'start.rb', :host=>config[:bind],
9
- :port=>config[:sockets][$STYLE_SOCKET]}.merge(config[:adapter_config])
10
- require settings[:runner].to_s
11
- Ramaze.start(settings)
12
- end
13
- end
14
-