mobileesp_converted 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +7 -0
- data/Gemfile +4 -0
- data/README.md +18 -0
- data/Rakefile +16 -0
- data/convert_to_ruby.vim +236 -0
- data/java_source/UAgentInfo.java +1026 -0
- data/lib/mobileesp_converted/u_agent_info.rb +1086 -0
- data/lib/mobileesp_converted/version.rb +3 -0
- data/lib/mobileesp_converted.rb +5 -0
- data/mobileesp_converted.gemspec +24 -0
- data/spec/mobileesp_converted/u_agent_info_spec.rb +111 -0
- data/spec/spec_helper.rb +4 -0
- metadata +86 -0
@@ -0,0 +1,24 @@
|
|
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ý"]
|
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 = "http://github.com/jistr/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 = "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
|
+
# Specs
|
23
|
+
gem.add_development_dependency 'minitest'
|
24
|
+
end
|
@@ -0,0 +1,111 @@
|
|
1
|
+
require_relative '../spec_helper'
|
2
|
+
|
3
|
+
module MobileESPConverted
|
4
|
+
class UAgentInfoSpec < MiniTest::Spec
|
5
|
+
describe UAgentInfo do
|
6
|
+
it "categorizes iPhone/Safari" do
|
7
|
+
uai = UAgentInfo.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 = UAgentInfo.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 Android phone / Android Browser" do
|
33
|
+
# UA string for Google Nexus S
|
34
|
+
uai = UAgentInfo.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")
|
35
|
+
uai.is_tier_tablet.must_equal false
|
36
|
+
uai.is_tier_iphone.must_equal true
|
37
|
+
uai.is_tier_rich_css.must_equal false
|
38
|
+
uai.is_tier_generic_mobile.must_equal false
|
39
|
+
uai.detect_iphone.must_equal false
|
40
|
+
uai.detect_ipad.must_equal false
|
41
|
+
uai.detect_android_phone.must_equal true
|
42
|
+
uai.detect_android_tablet.must_equal false
|
43
|
+
end
|
44
|
+
|
45
|
+
it "categorizes Android tablet / Android Browser" do
|
46
|
+
# UA string for Motorola Xoom
|
47
|
+
uai = UAgentInfo.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")
|
48
|
+
uai.is_tier_tablet.must_equal true
|
49
|
+
uai.is_tier_iphone.must_equal false
|
50
|
+
uai.is_tier_rich_css.must_equal false
|
51
|
+
uai.is_tier_generic_mobile.must_equal false
|
52
|
+
uai.detect_iphone.must_equal false
|
53
|
+
uai.detect_ipad.must_equal false
|
54
|
+
uai.detect_android_phone.must_equal false
|
55
|
+
uai.detect_android_tablet.must_equal true
|
56
|
+
end
|
57
|
+
|
58
|
+
it "categorizes Android / Opera Mobile" do
|
59
|
+
# Opera Mobile 12
|
60
|
+
uai = UAgentInfo.new("Opera/9.80 (Android 2.2.2; Linux; Opera Mobi/ADR-1202231246; U; en) Presto/2.10.254 Version/12.00", "text/html")
|
61
|
+
uai.is_tier_tablet.must_equal false
|
62
|
+
uai.is_tier_iphone.must_equal true
|
63
|
+
uai.is_tier_rich_css.must_equal false
|
64
|
+
uai.is_tier_generic_mobile.must_equal false
|
65
|
+
uai.detect_opera_mobile.must_equal true
|
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 Linux/Chrome" do
|
73
|
+
uai = UAgentInfo.new("Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/535.11 (KHTML, like Gecko) Chrome/17.0.963.46 Safari/535.11", "text/html")
|
74
|
+
uai.is_tier_tablet.must_equal false
|
75
|
+
uai.is_tier_iphone.must_equal false
|
76
|
+
uai.is_tier_rich_css.must_equal false
|
77
|
+
uai.is_tier_generic_mobile.must_equal false
|
78
|
+
uai.detect_iphone.must_equal false
|
79
|
+
uai.detect_ipad.must_equal false
|
80
|
+
uai.detect_android_phone.must_equal false
|
81
|
+
uai.detect_android_tablet.must_equal false
|
82
|
+
end
|
83
|
+
|
84
|
+
it "categorizes Windows/IE" do
|
85
|
+
# IE 9 on Windows 7
|
86
|
+
uai = UAgentInfo.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")
|
87
|
+
uai.is_tier_tablet.must_equal false
|
88
|
+
uai.is_tier_iphone.must_equal false
|
89
|
+
uai.is_tier_rich_css.must_equal false
|
90
|
+
uai.is_tier_generic_mobile.must_equal false
|
91
|
+
uai.detect_iphone.must_equal false
|
92
|
+
uai.detect_ipad.must_equal false
|
93
|
+
uai.detect_android_phone.must_equal false
|
94
|
+
uai.detect_android_tablet.must_equal false
|
95
|
+
end
|
96
|
+
|
97
|
+
it "categorizes Mac/Safari" do
|
98
|
+
# Safari 5 on Snow Leopard
|
99
|
+
uai = UAgentInfo.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")
|
100
|
+
uai.is_tier_tablet.must_equal false
|
101
|
+
uai.is_tier_iphone.must_equal false
|
102
|
+
uai.is_tier_rich_css.must_equal false
|
103
|
+
uai.is_tier_generic_mobile.must_equal false
|
104
|
+
uai.detect_iphone.must_equal false
|
105
|
+
uai.detect_ipad.must_equal false
|
106
|
+
uai.detect_android_phone.must_equal false
|
107
|
+
uai.detect_android_tablet.must_equal false
|
108
|
+
end
|
109
|
+
end
|
110
|
+
end
|
111
|
+
end
|
data/spec/spec_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,86 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: mobileesp_converted
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Anthony Hand
|
9
|
+
- Jiří Stránský
|
10
|
+
autorequire:
|
11
|
+
bindir: bin
|
12
|
+
cert_chain: []
|
13
|
+
date: 2012-03-12 00:00:00.000000000 Z
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: pry
|
17
|
+
requirement: &22740900 !ruby/object:Gem::Requirement
|
18
|
+
none: false
|
19
|
+
requirements:
|
20
|
+
- - ! '>='
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: '0'
|
23
|
+
type: :development
|
24
|
+
prerelease: false
|
25
|
+
version_requirements: *22740900
|
26
|
+
- !ruby/object:Gem::Dependency
|
27
|
+
name: minitest
|
28
|
+
requirement: &22740460 !ruby/object:Gem::Requirement
|
29
|
+
none: false
|
30
|
+
requirements:
|
31
|
+
- - ! '>='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: *22740460
|
37
|
+
description: Autoconverted version (from Java to Ruby) of MobileESP library.
|
38
|
+
email:
|
39
|
+
- jistr@jistr.com
|
40
|
+
executables: []
|
41
|
+
extensions: []
|
42
|
+
extra_rdoc_files: []
|
43
|
+
files:
|
44
|
+
- .gitignore
|
45
|
+
- Gemfile
|
46
|
+
- README.md
|
47
|
+
- Rakefile
|
48
|
+
- convert_to_ruby.vim
|
49
|
+
- java_source/UAgentInfo.java
|
50
|
+
- lib/mobileesp_converted.rb
|
51
|
+
- lib/mobileesp_converted/u_agent_info.rb
|
52
|
+
- lib/mobileesp_converted/version.rb
|
53
|
+
- mobileesp_converted.gemspec
|
54
|
+
- spec/mobileesp_converted/u_agent_info_spec.rb
|
55
|
+
- spec/spec_helper.rb
|
56
|
+
homepage: http://github.com/jistr/mobileesp_converted
|
57
|
+
licenses: []
|
58
|
+
post_install_message:
|
59
|
+
rdoc_options: []
|
60
|
+
require_paths:
|
61
|
+
- lib
|
62
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
63
|
+
none: false
|
64
|
+
requirements:
|
65
|
+
- - ! '>='
|
66
|
+
- !ruby/object:Gem::Version
|
67
|
+
version: '0'
|
68
|
+
segments:
|
69
|
+
- 0
|
70
|
+
hash: 3561921582123639498
|
71
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
72
|
+
none: false
|
73
|
+
requirements:
|
74
|
+
- - ! '>='
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
version: '0'
|
77
|
+
segments:
|
78
|
+
- 0
|
79
|
+
hash: 3561921582123639498
|
80
|
+
requirements: []
|
81
|
+
rubyforge_project:
|
82
|
+
rubygems_version: 1.8.11
|
83
|
+
signing_key:
|
84
|
+
specification_version: 3
|
85
|
+
summary: Provides device type detection based on HTTP request headers.
|
86
|
+
test_files: []
|