wurfl 1.1.0 → 1.1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/lib/wurfl/command/comparator.rb +15 -13
- data/lib/wurfl/handset.rb +11 -6
- data/test/utils_test.rb +20 -0
- data/wurfl.gemspec +5 -3
- metadata +4 -2
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.1.
|
1
|
+
1.1.1
|
@@ -11,6 +11,19 @@ class Wurfl::Command::Comparator < Wurfl::Command
|
|
11
11
|
exit 1
|
12
12
|
end
|
13
13
|
|
14
|
+
def display_differences(hand1, hand2)
|
15
|
+
puts "-------------------------------------"
|
16
|
+
puts "Handset: #{hand1.user_agent} :ID: #{hand1.wurfl_id}"
|
17
|
+
hand1.keys.each do |key|
|
18
|
+
v1, v2 = hand1[key], hand2[key]
|
19
|
+
next if v1.nil? || v2.nil? || v1 == v2
|
20
|
+
puts "Key:#{key}"
|
21
|
+
puts "h1>:#{hand1[key]}"
|
22
|
+
puts "h2<:#{hand2[key]}"
|
23
|
+
end
|
24
|
+
puts "-------------------------------------"
|
25
|
+
end
|
26
|
+
|
14
27
|
def execute
|
15
28
|
if ARGV.size != 2
|
16
29
|
usage
|
@@ -49,7 +62,8 @@ class Wurfl::Command::Comparator < Wurfl::Command
|
|
49
62
|
mwurfl.each do |key,handset|
|
50
63
|
if lwurfl.key?(key)
|
51
64
|
if handset != lwurfl[key]
|
52
|
-
different<< [handset,lwurfl[key]]
|
65
|
+
different << [handset,lwurfl[key]]
|
66
|
+
display_differences(handset,lwurfl[key])
|
53
67
|
end
|
54
68
|
else
|
55
69
|
notfound<< handset
|
@@ -68,18 +82,6 @@ class Wurfl::Command::Comparator < Wurfl::Command
|
|
68
82
|
puts "Different handsets: #{different.size}"
|
69
83
|
puts "||||||||||||||||||||||||||||||||||||"
|
70
84
|
different = different.sort { |x,y| y.first.wurfl_id <=> x.first.wurfl_id }
|
71
|
-
different.each do |hand1,hand2|
|
72
|
-
puts "-------------------------------------"
|
73
|
-
puts "Handset: #{hand1.user_agent} :ID: #{hand1.wurfl_id}"
|
74
|
-
diffkeys = hand1.compare(hand2)
|
75
|
-
diffkeys.each do |key,oval,oid|
|
76
|
-
next if hand1[key].nil? || hand2[key].nil?
|
77
|
-
puts "Key:#{key}"
|
78
|
-
puts "h1>:#{hand1[key]}"
|
79
|
-
puts "h2<:#{hand2[key]}"
|
80
|
-
end
|
81
|
-
puts "-------------------------------------"
|
82
|
-
end
|
83
85
|
|
84
86
|
puts "||||||||||||||||||||||||||||||||||||"
|
85
87
|
end
|
data/lib/wurfl/handset.rb
CHANGED
@@ -80,12 +80,10 @@ class Wurfl::Handset
|
|
80
80
|
# false if they are not exactly equal in values, id and user agent.
|
81
81
|
# Note: for a more detailed comparison, use the compare method.
|
82
82
|
def ==(other)
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
end
|
88
|
-
true
|
83
|
+
other.instance_of?(Wurfl::Handset) &&
|
84
|
+
self.wurfl_id == other.wurfl_id &&
|
85
|
+
self.user_agent == other.user_agent &&
|
86
|
+
other.keys.all? {|key| other[key] == self[key] }
|
89
87
|
end
|
90
88
|
|
91
89
|
# A method to compare a handset's values against another handset.
|
@@ -110,6 +108,13 @@ class Wurfl::Handset
|
|
110
108
|
|
111
109
|
class NullHandset
|
112
110
|
include Singleton
|
111
|
+
|
112
|
+
# In ruby 1.8.6 and before, this method is not public, and thus prevents
|
113
|
+
# NullHandsets from being deserialized
|
114
|
+
class << self
|
115
|
+
public :_load
|
116
|
+
end
|
117
|
+
|
113
118
|
def [](key) nil end
|
114
119
|
def get_value_and_owner(key) [ nil, nil ] end
|
115
120
|
def keys; [] end
|
data/test/utils_test.rb
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
$LOAD_PATH << File.join(File.dirname(__FILE__), '..', 'lib')
|
2
|
+
require 'wurfl/utils'
|
3
|
+
require 'wurfl/loader'
|
4
|
+
require 'test/unit'
|
5
|
+
require 'tempfile'
|
6
|
+
|
7
|
+
class TestLoader < Test::Unit::TestCase
|
8
|
+
include Wurfl::Utils
|
9
|
+
|
10
|
+
def test_save_and_load_wurfl_pstore
|
11
|
+
loader = Wurfl::Loader.new
|
12
|
+
handsets, fallbacks = loader.load_wurfl(File.join(File.dirname(__FILE__), "data", "wurfl.simple.xml"))
|
13
|
+
tempfile = Tempfile.new("wurfl.pstore").path
|
14
|
+
save_wurfl_pstore(tempfile,handsets,fallbacks)
|
15
|
+
loaded_handsets, loaded_fallbacks = load_wurfl_pstore(tempfile)
|
16
|
+
assert_equal handsets, loaded_handsets
|
17
|
+
assert_equal fallbacks, loaded_fallbacks
|
18
|
+
end
|
19
|
+
|
20
|
+
end
|
data/wurfl.gemspec
CHANGED
@@ -2,11 +2,11 @@
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |s|
|
4
4
|
s.name = %q{wurfl}
|
5
|
-
s.version = "1.1.
|
5
|
+
s.version = "1.1.1"
|
6
6
|
|
7
7
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
8
8
|
s.authors = ["Paul McMahon", "Zev Blut"]
|
9
|
-
s.date = %q{2009-
|
9
|
+
s.date = %q{2009-07-11}
|
10
10
|
s.default_executable = %q{wurfltools.rb}
|
11
11
|
s.description = %q{TODO}
|
12
12
|
s.email = %q{info@mobalean.com}
|
@@ -36,6 +36,7 @@ Gem::Specification.new do |s|
|
|
36
36
|
"test/data/wurfl.simple.xml",
|
37
37
|
"test/handset_test.rb",
|
38
38
|
"test/loader_test.rb",
|
39
|
+
"test/utils_test.rb",
|
39
40
|
"wurfl.gemspec"
|
40
41
|
]
|
41
42
|
s.has_rdoc = true
|
@@ -46,7 +47,8 @@ Gem::Specification.new do |s|
|
|
46
47
|
s.rubygems_version = %q{1.3.1}
|
47
48
|
s.summary = %q{Library and tools for manipulating the WURFL}
|
48
49
|
s.test_files = [
|
49
|
-
"test/
|
50
|
+
"test/utils_test.rb",
|
51
|
+
"test/loader_test.rb",
|
50
52
|
"test/handset_test.rb"
|
51
53
|
]
|
52
54
|
|
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.1.
|
4
|
+
version: 1.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Paul McMahon
|
@@ -10,7 +10,7 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date: 2009-
|
13
|
+
date: 2009-07-11 00:00:00 +09:00
|
14
14
|
default_executable: wurfltools.rb
|
15
15
|
dependencies: []
|
16
16
|
|
@@ -44,6 +44,7 @@ files:
|
|
44
44
|
- test/data/wurfl.simple.xml
|
45
45
|
- test/handset_test.rb
|
46
46
|
- test/loader_test.rb
|
47
|
+
- test/utils_test.rb
|
47
48
|
- wurfl.gemspec
|
48
49
|
has_rdoc: true
|
49
50
|
homepage: http://github.com/pwim/wurfl
|
@@ -72,5 +73,6 @@ signing_key:
|
|
72
73
|
specification_version: 2
|
73
74
|
summary: Library and tools for manipulating the WURFL
|
74
75
|
test_files:
|
76
|
+
- test/utils_test.rb
|
75
77
|
- test/loader_test.rb
|
76
78
|
- test/handset_test.rb
|