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
accepts thingies now match * wildcards
automatthew (author)
Tue Jul 22 17:25:20 -0700 2008
commit  64d828e9cedcd56c5ade94ce9a4c9563fc9a0eab
tree    8132e316617f25498e459635558c28f3e4939c78
parent  471bd18f8afc6bbe7616bbb0ff30375ceb3e1e8c
...
70
71
72
73
74
 
 
75
76
77
78
79
 
 
 
 
 
 
 
 
 
 
80
81
82
83
 
84
85
86
...
70
71
72
 
 
73
74
75
76
77
78
 
79
80
81
82
83
84
85
86
87
88
89
90
91
 
92
93
94
95
0
@@ -70,17 +70,26 @@ module Waves
0
         self.include? arg
0
       end
0
       
0
- def ===(other)
0
- self =~ other || super
0
+ def ===(arg)
0
+ self.include? arg
0
       end
0
       
0
       # try the normal include?, then if the arg is a Regexp, see if anything matches
0
       def include?(arg)
0
- super || (self.any? { |item| item =~ arg } if arg.is_a? Regexp ) || false
0
+ super || self.any? do |entry|
0
+ return true if entry == '*/*' || entry == '*' || arg === entry
0
+ if entry.match('\*') && arg.respond_to?(:split)
0
+ a, e = arg.split('/'), entry.split('/')
0
+ return true if e[0] == '*' && a[1] == e[1]
0
+ return true if e[1] == '*' && a[0] == e[0]
0
+ else
0
+ false
0
+ end
0
+ end
0
       end
0
       
0
       def self.parse(string)
0
- string.split(',').inject(self.new) { |a, entry| a << entry.split( ';' ).first; a }
0
+ string.split(',').inject(self.new) { |a, entry| a << entry.split( ';' ).first.strip; a }
0
       end
0
       
0
     end
...
5
6
7
8
9
10
11
12
 
13
14
15
...
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
...
5
6
7
 
 
 
 
 
8
9
10
11
...
29
30
31
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
32
33
34
0
@@ -5,11 +5,7 @@ describe "A Waves request instance" do
0
   
0
   before do
0
     Waves::Session.stub!(:base_path).and_return(BasePath)
0
- @request = Waves::Request.new(env_for("/",
0
- 'HTTP_ACCEPT' => 'text/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5',
0
- 'HTTP_ACCEPT_CHARSET' => 'ISO-8859-1,utf-8;q=0.7,*;q=0.7',
0
- 'HTTP_ACCEPT_LANGUAGE' => 'en-us,en;q=0.5'
0
- ))
0
+ @request = Waves::Request.new(env_for("/"))
0
   end
0
   
0
   it "has session, response, and blackboard objects" do
0
@@ -33,34 +29,6 @@ describe "A Waves request instance" do
0
     @request.content_type
0
   end
0
   
0
- it "parses the Accept header for content-types" do
0
- entries = ["text/xml", "application/xhtml+xml", "text/html", "text/plain", "image/png", "*/*"]
0
-
0
- @request.accept.should == entries
0
- (@request.accept =~ "text/xml").should == true
0
- (@request.accept === "text/xml").should == true
0
- (@request.accept =~ "text/bogus").should == false
0
- end
0
-
0
- it "parses the Accept-Charset header for character sets" do
0
- charsets = [ "ISO-8859-1", "utf-8", "*" ]
0
-
0
- @request.accept_charset.should == charsets
0
- (@request.accept_charset =~ "utf-8").should == true
0
- (@request.accept_charset === "utf-8").should == true
0
- (@request.accept_charset =~ "utf-16").should == false
0
- end
0
-
0
- it "parses the Accept-Language header for languages" do
0
- languages = [ "en-us", "en" ]
0
-
0
- @request.accept_language.should == languages
0
- (@request.accept_language =~ "en-us").should == true
0
- (@request.accept_language =~ /en/ ).should == true
0
- (@request.accept_language =~ /ru/ ).should == false
0
- (@request.accept_language === "en-us").should == true
0
- (@request.accept_language =~ "ru").should == false
0
- end
0
   
0
   # ** API CHANGE. figure out what changed and fix the tests **
0
   # it "delegates unknown methods to the Rack request" do

Comments

    No one has commented yet.