manveru-ramaze 2009.04.22 → 2009.05

Sign up to get free protection for your applications and to get access to all the features.
Files changed (74) hide show
  1. data/CHANGELOG +199 -0
  2. data/MANIFEST +16 -7
  3. data/{README.markdown → README.md} +0 -14
  4. data/Rakefile +20 -20
  5. data/benchmark/bench_templates/bench.rb +67 -0
  6. data/benchmark/bench_templates/view/large.erb +79 -0
  7. data/benchmark/bench_templates/view/large.haml +41 -0
  8. data/benchmark/bench_templates/view/large.xhtml +79 -0
  9. data/benchmark/bench_templates/view/small.erb +21 -0
  10. data/benchmark/bench_templates/view/small.haml +12 -0
  11. data/benchmark/bench_templates/view/small.xhtml +21 -0
  12. data/benchmark/run.rb +14 -21
  13. data/benchmark/suite/minimal.rb +3 -5
  14. data/benchmark/suite/no_informer.rb +0 -2
  15. data/benchmark/suite/no_sessions.rb +3 -4
  16. data/benchmark/suite/no_template.rb +1 -3
  17. data/benchmark/suite/simple.rb +1 -3
  18. data/benchmark/suite/template_erubis.rb +0 -2
  19. data/benchmark/suite/template_etanni.rb +8 -0
  20. data/benchmark/suite/template_ezamar.rb +1 -3
  21. data/benchmark/suite/template_haml.rb +0 -2
  22. data/benchmark/suite/template_liquid.rb +0 -2
  23. data/benchmark/suite/template_markaby.rb +0 -2
  24. data/benchmark/suite/template_nagoro.rb +1 -3
  25. data/benchmark/suite/template_redcloth.rb +0 -2
  26. data/benchmark/suite/template_tenjin.rb +0 -2
  27. data/bin/ramaze +9 -248
  28. data/doc/AUTHORS +11 -7
  29. data/examples/app/chat/layout/{default.nag → default.xhtml} +0 -0
  30. data/examples/app/chat/view/{chat.nag → chat.xhtml} +0 -0
  31. data/examples/app/chat/view/{index.nag → index.xhtml} +0 -0
  32. data/examples/helpers/cache.rb +6 -4
  33. data/lib/proto/config.ru +1 -1
  34. data/lib/ramaze.rb +2 -3
  35. data/lib/ramaze/cache/sequel.rb +17 -5
  36. data/lib/ramaze/gestalt.rb +3 -0
  37. data/lib/ramaze/helper/cache.rb +19 -9
  38. data/lib/ramaze/helper/gestalt.rb +32 -0
  39. data/lib/ramaze/helper/paginate.rb +1 -0
  40. data/lib/ramaze/helper/ultraviolet.rb +2 -0
  41. data/lib/ramaze/log/rotatinginformer.rb +10 -10
  42. data/lib/ramaze/request.rb +1 -4
  43. data/lib/ramaze/tool/bin.rb +330 -0
  44. data/lib/ramaze/version.rb +1 -1
  45. data/lib/ramaze/view.rb +3 -13
  46. data/lib/ramaze/view/erubis.rb +2 -2
  47. data/lib/ramaze/view/ezamar.rb +2 -2
  48. data/lib/ramaze/view/gestalt.rb +14 -0
  49. data/lib/ramaze/view/haml.rb +1 -1
  50. data/lib/ramaze/view/liquid.rb +2 -2
  51. data/lib/ramaze/view/maruku.rb +2 -1
  52. data/lib/ramaze/view/sass.rb +1 -1
  53. data/lib/ramaze/view/tenjin.rb +7 -4
  54. data/lib/vendor/route_exceptions.rb +8 -9
  55. data/ramaze.gemspec +6 -3
  56. data/spec/examples/caching.rb +2 -4
  57. data/spec/examples/element.rb +1 -0
  58. data/spec/examples/templates/template_ezamar.rb +1 -0
  59. data/spec/examples/templates/template_nagoro.rb +1 -0
  60. data/spec/ramaze/error.rb +1 -1
  61. data/spec/ramaze/gestalt.rb +22 -16
  62. data/spec/ramaze/helper/cache.rb +29 -1
  63. data/spec/ramaze/helper/localize.rb +10 -8
  64. data/spec/ramaze/helper/sequel_form.rb +2 -0
  65. data/spec/ramaze/helper/user.rb +2 -2
  66. data/spec/ramaze/view/gestalt.rb +94 -0
  67. data/spec/ramaze/view/gestalt/external.ges +8 -0
  68. data/tasks/install_dependencies.rake +1 -1
  69. data/tasks/release.rake +5 -4
  70. data/tasks/setup.rake +3 -23
  71. metadata +29 -11
  72. data/benchmark/suite/template_builder.rb +0 -12
  73. data/examples/helpers/provide.rb +0 -23
  74. data/lib/ramaze/snippets/kernel/constant.rb +0 -41
