rack-accept 0.1.1 → 0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,11 +1,10 @@
1
1
  Gem::Specification.new do |s|
2
-
3
2
  s.name = 'rack-accept'
4
- s.version = '0.1.1'
5
- s.date = '2010-04-01'
3
+ s.version = '0.2'
4
+ s.date = '2010-04-02'
6
5
 
7
- s.summary = 'HTTP Accept* tools for Rack'
8
- s.description = 'HTTP Accept, Accept-Charset, Accept-Encoding, and Accept-Language tools for Rack'
6
+ s.summary = 'HTTP Accept* for Ruby/Rack'
7
+ s.description = 'HTTP Accept, Accept-Charset, Accept-Encoding, and Accept-Language for Ruby/Rack'
9
8
 
10
9
  s.author = 'Michael J. I. Jackson'
11
10
  s.email = 'mjijackson@gmail.com'
@@ -14,7 +13,8 @@ Gem::Specification.new do |s|
14
13
 
15
14
  s.files = Dir['lib/**/*.rb'] +
16
15
  Dir['test/*.rb'] +
17
- %w< CHANGES rack-accept.gemspec Rakefile README >
16
+ Dir['doc/**/*'] +
17
+ %w< CHANGES .gemspec Rakefile README >
18
18
 
19
19
  s.test_files = s.files.select {|path| path =~ /^test\/.*_test.rb/ }
20
20
 
@@ -25,6 +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://github.com/mjijackson/rack-accept'
29
-
28
+ s.homepage = 'http://mjijackson.github.com/rack-accept'
30
29
  end
data/CHANGES CHANGED
@@ -1,3 +1,12 @@
1
- ## 0.1 / April 2010
1
+ ## 0.2 / April 2, 2010
2
+
3
+ * Moved all common header methods into Rack::Accept::Header module
4
+ * Many improvements to the documentation
5
+
6
+ ## 0.1.1 / April 1, 2010
7
+
8
+ * Whoops, forgot to require Rack. :]
9
+
10
+ ## 0.1 / April 1, 2010
2
11
 
3
12
  * Initial release
data/README CHANGED
@@ -1,9 +1,17 @@
1
1
  Rack::Accept
2
2
  ============
3
3
 
4
- rack-accept is a suite of tools for Rack/Ruby applications that eases the
5
- complexity of reading and writing Accept, Accept-Charset, Accept-Encoding, and
6
- Accept-Language HTTP request headers.
4
+ Rack::Accept is a suite of tools for Ruby/Rack applications that eases the
5
+ complexity of building and interpreting the Accept* family of HTTP request
6
+ headers.
7
+
8
+ Some features of the library are:
9
+
10
+ * Strict adherence to RFC 2616, specifically section 14
11
+ * Full support for the Accept, Accept-Charset, Accept-Encoding, and
12
+ Accept-Language HTTP request headers
13
+ * May be used as Rack middleware or standalone
14
+ * A comprehensive test suite that covers many edge cases
7
15
 
8
16
  Installation
9
17
  ------------
@@ -15,12 +23,12 @@ Using RubyGems:
15
23
  From a local copy:
16
24
 
17
25
  $ git clone git://github.com/mjijackson/rack-accept.git
18
- $ rake package && sudo rake install
26
+ $ sudo rake install
19
27
 
20
28
  Usage
21
29
  -----
22
30
 
23
- rack-accept implements the Rack middleware interface and may be used with any
31
+ Rack::Accept implements the Rack middleware interface and may be used with any
24
32
  Rack-based application. Simply insert the Rack::Accept module in your Rack
25
33
  middleware pipeline and access the Rack::Accept::Request object in the
26
34
  "rack-accept.request" environment key, as in the following example:
@@ -30,22 +38,52 @@ middleware pipeline and access the Rack::Accept::Request object in the
30
38
  use Rack::Accept
31
39
 
