onfocusio-mobileesp_converted 0.2.3.onf2
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 +7 -0
- data/.gitignore +8 -0
- data/Gemfile +4 -0
- data/LICENSE +176 -0
- data/README.md +18 -0
- data/Rakefile +16 -0
- data/convert_to_ruby.vim +236 -0
- data/java_source/UAgentInfo.java +1305 -0
- data/lib/mobileesp_converted/user_agent_info.rb +1394 -0
- data/lib/mobileesp_converted/version.rb +3 -0
- data/lib/onfocusio-mobileesp_converted.rb +5 -0
- data/onfocusio-mobileesp_converted.gemspec +25 -0
- data/spec/mobileesp_converted/user_agent_info_spec.rb +177 -0
- data/spec/spec_helper.rb +4 -0
- metadata +102 -0
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
|
2
|
+
require File.expand_path('../lib/mobileesp_converted/version', __FILE__)
|
|
3
|
+
|
|
4
|
+
Gem::Specification.new do |gem|
|
|
5
|
+
gem.authors = ["Anthony Hand", "Jiří Stránský", "Nicolas Fouché"]
|
|
6
|
+
gem.email = ["jistr@jistr.com"]
|
|
7
|
+
gem.description = %q{Autoconverted version (from Java to Ruby) of MobileESP library.}
|
|
8
|
+
gem.summary = %q{Provides device type detection based on HTTP request headers.}
|
|
9
|
+
gem.homepage = "https://github.com/onfocusio/mobileesp_converted/tree/onfocusio-mobileesp_converted"
|
|
10
|
+
|
|
11
|
+
gem.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
|
12
|
+
gem.files = `git ls-files`.split("\n")
|
|
13
|
+
gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
|
14
|
+
gem.name = "onfocusio-mobileesp_converted"
|
|
15
|
+
gem.require_paths = ["lib"]
|
|
16
|
+
gem.version = MobileESPConverted::VERSION
|
|
17
|
+
|
|
18
|
+
# == DEVELOPMENT DEPENDENCIES ==
|
|
19
|
+
# Smart irb
|
|
20
|
+
gem.add_development_dependency 'pry'
|
|
21
|
+
|
|
22
|
+
gem.add_development_dependency 'rake'
|
|
23
|
+
# Specs
|
|
24
|
+
gem.add_development_dependency 'minitest'
|
|
25
|
+
end
|
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
require_relative '../spec_helper'
|
|
2
|
+
|
|
3
|
+
module MobileESPConverted
|
|
4
|
+
class UserAgentInfoSpec < MiniTest::Spec
|
|
5
|
+
describe UserAgentInfo do
|
|
6
|
+
it "categorizes iPhone/Safari" do
|
|
7
|
+
uai = UserAgentInfo.new("Mozilla/5.0 (iPhone; U; CPU iPhone OS 4_0 like Mac OS X; en-us) AppleWebKit/532.9 (KHTML, like Gecko) Version/4.0.5 Mobile/8A293 Safari/6531.22.7", "text/html")
|
|
8
|
+
uai.is_tier_tablet.must_equal false
|
|
9
|
+
uai.is_tier_iphone.must_equal true
|
|
10
|
+
uai.is_tier_rich_css.must_equal false
|
|
11
|
+
uai.is_tier_generic_mobile.must_equal false
|
|
12
|
+
uai.detect_iphone.must_equal true
|
|
13
|
+
uai.detect_ipad.must_equal false
|
|
14
|
+
uai.detect_android_phone.must_equal false
|
|
15
|
+
uai.detect_android_tablet.must_equal false
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
it "categorizes iPad/Safari" do
|
|
19
|
+
uai = UserAgentInfo.new("Mozilla/5.0 (iPad; U; CPU iPhone OS 3_2 like Mac OS X; en-us) AppleWebKit/531.21.10 (KHTML, like Gecko) Version/4.0.4 Mobile/7B314 Safari/531.21.10", "text/html")
|
|
20
|
+
uai.detect_ipad.must_equal true
|
|
21
|
+
uai.is_iphone.must_equal false
|
|
22
|
+
uai.is_tier_tablet.must_equal true
|
|
23
|
+
uai.is_tier_iphone.must_equal false
|
|
24
|
+
uai.is_tier_rich_css.must_equal false
|
|
25
|
+
uai.is_tier_generic_mobile.must_equal false
|
|
26
|
+
uai.detect_iphone.must_equal false
|
|
27
|
+
uai.detect_ipad.must_equal true
|
|
28
|
+
uai.detect_android_phone.must_equal false
|
|
29
|
+
uai.detect_android_tablet.must_equal false
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
it "categorizes iPad Pro/Safari" do
|
|
33
|
+
uai = UserAgentInfo.new("Mozilla/5.0 (iPad; CPU OS 10_3_1 like Mac OS X) AppleWebKit/603.1.30 (KHTML, like Gecko) Version/10.0 Mobile/14E8301 Safari/602.1", "text/html")
|
|
34
|
+
uai.detect_ipad.must_equal true
|
|
35
|
+
uai.is_iphone.must_equal false
|
|
36
|
+
uai.is_tier_tablet.must_equal true
|
|
37
|
+
uai.is_tier_iphone.must_equal false
|
|
38
|
+
uai.is_tier_rich_css.must_equal false
|
|
39
|
+
uai.is_tier_generic_mobile.must_equal false
|
|
40
|
+
uai.detect_iphone.must_equal false
|
|
41
|
+
uai.detect_ipad.must_equal true
|
|
42
|
+
uai.detect_android_phone.must_equal false
|
|
43
|
+
uai.detect_android_tablet.must_equal false
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
it "categorizes Android phone / Android Browser" do
|
|
47
|
+
# UA string for Google Nexus S
|
|
48
|
+
uai = UserAgentInfo.new("Mozilla/5.0 (Linux; U; Android 2.3.4; fr-fr; Nexus S Build/GRJ22) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 Mobile Safari/533.1", "text/html")
|
|
49
|
+
uai.is_tier_tablet.must_equal false
|
|
50
|
+
uai.is_tier_iphone.must_equal true
|
|
51
|
+
uai.is_tier_rich_css.must_equal false
|
|
52
|
+
uai.is_tier_generic_mobile.must_equal false
|
|
53
|
+
uai.detect_iphone.must_equal false
|
|
54
|
+
uai.detect_ipad.must_equal false
|
|
55
|
+
uai.detect_android_phone.must_equal true
|
|
56
|
+
uai.detect_android_tablet.must_equal false
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
it "categorizes Android 4 phone / Custom Android Browser" do
|
|
60
|
+
# UA string for Xiaomi Hongmi (Red Rice)
|
|
61
|
+
uai = UserAgentInfo.new("Mozilla/5.0 (Linux; U; Android 4.2.1; ru-ru; HM2013023 Build/JOP40D) AppleWebKit/534.30 (KHTML, like Gecko) Version/4.0 Mobile Safari/534.30 XiaoMi/MiuiBrowser/1.0", "text/html")
|
|
62
|
+
uai.is_tier_tablet.must_equal false
|
|
63
|
+
uai.is_tier_iphone.must_equal true
|
|
64
|
+
uai.is_tier_rich_css.must_equal false
|
|
65
|
+
uai.is_tier_generic_mobile.must_equal false
|
|
66
|
+
uai.detect_iphone.must_equal false
|
|
67
|
+
uai.detect_ipad.must_equal false
|
|
68
|
+
uai.detect_android_phone.must_equal true
|
|
69
|
+
uai.detect_android_tablet.must_equal false
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
it "categorizes Android tablet / Android Browser" do
|
|
73
|
+
# UA string for Motorola Xoom
|
|
74
|
+
uai = UserAgentInfo.new("Mozilla/5.0 (Linux; U; Android 3.0; en-us; Xoom Build/HRI39) AppleWebKit/534.13 (KHTML, like Gecko) Version/4.0 Safari/534.13", "text/html")
|
|
75
|
+
uai.is_tier_tablet.must_equal true
|
|
76
|
+
uai.is_tier_iphone.must_equal false
|
|
77
|
+
uai.is_tier_rich_css.must_equal false
|
|
78
|
+
uai.is_tier_generic_mobile.must_equal false
|
|
79
|
+
uai.detect_iphone.must_equal false
|
|
80
|
+
uai.detect_ipad.must_equal false
|
|
81
|
+
uai.detect_android_phone.must_equal false
|
|
82
|
+
uai.detect_android_tablet.must_equal true
|
|
83
|
+
end
|
|
84
|
+
|
|
85
|
+
it "categorizes Android tablet / Chrome Browser" do
|
|
86
|
+
# UA string for Chrome on Pipo M9 Pro
|
|
87
|
+
uai = UserAgentInfo.new("Mozilla/5.0 (Linux; Android 4.2.2; M9pro Build/JDQ39) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/31.0.1650.59 Safari/537.36", "text/html")
|
|
88
|
+
uai.is_tier_tablet.must_equal true
|
|
89
|
+
uai.is_tier_iphone.must_equal false
|
|
90
|
+
uai.is_tier_rich_css.must_equal false
|
|
91
|
+
uai.is_tier_generic_mobile.must_equal false
|
|
92
|
+
uai.detect_iphone.must_equal false
|
|
93
|
+
uai.detect_ipad.must_equal false
|
|
94
|
+
uai.detect_android_phone.must_equal false
|
|
95
|
+
uai.detect_android_tablet.must_equal true
|
|
96
|
+
end
|
|
97
|
+
|
|
98
|
+
it "categorizes Android / Opera Mobile" do
|
|
99
|
+
# Opera Mobile 12
|
|
100
|
+
uai = UserAgentInfo.new("Opera/9.80 (Android 2.2.2; Linux; Opera Mobi/ADR-1202231246; U; en) Presto/2.10.254 Version/12.00", "text/html")
|
|
101
|
+
uai.is_tier_tablet.must_equal false
|
|
102
|
+
uai.is_tier_iphone.must_equal true
|
|
103
|
+
uai.is_tier_rich_css.must_equal false
|
|
104
|
+
uai.is_tier_generic_mobile.must_equal false
|
|
105
|
+
uai.detect_opera_mobile.must_equal true
|
|
106
|
+
uai.detect_iphone.must_equal false
|
|
107
|
+
uai.detect_ipad.must_equal false
|
|
108
|
+
uai.detect_android_phone.must_equal true
|
|
109
|
+
uai.detect_android_tablet.must_equal false
|
|
110
|
+
end
|
|
111
|
+
|
|
112
|
+
it "categorizes Linux/Chrome" do
|
|
113
|
+
uai = UserAgentInfo.new("Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/535.11 (KHTML, like Gecko) Chrome/17.0.963.46 Safari/535.11", "text/html")
|
|
114
|
+
uai.is_tier_tablet.must_equal false
|
|
115
|
+
uai.is_tier_iphone.must_equal false
|
|
116
|
+
uai.is_tier_rich_css.must_equal false
|
|
117
|
+
uai.is_tier_generic_mobile.must_equal false
|
|
118
|
+
uai.detect_iphone.must_equal false
|
|
119
|
+
uai.detect_ipad.must_equal false
|
|
120
|
+
uai.detect_android_phone.must_equal false
|
|
121
|
+
uai.detect_android_tablet.must_equal false
|
|
122
|
+
end
|
|
123
|
+
|
|
124
|
+
it "categorizes Windows/IE" do
|
|
125
|
+
# IE 9 on Windows 7
|
|
126
|
+
uai = UserAgentInfo.new("Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; WOW64; Trident/5.0; SLCC2; Media Center PC 6.0; InfoPath.3; MS-RTC LM 8; Zune 4.7)", "text/html")
|
|
127
|
+
uai.is_tier_tablet.must_equal false
|
|
128
|
+
uai.is_tier_iphone.must_equal false
|
|
129
|
+
uai.is_tier_rich_css.must_equal false
|
|
130
|
+
uai.is_tier_generic_mobile.must_equal false
|
|
131
|
+
uai.detect_iphone.must_equal false
|
|
132
|
+
uai.detect_ipad.must_equal false
|
|
133
|
+
uai.detect_android_phone.must_equal false
|
|
134
|
+
uai.detect_android_tablet.must_equal false
|
|
135
|
+
end
|
|
136
|
+
|
|
137
|
+
it "categorizes Mac/Safari" do
|
|
138
|
+
# Safari 5 on Snow Leopard
|
|
139
|
+
uai = UserAgentInfo.new("Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_8; de-at) AppleWebKit/533.21.1 (KHTML, like Gecko) Version/5.0.5 Safari/533.21.1", "text/html")
|
|
140
|
+
uai.is_tier_tablet.must_equal false
|
|
141
|
+
uai.is_tier_iphone.must_equal false
|
|
142
|
+
uai.is_tier_rich_css.must_equal false
|
|
143
|
+
uai.is_tier_generic_mobile.must_equal false
|
|
144
|
+
uai.detect_iphone.must_equal false
|
|
145
|
+
uai.detect_ipad.must_equal false
|
|
146
|
+
uai.detect_android_phone.must_equal false
|
|
147
|
+
uai.detect_android_tablet.must_equal false
|
|
148
|
+
end
|
|
149
|
+
|
|
150
|
+
# categorization according to original MobileESP implementation
|
|
151
|
+
it "categorizes Kindle Fire" do
|
|
152
|
+
uai = UserAgentInfo.new("Mozilla/5.0 (Linux; U; Android 2.3.4; en-us; Kindle Fire Build/GINGERBREAD) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 Mobile Safari/533.1", "text/html")
|
|
153
|
+
uai.is_tier_tablet.must_equal false
|
|
154
|
+
uai.is_tier_iphone.must_equal true
|
|
155
|
+
uai.is_tier_rich_css.must_equal false
|
|
156
|
+
uai.is_tier_generic_mobile.must_equal false
|
|
157
|
+
uai.detect_iphone.must_equal false
|
|
158
|
+
uai.detect_ipad.must_equal false
|
|
159
|
+
uai.detect_android_phone.must_equal true
|
|
160
|
+
uai.detect_android_tablet.must_equal false
|
|
161
|
+
end
|
|
162
|
+
|
|
163
|
+
# categorization according to original MobileESP implementation
|
|
164
|
+
it "categorizes Kindle Fire silk mode" do
|
|
165
|
+
uai = UserAgentInfo.new("Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_3; en-us; Silk/1.1.0-80) AppleWebKit/533.16 (KHTML, like Gecko) Version/5.0 Safari/533.16 Silk-Accelerated=true", "text/html")
|
|
166
|
+
uai.is_tier_tablet.must_equal false
|
|
167
|
+
uai.is_tier_iphone.must_equal false
|
|
168
|
+
uai.is_tier_rich_css.must_equal true
|
|
169
|
+
uai.is_tier_generic_mobile.must_equal false
|
|
170
|
+
uai.detect_iphone.must_equal false
|
|
171
|
+
uai.detect_ipad.must_equal false
|
|
172
|
+
uai.detect_android_phone.must_equal false
|
|
173
|
+
uai.detect_android_tablet.must_equal false
|
|
174
|
+
end
|
|
175
|
+
end
|
|
176
|
+
end
|
|
177
|
+
end
|
data/spec/spec_helper.rb
ADDED
metadata
ADDED
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: onfocusio-mobileesp_converted
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.2.3.onf2
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- Anthony Hand
|
|
8
|
+
- Jiří Stránský
|
|
9
|
+
- Nicolas Fouché
|
|
10
|
+
autorequire:
|
|
11
|
+
bindir: bin
|
|
12
|
+
cert_chain: []
|
|
13
|
+
date: 2017-06-27 00:00:00.000000000 Z
|
|
14
|
+
dependencies:
|
|
15
|
+
- !ruby/object:Gem::Dependency
|
|
16
|
+
name: pry
|
|
17
|
+
requirement: !ruby/object:Gem::Requirement
|
|
18
|
+
requirements:
|
|
19
|
+
- - ">="
|
|
20
|
+
- !ruby/object:Gem::Version
|
|
21
|
+
version: '0'
|
|
22
|
+
type: :development
|
|
23
|
+
prerelease: false
|
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
25
|
+
requirements:
|
|
26
|
+
- - ">="
|
|
27
|
+
- !ruby/object:Gem::Version
|
|
28
|
+
version: '0'
|
|
29
|
+
- !ruby/object:Gem::Dependency
|
|
30
|
+
name: rake
|
|
31
|
+
requirement: !ruby/object:Gem::Requirement
|
|
32
|
+
requirements:
|
|
33
|
+
- - ">="
|
|
34
|
+
- !ruby/object:Gem::Version
|
|
35
|
+
version: '0'
|
|
36
|
+
type: :development
|
|
37
|
+
prerelease: false
|
|
38
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
39
|
+
requirements:
|
|
40
|
+
- - ">="
|
|
41
|
+
- !ruby/object:Gem::Version
|
|
42
|
+
version: '0'
|
|
43
|
+
- !ruby/object:Gem::Dependency
|
|
44
|
+
name: minitest
|
|
45
|
+
requirement: !ruby/object:Gem::Requirement
|
|
46
|
+
requirements:
|
|
47
|
+
- - ">="
|
|
48
|
+
- !ruby/object:Gem::Version
|
|
49
|
+
version: '0'
|
|
50
|
+
type: :development
|
|
51
|
+
prerelease: false
|
|
52
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
53
|
+
requirements:
|
|
54
|
+
- - ">="
|
|
55
|
+
- !ruby/object:Gem::Version
|
|
56
|
+
version: '0'
|
|
57
|
+
description: Autoconverted version (from Java to Ruby) of MobileESP library.
|
|
58
|
+
email:
|
|
59
|
+
- jistr@jistr.com
|
|
60
|
+
executables: []
|
|
61
|
+
extensions: []
|
|
62
|
+
extra_rdoc_files: []
|
|
63
|
+
files:
|
|
64
|
+
- ".gitignore"
|
|
65
|
+
- Gemfile
|
|
66
|
+
- LICENSE
|
|
67
|
+
- README.md
|
|
68
|
+
- Rakefile
|
|
69
|
+
- convert_to_ruby.vim
|
|
70
|
+
- java_source/UAgentInfo.java
|
|
71
|
+
- lib/mobileesp_converted/user_agent_info.rb
|
|
72
|
+
- lib/mobileesp_converted/version.rb
|
|
73
|
+
- lib/onfocusio-mobileesp_converted.rb
|
|
74
|
+
- onfocusio-mobileesp_converted.gemspec
|
|
75
|
+
- spec/mobileesp_converted/user_agent_info_spec.rb
|
|
76
|
+
- spec/spec_helper.rb
|
|
77
|
+
homepage: https://github.com/onfocusio/mobileesp_converted/tree/onfocusio-mobileesp_converted
|
|
78
|
+
licenses: []
|
|
79
|
+
metadata: {}
|
|
80
|
+
post_install_message:
|
|
81
|
+
rdoc_options: []
|
|
82
|
+
require_paths:
|
|
83
|
+
- lib
|
|
84
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
85
|
+
requirements:
|
|
86
|
+
- - ">="
|
|
87
|
+
- !ruby/object:Gem::Version
|
|
88
|
+
version: '0'
|
|
89
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
90
|
+
requirements:
|
|
91
|
+
- - ">"
|
|
92
|
+
- !ruby/object:Gem::Version
|
|
93
|
+
version: 1.3.1
|
|
94
|
+
requirements: []
|
|
95
|
+
rubyforge_project:
|
|
96
|
+
rubygems_version: 2.6.8
|
|
97
|
+
signing_key:
|
|
98
|
+
specification_version: 4
|
|
99
|
+
summary: Provides device type detection based on HTTP request headers.
|
|
100
|
+
test_files:
|
|
101
|
+
- spec/mobileesp_converted/user_agent_info_spec.rb
|
|
102
|
+
- spec/spec_helper.rb
|