@@ -0,0 +1,41 @@
1
+ %html
2
+ %head
3
+ %title
4
+ - if @title
5
+ = @title
6
+ %body
7
+ %h1
8
+ - if @h1
9
+ = @h1
10
+ %div
11
+ - if @v1
12
+ - if @v2
13
+ - if @v3
14
+ - if @v4
15
+ - if @v5
16
+ - if @v6
17
+ - if @v7
18
+ - if @v8
19
+ - if @v9
20
+ - if @v10
21
+ - if @v11
22
+ - if @v12
23
+ - if @v13
24
+ - if @v14
25
+ - if @v15
26
+ - if @v16
27
+ - if @v17
28
+ - if @v18
29
+ - if @v19
30
+ - if @v20
31
+ - if @v21
32
+ - if @v22
33
+ - if @v23
34
+ - if @v24
35
+ - if @v25
36
+ - if @v26
37
+ - if @v27
38
+ - if @v28
39
+ - if @v29
40
+ - if @v30
41
+ = stuff
@@ -0,0 +1,79 @@
1
+ <html>
2
+ <head>
3
+ <title>
4
+ <?r if @title ?>
5
+ #{@title}
6
+ <?r end ?>
7
+ </title>
8
+ </head>
9
+ <body>
10
+ <h1>
11
+ <?r if @h1 ?>
12
+ #{@h1}
13
+ <?r end ?>
14
+ </h1>
15
+ <div>
16
+ <?r if @v1 ?>
17
+ <?r if @v2 ?>
18
+ <?r if @v3 ?>
19
+ <?r if @v4 ?>
20
+ <?r if @v5 ?>
21
+ <?r if @v6 ?>
22
+ <?r if @v7 ?>
23
+ <?r if @v8 ?>
24
+ <?r if @v9 ?>
25
+ <?r if @v10 ?>
26
+ <?r if @v11 ?>
27
+ <?r if @v12 ?>
28
+ <?r if @v13 ?>
29
+ <?r if @v14 ?>
30
+ <?r if @v15 ?>
31
+ <?r if @v16 ?>
32
+ <?r if @v17 ?>
33
+ <?r if @v18 ?>
34
+ <?r if @v19 ?>
35
+ <?r if @v20 ?>
36
+ <?r if @v21 ?>
37
+ <?r if @v22 ?>
38
+ <?r if @v23 ?>
39
+ <?r if @v24 ?>
40
+ <?r if @v25 ?>
41
+ <?r if @v26 ?>
42
+ <?r if @v27 ?>
43
+ <?r if @v28 ?>
44
+ <?r if @v29 ?>
45
+ <?r if @v30 ?>
46
+ #{stuff}
47
+ <?r end ?>
48
+ <?r end ?>
49
+ <?r end ?>
50
+ <?r end ?>
51
+ <?r end ?>
52
+ <?r end ?>
53
+ <?r end ?>
54
+ <?r end ?>
55
+ <?r end ?>
56
+ <?r end ?>
57
+ <?r end ?>
58
+ <?r end ?>
59
+ <?r end ?>
60
+ <?r end ?>
61
+ <?r end ?>
62
+ <?r end ?>
63
+ <?r end ?>
64
+ <?r end ?>
65
+ <?r end ?>
66
+ <?r end ?>
67
+ <?r end ?>
68
+ <?r end ?>
69
+ <?r end ?>
70
+ <?r end ?>
71
+ <?r end ?>
72
+ <?r end ?>
73
+ <?r end ?>
74
+ <?r end ?>
75
+ <?r end ?>
76
+ <?r end ?>
77
+ </div>
78
+ </body>
79
+ </html>
@@ -0,0 +1,21 @@
1
+ <html>
2
+ <head>
3
+ <title>
4
+ <% if @title %>
5
+ <%= @title %>
6
+ <% end %>
7
+ </title>
8
+ </head>
9
+ <body>
10
+ <h1>
11
+ <% if @h1 %>
12
+ <%= @h1 %>
13
+ <% end %>
14
+ </h1>
15
+ <div>
16
+ <% if @div %>
17
+ <%= @div %>
18
+ <% end %>
19
+ </div>
20
+ </body>
21
+ </html>
@@ -0,0 +1,12 @@
1
+ %html
2
+ %head
3
+ %title
4
+ - if @title
5
+ = @title
6
+ %body
7
+ %h1
8
+ - if @h1
9
+ = @h1
10
+ %div
11
+ - if @div
12
+ = @div
@@ -0,0 +1,21 @@
1
+ <html>
2
+ <head>
3
+ <title>
4
+ <?r if @title ?>
5
+ #{@title}
6
+ <?r end ?>
7
+ </title>
8
+ </head>
9
+ <body>
10
+ <h1>
11
+ <?r if @h1 ?>
12
+ #{@h1}
13
+ <?r end ?>
14
+ </h1>
15
+ <div>
16
+ <?r if @div ?>
17
+ #{@div}
18
+ <?r end ?>
19
+ </div>
20
+ </body>
21
+ </html>
data/benchmark/run.rb CHANGED
@@ -144,8 +144,8 @@ class RamazeBenchmark
144
144
  end
