rack-accept 0.4.2 → 0.4.3

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGES CHANGED
@@ -1,3 +1,7 @@
1
+ ## 0.4.3 / July 29, 2010
2
+
3
+ * Added support for Ruby 1.9.2
4
+
1
5
  ## 0.4 / April 5, 2010
2
6
 
3
7
  * Added support for media type queries with multiple range parameters
data/README CHANGED
@@ -23,6 +23,7 @@ Using RubyGems:
23
23
  From a local copy:
24
24
 
25
25
  $ git clone git://github.com/mjijackson/rack-accept.git
26
+ $ cd rack-accept
26
27
  $ rake package && sudo rake install
27
28
 
28
29
  Usage
@@ -99,8 +100,8 @@ Four-letter Words
99
100
 
100
101
  Spec: http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html
101
102
  Code: http://github.com/mjijackson/rack-accept
102
- Docs: http://mjijackson.github.com/rack-accept
103
103
  Bugs: http://github.com/mjijackson/rack-accept/issues
104
+ Docs: http://mjijackson.com/rack-accept
104
105
 
105
106
  License
106
107
  -------
data/Rakefile CHANGED
@@ -3,9 +3,6 @@ require 'rake/testtask'
3
3
 
4
4
  task :default => :test
5
5
 
6
- CLEAN.include %w< doc/api doc/*.html doc/*.css >
7
- CLOBBER.include %w< dist >
8
-
9
6
  # TESTS #######################################################################
10
7
 
11
8
  Rake::TestTask.new(:test) do |t|
@@ -14,26 +11,13 @@ end
14
11
 
15
12
  # DOCS ########################################################################
16
13
 
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) }
27
- end
28
- cp 'doc/assets/style.css', 'doc'
29
- end
30
-
31
- desc "Generate API documentation (in doc/api)"
14
+ desc "Generate API documentation"
32
15
  task :api => FileList['lib/**/*.rb'] do |t|
33
- rm_rf 'doc/api'
16
+ output_dir = ENV['OUTPUT_DIR'] || 'api'
17
+ rm_rf output_dir
34
18
  sh((<<-SH).gsub(/[\s\n]+/, ' ').strip)
35
19
  hanna
36
- --op doc/api
20
+ --op #{output_dir}
37
21
  --promiscuous
38
22
  --charset utf8
39
23
  --fmt html
@@ -46,6 +30,8 @@ task :api => FileList['lib/**/*.rb'] do |t|
46
30
  SH
47
31
  end
48
32
 
33
+ CLEAN.include 'api'
34
+
49
35
  # PACKAGING & INSTALLATION ####################################################
50
36
 
51
37
  if defined?(Gem)
@@ -79,3 +65,5 @@ if defined?(Gem)
79
65
  sh "gem push #{package('.gem')}"
80
66
  end
81
67
  end
68
+
69
+ CLOBBER.include 'dist'
@@ -21,6 +21,7 @@ Using [RubyGems][rubygems]:
21
21
  From a local copy:
22
22
 
23
23
  $ git clone git://github.com/mjijackson/rack-accept.git
24
+ $ cd rack-accept
24
25
  $ rake package && sudo rake install
25
26
 
26
27
  [rfc]: http://www.w3.org/Protocols/rfc2616/rfc2616.html
@@ -1,7 +1,7 @@
1
1
  License
2
2
  -------
3
3
 
4
- Copyright 2010 Michael J. I. Jackson
4
+ Copyright 2010 Michael Jackson
5
5
 
6
6
  Permission is hereby granted, free of charge, to any person obtaining a copy
7
7
  of this software and associated documentation files (the "Software"), to deal
@@ -4,7 +4,7 @@ require 'rack'
4
4
  #
5
5
  # http://mjijackson.com/rack-accept
6
6
  module Rack::Accept
7
- VERSION = [0, 4, 2]
7
+ VERSION = [0, 4, 3]
8
8
 
9
9
  # Returns the current version of Rack::Accept as a string.
10
10
  def self.version
@@ -1,12 +1,10 @@
1
1
  module Rack::Accept
2
-
3
2
  # Represents an HTTP Accept-Charset header according to the HTTP 1.1
4
3
  # specification, and provides several convenience methods for determining
5
4
  # acceptable character sets.
6
5
  #
7
6
  # http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.2
8
7
  class Charset
9
-
10
8
  include Header
11
9
 
12
10
  # The name of this header.
@@ -34,6 +32,5 @@ module Rack::Accept
34
32
  a == '*' ? 1 : (b == '*' ? -1 : 0)
35
33
  }
36
34
  end
37
-
38
35
  end
39
36
  end
@@ -1,8 +1,6 @@
1
1
  module Rack::Accept
2
-
3
2
  # Implements the Rack middleware interface.
4
3
  class Context
