mime_version 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/mime_version.rb +22 -0
- metadata +47 -0
data/lib/mime_version.rb
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
class MimeVersion
|
2
|
+
def initialize(app)
|
3
|
+
@app = app
|
4
|
+
end
|
5
|
+
|
6
|
+
def self.parse_version(content_type)
|
7
|
+
tag = "version="
|
8
|
+
@version = @default_version
|
9
|
+
@hash = Hash[content_type.split(';').map { |i| i.split('=') }]
|
10
|
+
@version = @hash["version"]
|
11
|
+
end
|
12
|
+
|
13
|
+
def call(env)
|
14
|
+
|
15
|
+
ENV['version'] = ""
|
16
|
+
if env.has_key? "CONTENT_TYPE"
|
17
|
+
@version = MimeVersion.parse_version(env["CONTENT_TYPE"])
|
18
|
+
ENV['version'] = @version
|
19
|
+
end
|
20
|
+
@app.call(env)
|
21
|
+
end
|
22
|
+
end
|
metadata
ADDED
@@ -0,0 +1,47 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: mime_version
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.4
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Chris Brulak
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-06-07 00:00:00.000000000 Z
|
13
|
+
dependencies: []
|
14
|
+
description: ! "Parse a version from the content type string and then use it in the
|
15
|
+
environment variable.\n For example: 'Content-type:text/html;vnd.example-com.foo+json;
|
16
|
+
version=1.1' will be parsed into 1.1"
|
17
|
+
email: chris.brulak@ama.ab.ca
|
18
|
+
executables: []
|
19
|
+
extensions: []
|
20
|
+
extra_rdoc_files: []
|
21
|
+
files:
|
22
|
+
- lib/mime_version.rb
|
23
|
+
homepage: http://rubygems.org/gems/mimeversion
|
24
|
+
licenses: []
|
25
|
+
post_install_message:
|
26
|
+
rdoc_options: []
|
27
|
+
require_paths:
|
28
|
+
- lib
|
29
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
30
|
+
none: false
|
31
|
+
requirements:
|
32
|
+
- - ! '>='
|
33
|
+
- !ruby/object:Gem::Version
|
34
|
+
version: '0'
|
35
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
36
|
+
none: false
|
37
|
+
requirements:
|
38
|
+
- - ! '>='
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
requirements: []
|
42
|
+
rubyforge_project:
|
43
|
+
rubygems_version: 1.8.23
|
44
|
+
signing_key:
|
45
|
+
specification_version: 3
|
46
|
+
summary: Mime version
|
47
|
+
test_files: []
|