32
40
  app = lambda {|env|
33
- accept = env['rack-accept.request']
34
- response = Rack::Response.new
35
-
36
- if accept.media_type?('text/html')
37
- response['Content-Type'] = 'text/html'
38
- response.write "<p>Hello. You accept text/html!</p>"
39
- else
40
- response['Content-Type'] = 'text/plain'
41
- response.write "Apparently you don't accept text/html. Too bad."
42
- end
43
-
44
- response.finish
41
+ accept = env['rack-accept.request']
42
+ response = Rack::Response.new
43
+
44
+ if accept.media_type?('text/html')
45
+ response['Content-Type'] = 'text/html'
46
+ response.write "<p>Hello. You accept text/html!</p>"
47
+ else
48
+ response['Content-Type'] = 'text/plain'
49
+ response.write "Apparently you don't accept text/html. Too bad."
50
+ end
51
+
52
+ response.finish
45
53
  }
46
54
 
47
55
  run app
48
56
 
57
+ Additionally, Rack::Accept may be used outside of a Rack context to provide
58
+ any Ruby app the ability to construct and interpret Accept headers.
59
+
60
+ require 'rack/accept'
61
+
62
+ mtype = Rack::Accept::MediaType.new
63
+ mtype.qvalues = {
64
+ 'text/html' => 1,
65
+ 'text/*' => 0.8,
66
+ '*/*' => 0.5
67
+ }
68
+
69
+ mtype.to_s # => "Accept: text/html, text/*;q=0.8, */*;q=0.5"
70
+
71
+ cset = Rack::Accept::Charset.new('unicode-1-1, iso-8859-5;q=0.8')
72
+ cset.best_of(%w< iso-8859-5 unicode-1-1 >) # => "unicode-1-1"
73
+ cset.accept?('iso-8859-1') # => true
74
+
75
+ The very last line in this example may look like a mistake to someone not
76
+ familiar with the intricacies of the spec, but it's actually correct. It
77
+ just puts emphasis on the convenience of using this library.
78
+
79
+ Four-letter Words
80
+ -----------------
81
+
82
+ Spec: http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html
83
+ Code: http://github.com/mjijackson/rack-accept
84
+ Docs: http://mjijackson.github.com/rack-accept
85
+ Bugs: http://github.com/mjijackson/rack-accept/issues
86
+
49
87
  License
50
88
  -------
51
89
 
data/Rakefile CHANGED
@@ -3,7 +3,7 @@ require 'rake/testtask'
3
3
 
4
4
  task :default => :test
5
5
 
6
- CLEAN.include %w< doc/api >
6
+ CLEAN.include %w< doc/api doc/*.html doc/*.css >
7
7
  CLOBBER.include %w< dist >
8
8
 
9
9
  # TESTS #######################################################################
@@ -14,63 +14,66 @@ end
14
14
 
15
15
  # DOCS ########################################################################
16
16
 
17
- desc "Generate all documentation"
18
- task :doc => %w< doc:api doc:etc >
19
-
20
- namespace :doc do
21
-
22
- desc "Generate API documentation (in doc/api)"
23
- task :api => FileList['lib/**/*.rb'] do |t|
24
- rm_rf 'doc/api'
25
- sh((<<-SH).gsub(/[\s\n]+/, ' ').strip)
26
- hanna
27
- --op doc/api
28
- --promiscuous
29
- --charset utf8
30
- --fmt html
31
- --inline-source
32
- --line-numbers
33
- --accessor option_accessor=RW
34
- --main Rack::Accept
35
- --title 'Rack::Accept API Documentation'
36
- #{t.prerequisites.join(' ')}
37
- SH
38
- end
39
-
40
- desc "Generate extra documentation"
41
- task :etc do
17
+ desc "Generate HTML documentation (in doc)"
18
+ task :doc => FileList['doc/*.markdown'] do |t|
19
+ require 'erb' unless defined?(ERB)
20
+ require 'rdiscount' unless defined?(RDiscount)
21
+ layout = ERB.new(File.read('doc/assets/layout.html.erb'), 0, '%<>')
22
+ t.prerequisites.each do |path|
23
+ source = File.read(path)
24
+ content = Markdown.new(source, :smart).to_html
25
+ output = layout.result(binding)
26
+ File.open(path.sub('.markdown', '.html'), 'w') {|io| io.write(output) }
42
27
  end
