wurfl_client 0.5.1 → 0.5.3
Sign up to get free protection for your applications and to get access to all the features.
- data/README +24 -12
- data/VERSION +1 -1
- data/examples/config.ru +26 -0
- data/test/data/wurfl-test.xml +58 -0
- data/wurfl_client.gemspec +3 -1
- metadata +4 -2
data/README
CHANGED
@@ -22,7 +22,7 @@ The WURFL Client can then be implemented f.i. as a thin Rack service, see Exampl
|
|
22
22
|
|
23
23
|
== Requirements
|
24
24
|
|
25
|
-
Ruby
|
25
|
+
Ruby Version supporting String.ord -> Possibly integrate http://gist.github.com/251465 as a fix
|
26
26
|
WURFL gem (http://github.com/pwim/wurfl): Handset, UserAgentMatcher, WURFL Loader
|
27
27
|
|
28
28
|
|
@@ -45,7 +45,7 @@ To setup the environment, you have to execute following steps:
|
|
45
45
|
|
46
46
|
3.) prepare the lookup tables (builds them into ./lookup directory by default). This will take some time!
|
47
47
|
|
48
|
-
|
48
|
+
wurfl_prepare_lookup.rb
|
49
49
|
|
50
50
|
Now, you are ready for device detection. If you make an automated script to do this update regularly, you must not forget to clear the lookup directory first.
|
51
51
|
The preparation script doesn't overwrite files. For minimal effect on your running webservice, you should use another lookup directory there and copy the
|
@@ -58,7 +58,7 @@ Here is an example automatic update script:
|
|
58
58
|
gunzip wurfl-latest.xml.gz
|
59
59
|
wurfl_minimize.rb
|
60
60
|
rm lookup/*
|
61
|
-
|
61
|
+
wurfl_prepare_lookup.rb
|
62
62
|
cp lookup/* /path/to/production/lookup
|
63
63
|
|
64
64
|
|
@@ -73,27 +73,39 @@ The device detection is as simple as this call:
|
|
73
73
|
|
74
74
|
puts "DEVICE: #{hs["brand_name"]} #{hs["model_name"]}"
|
75
75
|
|
76
|
-
You can easily put the WURFL detection into a Rack (http://rack.rubyforge.org/) middleware.
|
77
|
-
Using following 'config.ru', you can put this online using 'rackup'
|
76
|
+
You can easily put the WURFL detection into a Rack (http://rack.rubyforge.org/) middleware. I chose to output the data in JSON format.
|
77
|
+
Using following 'config.ru', you can put this online using 'rackup'.
|
78
78
|
|
79
79
|
require "wurfl_client"
|
80
80
|
|
81
81
|
class RackInterface
|
82
|
-
|
82
|
+
|
83
|
+
def getJSON(handset)
|
84
|
+
result = %Q{"WURFL-Client":1}
|
85
|
+
if handset
|
86
|
+
handset.keys.each do |key|
|
87
|
+
result << %Q{,"#{key}":"#{handset[key]}"}
|
88
|
+
end
|
89
|
+
end
|
90
|
+
"{#{result}}"
|
91
|
+
end
|
92
|
+
|
83
93
|
def call(env)
|
84
94
|
user_agent = env["HTTP_USER_AGENT"]
|
85
95
|
|
86
96
|
hs = WurflClient.detectMobileDevice(user_agent)
|
87
|
-
|
88
|
-
|
89
|
-
[200, {"Content-Type" => "text/plain"}, ["#{hsinfo}"] ]
|
97
|
+
|
98
|
+
[200, {"Content-Type" => "text/javascript"}, ["#{getJSON(hs)}"] ]
|
90
99
|
end
|
91
|
-
|
100
|
+
|
92
101
|
end
|
93
|
-
|
102
|
+
|
94
103
|
run RackInterface.new
|
95
104
|
|
96
|
-
|
105
|
+
Test by opening f.i. http://localhost:9292/. You should see the response
|
106
|
+
{"WURFL-Client":1}
|
107
|
+
|
108
|
+
You can get results for mobile devices by using the UserAgentSwitcher Firefox extension (http://chrispederick.com/work/user-agent-switcher/).
|
97
109
|
This can be further extended by a caching mechanism to reduce the server load. Being a Rack layer, it should
|
98
110
|
also be possible to integrate this into a rails app. If you know, how to do so, I would really appreciate your
|
99
111
|
contribution.
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.5.
|
1
|
+
0.5.3
|
data/examples/config.ru
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
# this script needs the lookup folder to be set up!
|
2
|
+
require "wurfl_client"
|
3
|
+
|
4
|
+
class RackInterface
|
5
|
+
|
6
|
+
def getJSON(handset)
|
7
|
+
result = %Q{"WURFL-Client":1}
|
8
|
+
if handset
|
9
|
+
handset.keys.each do |key|
|
10
|
+
result << %Q{,"#{key}":"#{handset[key]}"}
|
11
|
+
end
|
12
|
+
end
|
13
|
+
"{#{result}}"
|
14
|
+
end
|
15
|
+
|
16
|
+
def call(env)
|
17
|
+
user_agent = env["HTTP_USER_AGENT"]
|
18
|
+
|
19
|
+
hs = WurflClient.detectMobileDevice(user_agent)
|
20
|
+
|
21
|
+
[200, {"Content-Type" => "text/javascript"}, ["#{getJSON(hs)}"] ]
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
25
|
+
|
26
|
+
run RackInterface.new
|
@@ -0,0 +1,58 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
+
<wurfl>
|
3
|
+
<version>
|
4
|
+
<ver>Test Version</ver>
|
5
|
+
</version>
|
6
|
+
<devices>
|
7
|
+
<device id="generic" user_agent="" fall_back="root">
|
8
|
+
<group id="display">
|
9
|
+
<capability name="physical_screen_height" value="27"/>
|
10
|
+
<capability name="columns" value="11"/>
|
11
|
+
<capability name="physical_screen_width" value="27"/>
|
12
|
+
<capability name="rows" value="6"/>
|
13
|
+
<capability name="max_image_width" value="90"/>
|
14
|
+
<capability name="resolution_height" value="40"/>
|
15
|
+
<capability name="resolution_width" value="90"/>
|
16
|
+
<capability name="max_image_height" value="35"/>
|
17
|
+
</group>
|
18
|
+
</device>
|
19
|
+
<device id="generic_xhtml" user_agent="Mozz" fall_back="generic">
|
20
|
+
<group id="display">
|
21
|
+
<capability name="max_image_width" value="120"/>
|
22
|
+
<capability name="resolution_height" value="92"/>
|
23
|
+
<capability name="resolution_width" value="128"/>
|
24
|
+
<capability name="max_image_height" value="92"/>
|
25
|
+
</group>
|
26
|
+
<group id="product_info">
|
27
|
+
<capability name="mobile_browser" value="Safari"/>
|
28
|
+
</group>
|
29
|
+
</device>
|
30
|
+
<device id="apple_generic" user_agent="Mozilla/5.0 (iPhone;" fall_back="generic_xhtml">
|
31
|
+
<group id="display">
|
32
|
+
<capability name="columns" value="20"/>
|
33
|
+
<capability name="max_image_width" value="300"/>
|
34
|
+
<capability name="rows" value="20"/>
|
35
|
+
<capability name="resolution_width" value="300"/>
|
36
|
+
<capability name="resolution_height" value="300"/>
|
37
|
+
<capability name="max_image_height" value="300"/>
|
38
|
+
</group>
|
39
|
+
</device>
|
40
|
+
<device id="apple_iphone_ver1" user_agent="Mozilla/5.0 (iPhone; U; CPU like Mac OS X; en) AppleWebKit/420+ (KHTML, like Gecko) Version/3.0 Mobile/1A538a Safari/419.3" fall_back="apple_generic" actual_device_root="true">
|
41
|
+
<group id="product_info">
|
42
|
+
<capability name="mobile_browser" value="Safari"/>
|
43
|
+
<capability name="pointing_method" value="touchscreen"/>
|
44
|
+
<capability name="model_name" value="iPhone"/>
|
45
|
+
<capability name="device_os_version" value="1.0"/>
|
46
|
+
</group>
|
47
|
+
<group id="display">
|
48
|
+
<capability name="physical_screen_height" value="74"/>
|
49
|
+
<capability name="dual_orientation" value="true"/>
|
50
|
+
<capability name="physical_screen_width" value="49"/>
|
51
|
+
<capability name="max_image_width" value="320"/>
|
52
|
+
<capability name="resolution_height" value="480"/>
|
53
|
+
<capability name="resolution_width" value="320"/>
|
54
|
+
<capability name="max_image_height" value="360"/>
|
55
|
+
</group>
|
56
|
+
</device>
|
57
|
+
</devices>
|
58
|
+
</wurfl>
|
data/wurfl_client.gemspec
CHANGED
@@ -5,7 +5,7 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{wurfl_client}
|
8
|
-
s.version = "0.5.
|
8
|
+
s.version = "0.5.3"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Guido Pinkas"]
|
@@ -23,12 +23,14 @@ Gem::Specification.new do |s|
|
|
23
23
|
"VERSION",
|
24
24
|
"bin/wurfl_minimize.rb",
|
25
25
|
"bin/wurfl_prepare_lookup.rb",
|
26
|
+
"examples/config.ru",
|
26
27
|
"lib/wurfl_client.rb",
|
27
28
|
"lib/wurfl_client/device_profile.rb",
|
28
29
|
"lib/wurfl_client/lookup_helper.rb",
|
29
30
|
"lib/wurfl_client/lookup_preparer.rb",
|
30
31
|
"lib/wurfl_client/ua_device_detector.rb",
|
31
32
|
"test/data/iphone.pstore",
|
33
|
+
"test/data/wurfl-test.xml",
|
32
34
|
"test/device_profile_test.rb",
|
33
35
|
"test/lookup_helper_test.rb",
|
34
36
|
"test/ua_device_detector_test.rb",
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 5
|
8
|
-
-
|
9
|
-
version: 0.5.
|
8
|
+
- 3
|
9
|
+
version: 0.5.3
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Guido Pinkas
|
@@ -48,12 +48,14 @@ files:
|
|
48
48
|
- VERSION
|
49
49
|
- bin/wurfl_minimize.rb
|
50
50
|
- bin/wurfl_prepare_lookup.rb
|
51
|
+
- examples/config.ru
|
51
52
|
- lib/wurfl_client.rb
|
52
53
|
- lib/wurfl_client/device_profile.rb
|
53
54
|
- lib/wurfl_client/lookup_helper.rb
|
54
55
|
- lib/wurfl_client/lookup_preparer.rb
|
55
56
|
- lib/wurfl_client/ua_device_detector.rb
|
56
57
|
- test/data/iphone.pstore
|
58
|
+
- test/data/wurfl-test.xml
|
57
59
|
- test/device_profile_test.rb
|
58
60
|
- test/lookup_helper_test.rb
|
59
61
|
- test/ua_device_detector_test.rb
|