145
145
 
146
146
  attr_accessor :requests, :adapters, :port, :log, :display_code, :target
147
- attr_accessor :concurrent, :paths, :benchmarker, :informer, :sessions
148
- attr_accessor :show_log, :ignored_tags, :formats
147
+ attr_accessor :concurrent, :paths, :benchmarker, :informer
148
+ attr_accessor :mode, :show_log, :formats
149
149
 
150
150
  def initialize()
151
151
  @adapters = [:webrick]
@@ -157,10 +157,9 @@ class RamazeBenchmark
157
157
  @paths = ["/"]
158
158
  @target = /.+/
159
159
  @informer = true
160
- @sessions = true
161
- @ignored_tags = [:debug, :dev]
162
160
  @formats = ["text"]
163
161
  @writers = []
162
+ @mode = :live
164
163
  yield self
165
164
  end
166
165
 
@@ -175,8 +174,8 @@ class RamazeBenchmark
175
174
  end
176
175
 
177
176
  # benchmarks
178
- __DIR__ = File.expand_path(File.dirname(__FILE__))
179
- Dir[__DIR__('suite/*.rb')].each do |filename|
177
+ glob = File.expand_path('../suite/*.rb', __FILE__)
178
+ Dir.glob(glob) do |filename|
180
179
  @adapters.each do |adapter|
181
180
  @paths.each do |path|
182
181
  benchmark(filename, adapter, path) if @target.match(filename)
@@ -199,7 +198,6 @@ class RamazeBenchmark
199
198
  l :Concurrent, @concurrent
200
199
  l :Path, path
201
200
  l :Informer, @informer
202
- l :Sessions, @sessions
203
201
  if @display_code
204
202
  l :Code, "<code ruby>\n#{File.read(filename)}\n</code>\n\n"
205
203
  end
@@ -248,17 +246,17 @@ class RamazeBenchmark
248
246
  def ramaze(filename, adapter)
249
247
  pid = fork do
250
248
  begin
251
- require filename
252
- Ramaze::Log.ignored_tags = @ignored_tags
249
+ require 'ramaze'
250
+ Ramaze.options.mode = @mode
253
251
  if @informer