28
+ cp 'doc/assets/style.css', 'doc'
29
+ end
43
30
 
31
+ desc "Generate API documentation (in doc/api)"
32
+ task :api => FileList['lib/**/*.rb'] do |t|
33
+ rm_rf 'doc/api'
34
+ sh((<<-SH).gsub(/[\s\n]+/, ' ').strip)
35
+ hanna
36
+ --op doc/api
37
+ --promiscuous
38
+ --charset utf8
39
+ --fmt html
40
+ --inline-source
41
+ --line-numbers
42
+ --accessor option_accessor=RW
43
+ --main Rack::Accept
44
+ --title 'Rack::Accept API Documentation'
45
+ #{t.prerequisites.join(' ')}
46
+ SH
44
47
  end
45
48
 
46
- # PACKAGING ###################################################################
49
+ # PACKAGING & INSTALLATION ####################################################
47
50
 
48
51
  if defined?(Gem)
49
- $spec = eval("#{File.read('rack-accept.gemspec')}")
52
+ $spec = eval("#{File.read('.gemspec')}")
53
+
54
+ directory 'dist'
50
55
 
51
56
  def package(ext='')
52
57
  "dist/rack-accept-#{$spec.version}" + ext
53
58
  end
54
59
 
60
+ file package('.gem') => %w< dist > + $spec.files do |f|
61
+ sh "gem build .gemspec"
62
+ mv File.basename(f.name), f.name
63
+ end
64
+
65
+ file package('.tar.gz') => %w< dist > + $spec.files do |f|
66
+ sh "git archive --format=tar HEAD | gzip > #{f.name}"
67
+ end
68
+
55
69
  desc "Build packages"
56
70
  task :package => %w< .gem .tar.gz >.map {|e| package(e) }
57
71
 
58
72
  desc "Build and install as local gem"
59
- task :install => package('.gem') do
73
+ task :install => package('.gem') do |t|
60
74
  sh "gem install #{package('.gem')}"
61
75
  end
62
76
 
63
- directory 'dist/'
64
-
65
- file package('.gem') => %w< dist/ rack-accept.gemspec > + $spec.files do |f|
66
- sh "gem build rack-accept.gemspec"
67
- mv File.basename(f.name), f.name
68
- end
69
-
70
- file package('.tar.gz') => %w< dist/ > + $spec.files do |f|
71
- sh "git archive --format=tar HEAD | gzip > #{f.name}"
72
- end
73
-
74
77
  desc "Upload gem to rubygems.org"
75
78
  task :release => package('.gem') do |t|
76
79
  sh "gem push #{package('.gem')}"