5
-
6
4
  # This error is raised when the server is not able to provide an acceptable
7
5
  # response.
8
6
  class AcceptError < StandardError; end
@@ -65,6 +63,5 @@ module Rack::Accept
65
63
  raise AcceptError unless values.any? {|v| header.accept?(v) }
66
64
  end
67
65
  end
68
-
69
66
  end
70
67
  end
@@ -1,12 +1,10 @@
1
1
  module Rack::Accept
2
-
3
2
  # Represents an HTTP Accept-Encoding header according to the HTTP 1.1
4
3
  # specification, and provides several convenience methods for determining
5
4
  # acceptable content encodings.
6
5
  #
7
6
  # http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.3
8
7
  class Encoding
9
-
10
8
  include Header
11
9
 
12
10
  # The name of this header.
@@ -34,6 +32,5 @@ module Rack::Accept
34
32
  a == '*' ? 1 : (b == '*' ? -1 : 0)
35
33
  }
36
34
  end
37
-
38
35
  end
39
36
  end
@@ -1,10 +1,8 @@
1
1
  module Rack::Accept
2
-
3
2
  # Contains methods that are useful for working with Accept-style HTTP
4
3
  # headers. The MediaType, Charset, Encoding, and Language classes all mixin
5
4
  # this module.
6
5
  module Header
7
-
8
6
  # Parses the value of an Accept-style request header into a hash of
9
7
  # acceptable values and their respective quality factors (qvalues). The
10
8
  # +join+ method may be used on the resulting hash to obtain a header
@@ -145,6 +143,5 @@ module Rack::Accept
145
143
  end
146
144
 
147
145
  include PublicInstanceMethods
148
-
149
146
  end
150
147
  end
@@ -1,12 +1,10 @@
1
1
  module Rack::Accept
2
-
3
2
  # Represents an HTTP Accept-Language header according to the HTTP 1.1
4
3
  # specification, and provides several convenience methods for determining
5
4
  # acceptable content languages.
6
5
  #
7
6
  # http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.4
8
7
  class Language
9
-
10
8
  include Header
11
9
 
12
10
  # The name of this header.
@@ -32,6 +30,5 @@ module Rack::Accept
32
30
  a == '*' ? -1 : (b == '*' ? 1 : a.length <=> b.length)
33
31
  }.reverse
34
32
  end
35
-
36
33
  end
37
34
  end
@@ -1,12 +1,10 @@
1
1
  module Rack::Accept
2
-
3
2
  # Represents an HTTP Accept header according to the HTTP 1.1 specification,
4
3
  # and provides several convenience methods for determining acceptable media
5
4
  # types.
6
5
  #
7
6
  # http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.1
8
7
  class MediaType
9
-
10
8
  include Header
11
9
 
12
10
  # The name of this header.
@@ -58,6 +56,5 @@ module Rack::Accept
58
56
  parsed = parse_range_params(params)
59
57
  parsed == parsed.merge(parse_range_params(match))
60
58
  end
61
-
62
59
  end
63
60
  end
@@ -1,12 +1,10 @@
1
1
  require 'rack/request'
2
2
 
3
3
  module Rack::Accept
4
-
5
4
  # A container class for convenience methods when Rack::Accept is used on the
6
5
  # request level as Rack middleware. Instances of this class also manage a
7
6
  # lightweight cache of various header instances to speed up execution.
8
7
  class Request < Rack::Request
9
-
10
8
  attr_reader :env
11
9
 
12
10
  def initialize(env)
@@ -88,6 +86,5 @@ module Rack::Accept
88
86
  def best_language(values)
89
87
  language.best_of(values)
90
88
  end
91
-
92
89
  end
93
90
  end
@@ -1,10 +1,8 @@
1
1
  require 'rack/response'
2
2
 
3
3
  module Rack::Accept
4
-
5
4
  # The base class for responses issued by Rack::Accept.
6
5
  class Response < Rack::Response
7
-
8
6
  # Marks this response as being unacceptable and clears the response body.
9
7
  #
10
8
  # Note: The HTTP spec advises servers to respond with an "entity" that
@@ -16,6 +14,5 @@ module Rack::Accept
16
14
  self.body = []
17
15
  header['Content-Length'] = '0'
18
16
  end
19
-
20
17
  end
21
18
  end
@@ -1,7 +1,7 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'rack-accept'
3
- s.version = '0.4.2'
4
- s.date = '2010-05-04'
3
+ s.version = '0.4.3'
4
+ s.date = '2010-07-29'
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'
@@ -11,9 +11,9 @@ Gem::Specification.new do |s|
11
11
 
12
12
  s.require_paths = %w< lib >
13
13
 
14
- s.files = Dir['lib/**/*.rb'] +
14
+ s.files = Dir['doc/**/*'] +
15
+ Dir['lib/**/*.rb'] +
15
16
  Dir['test/*.rb'] +