254
252
  unless @show_log
255
- Ramaze::Log.loggers = [Ramaze::Logging::Logger::Informer.new("/dev/null")]
253
+ require 'ramaze/log/informer'
254
+ Ramaze::Log.loggers = [Ramaze::Logger::Informer.new("/dev/null")]
256
255
  end
257
256
  else
258
257
  Ramaze::Log.loggers = []
259
258
  end
260
- Ramaze::Global.sessions = @sessions
261
- Ramaze::Global.sourcereload = false
259
+ require filename
262
260
  Ramaze.start :adapter => adapter, :port => @port
263
261
  rescue LoadError => ex; l :Error, ex; end
264
262
  end
@@ -324,23 +322,18 @@ RamazeBenchmark.new do |bm|
324
322
  bm.paths = paths.split(",")
325
323
  end
326
324
 
327
- opt.on('--no-informer', 'Disable informer') do
328
- bm.informer = false
325
+ opt.on('--mode MODE', '[live] Ramaze mode') do |mode|
326
+ bm.mode = mode.to_sym
329
327
  end
330
328
 
331
- opt.on('--ignored-tags TAGS',
332
- '[debug,dev] Specify ignored tags for Ramaze::Log') do |tags|
333
- bm.ignored_tags = tags.split(",").map{|e| e.to_sym }
329
+ opt.on('--no-informer', 'Disable informer') do
330
+ bm.informer = false
334
331
  end
335
332
 
336
333
  opt.on('--show-log', 'Show log') do
337
334
  bm.show_log = true
338
335
  end
339
336
 
340
- opt.on('--no-sessions', 'Disable sessions') do
341
- bm.sessions = false
342
- end
343
-
344
337
  opt.on('--target REGEXP',
345
338
  '[/.+/] Specify benchmark scripts to measure') do |name|
346
339
  bm.target = Regexp.compile(name)
@@ -1,5 +1,3 @@
1
- require 'ramaze'
2
-
3
1
  class MainController < Ramaze::Controller
4
2
  engine :None
5
3
 
@@ -8,6 +6,6 @@ class MainController < Ramaze::Controller
8
6
  end
9
7
  end
10
8
 
11
- Ramaze::Global.sourcereload = false
12
- Ramaze::Global.sessions = false
13
- Ramaze::Log.loggers = []
9
+ Ramaze.middleware!(:bench){|m| m.run(Ramaze::AppMap) }
10
+ Ramaze.options.mode = :bench
11
+ Ramaze::Log.loggers.clear
@@ -1,5 +1,3 @@
1
- require 'ramaze'
2
-
3
1
  class MainController < Ramaze::Controller
4
2
  def index
5
3
  "Hello, World!"
@@ -1,10 +1,9 @@
1
- require 'ramaze'
2
-
3
1
  class MainController < Ramaze::Controller
4
2
  def index
5
3
  "Hello, World!"
6
4
  end
7
5
  end
8
6
 
9
- Ramaze::Log.loggers = []
10
- Ramaze::Global.sessions = false
7
+ Ramaze.middleware!(:nosessions){|m| m.run(Ramaze::AppMap) }
8
+ Ramaze.options.mode = :nosessions
9
+ Ramaze::Log.loggers.clear
@@ -1,9 +1,7 @@
1
- require 'ramaze'
2
-
3
1
  class MainController < Ramaze::Controller
4
2
  engine :None
5
3
 
6
4
  def index
7
5
  "Hello, World!"
8
6
  end
9
- end
7
+ end
@@ -1,7 +1,5 @@
1
- require 'ramaze'
2
-
3
1
  class MainController < Ramaze::Controller
4
2
  def index
5
3
  "Hello, World!"
6
4
  end
7
- end
5
+ end
@@ -1,5 +1,3 @@
1
- require 'ramaze'
2
-
3
1
  class MainController < Ramaze::Controller
4
2
  engine :Erubis
5
3
 
