rack-accept 0.4.3 → 0.4.4
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/rack/accept.rb +0 -7
- data/lib/rack/accept/header.rb +1 -1
- data/lib/rack/accept/version.rb +10 -0
- data/rack-accept.gemspec +6 -2
- data/test/media_type_test.rb +13 -0
- metadata +5 -22
data/lib/rack/accept.rb
CHANGED
@@ -4,13 +4,6 @@ require 'rack'
|
|
4
4
|
#
|
5
5
|
# http://mjijackson.com/rack-accept
|
6
6
|
module Rack::Accept
|
7
|
-
VERSION = [0, 4, 3]
|
8
|
-
|
9
|
-
# Returns the current version of Rack::Accept as a string.
|
10
|
-
def self.version
|
11
|
-
VERSION.join('.')
|
12
|
-
end
|
13
|
-
|
14
7
|
# Enables Rack::Accept to be used as a Rack middleware.
|
15
8
|
def self.new(app, &block)
|
16
9
|
Context.new(app, &block)
|
data/lib/rack/accept/header.rb
CHANGED
@@ -38,7 +38,7 @@ module Rack::Accept
|
|
38
38
|
# subtype, and 3) the media type parameters. An empty array is returned if
|
39
39
|
# no match can be made.
|
40
40
|
def parse_media_type(media_type)
|
41
|
-
m = media_type.to_s.match(/^([a-z*]+)\/([a-
|
41
|
+
m = media_type.to_s.match(/^([a-z*]+)\/([a-z0-9*\-.+]+)(?:;([a-z0-9=;]+))?$/)
|
42
42
|
m ? [m[1], m[2], m[3] || ''] : []
|
43
43
|
end
|
44
44
|
module_function :parse_media_type
|
data/rack-accept.gemspec
CHANGED
@@ -1,7 +1,11 @@
|
|
1
|
+
$LOAD_PATH.unshift(File.expand_path('../lib', __FILE__))
|
2
|
+
|
3
|
+
require 'rack/accept/version'
|
4
|
+
|
1
5
|
Gem::Specification.new do |s|
|
2
6
|
s.name = 'rack-accept'
|
3
|
-
s.version =
|
4
|
-
s.date = '
|
7
|
+
s.version = Rack::Accept.version
|
8
|
+
s.date = Time.now.strftime('%Y-%m-%d')
|
5
9
|
|
6
10
|
s.summary = 'HTTP Accept* for Ruby/Rack'
|
7
11
|
s.description = 'HTTP Accept, Accept-Charset, Accept-Encoding, and Accept-Language for Ruby/Rack'
|
data/test/media_type_test.rb
CHANGED
@@ -42,4 +42,17 @@ class MediaTypeTest < Test::Unit::TestCase
|
|
42
42
|
m = M.new('text/*;q=0.5;a=42')
|
43
43
|
assert_equal(0.5, m.qvalue('text/plain'))
|
44
44
|
end
|
45
|
+
|
46
|
+
def test_vendored_types
|
47
|
+
m = M.new("application/vnd.ms-excel")
|
48
|
+
assert_equal(nil, m.best_of(%w< application/vnd.ms-powerpoint >))
|
49
|
+
|
50
|
+
m = M.new("application/vnd.api-v1+json")
|
51
|
+
assert_equal(false, m.accept?("application/vnd.api-v2+json"))
|
52
|
+
|
53
|
+
v1, v2 = "application/vnd.api-v1+json", "application/vnd.api-v2+json"
|
54
|
+
m = M.new("#{v1},#{v2}")
|
55
|
+
assert_equal(v1, m.best_of([v1, v2]))
|
56
|
+
assert_equal(v2, m.best_of([v2, v1]))
|
57
|
+
end
|
45
58
|
end
|
metadata
CHANGED
@@ -1,13 +1,8 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rack-accept
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
|
5
|
-
|
6
|
-
segments:
|
7
|
-
- 0
|
8
|
-
- 4
|
9
|
-
- 3
|
10
|
-
version: 0.4.3
|
4
|
+
prerelease:
|
5
|
+
version: 0.4.4
|
11
6
|
platform: ruby
|
12
7
|
authors:
|
13
8
|
- Michael Jackson
|
@@ -15,7 +10,7 @@ autorequire:
|
|
15
10
|
bindir: bin
|
16
11
|
cert_chain: []
|
17
12
|
|
18
|
-
date:
|
13
|
+
date: 2011-05-03 00:00:00 -07:00
|
19
14
|
default_executable:
|
20
15
|
dependencies:
|
21
16
|
- !ruby/object:Gem::Dependency
|
@@ -26,10 +21,6 @@ dependencies:
|
|
26
21
|
requirements:
|
27
22
|
- - ">="
|
28
23
|
- !ruby/object:Gem::Version
|
29
|
-
hash: 3
|
30
|
-
segments:
|
31
|
-
- 0
|
32
|
-
- 4
|
33
24
|
version: "0.4"
|
34
25
|
type: :runtime
|
35
26
|
version_requirements: *id001
|
@@ -41,9 +32,6 @@ dependencies:
|
|
41
32
|
requirements:
|
42
33
|
- - ">="
|
43
34
|
- !ruby/object:Gem::Version
|
44
|
-
hash: 3
|
45
|
-
segments:
|
46
|
-
- 0
|
47
35
|
version: "0"
|
48
36
|
type: :development
|
49
37
|
version_requirements: *id002
|
@@ -68,6 +56,7 @@ files:
|
|
68
56
|
- lib/rack/accept/media_type.rb
|
69
57
|
- lib/rack/accept/request.rb
|
70
58
|
- lib/rack/accept/response.rb
|
59
|
+
- lib/rack/accept/version.rb
|
71
60
|
- lib/rack/accept.rb
|
72
61
|
- test/charset_test.rb
|
73
62
|
- test/context_test.rb
|
@@ -100,23 +89,17 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
100
89
|
requirements:
|
101
90
|
- - ">="
|
102
91
|
- !ruby/object:Gem::Version
|
103
|
-
hash: 3
|
104
|
-
segments:
|
105
|
-
- 0
|
106
92
|
version: "0"
|
107
93
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
108
94
|
none: false
|
109
95
|
requirements:
|
110
96
|
- - ">="
|
111
97
|
- !ruby/object:Gem::Version
|
112
|
-
hash: 3
|
113
|
-
segments:
|
114
|
-
- 0
|
115
98
|
version: "0"
|
116
99
|
requirements: []
|
117
100
|
|
118
101
|
rubyforge_project:
|
119
|
-
rubygems_version: 1.
|
102
|
+
rubygems_version: 1.6.2
|
120
103
|
signing_key:
|
121
104
|
specification_version: 3
|
122
105
|
summary: HTTP Accept* for Ruby/Rack
|