rails_request_parser 0.1.0 → 0.1.1
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.
- checksums.yaml +4 -4
- data/Rakefile +1 -1
- data/lib/rails_request_parser.rb +24 -5
- data/lib/rails_request_parser/version.rb +2 -2
- data/tasks/rspec.rake +3 -0
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bc7a3593d5c2e77b81cfb1be12e2002f984f8aa1
|
4
|
+
data.tar.gz: 7d735c35bbd535dd73d59e6b2cbc9493ad1a378a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f33c698a2a77901840511998499ce921d01478fbebb67a5b3fa357a242034cf8be4562a1c28f3ba5f0b8f68265edd3e6592be2fd936423696b901e195d338c63
|
7
|
+
data.tar.gz: de2cad4db1c82993880d778a1c31d5f37dbba964f76ef961d193883d48b2a2deb7c26e9df4358c0fc6e3942353e10f8d57a28770cc8918e0ae99e7f1babea778
|
data/Rakefile
CHANGED
data/lib/rails_request_parser.rb
CHANGED
@@ -1,10 +1,29 @@
|
|
1
|
-
require "rails_request_parser/version"
|
1
|
+
# require "rails_request_parser/version"
|
2
2
|
require 'user_agent_parser'
|
3
3
|
|
4
|
-
|
5
|
-
def
|
4
|
+
class RailsRequestParser
|
5
|
+
def initialize(request)
|
6
|
+
@request = request
|
7
|
+
end
|
8
|
+
def is_chrome_browser?
|
6
9
|
chrome = 'Chrome'.freeze
|
7
|
-
return UserAgentParser.parse(request.user_agent).family == chrome
|
10
|
+
return UserAgentParser.parse(@request.user_agent).family == chrome
|
11
|
+
end
|
12
|
+
def is_mac_os?
|
13
|
+
mac = 'Mac'.freeze
|
14
|
+
UserAgentParser.parse(@request.user_agent).os.to_s.include? mac
|
15
|
+
end
|
16
|
+
def is_windows_os?
|
17
|
+
windows = 'Windows'.freeze
|
18
|
+
UserAgentParser.parse(@request.user_agent).os.to_s.include? windows
|
8
19
|
end
|
9
|
-
# Your code goes here...
|
10
20
|
end
|
21
|
+
|
22
|
+
# firefox_user_agent = "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.11; rv:43.0) Gecko/20100101 Firefox/43.0"
|
23
|
+
# chrome_user_agent = "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/55.0.2883.95 Safari/537.36"
|
24
|
+
#
|
25
|
+
# Request = Struct.new(:user_agent)
|
26
|
+
# request = Request.new(chrome_user_agent)
|
27
|
+
# puts request
|
28
|
+
# request_parser = RailsRequestParser.new(request)
|
29
|
+
# puts request_parser.is_chrome_browser?
|
@@ -1,3 +1,3 @@
|
|
1
|
-
|
2
|
-
VERSION = "0.1.
|
1
|
+
class RailsRequestParser
|
2
|
+
VERSION = "0.1.1"
|
3
3
|
end
|
data/tasks/rspec.rake
ADDED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rails_request_parser
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Joe Gesualdo
|
@@ -86,6 +86,7 @@ files:
|
|
86
86
|
- lib/rails_request_parser.rb
|
87
87
|
- lib/rails_request_parser/version.rb
|
88
88
|
- rails_request_parser.gemspec
|
89
|
+
- tasks/rspec.rake
|
89
90
|
homepage: ''
|
90
91
|
licenses:
|
91
92
|
- MIT
|