@@ -0,0 +1,8 @@
1
+ class MainController < Ramaze::Controller
2
+ engine :Etanni
3
+
4
+ def index
5
+ @hello = "Hello, World!"
6
+ '<html><body><?r 10.times do ?><span>#{@hello}</span><?r end ?></body></html>'
7
+ end
8
+ end
@@ -1,10 +1,8 @@
1
- require 'ramaze'
2
-
3
1
  class MainController < Ramaze::Controller
4
2
  engine :Ezamar
5
3
 
6
4
  def index
7
5
  @hello = "Hello, World!"
8
- '<html><body><? 10.times do ?><span>#{@hello}</span><?r end ?></body></html>'
6
+ '<html><body><?r 10.times do ?><span>#{@hello}</span><?r end ?></body></html>'
9
7
  end
10
8
  end
@@ -1,5 +1,3 @@
1
- require 'ramaze'
2
-
3
1
  class MainController < Ramaze::Controller
4
2
  engine :Haml
5
3
 
@@ -1,5 +1,3 @@
1
- require 'ramaze'
2
-
3
1
  class MainController < Ramaze::Controller
4
2
  engine :Liquid
5
3
 
@@ -1,5 +1,3 @@
1
- require 'ramaze'
2
-
3
1
  class MainController < Ramaze::Controller
4
2
  engine :Markaby
5
3
  helper :markaby
@@ -1,10 +1,8 @@
1
- require 'ramaze'
2
-
3
1
  class MainController < Ramaze::Controller
4
2
  engine :Nagoro
5
3
 
6
4
  def index
7
5
  @hello = "Hello, World!"
8
- '<html><body><span times=10>#{@hello}</span></body></html>'
6
+ '<html><body><span times="10">#{@hello}</span></body></html>'
9
7
  end
10
8
  end
@@ -1,5 +1,3 @@
1
- require 'ramaze'
2
-
3
1
  class MainController < Ramaze::Controller
4
2
  engine :RedCloth
5
3
  layout :layout
@@ -1,5 +1,3 @@
1
- require 'ramaze'
2
-
3
1
  class MainController < Ramaze::Controller
4
2
  engine :Tenjin
5
3
 
data/bin/ramaze CHANGED
@@ -1,249 +1,10 @@
1
1
  #!/usr/bin/env ruby