16
- Dir['doc/**/*'] +
17
17
  %w< CHANGES rack-accept.gemspec Rakefile README >
18
18
 
19
19
  s.test_files = s.files.select {|path| path =~ /^test\/.*_test.rb/ }
@@ -1,7 +1,6 @@
1
- require File.dirname(__FILE__) + '/helper'
1
+ require File.expand_path('../helper', __FILE__)
2
2
 
3
3
  class CharsetTest < Test::Unit::TestCase
4
-
5
4
  C = Rack::Accept::Charset
6
5
 
7
6
  def test_qvalue
@@ -41,5 +40,4 @@ class CharsetTest < Test::Unit::TestCase
41
40
  assert_equal('iso-8859-1', c.best_of(%w< iso-8859-1 utf-8 >))
42
41
  assert_equal(nil, c.best_of(%w< utf-8 >))
43
42
  end
44
-
45
43
  end
@@ -1,7 +1,6 @@
1
- require File.dirname(__FILE__) + '/helper'
1
+ require File.expand_path('../helper', __FILE__)
2
2
 
3
3
  class ContextTest < Test::Unit::TestCase
4
-
5
4
  def media_types; Proc.new {|c| c.media_types = %w< text/html > } end
6
5
  def charsets; Proc.new {|c| c.charsets = %w< iso-8859-5 > } end
7
6
  def encodings; Proc.new {|c| c.encodings = %w< gzip > } end
@@ -55,5 +54,4 @@ class ContextTest < Test::Unit::TestCase
55
54
  request('HTTP_ACCEPT_LANGUAGE' => 'jp', &languages)
56
55
  assert_equal(406, status)
57
56
  end
58
-
59
57
  end
@@ -1,7 +1,6 @@
1
- require File.dirname(__FILE__) + '/helper'
1
+ require File.expand_path('../helper', __FILE__)
2
2
 
3
3
  class EncodingTest < Test::Unit::TestCase
4
-
5
4
  E = Rack::Accept::Encoding
6
5
 
7
6
  def test_qvalue
@@ -27,5 +26,4 @@ class EncodingTest < Test::Unit::TestCase
27
26
  assert_equal('identity', e.best_of(%w< identity compress >))
28
27
  assert_equal(nil, e.best_of(%w< zip >))
29
28
  end
30
-
31
29
  end
@@ -1,7 +1,6 @@
1
- require File.dirname(__FILE__) + '/helper'
1
+ require File.expand_path('../helper', __FILE__)
2
2
 
3
3
  class HeaderTest < Test::Unit::TestCase
4
-
5
4
  H = Rack::Accept::Header
6
5
 
7
6
  def test_parse_and_join
@@ -61,5 +60,4 @@ class HeaderTest < Test::Unit::TestCase
61
60
  assert_equal(0, H.normalize_qvalue(0))
62
61
  assert_equal(0.5, H.normalize_qvalue(0.5))
63
62
  end
64
-
65
63
  end
@@ -1,7 +1,6 @@
1
- require File.dirname(__FILE__) + '/helper'
1
+ require File.expand_path('../helper', __FILE__)
2
2
 
3
3
  class LanguageTest < Test::Unit::TestCase
4
-
5
4
  L = Rack::Accept::Language
6
5
 
7
6
  def test_qvalue
@@ -33,5 +32,4 @@ class LanguageTest < Test::Unit::TestCase
33
32
  assert_equal('en-us', l.best_of(%w< en-us en-au >))
34
33
  assert_equal(nil, l.best_of(%w< da >))
35
34
  end
36
-
37
35
  end
@@ -1,7 +1,6 @@
1
- require File.dirname(__FILE__) + '/helper'
1
+ require File.expand_path('../helper', __FILE__)
2
2
 
3
3
  class MediaTypeTest < Test::Unit::TestCase
4
-
5
4
  M = Rack::Accept::MediaType
6
5
 
7
6
  def test_qvalue
@@ -43,5 +42,4 @@ class MediaTypeTest < Test::Unit::TestCase
43
42
  m = M.new('text/*;q=0.5;a=42')
44
43
  assert_equal(0.5, m.qvalue('text/plain'))
45
44
  end
46
-
47
45
  end
@@ -1,7 +1,6 @@
1
- require File.dirname(__FILE__) + '/helper'
1
+ require File.expand_path('../helper', __FILE__)
2
2
 
3
3
  class RequestTest < Test::Unit::TestCase
4
-
5
4
  R = Rack::Accept::Request
6
5
 
7
6
  def test_media_type
@@ -58,5 +57,4 @@ class RequestTest < Test::Unit::TestCase
58
57
  assert(request.language?('en-gb'))
59
58
  assert(!request.language?('da'))
