acceptable 0.2.1 → 0.2.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.
data/README.rdoc CHANGED
@@ -1,3 +1,59 @@
1
+ === DESCRIPTION:
2
+
3
+ Provides definitive support for Accept-* headers, strictly compliant with RFC 2616.
4
+ Includes negotiation algorithms for Media-Types, Charsets and Content-Codings.
5
+ Also realizes perfectionistic LanguageTags support with basic/extended filtering (RFC 5646, RFC 4647).
6
+
7
+ == FEATURES:
8
+
9
+ * Accept-* headers support, strictly compliant with RFC 2616
10
+ * Media-Type negotiation
11
+ * Charset negotiation
12
+ * Content-coding negotiation
13
+ * LanguageTags (RFC 5646, RFC 4647)
14
+
15
+ == EXAMPLES:
16
+
17
+ === Media
18
+
19
+ env = Rack::MockRequest.env_for('/','HTTP_ACCEPT' => 'text/plain;q=0,text/*')
20
+ request = Request.new(env)
21
+ p request.accept_media?('text/css') #=> true
22
+ p request.accept_media?('text/plain') #=> false
23
+ p request.accept_media?('video/quicktime') #=> false
24
+
25
+ env = Rack::MockRequest.env_for('/','HTTP_ACCEPT' => 'text/*;q=0.8,text/x-json;q=0.8,text/html;p=whatever')
26
+ request = Request.new(env)
27
+ p request.preferred_media_from('text/css','text/html') #=> "text/css"
28
+ p request.preferred_media_from('text/x-json','text/html;p=whatever') #=> "text/html;p=whatever"
29
+ p request.preferred_media_from('text/x-json','text/html;p=Whatever') #=> "text/x-json" #parameter values are case-sensitive.
30
+
31
+ === LanguageTags
32
+
33
+ langtag = Rack::Acceptable::LanguageTag.parse('SL-LATN-ROZAJ')
34
+
35
+ p langtag.variants #=> ["rozaj"]
36
+ p langtag.script #=> "Latn"
37
+
38
+ # basic filtering (RFC 4647)
39
+ p langtag.has_prefix?('sl-Latn') #=> true
40
+ p langtag.matched_by_basic_range?('sl-Latn') #=> true
41
+ p langtag.has_prefix?('sl-Latn-ro') #=> false
42
+ p langtag.has_prefix?('sl') #=> true
43
+
44
+ # extended filtering (RFC 4647)
45
+ p langtag.matched_by_extended_range?('*') #=> true
46
+ p langtag.matched_by_extended_range?('sl-*') #=> true
47
+ p langtag.matched_by_extended_range?('*-Latn') #=> true
48
+ p langtag.matched_by_extended_range?('sl-rozaj') #=> true
49
+ p langtag.matched_by_extended_range?('sl-nedis') #=> false
50
+
51
+
52
+ == INSTALLATION:
53
+
54
+ rack-acceptable is available via rubygems:
55
+ $gem in acceptable
56
+
1
57
  == REQUIREMENTS:
2
58
 
3
59
  rack (>=1.0.0)
@@ -6,7 +62,7 @@ rack (>=1.0.0)
6
62
 
7
63
  (The MIT License)
8
64
 
9
- Copyright (c) 2009
65
+ Copyright (c) 2010
10
66
 
11
67
  Permission is hereby granted, free of charge, to any person obtaining
12
68
  a copy of this software and associated documentation files (the
@@ -1,6 +1,6 @@
1
1
  module Rack #:nodoc:
2
2
  module Acceptable #:nodoc:
3
- VERSION = '0.2.1'
3
+ VERSION = '0.2.2'
4
4
  end
5
5
  end
6
6
 
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 2
8
- - 1
9
- version: 0.2.1
8
+ - 2
9
+ version: 0.2.2
10
10
  platform: ruby
11
11
  authors:
12
12
  - SSDany
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-04-16 00:00:00 +04:00
17
+ date: 2010-04-17 00:00:00 +04:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
@@ -31,7 +31,11 @@ dependencies:
31
31
  version: 1.0.0
32
32
  type: :runtime
33
33
  version_requirements: *id001
34
- description: HTTP Accept parsers for Rack.
34
+ description: |
35
+ Provides definitive support for Accept-* headers, strictly compliant with RFC 2616.
36
+ Includes negotiation algorithms for Media-Types, Charsets and Content-Codings.
37
+ Also realizes perfectionistic LanguageTags support with basic/extended filtering (RFC 5646, RFC 4647).
38
+
35
39
  email: inadsence@gmail.com
36
40
  executables: []
37
41