rails-uploader 0.2.4 → 0.2.5

Sign up to get free protection for your applications and to get access to all the features.
@@ -47,10 +47,8 @@ module Uploader
47
47
  end
48
48
 
49
49
  def render_json(hash_or_object, status = 200)
50
- ctype = env["HTTP_USER_AGENT"] && env["HTTP_USER_AGENT"].include?("Android") ? "text/plain" : "application/json"
51
-
52
50
  self.status = status
53
- self.content_type = ctype
51
+ self.content_type = Uploader.content_type(env["HTTP_USER_AGENT"])
54
52
  self.response_body = hash_or_object.to_json(:root => false)
55
53
  end
56
54
  end
data/lib/uploader.rb CHANGED
@@ -31,6 +31,19 @@ module Uploader
31
31
  return if klass.blank?
32
32
  klass.safe_constantize
33
33
  end
34
+
35
+ def self.content_type(user_agent)
36
+ return "application/json" if user_agent.blank?
37
+
38
+ ie_version = user_agent.scan(/(MSIE\s|rv:)([\d\.]+)/).flatten.last
39
+
40
+ if user_agent.include?("Android") || (ie_version && ie_version.to_f <= 9.0) || (user_agent =~ /Trident\/[0-9\.]+\;/i)
41
+ "text/plain"
42
+ else
43
+ "application/json"
44
+ end
45
+ end
46
+
34
47
  end
35
48
 
36
49
  require 'uploader/engine'
@@ -1,3 +1,3 @@
1
1
  module Uploader
2
- VERSION = "0.2.4".freeze
2
+ VERSION = "0.2.5".freeze
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rails-uploader
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.4
4
+ version: 0.2.5
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2013-12-08 00:00:00.000000000 Z
13
+ date: 2014-03-18 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: jquery-ui-rails