wurfl_client 0.4.0 → 0.5.1

Sign up to get free protection for your applications and to get access to all the features.
data/README CHANGED
@@ -22,45 +22,83 @@ 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 1.9: (.ord!) -> http://gist.github.com/251465
26
- wurfl gem (http://github.com/pwim/wurfl): Handset, UserAgentMatcher, WURFL Loader
25
+ Ruby 1.9: (.ord!) -> Possibly integrate http://gist.github.com/251465 as a fix
26
+ WURFL gem (http://github.com/pwim/wurfl): Handset, UserAgentMatcher, WURFL Loader
27
+
27
28
 
28
29
  == Installation
29
30
 
30
- sudo gem install wurfl_client
31
+ sudo gem install wurfl_client
32
+
31
33
 
32
34
  == Setup
33
35
 
34
36
  To setup the environment, you have to execute following steps:
35
37
  1.) download and extract the latest WURFL file
36
- * curl -L -o wurfl-latest.xml.gz
37
- * gunzip wurfl-latest.xml.gz
38
+
39
+ curl -L -o wurfl-latest.xml.gz
40
+ gunzip wurfl-latest.xml.gz
38
41
 
39
42
  2.) minimize the WURFL XML file. You can adapt wurfl_minimize.yml to your needs, see http://wurfl.sourceforge.net/help_doc.php for a list of available capabilities)
40
- * wurfl_minimize.rb
41
43
 
44
+ wurfl_minimize.rb
45
+
42
46
  3.) prepare the lookup tables (builds them into ./lookup directory by default). This will take some time!
43
- * lookup_prepare.rb
47
+
48
+ lookup_prepare.rb
44
49
 
45
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.
46
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
47
52
  new data after the update is complete.
48
53
 
49
54
  Here is an example automatic update script:
50
- * #!/bin/sh
51
- * curl -L -o wurfl-latest.xml.gz
52
- * gunzip wurfl-latest.xml.gz
53
- * wurfl_minimize.rb
54
- * rm lookup/*
55
- * lookup_prepare.rb
56
- * cp lookup/* /path/to/production/lookup
57
55
 
58
- == Examples
56
+ #!/bin/sh
57
+ curl -L -o wurfl-latest.xml.gz
58
+ gunzip wurfl-latest.xml.gz
59
+ wurfl_minimize.rb
60
+ rm lookup/*
61
+ lookup_prepare.rb
62
+ cp lookup/* /path/to/production/lookup
63
+
59
64
 
60
- TODO: simple detection example
61
- TODO: rack application
65
+ == Examples
62
66
 
63
- == Authors
67
+ The device detection is as simple as this call:
68
+
69
+ require "wurfl_client"
70
+
71
+ user_agent = 'Mozilla/5.0 (iPhone; U; CPU iPhone like Mac OS X; en-us)'
72
+ device = WurflClient::detectMobileDevice(user_agent)
73
+
74
+ puts "DEVICE: #{hs["brand_name"]} #{hs["model_name"]}"
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':
78
+
79
+ require "wurfl_client"
80
+
81
+ class RackInterface
82
+
83
+ def call(env)
84
+ user_agent = env["HTTP_USER_AGENT"]
85
+
86
+ hs = WurflClient.detectMobileDevice(user_agent)
87
+ hsinfo = flash.collect { |k, v| "#{k}: #{v};" }.join
88
+
89
+ [200, {"Content-Type" => "text/plain"}, ["#{hsinfo}"] ]
90
+ end
91
+
92
+ end
93
+
94
+ run RackInterface.new
95
+
96
+
97
+ This can be further extended by a caching mechanism to reduce the server load. Being a Rack layer, it should
98
+ also be possible to integrate this into a rails app. If you know, how to do so, I would really appreciate your
99
+ contribution.
100
+
101
+ == Author
64
102
 
65
103
  * Guido Pinkas (Original Author)
66
104
 
data/Rakefile CHANGED
@@ -17,7 +17,7 @@ begin
17
17
  gemspec.email = "guido.pinkas@bindertrittenwein.com"
18
18
  gemspec.homepage = "http://github.com/bluecat76/wurfl_client"
19
19
  gemspec.authors = ["Guido Pinkas"]
20
- gemspec.add_dependency 'wurfl'
20
+ gemspec.add_dependency 'wurfl', '>=1.3.6'
21
21
  end
22
22
  Jeweler::GemcutterTasks.new
23
23
  rescue LoadError
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.4.0
1
+ 0.5.1
File without changes
Binary file
@@ -1,6 +1,6 @@
1
1
  $LOAD_PATH << File.join(File.dirname(__FILE__), '..', 'lib')
2
2
  require 'test/unit'
3
- require 'wurfl_client/wurfl_client'
3
+ require 'wurfl_client'
4
4
 
5
5
  class WurflClientTest < Test::Unit::TestCase
6
6
  def setup
data/wurfl_client.gemspec CHANGED
@@ -5,14 +5,14 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{wurfl_client}
8
- s.version = "0.4.0"
8
+ s.version = "0.5.1"
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"]
12
- s.date = %q{2010-09-27}
12
+ s.date = %q{2010-09-28}
13
13
  s.description = %q{WURFL Client is a library to do WURFL (http://wurfl.sourceforge.net/) mobile device detection for web applications. Included are tools to keep the WURFL file up to date automatically and to prepare a customized lookup tables, which allow a fast device detection.}
14
14
  s.email = %q{guido.pinkas@bindertrittenwein.com}
15
- s.executables = ["prepare_lookup.rb", "wurfl_minimize.rb"]
15
+ s.executables = ["wurfl_minimize.rb", "wurfl_prepare_lookup.rb"]
16
16
  s.extra_rdoc_files = [
17
17
  "README"
18
18
  ]
@@ -21,14 +21,18 @@ Gem::Specification.new do |s|
21
21
  "README",
22
22
  "Rakefile",
23
23
  "VERSION",
24
- "bin/prepare_lookup.rb",
25
24
  "bin/wurfl_minimize.rb",
25
+ "bin/wurfl_prepare_lookup.rb",
26
+ "lib/wurfl_client.rb",
26
27
  "lib/wurfl_client/device_profile.rb",
27
28
  "lib/wurfl_client/lookup_helper.rb",
28
29
  "lib/wurfl_client/lookup_preparer.rb",
29
30
  "lib/wurfl_client/ua_device_detector.rb",
30
- "lib/wurfl_client/wurfl_client.rb",
31
+ "test/data/iphone.pstore",
31
32
  "test/device_profile_test.rb",
33
+ "test/lookup_helper_test.rb",
34
+ "test/ua_device_detector_test.rb",
35
+ "test/wurfl_client_test.rb",
32
36
  "wurfl_client.gemspec"
33
37
  ]
34
38
  s.homepage = %q{http://github.com/bluecat76/wurfl_client}
@@ -48,12 +52,12 @@ Gem::Specification.new do |s|
48
52
  s.specification_version = 3
49
53
 
50
54
  if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
51
- s.add_runtime_dependency(%q<wurfl>, [">= 0"])
55
+ s.add_runtime_dependency(%q<wurfl>, [">= 1.3.6"])
52
56
  else
53
- s.add_dependency(%q<wurfl>, [">= 0"])
57
+ s.add_dependency(%q<wurfl>, [">= 1.3.6"])
54
58
  end
55
59
  else
56
- s.add_dependency(%q<wurfl>, [">= 0"])
60
+ s.add_dependency(%q<wurfl>, [">= 1.3.6"])
57
61
  end
58
62
  end
59
63
 
metadata CHANGED
@@ -4,9 +4,9 @@ version: !ruby/object:Gem::Version
4
4
  prerelease: false
5
5
  segments:
6
6
  - 0
7
- - 4
8
- - 0
9
- version: 0.4.0
7
+ - 5
8
+ - 1
9
+ version: 0.5.1
10
10
  platform: ruby
11
11
  authors:
12
12
  - Guido Pinkas
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-09-27 00:00:00 +02:00
17
+ date: 2010-09-28 00:00:00 +02:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
@@ -26,15 +26,17 @@ dependencies:
26
26
  - - ">="
27
27
  - !ruby/object:Gem::Version
28
28
  segments:
29
- - 0
30
- version: "0"
29
+ - 1
30
+ - 3
31
+ - 6
32
+ version: 1.3.6
31
33
  type: :runtime
32
34
  version_requirements: *id001
33
35
  description: WURFL Client is a library to do WURFL (http://wurfl.sourceforge.net/) mobile device detection for web applications. Included are tools to keep the WURFL file up to date automatically and to prepare a customized lookup tables, which allow a fast device detection.
34
36
  email: guido.pinkas@bindertrittenwein.com
35
37
  executables:
36
- - prepare_lookup.rb
37
38
  - wurfl_minimize.rb
39
+ - wurfl_prepare_lookup.rb
38
40
  extensions: []
39
41
 
40
42
  extra_rdoc_files:
@@ -44,18 +46,19 @@ files:
44
46
  - README
45
47
  - Rakefile
46
48
  - VERSION
47
- - bin/prepare_lookup.rb
48
49
  - bin/wurfl_minimize.rb
50
+ - bin/wurfl_prepare_lookup.rb
51
+ - lib/wurfl_client.rb
49
52
  - lib/wurfl_client/device_profile.rb
50
53
  - lib/wurfl_client/lookup_helper.rb
51
54
  - lib/wurfl_client/lookup_preparer.rb
52
55
  - lib/wurfl_client/ua_device_detector.rb
53
- - lib/wurfl_client/wurfl_client.rb
56
+ - test/data/iphone.pstore
54
57
  - test/device_profile_test.rb
55
- - wurfl_client.gemspec
56
58
  - test/lookup_helper_test.rb
57
- - test/wurfl_client_test.rb
58
59
  - test/ua_device_detector_test.rb
60
+ - test/wurfl_client_test.rb
61
+ - wurfl_client.gemspec
59
62
  has_rdoc: true
60
63
  homepage: http://github.com/bluecat76/wurfl_client
61
64
  licenses: []