wurfl 1.3.1 → 1.3.5

Sign up to get free protection for your applications and to get access to all the features.
data/Examples.txt ADDED
@@ -0,0 +1,27 @@
1
+ First step to do anything is to merge the patch and the base wurfl
2
+ into a pstore database.
3
+
4
+ 1 Get latest wurfl base and unzip it
5
+
6
+ wget http://jaist.dl.sourceforge.net/sourceforge/wurfl/wurfl-latest.xml.gz
7
+ gunzip wurfl-latest.xml.gz
8
+
9
+ 2 Using the wurfltools.rb utility, merge the patch to the base wurfl
10
+ and output as a pstore database.
11
+
12
+ wurfltools.rb loader -f ./wurfl-latest.xml -e wurfl.patch.xml -d handsetpstore.db
13
+
14
+
15
+ Now we can perform various operations, such as output a csv file
16
+ containing japanese carrier handset uer agents and the supported flash
17
+ lite version.
18
+
19
+
20
+ wurfltools.rb inspector -d handsetpstore.db -s '{|h| puts
21
+ h.user_agent+","+h["flash_lite_version"] if ( h.actual_device=="true"
22
+ && h.user_agent =~/^(docomo|kddi|softbank)/i) }' | sort | uniq
23
+
24
+
25
+
26
+ Output browser width and height
27
+ ./bin/wurfltools.rb inspector -d handsetpstore-november.db -s '{|h| puts h["model_name"]+","+h["resolution_width"]+","+h["resolution_height"] if (h.actual_device && h.user_agent=~/^(docomo|kddi|softbank|voda)/i) }' | sort | uniq
data/README.rdoc CHANGED
@@ -156,6 +156,14 @@ errors.
156
156
  * Paul McMahon (gem installer, refactorings)
157
157
  * Kai W. Zimmermann (uamatch)
158
158
 
159
+ == Contribution
160
+
161
+ All contribution is welcome. Please see the repo at http://github.com/pwim/wurfl.
162
+
163
+ == License
164
+
165
+ See LICENSE[link:files/LICENSE.html]
166
+
159
167
  == Copyright
160
168
 