@@ -0,0 +1,30 @@
1
+ <!DOCTYPE html>
2
+
3
+ <html lang="en">
4
+
5
+ <head>
6
+ <meta http-equiv="Content-Type" content="text/html;charset=utf-8">
7
+ <title>Rack::Accept</title>
8
+ <link rel="stylesheet" href="style.css" type="text/css" media="all">
9
+ </head>
10
+
11
+ <body>
12
+ <div id="wrapper">
13
+ <div id="header">
14
+ <h1>rack-accept</h1>
15
+ <ul>
16
+ <li><a href="license.html">License</a></li>
17
+ <li><a href="api/index.html">API</a></li>
18
+ <li><a href="http://github.com/mjijackson/rack-accept/issues">Bugs</a></li>
19
+ <li><a href="http://github.com/mjijackson/rack-accept">Code</a></li>
20
+ <li><a href="index.html">Home</a></li>
21
+ </ul>
22
+ </div>
23
+ <div id="content"><%= content %></div>
24
+ <div id="footer">
25
+ <p class="rights">Copyright &copy; 2010 <a href="http://mjijackson.com/about" rel="me author">Michael J. I. Jackson</a></p>
26
+ </div>
27
+ </div>
28
+ </body>
29
+
30
+ </html>
@@ -0,0 +1,69 @@
1
+ body {
2
+ background-color: #EEEEEE;
3
+ color: #333333;
4
+ font-family: "HelveticaNeue-Light","Helvetica Neue Light","Helvetica Neue",sans-serif;
5
+ font-size: 14px;
6
+ line-height: 1.5;
7
+ font-weight: 300;
8
+ margin: 25px 25px 50px;
9
+ }
10
+ a {
11
+ color: inherit;
12
+ text-decoration: none;
13
+ background-color: #FDFDFD;
14
+ padding: 3px 5px;
15
+ }
16
+ a:hover {
17
+ color: #666666;
18
+ }
19
+ h1, h2, h3 {
20
+ font-weight: 300;
21
+ }
22
+ h1 {
23
+ font-size: 32px;
24
+ }
25
+ h1, h2, h3, p, pre, ul, ol {
26
+ margin: 0 0 18px 0;
27
+ }
28
+ ol, ul {
29
+ padding-left: 36px;
30
+ }
31
+ li {
32
+ margin: 0;
33
+ padding: 0;
34
+ }
35
+ code {
36
+ font-size: 12px;
37
+ font-family: Menlo, monospace;
38
+ }
39
+ pre {
40
+ background-color: #FDFDFD;
41
+ padding-left: 6px;
42
+ }
43
+ #wrapper {
44
+ position: relative;
45
+ width: 600px;
46
+ margin: 0 auto;
47
+ }
48
+ #header {
49
+ margin-bottom: 36px;
50
+ }
51
+ #header ul {
52
+ position: absolute;
53
+ top: 14px;
54
+ right: 0;
55
+ list-style-type: none;
56
+ }
57
+ #header ul li {
58
+ float: right;
59
+ margin-left: 10px;
60
+ }
61
+ #content {
62
+ min-height: 400px;
63
+ }
64
+ #footer {
65
+ margin-top: 36px;
66
+ text-align: right;
67
+ font-size: 12px;
68
+ color: #999999;
69
+ }
@@ -0,0 +1,86 @@
1
+ __Rack::Accept__ is a suite of tools for Ruby/Rack applications that eases the
2
+ complexity of building and interpreting the Accept* family of [HTTP request
3
+ headers][rfc].
4
+
5
+ Some features of the library are:
6
+
7
+ * Strict adherence to [RFC 2616][rfc], specifically [section 14][sec14]
8
+ * Full support for the [Accept][sec14-1], [Accept-Charset][sec14-2],
9
+ [Accept-Encoding][sec14-3], and [Accept-Language][sec14-4] HTTP request
10
+ headers
11
+ * May be used as [Rack][rack] middleware or standalone
12
+ * A comprehensive [test suite][test] that covers many edge cases
13
+
14
+ Installation
15
+ ------------
16
+
17
+ Using [RubyGems][rubygems]:
18
+
19
+ $ sudo gem install rack-accept
20
+
21
+ From a local copy:
22
+
23
+ $ git clone git://github.com/mjijackson/rack-accept.git
24
+ $ sudo rake install
25
+
26
+ Usage
27
+ -----
28
+
29
+ Rack::Accept implements the Rack middleware interface and may be used with any
30
+ Rack-based application. Simply insert the Rack::Accept module in your Rack
31
+ middleware pipeline and access the [Rack::Accept::Request][req] object in the
32
+ "rack-accept.request" environment key, as in the following example:
33
+
34
+ require 'rack/accept'
35
+
36
+ use Rack::Accept
37
+
38
+ app = lambda {|env|
39
+ accept = env['rack-accept.request']
40
+ response = Rack::Response.new
41
+
42
+ if accept.media_type?('text/html')
43
+ response['Content-Type'] = 'text/html'
44
+ response.write "<p>Hello. You accept text/html!</p>"
45
+ else
46
+ response['Content-Type'] = 'text/plain'
47
+ response.write "Apparently you don't accept text/html. Too bad."
48
+ end
49
+
50
+ response.finish
51
+ }
52
+
53
+ run app
54
+
55
+ Additionally, Rack::Accept may be used outside of a Rack context to provide
56
+ any Ruby app the ability to construct and interpret Accept headers.
57
+
58
+ require 'rack/accept'
59
+
60
+ mtype = Rack::Accept::MediaType.new
61
+ mtype.qvalues = {
62
+ 'text/html' => 1,
63
+ 'text/*' => 0.8,
64
+ '*/*' => 0.5
65
+ }
66
+
67
+ mtype.to_s # => "Accept: text/html, text/*;q=0.8, */*;q=0.5"
68
+
69
+ cset = Rack::Accept::Charset.new('unicode-1-1, iso-8859-5;q=0.8')
70
+ cset.best_of(%w< iso-8859-5 unicode-1-1 >) # => "unicode-1-1"
71
+ cset.accept?('iso-8859-1') # => true
72
+
73
+ The very last line in this example may look like a mistake to someone not
74
+ familiar with the intricacies of [the spec][sec14-3], but it's actually
75
+ correct. It just puts emphasis on the convenience of using this library.
76
+
77
+ [rfc]: http://www.w3.org/Protocols/rfc2616/rfc2616.html
78
+ [sec14]: http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html
79
+ [sec14-1]: http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.1
80
+ [sec14-2]: http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.2
81
+ [sec14-3]: http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.3
82
+ [sec14-4]: http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.4
83
+ [rack]: http://rack.rubyforge.org/
84
+ [test]: http://github.com/mjijackson/rack-accept/tree/master/test/
85
+ [rubygems]: http://rubygems.org/
86
+ [req]: api/classes/Rack/Accept/Request.html
@@ -0,0 +1,19 @@
1
+ Copyright 2010 Michael J. I. Jackson
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy
4
+ of this software and associated documentation files (the "Software"), to deal
5
+ in the Software without restriction, including without limitation the rights
6
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
+ copies of the Software, and to permit persons to whom the Software is
8
+ furnished to do so, subject to the following conditions:
9
+
10
+ The above copyright notice and this permission notice shall be included in
11
+ all copies or substantial portions of the Software.
12
+
13
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19
+ THE SOFTWARE.
data/lib/rack/accept.rb CHANGED
@@ -3,7 +3,7 @@ require 'rack'
3
3
  module Rack::Accept
