mobileesp_converted 0.2.0 → 0.2.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.
data/Rakefile
CHANGED
@@ -7,7 +7,7 @@ task :default => [:test]
|
|
7
7
|
desc "Download Java MobileESP source code to ./tmp directory."
|
8
8
|
task :download_source do
|
9
9
|
`mkdir -p java_source`
|
10
|
-
`cd java_source; wget http://mobileesp.googlecode.com/svn/Java/UAgentInfo.java`
|
10
|
+
`cd java_source; rm UAgentInfo.java; wget http://mobileesp.googlecode.com/svn/Java/UAgentInfo.java`
|
11
11
|
end
|
12
12
|
|
13
13
|
Rake::TestTask.new do |t|
|
data/java_source/UAgentInfo.java
CHANGED
@@ -1,6 +1,21 @@
|
|
1
1
|
/* *******************************************
|
2
2
|
// Copyright 2010-2012, Anthony Hand
|
3
3
|
//
|
4
|
+
// File version date: April 23, 2012
|
5
|
+
// Update:
|
6
|
+
// - Updated DetectAmazonSilk(): Fixed an issue in the detection logic.
|
7
|
+
//
|
8
|
+
// File version date: April 22, 2012 - Second update
|
9
|
+
// Update: To address additional Kindle issues...
|
10
|
+
// - Updated DetectRichCSS(): Excluded e-Ink Kindle devices.
|
11
|
+
// - Created DetectAmazonSilk(): Created to detect Kindle Fire devices in Silk mode.
|
12
|
+
// - Updated DetectMobileQuick(): Updated to include e-Ink Kindle devices and the Kindle Fire in Silk mode.
|
13
|
+
//
|
14
|
+
// File version date: April 11, 2012
|
15
|
+
// Update:
|
16
|
+
// - Added a new variable for the new BlackBerry Curve Touch (9380): deviceBBCurveTouch.
|
17
|
+
// - Updated DetectBlackBerryTouch() to support the new BlackBerry Curve Touch (9380).
|
18
|
+
//
|
4
19
|
// File version date: January 21, 2012
|
5
20
|
// Update:
|
6
21
|
// - Moved Windows Phone 7 to the iPhone Tier. WP7.5's IE 9-based browser is good enough now.
|
@@ -16,13 +31,6 @@
|
|
16
31
|
// Update:
|
17
32
|
// - Updated DetectAndroidTablet() to exclude Opera Mini, which was falsely reporting as running on a tablet device when on a phone.
|
18
33
|
//
|
19
|
-
// File version date: August 7, 2011
|
20
|
-
// Update:
|
21
|
-
// - The Opera for Android browser doesn't follow Google's recommended useragent string guidelines, so some fixes were needed.
|
22
|
-
// - Updated DetectAndroidPhone() and DetectAndroidTablet() to properly detect devices running Opera Mobile.
|
23
|
-
// - Created 2 new methods: DetectOperaAndroidPhone() and DetectOperaAndroidTablet().
|
24
|
-
// - Updated DetectTierIphone(). Removed the call to DetectMaemoTablet(), an obsolete mobile OS.
|
25
|
-
//
|
26
34
|
//
|
27
35
|
// LICENSE INFORMATION
|
28
36
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
@@ -106,6 +114,7 @@ public class UAgentInfo {
|
|
106
114
|
public static final String deviceBBBoldTouch = "blackberry 99"; //Bold 99x0 (touchscreen)
|
107
115
|
public static final String deviceBBTour = "blackberry96"; //Tour
|
108
116
|
public static final String deviceBBCurve = "blackberry89"; //Curve 2
|
117
|
+
public static final String deviceBBCurveTouch = "blackberry 938"; //Curve Touch 9380
|
109
118
|
public static final String deviceBBTorch = "blackberry 98"; //Torch
|
110
119
|
public static final String deviceBBPlaybook = "playbook"; //PlayBook tablet
|
111
120
|
|
@@ -116,7 +125,8 @@ public class UAgentInfo {
|
|
116
125
|
public static final String engineBlazer = "blazer"; //Old Palm
|
117
126
|
public static final String engineXiino = "xiino"; //Another old Palm
|
118
127
|
|
119
|
-
public static final String deviceKindle = "kindle"; //Amazon Kindle, eInk one
|
128
|
+
public static final String deviceKindle = "kindle"; //Amazon Kindle, eInk one
|
129
|
+
public static final String engineSilk = "silk"; //Amazon's accelerated Silk browser for Kindle Fire
|
120
130
|
|
121
131
|
public static final String deviceNuvifone = "nuvifone"; //Garmin Nuvifone
|
122
132
|
|
@@ -533,7 +543,8 @@ public class UAgentInfo {
|
|
533
543
|
if (detectBlackBerry() &&
|
534
544
|
(userAgent.indexOf(deviceBBStorm) != -1 ||
|
535
545
|
userAgent.indexOf(deviceBBTorch) != -1 ||
|
536
|
-
userAgent.indexOf(deviceBBBoldTouch) != -1
|
546
|
+
userAgent.indexOf(deviceBBBoldTouch) != -1 ||
|
547
|
+
userAgent.indexOf(deviceBBCurveTouch) != -1 )) {
|
537
548
|
return true;
|
538
549
|
}
|
539
550
|
return false;
|
@@ -745,6 +756,18 @@ public class UAgentInfo {
|
|
745
756
|
return false;
|
746
757
|
}
|
747
758
|
|
759
|
+
/**
|
760
|
+
* Detects if the current Amazon device is using the Silk Browser.
|
761
|
+
* Note: Typically used by the the Kindle Fire.
|
762
|
+
* @return detection of an Amazon Kindle Fire in Silk mode.
|
763
|
+
*/
|
764
|
+
public boolean detectAmazonSilk() {
|
765
|
+
if (userAgent.indexOf(engineSilk) != -1) {
|
766
|
+
return true;
|
767
|
+
}
|
768
|
+
return false;
|
769
|
+
}
|
770
|
+
|
748
771
|
/**
|
749
772
|
* Detects if the current device is a mobile device.
|
750
773
|
* This method catches most of the popular modern devices.
|
@@ -789,6 +812,12 @@ public class UAgentInfo {
|
|
789
812
|
return true;
|
790
813
|
}
|
791
814
|
|
815
|
+
//We also look for Kindle devices
|
816
|
+
if (detectKindle()
|
817
|
+
|| detectAmazonSilk()) {
|
818
|
+
return true;
|
819
|
+
}
|
820
|
+
|
792
821
|
return false;
|
793
822
|
}
|
794
823
|
|
@@ -990,7 +1019,8 @@ public class UAgentInfo {
|
|
990
1019
|
//Note: 'High' BlackBerry devices ONLY
|
991
1020
|
if (detectMobileQuick()) {
|
992
1021
|
|
993
|
-
|
1022
|
+
//Exclude iPhone Tier and e-Ink Kindle devices.
|
1023
|
+
if (!detectTierIphone() && !detectKindle()) {
|
994
1024
|
|
995
1025
|
//The following devices are explicitly ok.
|
996
1026
|
//Note: 'High' BlackBerry devices ONLY
|
@@ -6,6 +6,21 @@
|
|
6
6
|
*******************************************
|
7
7
|
# Copyright 2010-2012, Anthony Hand
|
8
8
|
#
|
9
|
+
# File version date: April 23, 2012
|
10
|
+
# Update:
|
11
|
+
# - Updated DetectAmazonSilk(): Fixed an issue in the detection logic.
|
12
|
+
#
|
13
|
+
# File version date: April 22, 2012 - Second update
|
14
|
+
# Update: To address additional Kindle issues...
|
15
|
+
# - Updated DetectRichCSS(): Excluded e-Ink Kindle devices.
|
16
|
+
# - Created DetectAmazonSilk(): Created to detect Kindle Fire devices in Silk mode.
|
17
|
+
# - Updated DetectMobileQuick(): Updated to include e-Ink Kindle devices and the Kindle Fire in Silk mode.
|
18
|
+
#
|
19
|
+
# File version date: April 11, 2012
|
20
|
+
# Update:
|
21
|
+
# - Added a new variable for the new BlackBerry Curve Touch (9380): deviceBBCurveTouch.
|
22
|
+
# - Updated DetectBlackBerryTouch() to support the new BlackBerry Curve Touch (9380).
|
23
|
+
#
|
9
24
|
# File version date: January 21, 2012
|
10
25
|
# Update:
|
11
26
|
# - Moved Windows Phone 7 to the iPhone Tier. WP7.5's IE 9-based browser is good enough now.
|
@@ -21,13 +36,6 @@
|
|
21
36
|
# Update:
|
22
37
|
# - Updated DetectAndroidTablet() to exclude Opera Mini, which was falsely reporting as running on a tablet device when on a phone.
|
23
38
|
#
|
24
|
-
# File version date: August 7, 2011
|
25
|
-
# Update:
|
26
|
-
# - The Opera for Android browser doesn't follow Google's recommended useragent string guidelines, so some fixes were needed.
|
27
|
-
# - Updated DetectAndroidPhone() and DetectAndroidTablet() to properly detect devices running Opera Mobile.
|
28
|
-
# - Created 2 new methods: DetectOperaAndroidPhone() and DetectOperaAndroidTablet().
|
29
|
-
# - Updated DetectTierIphone(). Removed the call to DetectMaemoTablet(), an obsolete mobile OS.
|
30
|
-
#
|
31
39
|
#
|
32
40
|
# LICENSE INFORMATION
|
33
41
|
# Licensed under the Apache License, Version 2.0 (the "License")
|
@@ -115,6 +123,7 @@ module MobileESPConverted
|
|
115
123
|
DEVICE_B_B_BOLD_TOUCH = "blackberry 99"
|
116
124
|
DEVICE_B_B_TOUR = "blackberry96"
|
117
125
|
DEVICE_B_B_CURVE = "blackberry89"
|
126
|
+
DEVICE_B_B_CURVE_TOUCH = "blackberry 938"
|
118
127
|
DEVICE_B_B_TORCH = "blackberry 98"
|
119
128
|
DEVICE_B_B_PLAYBOOK = "playbook"
|
120
129
|
|
@@ -126,6 +135,7 @@ module MobileESPConverted
|
|
126
135
|
ENGINE_XIINO = "xiino"
|
127
136
|
|
128
137
|
DEVICE_KINDLE = "kindle"
|
138
|
+
ENGINE_SILK = "silk"
|
129
139
|
|
130
140
|
DEVICE_NUVIFONE = "nuvifone"
|
131
141
|
|
@@ -595,7 +605,8 @@ module MobileESPConverted
|
|
595
605
|
if (detect_black_berry() &&
|
596
606
|
(user_agent.include?(DEVICE_B_B_STORM) ||
|
597
607
|
user_agent.include?(DEVICE_B_B_TORCH) ||
|
598
|
-
user_agent.include?(DEVICE_B_B_BOLD_TOUCH)
|
608
|
+
user_agent.include?(DEVICE_B_B_BOLD_TOUCH) ||
|
609
|
+
user_agent.include?(DEVICE_B_B_CURVE_TOUCH) ))
|
599
610
|
return true
|
600
611
|
end
|
601
612
|
return false
|
@@ -812,6 +823,20 @@ module MobileESPConverted
|
|
812
823
|
return false
|
813
824
|
end
|
814
825
|
|
826
|
+
=begin
|
827
|
+
*
|
828
|
+
* Detects if the current Amazon device is using the Silk Browser.
|
829
|
+
* Note: Typically used by the the Kindle Fire.
|
830
|
+
* @return detection of an Amazon Kindle Fire in Silk mode.
|
831
|
+
|
832
|
+
=end
|
833
|
+
def detect_amazon_silk()
|
834
|
+
if (user_agent.include?(ENGINE_SILK))
|
835
|
+
return true
|
836
|
+
end
|
837
|
+
return false
|
838
|
+
end
|
839
|
+
|
815
840
|
=begin
|
816
841
|
*
|
817
842
|
* Detects if the current device is a mobile device.
|
@@ -850,6 +875,11 @@ module MobileESPConverted
|
|
850
875
|
return true
|
851
876
|
end
|
852
877
|
|
878
|
+
|
879
|
+
if (detect_kindle() || detect_amazon_silk())
|
880
|
+
return true
|
881
|
+
end
|
882
|
+
|
853
883
|
return false
|
854
884
|
end
|
855
885
|
|
@@ -1054,7 +1084,8 @@ module MobileESPConverted
|
|
1054
1084
|
|
1055
1085
|
if (detect_mobile_quick())
|
1056
1086
|
|
1057
|
-
|
1087
|
+
|
1088
|
+
if (!detect_tier_iphone() && !detect_kindle())
|
1058
1089
|
|
1059
1090
|
|
1060
1091
|
|
data/mobileesp_converted.gemspec
CHANGED
@@ -106,6 +106,32 @@ module MobileESPConverted
|
|
106
106
|
uai.detect_android_phone.must_equal false
|
107
107
|
uai.detect_android_tablet.must_equal false
|
108
108
|
end
|
109
|
+
|
110
|
+
# categorization according to original MobileESP implementation
|
111
|
+
it "categorizes Kindle Fire" do
|
112
|
+
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")
|
113
|
+
uai.is_tier_tablet.must_equal false
|
114
|
+
uai.is_tier_iphone.must_equal true
|
115
|
+
uai.is_tier_rich_css.must_equal false
|
116
|
+
uai.is_tier_generic_mobile.must_equal false
|
117
|
+
uai.detect_iphone.must_equal false
|
118
|
+
uai.detect_ipad.must_equal false
|
119
|
+
uai.detect_android_phone.must_equal true
|
120
|
+
uai.detect_android_tablet.must_equal false
|
121
|
+
end
|
122
|
+
|
123
|
+
# categorization according to original MobileESP implementation
|
124
|
+
it "categorizes Kindle Fire silk mode" do
|
125
|
+
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")
|
126
|
+
uai.is_tier_tablet.must_equal false
|
127
|
+
uai.is_tier_iphone.must_equal false
|
128
|
+
uai.is_tier_rich_css.must_equal true
|
129
|
+
uai.is_tier_generic_mobile.must_equal false
|
130
|
+
uai.detect_iphone.must_equal false
|
131
|
+
uai.detect_ipad.must_equal false
|
132
|
+
uai.detect_android_phone.must_equal false
|
133
|
+
uai.detect_android_tablet.must_equal false
|
134
|
+
end
|
109
135
|
end
|
110
136
|
end
|
111
137
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mobileesp_converted
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -10,11 +10,11 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2012-
|
13
|
+
date: 2012-11-11 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: pry
|
17
|
-
requirement:
|
17
|
+
requirement: !ruby/object:Gem::Requirement
|
18
18
|
none: false
|
19
19
|
requirements:
|
20
20
|
- - ! '>='
|
@@ -22,10 +22,31 @@ dependencies:
|
|
22
22
|
version: '0'
|
23
23
|
type: :development
|
24
24
|
prerelease: false
|
25
|
-
version_requirements:
|
25
|
+
version_requirements: !ruby/object:Gem::Requirement
|
26
|
+
none: false
|
27
|
+
requirements:
|
28
|
+
- - ! '>='
|
29
|
+
- !ruby/object:Gem::Version
|
30
|
+
version: '0'
|
31
|
+
- !ruby/object:Gem::Dependency
|
32
|
+
name: rake
|
33
|
+
requirement: !ruby/object:Gem::Requirement
|
34
|
+
none: false
|
35
|
+
requirements:
|
36
|
+
- - ! '>='
|
37
|
+
- !ruby/object:Gem::Version
|
38
|
+
version: '0'
|
39
|
+
type: :development
|
40
|
+
prerelease: false
|
41
|
+
version_requirements: !ruby/object:Gem::Requirement
|
42
|
+
none: false
|
43
|
+
requirements:
|
44
|
+
- - ! '>='
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: '0'
|
26
47
|
- !ruby/object:Gem::Dependency
|
27
48
|
name: minitest
|
28
|
-
requirement:
|
49
|
+
requirement: !ruby/object:Gem::Requirement
|
29
50
|
none: false
|
30
51
|
requirements:
|
31
52
|
- - ! '>='
|
@@ -33,7 +54,12 @@ dependencies:
|
|
33
54
|
version: '0'
|
34
55
|
type: :development
|
35
56
|
prerelease: false
|
36
|
-
version_requirements:
|
57
|
+
version_requirements: !ruby/object:Gem::Requirement
|
58
|
+
none: false
|
59
|
+
requirements:
|
60
|
+
- - ! '>='
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
version: '0'
|
37
63
|
description: Autoconverted version (from Java to Ruby) of MobileESP library.
|
38
64
|
email:
|
39
65
|
- jistr@jistr.com
|
@@ -67,7 +93,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
67
93
|
version: '0'
|
68
94
|
segments:
|
69
95
|
- 0
|
70
|
-
hash:
|
96
|
+
hash: -745614850810800464
|
71
97
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
72
98
|
none: false
|
73
99
|
requirements:
|
@@ -76,11 +102,13 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
76
102
|
version: '0'
|
77
103
|
segments:
|
78
104
|
- 0
|
79
|
-
hash:
|
105
|
+
hash: -745614850810800464
|
80
106
|
requirements: []
|
81
107
|
rubyforge_project:
|
82
|
-
rubygems_version: 1.8.
|
108
|
+
rubygems_version: 1.8.23
|
83
109
|
signing_key:
|
84
110
|
specification_version: 3
|
85
111
|
summary: Provides device type detection based on HTTP request headers.
|
86
|
-
test_files:
|
112
|
+
test_files:
|
113
|
+
- spec/mobileesp_converted/user_agent_info_spec.rb
|
114
|
+
- spec/spec_helper.rb
|