GitHub Sale: sign up for any paid plan this week and pay nothing until January 1, 2009!  [ hide ]

public
Rubygem
Description: Resource-oriented open source Ruby framework for Web apps.
Homepage: http://rubywaves.com/
Clone URL: git://github.com/dyoder/waves.git
Streamlined Mapping#satisfy and fixed related bug for matching request 
method. Also, fixed mapping test suite.
dyoder (author)
Wed Mar 26 22:41:52 -0700 2008
commit  5d31c85c6975ac756fec0120b8ffe3a293737d62
tree    b7e04b20b2551a8367b61dcf6426a13fa82d7e2b
parent  476c773d171c4c303462e84beadffd8781184d2f
...
2
3
4
 
 
5
6
7
...
2
3
4
5
6
7
8
9
0
@@ -2,6 +2,8 @@
0
 if File.exist?(waves_src = File.join(File.dirname(__FILE__), 'waves'))
0
   $:.unshift(File.join(waves_src, 'lib'))
0
   USE_WAVES_SRC = true
0
+else
0
+ USE_WAVES_SRC = false
0
 end
0
 
0
 begin
...
135
136
137
 
138
139
140
...
168
169
170
171
 
172
173
174
...
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
 
 
 
 
 
 
 
204
205
206
...
135
136
137
138
139
140
141
...
169
170
171
 
172
173
174
175
...
179
180
181
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
182
183
184
185
186
187
188
189
190
191
0
@@ -135,6 +135,7 @@ module Waves
0
     # Match the given request against the defined rules. This is typically only called
0
     # by a dispatcher object, so you shouldn't typically use it directly.
0
     def []( request )
0
+
0
       rx = { :before => [], :after => [], :action => nil }
0
       
0
       ( filters[:before] + filters[:wrap] ).each do | options, function |
0
@@ -168,7 +169,7 @@ module Waves
0
     end
0
     
0
     def match ( request, options, function )
0
- return nil if !options || !satisfy( request, options )
0
+ return nil unless satisfy( request, options )
0
      if options[:path]
0
      matches = options[:path].match( request.path )
0
    elsif options[:url]
0
@@ -178,29 +179,13 @@ module Waves
0
    end
0
   
0
     def satisfy( request, options )
0
- options.each do |method, param|
0
- begin
0
- value = request.send( method )
0
- rescue NoMethodError
0
- if method =~ %r{^rack\.}
0
- value = request.env[method.to_s.downcase]
0
- else
0
- value = request.env[method.to_s.upcase]
0
- end
0
- end
0
- if param.nil?
0
- return false unless value.nil?
0
- elsif value.nil?
0
- return false
0
- elsif param.is_a? Regexp
0
- return false unless value.to_s =~ param
0
- else
0
- return false unless value.to_s == param
0
- end
0
- end
0
- return true
0
- end
0
-
0
+ options.nil? or options.all? do |name,wanted|
0
+ got = request.send( name ) rescue request.env[ ( name =~ /^rack\./ ) ?
0
+ name.to_s.downcase : name.to_s.upcase ]
0
+ ( ( wanted.is_a?(Regexp) && wanted.match( got.to_s ) ) or
0
+ got.to_s == wanted.to_s ) unless ( wanted.nil? or got.nil? )
0
+ end
0
+ end
0
   end
0
 
0
 end
...
1
2
3
 
 
 
4
5
6
7
8
 
9
10
11
...
19
20
21
22
23
24
25
26
27
28
...
1
2
3
4
5
6
7
8
9
10
 
11
12
13
14
...
22
23
24
 
 
 
 
 
25
26
0
@@ -1,11 +1,14 @@
0
 #!/usr/bin/env ruby
0
 if File.exist?(waves_src = File.join(File.dirname(__FILE__), 'waves'))
0
   $:.unshift(File.join(waves_src, 'lib'))
0
+ USE_WAVES_SRC = true
0
+else
0
+ USE_WAVES_SRC = false
0
 end
0
 
0
 begin
0
   require 'waves'
0
- Waves::Console.load
0
+ Waves::Console.load(:mode => ENV['mode'])
0
   %w( schema cluster generate ).each { |task| require "lib/tasks/#{task}.rb" }
0
 rescue LoadError
0
   puts "Can't find waves gem or ./waves/lib directory. try rake symlink waves=/path/to/waves/"
0
@@ -19,9 +22,4 @@ task :symlink do
0
   bindir = File.join(waves, 'bin')
0
   system(cmd = "ln -s #{libdir} waves/") && puts(cmd)
0
   system(cmd = "ln -s #{bindir} waves/") && puts(cmd)
0
-end
0
-
0
-task :verify => :'cluster:restart' do
0
- specs = Dir[ :verify / :spec / '*.rb' ]
0
- `specrb -r../helpers #{specs.join(' ')} --rdox > doc/SPEC`
0
 end
0
\ No newline at end of file
...
2
3
4
 
5
6
 
7
8
9
10
11
12
13
14
 
 
15
16
17
...
2
3
4
5
6
 
7
8
9
10
11
12
13
 
 
14
15
16
17
18
0
@@ -2,16 +2,17 @@ namespace :cluster do
0
 
0
   desc 'Start a cluster of waves applications.'
0
   task :start do |task|
0
+ script = USE_WAVES_SRC ? 'bin/waves-server' : 'waves-server'
0
     ( Waves::Console.config.ports || [ Waves::Console.config.port ] ).each do |port|
0
- cmd = "./bin/waves-server -p #{port} -c #{ENV['mode']||'development'} -d"
0
+ cmd = "#{script} -p #{port} -c #{ENV['mode']||'development'} -d"
0
       puts cmd ; `#{cmd}`
0
     end
0
   end
0
   
0
   desc 'Stop a cluster of waves applications.'
0
   task :stop do |task|
0
- Dir[ :log / '*.pid' ].each do |path|
0
- pid = File.basename(path,'.pid').to_i
0
+ Dir[ :log / '*.pid' ].each do |pidfile|
0
+ pid = File.read(pidfile).to_i
0
      puts "Stopping process #{pid} ..."
0
      Process.kill( 'INT', pid ) rescue nil
0
     end

Comments

    No one has commented yet.