4
4
 
5
5
  # The current version of rack-accept.
6
- VERSION = [0, 1, 1]
6
+ VERSION = [0, 2]
7
7
 
8
8
  # Returns the current version of rack-accept as a string.
9
9
  def self.version
@@ -10,28 +10,11 @@ module Rack::Accept
10
10
 
11
11
  include Header
12
12
 
13
- attr_reader :qvalues
14
-
15
- def initialize(header)
16
- @qvalues = parse(header)
17
- end
18
-
19
13
  # The name of this header.
20
14
  def name
21
15
  'Accept-Charset'
22
16
  end
23
17
 
24
- # The value of this header, built from its internal representation.
25
- def value
26
- join(@qvalues)
27
- end
28
-
29
- # Returns an array of all character set values that were specified in the
30
- # original header, in no particular order.
31
- def values
32
- @qvalues.keys
33
- end
34
-
35
18
  # Determines the quality factor (qvalue) of the given +charset+,
36
19
  # according to the specifications of the original header.
37
20
  def qvalue(charset)
@@ -54,10 +37,5 @@ module Rack::Accept
54
37
  }
55
38
  end
56
39
 
57
- # Returns a string representation of this header.
58
- def to_s
59
- [name, value].join(': ')
60
- end
61
-
62
40
  end
63
41
  end
@@ -10,28 +10,11 @@ module Rack::Accept
10
10
 
11
11
  include Header
12
12
 