60
59
  end
61
-
62
60
  end
metadata CHANGED
@@ -1,12 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rack-accept
3
3
  version: !ruby/object:Gem::Version
4
+ hash: 9
4
5
  prerelease: false
5
6
  segments:
6
7
  - 0
7
8
  - 4
8
- - 2
9
- version: 0.4.2
9
+ - 3
10
+ version: 0.4.3
10
11
  platform: ruby
11
12
  authors:
12
13
  - Michael Jackson
@@ -14,16 +15,18 @@ autorequire:
14
15
  bindir: bin
15
16
  cert_chain: []
16
17
 
17
- date: 2010-05-04 00:00:00 -06:00
18
+ date: 2010-07-29 00:00:00 -06:00
18
19
  default_executable:
19
20
  dependencies:
20
21
  - !ruby/object:Gem::Dependency
21
22
  name: rack
22
23
  prerelease: false
23
24
  requirement: &id001 !ruby/object:Gem::Requirement
25
+ none: false
24
26
  requirements:
25
27
  - - ">="
26
28
  - !ruby/object:Gem::Version
29
+ hash: 3
27
30
  segments:
28
31
  - 0
29
32
  - 4
@@ -34,9 +37,11 @@ dependencies:
34
37
  name: rake
35
38
  prerelease: false
36
39
  requirement: &id002 !ruby/object:Gem::Requirement
40
+ none: false
37
41
  requirements:
38
42
  - - ">="
39
43
  - !ruby/object:Gem::Version
44
+ hash: 3
40
45
  segments:
41
46
  - 0
42
47
  version: "0"
@@ -52,6 +57,9 @@ extra_rdoc_files:
52
57
  - CHANGES
53
58
  - README
54
59
  files:
60
+ - doc/index.markdown
61
+ - doc/license.markdown
62
+ - doc/usage.markdown
55
63
  - lib/rack/accept/charset.rb
56
64
  - lib/rack/accept/context.rb
57
65
  - lib/rack/accept/encoding.rb
@@ -69,11 +77,6 @@ files:
69
77
  - test/language_test.rb
70
78
  - test/media_type_test.rb
71
79
  - test/request_test.rb
72
- - doc/assets/layout.html.erb
73
- - doc/assets/style.css
74
- - doc/index.markdown
75
- - doc/license.markdown
76
- - doc/usage.markdown
77
80
  - CHANGES
78
81
  - rack-accept.gemspec
79
82
  - Rakefile
@@ -93,23 +96,27 @@ rdoc_options:
93
96
  require_paths:
94
97
  - lib
95
98
  required_ruby_version: !ruby/object:Gem::Requirement
99
+ none: false
96
100
  requirements:
97
101
  - - ">="
98
102
  - !ruby/object:Gem::Version
103
+ hash: 3
99
104
  segments:
100
105
  - 0
101
106
  version: "0"
102
107
  required_rubygems_version: !ruby/object:Gem::Requirement
108
+ none: false
103
109
  requirements:
104
110
  - - ">="
105
111
  - !ruby/object:Gem::Version
112
+ hash: 3
106
113
  segments:
107
114
  - 0
108
115
  version: "0"
109
116
  requirements: []
110
117
 
111
118
  rubyforge_project:
112
- rubygems_version: 1.3.6
119
+ rubygems_version: 1.3.7
113
120
  signing_key:
114
121
  specification_version: 3
115
122
  summary: HTTP Accept* for Ruby/Rack
@@ -1,30 +0,0 @@
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="api/index.html">API</a></li>
17
- <li><a href="http://github.com/mjijackson/rack-accept/issues">Bugs</a></li>
18
- <li><a href="http://github.com/mjijackson/rack-accept">Code</a></li>
19
- <li><a href="usage.html">Usage</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><a href="license.html" rel="license">Copyright</a> &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>
@@ -1,79 +0,0 @@
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: 4px 0 4px 6px;
42
- line-height: 1.2;
43
- }
44
- strong {
45
- font-weight: bold;
46
- }
47
- ::selection {
48
- background: rgba(200,200,200,0.5);
49
- }
50
- ::-moz-selection {
51
- background: rgba(200,200,200,0.5);
52
- }
53
- #wrapper {
54
- position: relative;
55
- width: 600px;
56
- margin: 0 auto;
57
- }
58
- #header {
59
- margin-bottom: 36px;
60
- }
61
- #header ul {
62
- position: absolute;
63
- top: 14px;
64
- right: 0;
65
- list-style-type: none;
66
- }
67
- #header ul li {
68
- float: right;
69
- margin-left: 10px;
70
- }
71
- #content {
72
- min-height: 400px;
73
- }
74
- #footer {
75
- margin-top: 36px;
76
- text-align: right;
77
- font-size: 12px;
78
- color: #999999;
79
- }