rack-accept 0.4.1 → 0.4.2
Sign up to get free protection for your applications and to get access to all the features.
- data/README +2 -2
- data/Rakefile +3 -3
- data/doc/usage.markdown +1 -1
- data/lib/rack/accept.rb +5 -5
- data/lib/rack/accept/charset.rb +1 -2
- data/lib/rack/accept/encoding.rb +1 -2
- data/lib/rack/accept/header.rb +2 -2
- data/lib/rack/accept/language.rb +1 -2
- data/lib/rack/accept/media_type.rb +12 -2
- data/{.gemspec → rack-accept.gemspec} +5 -5
- data/test/media_type_test.rb +5 -0
- metadata +6 -6
data/README
CHANGED
@@ -31,7 +31,7 @@ Usage
|
|
31
31
|
Rack::Accept implements the Rack middleware interface and may be used with any
|
32
32
|
Rack-based application. Simply insert the Rack::Accept module in your Rack
|
33
33
|
middleware pipeline and access the Rack::Accept::Request object in the
|
34
|
-
"rack-accept.request" environment key, as in the following example
|
34
|
+
"rack-accept.request" environment key, as in the following example.
|
35
35
|
|
36
36
|
require 'rack/accept'
|
37
37
|
|
@@ -105,7 +105,7 @@ Four-letter Words
|
|
105
105
|
License
|
106
106
|
-------
|
107
107
|
|
108
|
-
Copyright 2010 Michael
|
108
|
+
Copyright 2010 Michael Jackson
|
109
109
|
|
110
110
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
111
111
|
of this software and associated documentation files (the "Software"), to deal
|
data/Rakefile
CHANGED
@@ -49,16 +49,16 @@ end
|
|
49
49
|
# PACKAGING & INSTALLATION ####################################################
|
50
50
|
|
51
51
|
if defined?(Gem)
|
52
|
-
$spec = eval("#{File.read('.gemspec')}")
|
52
|
+
$spec = eval("#{File.read('rack-accept.gemspec')}")
|
53
53
|
|
54
54
|
directory 'dist'
|
55
55
|
|
56
56
|
def package(ext='')
|
57
|
-
"dist
|
57
|
+
"dist/#{$spec.name}-#{$spec.version}" + ext
|
58
58
|
end
|
59
59
|
|
60
60
|
file package('.gem') => %w< dist > + $spec.files do |f|
|
61
|
-
sh "gem build .gemspec"
|
61
|
+
sh "gem build rack-accept.gemspec"
|
62
62
|
mv File.basename(f.name), f.name
|
63
63
|
end
|
64
64
|
|
data/doc/usage.markdown
CHANGED
@@ -4,7 +4,7 @@ Usage
|
|
4
4
|
Rack::Accept implements the Rack middleware interface and may be used with any
|
5
5
|
Rack-based application. Simply insert the Rack::Accept module in your Rack
|
6
6
|
middleware pipeline and access the [Request][req] object in the
|
7
|
-
"rack-accept.request" environment key, as in the following example
|
7
|
+
"rack-accept.request" environment key, as in the following example.
|
8
8
|
|
9
9
|
require 'rack/accept'
|
10
10
|
|
data/lib/rack/accept.rb
CHANGED
@@ -1,11 +1,12 @@
|
|
1
1
|
require 'rack'
|
2
2
|
|
3
|
+
# HTTP Accept* for Ruby/Rack.
|
4
|
+
#
|
5
|
+
# http://mjijackson.com/rack-accept
|
3
6
|
module Rack::Accept
|
7
|
+
VERSION = [0, 4, 2]
|
4
8
|
|
5
|
-
#
|
6
|
-
VERSION = [0, 4, 1]
|
7
|
-
|
8
|
-
# Returns the current version of rack-accept as a string.
|
9
|
+
# Returns the current version of Rack::Accept as a string.
|
9
10
|
def self.version
|
10
11
|
VERSION.join('.')
|
11
12
|
end
|
@@ -23,5 +24,4 @@ module Rack::Accept
|
|
23
24
|
autoload :MediaType, 'rack/accept/media_type'
|
24
25
|
autoload :Request, 'rack/accept/request'
|
25
26
|
autoload :Response, 'rack/accept/response'
|
26
|
-
|
27
27
|
end
|
data/lib/rack/accept/charset.rb
CHANGED
@@ -4,8 +4,7 @@ module Rack::Accept
|
|
4
4
|
# specification, and provides several convenience methods for determining
|
5
5
|
# acceptable character sets.
|
6
6
|
#
|
7
|
-
#
|
8
|
-
# information.
|
7
|
+
# http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.2
|
9
8
|
class Charset
|
10
9
|
|
11
10
|
include Header
|
data/lib/rack/accept/encoding.rb
CHANGED
@@ -4,8 +4,7 @@ module Rack::Accept
|
|
4
4
|
# specification, and provides several convenience methods for determining
|
5
5
|
# acceptable content encodings.
|
6
6
|
#
|
7
|
-
#
|
8
|
-
# information.
|
7
|
+
# http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.3
|
9
8
|
class Encoding
|
10
9
|
|
11
10
|
include Header
|
data/lib/rack/accept/header.rb
CHANGED
@@ -12,8 +12,8 @@ module Rack::Accept
|
|
12
12
|
def parse(header)
|
13
13
|
qvalues = {}
|
14
14
|
|
15
|
-
header.to_s.split(/,\s*/).
|
16
|
-
m = /^([^\s,]+?)(
|
15
|
+
header.to_s.split(/,\s*/).each do |part|
|
16
|
+
m = /^([^\s,]+?)(?:\s*;\s*q\s*=\s*(\d+(?:\.\d+)?))?$/.match(part)
|
17
17
|
|
18
18
|
if m
|
19
19
|
qvalues[m[1]] = normalize_qvalue((m[2] || 1).to_f)
|
data/lib/rack/accept/language.rb
CHANGED
@@ -4,8 +4,7 @@ module Rack::Accept
|
|
4
4
|
# specification, and provides several convenience methods for determining
|
5
5
|
# acceptable content languages.
|
6
6
|
#
|
7
|
-
#
|
8
|
-
# information.
|
7
|
+
# http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.4
|
9
8
|
class Language
|
10
9
|
|
11
10
|
include Header
|
@@ -4,8 +4,7 @@ module Rack::Accept
|
|
4
4
|
# and provides several convenience methods for determining acceptable media
|
5
5
|
# types.
|
6
6
|
#
|
7
|
-
#
|
8
|
-
# information.
|
7
|
+
# http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.1
|
9
8
|
class MediaType
|
10
9
|
|
11
10
|
include Header
|
@@ -42,6 +41,16 @@ module Rack::Accept
|
|
42
41
|
|
43
42
|
private
|
44
43
|
|
44
|
+
def initialize(header)
|
45
|
+
# Strip accept-extension for now. We may want to do something with this
|
46
|
+
# later if people actually start to use it.
|
47
|
+
header = header.to_s.split(/,\s*/).map {|part|
|
48
|
+
part.sub(/(;\s*q\s*=\s*[\d.]+).*$/, '\1')
|
49
|
+
}.join(', ')
|
50
|
+
|
51
|
+
super(header)
|
52
|
+
end
|
53
|
+
|
45
54
|
# Returns true if all parameters and values in +match+ are also present in
|
46
55
|
# +params+.
|
47
56
|
def params_match?(params, match)
|
@@ -49,5 +58,6 @@ module Rack::Accept
|
|
49
58
|
parsed = parse_range_params(params)
|
50
59
|
parsed == parsed.merge(parse_range_params(match))
|
51
60
|
end
|
61
|
+
|
52
62
|
end
|
53
63
|
end
|
@@ -1,12 +1,12 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
s.name = 'rack-accept'
|
3
|
-
s.version = '0.4.
|
4
|
-
s.date = '2010-04
|
3
|
+
s.version = '0.4.2'
|
4
|
+
s.date = '2010-05-04'
|
5
5
|
|
6
6
|
s.summary = 'HTTP Accept* for Ruby/Rack'
|
7
7
|
s.description = 'HTTP Accept, Accept-Charset, Accept-Encoding, and Accept-Language for Ruby/Rack'
|
8
8
|
|
9
|
-
s.author = 'Michael
|
9
|
+
s.author = 'Michael Jackson'
|
10
10
|
s.email = 'mjijackson@gmail.com'
|
11
11
|
|
12
12
|
s.require_paths = %w< lib >
|
@@ -14,7 +14,7 @@ Gem::Specification.new do |s|
|
|
14
14
|
s.files = Dir['lib/**/*.rb'] +
|
15
15
|
Dir['test/*.rb'] +
|
16
16
|
Dir['doc/**/*'] +
|
17
|
-
%w< CHANGES .gemspec Rakefile README >
|
17
|
+
%w< CHANGES rack-accept.gemspec Rakefile README >
|
18
18
|
|
19
19
|
s.test_files = s.files.select {|path| path =~ /^test\/.*_test.rb/ }
|
20
20
|
|
@@ -25,5 +25,5 @@ Gem::Specification.new do |s|
|
|
25
25
|
s.rdoc_options = %w< --line-numbers --inline-source --title Rack::Accept --main Rack::Accept >
|
26
26
|
s.extra_rdoc_files = %w< CHANGES README >
|
27
27
|
|
28
|
-
s.homepage = 'http://mjijackson.
|
28
|
+
s.homepage = 'http://mjijackson.com/rack-accept'
|
29
29
|
end
|
data/test/media_type_test.rb
CHANGED
metadata
CHANGED
@@ -5,16 +5,16 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 4
|
8
|
-
-
|
9
|
-
version: 0.4.
|
8
|
+
- 2
|
9
|
+
version: 0.4.2
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
|
-
- Michael
|
12
|
+
- Michael Jackson
|
13
13
|
autorequire:
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2010-04
|
17
|
+
date: 2010-05-04 00:00:00 -06:00
|
18
18
|
default_executable:
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
@@ -75,11 +75,11 @@ files:
|
|
75
75
|
- doc/license.markdown
|
76
76
|
- doc/usage.markdown
|
77
77
|
- CHANGES
|
78
|
-
- .gemspec
|
78
|
+
- rack-accept.gemspec
|
79
79
|
- Rakefile
|
80
80
|
- README
|
81
81
|
has_rdoc: true
|
82
|
-
homepage: http://mjijackson.
|
82
|
+
homepage: http://mjijackson.com/rack-accept
|
83
83
|
licenses: []
|
84
84
|
|
85
85
|
post_install_message:
|