13
- attr_reader :qvalues
14
-
15
- def initialize(header)
16
- @qvalues = parse(header)
17
- end
18
-
19
13
  # The name of this header.
20
14
  def name
21
15
  'Accept-Encoding'
22
16
  end
23
17
 
24
- # The value of this header, built from its internal representation.
25
- def value
26
- join(@qvalues)
27
- end
28
-
29
- # Returns an array of all encoding values that were specified in the
30
- # original header, in no particular order.
31
- def values
32
- @qvalues.keys
33
- end
34
-
35
18
  # Determines the quality factor (qvalue) of the given +encoding+,
36
19
  # according to the specifications of the original header.
37
20
  def qvalue(encoding)
@@ -54,10 +37,5 @@ module Rack::Accept
54
37
  }
55
38
  end
56
39
 
57
- # Returns a string representation of this header.
58
- def to_s
59
- [name, value].join(': ')
60
- end
61
-
62
40
  end
63
41
  end
@@ -46,13 +46,36 @@ module Rack::Accept
46
46
  module_function :parse_media_type
47
47
 
48
48
  module PublicInstanceMethods
49
- # Returns the quality factor (qvalue) of the given +value+. This method
50
- # is the only method that must be overridden in child classes in order
51
- # for them to be able to use all other methods of this module.
49
+ # A table of all values of this header to their respective quality
50
+ # factors (qvalues).
51
+ attr_accessor :qvalues
52
+
53
+ def initialize(header='')
54
+ @qvalues = parse(header)
55
+ end
56
+
57
+ # The name of this header. Should be overridden in classes that mixin
58
+ # this module.
59
+ def name
60
+ ''
61
+ end
62
+
63
+ # Returns the quality factor (qvalue) of the given +value+. Should be
64
+ # overridden in classes that mixin this module.
52
65
  def qvalue(value)
53
66
  1
54
67
  end
55
68
 
69
+ # Returns the value of this header as a string.
70
+ def value
71
+ join(@qvalues)
72
+ end
73
+
74
+ # Returns an array of all values of this header, in no particular order.
75
+ def values
76
+ @qvalues.keys
77
+ end
78
+
56
79
  # Determines if the given +value+ is acceptable (does not have a qvalue
57
80
  # of 0) according to this header.
58
81
  def accept?(value)
@@ -88,6 +111,11 @@ module Rack::Accept
88
111
  s.reject! {|q, v| q == 0 } unless keep_unacceptables
89
112
  s.first && s.first[1]
90
113
  end
114
+
115
+ # Returns a string representation of this header.
116
+ def to_s
117
+ [name, value].join(': ')
118
+ end
91
119
  end
92
120
 
93
121
  include PublicInstanceMethods
@@ -10,28 +10,11 @@ module Rack::Accept
10
10
 
11
11
  include Header
12
12
 
13
- attr_reader :qvalues
14
-
15
- def initialize(header)
16
- @qvalues = parse(header)
17
- end
18
-
19
13
  # The name of this header.
20
14
  def name
21
15
  'Accept-Language'
22
16
  end
23
17
 
24
- # The value of this header, built from its internal representation.
25
- def value
26
- join(@qvalues)
27
- end
28
-
29
- # Returns an array of all language values that were specified in the
30
- # original header, in no particular order.
31
- def values
32
- @qvalues.keys
33
- end
34
-
35
18
  # Determines the quality factor (qvalue) of the given +language+,
36
19
  # according to the specifications of the original header.
37
20
  def qvalue(language)
@@ -52,10 +35,5 @@ module Rack::Accept
52
35
  }.reverse
53
36
  end
54
37
 
55
- # Returns a string representation of this header.
56
- def to_s
57
- [name, value].join(': ')
58
- end
59
-
60
38
  end
61
39
  end
@@ -10,28 +10,11 @@ module Rack::Accept
10
10
 
11
11
  include Header
12
12
 
13
- attr_reader :qvalues
14
-
15
- def initialize(header)
16
- @qvalues = parse(header)
17
- end
18
-
19
13
  # The name of this header.