2
-
3
- def include_ramaze
4
- begin
5
- $:.unshift File.join(File.dirname(__FILE__), '/../lib')
6
- require 'ramaze'
7
- rescue LoadError
8
- $:.shift
9
-
10
- begin
11
- require 'rubygems'
12
- rescue LoadError
13
- end
14
- require 'ramaze'
15
- end
16
- end
17
-
18
- def usage
19
- <<-TXT
20
- Usage:
21
-
22
- ramaze <start [PIDFILE]|stop [PIDFILE]|restart [PIDFILE]|status [PIDFILE]|create PROJECT|console> [ruby/rack options]
23
-
24
- Commands:
25
- * All commands which take an optional PIDFILE default to PROJECT.pid if you do not supply one.
26
- * All commands which start a ramaze instance will default to webrick on port 7000 unless you supply
27
- the rack options -p/--port PORT and/or * -s/--server SERVER.
28
-
29
- start - Starts an instance of this application.
30
-
31
- stop - Stops a running instance of this application.
32
-
33
- restart - Stops running instance of this application, then starts it back up. Pidfile
34
- (if supplied) is used for both stop and start.
35
-
36
- status - Gives status of a running ramaze instance
37
-
38
- create - Creates a new prototype Ramaze application in a directory named PROJECT in
39
- the current directory. ramaze create foo would make ./foo containing an
40
- application prototype. Rack options are ignored here.
41
-
42
- console - Starts an irb console with app.rb (and irb completion) loaded. This command
43
- ignores rack options, ARGV is passed on to IRB.
44
-
45
- Rack Options
46
- #{%x{rackup --help}.split("\n").reject { |line| line.match(/^Usage:/) }.join("\n\t")}
47
- TXT
48
- end
49
-
50
- ## Methods for commands {{{
51
- def start
52
- # Find the name of this app
53
- app_name = default_pidfile.sub(/\.pid$/,'')
54
- added_args = []
55
- if daemonize = OURARGS.detect { |arg| arg.match(/^(-[dD]|--daemonize)$/) }
56
- if pid_arg = OURARGS.detect { |arg| arg.match(/^(-P|--pid)/) }
57
- puts "User supplied pid: #{pid_arg}"
58
- pid_file = OURARGS[OURARGS.index(pid_arg) + 1]
59
- puts "Starting daemon with user defined pidfile: #{pid_file}"
60
- else
61
- puts "Starting daemon with default pidfile: #{pid_file = default_pidfile}"
62
- added_args += ["-P", pid_file]
63
- end
64
- if check_running?(pid_file)
65
- $stderr.puts "Ramaze is already running with pidfile: #{pid_file}"
66
- exit 127
67
- end
68
- end
69
- added_args += ["-p", "7000"] unless OURARGS.detect { |arg| arg.match(/^(-p|--port)/) }
70
- added_args += ["-s", "webrick"] unless OURARGS.detect { |arg| arg.match(/^(-s|--server)/) }
71
- exec("rackup", "config.ru", *(ARGV + added_args))
72
- end
73
-
74
- def create(command)
75
- project_name = OURARGS[OURARGS.index(command) + 1]
76
- if project_name.nil?
77
- $stderr.puts "Must supply a project name" if project_name.nil?
78
- puts usage
79
- exit 1
80
- end
81
- opts = {}
82
- if OURARGS.detect { |arg| arg.match(/^(--force)/) }
83
- puts "Overwriting any existing files as requested."
84
- opts[:force] = true
85
- end
86
- if OURARGS.detect { |arg| arg.match(/^(--amend)/) }
87
- puts "Only amending missing files as requested."
88
- opts[:amend] = true
89
- end
90
- include_ramaze
91
- require 'ramaze/tool/create'
92
- Ramaze::Tool::Create.create(project_name, opts)
93
- end
94
-
95
- def stop(command)
96
- unless pid_file = find_pid(OURARGS[OURARGS.index(command) + 1])
97
- $stderr.puts "No pid_file found! Cannot stop ramaze (may not be started)."
98
- return false
99
- end
100
- pid = File.read(pid_file).to_i
101
- puts "Stopping pid #{pid}"
102
- Process.kill("INT", pid)
103
- sleep 2
104
- if is_running?(pid)
105
- $stderr.puts "Process #{pid} did not die, forcing it with -9"
106
- Process.kill(9, pid)
107
- File.unlink(pid_file) if File.file?(pid_file)
108
- true
109
- else
110
- File.unlink(pid_file) if File.file?(pid_file)
111
- true
112
- end
113
- end
114
-
115
- def status(command)
116
- unless pid_file = find_pid(OURARGS[OURARGS.index(command) + 1])
117
- $stderr.puts "No pid_file found! Ramaze may not be started."
118
- exit 1
119
- end
120
- puts "Pid file #{pid_file} found, PID is #{pid = File.read(pid_file)}"
121
- unless is_running?(pid.to_i)
122
- $stderr.puts "PID #{pid} is not running"
123
- exit 1
124
- end
125
- if Object.const_defined?("WIN32OLE")
126
- wmi = WIN32OLE.connect("winmgmts://")
127
- processes, ours = wmi.ExecQuery("select * from win32_process where ProcessId = #{pid}"), []
128
- processes.each { |p| ours << [p.Name, p.CommandLine, p.VirtualSize, p.CreationDate, p.ExecutablePath, p.Status ] }
129
- puts "Ramaze is running!\n\tName: %s\n\tCommand Line: %s\n\tVirtual Size: %s\n\tStarted: %s\n\tExec Path: %s\n\tStatus: %s" % ours.first
130
- else
131
- require "pathname"
132
- # Check for /proc
133
- if File.directory?(proc_dir = Pathname.new("/proc"))
134
- proc_dir = proc_dir.join(pid)
135
- # If we have a "stat" file, we'll assume linux and get as much info
136
- # as we can
137
- if File.file?(stat_file = proc_dir.join("stat"))
138
- stats = File.read(stat_file).split
139
- puts "Ramaze is running!\n\tCommand Line: %s\n\tVirtual Size: %s\n\tStarted: %s\n\tExec Path: %s\n\tStatus: %s" % [
140
- File.read(proc_dir.join("cmdline")).split("\000").join(" "),
141
- "%s k" % (stats[22].to_f / 1024),
142
- File.mtime(proc_dir),
143
- File.readlink(proc_dir.join("exe")),
144
- stats[2]
145
- ]
146
- exit
147
- end
148
- end
149
- # Fallthrough status, just print a ps
150
- puts "Ramaze process #{pid} is running!"
151
- begin
152
- puts %x{ps l #{pid}}
153
- rescue
154
- puts "No further information available"
155
- end
156
- end
157
- end
158
-
159
- ## End Command methods }}}
160
-
161
- # Helper methods {{{
162
- def default_pidfile
163
- return @default_pidfile if @default_pidfile
164
- @default_pidfile = (File.basename(File.expand_path(ENV["PWD"])) + ".pid").strip
165
- end
166
-
167
- def is_running?(pid)
168
- if Object.const_defined?("WIN32OLE")
169
- wmi = WIN32OLE.connect("winmgmts://")
170
- processes, ours = wmi.ExecQuery("select * from win32_process where ProcessId = #{pid}"), []
171
- processes.each { |process| ours << process.Name }
172
- ours.first.nil?
173
- else
174
- begin
175
- prio = Process.getpriority(Process::PRIO_PROCESS, pid)
176
- true
177
- rescue Errno::ESRCH
178
- false
179
- end
180
- end
181
- end
182
-
183
- def check_running?(pid_file)
184
- return false unless File.file?(pid_file)
185
- is_running?(File.read(pid_file).to_i)
186
- end
187
-
188
- def find_pid(pid_file)
189
- if pid_file.nil? or not File.file?(pid_file)
190
- pid_file = default_pidfile
191
- end
192
- unless File.file?(pid_file)
193
- $stderr.puts "Could not find running process id."
194
- return false
195
- end
196
- pid_file
197
- end
198
-
199
- ## End helper methods }}}
200
-
201
- OURARGS = ARGV.dup
202
- command = ARGV.detect { |arg| arg.match(/^(?:--?)?(?:start|stop|restart|create|h(?:elp)?|v(?:ersion)?|console|status)/) }
203
- if command.nil?
204
- command = ""
205
- else
206
- ARGV.delete(command)
207
- end
208
-
209
- case command
210
- when /^(?:--?)?status$/
211
- status(command)
212
- when /^(?:--?)?restart$/
213
- stop(command)
214
- start
215
- when /^(?:--?)?start$/
216
- start
217
- when /^(?:--?)?create$/
218
- create(command)
219
- when /^(?:--?)?stop$/
220
- if stop(command)
221
- puts "Ramazement has ended, go in peace."
222
- $stdout.flush
223
- else
224
- puts "Ramaze failed to stop (or was not running)"
225
- end
226
- when /^(?:--?)?console$/
227
- require "ramaze"
228
- require "irb"
229
- require "irb/completion"
230
- Ramaze.options.started = true
231
- require "start"
232
- IRB.start
233
- puts "Ramazement has ended, go in peace."
234
- when /^(?:--?)?h(elp)?$/
235
- puts usage
236
- when /^(?:--?)?v(ersion)?$/
237
- include_ramaze
238
- puts Ramaze::VERSION
239
- exit
240
- when /^$/
241
- puts "Must supply a valid command"
242
- puts usage
243
- exit 1
244
- else
245
- puts "#{command} not implemented"
246
- puts usage
247
- exit 1
248
- end
249
-
2
+ begin
3
+ require "pathname"
4
+ require Pathname.new(__FILE__).expand_path.dirname.join("..", "lib", "ramaze")
5
+ require "ramaze/bin_ramaze"
6
+ rescue LoadError
7
+ require "rubygems"
8
+ require "ramaze/tool/bin"
9
+ end
10
+ Ramaze::Tool::Bin::Cmd.run(ARGV)