161
169
  Copyright (c) 2009, mobalean (http://www.mobalean.com/)
data/Rakefile CHANGED
@@ -1,6 +1,7 @@
1
1
  require 'rake/rdoctask'
2
2
  require 'rake/testtask'
3
3
  require 'rubygems'
4
+ require 'shoulda/tasks'
4
5
 
5
6
  task :default => ['test']
6
7
 
@@ -16,10 +17,13 @@ begin
16
17
  s.summary = "Library and tools for manipulating the WURFL"
17
18
  s.description = "Library and tools for manipulating the WURFL"
18
19
  s.email = "info@mobalean.com"
19
- s.homepage = "http://github.com/pwim/wurfl"
20
- s.description = "TODO"
20
+ s.homepage = "http://wurfl.rubyforge.org"
21
21
  s.authors = ["Paul McMahon", "Zev Blut"]
22
22
  s.rubyforge_project = 'wurfl'
23
+ s.add_dependency 'libxml-ruby'
24
+ end
25
+ Jeweler::RubyforgeTasks.new do |rubyforge|
26
+ rubyforge.doc_task = "rdoc"
23
27
  end
24
28
  rescue LoadError
25
29
  puts "Jeweler not available. Install it with: sudo gem install technicalpickles-jeweler -s http://gems.github.com"
@@ -29,32 +33,5 @@ Rake::RDocTask.new(:rdoc) do |rdoc|
29
33
  rdoc.rdoc_dir = 'rdoc'
30
34
  rdoc.title = 'WURFL'
31
35
  rdoc.main = "README.rdoc"
32
- rdoc.rdoc_files.include("README.rdoc", "lib/**/*.rb")
36
+ rdoc.rdoc_files.include("README.rdoc", "LICENSE", "lib/**/*.rb")
33
37
  end
34
-
35
- begin
36
- require 'rake/contrib/sshpublisher'
37
- namespace :rubyforge do
38
-
39
- desc "Release gem and RDoc documentation to RubyForge"
40
- task :release => ["rubyforge:release:gem", "rubyforge:release:docs"]
41
-
42
- namespace :release do
43
- desc "Publish RDoc to RubyForge."
44
- task :docs => [:rdoc] do
45
- config = YAML.load(
46
- File.read(File.expand_path('~/.rubyforge/user-config.yml'))
47
- )
48
-
49
- host = "#{config['username']}@rubyforge.org"
50
- remote_dir = "/var/www/gforge-projects/wurfl/"
51
- local_dir = 'rdoc'
52
-
53
- Rake::SshDirPublisher.new(host, remote_dir, local_dir).upload
54
- end
55
- end
56
- end
57
- rescue LoadError
58
- puts "Rake SshDirPublisher is unavailable or your rubyforge environment is not configured."
59
- end
60
-
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.3.1
1
+ 1.3.5
@@ -108,13 +108,13 @@ class Wurfl::Command::Inspector < Wurfl::Command
108
108
  eval("pr = proc#{procstr}")
109
109
 
110
110
  if pr.class != Proc
111
- puts "You must pass a valid ruby block!"
111
+ STDERR.puts "You must pass a valid ruby block!"
112
112
  exit 1
113
113
  end
114
114
 
115
- puts "--------- Searching handsets -----------"
115
+ STDERR.puts "--------- Searching handsets -----------"
116
116
  res = insp.search_handsets(pr)
117
- puts "Number of results: #{res.size}"
117
+ STDERR.puts "Number of results: #{res.size}"
118
118
 
119
119
  res.each { |handset| puts handset.wurfl_id }
120
120
  exit 0
@@ -130,14 +130,12 @@ class Wurfl::Command::Inspector < Wurfl::Command
130
130
  puts "Handset user agent: #{handset.user_agent}"
131
131
  if query
132
132
  puts "Result of handset query: #{query}"
133
- rez = handset.get_value_and_owner(query)
134
- puts "#{rez[0]} from #{rez[1]}"
133
+ puts "#{handset[query]} from #{handset.owner(query)}"
135
134
  else
136
135
  puts "Attributes of handset"
137
136
  keys = handset.keys
138
137
  keys.each do |key|
139
- rez = handset.get_value_and_owner(key)
140
- puts "Attr:#{key} Val:#{rez[0]} from #{rez[1]}"
138
+ puts "Attr:#{key} Val:#{handset[key]} from #{handset.owner(key)}"
141
139
  end
142
140
  end
143
141
  exit 0
@@ -11,7 +11,6 @@ class Wurfl::Command::Loader < Wurfl::Command
11
11
  puts "Usage: wurfltools.rb loader [-p -v -h -e patchfile] -f wurflfile"
12
12
  puts " --file, -f (wurflfile): The master WURFL file to load."
13
13
  puts " --extension, -e (patchfile): A patch file to extend the traits of the master WURLF file."
14
- puts " --print, -p : Prints out handsets."
15
14
  puts " --help, -h : Prints this message."
16
15
  puts " --database, -d (databasename): Makes a PStore database for quick loading of data with other tools."
17
16
  puts " --load, -l (databasename): Loads handsets from a PStore database instead of XML file."
@@ -28,7 +27,6 @@ class Wurfl::Command::Loader < Wurfl::Command
28
27
 
29
28
  begin
30
29
  options = GetoptLong.new(
31
- ["-p","--print", GetoptLong::NO_ARGUMENT],
32
30
  ["-h","--help", GetoptLong::NO_ARGUMENT],
33
31
  ["-f","--file", GetoptLong::REQUIRED_ARGUMENT],
34
32
  ["-e","--extension", GetoptLong::REQUIRED_ARGUMENT],
@@ -38,8 +36,6 @@ class Wurfl::Command::Loader < Wurfl::Command
38
36
 
39
37
  options.each do |opt,arg|
40
38
  case opt
41
- when "-p"
42
- print = true
43
39
  when "-h"
44
40
  usage
45
41
  exit 1
@@ -113,14 +109,5 @@ class Wurfl::Command::Loader < Wurfl::Command
113
109
  STDERR.puts err.message
114
110
  end
115
111
  end
116
-
117
- if print
118
- hands.each do |key,value|
119
- puts "********************************************\n\n"
120
- puts "#{key}\n"
121
- value.each { |key,value| puts "#{key} = #{value}" }
122
- end
123
- end
124
-
125
112
  end
126
113
  end
@@ -72,8 +72,7 @@ class Wurfl::Command::Uamatch < Wurfl::Command
72
72
  puts "User_agent found: #{handset.user_agent}"
73
73
  if query
74
74
  puts "Result of handset query: #{query}"
75
- rez = handset.get_value_and_owner(query)
76
- puts "#{rez[0]} from #{rez[1]}"
75
+ puts "#{handset[query]} from #{handset.owner(query)}"
77
76
  end
78
77
  end
79
78
  exit 0
data/lib/wurfl/handset.rb CHANGED
@@ -7,10 +7,8 @@ A class that represents a handset based on information taken from the WURFL.
7
7
  =end
8
8
  class Wurfl::Handset
9
9
 
10
- extend Enumerable
11
-
12
10
  attr_accessor :wurfl_id, :user_agent
13
- attr_reader :fallback
11
+ attr_writer :fallback
14
12
 
15
13
  # Constructor
16
14
  # Parameters:
@@ -18,16 +16,20 @@ class Wurfl::Handset
18
16
  # useragent: is the user agent of the handset
19
17
  # fallback: is the fallback handset that this handset
20
18
  # uses for missing details.
21
- def initialize (wurfl_id, useragent, fallback = nil)
22
- # A hash to hold keys and values specific to this handset
23
- @capabilityhash = Hash::new
19
+ def initialize (wurfl_id, useragent, fallback = nil, actual_device = nil)
20
+ @capabilities = {}
24
21
  @wurfl_id = wurfl_id
25
22
  @user_agent = useragent
26
- @fallback = fallback || NullHandset.instance
23
+ @actual_device = actual_device
24
+ @fallback = fallback
25
+ end
26
+
27
+ def actual_device?
28
+ @actual_device
27
29
  end
28
30
 
29
- def fallback=(v)
30
- @fallback = v || NullHandset.instance
31
+ def fallback
32
+ @fallback || NullHandset.instance
31
33
  end
32
34
 
33
35
  # Hash accessor
@@ -36,41 +38,24 @@ class Wurfl::Handset
36
38
  # Returns:
37
39
  # The value of the key, nil if the handset does not have the key.
38
40
  def [] (key)
39
- @capabilityhash.key?(key) ? @capabilityhash[key] : @fallback[key]
41
+ @capabilities.key?(key) ? @capabilities[key] : fallback[key]
40
42
  end
41
43
 
42
- # like the above accessor, but also to know who the value
43
- # comes from
44
44
  # Returns:
45
- # the value and the id of the handset from which the value was obtained
46
- def get_value_and_owner(key)
47
- if @capabilityhash.key?(key)
48
- [ @capabilityhash[key], @wurfl_id ]
49
- else
50
- @fallback.get_value_and_owner(key)
51
- end
45
+ # the wurfl id of the handset from which the value of a capability is
46
+ # obtained
47
+ def owner(key)
48
+ @capabilities.key?(key) ? @wurfl_id : fallback.owner(key)
52
49
  end
53
50
 
54
51
  # Setter, A method to set a key and value of the handset.
55
52
  def []= (key,val)
56
- @capabilityhash[key] = val
57
- end
58
-
59
- # A Method to iterate over all of the keys and values that the handset has.
60
- # Note: this will abstract the hash iterator to handle all the lower level
61
- # calls for the fallback values.
62
- def each
63
- self.keys.each do |key|
64
- # here is the magic that gives us the key and value of the handset
65
- # all the way up to the fallbacks end.
66
- # Call the pass block with the key and value passed
67
- yield key, self[key]
68
- end
53
+ @capabilities[key] = val
69
54
  end
70
55
 
71
56
  # A method to get all of the keys that the handset has.
72
57
  def keys
73
- @capabilityhash.keys | @fallback.keys
58
+ @capabilities.keys | fallback.keys
74
59
  end
75
60
 
76
61
  # A method to do a simple equality check against two handsets.
@@ -102,7 +87,7 @@ class Wurfl::Handset
102
87
  end
103
88
 
104
89
  def [](key) nil end
105
- def get_value_and_owner(key) [ nil, nil ] end
90
+ def owner(key) nil end
106
91
  def keys; [] end
107
92
  end
108
93
  end
data/lib/wurfl/loader.rb CHANGED
@@ -21,7 +21,7 @@ class Wurfl::Loader
21
21
  doc = XML::Document.file(wurflfilepath)
22
22
  doc.find("///devices/device").each do |element|
23
23
  wurfl_id = element.attributes["id"]
24
- h = @handsets[wurfl_id] ||= Wurfl::Handset.new(wurfl_id, element.attributes["user_agent"])
24
+ h = @handsets[wurfl_id] ||= Wurfl::Handset.new(wurfl_id, element.attributes["user_agent"], nil, element.attributes["actual_device_root"])
25
25
  fall_back_id = element.attributes["fall_back"]
26
26
  fallbacks[wurfl_id] = fall_back_id unless fall_back_id == "root"
27
27
 
data/test/benchmark.rb CHANGED
@@ -2,8 +2,10 @@ $LOAD_PATH << File.join(File.dirname(__FILE__), '..', 'lib')
2
2
  require 'wurfl/loader'
3
3
  require 'benchmark'
4
4
 
5
- loader = Wurfl::Loader.new
6
- r = Benchmark.measure do
7
- loader.load_wurfl(File.join(File.dirname(__FILE__), "data", "wurfl.large.xml"))
5
+ if $0 == __FILE__
6
+ loader = Wurfl::Loader.new
7
+ r = Benchmark.measure do
8
+ loader.load_wurfl(File.join(File.dirname(__FILE__), "data", "wurfl.large.xml"))
9
+ end
10
+ puts r
8
11
  end
9
- puts r
@@ -34,5 +34,22 @@
34
34
  <capability name="max_image_height" value="300"/>
35
35
  </group>
36
36
  </device>
37
+ <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">
38
+ <group id="product_info">
39
+ <capability name="mobile_browser" value="Safari"/>
40
+ <capability name="pointing_method" value="touchscreen"/>
41
+ <capability name="model_name" value="iPhone"/>
42
+ <capability name="device_os_version" value="1.0"/>
43
+ </group>
44
+ <group id="display">
45
+ <capability name="physical_screen_height" value="74"/>
46
+ <capability name="dual_orientation" value="true"/>
47
+ <capability name="physical_screen_width" value="49"/>
48
+ <capability name="max_image_width" value="320"/>
49
+ <capability name="resolution_height" value="480"/>
50
+ <capability name="resolution_width" value="320"/>
51
+ <capability name="max_image_height" value="360"/>
52
+ </group>
53
+ </device>
37
54
  </devices>
38
55
  </wurfl>
data/test/handset_test.rb CHANGED
@@ -1,87 +1,110 @@
1
- $LOAD_PATH << File.join(File.dirname(__FILE__), '..', 'lib')
1
+ require File.join(File.dirname(__FILE__), 'test_helper')
2
2
  require 'wurfl/handset'
3
- require 'test/unit'
4
3
 
5
- class TestHandset < Test::Unit::TestCase
4
+ class HandsetTest < Test::Unit::TestCase
6
5
  def setup
7
- @f = Wurfl::Handset.new("f", "f", nil)
8
- @h = Wurfl::Handset.new("h", "h", @f)
9
-
10
- @f2 = Wurfl::Handset.new("f2", "f2_ua", nil)
11
- @h2 = Wurfl::Handset.new("h2","h2_ua", @f2)
6
+ @fallback = Wurfl::Handset.new("fallback_id", "f", nil)
7
+ @handset = Wurfl::Handset.new("handset_id", "h", @fallback)
12
8
  end
13
9
 
14
- def test_f
15
- assert_nil @h["capability"]
16
- @f["k"] = "v"
17
- assert_equal "v", @h["k"]
18
- @h["k"] = nil
19
- assert_nil @h["k"]
20
- end
10
+ should("not be equal to nil") { assert_not_equal @handset, nil }
11
+ should("not be equal to 1") { assert_not_equal @handset, 1 }
12
+ should("not be equal to fallback") { assert_not_equal @handset, @fallback }
13
+ should("equal self") { assert_equal @handset, @handset }
14
+ should("not have differences") { assert @handset.differences(@fallback).empty? }
21
15
 
22
- def test_get_value_and_owner
23
- assert_equal [nil, nil], @h.get_value_and_owner("k")
24
- @f["k"] = "v"
25
- assert_equal ["v", "f"], @h.get_value_and_owner("k")
26
- @h["k"] = nil
27
- assert_equal [nil, "h"], @h.get_value_and_owner("k")
16
+ context "key not set" do
17
+ should("not have value") { assert_nil @handset["k"] }
18
+ should("not have owner") { assert_equal nil, @handset.owner("k") }
28
19
  end
29
20
 
30
- def test_keys
31
- @h["k1"] = "v1"
32
- @f["k2"] = "v2"
33
- assert_equal(["k1", "k2"], @h.keys)
34
- end
21
+ context "fallback key set" do
22
+ setup { @fallback["k"] = "v" }
35
23
 
36
- def test_each
37
- @h["k1"] = "v1"
38
- @f["k2"] = "v2"
39
- a = []
40
- @h.each {|k,v| a << [k,v]}
41
- assert_equal [["k1","v1"], ["k2","v2"]], a
42
- end
24
+ should("fetch value from fallback") { assert_equal "v", @handset["k"] }
25
+ should("have fallback as owner") { assert_equal "fallback_id", @handset.owner("k") }
43
26
 
44
- def test_equivalence
45
- assert @h != nil
46
- assert @h != 1
47
- assert @h != @f
48
- assert @h == @h
49
- h2 = Wurfl::Handset.new("h","h", @f)
50
- assert @h == h2
51
- h2["k"] = "v"
52
- assert @h != h2
53
- @f["k"] = "v"
54
- assert @h == h2
55
- end
27
+ context "and handset overwrites key" do
28
+ setup { @handset["k"] = nil }
56
29
 
57
- def test_differences_handset_with_unmodified_fallback
58
- assert @h.differences(@f).empty?
30
+ should("fetch value from handset") { assert_nil @handset["k"] }
31
+ should("have handset as owner") { assert_equal "handset_id", @handset.owner("k") }
32
+ end
59
33
  end
60
34
 
61
- def test_differences_handset_with_identical_handset
62
- assert @h.differences(@h2).empty?
63
- end
35
+ context "fallback and handset set different keys" do
36
+ setup do
37
+ @handset["k1"] = "v1"
38
+ @fallback["k2"] = "v2"
39
+ end
64
40
 
65
- def test_differences_handset_that_has_extra_key
66
- @h["k"] = "v"
67
- assert_equal ["k"], @h.differences(@h2)
41
+ should("have keys from handset and fallback") { assert_equal(["k1", "k2"], @handset.keys) }
68
42
  end
69
43
 
70
- def test_differences_other_handset_that_has_extra_key
71
- @h2["k"] = "v"
72
- assert_equal ["k"], @h.differences(@h2)
73
- end
44
+ context "another handset with same wurfl_id and fallback" do
45
+ setup { @another_handset = Wurfl::Handset.new("handset_id","h", @fallback) }
74
46
 
75
- def test_differences_handset_that_has_differing_key_value
76
- @h["k"] = "v"
77
- @h2["k"] = "v2"
78
- assert_equal ["k"], @h.differences(@h2)
79
- end
47
+ should("equal handset") { assert_equal @handset, @another_handset}
48
+
49
+ context "and the other handset sets a key" do
50
+ setup { @another_handset["k"] = "v" }
51
+
52
+ should("not equal handset") { assert_not_equal @handset, @another_handset }
53
+
54
+ context "and the fallback sets identical key" do
55
+ setup { @fallback["k"] = "v" }
80
56
 
81
- def test_differences_handsets_with_differening_fallback_key_value
82
- @f["j"] = "1"
83
- @f2["j"] = "2"
84
- assert_equal ["j"], @h.differences(@h2)
57
+ should("equal handset") { assert_equal @handset, @another_handset }
58
+ end
59
+ end
85
60
  end
61
+
62
+ context "another handset with different wurfl_id and fallback" do
63
+ setup do
64
+ @another_fallback = Wurfl::Handset.new("f2", "f2_ua", nil)
65
+ @another_handset = Wurfl::Handset.new("h2","h2_ua", @another_fallback)
66
+ end
86
67
 
68
+ context "and no keys set" do
69
+ should('have no differences') {assert @handset.differences(@another_fallback).empty? }
70
+ end
71
+
72
+ context "and the other handset has a key set" do
73
+ setup { @another_handset["k"] = "v" }
74
+
75
+ should('have the key as a difference') do
76
+ assert_equal ["k"], @handset.differences(@another_handset)
77
+ end
78
+ end
79
+
80
+ context "and handset has a key set" do
81
+ setup { @handset["k"] = "v" }
82
+
83
+ should('have the key as a difference') do
84
+ assert_equal ["k"], @handset.differences(@another_handset)
85
+ end
86
+ end
87
+
88
+ context "and both handsets have different values for same key" do
89
+ setup do
90
+ @handset["k"] = "v"
91
+ @another_handset["k"] = "v2"
92
+ end
93
+
94
+ should 'have the key as a difference' do
95
+ assert_equal ["k"], @handset.differences(@another_handset)
96
+ end
97
+ end
98
+
99
+ context "and fallbacks have different values for same key" do
100
+ setup do
101
+ @fallback["j"] = "1"
102
+ @another_fallback["j"] = "2"
103
+ end
104
+
105
+ should 'have the key as a difference' do
106
+ assert_equal ["j"], @handset.differences(@another_handset)
107
+ end
108
+ end
109
+ end
87
110
  end
data/test/loader_test.rb CHANGED
@@ -1,42 +1,71 @@
1
- $LOAD_PATH << File.join(File.dirname(__FILE__), '..', 'lib')
1
+ require File.join(File.dirname(__FILE__), 'test_helper')
2
2
  require 'wurfl/loader'
3
- require 'test/unit'
4
3
 
5
- class TestLoader < Test::Unit::TestCase
4
+ class LoaderTest < Test::Unit::TestCase
5
+
6
+ class << self
7
+ def should_have_correct_values(h)
8
+ h.each do |wurfl_id, values|
9
+ values.each do |key, value|
10
+ should "have #{key} set to #{value} for #{wurfl_id}" do
11
+ assert_equal value.to_s, @handsets[wurfl_id.to_s][key.to_s]
12
+ end
13
+ end
14
+ end
15
+ end
16
+
17
+ def should_have_correct_user_agents(h)
18
+ h.each do |wurfl_id, user_agent|
19
+ should "have user agent '#{user_agent}' for #{wurfl_id}" do
20
+ assert_equal user_agent, @handsets[wurfl_id.to_s].user_agent
21
+ end
22
+ end
23
+ end
24
+ end
6
25
 
7
26
  def setup
8
27
  @loader = Wurfl::Loader.new
9
28
  end
10
29
 
11
- def test_load_wurfl
12
- handsets = @loader.load_wurfl(File.join(File.dirname(__FILE__), "data", "wurfl.simple.xml"))
13
- assert_equal("20", handsets["apple_generic"]["columns"])
14
- assert_equal("11", handsets["generic_xhtml"]["columns"])
15
- assert_equal("11", handsets["generic"]["columns"])
16
-
17
- assert_equal("300", handsets["apple_generic"]["max_image_height"])
18
- assert_equal("92", handsets["generic_xhtml"]["max_image_height"])
19
- assert_equal("35", handsets["generic"]["max_image_height"])
30
+ context "loaded base wurfl" do
31
+ setup do
32
+ @handsets = @loader.load_wurfl(File.join(File.dirname(__FILE__), "data", "wurfl.simple.xml"))
33
+ end
34
+ should_have_correct_values(
35
+ :apple_generic => { :columns => 20, :max_image_height => 300, :physical_screen_height => 27 },
36
+ :generic_xhtml => { :columns => 11, :max_image_height => 92, :physical_screen_height => 27 },
37
+ :generic => { :columns => 11, :max_image_height => 35, :physical_screen_height => 27 }
38
+ )
39
+ should_have_correct_user_agents(
40
+ :generic => "",
41
+ :apple_generic => "Mozilla/5.0 (iPhone;",
42
+ :generic_xhtml => "Mozz"
43
+ )
20
44
 
21
- assert_equal("", handsets["generic"].user_agent)
45
+ context 'and patch' do
46
+ setup do
47
+ @handsets = @loader.load_wurfl(File.join(File.dirname(__FILE__), "data", "wurfl.generic.patch.xml"))
48
+ end
49
+ should_have_correct_values(:generic => { :columns => 200, :rows => 6 })
50
+ end
51
+ should("not be actual device for generic") { assert !@handsets["generic"].actual_device? }
52
+ should("be actual device for apple_iphone_ver1") { assert @handsets["apple_iphone_ver1"].actual_device? }
22
53
  end
23
54
 
24
- def test_patched_generic
25
- @loader.load_wurfl(File.join(File.dirname(__FILE__), "data", "wurfl.simple.xml"))
26
- handsets = @loader.load_wurfl(File.join(File.dirname(__FILE__), "data", "wurfl.generic.patch.xml"))
27
- assert_equal("200", handsets["generic"]["columns"])
28
- assert_equal("6", handsets["generic"]["rows"])
29
- end
30
-
31
- def test_load_reverse_wurfl
32
- handsets = @loader.load_wurfl(File.join(File.dirname(__FILE__), "data", "wurfl.reverse.xml"))
33
- assert_equal("27", handsets["apple_generic"]["physical_screen_height"])
34
- assert_equal("27", handsets["generic_xhtml"]["physical_screen_height"])
35
- assert_equal("27", handsets["generic"]["physical_screen_height"])
36
-
37
- assert_equal("Mozilla/5.0 (iPhone;", handsets["apple_generic"].user_agent)
38
- assert_equal("Mozz", handsets["generic_xhtml"].user_agent)
39
- assert_equal("", handsets["generic"].user_agent)
55
+ context "loaded wurfl with handsets in reverse order" do
56
+ setup do
57
+ @handsets = @loader.load_wurfl(File.join(File.dirname(__FILE__), "data", "wurfl.reverse.xml"))
58
+ end
59
+ should_have_correct_values(
60
+ :apple_generic => { :columns => 20, :max_image_height => 300, :physical_screen_height => 27 },
61
+ :generic_xhtml => { :columns => 11, :max_image_height => 92, :physical_screen_height => 27 },
62
+ :generic => { :columns => 11, :max_image_height => 35, :physical_screen_height => 27 }
63
+ )
64
+ should_have_correct_user_agents(
65
+ :generic => "",
66
+ :apple_generic => "Mozilla/5.0 (iPhone;",
67
+ :generic_xhtml => "Mozz"
68
+ )
40
69
  end
41
70
 
42
71
  end
@@ -0,0 +1,3 @@
1
+ $LOAD_PATH << File.join(File.dirname(__FILE__), '..', 'lib')
2
+ require 'test/unit'
3
+ require 'shoulda'
@@ -1,7 +1,6 @@
1
- $LOAD_PATH << File.join(File.dirname(__FILE__), '..', 'lib')
1
+ require File.join(File.dirname(__FILE__), 'test_helper')
2
2
  require 'wurfl/user_agent_matcher'
3
3
  require 'wurfl/loader'
4
- require 'test/unit'
5
4
 
6
5
  class UserAgentMatcherTest < Test::Unit::TestCase
7
6
  def setup
data/test/utils_test.rb CHANGED
@@ -1,7 +1,6 @@
1
- $LOAD_PATH << File.join(File.dirname(__FILE__), '..', 'lib')
1
+ require File.join(File.dirname(__FILE__), 'test_helper')
2
2
  require 'wurfl/utils'
3
3
  require 'wurfl/loader'
4
- require 'test/unit'
5
4
  require 'tempfile'
6
5
 
7
6
  class TestLoader < Test::Unit::TestCase
data/wurfl.gemspec CHANGED
@@ -1,14 +1,17 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run `rake gemspec`
1
4
  # -*- encoding: utf-8 -*-
2
5
 
3
6
  Gem::Specification.new do |s|
4
7
  s.name = %q{wurfl}
5
- s.version = "1.3.1"
8
+ s.version = "1.3.5"
6
9
 
7
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
8
11
  s.authors = ["Paul McMahon", "Zev Blut"]
9
- s.date = %q{2009-07-23}
12
+ s.date = %q{2010-03-18}
10
13
  s.default_executable = %q{wurfltools.rb}
11
- s.description = %q{TODO}
14
+ s.description = %q{Library and tools for manipulating the WURFL}
12
15
  s.email = %q{info@mobalean.com}
13
16
  s.executables = ["wurfltools.rb"]
14
17
  s.extra_rdoc_files = [
@@ -17,6 +20,7 @@ Gem::Specification.new do |s|
17
20
  ]
18
21
  s.files = [
19
22
  ".gitignore",
23
+ "Examples.txt",
20
24
  "LICENSE",
21
25
  "README.rdoc",
22
26
  "Rakefile",
@@ -41,32 +45,36 @@ Gem::Specification.new do |s|
41
45
  "test/data/wurfl.simple.xml",
42
46
  "test/handset_test.rb",
43
47
  "test/loader_test.rb",
48
+ "test/test_helper.rb",
44
49
  "test/user_agent_matcher_test.rb",
45
50
  "test/utils_test.rb",
46
51
  "wurfl.gemspec"
47
52
  ]
48
- s.has_rdoc = true
49
- s.homepage = %q{http://github.com/pwim/wurfl}
53
+ s.homepage = %q{http://wurfl.rubyforge.org}
50
54
  s.rdoc_options = ["--charset=UTF-8"]
51
55
  s.require_paths = ["lib"]
52
56
  s.rubyforge_project = %q{wurfl}
53
- s.rubygems_version = %q{1.3.1}
57
+ s.rubygems_version = %q{1.3.5}
54
58
  s.summary = %q{Library and tools for manipulating the WURFL}
55
59
  s.test_files = [
56
- "test/loader_test.rb",
60
+ "test/benchmark.rb",
57
61
  "test/handset_test.rb",
58
- "test/utils_test.rb",
62
+ "test/loader_test.rb",
63
+ "test/test_helper.rb",
59
64
  "test/user_agent_matcher_test.rb",
60
- "test/benchmark.rb"
65
+ "test/utils_test.rb"
61
66
  ]
62
67
 
63
68
  if s.respond_to? :specification_version then
64
69
  current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
65
- s.specification_version = 2
70
+ s.specification_version = 3
66
71
 
67
72
  if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
73
+ s.add_runtime_dependency(%q<libxml-ruby>, [">= 0"])
68
74
  else
75
+ s.add_dependency(%q<libxml-ruby>, [">= 0"])
69
76
  end
70
77
  else
78
+ s.add_dependency(%q<libxml-ruby>, [">= 0"])
71
79
  end
72
80
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: wurfl
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.1
4
+ version: 1.3.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Paul McMahon
@@ -10,11 +10,20 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2009-07-23 00:00:00 +09:00
13
+ date: 2010-03-18 00:00:00 +09:00
14
14
  default_executable: wurfltools.rb
15
- dependencies: []
16
-
17
- description: TODO
15
+ dependencies:
16
+ - !ruby/object:Gem::Dependency
17
+ name: libxml-ruby
18
+ type: :runtime
19
+ version_requirement:
20
+ version_requirements: !ruby/object:Gem::Requirement
21
+ requirements:
22
+ - - ">="
23
+ - !ruby/object:Gem::Version
24
+ version: "0"
25
+ version:
26
+ description: Library and tools for manipulating the WURFL
18
27
  email: info@mobalean.com
19
28
  executables:
20
29
  - wurfltools.rb
@@ -25,6 +34,7 @@ extra_rdoc_files:
25
34
  - README.rdoc
26
35
  files:
27
36
  - .gitignore
37
+ - Examples.txt
28
38
  - LICENSE
29
39
  - README.rdoc
30
40
  - Rakefile
@@ -49,11 +59,14 @@ files:
49
59
  - test/data/wurfl.simple.xml
50
60
  - test/handset_test.rb
51
61
  - test/loader_test.rb
62
+ - test/test_helper.rb
52
63
  - test/user_agent_matcher_test.rb
53
64
  - test/utils_test.rb
54
65
  - wurfl.gemspec
55
66
  has_rdoc: true
56
- homepage: http://github.com/pwim/wurfl
67
+ homepage: http://wurfl.rubyforge.org
68
+ licenses: []
69
+
57
70
  post_install_message:
58
71
  rdoc_options:
59
72
  - --charset=UTF-8
@@ -74,13 +87,14 @@ required_rubygems_version: !ruby/object:Gem::Requirement
74
87
  requirements: []
75
88
 
76
89
  rubyforge_project: wurfl
77
- rubygems_version: 1.3.1
90
+ rubygems_version: 1.3.5
78
91
  signing_key:
79
- specification_version: 2
92
+ specification_version: 3
80
93
  summary: Library and tools for manipulating the WURFL
81
94
  test_files:
82
- - test/loader_test.rb
95
+ - test/benchmark.rb
83
96
  - test/handset_test.rb
84
- - test/utils_test.rb
97
+ - test/loader_test.rb
98
+ - test/test_helper.rb
85
99
  - test/user_agent_matcher_test.rb
86
- - test/benchmark.rb
100
+ - test/utils_test.rb