20
14
  def name
21
15
  'Accept'
22
16
  end
23
17
 
24
- # The value of this header, built from its internal representation.
25
- def value
26
- join(@qvalues)
27
- end
28
-
29
- # Returns an array of all media type values that were specified in the
30
- # original header, in no particular order.
31
- def values
32
- @qvalues.keys
33
- end
34
-
35
18
  # Determines the quality factor (qvalue) of the given +media_type+,
36
19
  # according to the specifications of the original header.
37
20
  def qvalue(media_type)
@@ -58,10 +41,5 @@ module Rack::Accept
58
41
  }.reverse
59
42
  end
60
43
 
61
- # Returns a string representation of this header.
62
- def to_s
63
- [name, value].join(': ')
64
- end
65
-
66
44
  end
67
45
  end
@@ -1,13 +1,13 @@
1
1
  module Rack::Accept
2
2
 
3
- # A container class for convenience methods when rack-accept is used on the
4
- # request level (as a Rack middleware, for example). This class manages a
3
+ # A container class for convenience methods when Rack::Accept is used on the
4
+ # request level (as Rack middleware, for example). This class manages a
5
5
  # lightweight cache of various header instances to speed up execution.
6
6
  #
7
- # This class currently does not extend Rack::Request because that class
7
+ # Request currently does not extend Rack::Request because that class
8
8
  # currently provides some limited functionality when it comes to determining
9
- # the proper encoding to use with a request and I didn't want to confuse the
10
- # user.
9
+ # the proper encoding to use with a request and I didn't want to confuse
10
+ # users.
11
11
  class Request
12
12
 
13
13
  attr_reader :env
metadata CHANGED
@@ -4,9 +4,8 @@ version: !ruby/object:Gem::Version
4
4
  prerelease: false
5
5
  segments:
6
6
  - 0
7
- - 1
8
- - 1
9
- version: 0.1.1
7
+ - 2
8
+ version: "0.2"
10
9
  platform: ruby
11
10
  authors:
12
11
  - Michael J. I. Jackson
@@ -14,7 +13,7 @@ autorequire:
14
13
  bindir: bin
15
14
  cert_chain: []
16
15
 
17
- date: 2010-04-01 00:00:00 -06:00
16
+ date: 2010-04-02 00:00:00 -06:00
18
17
  default_executable:
19
18
  dependencies:
20
19
  - !ruby/object:Gem::Dependency
@@ -42,7 +41,7 @@ dependencies:
42
41
  version: "0"
43
42
  type: :development
44
43
  version_requirements: *id002
45
- description: HTTP Accept, Accept-Charset, Accept-Encoding, and Accept-Language tools for Rack
44
+ description: HTTP Accept, Accept-Charset, Accept-Encoding, and Accept-Language for Ruby/Rack
46
45
  email: mjijackson@gmail.com
47
46
  executables: []
48
47
 
@@ -67,12 +66,16 @@ files:
67
66
  - test/language_test.rb
68
67
  - test/media_type_test.rb
69
68
  - test/request_test.rb
69
+ - doc/assets/layout.html.erb
70
+ - doc/assets/style.css
71
+ - doc/index.markdown
72
+ - doc/license.markdown
70
73
  - CHANGES
71
- - rack-accept.gemspec
74
+ - .gemspec
72
75
  - Rakefile
73
76
  - README
74
77
  has_rdoc: true
75
- homepage: http://github.com/mjijackson/rack-accept
78
+ homepage: http://mjijackson.github.com/rack-accept
76
79
  licenses: []
77
80
 
78
81
  post_install_message:
@@ -105,7 +108,7 @@ rubyforge_project:
105
108
  rubygems_version: 1.3.6
106
109
  signing_key:
107
110
  specification_version: 3
108
- summary: HTTP Accept* tools for Rack
111
+ summary: HTTP Accept* for Ruby/Rack
109
112
  test_files:
110
113
  - test/charset_test.rb
111
114
  - test/encoding_test.rb